@homepages/concrete 7.0.0 → 9.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 (331) hide show
  1. package/CHANGELOG.md +1007 -0
  2. package/README.md +20 -9
  3. package/codemods/list-grammar.mjs +923 -0
  4. package/codemods/manifest.json +66 -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-BUmdDDX5.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/commands.js +1 -1
  57. package/dist/cli/dev/crop.js +1 -1
  58. package/dist/cli/dev/fixture-ladders.js +96 -0
  59. package/dist/cli/dev/islands.js +12 -123
  60. package/dist/cli/dev/listen.js +20 -1
  61. package/dist/cli/dev/load-template.js +1 -1
  62. package/dist/cli/dev/server.js +35 -10
  63. package/dist/cli/dev/vite.js +9 -7
  64. package/dist/cli/dev/workspace-reader.js +16 -16
  65. package/dist/cli/media/derive.js +43 -57
  66. package/dist/cli/media/frame-rung-floor.js +0 -1
  67. package/dist/cli/property/index.js +1 -6
  68. package/dist/css/inline.js +1 -22
  69. package/dist/eslint/rules/no-marker-literal.js +1 -1
  70. package/dist/fixtures/load.js +16 -7
  71. package/dist/fixtures/media-plugin.js +17 -12
  72. package/dist/fixtures/media-store.js +115 -0
  73. package/dist/fixtures/property.js +345 -126
  74. package/dist/fixtures/resolve.js +263 -251
  75. package/dist/fixtures/rows.js +4 -11
  76. package/dist/fixtures.d.ts +234 -109
  77. package/dist/index.d.ts +25 -16
  78. package/dist/index.js +10 -6
  79. package/dist/islands/marker.js +2 -1
  80. package/dist/packages/external/concrete/package.js +1 -1
  81. package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
  82. package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
  83. package/dist/packages/internal/capture-settle/dist/index.js +3 -0
  84. package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
  85. package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
  86. package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
  87. package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
  88. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +252 -35
  89. package/dist/packages/internal/fill-bake/dist/compute-reads.js +365 -4
  90. package/dist/packages/internal/fill-bake/dist/derive-source.js +35 -21
  91. package/dist/packages/internal/fill-bake/dist/index.js +8 -3
  92. package/dist/packages/internal/fill-bake/dist/item-merge.js +119 -0
  93. package/dist/packages/internal/fill-bake/dist/item-overrides.js +28 -0
  94. package/dist/packages/internal/fill-bake/dist/linked-merge.js +40 -0
  95. package/dist/packages/internal/fill-bake/dist/list-grammar.js +175 -0
  96. package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
  97. package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +390 -0
  98. package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
  99. package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +1 -1
  100. package/dist/packages/internal/fill-vocabulary/dist/verbs.js +75 -0
  101. package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
  102. package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
  103. package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
  104. package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
  105. package/dist/packages/internal/image-ladder/dist/index.js +3 -3
  106. package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
  107. package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
  108. package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
  109. package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
  110. package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
  111. package/dist/packages/internal/island-runtime/dist/index.js +2 -1
  112. package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
  113. package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
  114. package/dist/packages/internal/media-resolution/dist/document.js +63 -0
  115. package/dist/packages/internal/media-resolution/dist/image.js +228 -0
  116. package/dist/packages/internal/media-resolution/dist/index.js +11 -0
  117. package/dist/packages/internal/media-resolution/dist/list.js +112 -0
  118. package/dist/packages/internal/media-resolution/dist/media.js +59 -0
  119. package/dist/packages/internal/media-resolution/dist/records.js +7 -0
  120. package/dist/packages/internal/media-resolution/dist/slot.js +34 -0
  121. package/dist/packages/internal/media-resolution/dist/store.js +19 -0
  122. package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
  123. package/dist/packages/internal/media-resolution/dist/video.js +93 -0
  124. package/dist/packages/internal/property-facts/dist/registry-facts.js +244 -0
  125. package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
  126. package/dist/packages/internal/section-contracts/dist/catalog.js +35 -27
  127. package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
  128. package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +27 -0
  129. package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
  130. package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -0
  131. package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
  132. package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
  133. package/dist/packages/internal/section-contracts/dist/index.js +7 -5
  134. package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +23 -19
  135. package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -7
  136. package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
  137. package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
  138. package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
  139. package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +5 -5
  140. package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
  141. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +7 -4
  142. package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +83 -0
  143. package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
  144. package/dist/packages/internal/section-contracts/dist/runners.js +77 -33
  145. package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
  146. package/dist/packages/internal/section-contracts/dist/source-contract.js +120 -66
  147. package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
  148. package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
  149. package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +43 -18
  150. package/dist/packages/internal/source-resolution/dist/index.js +113 -118
  151. package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
  152. package/dist/packages/internal/street-address/dist/index.js +72 -0
  153. package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
  154. package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
  155. package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
  156. package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
  157. package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
  158. package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
  159. package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
  160. package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
  161. package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
  162. package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
  163. package/dist/packages/internal/template-contracts/dist/decision-fills.js +85 -0
  164. package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
  165. package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
  166. package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
  167. package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
  168. package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
  169. package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
  170. package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
  171. package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
  172. package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +12 -36
  173. package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
  174. package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
  175. package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
  176. package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
  177. package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +158 -0
  178. package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
  179. package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
  180. package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
  181. package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
  182. package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
  183. package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
  184. package/dist/packages/internal/template-contracts/dist/list-editing.js +94 -0
  185. package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
  186. package/dist/packages/internal/template-contracts/dist/list.js +258 -0
  187. package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
  188. package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
  189. package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
  190. package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
  191. package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
  192. package/dist/packages/internal/template-contracts/dist/object.js +131 -0
  193. package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
  194. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
  195. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
  196. package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
  197. package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
  198. package/dist/packages/internal/template-contracts/dist/read-graph.js +250 -0
  199. package/dist/packages/internal/template-contracts/dist/ref-locate.js +192 -0
  200. package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
  201. package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +268 -0
  202. package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
  203. package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
  204. package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
  205. package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
  206. package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
  207. package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
  208. package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +133 -0
  209. package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
  210. package/dist/packages/internal/template-contracts/dist/row-sources.js +48 -8
  211. package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
  212. package/dist/packages/internal/template-contracts/dist/row.js +84 -0
  213. package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
  214. package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
  215. package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
  216. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +243 -384
  217. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +334 -230
  218. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
  219. package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
  220. package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
  221. package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
  222. package/dist/packages/internal/template-contracts/dist/slot-types.js +140 -0
  223. package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +97 -0
  224. package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
  225. package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
  226. package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
  227. package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
  228. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
  229. package/dist/platform/fs.js +5 -2
  230. package/dist/playground/canvas-island-host.d.ts +11 -0
  231. package/dist/playground/canvas-island-host.js +29 -0
  232. package/dist/playground/canvas-markers.js +14 -0
  233. package/dist/playground-island-runtime.d.ts +3 -2
  234. package/dist/playground-island-runtime.js +3 -2
  235. package/dist/primitives/FrameShell.js +0 -1
  236. package/dist/primitives/Image.d.ts +5 -4
  237. package/dist/primitives/Tour.d.ts +1 -1
  238. package/dist/primitives/Video.d.ts +2 -2
  239. package/dist/primitives/index.d.ts +2 -3
  240. package/dist/primitives/picture-sources.js +2 -2
  241. package/dist/primitives/probe-context.js +2 -12
  242. package/dist/primitives/slot-address.d.ts +44 -0
  243. package/dist/primitives/slot-address.js +19 -0
  244. package/dist/primitives/slot-bindings.d.ts +65 -26
  245. package/dist/primitives/slot-bindings.js +104 -46
  246. package/dist/primitives/slot-document.d.ts +23 -18
  247. package/dist/primitives/slot-document.js +39 -14
  248. package/dist/primitives/slot-download.d.ts +39 -0
  249. package/dist/primitives/slot-download.js +39 -0
  250. package/dist/primitives/slot-list.d.ts +3 -3
  251. package/dist/primitives/slot-list.js +0 -2
  252. package/dist/primitives/slot-media.d.ts +24 -5
  253. package/dist/primitives/slot-media.js +6 -9
  254. package/dist/primitives/slot-object.d.ts +49 -0
  255. package/dist/primitives/slot-object.js +20 -0
  256. package/dist/primitives/slot-scalar.d.ts +27 -2
  257. package/dist/primitives/slot-scalar.js +50 -7
  258. package/dist/primitives/slot.d.ts +13 -6
  259. package/dist/primitives/slot.js +10 -3
  260. package/dist/rules/registry.js +19 -30
  261. package/dist/schema/define-schema.d.ts +4 -8
  262. package/dist/schema/define-schema.js +178 -79
  263. package/dist/schema/extract-fill-spec.js +2 -158
  264. package/dist/schema/fact.d.ts +57 -15
  265. package/dist/schema/fact.js +42 -7
  266. package/dist/schema/facts-view.d.ts +14 -0
  267. package/dist/schema/format.d.ts +1 -0
  268. package/dist/schema/format.js +2 -1
  269. package/dist/schema/manifest.js +24 -0
  270. package/dist/schema/property-facts.d.ts +8 -11
  271. package/dist/schema/section-props.d.ts +2 -66
  272. package/dist/schema/section-schema.d.ts +8 -11
  273. package/dist/schema/section-schema.js +27 -10
  274. package/dist/section/declare.d.ts +18 -7
  275. package/dist/section/declare.js +18 -5
  276. package/dist/section/materialize.js +3 -8
  277. package/dist/section/section.d.ts +12 -8
  278. package/dist/section/section.js +1 -1
  279. package/dist/template/logic-shim.d.ts +14 -7
  280. package/dist/template/logic-shim.js +14 -7
  281. package/dist/template/materialize.js +17 -18
  282. package/dist/template/mirror-types.js +30 -31
  283. package/dist/template/section-reads.js +85 -9
  284. package/guide/reference/cli/INDEX.md +2 -2
  285. package/guide/reference/cli/build.md +1 -1
  286. package/guide/reference/cli/check.md +1 -1
  287. package/guide/reference/cli/dev.md +1 -1
  288. package/guide/reference/cli/property-add.md +1 -1
  289. package/guide/reference/cli/property-list.md +2 -2
  290. package/guide/reference/cli/publish.md +1 -1
  291. package/guide/reference/cli/upgrade.md +1 -1
  292. package/guide/reference/rules/INDEX.md +29 -29
  293. package/package.json +9 -8
  294. package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
  295. package/dist/artifact/playground/client/assets/index-D8eepVr-.js +0 -1101
  296. package/dist/fixtures/canonical.d.ts +0 -166
  297. package/dist/fixtures/media.js +0 -163
  298. package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -111
  299. package/dist/packages/internal/format-geometry/dist/index.js +0 -4
  300. package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
  301. package/dist/packages/internal/property-facts/dist/index.js +0 -3
  302. package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
  303. package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +0 -20
  304. package/dist/packages/internal/section-contracts/dist/name-title-contract.js +0 -20
  305. package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +0 -22
  306. package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
  307. package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +0 -15
  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 -111
  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 -89
  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 -613
  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,83 @@
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 { tableKeySpelling, tableMemberOrRefuse } from "./table-member.js";
6
+ import { fittingTypes, memberFits, refuseIndexedRow } from "./source-contract.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) {
58
+ if (slot.place === "top" && slot.def.fields !== void 0) return;
59
+ throw new Error(`${where} reads a row member without naming its row slot — read it through a row: \`{ kind: "row", slot, field }\`.`);
60
+ }
61
+ const holder = resolveHolder(ctx, slot, member.slot, where);
62
+ if (holder.kind === "address") addressMemberType(member.field, where);
63
+ else if (holder.table !== null) memberOf(holder.table, member.field, where);
64
+ });
65
+ }
66
+ function assertRowRuleContract(ctx) {
67
+ for (const slot of grammarSlots(ctx.schema)) {
68
+ const source = slot.def.source;
69
+ refuseIndexedRow(`Section "${ctx.key}": "${slot.path}"`, source);
70
+ if (source?.kind === "row") {
71
+ const member = memberSourceOf(source);
72
+ if (member !== null) checkMemberSource(ctx, slot, member);
73
+ else if (slot.place !== "top") throw new Error(`Section "${ctx.key}": "${slot.path}" reads row member "${String(source.field)}" without naming its row slot — the enclosing-list form reads only in a \`fields\` list. Declare the row and read through it: \`{ kind: "row", slot, field }\`.`);
74
+ }
75
+ if (source?.kind === "derived") checkReads(ctx, slot, source.reads, "compute");
76
+ 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.`);
77
+ const fill = fillOf(ctx, slot);
78
+ if (fill !== void 0) checkReads(ctx, slot, fill["reads"], "fill");
79
+ }
80
+ }
81
+
82
+ //#endregion
83
+ 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,26 +1,32 @@
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
- import { DECISION_KINDS } from "./fill-spec-view.js";
5
- import { assertChooseSelectContract } from "./choose-select-contract.js";
6
7
  import { assertCountBoundsContract } from "./count-bounds-contract.js";
7
8
  import { assertGroupContract } from "./group-contract.js";
8
9
  import { assertInterpolationContract } from "./interpolation-contract.js";
10
+ import { DECISION_KINDS } from "./fill-spec-view.js";
9
11
  import { assertWriterReadsFactContract } from "./writer-reads-fact-contract.js";
10
12
  import { assertListFillContract } from "./list-fill-contract.js";
11
13
  import { assertListScalarContract } from "./list-scalar-contract.js";
12
- import { assertNameTitleContract } from "./name-title-contract.js";
14
+ import { assertListSourceContract } from "./list-source-contract.js";
13
15
  import { assertNestedSlotTypes } from "./nested-slot-contract.js";
14
- import { assertRecordCollectionContract } from "./record-collection-contract.js";
16
+ import { assertDirectlyLinkedListContract } from "./directly-linked-list-contract.js";
17
+ import { assertFillVerbContract } from "./fill-verb-contract.js";
18
+ import { assertObjectContract } from "./object-contract.js";
15
19
  import { assertOptionSourceContract } from "./option-source-contract.js";
16
20
  import { assertPoiCurationContract } from "./poi-curation-contract.js";
17
- import { assertPoolingFieldContract } from "./pooling-field-contract.js";
21
+ import { assertReadsAcyclicContract } from "./reads-acyclic-contract.js";
18
22
  import { assertRowFillContract } from "./row-fill-contract.js";
19
- import { assertSourceContract } from "./source-contract.js";
23
+ import { assertDeclaredRefs, assertSourceContract } from "./source-contract.js";
24
+ import { assertRowRuleContract } from "./row-rule-contract.js";
25
+ import { assertRowSourceContract } from "./row-source-contract.js";
26
+ import { fillViews } from "../../template-contracts/dist/decision-fills.js";
20
27
  import { assertDisplayContract } from "./display-contract.js";
21
28
  import { assertDisplayEvidenceContract } from "./display-evidence-contract.js";
22
29
  import { assertSelectContract } from "./select-contract.js";
23
- import { assertSourceFilterContract } from "./source-filter-contract.js";
24
30
  import { assertSourcesContract } from "./sources-contract.js";
25
31
  import { assertUrlContract } from "./url-contract.js";
26
32
 
@@ -33,10 +39,24 @@ const byDecision = (run) => ({
33
39
  scope: "decision",
34
40
  run
35
41
  });
42
+ function decisionReadNodes(decision) {
43
+ const nodes = [];
44
+ const add = (at, node) => {
45
+ if (node === null || typeof node !== "object") return;
46
+ const { reads, of } = node;
47
+ nodes.push([at, { reads }]);
48
+ if (of !== null && typeof of === "object") nodes.push([`${at} of`, { reads: of.reads }]);
49
+ };
50
+ add("", decision);
51
+ const fields = decision.fields;
52
+ if (fields !== null && typeof fields === "object") for (const [field, node] of Object.entries(fields)) add(` field "${field}"`, node);
53
+ return nodes;
54
+ }
36
55
  const CONTRACTS = {
37
56
  "reads-readable": {
38
57
  implementation: bySection(({ key, fillSpec }) => {
39
- 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.`);
58
+ for (const r of fillSpec.reads ?? []) if (!isReadableFactKey(r) && !Object.hasOwn(FACT_GRAPH, legacyFactKey(r))) throw new Error(`Section "${key}": fill-spec reads "${r}", which is not a fact the registry declares.`);
59
+ for (const d of fillSpec.decisions) for (const [at, node] of decisionReadNodes(d)) assertDeclaredRefs(`Section "${key}": fill-spec decision "${d.id}"${at}`, node.reads, () => void 0);
40
60
  }),
41
61
  assertions: []
42
62
  },
@@ -52,10 +72,18 @@ const CONTRACTS = {
52
72
  },
53
73
  "produces-known-slot": {
54
74
  implementation: byDecision(({ key, schema }, d) => {
55
- 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}".`);
75
+ 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}".`);
56
76
  }),
57
77
  assertions: []
58
78
  },
79
+ "fill-verb": {
80
+ implementation: byDecision(({ key, schema, fillSpec }, d) => assertFillVerbContract({
81
+ key,
82
+ schema,
83
+ fillSpec
84
+ }, d)),
85
+ assertions: [assertFillVerbContract]
86
+ },
59
87
  "poi-curation": {
60
88
  implementation: byDecision(({ key, schema }, d) => assertPoiCurationContract(schema, d, key)),
61
89
  assertions: [assertPoiCurationContract]
@@ -64,18 +92,6 @@ const CONTRACTS = {
64
92
  implementation: byDecision(({ key, schema }, d) => assertListFillContract(schema, d, key)),
65
93
  assertions: [assertListFillContract]
66
94
  },
67
- "choose-select": {
68
- implementation: byDecision(({ key, schema }, d) => assertChooseSelectContract(schema, d, key)),
69
- assertions: [assertChooseSelectContract]
70
- },
71
- "name-title": {
72
- implementation: byDecision(({ key, schema }, d) => assertNameTitleContract(schema, d, key)),
73
- assertions: [assertNameTitleContract]
74
- },
75
- "pooling-field": {
76
- implementation: byDecision(({ key, schema }, d) => assertPoolingFieldContract(schema, d, key)),
77
- assertions: [assertPoolingFieldContract]
78
- },
79
95
  "row-fill": {
80
96
  implementation: byDecision(({ key, schema }, d) => assertRowFillContract(schema, d, key)),
81
97
  assertions: [assertRowFillContract]
@@ -89,7 +105,7 @@ const CONTRACTS = {
89
105
  assertions: [assertCapContract]
90
106
  },
91
107
  "writer-reads-fact": {
92
- implementation: byDecision(({ key, schema }, d) => assertWriterReadsFactContract(schema, d, key)),
108
+ implementation: byDecision(({ key, schema, fillSpec }, d) => assertWriterReadsFactContract(schema, d, key, fillSpec)),
93
109
  assertions: [assertWriterReadsFactContract]
94
110
  },
95
111
  display: {
@@ -101,15 +117,35 @@ const CONTRACTS = {
101
117
  assertions: [assertDisplayEvidenceContract]
102
118
  },
103
119
  source: {
104
- implementation: bySection(({ key, schema }) => assertSourceContract({
120
+ implementation: bySection(({ key, schema, fillSpec }) => assertSourceContract({
105
121
  key,
106
122
  slots: schema.slots
107
- })),
123
+ }, fillSpec)),
108
124
  assertions: [assertSourceContract]
109
125
  },
126
+ object: {
127
+ implementation: bySection(({ key, schema, fillSpec }) => assertObjectContract(schema, key, fillSpec)),
128
+ assertions: [assertObjectContract]
129
+ },
130
+ "list-source": {
131
+ implementation: bySection((input) => assertListSourceContract(input)),
132
+ assertions: [assertListSourceContract]
133
+ },
134
+ "row-source": {
135
+ implementation: bySection((input) => assertRowSourceContract(input)),
136
+ assertions: [assertRowSourceContract]
137
+ },
138
+ "row-rule": {
139
+ implementation: bySection((input) => assertRowRuleContract(input)),
140
+ assertions: [assertRowRuleContract]
141
+ },
142
+ "reads-acyclic": {
143
+ implementation: bySection((input) => assertReadsAcyclicContract(input)),
144
+ assertions: [assertReadsAcyclicContract]
145
+ },
110
146
  "record-collection": {
111
- implementation: bySection(({ key, schema }) => assertRecordCollectionContract(schema, key)),
112
- assertions: [assertRecordCollectionContract]
147
+ implementation: bySection(({ key, schema }) => assertDirectlyLinkedListContract(schema, key)),
148
+ assertions: [assertDirectlyLinkedListContract]
113
149
  },
114
150
  "nested-slot-types": {
115
151
  implementation: bySection(({ key, schema }) => assertNestedSlotTypes(schema, key)),
@@ -131,10 +167,6 @@ const CONTRACTS = {
131
167
  implementation: bySection(({ key, schema }) => assertUrlContract(schema, key)),
132
168
  assertions: [assertUrlContract]
133
169
  },
134
- "source-filter": {
135
- implementation: bySection(({ key, schema }) => assertSourceFilterContract(schema, key)),
136
- assertions: [assertSourceFilterContract]
137
- },
138
170
  sources: {
139
171
  implementation: bySection(({ key, schema }) => assertSourcesContract(schema, key)),
140
172
  assertions: [assertSourcesContract]
@@ -148,16 +180,28 @@ const CONTRACTS = {
148
180
  assertions: [assertGroupContract]
149
181
  }
150
182
  };
183
+ function perFill(input) {
184
+ const decisions = input.fillSpec.decisions.flatMap((decision) => fillViews(decision));
185
+ return {
186
+ ...input,
187
+ fillSpec: {
188
+ ...input.fillSpec,
189
+ decisions
190
+ }
191
+ };
192
+ }
151
193
  function toSectionRunner(implementation) {
152
- if (implementation.scope === "section") return implementation.run;
194
+ if (implementation.scope === "section") return (input) => implementation.run(perFill(input));
153
195
  const { run } = implementation;
154
- return (input) => {
196
+ return (raw) => {
197
+ const input = perFill(raw);
155
198
  for (const decision of input.fillSpec.decisions) run(input, decision);
156
199
  };
157
200
  }
158
201
  const SECTION_CONTRACT_RUNNERS = Object.fromEntries(SECTION_CONTRACT_CATALOG.map(({ id }) => [id, toSectionRunner(CONTRACTS[id].implementation)]));
159
202
  const SECTION_CONTRACT_ASSERTIONS = Object.fromEntries(SECTION_CONTRACT_CATALOG.map(({ id }) => [id, CONTRACTS[id].assertions]));
160
- function collectSectionContractViolations(input) {
203
+ function collectSectionContractViolations(raw) {
204
+ const input = perFill(raw);
161
205
  const violations = [];
162
206
  const attempt = (contract, run) => {
163
207
  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,115 +1,173 @@
1
- import { COLLECTIONS, FACT_GRAPH, SOURCE_FIELDS, isWritableSourceField } from "../../template-contracts/dist/slot-catalog.js";
2
- import { usesRowSources } from "../../template-contracts/dist/row-sources.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 { plannedFieldsOf } from "./fill-spec-view.js";
6
+ import { objectFieldOf } from "../../template-contracts/dist/slot-overrides.js";
7
+ import { tableMemberOrRefuse } from "./table-member.js";
3
8
 
4
9
  //#region ../../internal/section-contracts/dist/source-contract.js
5
- function rowContainerOf(desc) {
6
- if (desc.value_type === "unit_list") return "unit";
7
- if (desc.value_type === "contact_list") return "contact";
8
- return null;
9
- }
10
- function assertOne(path, key, slot, rowContainer) {
10
+ function assertOne(path, key, slot, section) {
11
+ if (slot.type === "row" || slot.type === "object") return;
11
12
  const src = slot.source;
12
- if (!src) {
13
- 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.`);
13
+ if (!src) return;
14
+ if (src.kind === "section") {
15
+ if (slot.type !== "list") assertMirror(path, key, slot, section);
14
16
  return;
15
17
  }
16
- if (src.kind === "direct") {
17
- const def = SOURCE_FIELDS[src.field ?? ""];
18
- if (!def) throw new Error(`${path}: unknown direct source field "${String(src.field)}"`);
18
+ if (src.kind === "home") {
19
+ const field = src.key ?? "";
20
+ if (isMediaListKey(field)) throw new Error(`${path}: "${field}" is read, never bound — a \`compute()\` reads a media list; a media slot or a list of media picks from it, naming it as its \`from\` (\`fill.pick\`).`);
21
+ const def = sourceFieldDescriptor(field);
22
+ if (!def) throw new Error(`${path}: unknown fact "${String(src.key)}"`);
19
23
  const recordItemSlot = slot.type === "list" && slot.fields != null;
20
- if (def.image && slot.type !== "image" && !recordItemSlot) throw new Error(`${path}: image source field "${src.field}" must sit on an image slot`);
21
- if (Object.hasOwn(COLLECTIONS, src.field ?? "")) {
22
- 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.`);
24
+ if (def.image && slot.type !== "image") throw new Error(`${path}: image source field "${src.key}" must sit on an image slot`);
25
+ if (def.value_type === "address" && slot.type !== "address") throw new Error(`${path}: "${field}" is a whole address, which only an \`address\` slot holds — bind it to an \`address()\`, or show the line you want with a \`compute()\` reading it (\`concrete upgrade\` rewrites a text slot bound to it).`);
26
+ if (slot.type === "address" && def.value_type !== "address") throw new Error(`${path}: an \`address\` slot bound to "${field}", which is not an address — bind it to the property's address, or compute the value.`);
27
+ if (tableKeyOf(field) !== null) {
28
+ if (slot.type === "list" && slot.fields === void 0 && (slot.element?.type === "row" || slot.element?.type === "object")) return;
29
+ if (!recordItemSlot) throw new Error(`${path}: table source "${src.key}" needs a record item (a list declaring \`fields\`, or an item that declares a row) — a fact row cannot project onto one slot.`);
23
30
  }
24
- if (rowContainer !== null && def.container !== rowContainer) throw new Error(`${path}: row-field source "${src.field}" belongs to the "${def.container}" container, but this list's rows resolve against "${rowContainer}" — a row field must bind a field of its own row.`);
25
- if (typeof slot.writeback !== "boolean") throw new Error(`${path}: a direct source requires "writeback" (boolean) — declare whether edits propagate to "${src.field}".`);
26
- 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".`);
27
31
  return;
28
32
  }
33
+ 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.`);
34
+ 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.`);
29
35
  if (src.kind !== "derived") return;
30
- 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.`);
31
36
  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) })").`);
32
37
  assertDeclaredRefs(path, src.reads);
33
38
  }
39
+ function declaredSlot(section, target) {
40
+ if (Object.hasOwn(section.slots, target)) return section.slots[target];
41
+ const field = objectFieldOf(target);
42
+ if (field === null) return void 0;
43
+ const object = section.slots[field.object];
44
+ return object?.type === "object" && object.fields !== void 0 && Object.hasOwn(object.fields, field.field) ? object.fields[field.field] : void 0;
45
+ }
46
+ function assertMirror(path, key, slot, section) {
47
+ const { section: upstreamSection, slot: upstream } = slot.source ?? {};
48
+ 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 }\`).`);
49
+ if (upstreamSection !== section.key) return;
50
+ if (upstream === key) throw new Error(`${path} is sourced by itself — a mirror's source is another slot.`);
51
+ const upstreamDef = declaredSlot(section, upstream);
52
+ 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.`);
53
+ const held = mirrorKindOf(slot);
54
+ const upstreamKind = mirrorKindOf(upstreamDef);
55
+ if (held !== void 0 && upstreamKind !== void 0 && held !== upstreamKind) throw new Error(`${path} mirrors slot "${upstream}" but holds ${held} where its upstream holds ${upstreamKind} — a mirror IS its upstream's value: declare it at the upstream's kind, or derive the value with a \`compute()\`.`);
56
+ }
34
57
  function assertDeclaredRefs(path, reads, rowMember) {
35
58
  if (reads === void 0) return;
36
59
  if (!Array.isArray(reads)) throw new Error(`${path}: "reads" is not a list of refs.`);
37
60
  reads.forEach((entry, i) => {
38
- const { kind, key, section, slot, field } = entry ?? {};
39
- if (kind === "fact" && typeof key === "string") return;
40
- if (kind === "slot" && typeof section === "string" && typeof slot === "string") return;
61
+ const record = entry ?? {};
62
+ const { kind, key, section, slot, field } = record;
63
+ if (kind === "home" && typeof key === "string") return;
64
+ if (kind === "section" && typeof section === "string" && typeof slot === "string") return;
65
+ refuseIndexedRow(`${path}: reads[${String(i)}]`, record);
66
+ if (kind === "row" && "slot" in record || kind === "element") return;
41
67
  if (kind === "row" && typeof field === "string") {
42
68
  if (rowMember === void 0) throw new Error(`${path}: reads[${String(i)}] reads the row member "${field}" outside a record list's row — only a row field's compute runs once per row.`);
43
69
  rowMember(field);
44
70
  return;
45
71
  }
46
- 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 }).`);
72
+ throw new Error(kind === void 0 ? `${path}: reads[${String(i)}] is a ref without a "kind" — this framework reads only kind-tagged refs. Run \`concrete upgrade\`, then build again.` : kind === "item" ? `${path}: reads[${String(i)}] reads a field of its own item ({ kind: "item" }) — a section's item fields do not read one another; read the element, or a member through a row.` : `${path}: reads[${String(i)}] is not a home ref ({ kind: "home", key }) or a section ref ({ kind: "section", section, slot }).`);
47
73
  });
48
74
  }
49
- function assertSourceContract(schema) {
75
+ function assertSourceContract(schema, fillSpec = { decisions: [] }) {
50
76
  for (const [name, slot] of Object.entries(schema.slots)) {
51
77
  const at = `${schema.key}.${name}`;
52
- 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.`);
53
- assertOne(at, name, slot, null);
54
- if (slot.type !== "list" || slot.fields === void 0) continue;
55
- if (usesRowSources(slot.fields)) {
56
- assertRowSourceList(at, name, slot, slot.fields);
57
- continue;
58
- }
59
- const hostField = slot.source?.kind === "direct" ? slot.source.field : void 0;
60
- const hostDesc = hostField !== void 0 ? SOURCE_FIELDS[hostField] : void 0;
61
- const rowContainer = hostDesc !== void 0 ? rowContainerOf(hostDesc) : null;
62
- for (const [fieldKey, rowField] of Object.entries(slot.fields)) {
63
- const path = `${schema.key}.${name}.${fieldKey}`;
64
- if (rowField.source?.kind === "direct" && rowContainer === null) throw new Error(hostDesc === void 0 ? `${path}: row-field source "${String(rowField.source.field)}" on a list that is not fact-bound — a per-field source resolves against the row an array source projects, so bind the list itself (or remove the field's source).` : `${path}: row-field source "${String(rowField.source.field)}" on a list bound to "${String(hostField)}", whose rows are not projected from catalog fields — such a row carries its own members, so name the member as the field's own key and drop \`source\`.`);
65
- assertOne(path, fieldKey, rowField, rowContainer);
78
+ refuseIndexedRow(at, slot.source);
79
+ if (slot.source?.kind === "row" && memberSourceOf(slot.source) === null) throw new Error(`${at}: a row source on a top-level slot names no row slot — a top-level slot reads a member through a row it declares (\`{ kind: "row", slot, field }\`). Bind the slot to a fact or read it through a row.`);
80
+ assertOne(at, name, slot, schema);
81
+ const grammarFields = slot.type === "object" ? slot.fields : slot.type === "list" && slot.fields === void 0 ? slot.element?.fields : void 0;
82
+ for (const [fieldKey, field] of Object.entries(grammarFields ?? {})) {
83
+ refuseIndexedRow(`${at}.${fieldKey}`, field.source);
84
+ if (field.source?.kind === "row") continue;
85
+ assertOne(`${at}.${fieldKey}`, `${name}.${fieldKey}`, field, schema);
66
86
  }
87
+ if (slot.type !== "list" || slot.fields === void 0) continue;
88
+ assertNotImplicit(at, slot.fields, plannedRowFields(fillSpec, name));
89
+ assertRowSourceList(at, name, slot, slot.fields);
67
90
  }
68
91
  }
92
+ function plannedRowFields(fillSpec, listKey) {
93
+ const decision = fillSpec.decisions.find((d) => d.produces.includes(listKey));
94
+ return new Set(decision === void 0 ? [] : plannedFieldsOf(decision));
95
+ }
96
+ function assertNotImplicit(at, fields, planned) {
97
+ const offenders = [];
98
+ for (const [fieldKey, field] of Object.entries(fields)) {
99
+ const kind = field.source?.kind;
100
+ if (kind === "home") offenders.push(`"${fieldKey}" (bound to the fact "${String(field.source?.key)}")`);
101
+ else if ((kind === void 0 || kind === "authored") && !planned.has(fieldKey)) offenders.push(`"${fieldKey}" (no origin)`);
102
+ }
103
+ if (offenders.length === 0) return;
104
+ throw new Error(`${at}: a record list in the implicit form, which this platform no longer reads — row field ${offenders.join(", ")}. Every row field declares its own origin: a member of its row (\`row.<member>\`), a \`compute()\`, or a \`fill()\`. Rebuild the section with @homepages/concrete 7.0.0 or later (\`concrete upgrade\`).`);
105
+ }
106
+ function refuseIndexedRow(path, ref) {
107
+ if (ref === null || typeof ref !== "object") return;
108
+ const record = ref;
109
+ if (record["kind"] !== "row" || !("collection" in record || "index" in record)) return;
110
+ const table = String(record["collection"]);
111
+ const index = String(record["index"]);
112
+ 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) })\`.`);
113
+ }
69
114
  function memberFits(valueType, field) {
70
115
  switch (valueType) {
71
116
  case "image": return field.type === "image";
72
- case "image_list": return field.type === "list" && field.fields === void 0 && field.element?.type === "image";
117
+ case "image_list": return field.type === "list" && field.fields === void 0 && (field.element?.type === "image" || holdsElementImage(field.element));
118
+ case "row_list": return field.type === "list" && field.fields === void 0 && (field.element?.type === "object" || field.element?.type === "row");
119
+ case "text_list": return field.type === "list" && field.fields === void 0 && TEXT_FIELD_TYPES.includes(field.element?.type ?? "");
120
+ case "number_list": return field.type === "list" && field.fields === void 0 && field.element?.type === "number";
121
+ case "address": return field.type === "address";
73
122
  case "number": return field.type === "number";
74
- case "text": return field.type === "text" || field.type === "url" || field.type === "select";
123
+ case "text": return TEXT_FIELD_TYPES.includes(field.type ?? "");
75
124
  default: return false;
76
125
  }
77
126
  }
127
+ const TEXT_FIELD_TYPES = [
128
+ "text",
129
+ "url",
130
+ "select",
131
+ "date",
132
+ "email",
133
+ "phone"
134
+ ];
135
+ function holdsElementImage(element) {
136
+ if (element?.type !== "object" || element.fields === void 0) return false;
137
+ return Object.values(element.fields).some((field) => field.type === "image" && field.source?.kind === "element");
138
+ }
78
139
  function fittingTypes(valueType) {
79
140
  switch (valueType) {
80
141
  case "image": return "an `image` field";
81
- case "image_list": return "a list of images (`list({ item: image() })`)";
142
+ case "image_list": return "a list of images (`list({ item: image() })`), or a list of objects with an image field reading the element";
143
+ case "row_list": return "a list of objects (`list({ item: object(...) })`)";
144
+ case "text_list": return "a list of text values (`list({ item: text.short({ cap }) })`)";
145
+ case "number_list": return "a list of numbers (`list({ item: number() })`)";
146
+ case "address": return "an `address` field";
82
147
  case "number": return "a `number` field";
83
- case "text": return "a `text`, `url` or `select` field";
148
+ case "text": return "a `text`, `url`, `select`, `date`, `email` or `phone` field";
84
149
  default: return "no field — it is not offered to a row";
85
150
  }
86
151
  }
87
152
  function assertRowSourceList(at, listKey, list, fields) {
88
153
  const listSource = list.source;
89
- const boundField = listSource?.kind === "direct" ? listSource.field ?? "" : void 0;
90
- 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.`);
91
- const collection = boundField;
92
- const computed = listSource?.kind === "derived";
154
+ const boundField = listSource?.kind === "home" ? listSource.key ?? "" : void 0;
155
+ const table = boundField === void 0 ? void 0 : tableKeyOf(boundField);
156
+ if (table === null) throw new Error(`${at}: row sources on a list bound to "${String(boundField)}", which is not a table — a row member names a member of the row a table supplies.`);
93
157
  const filled = listSource === void 0;
94
158
  const assertMember = (path, member) => {
95
159
  if (filled) throw new Error(`${path}: row member "${member}" on a list a fill() builds — its rows do not exist until the fill answers, so they offer no members. Give the field its own fill() instead.`);
96
- if (collection === void 0) return void 0;
97
- 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.`);
98
- const row = FACT_GRAPH[collection].row;
99
- const descriptor = row[member];
100
- 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(", ")}.`);
101
- return descriptor;
160
+ if (table === void 0) return void 0;
161
+ return tableMemberOrRefuse(table, member, path, {
162
+ noun: "row member",
163
+ identity: `row member "${member}" is the row's identity, which every baked "${String(boundField)}" row carries as "${member}" already — drop the field.`
164
+ });
102
165
  };
103
166
  for (const [fieldKey, field] of Object.entries(fields)) {
104
167
  const path = `${at}.${fieldKey}`;
105
168
  const src = field.source;
106
- if (src === void 0 || src.kind === "authored") {
107
- 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.`);
108
- continue;
109
- }
110
- if (src.kind === "direct") throw new Error(`${path}: a direct source on a row field of a list whose other fields name row members — one list declares its rows one way. Name this field's member too (\`source: <row>.<member>\`).`);
169
+ if (src === void 0 || src.kind === "authored") continue;
111
170
  if (src.kind === "derived") {
112
- 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.`);
113
171
  const handle = `${listKey}.${fieldKey}`;
114
172
  if (src.transform !== handle) throw new Error(`${path}: unknown transform "${String(src.transform)}". A row field's compute() is held under "${handle}" — its list's key and its own — which this declaration does not name, so it was not produced by the framework's compute() path.`);
115
173
  assertDeclaredRefs(path, src.reads, (member) => {
@@ -118,18 +176,14 @@ function assertRowSourceList(at, listKey, list, fields) {
118
176
  continue;
119
177
  }
120
178
  if (src.kind !== "row") continue;
179
+ refuseIndexedRow(path, src);
121
180
  if (typeof src.field !== "string") throw new Error(`${path}: a row source names no member — it is \`{ kind: "row", field: "<member>" }\`.`);
122
181
  const member = src.field;
123
182
  const descriptor = assertMember(path, member);
124
- 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}".`);
125
- if (descriptor === void 0) {
126
- 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".`);
127
- continue;
128
- }
183
+ if (descriptor === void 0) continue;
129
184
  if (!memberFits(descriptor.value_type, field)) throw new Error(`${path}: row member "${member}" is a ${descriptor.value_type} value and cannot sit on a "${String(field.type)}" field — it belongs on ${fittingTypes(descriptor.value_type)}.`);
130
- 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".`);
131
185
  }
132
186
  }
133
187
 
134
188
  //#endregion
135
- export { assertDeclaredRefs, assertSourceContract };
189
+ export { assertDeclaredRefs, assertSourceContract, fittingTypes, memberFits, refuseIndexedRow };