@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
|
@@ -2,14 +2,6 @@ import { mergeLinkedValue } from "./linked-merge.js";
|
|
|
2
2
|
|
|
3
3
|
//#region ../../internal/fill-bake/dist/item-merge.js
|
|
4
4
|
const isTempId = (id) => typeof id === "string" && id.startsWith("tmp_");
|
|
5
|
-
function spelledUnder(idKey, cur) {
|
|
6
|
-
if (idKey === "id" || typeof cur[idKey] === "string" || typeof cur["id"] !== "string") return cur;
|
|
7
|
-
const { id, ...rest } = cur;
|
|
8
|
-
return {
|
|
9
|
-
[idKey]: id,
|
|
10
|
-
...rest
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
5
|
function oneItemPerIdentity(idKey, current) {
|
|
14
6
|
const out = [];
|
|
15
7
|
const at = /* @__PURE__ */ new Map();
|
|
@@ -42,22 +34,27 @@ function mergeItem(cur, fresh, itemOverrides, generatedFields, idKey, keepUnbake
|
|
|
42
34
|
}
|
|
43
35
|
function mergeSourcedItems(input) {
|
|
44
36
|
const membership = input.membership ?? "table";
|
|
45
|
-
const
|
|
37
|
+
const idKey = input.idKey ?? "id";
|
|
38
|
+
const current = oneItemPerIdentity(idKey, input.current);
|
|
46
39
|
if (membership === "table") return mergeTableItems({
|
|
47
40
|
...input,
|
|
41
|
+
idKey,
|
|
48
42
|
current
|
|
49
43
|
});
|
|
50
|
-
const { freshSource, overrides, generatedFields
|
|
44
|
+
const { freshSource, overrides, generatedFields } = input;
|
|
51
45
|
const currentById = /* @__PURE__ */ new Map();
|
|
52
46
|
for (const cur of current) {
|
|
53
47
|
const id = cur[idKey];
|
|
54
48
|
if (typeof id === "string") currentById.set(id, cur);
|
|
55
49
|
}
|
|
56
|
-
if (membership === "source")
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
if (membership === "source") {
|
|
51
|
+
if (input.ordered === true) return mergeOrderedSourceItems(current, freshSource, input, idKey);
|
|
52
|
+
return freshSource.map((fresh) => {
|
|
53
|
+
const id = fresh[idKey];
|
|
54
|
+
const cur = typeof id === "string" ? currentById.get(id) : void 0;
|
|
55
|
+
return cur === void 0 ? fresh : mergeItem(cur, fresh, overrides?.[id], generatedFields, idKey, true);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
61
58
|
const freshById = /* @__PURE__ */ new Map();
|
|
62
59
|
for (const fresh of freshSource) {
|
|
63
60
|
const id = fresh[idKey];
|
|
@@ -69,8 +66,30 @@ function mergeSourcedItems(input) {
|
|
|
69
66
|
return fresh === void 0 ? cur : mergeItem(cur, fresh, overrides?.[id], generatedFields, idKey, true);
|
|
70
67
|
});
|
|
71
68
|
}
|
|
69
|
+
function mergeOrderedSourceItems(current, freshSource, input, idKey) {
|
|
70
|
+
const freshById = /* @__PURE__ */ new Map();
|
|
71
|
+
for (const fresh of freshSource) {
|
|
72
|
+
const id = fresh[idKey];
|
|
73
|
+
if (typeof id === "string") freshById.set(id, fresh);
|
|
74
|
+
}
|
|
75
|
+
const out = [];
|
|
76
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
77
|
+
for (const cur of current) {
|
|
78
|
+
const id = cur[idKey];
|
|
79
|
+
const fresh = typeof id === "string" ? freshById.get(id) : void 0;
|
|
80
|
+
if (fresh === void 0 || emitted.has(id)) continue;
|
|
81
|
+
out.push(mergeItem(cur, fresh, input.overrides?.[id], input.generatedFields, idKey, true));
|
|
82
|
+
emitted.add(id);
|
|
83
|
+
}
|
|
84
|
+
for (const fresh of freshSource) {
|
|
85
|
+
const id = fresh[idKey];
|
|
86
|
+
if (typeof id === "string" && emitted.has(id)) continue;
|
|
87
|
+
out.push(fresh);
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
72
91
|
function mergeTableItems(input) {
|
|
73
|
-
const { current, freshSource, overrides, removed, generatedFields, idKey } = input;
|
|
92
|
+
const { current, freshSource, overrides, removed, generatedFields, idKey, ordered } = input;
|
|
74
93
|
const freshById = /* @__PURE__ */ new Map();
|
|
75
94
|
for (const f of freshSource) {
|
|
76
95
|
const id = f[idKey];
|
|
@@ -95,6 +114,7 @@ function mergeTableItems(input) {
|
|
|
95
114
|
if (removed?.[id] === true) continue;
|
|
96
115
|
out.push(fresh);
|
|
97
116
|
}
|
|
117
|
+
if (ordered === true) return out;
|
|
98
118
|
const freshIndex = /* @__PURE__ */ new Map();
|
|
99
119
|
freshSource.forEach((f, i) => {
|
|
100
120
|
const id = f[idKey];
|
|
@@ -1,28 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region ../../internal/fill-bake/dist/item-overrides.js
|
|
4
|
-
function asEntry(value) {
|
|
5
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
6
|
-
}
|
|
7
|
-
function keepOverriddenItemFields(fresh, stored, marked) {
|
|
8
|
-
if (!Array.isArray(fresh) || !Array.isArray(stored) || Object.keys(marked).length === 0) return fresh;
|
|
9
|
-
const storedById = /* @__PURE__ */ new Map();
|
|
10
|
-
for (const value of stored) {
|
|
11
|
-
const entry = asEntry(value);
|
|
12
|
-
const id = elementIdentity(entry);
|
|
13
|
-
if (entry !== null && id !== null) storedById.set(id, entry);
|
|
14
|
-
}
|
|
15
|
-
return fresh.map((value) => {
|
|
16
|
-
const entry = asEntry(value);
|
|
17
|
-
const id = elementIdentity(entry);
|
|
18
|
-
const fields = id === null ? void 0 : marked[id];
|
|
19
|
-
const twin = id === null ? void 0 : storedById.get(id);
|
|
20
|
-
if (entry === null || fields === void 0 || twin === void 0) return value;
|
|
21
|
-
const kept = { ...entry };
|
|
22
|
-
for (const field of Object.keys(fields)) if (field in twin) kept[field] = twin[field];
|
|
23
|
-
return kept;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { keepOverriddenItemFields };
|
|
1
|
+
import "../../template-contracts/dist/ref-locate.js";
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
import { contentMediaIdOf } from "../../template-contracts/dist/registry-facts.js";
|
|
1
2
|
import { elementIdentity } from "../../template-contracts/dist/ref-locate.js";
|
|
2
3
|
|
|
3
4
|
//#region ../../internal/fill-bake/dist/linked-merge.js
|
|
4
5
|
const isFields = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
if (typeof value["asset_id"] === "string" && value["asset_id"] !== "") return value["asset_id"];
|
|
8
|
-
if (typeof value["photo_id"] === "string" && value["photo_id"] !== "") return value["photo_id"];
|
|
9
|
-
return null;
|
|
6
|
+
function mediaOf(value) {
|
|
7
|
+
return contentMediaIdOf(value) ?? null;
|
|
10
8
|
}
|
|
11
9
|
function mergeLinkedValue(current, fresh) {
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
10
|
+
const media = mediaOf(fresh);
|
|
11
|
+
if (media !== null) return mediaOf(current) === media ? current : fresh;
|
|
14
12
|
if (Array.isArray(fresh)) return Array.isArray(current) ? mergeLinkedList(current, fresh) : fresh;
|
|
15
13
|
if (isFields(fresh)) return isFields(current) ? mergeLinkedFields(current, fresh) : fresh;
|
|
16
14
|
return fresh;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { normalizeAddressValue } from "../../template-contracts/dist/address-value.js";
|
|
2
2
|
import { storedAsRefs } from "../../template-contracts/dist/registry-facts.js";
|
|
3
|
-
import { attributedRows, elementIdentity
|
|
4
|
-
import { elementRowKeys, memberSourceOf
|
|
3
|
+
import { attributedRows, elementIdentity } from "../../template-contracts/dist/ref-locate.js";
|
|
4
|
+
import { elementRowKeys, memberSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
5
5
|
import { projectTableRows, readRowMember } from "../../source-resolution/dist/index.js";
|
|
6
6
|
|
|
7
7
|
//#region ../../internal/fill-bake/dist/list-grammar.js
|
|
8
8
|
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
9
9
|
function isGrammarList(def) {
|
|
10
|
-
return def.type === "list" && def.
|
|
10
|
+
return def.type === "list" && def.element !== void 0;
|
|
11
11
|
}
|
|
12
12
|
function objectElementFields(def) {
|
|
13
13
|
return def.element?.type === "object" ? def.element.fields ?? {} : void 0;
|
|
@@ -17,6 +17,10 @@ function decisionProducing(scope, path) {
|
|
|
17
17
|
}
|
|
18
18
|
function rowIdentity(element, table) {
|
|
19
19
|
if (typeof element === "string") return element === "" ? null : element;
|
|
20
|
+
if (table !== null && isRecord(element)) {
|
|
21
|
+
const id = element["id"];
|
|
22
|
+
if (typeof id === "string" && id !== "") return id;
|
|
23
|
+
}
|
|
20
24
|
return elementIdentity(element, table);
|
|
21
25
|
}
|
|
22
26
|
function computedRow(element, tables, facts) {
|
|
@@ -38,12 +42,6 @@ function computedRow(element, tables, facts) {
|
|
|
38
42
|
id: rowIdentity(element, first)
|
|
39
43
|
};
|
|
40
44
|
}
|
|
41
|
-
function registryReadingOf(table) {
|
|
42
|
-
return {
|
|
43
|
-
table: table.table,
|
|
44
|
-
reading: "registry"
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
45
|
function readResolvedRowMember(row, member, facts) {
|
|
48
46
|
if (row.table !== null) return row.id === null ? null : storedAsRefs(readRowMember(row.table, row.id, member, facts));
|
|
49
47
|
return isRecord(row.element) ? row.element[member] ?? null : null;
|
|
@@ -70,20 +68,12 @@ function projectElements(elements, projection) {
|
|
|
70
68
|
const fields = element.type === "object" ? element.fields ?? {} : void 0;
|
|
71
69
|
if (table !== null) {
|
|
72
70
|
if (fields === void 0) return elements.map((identified) => identified.id);
|
|
73
|
-
const idKey = elementIdentityKey(table.table);
|
|
74
|
-
const members = rowMemberSources(fields);
|
|
75
71
|
return elements.flatMap(({ element: held, id }) => {
|
|
76
|
-
const
|
|
77
|
-
const [projected] = storedAsRefs(projectTableRows(table, facts, fields, computes, [rowId]));
|
|
72
|
+
const [projected] = storedAsRefs(projectTableRows(table, facts, fields, computes, [typeof held === "string" ? held : id]));
|
|
78
73
|
if (projected === void 0) return [];
|
|
79
|
-
for (const [key, field] of Object.entries(fields)) {
|
|
80
|
-
const nested = nestedItemOf(field);
|
|
81
|
-
const member = members[key];
|
|
82
|
-
if (nested !== void 0 && member !== void 0 && readsElementRows(nested)) projected[key] = storedAsRefs(readRowMember(registryReadingOf(table), rowId, member, facts));
|
|
83
|
-
}
|
|
84
74
|
return [withNestedLists({
|
|
85
75
|
...projected,
|
|
86
|
-
|
|
76
|
+
id
|
|
87
77
|
}, fields, facts)];
|
|
88
78
|
});
|
|
89
79
|
}
|
|
@@ -94,14 +84,6 @@ function projectElements(elements, projection) {
|
|
|
94
84
|
function nestedItemOf(def) {
|
|
95
85
|
return isGrammarList(def) && def.element?.type === "object" ? def.element : void 0;
|
|
96
86
|
}
|
|
97
|
-
function readsElementRows(declaration) {
|
|
98
|
-
const fields = declaration.fields ?? {};
|
|
99
|
-
return elementRowKeys(fields).length > 0 || Object.keys(rowMemberSources(fields)).length > 0;
|
|
100
|
-
}
|
|
101
|
-
function readNestedMember(row, member, nestedItem, facts) {
|
|
102
|
-
if (row.table !== null && row.id !== null && readsElementRows(nestedItem)) return storedAsRefs(readRowMember(registryReadingOf(row.table), row.id, member, facts));
|
|
103
|
-
return readResolvedRowMember(row, member, facts);
|
|
104
|
-
}
|
|
105
87
|
function projectNestedList(value, nestedItem, facts) {
|
|
106
88
|
if (!Array.isArray(value)) return value;
|
|
107
89
|
const ids = contentIdentities(value);
|
|
@@ -136,12 +118,7 @@ function projectContentItem({ element, id, storedItem }, fields, computes) {
|
|
|
136
118
|
continue;
|
|
137
119
|
}
|
|
138
120
|
const member = memberSourceOf(field.source);
|
|
139
|
-
if (member !== null && elementRows.has(member.slot))
|
|
140
|
-
out[key] = readMember(member.field);
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
const enclosing = rowMemberOf(field.source);
|
|
144
|
-
if (enclosing !== null) out[key] = readMember(enclosing);
|
|
121
|
+
if (member !== null && elementRows.has(member.slot)) out[key] = readMember(member.field);
|
|
145
122
|
}
|
|
146
123
|
for (const [key, field] of Object.entries(fields)) {
|
|
147
124
|
const member = memberSourceOf(field.source);
|
|
@@ -172,4 +149,4 @@ function storedElements(stored, fields, table) {
|
|
|
172
149
|
}
|
|
173
150
|
|
|
174
151
|
//#endregion
|
|
175
|
-
export { computedRow, contentIdentities, decisionProducing, isGrammarList, nestedItemOf, objectElementFields, projectElements, projectNestedList,
|
|
152
|
+
export { computedRow, contentIdentities, decisionProducing, isGrammarList, nestedItemOf, objectElementFields, projectElements, projectNestedList, readResolvedRowMember, rowIdentity, storedElements };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./bake-property-ref.js";
|
|
@@ -3,7 +3,7 @@ import { plannerForField } from "../../template-contracts/dist/row-planners.js";
|
|
|
3
3
|
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
4
4
|
import "./row-planners.js";
|
|
5
5
|
import { bindsElement, holderLabel, holderOf, isFactBound } from "./holder.js";
|
|
6
|
-
import {
|
|
6
|
+
import { pickIsUnique, readFillVerb, verbRunsOn, writesElements } from "./verbs.js";
|
|
7
7
|
|
|
8
8
|
//#region ../../internal/fill-vocabulary/dist/resolved-decision.js
|
|
9
9
|
function producedSlotOf(slots, id) {
|
|
@@ -15,15 +15,6 @@ function producedSlotOf(slots, id) {
|
|
|
15
15
|
const field = id.slice(dot + 1);
|
|
16
16
|
return fields !== void 0 && Object.hasOwn(fields, field) ? fields[field] : void 0;
|
|
17
17
|
}
|
|
18
|
-
function declaredCountOf(raw) {
|
|
19
|
-
if (typeof raw === "number") return raw;
|
|
20
|
-
if (raw === null || typeof raw !== "object") return void 0;
|
|
21
|
-
const { min, max } = raw;
|
|
22
|
-
return {
|
|
23
|
-
...typeof min === "number" ? { min } : {},
|
|
24
|
-
...typeof max === "number" ? { max } : {}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
18
|
function capHolderOf(slot) {
|
|
28
19
|
if (isValueKind(slot.type) || slot.type === "list" && isValueKind(slot.element?.type)) return null;
|
|
29
20
|
if (listItemFieldsOf(slot) !== void 0) return null;
|
|
@@ -137,7 +128,7 @@ const HONOURED_BY_PLANNER = {
|
|
|
137
128
|
"reads",
|
|
138
129
|
"none"
|
|
139
130
|
]),
|
|
140
|
-
|
|
131
|
+
mediaList: /* @__PURE__ */ new Set([
|
|
141
132
|
"brief",
|
|
142
133
|
"reads",
|
|
143
134
|
"count",
|
|
@@ -210,19 +201,8 @@ function noneOf(node, label) {
|
|
|
210
201
|
if (node.none === true) return true;
|
|
211
202
|
throw new Error(`${label}: \`none\` is \`true\` or absent, never ${JSON.stringify(node.none)}`);
|
|
212
203
|
}
|
|
213
|
-
|
|
214
|
-
"
|
|
215
|
-
"choice",
|
|
216
|
-
"assets",
|
|
217
|
-
"image",
|
|
218
|
-
"video",
|
|
219
|
-
"tour",
|
|
220
|
-
"document",
|
|
221
|
-
"media"
|
|
222
|
-
]);
|
|
223
|
-
function abstainsByVerdict(verb, planner) {
|
|
224
|
-
if (verb !== void 0) return verb === "pick";
|
|
225
|
-
return planner !== void 0 && PICKING_PLANNERS.has(planner);
|
|
204
|
+
function abstainsByVerdict(verb) {
|
|
205
|
+
return verb === "pick";
|
|
226
206
|
}
|
|
227
207
|
function findsPlaces(verb, holders) {
|
|
228
208
|
return verb === "find" && holders.length > 0 && holders.every((holder) => holder !== void 0 && holdsPlaces(holder));
|
|
@@ -247,15 +227,9 @@ function writtenKindOfField(field, planner) {
|
|
|
247
227
|
if (planner === "text") return writtenKindOfDeclared(field);
|
|
248
228
|
if (planner === "list") return writtenKindOfDeclared(field.element);
|
|
249
229
|
}
|
|
250
|
-
function normalizedVerbOf(decision
|
|
230
|
+
function normalizedVerbOf(decision) {
|
|
251
231
|
if (decision.verb !== void 0) return readFillVerb(decision.verb);
|
|
252
|
-
|
|
253
|
-
const planned = decision.fields !== null && typeof decision.fields === "object" ? Object.keys(decision.fields) : [];
|
|
254
|
-
for (const id of decision.produces) {
|
|
255
|
-
const slot = producedSlotOf(slots, id);
|
|
256
|
-
const verb = slot === void 0 ? void 0 : impliedVerbOf(slot, planned);
|
|
257
|
-
if (verb !== void 0) return verb;
|
|
258
|
-
}
|
|
232
|
+
return decision.kind === "display" ? "pick" : void 0;
|
|
259
233
|
}
|
|
260
234
|
function honouredFor(base, written) {
|
|
261
235
|
if (written === void 0) return base;
|
|
@@ -269,7 +243,7 @@ function resolveDecision(decision, slots) {
|
|
|
269
243
|
const refused = [];
|
|
270
244
|
const label = `fill "${decision.id}"`;
|
|
271
245
|
const declaresVerb = decision.verb !== void 0;
|
|
272
|
-
const verb = normalizedVerbOf(decision
|
|
246
|
+
const verb = normalizedVerbOf(decision);
|
|
273
247
|
if (declaresVerb && decision.count !== void 0) refused.push({
|
|
274
248
|
option: "count",
|
|
275
249
|
where: decision.produces[0] ?? "",
|
|
@@ -305,7 +279,7 @@ function resolveDecision(decision, slots) {
|
|
|
305
279
|
holder,
|
|
306
280
|
runs: true,
|
|
307
281
|
...writtenKind === void 0 ? {} : { writtenKind },
|
|
308
|
-
...countEntry(honoured, declaresVerb,
|
|
282
|
+
...countEntry(honoured, declaresVerb, slot),
|
|
309
283
|
...honoured.has("cap") ? capEntry(decision.cap, slot, writesElements(verb, holder)) : {}
|
|
310
284
|
};
|
|
311
285
|
});
|
|
@@ -335,13 +309,12 @@ function resolveDecision(decision, slots) {
|
|
|
335
309
|
const honoured = honouredFor(HONOURED_BY_PLANNER[planner], writtenKind);
|
|
336
310
|
const where = `${decision.produces[0]}.${name}`;
|
|
337
311
|
refused.push(...refusalsOf(wire, honoured, `${label} field "${name}"`, where, `row field "${where}" (${planner})`));
|
|
338
|
-
const declaredCount = wire.verb !== void 0 ? boundsOf(fieldSlot) : declaredCountOf(wire.count);
|
|
339
312
|
return {
|
|
340
313
|
...base,
|
|
341
314
|
...writtenKind === void 0 ? {} : { writtenKind },
|
|
342
|
-
mayAbstain: abstainsByVerdict(fieldVerb
|
|
315
|
+
mayAbstain: abstainsByVerdict(fieldVerb) || base.mayAbstain && honoured.has("none"),
|
|
343
316
|
...honoured.has("count") ? { count: {
|
|
344
|
-
declared:
|
|
317
|
+
declared: boundsOf(fieldSlot),
|
|
345
318
|
holderMax: fieldSlot.max
|
|
346
319
|
} } : {},
|
|
347
320
|
...honoured.has("cap") ? capEntry(wire.cap, fieldSlot) : {}
|
|
@@ -369,10 +342,10 @@ function boundsOf(slot) {
|
|
|
369
342
|
...typeof slot.max === "number" ? { max: slot.max } : {}
|
|
370
343
|
};
|
|
371
344
|
}
|
|
372
|
-
function countEntry(honoured, declaresVerb,
|
|
345
|
+
function countEntry(honoured, declaresVerb, slot) {
|
|
373
346
|
if (!honoured.has("count")) return {};
|
|
374
347
|
return { count: {
|
|
375
|
-
declared: declaresVerb ? boundsOf(slot) :
|
|
348
|
+
declared: declaresVerb ? boundsOf(slot) : void 0,
|
|
376
349
|
holderMax: slot.max
|
|
377
350
|
} };
|
|
378
351
|
}
|
|
@@ -12,10 +12,8 @@ const FILL_VERBS = [
|
|
|
12
12
|
function isFillVerb(value) {
|
|
13
13
|
return typeof value === "string" && FILL_VERBS.includes(value);
|
|
14
14
|
}
|
|
15
|
-
const RETIRED_VERBS = { curate: "find" };
|
|
16
15
|
function readFillVerb(value) {
|
|
17
|
-
|
|
18
|
-
return typeof value === "string" && Object.hasOwn(RETIRED_VERBS, value) ? RETIRED_VERBS[value] : void 0;
|
|
16
|
+
return isFillVerb(value) ? value : void 0;
|
|
19
17
|
}
|
|
20
18
|
function choosesOne(type) {
|
|
21
19
|
return type === "select" || poolOfKind(type) !== void 0;
|
|
@@ -54,22 +52,9 @@ function verbRunsOn(verb, slot, planned = []) {
|
|
|
54
52
|
function writesElements(verb, holder) {
|
|
55
53
|
return verb === "write" && holder?.shape === "objects" && holder.bindsElement;
|
|
56
54
|
}
|
|
57
|
-
function impliedVerbOf(slot, planned = []) {
|
|
58
|
-
const holder = holderOf(slot);
|
|
59
|
-
if (holder.shape === "one") {
|
|
60
|
-
if (choosesOne(holder.type)) return "pick";
|
|
61
|
-
return writesOne(holder.type) ? "write" : void 0;
|
|
62
|
-
}
|
|
63
|
-
if (holder.shape === "list") {
|
|
64
|
-
if (choosesOne(holder.item)) return "pick";
|
|
65
|
-
if (isFindableKind(holder.item)) return "find";
|
|
66
|
-
return holder.item === "row" ? void 0 : "write";
|
|
67
|
-
}
|
|
68
|
-
return holder.bound === void 0 && everyFieldPlanned(slot, planned) ? "write" : void 0;
|
|
69
|
-
}
|
|
70
55
|
function pickIsUnique(verb, node) {
|
|
71
56
|
return verb === "pick" && node.unique !== false;
|
|
72
57
|
}
|
|
73
58
|
|
|
74
59
|
//#endregion
|
|
75
|
-
export { FILL_VERBS, FINDABLE_KINDS, findRunsOn,
|
|
60
|
+
export { FILL_VERBS, FINDABLE_KINDS, findRunsOn, isFillVerb, isFindableKind, pickIsUnique, pickRunsOn, readFillVerb, verbRunsOn, writesElements };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { contentMediaIdOf } from "../../template-contracts/dist/registry-facts.js";
|
|
1
2
|
import { readLadder } from "./store.js";
|
|
2
3
|
|
|
3
4
|
//#region ../../internal/media-resolution/dist/document.js
|
|
@@ -15,7 +16,7 @@ async function withPreview(out, previewKey, store) {
|
|
|
15
16
|
out.poster = await store.fileUrl(previewKey);
|
|
16
17
|
} catch (err) {
|
|
17
18
|
store.log?.warn({
|
|
18
|
-
|
|
19
|
+
media_id: out.asset_id,
|
|
19
20
|
err: err.message
|
|
20
21
|
}, "resolve-document-slot: preview presign failed; no poster");
|
|
21
22
|
return out;
|
|
@@ -24,35 +25,35 @@ async function withPreview(out, previewKey, store) {
|
|
|
24
25
|
if (responsive) out.poster_responsive = responsive;
|
|
25
26
|
return out;
|
|
26
27
|
}
|
|
27
|
-
async function resolveDocumentSlot(value,
|
|
28
|
+
async function resolveDocumentSlot(value, records, store) {
|
|
28
29
|
if (value === null) return null;
|
|
29
30
|
if (typeof value !== "object") return DEFAULT;
|
|
30
31
|
const v = value;
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
store.log?.warn({
|
|
32
|
+
const mediaId = contentMediaIdOf(v) ?? "";
|
|
33
|
+
if (!mediaId) return DEFAULT;
|
|
34
|
+
const record = records.get(mediaId);
|
|
35
|
+
if (record === void 0) {
|
|
36
|
+
store.log?.warn({ media_id: mediaId }, "resolve-document-slot: no media the render may reach");
|
|
36
37
|
return DEFAULT;
|
|
37
38
|
}
|
|
38
|
-
const key =
|
|
39
|
+
const key = record.key;
|
|
39
40
|
if (key === null) {
|
|
40
|
-
store.log?.warn({
|
|
41
|
+
store.log?.warn({ media_id: mediaId }, "resolve-document-slot: media has no stored object");
|
|
41
42
|
return DEFAULT;
|
|
42
43
|
}
|
|
43
44
|
try {
|
|
44
|
-
const filename =
|
|
45
|
+
const filename = (v.picked === null && typeof v.name === "string" && v.name !== "" ? v.name : null) ?? record.name;
|
|
45
46
|
return await withPreview({
|
|
46
|
-
asset_id:
|
|
47
|
+
asset_id: mediaId,
|
|
47
48
|
url: store.namedFileUrl ? await store.namedFileUrl(key, filename) : await store.fileUrl(key),
|
|
48
49
|
filename,
|
|
49
|
-
content_type:
|
|
50
|
-
size_bytes:
|
|
50
|
+
content_type: record.mime ?? "",
|
|
51
|
+
size_bytes: record.bytes ?? 0,
|
|
51
52
|
poster: ""
|
|
52
|
-
},
|
|
53
|
+
}, record.renditions.poster?.key ?? null, store);
|
|
53
54
|
} catch (err) {
|
|
54
55
|
store.log?.error({
|
|
55
|
-
|
|
56
|
+
media_id: mediaId,
|
|
56
57
|
err: err.message
|
|
57
58
|
}, "resolve-document-slot: presign failed; soft-empty document");
|
|
58
59
|
return DEFAULT;
|