@homepages/concrete 8.0.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/CHANGELOG.md +1005 -0
  2. package/README.md +20 -9
  3. package/codemods/list-grammar.mjs +923 -0
  4. package/codemods/manifest.json +64 -0
  5. package/codemods/process-builders.mjs +198 -0
  6. package/codemods/slot-object.mjs +1097 -0
  7. package/codemods/steps/content-object-fields.mjs +324 -0
  8. package/codemods/steps/list-object-form.mjs +6 -7
  9. package/codemods/table-rows.mjs +568 -0
  10. package/codemods/unwrap-object-fields.mjs +310 -0
  11. package/codemods/viewer-slot-document.mjs +131 -0
  12. package/codemods/write-property-as-facts-document.mjs +716 -0
  13. package/codemods/write-the-address-line.mjs +255 -0
  14. package/codemods/write-the-registry-members.mjs +653 -0
  15. package/codemods/write-the-select-from.mjs +141 -0
  16. package/codemods/write-the-sole-from.mjs +369 -0
  17. package/codemods/write-the-table-from.mjs +267 -0
  18. package/codemods/write-the-whole-item.mjs +512 -0
  19. package/codemods/writeback-drop.mjs +168 -0
  20. package/codemods/written-contact-address.mjs +162 -0
  21. package/codemods/written-media-category.mjs +227 -0
  22. package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
  23. package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
  24. package/codemods/written-uploads-sort-into-lists.mjs +405 -0
  25. package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
  26. package/codemods/written-video-sources-drop.mjs +144 -0
  27. package/codemods/written-without-pick-none.mjs +146 -0
  28. package/codemods/written-without-retired-knowledge.mjs +223 -0
  29. package/codemods/written-without-the-media-key.mjs +202 -0
  30. package/codemods/written-without-the-property-type.mjs +249 -0
  31. package/dist/artifact/playground/client/assets/index-BOYbgBnP.js +1259 -0
  32. package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +1 -0
  33. package/dist/artifact/playground/client/index.html +2 -2
  34. package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
  35. package/dist/artifact/playground/host.mjs +61 -27
  36. package/dist/base.css +58 -1
  37. package/dist/cli/build/artifact.js +6 -9
  38. package/dist/cli/build/captures.js +2 -12
  39. package/dist/cli/build/esbuild.js +1 -25
  40. package/dist/cli/build/fixtures.js +2 -1
  41. package/dist/cli/build/icons.js +1 -1
  42. package/dist/cli/build/static.js +2 -2
  43. package/dist/cli/capture/capture.js +8 -9
  44. package/dist/cli/check/analyze.js +8 -1
  45. package/dist/cli/check/load-outdir.js +47 -0
  46. package/dist/cli/check/load-workspace.js +4 -4
  47. package/dist/cli/check/render/html.js +1 -2
  48. package/dist/cli/check/render/inputs.js +10 -3
  49. package/dist/cli/check/render/island-frames.js +2 -1
  50. package/dist/cli/check/render/marker-coverage.js +23 -15
  51. package/dist/cli/check/report.js +5 -0
  52. package/dist/cli/check/stages/bundles.js +1 -1
  53. package/dist/cli/check/stages/relations.js +1 -1
  54. package/dist/cli/check/stages/render.js +48 -33
  55. package/dist/cli/check/stages/sections.js +83 -31
  56. package/dist/cli/check/stages/workspace.js +2 -0
  57. package/dist/cli/check/template-key.js +16 -0
  58. package/dist/cli/commands.js +1 -1
  59. package/dist/cli/dev/crop.js +1 -1
  60. package/dist/cli/dev/fixture-ladders.js +96 -0
  61. package/dist/cli/dev/islands.js +12 -123
  62. package/dist/cli/dev/listen.js +20 -1
  63. package/dist/cli/dev/load-template.js +1 -1
  64. package/dist/cli/dev/server.js +35 -10
  65. package/dist/cli/dev/vite.js +9 -7
  66. package/dist/cli/dev/workspace-reader.js +16 -16
  67. package/dist/cli/media/derive.js +43 -57
  68. package/dist/cli/media/frame-rung-floor.js +0 -1
  69. package/dist/cli/property/index.js +1 -6
  70. package/dist/css/inline.js +1 -22
  71. package/dist/eslint/rules/no-marker-literal.js +1 -1
  72. package/dist/fixtures/load.js +16 -7
  73. package/dist/fixtures/media-plugin.js +17 -12
  74. package/dist/fixtures/media-store.js +115 -0
  75. package/dist/fixtures/property.js +345 -126
  76. package/dist/fixtures/resolve.js +260 -251
  77. package/dist/fixtures/rows.js +4 -11
  78. package/dist/fixtures.d.ts +234 -109
  79. package/dist/index.d.ts +25 -16
  80. package/dist/index.js +10 -6
  81. package/dist/islands/marker.js +2 -1
  82. package/dist/packages/external/concrete/package.js +1 -1
  83. package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
  84. package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
  85. package/dist/packages/internal/capture-settle/dist/index.js +3 -0
  86. package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
  87. package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
  88. package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
  89. package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
  90. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +250 -46
  91. package/dist/packages/internal/fill-bake/dist/compute-reads.js +361 -4
  92. package/dist/packages/internal/fill-bake/dist/derive-source.js +25 -18
  93. package/dist/packages/internal/fill-bake/dist/index.js +9 -3
  94. package/dist/packages/internal/fill-bake/dist/item-merge.js +113 -0
  95. package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -0
  96. package/dist/packages/internal/fill-bake/dist/linked-merge.js +38 -0
  97. package/dist/packages/internal/fill-bake/dist/list-grammar.js +174 -0
  98. package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
  99. package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
  100. package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +363 -0
  101. package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
  102. package/dist/packages/internal/fill-vocabulary/dist/verbs.js +60 -0
  103. package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
  104. package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
  105. package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
  106. package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
  107. package/dist/packages/internal/image-ladder/dist/index.js +3 -3
  108. package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
  109. package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
  110. package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
  111. package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
  112. package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
  113. package/dist/packages/internal/island-runtime/dist/index.js +2 -1
  114. package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
  115. package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
  116. package/dist/packages/internal/media-resolution/dist/document.js +63 -0
  117. package/dist/packages/internal/media-resolution/dist/image.js +226 -0
  118. package/dist/packages/internal/media-resolution/dist/index.js +11 -0
  119. package/dist/packages/internal/media-resolution/dist/list.js +112 -0
  120. package/dist/packages/internal/media-resolution/dist/media.js +59 -0
  121. package/dist/packages/internal/media-resolution/dist/records.js +7 -0
  122. package/dist/packages/internal/media-resolution/dist/slot.js +37 -0
  123. package/dist/packages/internal/media-resolution/dist/store.js +19 -0
  124. package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
  125. package/dist/packages/internal/media-resolution/dist/video.js +93 -0
  126. package/dist/packages/internal/property-facts/dist/registry-facts.js +245 -0
  127. package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
  128. package/dist/packages/internal/section-contracts/dist/catalog.js +34 -14
  129. package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
  130. package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +21 -0
  131. package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
  132. package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
  133. package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
  134. package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
  135. package/dist/packages/internal/section-contracts/dist/index.js +7 -2
  136. package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +2 -36
  137. package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -21
  138. package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
  139. package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
  140. package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
  141. package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +9 -5
  142. package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
  143. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -17
  144. package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +80 -0
  145. package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
  146. package/dist/packages/internal/section-contracts/dist/runners.js +77 -18
  147. package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
  148. package/dist/packages/internal/section-contracts/dist/source-contract.js +89 -95
  149. package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
  150. package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
  151. package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +39 -23
  152. package/dist/packages/internal/source-resolution/dist/index.js +113 -73
  153. package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
  154. package/dist/packages/internal/street-address/dist/index.js +72 -0
  155. package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
  156. package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
  157. package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
  158. package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
  159. package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
  160. package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
  161. package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
  162. package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
  163. package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
  164. package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
  165. package/dist/packages/internal/template-contracts/dist/decision-fills.js +81 -0
  166. package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
  167. package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
  168. package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
  169. package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
  170. package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
  171. package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
  172. package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
  173. package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
  174. package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +10 -24
  175. package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
  176. package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
  177. package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
  178. package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
  179. package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +93 -0
  180. package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
  181. package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
  182. package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
  183. package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
  184. package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
  185. package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
  186. package/dist/packages/internal/template-contracts/dist/list-editing.js +93 -0
  187. package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
  188. package/dist/packages/internal/template-contracts/dist/list.js +258 -0
  189. package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
  190. package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
  191. package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
  192. package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
  193. package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
  194. package/dist/packages/internal/template-contracts/dist/object.js +131 -0
  195. package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
  196. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
  197. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
  198. package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
  199. package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
  200. package/dist/packages/internal/template-contracts/dist/read-graph.js +240 -0
  201. package/dist/packages/internal/template-contracts/dist/ref-locate.js +176 -0
  202. package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
  203. package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +270 -0
  204. package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
  205. package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
  206. package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
  207. package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
  208. package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
  209. package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
  210. package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +127 -0
  211. package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
  212. package/dist/packages/internal/template-contracts/dist/row-sources.js +41 -5
  213. package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
  214. package/dist/packages/internal/template-contracts/dist/row.js +84 -0
  215. package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
  216. package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
  217. package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
  218. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +233 -405
  219. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +331 -227
  220. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
  221. package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
  222. package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
  223. package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
  224. package/dist/packages/internal/template-contracts/dist/slot-types.js +139 -0
  225. package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +95 -0
  226. package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
  227. package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
  228. package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
  229. package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
  230. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
  231. package/dist/platform/fs.js +5 -2
  232. package/dist/playground/canvas-island-host.d.ts +11 -0
  233. package/dist/playground/canvas-island-host.js +29 -0
  234. package/dist/playground/canvas-markers.js +14 -0
  235. package/dist/playground-island-runtime.d.ts +3 -2
  236. package/dist/playground-island-runtime.js +3 -2
  237. package/dist/primitives/FrameShell.js +0 -1
  238. package/dist/primitives/Image.d.ts +5 -4
  239. package/dist/primitives/Tour.d.ts +1 -1
  240. package/dist/primitives/Video.d.ts +2 -2
  241. package/dist/primitives/index.d.ts +2 -3
  242. package/dist/primitives/picture-sources.js +2 -2
  243. package/dist/primitives/probe-context.js +2 -12
  244. package/dist/primitives/slot-address.d.ts +44 -0
  245. package/dist/primitives/slot-address.js +19 -0
  246. package/dist/primitives/slot-bindings.d.ts +65 -26
  247. package/dist/primitives/slot-bindings.js +104 -46
  248. package/dist/primitives/slot-document.d.ts +23 -18
  249. package/dist/primitives/slot-document.js +39 -14
  250. package/dist/primitives/slot-download.d.ts +39 -0
  251. package/dist/primitives/slot-download.js +39 -0
  252. package/dist/primitives/slot-list.d.ts +3 -3
  253. package/dist/primitives/slot-list.js +0 -2
  254. package/dist/primitives/slot-media.d.ts +24 -5
  255. package/dist/primitives/slot-media.js +6 -9
  256. package/dist/primitives/slot-object.d.ts +49 -0
  257. package/dist/primitives/slot-object.js +20 -0
  258. package/dist/primitives/slot-scalar.d.ts +27 -2
  259. package/dist/primitives/slot-scalar.js +50 -7
  260. package/dist/primitives/slot.d.ts +13 -6
  261. package/dist/primitives/slot.js +10 -3
  262. package/dist/rules/registry.js +25 -30
  263. package/dist/schema/define-schema.d.ts +4 -8
  264. package/dist/schema/define-schema.js +178 -79
  265. package/dist/schema/extract-fill-spec.js +2 -153
  266. package/dist/schema/fact.d.ts +57 -15
  267. package/dist/schema/fact.js +42 -7
  268. package/dist/schema/facts-view.d.ts +14 -0
  269. package/dist/schema/format.d.ts +1 -0
  270. package/dist/schema/format.js +2 -1
  271. package/dist/schema/manifest.js +24 -0
  272. package/dist/schema/property-facts.d.ts +8 -12
  273. package/dist/schema/section-props.d.ts +2 -66
  274. package/dist/schema/section-schema.d.ts +8 -11
  275. package/dist/schema/section-schema.js +27 -10
  276. package/dist/section/declare.d.ts +18 -7
  277. package/dist/section/declare.js +18 -5
  278. package/dist/section/materialize.js +3 -8
  279. package/dist/section/section.d.ts +12 -8
  280. package/dist/section/section.js +1 -1
  281. package/dist/template/logic-shim.d.ts +14 -7
  282. package/dist/template/logic-shim.js +14 -7
  283. package/dist/template/materialize.js +17 -18
  284. package/dist/template/mirror-types.js +30 -31
  285. package/dist/template/section-reads.js +85 -9
  286. package/guide/reference/cli/INDEX.md +2 -2
  287. package/guide/reference/cli/build.md +1 -1
  288. package/guide/reference/cli/check.md +1 -1
  289. package/guide/reference/cli/dev.md +1 -1
  290. package/guide/reference/cli/property-add.md +1 -1
  291. package/guide/reference/cli/property-list.md +2 -2
  292. package/guide/reference/cli/publish.md +1 -1
  293. package/guide/reference/cli/upgrade.md +1 -1
  294. package/guide/reference/rules/INDEX.md +29 -25
  295. package/package.json +9 -8
  296. package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
  297. package/dist/artifact/playground/client/assets/index-Dn_xT16-.js +0 -1101
  298. package/dist/fixtures/canonical.d.ts +0 -166
  299. package/dist/fixtures/media.js +0 -163
  300. package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -51
  301. package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
  302. package/dist/packages/internal/format-geometry/dist/index.js +0 -4
  303. package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
  304. package/dist/packages/internal/property-facts/dist/index.js +0 -3
  305. package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
  306. package/dist/packages/internal/section-contracts/dist/group-contract.js +0 -19
  307. package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
  308. package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
  309. package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -104
  310. package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
  311. package/dist/primitives/slot-group.d.ts +0 -40
  312. package/dist/primitives/slot-group.js +0 -36
  313. package/dist/schema/extract-used-facts.js +0 -34
  314. package/dist/schema/fill-builders.d.ts +0 -115
  315. package/dist/schema/fill-builders.js +0 -25
  316. package/dist/schema/fill-declaration.d.ts +0 -14
  317. package/dist/schema/fill-spec.js +0 -98
  318. package/dist/schema/layout.d.ts +0 -30
  319. package/dist/schema/layout.js +0 -14
  320. package/dist/schema/row-fields.js +0 -88
  321. package/dist/schema/row-ref.d.ts +0 -59
  322. package/dist/schema/row-ref.js +0 -28
  323. package/dist/schema/runtime-values.d.ts +0 -71
  324. package/dist/schema/section-nav.js +0 -14
  325. package/dist/schema/slot-builders.d.ts +0 -633
  326. package/dist/schema/slot-builders.js +0 -177
  327. package/dist/schema/slot-ref.d.ts +0 -79
  328. package/dist/schema/slot-ref.js +0 -41
  329. package/dist/schema/slot-types.d.ts +0 -111
  330. package/dist/schema/slot-types.js +0 -214
  331. package/dist/section/groups.js +0 -68
@@ -0,0 +1,80 @@
1
+ import { ADDRESS_MEMBERS, isAddressMember } from "../../template-contracts/dist/address-value.js";
2
+ import { rowTableOf } from "../../template-contracts/dist/ref-locate.js";
3
+ import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
4
+ import { fillOf, grammarSlots, insideItem, slotInScope } from "./grammar-scope.js";
5
+ import { fittingTypes, memberFits, refuseIndexedRow } from "./source-contract.js";
6
+ import { tableKeySpelling, tableMemberOrRefuse } from "./table-member.js";
7
+
8
+ //#region ../../internal/section-contracts/dist/row-rule-contract.js
9
+ const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
10
+ function memberOf(table, field, where) {
11
+ return tableMemberOrRefuse(table, field, where, {
12
+ noun: "member",
13
+ identity: `"${field}" is the "${tableKeySpelling(table)}" row's identity, which the row slot's value already is — read a member of the row instead.`
14
+ });
15
+ }
16
+ function resolveHolder(ctx, reader, rowKey, where) {
17
+ const row = slotInScope(ctx.schema, reader, rowKey);
18
+ if (row === void 0) throw new Error(`${where} reads a member of "${rowKey}", which is no slot in scope — a member is read through a row slot beside it or at the top level.`);
19
+ if (row.def.type === "address") return { kind: "address" };
20
+ if (row.def.type !== "row") throw new Error(`${where} reads a member of "${rowKey}", a "${String(row.def.type)}" — a member is read only through a row slot or an address. Declare \`row({ source })\` and read its member.`);
21
+ return {
22
+ kind: "row",
23
+ table: rowTableOf(row.def)
24
+ };
25
+ }
26
+ function addressMemberType(field, where) {
27
+ if (!isAddressMember(field)) throw new Error(`${where}: unknown member "${field}" — an address offers ${ADDRESS_MEMBERS.map((name) => `"${name}"`).join(", ")}.`);
28
+ return field === "latitude" || field === "longitude" ? "number" : "text";
29
+ }
30
+ function assertMemberFits(slot, field, valueType, where) {
31
+ if (!(memberFits(valueType, slot.def) || !insideItem(slot) && valueType === "number" && slot.def.type === "text")) throw new Error(`${where}: member "${field}" is a ${valueType} value and cannot sit on a "${String(slot.def.type)}" slot — it belongs on ${fittingTypes(valueType)}.`);
32
+ }
33
+ function checkMemberSource(ctx, slot, ref) {
34
+ const where = `Section "${ctx.key}": "${slot.path}"`;
35
+ const holder = resolveHolder(ctx, slot, ref.slot, where);
36
+ if (holder.kind === "address") {
37
+ assertMemberFits(slot, ref.field, addressMemberType(ref.field, where), where);
38
+ return;
39
+ }
40
+ const table = holder.table;
41
+ if (table === null) return;
42
+ const descriptor = memberOf(table, ref.field, where);
43
+ assertMemberFits(slot, ref.field, descriptor.value_type, where);
44
+ }
45
+ function checkReads(ctx, slot, reads, what) {
46
+ if (!Array.isArray(reads)) return;
47
+ reads.forEach((entry, i) => {
48
+ if (!isRecord(entry)) return;
49
+ const where = `Section "${ctx.key}": "${slot.path}" ${what} reads[${String(i)}]`;
50
+ if (entry["kind"] === "element") {
51
+ if (!insideItem(slot)) throw new Error(`${where} reads the element outside a list's item, where no element exists.`);
52
+ return;
53
+ }
54
+ refuseIndexedRow(where, entry);
55
+ if (entry["kind"] !== "row") return;
56
+ const member = memberSourceOf(entry);
57
+ if (member === null) throw new Error(`${where} reads a row member without naming its row slot — read it through a row: \`{ kind: "row", slot, field }\`.`);
58
+ const holder = resolveHolder(ctx, slot, member.slot, where);
59
+ if (holder.kind === "address") addressMemberType(member.field, where);
60
+ else if (holder.table !== null) memberOf(holder.table, member.field, where);
61
+ });
62
+ }
63
+ function assertRowRuleContract(ctx) {
64
+ for (const slot of grammarSlots(ctx.schema)) {
65
+ const source = slot.def.source;
66
+ refuseIndexedRow(`Section "${ctx.key}": "${slot.path}"`, source);
67
+ if (source?.kind === "row") {
68
+ const member = memberSourceOf(source);
69
+ if (member !== null) checkMemberSource(ctx, slot, member);
70
+ else throw new Error(`Section "${ctx.key}": "${slot.path}" reads row member "${String(source.field)}" without naming its row slot — declare the row and read through it: \`{ kind: "row", slot, field }\`.`);
71
+ }
72
+ if (source?.kind === "derived") checkReads(ctx, slot, source.reads, "compute");
73
+ if (source?.kind === "element" && slot.def.type !== "row" && !insideItem(slot)) throw new Error(`Section "${ctx.key}": "${slot.path}" is sourced by the element outside a list's item, where no element exists.`);
74
+ const fill = fillOf(ctx, slot);
75
+ if (fill !== void 0) checkReads(ctx, slot, fill["reads"], "fill");
76
+ }
77
+ }
78
+
79
+ //#endregion
80
+ export { assertRowRuleContract };
@@ -0,0 +1,67 @@
1
+ import { TABLES, tableKeyOf } from "../../template-contracts/dist/slot-catalog.js";
2
+ import { memberListOfKey } from "../../template-contracts/dist/registry-shape.js";
3
+ import { listSourceRefusal } from "../../template-contracts/dist/row.js";
4
+ import "../../template-contracts/dist/table-members.js";
5
+ import { elementTableOf, fillOf, grammarSlots, insideItem, sameSectionSlot, sectionSlotAt } from "./grammar-scope.js";
6
+
7
+ //#region ../../internal/section-contracts/dist/row-source-contract.js
8
+ const ORIGINS = "the element inside an item, a row slot, a `compute()`, or a `fill.pick`";
9
+ function originTable(ctx, row) {
10
+ const source = row.def.source;
11
+ if (source?.kind === "element" && row.container !== void 0) return elementTableOf(ctx, row.container)?.table ?? null;
12
+ if (source?.kind !== "section") return null;
13
+ const target = sameSectionSlot(ctx, source);
14
+ const def = target === null ? void 0 : sectionSlotAt(ctx.schema, target)?.def;
15
+ if (def?.type !== "row" || typeof def.from !== "string") return null;
16
+ return tableKeyOf(def.from)?.table ?? def.from;
17
+ }
18
+ function checkRow(ctx, row) {
19
+ const where = `Section "${ctx.key}": row "${row.path}"`;
20
+ const from = row.def.from;
21
+ if (from === void 0) throw new Error(`${where} declares no \`from\` — a row names its table: \`row({ label, from: fact.property.contacts })\`; rebuild the section with the current Concrete.`);
22
+ if (Array.isArray(from)) for (const [index, key] of from.entries()) {
23
+ if (tableKeyOf(key) === null) throw new Error(`${where}'s \`from\` lists ${JSON.stringify(key)}, which is no table — a row's list of \`from\` names tables.`);
24
+ if (from.indexOf(key) !== index) throw new Error(`${where} names the table ${JSON.stringify(key)} twice in \`from\`.`);
25
+ }
26
+ const table = Array.isArray(from) ? tableKeyOf(from[0]) : tableKeyOf(from);
27
+ if (table === null) {
28
+ if (memberListOfKey(from) === null) throw new Error(`${where}'s \`from\` is ${JSON.stringify(from)}, which is neither a table nor a table's list-valued member — a row's \`from\` is one of ${Object.keys(TABLES).map((t) => `"${t}"`).join(", ")}, or \`<table>.<member>\` for a list-valued member.`);
29
+ if (row.def.source?.kind !== "element" || !insideItem(row)) throw new Error(`${where} is \`from\` the list-valued member ${JSON.stringify(from)} but holds no element — a row from a member holds an item of the list over it: \`source: entry\`.`);
30
+ return;
31
+ }
32
+ const source = row.def.source;
33
+ if (source === void 0) {
34
+ const fill = fillOf(ctx, row);
35
+ if (fill !== void 0 && fill["verb"] !== "pick") throw new Error(`${where} is filled by ${fill["verb"] === void 0 ? "a fill naming no verb" : `\`fill.${String(fill["verb"])}\``} — a row holds a row that exists, which only a \`fill.pick\` yields.`);
36
+ return;
37
+ }
38
+ switch (source.kind) {
39
+ case "home": throw new Error(`${where} is sourced by ${JSON.stringify(source.key)} — a table is a row's \`from\`, never its source; a row's source is ${ORIGINS}.`);
40
+ case "element":
41
+ if (!insideItem(row)) throw new Error(`${where} is sourced by the element, but it sits outside a list's item, where no element exists.`);
42
+ break;
43
+ case "section": {
44
+ if (typeof source.section !== "string" || typeof source.slot !== "string") throw new Error(`${where} is sourced by a section ref naming no section and slot.`);
45
+ const target = sameSectionSlot(ctx, source);
46
+ if (target === null) return;
47
+ const def = sectionSlotAt(ctx.schema, target)?.def;
48
+ if (def === void 0) throw new Error(`${where} is sourced by slot "${target}", which this section does not declare.`);
49
+ if (def.type === "list") throw new Error(listSourceRefusal(where, `the list slot "${target}"`));
50
+ if (def.type !== "row") throw new Error(`${where} is sourced by slot "${target}", a "${String(def.type)}" — a row's slot source is another row.`);
51
+ if (target === row.path) throw new Error(`${where} is sourced by itself.`);
52
+ break;
53
+ }
54
+ case "derived":
55
+ if (source.transform !== row.path) throw new Error(`${where}: unknown transform "${String(source.transform)}". A row's compute() is held under "${row.path}".`);
56
+ return;
57
+ default: throw new Error(`${where} is sourced by ${JSON.stringify(source)} — a row's source is ${ORIGINS}.`);
58
+ }
59
+ const held = originTable(ctx, row);
60
+ if (held !== null && held !== table.table) throw new Error(`${where} is \`from\` the ${table.table} table but its source holds rows of ${held} — a row's source yields a row of its own \`from\`.`);
61
+ }
62
+ function assertRowSourceContract(ctx) {
63
+ for (const slot of grammarSlots(ctx.schema)) if (slot.def.type === "row") checkRow(ctx, slot);
64
+ }
65
+
66
+ //#endregion
67
+ export { assertRowSourceContract };
@@ -1,19 +1,28 @@
1
1
  import { FACT_GRAPH } from "../../template-contracts/dist/slot-catalog.js";
2
+ import { legacyFactKey } from "../../template-contracts/dist/registry-aliases.js";
3
+ import { isReadableFactKey } from "../../template-contracts/dist/fact-keys.js";
2
4
  import { SECTION_CONTRACT_CATALOG } from "./catalog.js";
5
+ import { producedSlot } from "./grammar-scope.js";
3
6
  import { assertCapContract } from "./cap-contract.js";
4
7
  import { assertCountBoundsContract } from "./count-bounds-contract.js";
5
- import { assertGroupContract } from "./group-contract.js";
6
8
  import { assertInterpolationContract } from "./interpolation-contract.js";
7
- import { DECISION_KINDS } from "./fill-spec-view.js";
8
9
  import { assertWriterReadsFactContract } from "./writer-reads-fact-contract.js";
9
10
  import { assertListFillContract } from "./list-fill-contract.js";
10
11
  import { assertListScalarContract } from "./list-scalar-contract.js";
12
+ import { assertListSourceContract } from "./list-source-contract.js";
11
13
  import { assertNestedSlotTypes } from "./nested-slot-contract.js";
12
- import { assertRecordCollectionContract } from "./record-collection-contract.js";
14
+ import { assertDirectlyLinkedListContract } from "./directly-linked-list-contract.js";
15
+ import { assertFillVerbContract } from "./fill-verb-contract.js";
16
+ import { assertObjectContract } from "./object-contract.js";
13
17
  import { assertOptionSourceContract } from "./option-source-contract.js";
18
+ import { DECISION_KINDS } from "./fill-spec-view.js";
14
19
  import { assertPoiCurationContract } from "./poi-curation-contract.js";
20
+ import { assertReadsAcyclicContract } from "./reads-acyclic-contract.js";
15
21
  import { assertRowFillContract } from "./row-fill-contract.js";
16
- import { assertSourceContract } from "./source-contract.js";
22
+ import { assertDeclaredRefs, assertSourceContract } from "./source-contract.js";
23
+ import { assertRowRuleContract } from "./row-rule-contract.js";
24
+ import { assertRowSourceContract } from "./row-source-contract.js";
25
+ import { fillViews } from "../../template-contracts/dist/decision-fills.js";
17
26
  import { assertDisplayContract } from "./display-contract.js";
18
27
  import { assertDisplayEvidenceContract } from "./display-evidence-contract.js";
19
28
  import { assertSelectContract } from "./select-contract.js";
@@ -29,10 +38,24 @@ const byDecision = (run) => ({
29
38
  scope: "decision",
30
39
  run
31
40
  });
41
+ function decisionReadNodes(decision) {
42
+ const nodes = [];
43
+ const add = (at, node) => {
44
+ if (node === null || typeof node !== "object") return;
45
+ const { reads, of } = node;
46
+ nodes.push([at, { reads }]);
47
+ if (of !== null && typeof of === "object") nodes.push([`${at} of`, { reads: of.reads }]);
48
+ };
49
+ add("", decision);
50
+ const fields = decision.fields;
51
+ if (fields !== null && typeof fields === "object") for (const [field, node] of Object.entries(fields)) add(` field "${field}"`, node);
52
+ return nodes;
53
+ }
32
54
  const CONTRACTS = {
33
55
  "reads-readable": {
34
56
  implementation: bySection(({ key, fillSpec }) => {
35
- for (const r of fillSpec.reads ?? []) if (!Object.hasOwn(FACT_GRAPH, r)) throw new Error(`Section "${key}": fill-spec reads "${r}", which is not a fact the registry declares.`);
57
+ for (const r of fillSpec.reads ?? []) if (!isReadableFactKey(r) && !Object.hasOwn(FACT_GRAPH, legacyFactKey(r))) throw new Error(`Section "${key}": fill-spec reads "${r}", which is not a fact the registry declares.`);
58
+ for (const d of fillSpec.decisions) for (const [at, node] of decisionReadNodes(d)) assertDeclaredRefs(`Section "${key}": fill-spec decision "${d.id}"${at}`, node.reads);
36
59
  }),
37
60
  assertions: []
38
61
  },
@@ -48,10 +71,18 @@ const CONTRACTS = {
48
71
  },
49
72
  "produces-known-slot": {
50
73
  implementation: byDecision(({ key, schema }, d) => {
51
- for (const produced of d.produces) if (!(produced in schema.slots)) throw new Error(`Section "${key}": fill-spec decision "${d.id}" produces unknown slot "${produced}".`);
74
+ for (const produced of d.produces) if (producedSlot(schema, produced) === void 0) throw new Error(`Section "${key}": fill-spec decision "${d.id}" produces unknown slot "${produced}".`);
52
75
  }),
53
76
  assertions: []
54
77
  },
78
+ "fill-verb": {
79
+ implementation: byDecision(({ key, schema, fillSpec }, d) => assertFillVerbContract({
80
+ key,
81
+ schema,
82
+ fillSpec
83
+ }, d)),
84
+ assertions: [assertFillVerbContract]
85
+ },
55
86
  "poi-curation": {
56
87
  implementation: byDecision(({ key, schema }, d) => assertPoiCurationContract(schema, d, key)),
57
88
  assertions: [assertPoiCurationContract]
@@ -73,7 +104,7 @@ const CONTRACTS = {
73
104
  assertions: [assertCapContract]
74
105
  },
75
106
  "writer-reads-fact": {
76
- implementation: byDecision(({ key, schema }, d) => assertWriterReadsFactContract(schema, d, key)),
107
+ implementation: byDecision(({ key, schema, fillSpec }, d) => assertWriterReadsFactContract(schema, d, key, fillSpec)),
77
108
  assertions: [assertWriterReadsFactContract]
78
109
  },
79
110
  display: {
@@ -85,15 +116,35 @@ const CONTRACTS = {
85
116
  assertions: [assertDisplayEvidenceContract]
86
117
  },
87
118
  source: {
88
- implementation: bySection(({ key, schema, fillSpec }) => assertSourceContract({
119
+ implementation: bySection(({ key, schema }) => assertSourceContract({
89
120
  key,
90
121
  slots: schema.slots
91
- }, fillSpec)),
122
+ })),
92
123
  assertions: [assertSourceContract]
93
124
  },
125
+ object: {
126
+ implementation: bySection(({ key, schema, fillSpec }) => assertObjectContract(schema, key, fillSpec)),
127
+ assertions: [assertObjectContract]
128
+ },
129
+ "list-source": {
130
+ implementation: bySection((input) => assertListSourceContract(input)),
131
+ assertions: [assertListSourceContract]
132
+ },
133
+ "row-source": {
134
+ implementation: bySection((input) => assertRowSourceContract(input)),
135
+ assertions: [assertRowSourceContract]
136
+ },
137
+ "row-rule": {
138
+ implementation: bySection((input) => assertRowRuleContract(input)),
139
+ assertions: [assertRowRuleContract]
140
+ },
141
+ "reads-acyclic": {
142
+ implementation: bySection((input) => assertReadsAcyclicContract(input)),
143
+ assertions: [assertReadsAcyclicContract]
144
+ },
94
145
  "record-collection": {
95
- implementation: bySection(({ key, schema }) => assertRecordCollectionContract(schema, key)),
96
- assertions: [assertRecordCollectionContract]
146
+ implementation: bySection(({ key, schema }) => assertDirectlyLinkedListContract(schema, key)),
147
+ assertions: [assertDirectlyLinkedListContract]
97
148
  },
98
149
  "nested-slot-types": {
99
150
  implementation: bySection(({ key, schema }) => assertNestedSlotTypes(schema, key)),
@@ -122,22 +173,30 @@ const CONTRACTS = {
122
173
  interpolation: {
123
174
  implementation: bySection(({ key, schema, fillSpec }) => assertInterpolationContract(fillSpec, key, schema)),
124
175
  assertions: [assertInterpolationContract]
125
- },
126
- group: {
127
- implementation: bySection(({ key, schema }) => assertGroupContract(schema, key)),
128
- assertions: [assertGroupContract]
129
176
  }
130
177
  };
178
+ function perFill(input) {
179
+ const decisions = input.fillSpec.decisions.flatMap((decision) => fillViews(decision));
180
+ return {
181
+ ...input,
182
+ fillSpec: {
183
+ ...input.fillSpec,
184
+ decisions
185
+ }
186
+ };
187
+ }
131
188
  function toSectionRunner(implementation) {
132
- if (implementation.scope === "section") return implementation.run;
189
+ if (implementation.scope === "section") return (input) => implementation.run(perFill(input));
133
190
  const { run } = implementation;
134
- return (input) => {
191
+ return (raw) => {
192
+ const input = perFill(raw);
135
193
  for (const decision of input.fillSpec.decisions) run(input, decision);
136
194
  };
137
195
  }
138
196
  const SECTION_CONTRACT_RUNNERS = Object.fromEntries(SECTION_CONTRACT_CATALOG.map(({ id }) => [id, toSectionRunner(CONTRACTS[id].implementation)]));
139
197
  const SECTION_CONTRACT_ASSERTIONS = Object.fromEntries(SECTION_CONTRACT_CATALOG.map(({ id }) => [id, CONTRACTS[id].assertions]));
140
- function collectSectionContractViolations(input) {
198
+ function collectSectionContractViolations(raw) {
199
+ const input = perFill(raw);
141
200
  const violations = [];
142
201
  const attempt = (contract, run) => {
143
202
  try {
@@ -1,15 +1,7 @@
1
- import { normalizeSelectKey } from "../../template-contracts/dist/select-key.js";
2
-
3
1
  //#region ../../internal/section-contracts/dist/select-contract.js
4
2
  function checkSelectSlot(slot, label, sectionKey) {
5
3
  if (slot.type !== "select") return;
6
4
  if (slot.values != null === (slot.options != null)) throw new Error(`Section "${sectionKey}": ${label} needs exactly one of \`values\` or \`options\`.`);
7
- if (slot.creatable === true && Array.isArray(slot.values)) for (const entry of slot.values) {
8
- const key = typeof entry === "string" ? entry : entry?.value;
9
- if (typeof key !== "string") continue;
10
- const normalized = normalizeSelectKey(key);
11
- if (normalized !== key) throw new Error(`Section "${sectionKey}": ${label} is \`creatable\`, so its option keys must be normalized — "${key}" should be "${normalized}".`);
12
- }
13
5
  }
14
6
  function assertSelectContract(schema, sectionKey) {
15
7
  for (const [slotId, slotUnknown] of Object.entries(schema.slots)) {
@@ -1,132 +1,126 @@
1
- import { COLLECTIONS, FACT_GRAPH, SOURCE_FIELDS, isWritableSourceField } from "../../template-contracts/dist/slot-catalog.js";
2
- import { plannedFieldsOf } from "./fill-spec-view.js";
1
+ import { tableKeyOf } from "../../template-contracts/dist/slot-catalog.js";
2
+ import { mirrorKindOf } from "../../template-contracts/dist/mirror-kind.js";
3
+ import { isMediaListKey, sourceFieldDescriptor } from "../../template-contracts/dist/fact-keys.js";
4
+ import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
5
+ import { objectFieldOf } from "../../template-contracts/dist/slot-overrides.js";
3
6
 
4
7
  //#region ../../internal/section-contracts/dist/source-contract.js
5
- function assertOne(path, key, slot) {
8
+ function assertOne(path, key, slot, section) {
9
+ if (slot.type === "row" || slot.type === "object") return;
6
10
  const src = slot.source;
7
- if (!src) {
8
- if (slot.writeback !== void 0) throw new Error(`${path}: "writeback" without a source. Only a slot bound to a fact (a direct source) answers whether edits propagate — remove the key.`);
11
+ if (!src) return;
12
+ if (src.kind === "section") {
13
+ if (slot.type !== "list") assertMirror(path, key, slot, section);
9
14
  return;
10
15
  }
11
- if (src.kind === "direct") {
12
- const def = SOURCE_FIELDS[src.field ?? ""];
13
- if (!def) throw new Error(`${path}: unknown direct source field "${String(src.field)}"`);
14
- const recordItemSlot = slot.type === "list" && slot.fields != null;
15
- if (def.image && slot.type !== "image") throw new Error(`${path}: image source field "${src.field}" must sit on an image slot`);
16
- if (Object.hasOwn(COLLECTIONS, src.field ?? "")) {
17
- if (!recordItemSlot) throw new Error(`${path}: fact-collection source "${src.field}" needs a record item (a list declaring \`fields\`) — a fact row cannot project onto one slot.`);
18
- }
19
- if (typeof slot.writeback !== "boolean") throw new Error(`${path}: a direct source requires "writeback" (boolean) — declare whether edits propagate to "${src.field}".`);
20
- if (slot.writeback === true && !isWritableSourceField(src.field ?? "")) throw new Error(`${path}: "writeback: true" on read-only source field "${src.field}" — the catalog has no write path for it; declare "writeback: false".`);
16
+ if (src.kind === "home") {
17
+ const field = src.key ?? "";
18
+ if (isMediaListKey(field)) throw new Error(`${path}: "${field}" is read, never bound — a \`compute()\` reads a media list; a media slot or a list of media picks from it, naming it as its \`from\` (\`fill.pick\`).`);
19
+ const def = sourceFieldDescriptor(field);
20
+ if (!def) throw new Error(`${path}: unknown fact "${String(src.key)}"`);
21
+ if (def.image && slot.type !== "image") throw new Error(`${path}: image source field "${src.key}" must sit on an image slot`);
22
+ if (def.value_type === "address" && slot.type !== "address") throw new Error(`${path}: "${field}" is a whole address, which only an \`address\` slot holds — bind it to an \`address()\`, or show the line you want with a \`compute()\` reading it (\`concrete upgrade\` rewrites a text slot bound to it).`);
23
+ if (slot.type === "address" && def.value_type !== "address") throw new Error(`${path}: an \`address\` slot bound to "${field}", which is not an address — bind it to the property's address, or compute the value.`);
24
+ if (tableKeyOf(field) !== null && !(slot.type === "list" && (slot.element?.type === "row" || slot.element?.type === "object"))) throw new Error(`${path}: table source "${src.key}" needs an item that declares a row (\`list({ item: (el) => object({ … }) })\`) — a fact row cannot project onto one slot.`);
21
25
  return;
22
26
  }
27
+ if (typeof src.kind !== "string") throw new Error(`${path} is sourced by a ref without a "kind" — this framework reads only kind-tagged refs. Run \`concrete upgrade\`, then build again.`);
28
+ if (src.kind === "item") throw new Error(`${path} is sourced by a field of its own item ({ kind: "item" }) — a section's item fields do not read one another; read the element, or a member through a row.`);
23
29
  if (src.kind !== "derived") return;
24
- if (slot.writeback !== void 0) throw new Error(`${path}: "writeback" on a derived (compute) source. Nothing can write back through a derivation — remove the key.`);
25
30
  if (src.transform !== key) throw new Error(`${path}: unknown transform "${String(src.transform)}". A "derived" source is a compute() binding, and its transform must equal its own slot key ("${key}") — it does not, which means the schema was hand-authored with a mismatched transform rather than produced by defineSchema's compute() path. Author a derived value with compute() ("slot({ source: compute({ reads }, fn) })").`);
26
31
  assertDeclaredRefs(path, src.reads);
27
32
  }
28
- function assertDeclaredRefs(path, reads, rowMember) {
33
+ function declaredSlot(section, target) {
34
+ if (Object.hasOwn(section.slots, target)) return section.slots[target];
35
+ const field = objectFieldOf(target);
36
+ if (field === null) return void 0;
37
+ const object = section.slots[field.object];
38
+ return object?.type === "object" && object.fields !== void 0 && Object.hasOwn(object.fields, field.field) ? object.fields[field.field] : void 0;
39
+ }
40
+ function assertMirror(path, key, slot, section) {
41
+ const { section: upstreamSection, slot: upstream } = slot.source ?? {};
42
+ if (typeof upstreamSection !== "string" || upstreamSection === "" || typeof upstream !== "string" || upstream === "") throw new Error(`${path}: a slot source names no section and slot — a mirror's source is a section ref (\`{ kind: "section", section, slot }\`).`);
43
+ if (upstreamSection !== section.key) return;
44
+ if (upstream === key) throw new Error(`${path} is sourced by itself — a mirror's source is another slot.`);
45
+ const upstreamDef = declaredSlot(section, upstream);
46
+ if (upstreamDef === void 0) throw new Error(`${path} mirrors slot "${upstream}", which this section does not declare — name a top-level slot or a top-level object's field.`);
47
+ const held = mirrorKindOf(slot);
48
+ const upstreamKind = mirrorKindOf(upstreamDef);
49
+ if (held !== void 0 && upstreamKind !== void 0 && held !== upstreamKind) throw new Error(`${path} mirrors slot "${upstream}" but holds ${held} where its upstream holds ${upstreamKind} — a mirror IS its upstream's value: declare it at the upstream's kind, or derive the value with a \`compute()\`.`);
50
+ }
51
+ function assertDeclaredRefs(path, reads) {
29
52
  if (reads === void 0) return;
30
53
  if (!Array.isArray(reads)) throw new Error(`${path}: "reads" is not a list of refs.`);
31
54
  reads.forEach((entry, i) => {
32
- const { kind, key, section, slot, field } = entry ?? {};
33
- if (kind === "fact" && typeof key === "string") return;
34
- if (kind === "slot" && typeof section === "string" && typeof slot === "string") return;
35
- if (kind === "row" && typeof field === "string") {
36
- if (rowMember === void 0) throw new Error(`${path}: reads[${String(i)}] reads the row member "${field}" outside a record list's row — only a row field's compute runs once per row.`);
37
- rowMember(field);
38
- return;
39
- }
40
- throw new Error(kind === void 0 ? `${path}: reads[${String(i)}] is a ref without a "kind" — this framework reads only kind-tagged fact and slot refs. Run \`concrete upgrade\`, then build again.` : `${path}: reads[${String(i)}] is not a fact ref ({ kind: "fact", key }) or a slot ref ({ kind: "slot", section, slot }).`);
55
+ const record = entry ?? {};
56
+ const { kind, key, section, slot, field } = record;
57
+ if (kind === "home" && typeof key === "string") return;
58
+ if (kind === "section" && typeof section === "string" && typeof slot === "string") return;
59
+ refuseIndexedRow(`${path}: reads[${String(i)}]`, record);
60
+ if (kind === "row" && "slot" in record || kind === "element") return;
61
+ throw new Error(kind === void 0 ? `${path}: reads[${String(i)}] is a ref without a "kind" — this framework reads only kind-tagged refs. Run \`concrete upgrade\`, then build again.` : kind === "item" ? `${path}: reads[${String(i)}] reads a field of its own item ({ kind: "item" }) — a section's item fields do not read one another; read the element, or a member through a row.` : kind === "row" ? `${path}: reads[${String(i)}] reads the row member "${String(field)}" without naming its row slot — read it through a row: \`{ kind: "row", slot, field }\`.` : `${path}: reads[${String(i)}] is not a home ref ({ kind: "home", key }) or a section ref ({ kind: "section", section, slot }).`);
41
62
  });
42
63
  }
43
- function assertSourceContract(schema, fillSpec = { decisions: [] }) {
64
+ function assertSourceContract(schema) {
44
65
  for (const [name, slot] of Object.entries(schema.slots)) {
45
66
  const at = `${schema.key}.${name}`;
46
- if (slot.source?.kind === "row") throw new Error(`${at}: a row source on a top-level slot — a row member or marker names a field of a record list's row, and a top-level slot has no row. Bind the slot to a fact instead.`);
47
- assertOne(at, name, slot);
48
- if (slot.type !== "list" || slot.fields === void 0) continue;
49
- assertNotImplicit(at, slot.fields, plannedRowFields(fillSpec, name));
50
- assertRowSourceList(at, name, slot, slot.fields);
67
+ refuseIndexedRow(at, slot.source);
68
+ if (slot.source?.kind === "row" && memberSourceOf(slot.source) === null) throw new Error(`${at}: a row source on a top-level slot names no row slot — a top-level slot reads a member through a row it declares (\`{ kind: "row", slot, field }\`). Bind the slot to a fact or read it through a row.`);
69
+ assertOne(at, name, slot, schema);
70
+ const fields = slot.type === "object" ? slot.fields : slot.type === "list" ? slot.element?.fields : void 0;
71
+ for (const [fieldKey, field] of Object.entries(fields ?? {})) {
72
+ refuseIndexedRow(`${at}.${fieldKey}`, field.source);
73
+ if (field.source?.kind === "row") continue;
74
+ assertOne(`${at}.${fieldKey}`, `${name}.${fieldKey}`, field, schema);
75
+ }
51
76
  }
52
77
  }
53
- function plannedRowFields(fillSpec, listKey) {
54
- const decision = fillSpec.decisions.find((d) => d.produces.includes(listKey));
55
- return new Set(decision === void 0 ? [] : plannedFieldsOf(decision));
56
- }
57
- function assertNotImplicit(at, fields, planned) {
58
- const offenders = [];
59
- for (const [fieldKey, field] of Object.entries(fields)) {
60
- const kind = field.source?.kind;
61
- if (kind === "direct") offenders.push(`"${fieldKey}" (bound \`direct\` to "${String(field.source?.field)}")`);
62
- else if ((kind === void 0 || kind === "authored") && !planned.has(fieldKey)) offenders.push(`"${fieldKey}" (no origin)`);
63
- }
64
- if (offenders.length === 0) return;
65
- throw new Error(`${at}: a record list in the implicit form, which this platform no longer reads — row field ${offenders.join(", ")}. Every row field declares its own origin: a member of its row (\`row.<member>\`), a \`compute()\`, or a \`fill()\`. Rebuild the section with @homepages/concrete 7.0.0 or later (\`concrete upgrade\`).`);
78
+ function refuseIndexedRow(path, ref) {
79
+ if (ref === null || typeof ref !== "object") return;
80
+ const record = ref;
81
+ if (record["kind"] !== "row" || !("collection" in record || "index" in record)) return;
82
+ const table = String(record["collection"]);
83
+ const index = String(record["index"]);
84
+ throw new Error(`${path}: a row read by position (\`fact.property.${table}[${index}]\`) — a list is read whole, and no source or read names its element by position. Declare the row as a computed row and read its member: \`row({ from: fact.property.${table}, source: compute({ reads: [fact.property.${table}] }, (rows) => rows[${index}] ?? null) })\`.`);
66
85
  }
67
86
  function memberFits(valueType, field) {
68
87
  switch (valueType) {
69
88
  case "image": return field.type === "image";
70
- case "image_list": return field.type === "list" && field.fields === void 0 && field.element?.type === "image";
89
+ case "image_list": return field.type === "list" && (field.element?.type === "image" || holdsElementImage(field.element));
90
+ case "row_list": return field.type === "list" && (field.element?.type === "object" || field.element?.type === "row");
91
+ case "text_list": return field.type === "list" && TEXT_FIELD_TYPES.includes(field.element?.type ?? "");
92
+ case "number_list": return field.type === "list" && field.element?.type === "number";
93
+ case "address": return field.type === "address";
71
94
  case "number": return field.type === "number";
72
- case "text": return field.type === "text" || field.type === "url" || field.type === "select";
95
+ case "text": return TEXT_FIELD_TYPES.includes(field.type ?? "");
73
96
  default: return false;
74
97
  }
75
98
  }
99
+ const TEXT_FIELD_TYPES = [
100
+ "text",
101
+ "url",
102
+ "select",
103
+ "date",
104
+ "email",
105
+ "phone"
106
+ ];
107
+ function holdsElementImage(element) {
108
+ if (element?.type !== "object" || element.fields === void 0) return false;
109
+ return Object.values(element.fields).some((field) => field.type === "image" && field.source?.kind === "element");
110
+ }
76
111
  function fittingTypes(valueType) {
77
112
  switch (valueType) {
78
113
  case "image": return "an `image` field";
79
- case "image_list": return "a list of images (`list({ item: image() })`)";
114
+ case "image_list": return "a list of images (`list({ item: image() })`), or a list of objects with an image field reading the element";
115
+ case "row_list": return "a list of objects (`list({ item: object(...) })`)";
116
+ case "text_list": return "a list of text values (`list({ item: text.short({ cap }) })`)";
117
+ case "number_list": return "a list of numbers (`list({ item: number() })`)";
118
+ case "address": return "an `address` field";
80
119
  case "number": return "a `number` field";
81
- case "text": return "a `text`, `url` or `select` field";
120
+ case "text": return "a `text`, `url`, `select`, `date`, `email` or `phone` field";
82
121
  default: return "no field — it is not offered to a row";
83
122
  }
84
123
  }
85
- function assertRowSourceList(at, listKey, list, fields) {
86
- const listSource = list.source;
87
- const boundField = listSource?.kind === "direct" ? listSource.field ?? "" : void 0;
88
- if (boundField !== void 0 && !Object.hasOwn(COLLECTIONS, boundField)) throw new Error(`${at}: row sources on a list bound to "${boundField}", which is not a fact collection — a row member names a member of the row a collection supplies.`);
89
- const collection = boundField;
90
- const computed = listSource?.kind === "derived";
91
- const filled = listSource === void 0;
92
- const assertMember = (path, member) => {
93
- if (filled) throw new Error(`${path}: row member "${member}" on a list a fill() builds — its rows do not exist until the fill answers, so they offer no members. Give the field its own fill() instead.`);
94
- if (collection === void 0) return void 0;
95
- if (member === COLLECTIONS[collection].idKey) throw new Error(`${path}: row member "${member}" is the row's identity, which every baked "${collection}" row carries as "${member}" already — drop the field.`);
96
- const row = FACT_GRAPH[collection].row;
97
- const descriptor = row[member];
98
- if (descriptor === void 0) throw new Error(`${path}: unknown row member "${member}" — a "${collection}" row offers ${Object.keys(row).filter((name) => name !== COLLECTIONS[collection].idKey).map((name) => `"${name}"`).join(", ")}.`);
99
- return descriptor;
100
- };
101
- for (const [fieldKey, field] of Object.entries(fields)) {
102
- const path = `${at}.${fieldKey}`;
103
- const src = field.source;
104
- if (src === void 0 || src.kind === "authored") {
105
- if (field.writeback !== void 0) throw new Error(`${path}: "writeback" without a source. Only a field bound to a row member answers whether edits propagate — remove the key.`);
106
- continue;
107
- }
108
- if (src.kind === "derived") {
109
- if (field.writeback !== void 0) throw new Error(`${path}: "writeback" on a derived (compute) source. Nothing can write back through a derivation — remove the key.`);
110
- const handle = `${listKey}.${fieldKey}`;
111
- if (src.transform !== handle) throw new Error(`${path}: unknown transform "${String(src.transform)}". A row field's compute() is held under "${handle}" — its list's key and its own — which this declaration does not name, so it was not produced by the framework's compute() path.`);
112
- assertDeclaredRefs(path, src.reads, (member) => {
113
- assertMember(path, member);
114
- });
115
- continue;
116
- }
117
- if (src.kind !== "row") continue;
118
- if (typeof src.field !== "string") throw new Error(`${path}: a row source names no member — it is \`{ kind: "row", field: "<member>" }\`.`);
119
- const member = src.field;
120
- const descriptor = assertMember(path, member);
121
- if (field.writeback !== void 0 && typeof field.writeback !== "boolean") throw new Error(`${path}: "writeback" is not a boolean — declare whether edits propagate to row member "${member}".`);
122
- if (descriptor === void 0) {
123
- if (computed && field.writeback === true) throw new Error(`${path}: "writeback: true" on a row of a computed list — nothing can write back through a derivation; declare "writeback: false".`);
124
- continue;
125
- }
126
- if (!memberFits(descriptor.value_type, field)) throw new Error(`${path}: row member "${member}" is a ${descriptor.value_type} value and cannot sit on a "${String(field.type)}" field — it belongs on ${fittingTypes(descriptor.value_type)}.`);
127
- if (field.writeback === true && descriptor.writeback === void 0) throw new Error(`${path}: "writeback: true" on read-only row member "${member}" — the catalog has no write path for it; declare "writeback: false".`);
128
- }
129
- }
130
124
 
131
125
  //#endregion
132
- export { assertDeclaredRefs, assertSourceContract };
126
+ export { assertDeclaredRefs, assertSourceContract, fittingTypes, memberFits, refuseIndexedRow };