@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.
Files changed (143) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +3 -3
  3. package/codemods/manifest.json +14 -0
  4. package/codemods/registry-keys-only.mjs +113 -0
  5. package/codemods/steps/list-object-form.mjs +2 -3
  6. package/codemods/steps/registry-key-reads.mjs +276 -0
  7. package/dist/artifact/playground/client/assets/index-BFNHB7VM.css +1 -0
  8. package/dist/artifact/playground/client/assets/index-Div1yo6s.js +1259 -0
  9. package/dist/artifact/playground/client/index.html +2 -2
  10. package/dist/artifact/playground/host.mjs +42 -42
  11. package/dist/cli/build/artifact.js +2 -1
  12. package/dist/cli/build/fixtures.js +2 -1
  13. package/dist/cli/check/render/inputs.js +3 -3
  14. package/dist/cli/check/stages/sections.js +5 -6
  15. package/dist/cli/check/stages/workspace.js +2 -0
  16. package/dist/cli/check/template-key.js +16 -0
  17. package/dist/cli/dev/workspace-reader.js +9 -2
  18. package/dist/fixtures/media-store.js +3 -3
  19. package/dist/fixtures/resolve.js +28 -23
  20. package/dist/fixtures/synthesize-empties.js +3 -1
  21. package/dist/fixtures.d.ts +1 -1
  22. package/dist/index.d.ts +3 -4
  23. package/dist/packages/external/concrete/package.js +1 -1
  24. package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +1 -1
  25. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +15 -27
  26. package/dist/packages/internal/fill-bake/dist/compute-reads.js +12 -12
  27. package/dist/packages/internal/fill-bake/dist/derive-source.js +7 -14
  28. package/dist/packages/internal/fill-bake/dist/index.js +4 -3
  29. package/dist/packages/internal/fill-bake/dist/item-merge.js +36 -16
  30. package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -28
  31. package/dist/packages/internal/fill-bake/dist/linked-merge.js +5 -7
  32. package/dist/packages/internal/fill-bake/dist/list-grammar.js +11 -34
  33. package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
  34. package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +12 -39
  35. package/dist/packages/internal/fill-vocabulary/dist/verbs.js +2 -17
  36. package/dist/packages/internal/media-resolution/dist/document.js +16 -15
  37. package/dist/packages/internal/media-resolution/dist/image.js +38 -94
  38. package/dist/packages/internal/media-resolution/dist/index.js +1 -1
  39. package/dist/packages/internal/media-resolution/dist/list.js +12 -12
  40. package/dist/packages/internal/media-resolution/dist/media.js +17 -16
  41. package/dist/packages/internal/media-resolution/dist/records.js +4 -2
  42. package/dist/packages/internal/media-resolution/dist/slot.js +9 -6
  43. package/dist/packages/internal/media-resolution/dist/tour.js +12 -11
  44. package/dist/packages/internal/media-resolution/dist/video.js +16 -16
  45. package/dist/packages/internal/property-facts/dist/registry-facts.js +10 -2
  46. package/dist/packages/internal/section-contracts/dist/catalog.js +2 -10
  47. package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +5 -12
  48. package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
  49. package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +7 -5
  50. package/dist/packages/internal/section-contracts/dist/grammar-scope.js +1 -1
  51. package/dist/packages/internal/section-contracts/dist/index.js +0 -2
  52. package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +0 -29
  53. package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +2 -16
  54. package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +6 -6
  55. package/dist/packages/internal/section-contracts/dist/object-contract.js +4 -2
  56. package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +6 -2
  57. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -15
  58. package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +6 -7
  59. package/dist/packages/internal/section-contracts/dist/row-source-contract.js +7 -8
  60. package/dist/packages/internal/section-contracts/dist/runners.js +5 -17
  61. package/dist/packages/internal/section-contracts/dist/select-contract.js +7 -1
  62. package/dist/packages/internal/section-contracts/dist/source-contract.js +20 -79
  63. package/dist/packages/internal/section-contracts/dist/sources-contract.js +1 -1
  64. package/dist/packages/internal/section-contracts/dist/table-member.js +5 -8
  65. package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +5 -10
  66. package/dist/packages/internal/source-resolution/dist/index.js +21 -189
  67. package/dist/packages/internal/template-artifact/dist/index.js +2 -2
  68. package/dist/packages/internal/template-artifact/dist/layout.js +3 -1
  69. package/dist/packages/internal/template-artifact/dist/verify.js +32 -16
  70. package/dist/packages/internal/template-contracts/dist/content-pick.js +24 -1
  71. package/dist/packages/internal/template-contracts/dist/decision-fills.js +2 -6
  72. package/dist/packages/internal/template-contracts/dist/document-value.d.ts +2 -2
  73. package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +3 -2
  74. package/dist/packages/internal/template-contracts/dist/fact-keys.js +19 -43
  75. package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +24 -3
  76. package/dist/packages/internal/template-contracts/dist/fact-registry.js +14 -7
  77. package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +1 -1
  78. package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +3 -68
  79. package/dist/packages/internal/template-contracts/dist/fill-spec.js +7 -6
  80. package/dist/packages/internal/template-contracts/dist/list-editing.js +0 -1
  81. package/dist/packages/internal/template-contracts/dist/list.d.ts +1 -1
  82. package/dist/packages/internal/template-contracts/dist/list.js +7 -15
  83. package/dist/packages/internal/template-contracts/dist/media-candidates.js +1 -1
  84. package/dist/packages/internal/template-contracts/dist/mirror-kind.js +2 -2
  85. package/dist/packages/internal/template-contracts/dist/object.js +3 -2
  86. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +2 -2
  87. package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +2 -2
  88. package/dist/packages/internal/template-contracts/dist/read-graph.js +14 -51
  89. package/dist/packages/internal/template-contracts/dist/ref-locate.js +15 -27
  90. package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +3 -1
  91. package/dist/packages/internal/template-contracts/dist/registry-facts.js +13 -24
  92. package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +20 -4
  93. package/dist/packages/internal/template-contracts/dist/registry-shape.js +69 -11
  94. package/dist/packages/internal/template-contracts/dist/row-planners.js +1 -1
  95. package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +5 -14
  96. package/dist/packages/internal/template-contracts/dist/row-ref.js +7 -23
  97. package/dist/packages/internal/template-contracts/dist/row-sources.js +6 -16
  98. package/dist/packages/internal/template-contracts/dist/row.d.ts +1 -1
  99. package/dist/packages/internal/template-contracts/dist/row.js +6 -7
  100. package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +5 -20
  101. package/dist/packages/internal/template-contracts/dist/section-schema-types.d.ts +1 -0
  102. package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +29 -37
  103. package/dist/packages/internal/template-contracts/dist/slot-builders.js +4 -7
  104. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +2 -733
  105. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +2 -502
  106. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +4 -1
  107. package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +4 -4
  108. package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -2
  109. package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +9 -10
  110. package/dist/packages/internal/template-contracts/dist/table-members.d.ts +5 -12
  111. package/dist/packages/internal/template-contracts/dist/table-members.js +7 -37
  112. package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +2 -2
  113. package/dist/primitives/Image.d.ts +3 -3
  114. package/dist/primitives/slot-bindings.js +2 -2
  115. package/dist/primitives/slot-download.d.ts +1 -1
  116. package/dist/primitives/slot-media.d.ts +1 -1
  117. package/dist/rules/registry.js +6 -0
  118. package/dist/schema/fact.d.ts +19 -52
  119. package/dist/schema/fact.js +6 -25
  120. package/dist/schema/facts-view.d.ts +1 -2
  121. package/dist/schema/property-facts.d.ts +1 -62
  122. package/dist/schema/section-schema.d.ts +2 -2
  123. package/dist/schema/section-schema.js +1 -1
  124. package/dist/section/section.d.ts +2 -2
  125. package/guide/reference/cli/INDEX.md +2 -2
  126. package/guide/reference/cli/build.md +1 -1
  127. package/guide/reference/cli/check.md +1 -1
  128. package/guide/reference/cli/dev.md +1 -1
  129. package/guide/reference/cli/property-add.md +1 -1
  130. package/guide/reference/cli/property-list.md +1 -1
  131. package/guide/reference/cli/publish.md +1 -1
  132. package/guide/reference/cli/upgrade.md +1 -1
  133. package/guide/reference/rules/INDEX.md +4 -5
  134. package/package.json +1 -1
  135. package/dist/artifact/playground/client/assets/index-BUmdDDX5.js +0 -1259
  136. package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +0 -1
  137. package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
  138. package/dist/packages/internal/section-contracts/dist/group-contract.js +0 -19
  139. package/dist/packages/internal/section-contracts/dist/option-source-contract.js +0 -22
  140. package/dist/packages/internal/template-contracts/dist/comparable-address.js +0 -19
  141. package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +0 -62
  142. package/dist/packages/internal/template-contracts/dist/legacy-facts.js +0 -167
  143. 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 current = oneItemPerIdentity(input.idKey, input.current.map((cur) => spelledUnder(input.idKey, cur)));
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, idKey } = input;
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") return freshSource.map((fresh) => {
57
- const id = fresh[idKey];
58
- const cur = typeof id === "string" ? currentById.get(id) : void 0;
59
- return cur === void 0 ? fresh : mergeItem(cur, fresh, overrides?.[id], generatedFields, idKey, true);
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 { elementIdentity } from "../../template-contracts/dist/ref-locate.js";
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 uploadOf(value) {
6
- if (!isFields(value)) return null;
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 upload = uploadOf(fresh);
13
- if (upload !== null) return uploadOf(current) === upload ? current : fresh;
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, elementIdentityKey } from "../../template-contracts/dist/ref-locate.js";
4
- import { elementRowKeys, memberSourceOf, rowMemberOf, rowMemberSources } from "../../template-contracts/dist/row-sources.js";
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.fields === void 0 && def.element !== void 0;
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 rowId = typeof held === "string" ? held : id;
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
- [idKey]: id
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, readNestedMember, readResolvedRowMember, readsElementRows, rowIdentity, storedElements };
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 { impliedVerbOf, pickIsUnique, readFillVerb, verbRunsOn, writesElements } from "./verbs.js";
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
- assets: /* @__PURE__ */ new Set([
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
- const PICKING_PLANNERS = /* @__PURE__ */ new Set([
214
- "select",
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, slots) {
230
+ function normalizedVerbOf(decision) {
251
231
  if (decision.verb !== void 0) return readFillVerb(decision.verb);
252
- if (decision.kind === "display") return "pick";
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, slots);
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, decision, slot),
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, planner) || base.mayAbstain && honoured.has("none"),
315
+ mayAbstain: abstainsByVerdict(fieldVerb) || base.mayAbstain && honoured.has("none"),
343
316
  ...honoured.has("count") ? { count: {
344
- declared: declaredCount,
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, decision, slot) {
345
+ function countEntry(honoured, declaresVerb, slot) {
373
346
  if (!honoured.has("count")) return {};
374
347
  return { count: {
375
- declared: declaresVerb ? boundsOf(slot) : declaredCountOf(decision.count),
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
- if (isFillVerb(value)) return value;
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, impliedVerbOf, isFillVerb, isFindableKind, pickIsUnique, pickRunsOn, readFillVerb, verbRunsOn, writesElements };
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
- asset_id: out.asset_id,
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, assets, store) {
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 assetId = typeof v.asset_id === "string" ? v.asset_id : "";
32
- if (!assetId) return DEFAULT;
33
- const asset = assets.get(assetId);
34
- if (asset === void 0) {
35
- store.log?.warn({ asset_id: assetId }, "resolve-document-slot: no asset the render may reach");
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 = asset.key;
39
+ const key = record.key;
39
40
  if (key === null) {
40
- store.log?.warn({ asset_id: assetId }, "resolve-document-slot: asset has no stored object");
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 = asset.name;
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: assetId,
47
+ asset_id: mediaId,
47
48
  url: store.namedFileUrl ? await store.namedFileUrl(key, filename) : await store.fileUrl(key),
48
49
  filename,
49
- content_type: asset.mime ?? "",
50
- size_bytes: asset.bytes ?? 0,
50
+ content_type: record.mime ?? "",
51
+ size_bytes: record.bytes ?? 0,
51
52
  poster: ""
52
- }, asset.renditions.poster?.key ?? null, store);
53
+ }, record.renditions.poster?.key ?? null, store);
53
54
  } catch (err) {
54
55
  store.log?.error({
55
- asset_id: assetId,
56
+ media_id: mediaId,
56
57
  err: err.message
57
58
  }, "resolve-document-slot: presign failed; soft-empty document");
58
59
  return DEFAULT;