feat(gate): buildSchemaLinkingRequest descriptor builder

This commit is contained in:
2026-07-06 23:25:00 +02:00
committed by Marco Pancotti
parent 00365cc6e6
commit 559f52e26e
2 changed files with 31 additions and 0 deletions
@@ -15,6 +15,7 @@ const {
buildArtifactGate,
buildInfoRequest,
buildFreetextRequest,
buildSchemaLinkingRequest,
withChildLinkage,
} = require("../builders.js");
@@ -118,6 +119,17 @@ test("freetext request carries a title and no options", () => {
assert.deepEqual(result.reserved, ["back", "exit", "other"]);
});
test("buildSchemaLinkingRequest carries tables + reserved", () => {
const out = buildSchemaLinkingRequest({
id: "u7", phase: "F4", title: "F4 — Schema linking",
tables: [{ id: "t1", name: "dim_patient", kind: "promote", columns: [] }],
});
assert.equal(out.widget, "schema-linking");
assert.equal(out.id, "u7");
assert.equal(out.tables.length, 1);
assert.deepEqual(out.reserved, ["back", "exit", "other"]);
});
test("withChildLinkage sets option.opens and returns the option", () => {
const child = { widget: "freetext", title: "Motivazione del rifiuto" };
const option = withChildLinkage({ id: "reject", label: "Rifiuta" }, child);
+19
View File
@@ -156,6 +156,24 @@ function buildFreetextRequest({ id, phase, title }) {
};
}
// Build a `schema-linking` ui_request: table rows (promote/exclude) each carrying
// their full catalog columns; the frontend renders rows + a per-table columns
// modal (suggested pre-selected). `tables` is validated shallowly here.
function buildSchemaLinkingRequest({ id, phase, title, tables }) {
requireString(title, "title", "schema-linking");
const tabs = requireArray(tables, "tables", "schema-linking");
return {
type: "ui_request",
id,
phase,
schema_version: SCHEMA_VERSION,
widget: "schema-linking",
title,
tables: [...tabs],
reserved: RESERVED,
};
}
// Attach a child-widget spec to an option (linkage, §4.2). Returns the option.
function withChildLinkage(option, widgetSpec) {
option.opens = widgetSpec;
@@ -168,6 +186,7 @@ module.exports = {
buildArtifactGate,
buildInfoRequest,
buildFreetextRequest,
buildSchemaLinkingRequest,
withChildLinkage,
SCHEMA_VERSION,
RESERVED,