@homepages/concrete 9.0.0 → 10.0.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 +69 -0
- package/README.md +3 -3
- package/codemods/manifest.json +14 -0
- package/codemods/registry-keys-only.mjs +113 -0
- package/codemods/steps/list-object-form.mjs +2 -3
- package/codemods/steps/registry-key-reads.mjs +276 -0
- package/dist/artifact/playground/client/assets/index-BFNHB7VM.css +1 -0
- package/dist/artifact/playground/client/assets/index-Div1yo6s.js +1259 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/host.mjs +42 -42
- package/dist/cli/build/artifact.js +2 -1
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/check/render/inputs.js +3 -3
- package/dist/cli/check/stages/sections.js +5 -6
- package/dist/cli/check/stages/workspace.js +2 -0
- package/dist/cli/check/template-key.js +16 -0
- package/dist/cli/dev/workspace-reader.js +9 -2
- package/dist/fixtures/media-store.js +3 -3
- package/dist/fixtures/resolve.js +28 -23
- package/dist/fixtures/synthesize-empties.js +3 -1
- package/dist/fixtures.d.ts +1 -1
- package/dist/index.d.ts +3 -4
- 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 +15 -27
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +12 -12
- package/dist/packages/internal/fill-bake/dist/derive-source.js +7 -14
- package/dist/packages/internal/fill-bake/dist/index.js +4 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +36 -16
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -28
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +5 -7
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +11 -34
- package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +12 -39
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +2 -17
- package/dist/packages/internal/media-resolution/dist/document.js +16 -15
- package/dist/packages/internal/media-resolution/dist/image.js +38 -94
- package/dist/packages/internal/media-resolution/dist/index.js +1 -1
- package/dist/packages/internal/media-resolution/dist/list.js +12 -12
- package/dist/packages/internal/media-resolution/dist/media.js +17 -16
- package/dist/packages/internal/media-resolution/dist/records.js +4 -2
- package/dist/packages/internal/media-resolution/dist/slot.js +9 -6
- package/dist/packages/internal/media-resolution/dist/tour.js +12 -11
- package/dist/packages/internal/media-resolution/dist/video.js +16 -16
- package/dist/packages/internal/property-facts/dist/registry-facts.js +10 -2
- package/dist/packages/internal/section-contracts/dist/catalog.js +2 -10
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +5 -12
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +7 -5
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +1 -1
- package/dist/packages/internal/section-contracts/dist/index.js +0 -2
- 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/object-contract.js +4 -2
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +6 -2
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -15
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +6 -7
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +7 -8
- package/dist/packages/internal/section-contracts/dist/runners.js +5 -17
- package/dist/packages/internal/section-contracts/dist/select-contract.js +7 -1
- package/dist/packages/internal/section-contracts/dist/source-contract.js +20 -79
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/table-member.js +5 -8
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +5 -10
- package/dist/packages/internal/source-resolution/dist/index.js +21 -189
- package/dist/packages/internal/template-artifact/dist/index.js +2 -2
- package/dist/packages/internal/template-artifact/dist/layout.js +3 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +32 -16
- package/dist/packages/internal/template-contracts/dist/content-pick.js +24 -1
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +2 -6
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +3 -2
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +19 -43
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +24 -3
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +14 -7
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +3 -68
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +7 -6
- package/dist/packages/internal/template-contracts/dist/list-editing.js +0 -1
- package/dist/packages/internal/template-contracts/dist/list.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/list.js +7 -15
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +1 -1
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +2 -2
- package/dist/packages/internal/template-contracts/dist/object.js +3 -2
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +2 -2
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/read-graph.js +14 -51
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +15 -27
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +3 -1
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +13 -24
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +20 -4
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +69 -11
- package/dist/packages/internal/template-contracts/dist/row-planners.js +1 -1
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +5 -14
- package/dist/packages/internal/template-contracts/dist/row-ref.js +7 -23
- package/dist/packages/internal/template-contracts/dist/row-sources.js +6 -16
- package/dist/packages/internal/template-contracts/dist/row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/row.js +6 -7
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +5 -20
- package/dist/packages/internal/template-contracts/dist/section-schema-types.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +29 -37
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +4 -7
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +2 -733
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +2 -502
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +4 -1
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +4 -4
- package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -2
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +9 -10
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +5 -12
- package/dist/packages/internal/template-contracts/dist/table-members.js +7 -37
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +2 -2
- package/dist/primitives/Image.d.ts +3 -3
- package/dist/primitives/slot-bindings.js +2 -2
- package/dist/primitives/slot-download.d.ts +1 -1
- package/dist/primitives/slot-media.d.ts +1 -1
- package/dist/rules/registry.js +6 -0
- package/dist/schema/fact.d.ts +19 -52
- package/dist/schema/fact.js +6 -25
- package/dist/schema/facts-view.d.ts +1 -2
- package/dist/schema/property-facts.d.ts +1 -62
- package/dist/schema/section-schema.d.ts +2 -2
- package/dist/schema/section-schema.js +1 -1
- package/dist/section/section.d.ts +2 -2
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +4 -5
- package/package.json +1 -1
- package/dist/artifact/playground/client/assets/index-BUmdDDX5.js +0 -1259
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +0 -1
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
- package/dist/packages/internal/section-contracts/dist/group-contract.js +0 -19
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +0 -22
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +0 -19
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +0 -62
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +0 -167
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +0 -77
|
@@ -1,52 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { memberListOfKey, tableColumnOfKey } from "./registry-shape.js";
|
|
3
|
-
import { REGISTRY_FACT_LEGACY, registryMemberOfLegacy } from "./registry-aliases.js";
|
|
1
|
+
import { memberListOfKey, tableColumnOfKey, tableOf } from "./registry-shape.js";
|
|
4
2
|
import "./ref-locate.js";
|
|
5
3
|
import { isMediaListKey, isRegistryFactKey } from "./fact-keys.js";
|
|
6
4
|
|
|
7
5
|
//#region ../../internal/template-contracts/dist/read-graph.js
|
|
8
|
-
function tableBase(key) {
|
|
9
|
-
const table = tableKeyOf(key);
|
|
10
|
-
if (table === null) return null;
|
|
11
|
-
return table.reading === "registry" ? key : REGISTRY_TABLE_KEYS[table.table];
|
|
12
|
-
}
|
|
13
6
|
function rowBaseOf(from) {
|
|
14
7
|
const member = memberListOfKey(from);
|
|
15
8
|
if (member !== null) return `${from.slice(0, from.length - member.member.length - 1)}[].${member.member}`;
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
function primaryRowMember(table, container, legacy) {
|
|
19
|
-
const aliases = FACT_PROJECTIONS[container] ?? {};
|
|
20
|
-
const authored = Object.keys(aliases).find((name) => aliases[name] === legacy) ?? legacy;
|
|
21
|
-
return registryMemberOfLegacy(table, authored) ?? authored;
|
|
22
|
-
}
|
|
23
|
-
const LEGACY_REGISTRY = new Map(Object.entries(REGISTRY_FACT_LEGACY).map(([registry, legacy]) => [legacy, registry]));
|
|
24
|
-
const PRIMARY_ROW_TABLES = {
|
|
25
|
-
unit: "units",
|
|
26
|
-
contact: "contacts"
|
|
27
|
-
};
|
|
9
|
+
return tableOf(from) === null ? null : from;
|
|
10
|
+
}
|
|
28
11
|
function factPathOf(key) {
|
|
29
12
|
const column = tableColumnOfKey(key);
|
|
30
13
|
if (column !== null) return `${column.tableKey}[].${column.member}`;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (isRegistryFactKey(key) || isMediaListKey(key)) return key;
|
|
34
|
-
const registry = LEGACY_REGISTRY.get(key);
|
|
35
|
-
if (registry !== void 0) return registry;
|
|
36
|
-
const graph = FACT_GRAPH;
|
|
37
|
-
const entry = Object.hasOwn(graph, key) ? graph[key] : void 0;
|
|
38
|
-
if (entry?.primary_of !== void 0) return tableBase(entry.primary_of);
|
|
39
|
-
const container = entry?.container;
|
|
40
|
-
const primary = container === void 0 ? void 0 : PRIMARY_ROW_TABLES[container];
|
|
41
|
-
if (container === void 0 || primary === void 0) return null;
|
|
42
|
-
return `${REGISTRY_TABLE_KEYS[primary]}[0].${primaryRowMember(primary, container, key)}`;
|
|
14
|
+
if (tableOf(key) !== null || isRegistryFactKey(key) || isMediaListKey(key)) return key;
|
|
15
|
+
return null;
|
|
43
16
|
}
|
|
44
17
|
function fromList(from) {
|
|
45
18
|
return from === void 0 ? [] : typeof from === "string" ? [from] : [...from];
|
|
46
19
|
}
|
|
47
20
|
function rowPathsOf(slot) {
|
|
48
|
-
|
|
49
|
-
return (from.length > 0 ? from : slot.source?.kind === "home" && slot.source.key !== void 0 ? [slot.source.key] : []).map(rowBaseOf).filter((path) => path !== null);
|
|
21
|
+
return fromList(slot.from).map(rowBaseOf).filter((path) => path !== null);
|
|
50
22
|
}
|
|
51
23
|
function rowsIn(slots, outer) {
|
|
52
24
|
const rows = new Map(outer);
|
|
@@ -71,11 +43,10 @@ function unique(paths) {
|
|
|
71
43
|
return [...new Set(paths)];
|
|
72
44
|
}
|
|
73
45
|
function fillsOfDecision(decision) {
|
|
74
|
-
|
|
75
|
-
return decision.verb !== void 0 || decision.brief !== void 0 ? [decision] : [];
|
|
46
|
+
return decision.fills ?? [];
|
|
76
47
|
}
|
|
77
48
|
function ofTables(of) {
|
|
78
|
-
return (Array.isArray(of) ? of : [
|
|
49
|
+
return (Array.isArray(of) ? of : []).filter((ref) => typeof ref === "object" && ref !== null && ref.kind === "home");
|
|
79
50
|
}
|
|
80
51
|
function fillsByPath(spec) {
|
|
81
52
|
const byPath = /* @__PURE__ */ new Map();
|
|
@@ -143,15 +114,12 @@ function graphSlot(path, slot, scope, fill) {
|
|
|
143
114
|
slot: source.slot ?? ""
|
|
144
115
|
}
|
|
145
116
|
};
|
|
146
|
-
case "row": {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
requires: []
|
|
153
|
-
};
|
|
154
|
-
}
|
|
117
|
+
case "row": return {
|
|
118
|
+
...head,
|
|
119
|
+
kind: "member",
|
|
120
|
+
reads: memberPaths(scope.rows.get(source.slot ?? "") ?? [], source.field ?? ""),
|
|
121
|
+
requires: []
|
|
122
|
+
};
|
|
155
123
|
case "element": return {
|
|
156
124
|
...head,
|
|
157
125
|
kind: slot.type === "row" ? "row" : "element",
|
|
@@ -178,7 +146,6 @@ function walk(path, slot, scope, fills, into) {
|
|
|
178
146
|
const fields = slot.fields ?? {};
|
|
179
147
|
const inner = {
|
|
180
148
|
rows: rowsIn(fields, scope.rows),
|
|
181
|
-
listRows: scope.listRows,
|
|
182
149
|
when: whenOf(slot, scope.when)
|
|
183
150
|
};
|
|
184
151
|
for (const [field, def] of Object.entries(fields)) walk(`${path}.${field}`, def, inner, fills, into);
|
|
@@ -187,10 +154,8 @@ function walk(path, slot, scope, fills, into) {
|
|
|
187
154
|
into.push(graphSlot(path, slot, scope, fills.get(path)));
|
|
188
155
|
const element = slot.element;
|
|
189
156
|
if (slot.type !== "list" || element === void 0) return;
|
|
190
|
-
const listRows = slot.source?.kind === "home" && slot.source.key !== void 0 ? [rowBaseOf(slot.source.key)].filter((p) => p !== null) : [];
|
|
191
157
|
const item = {
|
|
192
158
|
rows: scope.rows,
|
|
193
|
-
listRows,
|
|
194
159
|
when: whenOf(slot, scope.when)
|
|
195
160
|
};
|
|
196
161
|
if (element.type !== "object") {
|
|
@@ -200,7 +165,6 @@ function walk(path, slot, scope, fills, into) {
|
|
|
200
165
|
const fields = element.fields ?? {};
|
|
201
166
|
const inner = {
|
|
202
167
|
rows: rowsIn(fields, scope.rows),
|
|
203
|
-
listRows,
|
|
204
168
|
when: whenOf(element, item.when)
|
|
205
169
|
};
|
|
206
170
|
for (const [field, def] of Object.entries(fields)) walk(`${path}[].${field}`, def, inner, fills, into);
|
|
@@ -231,7 +195,6 @@ function sectionGraphOf(schema, fillSpec) {
|
|
|
231
195
|
const slots = schema.slots;
|
|
232
196
|
const top = {
|
|
233
197
|
rows: rowsIn(slots, /* @__PURE__ */ new Map()),
|
|
234
|
-
listRows: [],
|
|
235
198
|
when: void 0
|
|
236
199
|
};
|
|
237
200
|
const fills = fillsByPath(fillSpec);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tableOf, tableOfSource } from "./registry-shape.js";
|
|
2
2
|
import "./mirror-kind.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/template-contracts/dist/ref-locate.js
|
|
@@ -82,20 +82,20 @@ function holderOf(slots, reader, key) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
function rowTableOf(row) {
|
|
85
|
-
return
|
|
85
|
+
return tableOf(row.from);
|
|
86
86
|
}
|
|
87
87
|
function rowTablesOf(row) {
|
|
88
88
|
if (!Array.isArray(row.from)) {
|
|
89
89
|
const table = rowTableOf(row);
|
|
90
90
|
return table === null ? [] : [table];
|
|
91
91
|
}
|
|
92
|
-
return row.from.flatMap((key) =>
|
|
92
|
+
return row.from.flatMap((key) => tableOf(key) ?? []);
|
|
93
93
|
}
|
|
94
94
|
function attributedRows(facts, tables) {
|
|
95
95
|
const seen = /* @__PURE__ */ new Set();
|
|
96
96
|
const out = [];
|
|
97
97
|
for (const table of tables) {
|
|
98
|
-
const rows = facts[table
|
|
98
|
+
const rows = facts[table];
|
|
99
99
|
for (const row of rows) {
|
|
100
100
|
const id = nonEmpty(row["id"]);
|
|
101
101
|
if (id === null || seen.has(id)) continue;
|
|
@@ -132,19 +132,15 @@ function isElementSource(source) {
|
|
|
132
132
|
function slotTableOf(scope, id) {
|
|
133
133
|
return oneTable(tablesAt(scope, scope.section, scope.slots, id, /* @__PURE__ */ new Set()));
|
|
134
134
|
}
|
|
135
|
-
function listTableOf(scope, list
|
|
136
|
-
return oneTable(listTablesOf(scope, list
|
|
135
|
+
function listTableOf(scope, list) {
|
|
136
|
+
return oneTable(listTablesOf(scope, list));
|
|
137
137
|
}
|
|
138
|
-
function listTablesOf(scope, list
|
|
139
|
-
if (list.fields !== void 0 && list.source === void 0) return pickedTables(pickedOf);
|
|
138
|
+
function listTablesOf(scope, list) {
|
|
140
139
|
return listTables(scope, scope.section, scope.slots, list, /* @__PURE__ */ new Set());
|
|
141
140
|
}
|
|
142
141
|
function oneTable(tables) {
|
|
143
142
|
return tables.length === 1 ? tables[0] : null;
|
|
144
143
|
}
|
|
145
|
-
function pickedTables(pickedOf) {
|
|
146
|
-
return (Array.isArray(pickedOf) ? pickedOf : [pickedOf]).flatMap((ref) => isRecord(ref) ? tableKeyOfSource(ref) ?? [] : []);
|
|
147
|
-
}
|
|
148
144
|
function tablesAt(scope, section, slots, id, seen) {
|
|
149
145
|
const visit = `${section ?? ""}\u0000${id}`;
|
|
150
146
|
if (seen.has(visit)) return [];
|
|
@@ -157,7 +153,7 @@ function tablesAt(scope, section, slots, id, seen) {
|
|
|
157
153
|
function listTables(scope, section, slots, list, seen) {
|
|
158
154
|
const source = isRecord(list.source) ? list.source : void 0;
|
|
159
155
|
if (source === void 0 || source["kind"] === "authored" || source["kind"] === "derived") return itemRowTablesOf(list.element);
|
|
160
|
-
const table =
|
|
156
|
+
const table = tableOfSource(source);
|
|
161
157
|
if (table !== null) return [table];
|
|
162
158
|
const { kind, section: target, slot } = source;
|
|
163
159
|
if (kind !== "section" || typeof target !== "string" || typeof slot !== "string") return [];
|
|
@@ -166,27 +162,19 @@ function listTables(scope, section, slots, list, seen) {
|
|
|
166
162
|
return other === void 0 ? [] : tablesAt(scope, target, other, slot, seen);
|
|
167
163
|
}
|
|
168
164
|
const nonEmpty = (value) => typeof value === "string" && value !== "" ? value : null;
|
|
169
|
-
function elementIdentityKey(table) {
|
|
170
|
-
return table === null || !isLegacyTable(table) ? "id" : TABLES[table].idKey;
|
|
171
|
-
}
|
|
172
|
-
const LEGACY_IDENTITY_KEYS = [...new Set(Object.values(TABLES).map((table) => table.idKey))].filter((key) => key !== "id");
|
|
173
165
|
function elementIdentity(element, table = null) {
|
|
174
166
|
if (typeof element === "string") return table === null ? null : nonEmpty(element);
|
|
175
|
-
const field = elementIdentityField(element
|
|
167
|
+
const field = elementIdentityField(element);
|
|
176
168
|
return field === null ? null : nonEmpty(element[field]);
|
|
177
169
|
}
|
|
178
|
-
function elementIdentityField(element
|
|
170
|
+
function elementIdentityField(element) {
|
|
179
171
|
if (!isRecord(element)) return null;
|
|
180
|
-
return
|
|
181
|
-
"id",
|
|
182
|
-
"asset_id",
|
|
183
|
-
...LEGACY_IDENTITY_KEYS
|
|
184
|
-
] : [
|
|
185
|
-
elementIdentityKey(table.table),
|
|
172
|
+
return [
|
|
186
173
|
"id",
|
|
187
|
-
"
|
|
188
|
-
|
|
174
|
+
"media",
|
|
175
|
+
"file"
|
|
176
|
+
].find((key) => nonEmpty(element[key]) !== null) ?? null;
|
|
189
177
|
}
|
|
190
178
|
|
|
191
179
|
//#endregion
|
|
192
|
-
export { attributedRows, elementIdentity, elementIdentityField,
|
|
180
|
+
export { attributedRows, elementIdentity, elementIdentityField, heldRowTableOf, holderOf, isHolderKind, itemHolderOf, itemRowTablesOf, listTableOf, listTablesOf, mirrorRefOf, placementOf, refSectionKey, rowTableOf, rowTablesOf, sectionSlotAt, slotInScope, slotTableOf };
|
|
@@ -174,6 +174,8 @@ interface HomeMediaValue {
|
|
|
174
174
|
interface RenditionInputs {
|
|
175
175
|
crop: MediaCrop | null;
|
|
176
176
|
options: Record<string, unknown>;
|
|
177
|
+
/** The version of the pass that cut it, where that pass is versioned (the cut-out's); a newer pass re-cuts. */
|
|
178
|
+
version?: string;
|
|
177
179
|
}
|
|
178
180
|
/** A rendition a place's own processing cut, with the inputs it was cut at. */
|
|
179
181
|
interface PlaceRendition extends Rendition {
|
|
@@ -181,7 +183,7 @@ interface PlaceRendition extends Rendition {
|
|
|
181
183
|
}
|
|
182
184
|
/**
|
|
183
185
|
* The place members a record carries: a home value's, `name` resolved. `id` is the media
|
|
184
|
-
* id and `file` the file's — one id
|
|
186
|
+
* id and `file` the file's — one id for a value born over its own file.
|
|
185
187
|
*/
|
|
186
188
|
interface PlaceMembers {
|
|
187
189
|
id: string;
|
|
@@ -81,24 +81,23 @@ function isMediaRecord(value) {
|
|
|
81
81
|
return typeof id === "string" && typeof kind === "string" && isMediaKind(kind) && isObject(renditions);
|
|
82
82
|
}
|
|
83
83
|
function isHomeMediaValue(value) {
|
|
84
|
-
return isObject(value) && typeof value["id"] === "string" && typeof value["file"] === "string" && isObject(value["renditions"]) && !("kind" in value);
|
|
84
|
+
return isObject(value) && typeof value["id"] === "string" && typeof value["file"] === "string" && isObject(value["renditions"]) && !("kind" in value) && !("picked" in value);
|
|
85
85
|
}
|
|
86
86
|
function isContentMediaValue(value) {
|
|
87
|
-
return isObject(value) && typeof value["file"] === "string" && "
|
|
87
|
+
return isObject(value) && typeof value["file"] === "string" && value["file"] !== "" && !isHomeMediaValue(value) && !isMediaRecord(value);
|
|
88
88
|
}
|
|
89
89
|
function isMediaReference(value) {
|
|
90
90
|
return isObject(value) && typeof value["media"] === "string" && value["media"] !== "";
|
|
91
91
|
}
|
|
92
|
-
function storedReferenceOf(value) {
|
|
93
|
-
const id = value["asset_id"];
|
|
94
|
-
return typeof id === "string" && id !== "" ? id : void 0;
|
|
95
|
-
}
|
|
96
92
|
function mediaIdOf(value) {
|
|
97
93
|
if (!isObject(value)) return void 0;
|
|
98
94
|
if (isMediaReference(value)) return value.media;
|
|
99
95
|
if (isHomeMediaValue(value) || isMediaRecord(value)) return value.id;
|
|
100
96
|
if (isContentMediaValue(value)) return value.picked ?? value.file;
|
|
101
|
-
|
|
97
|
+
}
|
|
98
|
+
function contentMediaIdOf(value) {
|
|
99
|
+
if (isMediaReference(value)) return value.media;
|
|
100
|
+
if (isContentMediaValue(value)) return value.file;
|
|
102
101
|
}
|
|
103
102
|
function collectOwning(value, into) {
|
|
104
103
|
if (Array.isArray(value)) for (const item of value) collectOwning(item, into);
|
|
@@ -126,17 +125,6 @@ function mediaRecords(document) {
|
|
|
126
125
|
}
|
|
127
126
|
return out;
|
|
128
127
|
}
|
|
129
|
-
function copyRecordOf(value, document) {
|
|
130
|
-
const file = fileIn(document, value.file);
|
|
131
|
-
if (file === void 0) return null;
|
|
132
|
-
return mergeMedia(file, {
|
|
133
|
-
id: value.picked ?? value.file,
|
|
134
|
-
file: value.file,
|
|
135
|
-
crop: value.crop,
|
|
136
|
-
name: value.name,
|
|
137
|
-
renditions: value.renditions
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
128
|
function hasOwnFraming(own) {
|
|
141
129
|
return Object.hasOwn(own, "crop") || own.renditions !== void 0;
|
|
142
130
|
}
|
|
@@ -178,10 +166,8 @@ function readAsRecords(value, document) {
|
|
|
178
166
|
});
|
|
179
167
|
if (!isObject(at) || isMediaRecord(at)) return at;
|
|
180
168
|
if (isHomeMediaValue(at)) return recordOf(at, document);
|
|
181
|
-
if (isContentMediaValue(at)) return
|
|
169
|
+
if (isContentMediaValue(at)) return resolve(at.file);
|
|
182
170
|
if (isMediaReference(at)) return framedAt(resolve(at.media), at);
|
|
183
|
-
const stored = storedReferenceOf(at);
|
|
184
|
-
if (stored !== void 0) return resolve(stored);
|
|
185
171
|
const out = {};
|
|
186
172
|
for (const [key, member] of Object.entries(at)) out[key] = read(member);
|
|
187
173
|
return out;
|
|
@@ -191,12 +177,15 @@ function readAsRecords(value, document) {
|
|
|
191
177
|
function storedAsRefs(value) {
|
|
192
178
|
if (Array.isArray(value)) return value.map(storedAsRefs);
|
|
193
179
|
if (!isObject(value)) return value;
|
|
194
|
-
if (isMediaRecord(value) || isHomeMediaValue(value)) return {
|
|
195
|
-
if (isMediaReference(value))
|
|
180
|
+
if (isMediaRecord(value) || isHomeMediaValue(value)) return { media: value.id };
|
|
181
|
+
if (isMediaReference(value)) {
|
|
182
|
+
const { crop: _crop, renditions: _renditions, ...context } = value;
|
|
183
|
+
return context;
|
|
184
|
+
}
|
|
196
185
|
const out = {};
|
|
197
186
|
for (const [key, member] of Object.entries(value)) out[key] = storedAsRefs(member);
|
|
198
187
|
return out;
|
|
199
188
|
}
|
|
200
189
|
|
|
201
190
|
//#endregion
|
|
202
|
-
export { FILE_RENDITION_NAMES, PLACE_RENDITION_NAMES, RENDITION_NAMES, cropsPart, fileNameOf, framedAt, framingOver, hasOwnFraming, isContentMediaValue, isHomeMediaValue, isMediaRecord, isMediaReference, mediaIdOf, mediaRecords, mergeMedia, owningValues, readAsRecords, recordOf, splitMedia, storedAsRefs, videoSourceOf };
|
|
191
|
+
export { FILE_RENDITION_NAMES, PLACE_RENDITION_NAMES, RENDITION_NAMES, contentMediaIdOf, cropsPart, fileNameOf, framedAt, framingOver, hasOwnFraming, isContentMediaValue, isHomeMediaValue, isMediaRecord, isMediaReference, mediaIdOf, mediaRecords, mergeMedia, owningValues, readAsRecords, recordOf, splitMedia, storedAsRefs, videoSourceOf };
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LibraryFactRegistry, PropertyTablePages } from "./fact-registry.js";
|
|
1
|
+
import { LibraryTablePages, PropertyTablePages } from "./fact-registry.js";
|
|
3
2
|
//#region ../../internal/template-contracts/dist/registry-shape.d.ts
|
|
3
|
+
type LibraryTable = keyof LibraryTablePages & string;
|
|
4
|
+
/**
|
|
5
|
+
* A table's name — a list of objects a home declares, by its page: the property's own and
|
|
6
|
+
* the library's (`contacts`). Typed off each home's table pages (`PropertyTablePages`,
|
|
7
|
+
* `LibraryTablePages`), which the registries' own types cannot be read for: the grammar
|
|
8
|
+
* that builds them reads this type. `fact-registry.test.ts` holds both to `tableNames()`.
|
|
9
|
+
*/
|
|
10
|
+
type RegistryTable = (keyof PropertyTablePages & string) | LibraryTable;
|
|
11
|
+
/** A table's registry key: a property list reading it (`property.units`, `property.contacts`), or the library list holding it (`library.contacts`). */
|
|
12
|
+
type RegistryTableKey = `property.${RegistryTable}` | `library.${LibraryTable}`;
|
|
4
13
|
type ItemFieldsOf<Page> = Page extends {
|
|
5
14
|
readonly declaration: {
|
|
6
15
|
readonly element: {
|
|
@@ -8,6 +17,13 @@ type ItemFieldsOf<Page> = Page extends {
|
|
|
8
17
|
};
|
|
9
18
|
};
|
|
10
19
|
} ? F : never;
|
|
20
|
+
/** The item declaration of a table's list, as the registry types it — off the table's own page (see {@link TableFieldsOf}). */
|
|
21
|
+
type TableElementOf<T extends RegistryTable> = T extends LibraryTable ? ItemOf<LibraryTablePages[T]> : T extends keyof PropertyTablePages ? ItemOf<PropertyTablePages[T]> : never;
|
|
22
|
+
type ItemOf<Page> = Page extends {
|
|
23
|
+
readonly declaration: {
|
|
24
|
+
readonly element: infer E;
|
|
25
|
+
};
|
|
26
|
+
} ? E : never;
|
|
11
27
|
/**
|
|
12
28
|
* The declarations of a table's members, as the registry types them — the library's
|
|
13
29
|
* contacts, the property's other lists. A property table is read off its own page
|
|
@@ -15,7 +31,7 @@ type ItemFieldsOf<Page> = Page extends {
|
|
|
15
31
|
* contacts from a row's members, which are typed here, so it cannot be read while it is
|
|
16
32
|
* being typed.
|
|
17
33
|
*/
|
|
18
|
-
type TableFieldsOf<T extends RegistryTable> = T extends
|
|
34
|
+
type TableFieldsOf<T extends RegistryTable> = T extends LibraryTable ? ItemFieldsOf<LibraryTablePages[T]> : T extends keyof PropertyTablePages ? ItemFieldsOf<PropertyTablePages[T]> : never;
|
|
19
35
|
/** {@link memberValueType}, at the type level. */
|
|
20
36
|
type MemberValueTypeOf<D> = D extends {
|
|
21
37
|
readonly type: "list";
|
|
@@ -38,4 +54,4 @@ type MemberValueTypeOf<D> = D extends {
|
|
|
38
54
|
readonly type: "text" | "select" | "email" | "phone" | "url" | "date";
|
|
39
55
|
} ? "text" : never;
|
|
40
56
|
//#endregion
|
|
41
|
-
export { MemberValueTypeOf, TableFieldsOf };
|
|
57
|
+
export { MemberValueTypeOf, RegistryTable, RegistryTableKey, TableElementOf, TableFieldsOf };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ADDRESS_MEMBERS } from "./address-value.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isMediaKind } from "./slot-catalog.js";
|
|
3
3
|
import { isFactCompute } from "./fact-compute.js";
|
|
4
4
|
import "./media-candidates.js";
|
|
5
5
|
|
|
@@ -88,8 +88,63 @@ function factValueType(key, declaration) {
|
|
|
88
88
|
function addressPartValueType(part) {
|
|
89
89
|
return part === "latitude" || part === "longitude" ? "number" : "text";
|
|
90
90
|
}
|
|
91
|
+
function tableOfList(name, declaration) {
|
|
92
|
+
if (declaration.type !== "list") return null;
|
|
93
|
+
const element = declaration.element;
|
|
94
|
+
if (element.type === "object") return name;
|
|
95
|
+
if (element.type === "row") return element.from.slice(element.from.indexOf(".") + 1);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
let TABLE_KEYS;
|
|
99
|
+
function linkedTableKeys() {
|
|
100
|
+
if (TABLE_KEYS !== void 0) return TABLE_KEYS;
|
|
101
|
+
linkedRegistry("library");
|
|
102
|
+
const keys = /* @__PURE__ */ new Map();
|
|
103
|
+
for (const registry of LINKED.values()) for (const [name, page] of Object.entries(registry.pages)) {
|
|
104
|
+
const table = tableOfList(name, page.declaration);
|
|
105
|
+
if (table !== null) keys.set(`${registry.home}.${name}`, table);
|
|
106
|
+
}
|
|
107
|
+
if (LINKED.has("property") && LINKED.has("library")) TABLE_KEYS = keys;
|
|
108
|
+
return keys;
|
|
109
|
+
}
|
|
110
|
+
function tableNames() {
|
|
111
|
+
return [...new Set(linkedTableKeys().values())];
|
|
112
|
+
}
|
|
113
|
+
function tableOf(key) {
|
|
114
|
+
return typeof key === "string" ? linkedTableKeys().get(key) ?? null : null;
|
|
115
|
+
}
|
|
116
|
+
function tableOfSource(source) {
|
|
117
|
+
return source?.kind === "home" ? tableOf(source.key) : null;
|
|
118
|
+
}
|
|
119
|
+
function tableForSlot(slot) {
|
|
120
|
+
return tableOfSource(slot.source);
|
|
121
|
+
}
|
|
91
122
|
function tableHome(table) {
|
|
92
|
-
|
|
123
|
+
for (const registry of LINKED.values()) {
|
|
124
|
+
const page = Object.hasOwn(registry.pages, table) ? registry.pages[table] : void 0;
|
|
125
|
+
if (page?.declaration.type === "list" && page.declaration.element.type === "object") return registry.home;
|
|
126
|
+
}
|
|
127
|
+
throw new Error(`fact registry: no linked registry declares a table "${table}"`);
|
|
128
|
+
}
|
|
129
|
+
function tableKey(table) {
|
|
130
|
+
return `property.${table}`;
|
|
131
|
+
}
|
|
132
|
+
function tableBounds(table) {
|
|
133
|
+
const declaration = linkedRegistry("property").pages[table]?.declaration;
|
|
134
|
+
if (declaration?.type !== "list") return {};
|
|
135
|
+
return {
|
|
136
|
+
...typeof declaration.min === "number" ? { min: declaration.min } : {},
|
|
137
|
+
...typeof declaration.max === "number" ? { max: declaration.max } : {}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function stampTableBounds(slots) {
|
|
141
|
+
for (const slot of Object.values(slots)) {
|
|
142
|
+
const table = tableForSlot(slot);
|
|
143
|
+
if (table === null) continue;
|
|
144
|
+
const inherited = tableBounds(table);
|
|
145
|
+
if (slot.min === void 0 && inherited.min !== void 0) slot.min = inherited.min;
|
|
146
|
+
if (slot.max === void 0 && inherited.max !== void 0) slot.max = inherited.max;
|
|
147
|
+
}
|
|
93
148
|
}
|
|
94
149
|
function tableFieldsIn(registry, table) {
|
|
95
150
|
const page = registry.pages[table];
|
|
@@ -103,15 +158,18 @@ function linkedTableFields(table) {
|
|
|
103
158
|
function fieldOf(fields, member) {
|
|
104
159
|
return Object.hasOwn(fields, member) ? fields[member] : void 0;
|
|
105
160
|
}
|
|
161
|
+
function tableMemberValueType(table, member) {
|
|
162
|
+
const declaration = fieldOf(linkedTableFields(table), member);
|
|
163
|
+
return declaration === void 0 ? void 0 : memberValueType(declaration);
|
|
164
|
+
}
|
|
106
165
|
function memberListOfKey(key) {
|
|
107
166
|
if (typeof key !== "string") return null;
|
|
108
167
|
const dot = key.lastIndexOf(".");
|
|
109
168
|
if (dot <= 0) return null;
|
|
110
|
-
const table =
|
|
111
|
-
if (table
|
|
169
|
+
const table = tableOf(key.slice(0, dot));
|
|
170
|
+
if (table === null) return null;
|
|
112
171
|
const member = key.slice(dot + 1);
|
|
113
|
-
|
|
114
|
-
return declaration !== void 0 && memberValueType(declaration) === "row_list" ? {
|
|
172
|
+
return tableMemberValueType(table, member) === "row_list" ? {
|
|
115
173
|
table,
|
|
116
174
|
member
|
|
117
175
|
} : null;
|
|
@@ -121,15 +179,15 @@ function tableColumnOfKey(key) {
|
|
|
121
179
|
const dot = key.lastIndexOf(".");
|
|
122
180
|
if (dot <= 0) return null;
|
|
123
181
|
const tableKey = key.slice(0, dot);
|
|
124
|
-
const table =
|
|
125
|
-
if (table
|
|
182
|
+
const table = tableOf(tableKey);
|
|
183
|
+
if (table === null) return null;
|
|
126
184
|
const member = key.slice(dot + 1);
|
|
127
|
-
return
|
|
128
|
-
table
|
|
185
|
+
return tableMemberValueType(table, member) === void 0 ? null : {
|
|
186
|
+
table,
|
|
129
187
|
tableKey,
|
|
130
188
|
member
|
|
131
189
|
};
|
|
132
190
|
}
|
|
133
191
|
|
|
134
192
|
//#endregion
|
|
135
|
-
export { addressPartValueType, fieldOf, isDerived, isMediaListDeclaration, linkRegistry, linkedRegistry, linkedTableFields, mediaListKeysOf, memberListOfKey, memberValueType, registryFactsOf, tableColumnOfKey, tableFieldsIn, tableHome };
|
|
193
|
+
export { addressPartValueType, fieldOf, isDerived, isMediaListDeclaration, linkRegistry, linkedRegistry, linkedTableFields, mediaListKeysOf, memberListOfKey, memberValueType, registryFactsOf, stampTableBounds, tableBounds, tableColumnOfKey, tableFieldsIn, tableForSlot, tableHome, tableKey, tableMemberValueType, tableNames, tableOf, tableOfSource };
|
|
@@ -17,7 +17,7 @@ function plannerForField(field) {
|
|
|
17
17
|
const element = field.element?.type;
|
|
18
18
|
if (element === "select") return "select";
|
|
19
19
|
if (isFindableKind(element) || element === "object" || element === "row") return void 0;
|
|
20
|
-
if (poolingPrimitiveOf({ type: element }) !== void 0) return "
|
|
20
|
+
if (poolingPrimitiveOf({ type: element }) !== void 0) return "mediaList";
|
|
21
21
|
return "list";
|
|
22
22
|
}
|
|
23
23
|
if (field.type === "text" || isValueKind(field.type)) return "text";
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import { AddressMember, AddressValue } from "./address-value.js";
|
|
2
|
-
import { LIBRARY_TABLE_KEYS, REGISTRY_TABLE_KEYS, RegistryTable, RegistryTableKey, TABLES, TableField } from "./slot-catalog.js";
|
|
3
2
|
import { PoiRow } from "./poi-row.js";
|
|
4
3
|
import { ImageValue } from "./runtime-values.js";
|
|
5
|
-
import { MemberValueTypeOf, TableFieldsOf } from "./registry-shape.js";
|
|
4
|
+
import { MemberValueTypeOf, RegistryTable, RegistryTableKey, TableFieldsOf } from "./registry-shape.js";
|
|
6
5
|
import { RegistryTableRow } from "./table-members.js";
|
|
7
6
|
import { ComputeBinding } from "./compute.js";
|
|
8
7
|
import { SlotValue } from "./slot-value.js";
|
|
9
8
|
import { ElementRef, RowRef, SiblingSlot, SlotRef } from "./slot-ref.js";
|
|
10
9
|
import { DocumentMediaValue } from "./registry-facts.js";
|
|
11
10
|
//#region ../../internal/template-contracts/dist/row-ref.d.ts
|
|
12
|
-
/** The library key naming table `T`, where the library holds its rows. */
|
|
13
|
-
type LibraryKeyOf<T extends RegistryTable> = T extends keyof typeof LIBRARY_TABLE_KEYS ? (typeof LIBRARY_TABLE_KEYS)[T] : never;
|
|
14
11
|
/** The table a registry table key names — `units` for `property.units`, `contacts` for `library.contacts`. */
|
|
15
|
-
type TableOfKey<K extends RegistryTableKey> =
|
|
16
|
-
/**
|
|
17
|
-
* The identity key a table's items carry in a section's content — `TABLES[t].idKey`,
|
|
18
|
-
* `unit_id` on a unit — or `id` for a table with no legacy entry. It does not move with the
|
|
19
|
-
* reading: only what a `compute()` sees does.
|
|
20
|
-
*/
|
|
21
|
-
type TableIdKey<K extends RegistryTableKey> = TableOfKey<K> extends TableField ? (typeof TABLES)[TableOfKey<K>]["idKey"] : "id";
|
|
12
|
+
type TableOfKey<K extends RegistryTableKey> = K extends `${string}.${infer T extends RegistryTable}` ? T : never;
|
|
22
13
|
/**
|
|
23
14
|
* The keys a row slot's definition owns (`RowSlotDef`'s, ./row.ts). A row answers each
|
|
24
15
|
* from its definition — present or not — and never as a member, but where its table has
|
|
@@ -77,8 +68,8 @@ type MemberRef<T extends RegistryTable, M extends keyof Members<T> & string> = R
|
|
|
77
68
|
/**
|
|
78
69
|
* What a row of table `K` offers: one member ref per member of the table's registry row
|
|
79
70
|
* (`linkedTableFields`). A slot sourced by one fits its value (`MemberValue`); a
|
|
80
|
-
* `compute()` reading one receives what the facts document holds — an image's
|
|
81
|
-
* `{
|
|
71
|
+
* `compute()` reading one receives what the facts document holds — an image's value
|
|
72
|
+
* or `{ media }` reference, `null` for an unanswered member. The mapping only FILTERS the table's
|
|
82
73
|
* keys, so each member's doc comment is what an author reads hovering `unit.beds`.
|
|
83
74
|
*/
|
|
84
75
|
type TableRow<K extends RegistryTableKey> = { readonly [M in keyof Members<TableOfKey<K>> & string]: MemberRef<TableOfKey<K>, M>; };
|
|
@@ -130,4 +121,4 @@ type OriginTableOf<Source> = Source extends ElementRef<infer V, infer T> ? T ext
|
|
|
130
121
|
*/
|
|
131
122
|
type AddressMembers = { readonly [M in AddressMember]: RowRef<M, AddressValue[M]>; };
|
|
132
123
|
//#endregion
|
|
133
|
-
export { AddressMembers, AddressPartRefs, ElementOf, ElementTableOf, MemberListItem, MemberListRow, OriginTableOf, ROW_OWN_KEYS, RowId, RowOwnKey,
|
|
124
|
+
export { AddressMembers, AddressPartRefs, ElementOf, ElementTableOf, MemberListItem, MemberListRow, OriginTableOf, ROW_OWN_KEYS, RowId, RowOwnKey, TableOfKey, TableRow };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isAddressMember } from "./address-value.js";
|
|
2
|
-
import { FACT_GRAPH, TABLES } from "./slot-catalog.js";
|
|
3
2
|
import { ROW_OF } from "./slot-ref.js";
|
|
4
|
-
import {
|
|
3
|
+
import { linkedTableFields, tableMemberValueType } from "./registry-shape.js";
|
|
5
4
|
|
|
6
5
|
//#region ../../internal/template-contracts/dist/row-ref.js
|
|
7
6
|
const ROW_OWN_KEYS = [
|
|
@@ -23,12 +22,10 @@ function withTable(slot, table) {
|
|
|
23
22
|
function carriedTable(x) {
|
|
24
23
|
if (typeof x !== "object" || x === null) return null;
|
|
25
24
|
const table = x[TABLE_OF];
|
|
26
|
-
return typeof table === "
|
|
25
|
+
return typeof table === "string" ? table : null;
|
|
27
26
|
}
|
|
28
|
-
function tableMembers(
|
|
29
|
-
|
|
30
|
-
const row = FACT_GRAPH[key.table].row;
|
|
31
|
-
return Object.keys(row).filter((member) => member !== TABLES[key.table].idKey && !ROW_OWN.has(member));
|
|
27
|
+
function tableMembers(table) {
|
|
28
|
+
return Object.keys(linkedTableFields(table));
|
|
32
29
|
}
|
|
33
30
|
function memberRef(row, field) {
|
|
34
31
|
return Object.freeze({
|
|
@@ -48,19 +45,6 @@ function rowDefinition(slot) {
|
|
|
48
45
|
const definition = slot[ROW_DEFINITION];
|
|
49
46
|
return typeof definition === "object" && definition !== null ? definition : slot;
|
|
50
47
|
}
|
|
51
|
-
function isAddressValued(table, member) {
|
|
52
|
-
if (table.reading === "legacy") return false;
|
|
53
|
-
const declaration = fieldOf(linkedTableFields(table.table), member);
|
|
54
|
-
return declaration !== void 0 && memberValueType(declaration) === "address";
|
|
55
|
-
}
|
|
56
|
-
function memberKindOf(table, member) {
|
|
57
|
-
if (table.reading === "legacy") {
|
|
58
|
-
const row = FACT_GRAPH[table.table].row;
|
|
59
|
-
return Object.hasOwn(row, member) ? String(row[member].value_type) : void 0;
|
|
60
|
-
}
|
|
61
|
-
const declaration = fieldOf(linkedTableFields(table.table), member);
|
|
62
|
-
return declaration === void 0 ? void 0 : String(memberValueType(declaration) ?? "");
|
|
63
|
-
}
|
|
64
48
|
const PROBED_KEYS = /* @__PURE__ */ new Set([
|
|
65
49
|
"then",
|
|
66
50
|
"toJSON",
|
|
@@ -77,12 +61,12 @@ function rowWithMembers(def, table, also = []) {
|
|
|
77
61
|
if (typeof key !== "string") return Reflect.get(target, key, receiver);
|
|
78
62
|
if (table !== null && members !== null) {
|
|
79
63
|
const tables = [table, ...also];
|
|
80
|
-
const kinds = tables.map((each) => each === table
|
|
64
|
+
const kinds = tables.map((each) => each === table && !members.has(key) ? void 0 : tableMemberValueType(each, key));
|
|
81
65
|
if (kinds.every((kind) => kind === void 0)) return Reflect.get(target, key, receiver);
|
|
82
66
|
const misfit = kinds.findIndex((kind) => kind === void 0 || kind !== kinds[0]);
|
|
83
|
-
if (misfit === -1) return
|
|
67
|
+
if (misfit === -1) return kinds[0] === "address" ? addressMemberRef(proxy, key) : memberRef(proxy, key);
|
|
84
68
|
if (key in target || ROW_OWN.has(key)) return Reflect.get(target, key, receiver);
|
|
85
|
-
throw new Error(`row: "${String(target.label)}" reads the member "${key}", which its \`from\` table ${tables[misfit]
|
|
69
|
+
throw new Error(`row: "${String(target.label)}" reads the member "${key}", which its \`from\` table ${tables[misfit]} ${kinds[misfit] === void 0 ? "lacks" : "holds at another kind"} — every table a row names carries every member its readers read, at one kind.`);
|
|
86
70
|
}
|
|
87
71
|
if (key in target || ROW_OWN.has(key)) return Reflect.get(target, key, receiver);
|
|
88
72
|
return PROBED_KEYS.has(key) ? void 0 : memberRef(proxy, key);
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tableOf } from "./registry-shape.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../internal/template-contracts/dist/row-sources.js
|
|
4
4
|
function sourceRecord(source) {
|
|
5
5
|
return source !== null && typeof source === "object" ? source : null;
|
|
6
6
|
}
|
|
7
|
-
function rowMemberOf(source) {
|
|
8
|
-
const src = sourceRecord(source);
|
|
9
|
-
if (src?.["kind"] !== "row" || "slot" in src) return null;
|
|
10
|
-
return typeof src["field"] === "string" ? src["field"] : null;
|
|
11
|
-
}
|
|
12
7
|
function memberSourceOf(source) {
|
|
13
8
|
const src = sourceRecord(source);
|
|
14
9
|
if (src?.["kind"] !== "row") return null;
|
|
@@ -26,17 +21,12 @@ function rowMemberSources(fields) {
|
|
|
26
21
|
const elementRows = new Set(elementRowKeys(fields));
|
|
27
22
|
const map = {};
|
|
28
23
|
for (const [key, field] of Object.entries(fields ?? {})) {
|
|
29
|
-
const member =
|
|
30
|
-
if (member !== null) map[key] = member;
|
|
24
|
+
const member = memberSourceOf(field.source);
|
|
25
|
+
if (member !== null && elementRows.has(member.slot)) map[key] = member.field;
|
|
31
26
|
}
|
|
32
27
|
return map;
|
|
33
28
|
}
|
|
34
|
-
function elementMemberOf(source, elementRows) {
|
|
35
|
-
const member = memberSourceOf(source);
|
|
36
|
-
return member !== null && elementRows.has(member.slot) ? member.field : null;
|
|
37
|
-
}
|
|
38
29
|
function listItemFieldsOf(list) {
|
|
39
|
-
if (list.fields !== void 0) return list.fields;
|
|
40
30
|
if (list.element?.type === "object") return list.element.fields;
|
|
41
31
|
}
|
|
42
32
|
function listSourceOf(list) {
|
|
@@ -44,10 +34,10 @@ function listSourceOf(list) {
|
|
|
44
34
|
if (src === null || src["kind"] === "authored") return { kind: "none" };
|
|
45
35
|
const { kind, key, section, slot, transform } = src;
|
|
46
36
|
if (kind === "home" && typeof key === "string") {
|
|
47
|
-
const table =
|
|
37
|
+
const table = tableOf(key);
|
|
48
38
|
if (table !== null) return {
|
|
49
39
|
kind: "table",
|
|
50
|
-
table
|
|
40
|
+
table
|
|
51
41
|
};
|
|
52
42
|
}
|
|
53
43
|
if (kind === "section" && typeof section === "string" && typeof slot === "string") return {
|
|
@@ -63,4 +53,4 @@ function listSourceOf(list) {
|
|
|
63
53
|
}
|
|
64
54
|
|
|
65
55
|
//#endregion
|
|
66
|
-
export { elementRowKeys, listItemFieldsOf, listSourceOf, memberSourceOf,
|
|
56
|
+
export { elementRowKeys, listItemFieldsOf, listSourceOf, memberSourceOf, rowMemberSources };
|