36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
// Rewrite replay gate F4 "tabelle/colonne/esclusioni" as a `schema-linking`
|
|
// descriptor carrying the real catalog columns (schema-linking-fixture.json),
|
|
// so the SchemaLinkingGateWidget renders in replay. Run after editing the
|
|
// fixture: node tools/replay/augment-schema-linking.mjs
|
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, join } from "node:path";
|
|
|
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
const replayPath = join(HERE, "replay.json");
|
|
const replay = JSON.parse(readFileSync(replayPath, "utf8"));
|
|
const tables = JSON.parse(readFileSync(join(HERE, "schema-linking-fixture.json"), "utf8"));
|
|
|
|
const idx = replay.gates.findIndex(
|
|
(g) =>
|
|
/tabelle\/colonne\/esclusioni/.test(g.descriptor?.title ?? "") &&
|
|
(g.descriptor?.widget === "multiselect" || g.descriptor?.widget === "schema-linking")
|
|
);
|
|
if (idx < 0) {
|
|
console.error("F4 tables gate not found in replay.json");
|
|
process.exit(1);
|
|
}
|
|
const d = replay.gates[idx].descriptor;
|
|
replay.gates[idx].descriptor = {
|
|
type: "ui_request",
|
|
id: d.id,
|
|
phase: d.phase,
|
|
schema_version: d.schema_version,
|
|
widget: "schema-linking",
|
|
title: d.title,
|
|
tables,
|
|
reserved: ["back", "exit", "other"],
|
|
};
|
|
writeFileSync(replayPath, JSON.stringify(replay, null, 2) + "\n");
|
|
console.log(`Rewrote gate ${idx} -> schema-linking (${tables.length} tables)`);
|