@homepages/concrete 9.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +2 -2
- package/codemods/manifest.json +4 -0
- package/dist/artifact/playground/client/assets/index-BOYbgBnP.js +1259 -0
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +24 -24
- package/dist/cli/check/stages/workspace.js +2 -0
- package/dist/cli/check/template-key.js +16 -0
- package/dist/fixtures/resolve.js +4 -7
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +8 -22
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +4 -8
- package/dist/packages/internal/fill-bake/dist/derive-source.js +7 -14
- package/dist/packages/internal/fill-bake/dist/index.js +3 -2
- package/dist/packages/internal/fill-bake/dist/item-merge.js +4 -10
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -28
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +1 -3
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +10 -11
- package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +11 -38
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +2 -17
- package/dist/packages/internal/media-resolution/dist/image.js +6 -8
- package/dist/packages/internal/media-resolution/dist/list.js +1 -1
- package/dist/packages/internal/media-resolution/dist/slot.js +4 -1
- package/dist/packages/internal/media-resolution/dist/tour.js +1 -1
- package/dist/packages/internal/media-resolution/dist/video.js +1 -1
- package/dist/packages/internal/property-facts/dist/registry-facts.js +2 -1
- package/dist/packages/internal/section-contracts/dist/catalog.js +1 -5
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +4 -10
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +2 -2
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +1 -1
- package/dist/packages/internal/section-contracts/dist/index.js +0 -1
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +0 -29
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +2 -16
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +6 -6
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +6 -2
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +0 -14
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +3 -6
- package/dist/packages/internal/section-contracts/dist/runners.js +4 -9
- package/dist/packages/internal/section-contracts/dist/source-contract.js +10 -73
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +5 -10
- package/dist/packages/internal/source-resolution/dist/index.js +7 -8
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +2 -6
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +4 -4
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +3 -68
- package/dist/packages/internal/template-contracts/dist/list-editing.js +0 -1
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +1 -1
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +2 -2
- package/dist/packages/internal/template-contracts/dist/read-graph.js +9 -19
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +8 -24
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +2 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +2 -8
- package/dist/packages/internal/template-contracts/dist/row-sources.js +3 -13
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1 -32
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +0 -4
- package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -2
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +7 -9
- package/dist/primitives/slot-bindings.js +2 -2
- package/dist/rules/registry.js +6 -0
- package/dist/section/section.d.ts +2 -2
- package/guide/reference/rules/INDEX.md +2 -2
- package/package.json +1 -1
- package/dist/artifact/playground/client/assets/index-BUmdDDX5.js +0 -1259
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
- package/dist/packages/internal/section-contracts/dist/group-contract.js +0 -19
|
@@ -19,7 +19,7 @@ async function resolveVideoSlot(value, assets, store) {
|
|
|
19
19
|
if (value === null) return null;
|
|
20
20
|
if (typeof value !== "object") return DEFAULT;
|
|
21
21
|
const v = value;
|
|
22
|
-
const videoId = typeof v.
|
|
22
|
+
const videoId = typeof v.asset_id === "string" ? v.asset_id : "";
|
|
23
23
|
if (!videoId) return DEFAULT;
|
|
24
24
|
const asset = assets.get(videoId);
|
|
25
25
|
if (asset === void 0) {
|
|
@@ -20,7 +20,8 @@ const CropSchema = z.object({
|
|
|
20
20
|
}).strict();
|
|
21
21
|
const RenditionInputsSchema = z.object({
|
|
22
22
|
crop: CropSchema.nullable(),
|
|
23
|
-
options: z.record(z.string(), z.unknown())
|
|
23
|
+
options: z.record(z.string(), z.unknown()),
|
|
24
|
+
version: z.string().optional()
|
|
24
25
|
}).strict();
|
|
25
26
|
const PlaceRenditionSchema = RenditionSchema.extend({ over: RenditionInputsSchema }).strict();
|
|
26
27
|
const ServedPlaceRenditionSchema = ServedRenditionSchema.extend({ over: RenditionInputsSchema }).strict();
|
|
@@ -54,7 +54,7 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
id: "object",
|
|
57
|
-
summary: "An object groups value slots, rows, lists of value slots and lists of objects one level deep, holds no value of its own, is labelled by
|
|
57
|
+
summary: "An object groups value slots, rows, lists of value slots and lists of objects one level deep, holds no value of its own, is labelled by its label field, and names no field like its binding's own keys."
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
id: "list-source",
|
|
@@ -103,10 +103,6 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
103
103
|
{
|
|
104
104
|
id: "interpolation",
|
|
105
105
|
summary: "A fill brief refers to its facts through reads and never interpolates one."
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
id: "group",
|
|
109
|
-
summary: "Group ids are unique, every group names real slots, and no slot sits in two groups."
|
|
110
106
|
}
|
|
111
107
|
];
|
|
112
108
|
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TABLES, isLegacyTable, tableBounds, tableForSlot } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../internal/section-contracts/dist/directly-linked-list-contract.js
|
|
4
4
|
function assertDirectlyLinkedListContract(schema, sectionKey) {
|
|
5
5
|
for (const [slotId, slotUnknown] of Object.entries(schema.slots)) {
|
|
6
6
|
const slot = slotUnknown;
|
|
7
|
-
|
|
8
|
-
if (slot.type !== "list" || slot.fields == null && !grammar) continue;
|
|
7
|
+
if (slot.type !== "list" || slot.element?.type !== "object" && slot.element?.type !== "row") continue;
|
|
9
8
|
const label = `list "${slotId}"`;
|
|
10
|
-
|
|
11
|
-
if (source?.kind !== "home") continue;
|
|
9
|
+
if (slot.source?.kind !== "home") continue;
|
|
12
10
|
const table = tableForSlot(slot);
|
|
13
|
-
if (table === null
|
|
14
|
-
if (table === null) {
|
|
15
|
-
const legal = Object.keys(REGISTRY_TABLE_KEYS).map((field) => `fact.property.${field}`).join(" / ");
|
|
16
|
-
throw new Error(`Section "${sectionKey}": ${label} is bound to the fact "${source.key ?? "?"}", which is not a known table. TABLES is a closed registry owned by @homepages/concrete — a workspace cannot add to it. A directly linked list may only bind a registry array (${legal}); for any other repeating data, drop \`source\` and give the slot a fill decision instead.`);
|
|
17
|
-
}
|
|
11
|
+
if (table === null) continue;
|
|
18
12
|
const entry = isLegacyTable(table) ? TABLES[table] : null;
|
|
19
13
|
if (entry !== null && !entry.ownership) throw new Error(`Section "${sectionKey}": ${label} table "${table}" declares no ownership in TABLES. TABLES is a closed registry owned by @homepages/concrete — this is a framework defect, not something a workspace can fix.`);
|
|
20
14
|
const inherited = tableBounds(table);
|
|
@@ -9,10 +9,6 @@ const DECISION_KINDS = [
|
|
|
9
9
|
function isListFill(decision) {
|
|
10
10
|
return decision.kind === "list";
|
|
11
11
|
}
|
|
12
|
-
function plannedFieldsOf(decision) {
|
|
13
|
-
const fields = decision.fields;
|
|
14
|
-
return fields !== null && typeof fields === "object" ? Object.keys(fields) : [];
|
|
15
|
-
}
|
|
16
12
|
|
|
17
13
|
//#endregion
|
|
18
|
-
export { DECISION_KINDS, isListFill
|
|
14
|
+
export { DECISION_KINDS, isListFill };
|
|
@@ -70,7 +70,7 @@ function assertFillVerbContract(ctx, decision) {
|
|
|
70
70
|
const where = `Section "${ctx.key}": fill "${decision.id}"`;
|
|
71
71
|
const node = decision;
|
|
72
72
|
if (decision.verb === void 0) {
|
|
73
|
-
for (const option of ["of", "unique"]) if (decision[option] !== void 0) throw new Error(`${where} declares \`${option}\` but no verb — \`${option}\` belongs to a \`fill.pick
|
|
73
|
+
for (const option of ["of", "unique"]) if (decision[option] !== void 0) throw new Error(`${where} declares \`${option}\` but no verb — \`${option}\` belongs to a \`fill.pick\`.`);
|
|
74
74
|
} else {
|
|
75
75
|
const verb = checkNode(node, where);
|
|
76
76
|
for (const id of decision.produces) {
|
|
@@ -83,7 +83,7 @@ function assertFillVerbContract(ctx, decision) {
|
|
|
83
83
|
const list = decision.produces.length === 1 ? producedSlot(ctx.schema, decision.produces[0]) : void 0;
|
|
84
84
|
const itemFields = list === void 0 ? void 0 : listItemFieldsOf(list);
|
|
85
85
|
for (const [name, entry] of Object.entries(fields)) {
|
|
86
|
-
if (!isRecord(entry)
|
|
86
|
+
if (!isRecord(entry)) continue;
|
|
87
87
|
const at = `${where} field "${name}"`;
|
|
88
88
|
const verb = checkNode(entry, at);
|
|
89
89
|
const field = itemFields?.[name];
|
|
@@ -5,7 +5,7 @@ import { listSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
|
5
5
|
//#region ../../internal/section-contracts/dist/grammar-scope.js
|
|
6
6
|
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7
7
|
function isGrammarList(slot) {
|
|
8
|
-
return slot.type === "list" && slot.
|
|
8
|
+
return slot.type === "list" && slot.element !== void 0;
|
|
9
9
|
}
|
|
10
10
|
function grammarSlots(schema) {
|
|
11
11
|
const out = [];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SECTION_CONTRACT_CATALOG } from "./catalog.js";
|
|
2
2
|
import { assertCapContract } from "./cap-contract.js";
|
|
3
3
|
import { assertCountBoundsContract } from "./count-bounds-contract.js";
|
|
4
|
-
import { assertGroupContract } from "./group-contract.js";
|
|
5
4
|
import { assertInterpolationContract } from "./interpolation-contract.js";
|
|
6
5
|
import { assertWriterReadsFactContract } from "./writer-reads-fact-contract.js";
|
|
7
6
|
import { assertListFillContract } from "./list-fill-contract.js";
|
|
@@ -1,37 +1,8 @@
|
|
|
1
|
-
import { isListSlot } from "../../fill-vocabulary/dist/holder.js";
|
|
2
|
-
import { resolveDecision } from "../../fill-vocabulary/dist/resolved-decision.js";
|
|
3
|
-
import { producedSlots } from "./grammar-scope.js";
|
|
4
1
|
import { assertOptionsHonoured } from "./fill-options.js";
|
|
5
|
-
import { isListFill, plannedFieldsOf } from "./fill-spec-view.js";
|
|
6
2
|
|
|
7
3
|
//#region ../../internal/section-contracts/dist/list-fill-contract.js
|
|
8
4
|
function assertListFillContract(schema, decision, sectionKey) {
|
|
9
5
|
assertOptionsHonoured(schema, decision, sectionKey, ["brief", "none"]);
|
|
10
|
-
const fill = decision;
|
|
11
|
-
if (!isListFill(decision)) return;
|
|
12
|
-
if (decision.verb !== void 0) return;
|
|
13
|
-
const resolved = resolveDecision(decision, producedSlots(schema, decision.produces));
|
|
14
|
-
for (const target of resolved.targets) {
|
|
15
|
-
const slot = schema.slots[target.slot];
|
|
16
|
-
if (slot === void 0 || !isListSlot(slot)) continue;
|
|
17
|
-
const where = `Section "${sectionKey}": list fill "${decision.id}"`;
|
|
18
|
-
if (!target.runs) {
|
|
19
|
-
if (slot.fields !== void 0) assertRowsOriginate(slot, plannedFieldsOf(decision), `${where} produces "${target.slot}"`);
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
assertDeclares(fill, resolved.verb, target, slot, where);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function assertRowsOriginate(slot, planned, where) {
|
|
26
|
-
const unwritten = Object.entries(slot.fields ?? {}).filter(([name, field]) => field.source === void 0 && !planned.includes(name)).map(([name]) => name);
|
|
27
|
-
throw new Error(`${where}, a record list whose rows nothing originates: it is not bound to a facts array, and ${unwritten.length > 0 ? `${unwritten.map((name) => `"${name}"`).join(", ")} ${unwritten.length === 1 ? "carries" : "carry"} no fill of its own` : "no row field carries a fill of its own"}. Bind the list with \`source:\`, or give every row field a \`fill()\`, a row member or a \`compute()\`.`);
|
|
28
|
-
}
|
|
29
|
-
function assertDeclares(fill, verb, target, slot, where) {
|
|
30
|
-
if (verb === void 0) return;
|
|
31
|
-
if (typeof fill.brief !== "string" || fill.brief.length === 0) throw new Error(`${where} originates rows but declares no \`brief\` — the brief is the whole instruction.`);
|
|
32
|
-
if (verb === "write" && fill.count === void 0 && slot.max === void 0) throw new Error(`${where} writes its ${target.holder?.shape === "objects" ? "rows" : "items"} but neither it nor the slot says how many — declare a \`count\`, or give the slot a \`max\`.`);
|
|
33
|
-
const band = fill.count;
|
|
34
|
-
if (typeof band?.min === "number" && typeof band.max === "number" && band.min > band.max) throw new Error(`${where} declares count.min ${String(band.min)} above count.max ${String(band.max)} — a band the model can never answer inside.`);
|
|
35
6
|
}
|
|
36
7
|
|
|
37
8
|
//#endregion
|
|
@@ -23,9 +23,9 @@ function checkSelectListVocabulary(element, label, sectionKey) {
|
|
|
23
23
|
if (!Array.isArray(element.values) || element.values.length === 0) throw new Error(`Section "${sectionKey}": ${label} element is a \`select\` with no \`values\` — a select-list's vocabulary must be a non-empty static \`values\` array.`);
|
|
24
24
|
}
|
|
25
25
|
function checkSingleItem(slot, label, sectionKey) {
|
|
26
|
-
if (slot.title !== void 0) throw new Error(`Section "${sectionKey}": ${label} declares \`title\`
|
|
26
|
+
if (slot.title !== void 0) throw new Error(`Section "${sectionKey}": ${label} declares \`title\` — an item's title is its object's \`label\`.`);
|
|
27
27
|
const element = slot.element;
|
|
28
|
-
if (element == null) throw new Error(`Section "${sectionKey}": ${label} must declare its item — \`element
|
|
28
|
+
if (element == null) throw new Error(`Section "${sectionKey}": ${label} must declare its item — \`element\`, a slot, an \`object\` or a \`row\`.`);
|
|
29
29
|
if (!LIST_ITEM_TYPES.has(element.type ?? "")) throw new Error(`Section "${sectionKey}": ${label} element must be a single value primitive (${[...LIST_ITEM_TYPES].join("|")}) — never a list or a record, got "${element.type}".`);
|
|
30
30
|
if (element.type === "select") checkSelectListVocabulary(element, label, sectionKey);
|
|
31
31
|
const vocabulary = element.values;
|
|
@@ -35,21 +35,7 @@ function checkSingleItem(slot, label, sectionKey) {
|
|
|
35
35
|
if (typeof slot.min === "number" && slot.min > distinctCount) throw new Error(`Section "${sectionKey}": ${label} is \`unique\` with min ${slot.min} but its vocabulary has only ${distinctCount} distinct option(s) — min can never be satisfied.`);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
function checkRecordItem(slot, label, sectionKey) {
|
|
39
|
-
if (slot.unique !== void 0) throw new Error(`Section "${sectionKey}": ${label} declares \`unique\` beside \`fields\` — \`unique\` is select-element distinctness; a record item has no element vocabulary.`);
|
|
40
|
-
const fields = slot.fields ?? {};
|
|
41
|
-
for (const [fieldId, field] of Object.entries(fields)) {
|
|
42
|
-
if (field.type === "list" && field.fields != null) throw new Error(`Section "${sectionKey}": ${label} field "${fieldId}" may not be a record — identity is a flat 4-tuple, and a record field has no fifth element to address through.`);
|
|
43
|
-
if (field.type === "list") checkSingleItem(field, `${label} field "${fieldId}"`, sectionKey);
|
|
44
|
-
}
|
|
45
|
-
if (slot.title !== void 0 && !Object.hasOwn(fields, slot.title)) throw new Error(`Section "${sectionKey}": ${label} \`title\` names "${slot.title}", which is not a declared field.`);
|
|
46
|
-
}
|
|
47
38
|
function checkListSlot(slot, label, sectionKey) {
|
|
48
|
-
if (slot.element != null && slot.fields != null) throw new Error(`Section "${sectionKey}": ${label} declares both \`element\` and \`fields\` — the item is exactly one of the two.`);
|
|
49
|
-
if (slot.fields != null) {
|
|
50
|
-
checkRecordItem(slot, label, sectionKey);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
39
|
const item = slot.element?.type;
|
|
54
40
|
if (item === "object" || item === "row") {
|
|
55
41
|
checkGrammarItem(slot, item, label, sectionKey);
|
|
@@ -4,16 +4,16 @@ import { nestedItemOf } from "./grammar-scope.js";
|
|
|
4
4
|
//#region ../../internal/section-contracts/dist/nested-slot-contract.js
|
|
5
5
|
function assertNestedSlotTypes(schema, sectionKey) {
|
|
6
6
|
for (const [slotId, slot] of Object.entries(schema.slots)) {
|
|
7
|
-
if (slot.fields) check(slot.fields,
|
|
8
|
-
if (slot.type === "list" && slot.
|
|
7
|
+
if (slot.type === "object" && slot.fields) check(slot.fields, `object "${slotId}"`, sectionKey);
|
|
8
|
+
if (slot.type === "list" && slot.element?.type === "object" && slot.element.fields) check(slot.element.fields, `list "${slotId}"`, sectionKey);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
function check(fields, owner,
|
|
11
|
+
function check(fields, owner, sectionKey) {
|
|
12
12
|
for (const [childId, child] of Object.entries(fields)) {
|
|
13
13
|
if (child.type == null) continue;
|
|
14
|
-
if (!SLOT_TYPES.includes(child.type) &&
|
|
15
|
-
const nested =
|
|
16
|
-
if (nested?.fields) check(nested.fields, `${owner} field "${childId}"`,
|
|
14
|
+
if (!SLOT_TYPES.includes(child.type) && child.type !== "row" && child.type !== "object") throw new Error(`Section "${sectionKey}": ${owner} item "${childId}" has unknown nested slot type "${child.type}".`);
|
|
15
|
+
const nested = nestedItemOf(child);
|
|
16
|
+
if (nested?.fields) check(nested.fields, `${owner} field "${childId}"`, sectionKey);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isFindableKind } from "../../template-contracts/dist/findable.js";
|
|
2
|
+
import { holderOf } from "../../fill-vocabulary/dist/holder.js";
|
|
3
|
+
import "../../fill-vocabulary/dist/verbs.js";
|
|
2
4
|
import { isListFill } from "./fill-spec-view.js";
|
|
3
5
|
|
|
4
6
|
//#region ../../internal/section-contracts/dist/poi-curation-contract.js
|
|
@@ -6,7 +8,9 @@ function assertPoiCurationContract(schema, decision, sectionKey) {
|
|
|
6
8
|
if (!isListFill(decision) || decision.produces.length <= 1) return;
|
|
7
9
|
const found = decision.produces.find((slotId) => {
|
|
8
10
|
const slot = schema.slots[slotId];
|
|
9
|
-
|
|
11
|
+
if (slot === void 0) return false;
|
|
12
|
+
const holder = holderOf(slot);
|
|
13
|
+
return holder.shape === "list" && isFindableKind(holder.item);
|
|
10
14
|
});
|
|
11
15
|
if (found === void 0) return;
|
|
12
16
|
throw new Error(`Section "${sectionKey}": POI find decision "${decision.id}" must produce exactly one slot (got [${decision.produces.join(", ")}]) — "${found}" is found by one place lookup, which answers one list.`);
|
|
@@ -2,7 +2,6 @@ import { plannerForField } from "../../template-contracts/dist/row-planners.js";
|
|
|
2
2
|
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
3
3
|
import "../../fill-vocabulary/dist/row-planners.js";
|
|
4
4
|
import { isListFill } from "./fill-spec-view.js";
|
|
5
|
-
import { rowReadFields } from "../../fill-vocabulary/dist/row-reads.js";
|
|
6
5
|
|
|
7
6
|
//#region ../../internal/section-contracts/dist/row-fill-contract.js
|
|
8
7
|
function assertRowFillContract(schema, decision, sectionKey) {
|
|
@@ -22,22 +21,9 @@ function assertRowFillContract(schema, decision, sectionKey) {
|
|
|
22
21
|
if (rowField.source) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" fills field "${field}" of "${slotId}", which is source-bound (source.kind "${rowField.source.kind ?? "?"}") — the fact bakes it; drop the decision.`);
|
|
23
22
|
if (rowField.type === "row") continue;
|
|
24
23
|
if (plannerForField(rowField) === void 0) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" fills field "${field}" of "${slotId}" (type "${rowField.type}"), which no row can be filled with — a row field is written or picked inside the list's one batched call: text, a date, an email, a phone, a url, a select key, an asset, or a list of those.`);
|
|
25
|
-
if (slot.source === void 0 && slot.fields !== void 0) {
|
|
26
|
-
const reads = fill.fields?.[field]?.reads;
|
|
27
|
-
assertEarlierRowReads(declared, field, reads, `Section "${sectionKey}": list fill "${decision.id}" field "${field}" of "${slotId}"`);
|
|
28
|
-
}
|
|
29
24
|
}
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
|
-
function assertEarlierRowReads(declared, field, reads, where) {
|
|
33
|
-
const position = declared.indexOf(field);
|
|
34
|
-
for (const read of rowReadFields(reads)) {
|
|
35
|
-
const at = declared.indexOf(read);
|
|
36
|
-
if (at === -1) throw new Error(`${where} reads row field "${read}", which the row does not declare (declared: ${declared.join(", ")}).`);
|
|
37
|
-
if (at === position) throw new Error(`${where} reads itself — a row fill reads only fields declared before it.`);
|
|
38
|
-
if (at > position) throw new Error(`${where} reads row field "${read}", declared after it — the model writes a row top to bottom, so a fill reads only earlier fields. Declare "${read}" first, or drop the read.`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
27
|
|
|
42
28
|
//#endregion
|
|
43
29
|
export { assertRowFillContract };
|
|
@@ -2,8 +2,8 @@ import { ADDRESS_MEMBERS, isAddressMember } from "../../template-contracts/dist/
|
|
|
2
2
|
import { rowTableOf } from "../../template-contracts/dist/ref-locate.js";
|
|
3
3
|
import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
4
4
|
import { fillOf, grammarSlots, insideItem, slotInScope } from "./grammar-scope.js";
|
|
5
|
-
import { tableKeySpelling, tableMemberOrRefuse } from "./table-member.js";
|
|
6
5
|
import { fittingTypes, memberFits, refuseIndexedRow } from "./source-contract.js";
|
|
6
|
+
import { tableKeySpelling, tableMemberOrRefuse } from "./table-member.js";
|
|
7
7
|
|
|
8
8
|
//#region ../../internal/section-contracts/dist/row-rule-contract.js
|
|
9
9
|
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -54,10 +54,7 @@ function checkReads(ctx, slot, reads, what) {
|
|
|
54
54
|
refuseIndexedRow(where, entry);
|
|
55
55
|
if (entry["kind"] !== "row") return;
|
|
56
56
|
const member = memberSourceOf(entry);
|
|
57
|
-
if (member === null) {
|
|
58
|
-
if (slot.place === "top" && slot.def.fields !== void 0) return;
|
|
59
|
-
throw new Error(`${where} reads a row member without naming its row slot — read it through a row: \`{ kind: "row", slot, field }\`.`);
|
|
60
|
-
}
|
|
57
|
+
if (member === null) throw new Error(`${where} reads a row member without naming its row slot — read it through a row: \`{ kind: "row", slot, field }\`.`);
|
|
61
58
|
const holder = resolveHolder(ctx, slot, member.slot, where);
|
|
62
59
|
if (holder.kind === "address") addressMemberType(member.field, where);
|
|
63
60
|
else if (holder.table !== null) memberOf(holder.table, member.field, where);
|
|
@@ -70,7 +67,7 @@ function assertRowRuleContract(ctx) {
|
|
|
70
67
|
if (source?.kind === "row") {
|
|
71
68
|
const member = memberSourceOf(source);
|
|
72
69
|
if (member !== null) checkMemberSource(ctx, slot, member);
|
|
73
|
-
else
|
|
70
|
+
else throw new Error(`Section "${ctx.key}": "${slot.path}" reads row member "${String(source.field)}" without naming its row slot — declare the row and read through it: \`{ kind: "row", slot, field }\`.`);
|
|
74
71
|
}
|
|
75
72
|
if (source?.kind === "derived") checkReads(ctx, slot, source.reads, "compute");
|
|
76
73
|
if (source?.kind === "element" && slot.def.type !== "row" && !insideItem(slot)) throw new Error(`Section "${ctx.key}": "${slot.path}" is sourced by the element outside a list's item, where no element exists.`);
|
|
@@ -5,9 +5,7 @@ import { SECTION_CONTRACT_CATALOG } from "./catalog.js";
|
|
|
5
5
|
import { producedSlot } from "./grammar-scope.js";
|
|
6
6
|
import { assertCapContract } from "./cap-contract.js";
|
|
7
7
|
import { assertCountBoundsContract } from "./count-bounds-contract.js";
|
|
8
|
-
import { assertGroupContract } from "./group-contract.js";
|
|
9
8
|
import { assertInterpolationContract } from "./interpolation-contract.js";
|
|
10
|
-
import { DECISION_KINDS } from "./fill-spec-view.js";
|
|
11
9
|
import { assertWriterReadsFactContract } from "./writer-reads-fact-contract.js";
|
|
12
10
|
import { assertListFillContract } from "./list-fill-contract.js";
|
|
13
11
|
import { assertListScalarContract } from "./list-scalar-contract.js";
|
|
@@ -17,6 +15,7 @@ import { assertDirectlyLinkedListContract } from "./directly-linked-list-contrac
|
|
|
17
15
|
import { assertFillVerbContract } from "./fill-verb-contract.js";
|
|
18
16
|
import { assertObjectContract } from "./object-contract.js";
|
|
19
17
|
import { assertOptionSourceContract } from "./option-source-contract.js";
|
|
18
|
+
import { DECISION_KINDS } from "./fill-spec-view.js";
|
|
20
19
|
import { assertPoiCurationContract } from "./poi-curation-contract.js";
|
|
21
20
|
import { assertReadsAcyclicContract } from "./reads-acyclic-contract.js";
|
|
22
21
|
import { assertRowFillContract } from "./row-fill-contract.js";
|
|
@@ -56,7 +55,7 @@ const CONTRACTS = {
|
|
|
56
55
|
"reads-readable": {
|
|
57
56
|
implementation: bySection(({ key, fillSpec }) => {
|
|
58
57
|
for (const r of fillSpec.reads ?? []) if (!isReadableFactKey(r) && !Object.hasOwn(FACT_GRAPH, legacyFactKey(r))) throw new Error(`Section "${key}": fill-spec reads "${r}", which is not a fact the registry declares.`);
|
|
59
|
-
for (const d of fillSpec.decisions) for (const [at, node] of decisionReadNodes(d)) assertDeclaredRefs(`Section "${key}": fill-spec decision "${d.id}"${at}`, node.reads
|
|
58
|
+
for (const d of fillSpec.decisions) for (const [at, node] of decisionReadNodes(d)) assertDeclaredRefs(`Section "${key}": fill-spec decision "${d.id}"${at}`, node.reads);
|
|
60
59
|
}),
|
|
61
60
|
assertions: []
|
|
62
61
|
},
|
|
@@ -117,10 +116,10 @@ const CONTRACTS = {
|
|
|
117
116
|
assertions: [assertDisplayEvidenceContract]
|
|
118
117
|
},
|
|
119
118
|
source: {
|
|
120
|
-
implementation: bySection(({ key, schema
|
|
119
|
+
implementation: bySection(({ key, schema }) => assertSourceContract({
|
|
121
120
|
key,
|
|
122
121
|
slots: schema.slots
|
|
123
|
-
}
|
|
122
|
+
})),
|
|
124
123
|
assertions: [assertSourceContract]
|
|
125
124
|
},
|
|
126
125
|
object: {
|
|
@@ -174,10 +173,6 @@ const CONTRACTS = {
|
|
|
174
173
|
interpolation: {
|
|
175
174
|
implementation: bySection(({ key, schema, fillSpec }) => assertInterpolationContract(fillSpec, key, schema)),
|
|
176
175
|
assertions: [assertInterpolationContract]
|
|
177
|
-
},
|
|
178
|
-
group: {
|
|
179
|
-
implementation: bySection(({ key, schema }) => assertGroupContract(schema, key)),
|
|
180
|
-
assertions: [assertGroupContract]
|
|
181
176
|
}
|
|
182
177
|
};
|
|
183
178
|
function perFill(input) {
|
|
@@ -2,9 +2,7 @@ import { tableKeyOf } from "../../template-contracts/dist/slot-catalog.js";
|
|
|
2
2
|
import { mirrorKindOf } from "../../template-contracts/dist/mirror-kind.js";
|
|
3
3
|
import { isMediaListKey, sourceFieldDescriptor } from "../../template-contracts/dist/fact-keys.js";
|
|
4
4
|
import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
5
|
-
import { plannedFieldsOf } from "./fill-spec-view.js";
|
|
6
5
|
import { objectFieldOf } from "../../template-contracts/dist/slot-overrides.js";
|
|
7
|
-
import { tableMemberOrRefuse } from "./table-member.js";
|
|
8
6
|
|
|
9
7
|
//#region ../../internal/section-contracts/dist/source-contract.js
|
|
10
8
|
function assertOne(path, key, slot, section) {
|
|
@@ -20,14 +18,10 @@ function assertOne(path, key, slot, section) {
|
|
|
20
18
|
if (isMediaListKey(field)) throw new Error(`${path}: "${field}" is read, never bound — a \`compute()\` reads a media list; a media slot or a list of media picks from it, naming it as its \`from\` (\`fill.pick\`).`);
|
|
21
19
|
const def = sourceFieldDescriptor(field);
|
|
22
20
|
if (!def) throw new Error(`${path}: unknown fact "${String(src.key)}"`);
|
|
23
|
-
const recordItemSlot = slot.type === "list" && slot.fields != null;
|
|
24
21
|
if (def.image && slot.type !== "image") throw new Error(`${path}: image source field "${src.key}" must sit on an image slot`);
|
|
25
22
|
if (def.value_type === "address" && slot.type !== "address") throw new Error(`${path}: "${field}" is a whole address, which only an \`address\` slot holds — bind it to an \`address()\`, or show the line you want with a \`compute()\` reading it (\`concrete upgrade\` rewrites a text slot bound to it).`);
|
|
26
23
|
if (slot.type === "address" && def.value_type !== "address") throw new Error(`${path}: an \`address\` slot bound to "${field}", which is not an address — bind it to the property's address, or compute the value.`);
|
|
27
|
-
if (tableKeyOf(field) !== null) {
|
|
28
|
-
if (slot.type === "list" && slot.fields === void 0 && (slot.element?.type === "row" || slot.element?.type === "object")) return;
|
|
29
|
-
if (!recordItemSlot) throw new Error(`${path}: table source "${src.key}" needs a record item (a list declaring \`fields\`, or an item that declares a row) — a fact row cannot project onto one slot.`);
|
|
30
|
-
}
|
|
24
|
+
if (tableKeyOf(field) !== null && !(slot.type === "list" && (slot.element?.type === "row" || slot.element?.type === "object"))) throw new Error(`${path}: table source "${src.key}" needs an item that declares a row (\`list({ item: (el) => object({ … }) })\`) — a fact row cannot project onto one slot.`);
|
|
31
25
|
return;
|
|
32
26
|
}
|
|
33
27
|
if (typeof src.kind !== "string") throw new Error(`${path} is sourced by a ref without a "kind" — this framework reads only kind-tagged refs. Run \`concrete upgrade\`, then build again.`);
|
|
@@ -54,7 +48,7 @@ function assertMirror(path, key, slot, section) {
|
|
|
54
48
|
const upstreamKind = mirrorKindOf(upstreamDef);
|
|
55
49
|
if (held !== void 0 && upstreamKind !== void 0 && held !== upstreamKind) throw new Error(`${path} mirrors slot "${upstream}" but holds ${held} where its upstream holds ${upstreamKind} — a mirror IS its upstream's value: declare it at the upstream's kind, or derive the value with a \`compute()\`.`);
|
|
56
50
|
}
|
|
57
|
-
function assertDeclaredRefs(path, reads
|
|
51
|
+
function assertDeclaredRefs(path, reads) {
|
|
58
52
|
if (reads === void 0) return;
|
|
59
53
|
if (!Array.isArray(reads)) throw new Error(`${path}: "reads" is not a list of refs.`);
|
|
60
54
|
reads.forEach((entry, i) => {
|
|
@@ -64,44 +58,22 @@ function assertDeclaredRefs(path, reads, rowMember) {
|
|
|
64
58
|
if (kind === "section" && typeof section === "string" && typeof slot === "string") return;
|
|
65
59
|
refuseIndexedRow(`${path}: reads[${String(i)}]`, record);
|
|
66
60
|
if (kind === "row" && "slot" in record || kind === "element") return;
|
|
67
|
-
|
|
68
|
-
if (rowMember === void 0) throw new Error(`${path}: reads[${String(i)}] reads the row member "${field}" outside a record list's row — only a row field's compute runs once per row.`);
|
|
69
|
-
rowMember(field);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
throw new Error(kind === void 0 ? `${path}: reads[${String(i)}] is a ref without a "kind" — this framework reads only kind-tagged refs. Run \`concrete upgrade\`, then build again.` : kind === "item" ? `${path}: reads[${String(i)}] reads a field of its own item ({ kind: "item" }) — a section's item fields do not read one another; read the element, or a member through a row.` : `${path}: reads[${String(i)}] is not a home ref ({ kind: "home", key }) or a section ref ({ kind: "section", section, slot }).`);
|
|
61
|
+
throw new Error(kind === void 0 ? `${path}: reads[${String(i)}] is a ref without a "kind" — this framework reads only kind-tagged refs. Run \`concrete upgrade\`, then build again.` : kind === "item" ? `${path}: reads[${String(i)}] reads a field of its own item ({ kind: "item" }) — a section's item fields do not read one another; read the element, or a member through a row.` : kind === "row" ? `${path}: reads[${String(i)}] reads the row member "${String(field)}" without naming its row slot — read it through a row: \`{ kind: "row", slot, field }\`.` : `${path}: reads[${String(i)}] is not a home ref ({ kind: "home", key }) or a section ref ({ kind: "section", section, slot }).`);
|
|
73
62
|
});
|
|
74
63
|
}
|
|
75
|
-
function assertSourceContract(schema
|
|
64
|
+
function assertSourceContract(schema) {
|
|
76
65
|
for (const [name, slot] of Object.entries(schema.slots)) {
|
|
77
66
|
const at = `${schema.key}.${name}`;
|
|
78
67
|
refuseIndexedRow(at, slot.source);
|
|
79
68
|
if (slot.source?.kind === "row" && memberSourceOf(slot.source) === null) throw new Error(`${at}: a row source on a top-level slot names no row slot — a top-level slot reads a member through a row it declares (\`{ kind: "row", slot, field }\`). Bind the slot to a fact or read it through a row.`);
|
|
80
69
|
assertOne(at, name, slot, schema);
|
|
81
|
-
const
|
|
82
|
-
for (const [fieldKey, field] of Object.entries(
|
|
70
|
+
const fields = slot.type === "object" ? slot.fields : slot.type === "list" ? slot.element?.fields : void 0;
|
|
71
|
+
for (const [fieldKey, field] of Object.entries(fields ?? {})) {
|
|
83
72
|
refuseIndexedRow(`${at}.${fieldKey}`, field.source);
|
|
84
73
|
if (field.source?.kind === "row") continue;
|
|
85
74
|
assertOne(`${at}.${fieldKey}`, `${name}.${fieldKey}`, field, schema);
|
|
86
75
|
}
|
|
87
|
-
if (slot.type !== "list" || slot.fields === void 0) continue;
|
|
88
|
-
assertNotImplicit(at, slot.fields, plannedRowFields(fillSpec, name));
|
|
89
|
-
assertRowSourceList(at, name, slot, slot.fields);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function plannedRowFields(fillSpec, listKey) {
|
|
93
|
-
const decision = fillSpec.decisions.find((d) => d.produces.includes(listKey));
|
|
94
|
-
return new Set(decision === void 0 ? [] : plannedFieldsOf(decision));
|
|
95
|
-
}
|
|
96
|
-
function assertNotImplicit(at, fields, planned) {
|
|
97
|
-
const offenders = [];
|
|
98
|
-
for (const [fieldKey, field] of Object.entries(fields)) {
|
|
99
|
-
const kind = field.source?.kind;
|
|
100
|
-
if (kind === "home") offenders.push(`"${fieldKey}" (bound to the fact "${String(field.source?.key)}")`);
|
|
101
|
-
else if ((kind === void 0 || kind === "authored") && !planned.has(fieldKey)) offenders.push(`"${fieldKey}" (no origin)`);
|
|
102
76
|
}
|
|
103
|
-
if (offenders.length === 0) return;
|
|
104
|
-
throw new Error(`${at}: a record list in the implicit form, which this platform no longer reads — row field ${offenders.join(", ")}. Every row field declares its own origin: a member of its row (\`row.<member>\`), a \`compute()\`, or a \`fill()\`. Rebuild the section with @homepages/concrete 7.0.0 or later (\`concrete upgrade\`).`);
|
|
105
77
|
}
|
|
106
78
|
function refuseIndexedRow(path, ref) {
|
|
107
79
|
if (ref === null || typeof ref !== "object") return;
|
|
@@ -114,10 +86,10 @@ function refuseIndexedRow(path, ref) {
|
|
|
114
86
|
function memberFits(valueType, field) {
|
|
115
87
|
switch (valueType) {
|
|
116
88
|
case "image": return field.type === "image";
|
|
117
|
-
case "image_list": return field.type === "list" &&
|
|
118
|
-
case "row_list": return field.type === "list" &&
|
|
119
|
-
case "text_list": return field.type === "list" &&
|
|
120
|
-
case "number_list": return field.type === "list" && field.
|
|
89
|
+
case "image_list": return field.type === "list" && (field.element?.type === "image" || holdsElementImage(field.element));
|
|
90
|
+
case "row_list": return field.type === "list" && (field.element?.type === "object" || field.element?.type === "row");
|
|
91
|
+
case "text_list": return field.type === "list" && TEXT_FIELD_TYPES.includes(field.element?.type ?? "");
|
|
92
|
+
case "number_list": return field.type === "list" && field.element?.type === "number";
|
|
121
93
|
case "address": return field.type === "address";
|
|
122
94
|
case "number": return field.type === "number";
|
|
123
95
|
case "text": return TEXT_FIELD_TYPES.includes(field.type ?? "");
|
|
@@ -149,41 +121,6 @@ function fittingTypes(valueType) {
|
|
|
149
121
|
default: return "no field — it is not offered to a row";
|
|
150
122
|
}
|
|
151
123
|
}
|
|
152
|
-
function assertRowSourceList(at, listKey, list, fields) {
|
|
153
|
-
const listSource = list.source;
|
|
154
|
-
const boundField = listSource?.kind === "home" ? listSource.key ?? "" : void 0;
|
|
155
|
-
const table = boundField === void 0 ? void 0 : tableKeyOf(boundField);
|
|
156
|
-
if (table === null) throw new Error(`${at}: row sources on a list bound to "${String(boundField)}", which is not a table — a row member names a member of the row a table supplies.`);
|
|
157
|
-
const filled = listSource === void 0;
|
|
158
|
-
const assertMember = (path, member) => {
|
|
159
|
-
if (filled) throw new Error(`${path}: row member "${member}" on a list a fill() builds — its rows do not exist until the fill answers, so they offer no members. Give the field its own fill() instead.`);
|
|
160
|
-
if (table === void 0) return void 0;
|
|
161
|
-
return tableMemberOrRefuse(table, member, path, {
|
|
162
|
-
noun: "row member",
|
|
163
|
-
identity: `row member "${member}" is the row's identity, which every baked "${String(boundField)}" row carries as "${member}" already — drop the field.`
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
for (const [fieldKey, field] of Object.entries(fields)) {
|
|
167
|
-
const path = `${at}.${fieldKey}`;
|
|
168
|
-
const src = field.source;
|
|
169
|
-
if (src === void 0 || src.kind === "authored") continue;
|
|
170
|
-
if (src.kind === "derived") {
|
|
171
|
-
const handle = `${listKey}.${fieldKey}`;
|
|
172
|
-
if (src.transform !== handle) throw new Error(`${path}: unknown transform "${String(src.transform)}". A row field's compute() is held under "${handle}" — its list's key and its own — which this declaration does not name, so it was not produced by the framework's compute() path.`);
|
|
173
|
-
assertDeclaredRefs(path, src.reads, (member) => {
|
|
174
|
-
assertMember(path, member);
|
|
175
|
-
});
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (src.kind !== "row") continue;
|
|
179
|
-
refuseIndexedRow(path, src);
|
|
180
|
-
if (typeof src.field !== "string") throw new Error(`${path}: a row source names no member — it is \`{ kind: "row", field: "<member>" }\`.`);
|
|
181
|
-
const member = src.field;
|
|
182
|
-
const descriptor = assertMember(path, member);
|
|
183
|
-
if (descriptor === void 0) continue;
|
|
184
|
-
if (!memberFits(descriptor.value_type, field)) throw new Error(`${path}: row member "${member}" is a ${descriptor.value_type} value and cannot sit on a "${String(field.type)}" field — it belongs on ${fittingTypes(descriptor.value_type)}.`);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
124
|
|
|
188
125
|
//#endregion
|
|
189
126
|
export { assertDeclaredRefs, assertSourceContract, fittingTypes, memberFits, refuseIndexedRow };
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { rowTableOf } from "../../template-contracts/dist/ref-locate.js";
|
|
2
|
-
import {
|
|
2
|
+
import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
3
3
|
import { holderOf } from "../../fill-vocabulary/dist/holder.js";
|
|
4
|
-
import { impliedVerbOf } from "../../fill-vocabulary/dist/verbs.js";
|
|
5
4
|
import { elementIsFact, grammarSlots, producedSlot, slotInScope } from "./grammar-scope.js";
|
|
6
|
-
import { plannedFieldsOf } from "./fill-spec-view.js";
|
|
7
5
|
|
|
8
6
|
//#region ../../internal/section-contracts/dist/writer-reads-fact-contract.js
|
|
9
|
-
function writes(node
|
|
10
|
-
|
|
11
|
-
if (slot === void 0) return false;
|
|
12
|
-
return impliedVerbOf(slot, planned) === "write" && holderOf(slot).shape !== "objects";
|
|
7
|
+
function writes(node) {
|
|
8
|
+
return node.verb === "write";
|
|
13
9
|
}
|
|
14
10
|
function readsAFact(reads, rowsAreFacts, memberIsFact) {
|
|
15
11
|
return (reads ?? []).some((ref) => {
|
|
@@ -44,10 +40,9 @@ function assertWriterReadsFactContract(schema, decision, sectionKey, fillSpec =
|
|
|
44
40
|
if (slot === void 0) continue;
|
|
45
41
|
const holder = holderOf(slot);
|
|
46
42
|
if (holder.shape === "objects" && holder.bound !== void 0) rowsAreFacts = true;
|
|
47
|
-
if (
|
|
48
|
-
const itemFields = listItemFieldsOf(slot);
|
|
43
|
+
if (writes(fill)) writing.push(slotId);
|
|
49
44
|
for (const [field, node] of Object.entries(fill.fields ?? {})) {
|
|
50
|
-
if (writes(node
|
|
45
|
+
if (writes(node)) writing.push(`${slotId}.${field}`);
|
|
51
46
|
const reader = scoped.find((s) => s.place === "item-field" && s.path === `${slotId}.${field}`);
|
|
52
47
|
if (readsAFact(node.reads, rowsAreFacts, memberIsFact(reader))) fieldsReadAFact = true;
|
|
53
48
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { addressMember, isAddressMember, normalizeAddressValue } from "../../template-contracts/dist/address-value.js";
|
|
2
2
|
import { FACT_GRAPH, FACT_PROJECTIONS, REFERRAL_FIELDS, REFERRAL_IMAGE_FIELDS, SOURCE_FIELDS, TABLES, tableKeyOf } from "../../template-contracts/dist/slot-catalog.js";
|
|
3
3
|
import { memberValueType, tableColumnOfKey } from "../../template-contracts/dist/registry-shape.js";
|
|
4
|
-
import { elementIdentityKey } from "../../template-contracts/dist/ref-locate.js";
|
|
5
4
|
import { isMediaListKey, isRegistryFactKey, readRegistryFact, registryPropertyRoot } from "../../template-contracts/dist/fact-keys.js";
|
|
6
5
|
import { rowIdentityKey, tableFields, tableRowMember } from "../../template-contracts/dist/table-members.js";
|
|
7
6
|
import { elementRowKeys, rowMemberSources } from "../../template-contracts/dist/row-sources.js";
|
|
@@ -143,16 +142,16 @@ function readRowMember(table, id, member, facts) {
|
|
|
143
142
|
return row === void 0 ? null : readMemberOf(table, row, member);
|
|
144
143
|
}
|
|
145
144
|
function projectTableRows(table, facts, fields, rowComputes = {}, ids) {
|
|
146
|
-
const key = tableKey(table);
|
|
147
|
-
const idKey = elementIdentityKey(key.table);
|
|
148
|
-
const rowId = rowIdentityKey(key);
|
|
149
|
-
const members = rowMemberSources(fields);
|
|
150
145
|
const elementRows = elementRowKeys(fields);
|
|
151
|
-
return (
|
|
152
|
-
|
|
146
|
+
return projectRows(tableKey(table), facts, rowMemberSources(fields), elementRows, rowComputes, ids);
|
|
147
|
+
}
|
|
148
|
+
function projectRows(key, facts, members, elementRows, rowComputes, ids) {
|
|
149
|
+
const rowId = rowIdentityKey(key);
|
|
150
|
+
return (ids === void 0 ? tableRowsOf(key, facts) : ids.flatMap((id) => {
|
|
151
|
+
const row = tableRowById(key, id, facts);
|
|
153
152
|
return row === void 0 ? [] : [row];
|
|
154
153
|
})).map((row) => {
|
|
155
|
-
const out = {
|
|
154
|
+
const out = { id: row[rowId] };
|
|
156
155
|
for (const field of elementRows) out[field] = row[rowId];
|
|
157
156
|
for (const [field, member] of Object.entries(members)) out[field] = readMemberOf(key, row, member);
|
|
158
157
|
for (const [field, compute] of Object.entries(rowComputes)) out[field] = compute((member) => readMemberOf(key, row, member), row[rowId]);
|
|
@@ -11,15 +11,11 @@ function isRecord(value) {
|
|
|
11
11
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
12
12
|
}
|
|
13
13
|
function decisionFills(node) {
|
|
14
|
-
if (!isRecord(node)) return [];
|
|
15
|
-
|
|
14
|
+
if (!isRecord(node) || !Array.isArray(node["fills"])) return [];
|
|
15
|
+
return node["fills"].filter(isRecord).map((fill) => ({
|
|
16
16
|
...fill,
|
|
17
17
|
kind: "fill"
|
|
18
18
|
}));
|
|
19
|
-
if (node["verb"] === void 0 && node["brief"] === void 0) return [];
|
|
20
|
-
const fill = { kind: "fill" };
|
|
21
|
-
for (const key of WIRE_FILL_KEYS) if (node[key] !== void 0) fill[key] = node[key];
|
|
22
|
-
return [fill];
|
|
23
19
|
}
|
|
24
20
|
function isHomeRef(value) {
|
|
25
21
|
return isRecord(value) && value["kind"] === "home" && typeof value["key"] === "string";
|