feat(gate): buildSchemaLinkingRequest descriptor builder
This commit is contained in:
@@ -15,6 +15,7 @@ const {
|
|||||||
buildArtifactGate,
|
buildArtifactGate,
|
||||||
buildInfoRequest,
|
buildInfoRequest,
|
||||||
buildFreetextRequest,
|
buildFreetextRequest,
|
||||||
|
buildSchemaLinkingRequest,
|
||||||
withChildLinkage,
|
withChildLinkage,
|
||||||
} = require("../builders.js");
|
} = require("../builders.js");
|
||||||
|
|
||||||
@@ -118,6 +119,17 @@ test("freetext request carries a title and no options", () => {
|
|||||||
assert.deepEqual(result.reserved, ["back", "exit", "other"]);
|
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", () => {
|
test("withChildLinkage sets option.opens and returns the option", () => {
|
||||||
const child = { widget: "freetext", title: "Motivazione del rifiuto" };
|
const child = { widget: "freetext", title: "Motivazione del rifiuto" };
|
||||||
const option = withChildLinkage({ id: "reject", label: "Rifiuta" }, child);
|
const option = withChildLinkage({ id: "reject", label: "Rifiuta" }, child);
|
||||||
|
|||||||
@@ -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.
|
// Attach a child-widget spec to an option (linkage, §4.2). Returns the option.
|
||||||
function withChildLinkage(option, widgetSpec) {
|
function withChildLinkage(option, widgetSpec) {
|
||||||
option.opens = widgetSpec;
|
option.opens = widgetSpec;
|
||||||
@@ -168,6 +186,7 @@ module.exports = {
|
|||||||
buildArtifactGate,
|
buildArtifactGate,
|
||||||
buildInfoRequest,
|
buildInfoRequest,
|
||||||
buildFreetextRequest,
|
buildFreetextRequest,
|
||||||
|
buildSchemaLinkingRequest,
|
||||||
withChildLinkage,
|
withChildLinkage,
|
||||||
SCHEMA_VERSION,
|
SCHEMA_VERSION,
|
||||||
RESERVED,
|
RESERVED,
|
||||||
|
|||||||
Reference in New Issue
Block a user