@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.
- package/CHANGELOG.md +1007 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +66 -0
- package/codemods/process-builders.mjs +198 -0
- package/codemods/slot-object.mjs +1097 -0
- package/codemods/steps/content-object-fields.mjs +324 -0
- package/codemods/steps/list-object-form.mjs +6 -7
- package/codemods/table-rows.mjs +568 -0
- package/codemods/unwrap-object-fields.mjs +310 -0
- package/codemods/viewer-slot-document.mjs +131 -0
- package/codemods/write-property-as-facts-document.mjs +716 -0
- package/codemods/write-the-address-line.mjs +255 -0
- package/codemods/write-the-registry-members.mjs +653 -0
- package/codemods/write-the-select-from.mjs +141 -0
- package/codemods/write-the-sole-from.mjs +369 -0
- package/codemods/write-the-table-from.mjs +267 -0
- package/codemods/write-the-whole-item.mjs +512 -0
- package/codemods/writeback-drop.mjs +168 -0
- package/codemods/written-contact-address.mjs +162 -0
- package/codemods/written-media-category.mjs +227 -0
- package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
- package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
- package/codemods/written-uploads-sort-into-lists.mjs +405 -0
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
- package/codemods/written-video-sources-drop.mjs +144 -0
- package/codemods/written-without-pick-none.mjs +146 -0
- package/codemods/written-without-retired-knowledge.mjs +223 -0
- package/codemods/written-without-the-media-key.mjs +202 -0
- package/codemods/written-without-the-property-type.mjs +249 -0
- package/dist/artifact/playground/client/assets/index-BUmdDDX5.js +1259 -0
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +61 -27
- package/dist/base.css +58 -1
- package/dist/cli/build/artifact.js +6 -9
- package/dist/cli/build/captures.js +2 -12
- package/dist/cli/build/esbuild.js +1 -25
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/static.js +2 -2
- package/dist/cli/capture/capture.js +8 -9
- package/dist/cli/check/analyze.js +8 -1
- package/dist/cli/check/load-outdir.js +47 -0
- package/dist/cli/check/load-workspace.js +4 -4
- package/dist/cli/check/render/html.js +1 -2
- package/dist/cli/check/render/inputs.js +10 -3
- package/dist/cli/check/render/island-frames.js +2 -1
- package/dist/cli/check/render/marker-coverage.js +23 -15
- package/dist/cli/check/report.js +5 -0
- package/dist/cli/check/stages/bundles.js +1 -1
- package/dist/cli/check/stages/relations.js +1 -1
- package/dist/cli/check/stages/render.js +48 -33
- package/dist/cli/check/stages/sections.js +83 -31
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/crop.js +1 -1
- package/dist/cli/dev/fixture-ladders.js +96 -0
- package/dist/cli/dev/islands.js +12 -123
- package/dist/cli/dev/listen.js +20 -1
- package/dist/cli/dev/load-template.js +1 -1
- package/dist/cli/dev/server.js +35 -10
- package/dist/cli/dev/vite.js +9 -7
- package/dist/cli/dev/workspace-reader.js +16 -16
- package/dist/cli/media/derive.js +43 -57
- package/dist/cli/media/frame-rung-floor.js +0 -1
- package/dist/cli/property/index.js +1 -6
- package/dist/css/inline.js +1 -22
- package/dist/eslint/rules/no-marker-literal.js +1 -1
- package/dist/fixtures/load.js +16 -7
- package/dist/fixtures/media-plugin.js +17 -12
- package/dist/fixtures/media-store.js +115 -0
- package/dist/fixtures/property.js +345 -126
- package/dist/fixtures/resolve.js +263 -251
- package/dist/fixtures/rows.js +4 -11
- package/dist/fixtures.d.ts +234 -109
- package/dist/index.d.ts +25 -16
- package/dist/index.js +10 -6
- package/dist/islands/marker.js +2 -1
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
- package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
- package/dist/packages/internal/capture-settle/dist/index.js +3 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
- package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
- package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +252 -35
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +365 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +35 -21
- package/dist/packages/internal/fill-bake/dist/index.js +8 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +119 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +28 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +40 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +175 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +390 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +75 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
- package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
- package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
- package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
- package/dist/packages/internal/image-ladder/dist/index.js +3 -3
- package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
- package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
- package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
- package/dist/packages/internal/island-runtime/dist/index.js +2 -1
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
- package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
- package/dist/packages/internal/media-resolution/dist/document.js +63 -0
- package/dist/packages/internal/media-resolution/dist/image.js +228 -0
- package/dist/packages/internal/media-resolution/dist/index.js +11 -0
- package/dist/packages/internal/media-resolution/dist/list.js +112 -0
- package/dist/packages/internal/media-resolution/dist/media.js +59 -0
- package/dist/packages/internal/media-resolution/dist/records.js +7 -0
- package/dist/packages/internal/media-resolution/dist/slot.js +34 -0
- package/dist/packages/internal/media-resolution/dist/store.js +19 -0
- package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
- package/dist/packages/internal/media-resolution/dist/video.js +93 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +244 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +35 -27
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -0
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
- package/dist/packages/internal/section-contracts/dist/index.js +7 -5
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +23 -19
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -7
- package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +5 -5
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +7 -4
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +83 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +77 -33
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +120 -66
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
- package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +43 -18
- package/dist/packages/internal/source-resolution/dist/index.js +113 -118
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
- package/dist/packages/internal/street-address/dist/index.js +72 -0
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
- package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
- package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
- package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +85 -0
- package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
- package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +12 -36
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
- package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +158 -0
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
- package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
- package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
- package/dist/packages/internal/template-contracts/dist/list-editing.js +94 -0
- package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
- package/dist/packages/internal/template-contracts/dist/list.js +258 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
- package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
- package/dist/packages/internal/template-contracts/dist/object.js +131 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
- package/dist/packages/internal/template-contracts/dist/read-graph.js +250 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +192 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +268 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
- package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
- package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
- package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +133 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +48 -8
- package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/row.js +84 -0
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +243 -384
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +334 -230
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.js +140 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
- package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
- package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
- package/dist/platform/fs.js +5 -2
- package/dist/playground/canvas-island-host.d.ts +11 -0
- package/dist/playground/canvas-island-host.js +29 -0
- package/dist/playground/canvas-markers.js +14 -0
- package/dist/playground-island-runtime.d.ts +3 -2
- package/dist/playground-island-runtime.js +3 -2
- package/dist/primitives/FrameShell.js +0 -1
- package/dist/primitives/Image.d.ts +5 -4
- package/dist/primitives/Tour.d.ts +1 -1
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/index.d.ts +2 -3
- package/dist/primitives/picture-sources.js +2 -2
- package/dist/primitives/probe-context.js +2 -12
- package/dist/primitives/slot-address.d.ts +44 -0
- package/dist/primitives/slot-address.js +19 -0
- package/dist/primitives/slot-bindings.d.ts +65 -26
- package/dist/primitives/slot-bindings.js +104 -46
- package/dist/primitives/slot-document.d.ts +23 -18
- package/dist/primitives/slot-document.js +39 -14
- package/dist/primitives/slot-download.d.ts +39 -0
- package/dist/primitives/slot-download.js +39 -0
- package/dist/primitives/slot-list.d.ts +3 -3
- package/dist/primitives/slot-list.js +0 -2
- package/dist/primitives/slot-media.d.ts +24 -5
- package/dist/primitives/slot-media.js +6 -9
- package/dist/primitives/slot-object.d.ts +49 -0
- package/dist/primitives/slot-object.js +20 -0
- package/dist/primitives/slot-scalar.d.ts +27 -2
- package/dist/primitives/slot-scalar.js +50 -7
- package/dist/primitives/slot.d.ts +13 -6
- package/dist/primitives/slot.js +10 -3
- package/dist/rules/registry.js +19 -30
- package/dist/schema/define-schema.d.ts +4 -8
- package/dist/schema/define-schema.js +178 -79
- package/dist/schema/extract-fill-spec.js +2 -158
- package/dist/schema/fact.d.ts +57 -15
- package/dist/schema/fact.js +42 -7
- package/dist/schema/facts-view.d.ts +14 -0
- package/dist/schema/format.d.ts +1 -0
- package/dist/schema/format.js +2 -1
- package/dist/schema/manifest.js +24 -0
- package/dist/schema/property-facts.d.ts +8 -11
- package/dist/schema/section-props.d.ts +2 -66
- package/dist/schema/section-schema.d.ts +8 -11
- package/dist/schema/section-schema.js +27 -10
- package/dist/section/declare.d.ts +18 -7
- package/dist/section/declare.js +18 -5
- package/dist/section/materialize.js +3 -8
- package/dist/section/section.d.ts +12 -8
- package/dist/section/section.js +1 -1
- package/dist/template/logic-shim.d.ts +14 -7
- package/dist/template/logic-shim.js +14 -7
- package/dist/template/materialize.js +17 -18
- package/dist/template/mirror-types.js +30 -31
- package/dist/template/section-reads.js +85 -9
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +29 -29
- package/package.json +9 -8
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
- package/dist/artifact/playground/client/assets/index-D8eepVr-.js +0 -1101
- package/dist/fixtures/canonical.d.ts +0 -166
- package/dist/fixtures/media.js +0 -163
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -111
- package/dist/packages/internal/format-geometry/dist/index.js +0 -4
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
- package/dist/packages/internal/property-facts/dist/index.js +0 -3
- package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +0 -22
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +0 -15
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
- package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -111
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
- package/dist/primitives/slot-group.d.ts +0 -40
- package/dist/primitives/slot-group.js +0 -36
- package/dist/schema/extract-used-facts.js +0 -34
- package/dist/schema/fill-builders.d.ts +0 -115
- package/dist/schema/fill-builders.js +0 -25
- package/dist/schema/fill-declaration.d.ts +0 -14
- package/dist/schema/fill-spec.js +0 -89
- package/dist/schema/layout.d.ts +0 -30
- package/dist/schema/layout.js +0 -14
- package/dist/schema/row-fields.js +0 -88
- package/dist/schema/row-ref.d.ts +0 -59
- package/dist/schema/row-ref.js +0 -28
- package/dist/schema/runtime-values.d.ts +0 -71
- package/dist/schema/section-nav.js +0 -14
- package/dist/schema/slot-builders.d.ts +0 -613
- package/dist/schema/slot-builders.js +0 -177
- package/dist/schema/slot-ref.d.ts +0 -79
- package/dist/schema/slot-ref.js +0 -41
- package/dist/schema/slot-types.d.ts +0 -111
- package/dist/schema/slot-types.js +0 -214
- package/dist/section/groups.js +0 -68
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { isFactRef, isSiblingPage, isSiblingSlot, isSiblingSource, serializeRef } from "../packages/internal/template-contracts/dist/slot-ref.js";
|
|
2
|
+
import { COMPUTED, isComputeBinding } from "../packages/internal/template-contracts/dist/compute.js";
|
|
3
|
+
import { isFillBinding } from "../packages/internal/template-contracts/dist/fill-builders.js";
|
|
4
|
+
import { FILL, FILL_SECTION, fillMark, getFills } from "../packages/internal/template-contracts/dist/fill-declaration.js";
|
|
5
|
+
import { mapSlotRefs, memberResolver, ownKeyRead, ownKeyRefusal, plainSlot, rowScope, unresolvedMember } from "../packages/internal/template-contracts/dist/resolve-scope.js";
|
|
6
|
+
import { declaredFields } from "../packages/internal/template-contracts/dist/object.js";
|
|
7
|
+
import { isReadableFactKey } from "../packages/internal/template-contracts/dist/fact-keys.js";
|
|
6
8
|
|
|
7
9
|
//#region src/schema/define-schema.ts
|
|
8
|
-
function derivedSource(transform, reads) {
|
|
10
|
+
function derivedSource(transform, reads, requires) {
|
|
9
11
|
if (reads === void 0 || reads.length === 0) return {
|
|
10
12
|
kind: "derived",
|
|
11
13
|
transform
|
|
@@ -13,45 +15,169 @@ function derivedSource(transform, reads) {
|
|
|
13
15
|
return {
|
|
14
16
|
kind: "derived",
|
|
15
17
|
transform,
|
|
16
|
-
reads: reads.map(serializeRef)
|
|
18
|
+
reads: reads.map(serializeRef),
|
|
19
|
+
...requires === void 0 || requires.length === 0 ? {} : { requires: requires.map(serializeRef) }
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
if (!
|
|
23
|
-
|
|
24
|
-
if (slot === void 0) throw new Error(`\`${at}\` reads the slot "${read.label}", which is not a slot of this section. Read another section's slot through its ref (\`Section.slots.<key>\`), and a sibling through the const the section's \`slots\` record holds.`);
|
|
25
|
-
if (sectionKey === void 0) throw new Error(`\`${at}\` reads its sibling slot "${slot}", which needs the section's key — declare it with \`section()\`.`);
|
|
26
|
-
return {
|
|
27
|
-
section: sectionKey,
|
|
28
|
-
slot
|
|
29
|
-
};
|
|
30
|
-
});
|
|
22
|
+
function assertRequires(at, requires) {
|
|
23
|
+
for (const required of requires ?? []) {
|
|
24
|
+
if (!isFactRef(required)) throw new Error(`\`${at}\` requires a read that is no fact — \`requires\` names the facts the value cannot do without (\`fact.property.address\`). A slot's own requirement is its holder's: mark that slot \`required\`.`);
|
|
25
|
+
if (!isReadableFactKey(required.key)) throw new Error(`\`${at}\` requires "${required.key}", which is not a fact the registry declares.`);
|
|
26
|
+
}
|
|
31
27
|
}
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
28
|
+
function computeSource(scope, at, binding) {
|
|
29
|
+
const resolve = (refs) => refs.map((read) => resolveRead(scope, at, read));
|
|
30
|
+
const requires = binding.requires === void 0 ? void 0 : resolve(binding.requires);
|
|
31
|
+
assertRequires(at, requires);
|
|
32
|
+
return derivedSource(at, resolve(binding.reads), requires);
|
|
33
|
+
}
|
|
34
|
+
function siblingKeys(slots) {
|
|
35
|
+
const keys = /* @__PURE__ */ new Map();
|
|
36
|
+
for (const [key, slot] of Object.entries(slots)) {
|
|
37
|
+
keys.set(slot, key);
|
|
38
|
+
if (slot.type !== "object") continue;
|
|
39
|
+
for (const fields of [slot.fields, declaredFields(slot) ?? {}]) for (const [field, def] of Object.entries(fields)) keys.set(def, `${key}.${field}`);
|
|
40
|
+
}
|
|
41
|
+
return keys;
|
|
42
|
+
}
|
|
43
|
+
function sectionRows(slots) {
|
|
44
|
+
const rows = rowScope(slots);
|
|
45
|
+
for (const [key, slot] of Object.entries(slots)) {
|
|
46
|
+
if (slot.type !== "object") continue;
|
|
47
|
+
for (const [row, field] of rowScope(declaredFields(slot) ?? {})) if (!rows.has(row)) rows.set(row, `${key}.${field}`);
|
|
48
|
+
}
|
|
49
|
+
return rows;
|
|
50
|
+
}
|
|
51
|
+
function siblingRef(scope, at, read) {
|
|
52
|
+
const slot = scope.keyOf.get(read);
|
|
53
|
+
if (slot === void 0) throw new Error(`\`${at}\` reads the slot "${String(read.label ?? read.type)}", which is neither a top-level slot of this section nor a field of one of its objects. Read another section's slot through its ref (\`Section.slots.<key>\`), a sibling or an object's field through the const the section declares it with, and a field of a list's item through the row or the element it reads.`);
|
|
54
|
+
if (scope.sectionKey === void 0) throw new Error(`\`${at}\` reads its sibling slot "${slot}", which needs the section's key — declare it with \`section()\`.`);
|
|
40
55
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
section: scope.sectionKey,
|
|
57
|
+
slot
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function resolveRead(scope, at, read) {
|
|
61
|
+
const member = scope.members(read);
|
|
62
|
+
if (member !== read) return member;
|
|
63
|
+
if (isSiblingPage(read)) throw new Error(`\`${at}\` reads a fact registry's page — a section reads a fact through \`fact.*\` (\`fact.property.address\`), never a registry's own declaration.`);
|
|
64
|
+
return isSiblingSlot(read) ? siblingRef(scope, at, read) : read;
|
|
65
|
+
}
|
|
66
|
+
function refuseRegistryKeys(path, slot) {
|
|
67
|
+
const def = slot;
|
|
68
|
+
if (def.type === "list" && isComputeBinding(def.max)) throw new Error(`\`${path}\` computes its \`max\` — no section runner reads a computed bound; declare a number, or bound the list where its items are produced.`);
|
|
69
|
+
if (def.element !== void 0) refuseRegistryKeys(path, def.element);
|
|
70
|
+
if (def.fields !== void 0) for (const [key, field] of Object.entries(def.fields)) refuseRegistryKeys(`${path}.${key}`, field);
|
|
71
|
+
}
|
|
72
|
+
function resolveFill(scope, at, binding) {
|
|
73
|
+
let out;
|
|
74
|
+
const reads = binding.reads;
|
|
75
|
+
if (reads !== void 0) {
|
|
76
|
+
const sourced = reads.find((read) => isSiblingSlot(read) && read.source !== void 0);
|
|
77
|
+
if (sourced !== void 0) {
|
|
78
|
+
const upstream = siblingRef(scope, at, sourced);
|
|
79
|
+
throw new Error(`\`${at}\` is filled and reads its sibling slot "${upstream.slot}", which is sourced — a fact, a \`compute()\` or another slot settles it, not a fill. A sourced value settles at finalize, AFTER every fill has run, so the fill would read nothing. Read the refs that slot reads instead, or read a slot a fill writes.`);
|
|
80
|
+
}
|
|
81
|
+
const resolved = reads.map((read) => resolveRead(scope, at, read));
|
|
82
|
+
if (resolved.some((read, i) => read !== reads[i])) {
|
|
83
|
+
const sameSection = reads.some(isSiblingSlot) ? scope.sectionKey : void 0;
|
|
84
|
+
out = {
|
|
85
|
+
...binding,
|
|
86
|
+
reads: resolved,
|
|
87
|
+
[FILL_SECTION]: sameSection
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
assertRequires(at, binding.requires);
|
|
92
|
+
return out ?? binding;
|
|
93
|
+
}
|
|
94
|
+
function resolveSlot(scope, path, slot) {
|
|
95
|
+
const ownKey = ownKeyRead(slot, scope.rows, path);
|
|
96
|
+
if (ownKey !== void 0) throw new Error(`\`${path}\` ${ownKeyRefusal(ownKey)}`);
|
|
97
|
+
let out = mapSlotRefs(slot, scope.members);
|
|
98
|
+
const source = out.source;
|
|
99
|
+
if (isComputeBinding(source)) {
|
|
100
|
+
scope.computed[path] = source.fn;
|
|
101
|
+
out = {
|
|
102
|
+
...out,
|
|
103
|
+
source: computeSource(scope, path, source)
|
|
104
|
+
};
|
|
105
|
+
} else if (isSiblingSource(source)) out = {
|
|
106
|
+
...out,
|
|
107
|
+
source: {
|
|
108
|
+
kind: "section",
|
|
109
|
+
...siblingRef(scope, path, source.of)
|
|
110
|
+
}
|
|
44
111
|
};
|
|
112
|
+
const fills = getFills(out);
|
|
113
|
+
if (fills !== void 0) {
|
|
114
|
+
const resolved = fills.map((binding) => resolveFill(scope, path, binding));
|
|
115
|
+
if (resolved.some((binding, i) => binding !== fills[i])) out = {
|
|
116
|
+
...out,
|
|
117
|
+
[FILL]: resolved
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
out = withVariant(out);
|
|
121
|
+
const member = unresolvedMember(out);
|
|
122
|
+
if (member !== void 0) throw new Error(`\`${path}\` reads the member "${member}" of a row that is not in scope — a member is read through a row declared beside its reader (a field of the same object or item), at the section's top level, or as a field of a top-level object.`);
|
|
123
|
+
return plainSlot(out);
|
|
45
124
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
125
|
+
function withVariant(slot) {
|
|
126
|
+
const when = slot.when;
|
|
127
|
+
if (when === void 0) return slot;
|
|
128
|
+
const rewritten = { ...slot };
|
|
129
|
+
delete rewritten.when;
|
|
130
|
+
rewritten.variant = { cases: typeof when === "string" ? [when] : [...when] };
|
|
131
|
+
return rewritten;
|
|
132
|
+
}
|
|
133
|
+
function resolveNestedItem(list) {
|
|
134
|
+
const element = list.element;
|
|
135
|
+
if (element?.type !== "object") return list;
|
|
136
|
+
const fields = {};
|
|
137
|
+
let changed = false;
|
|
138
|
+
for (const [field, def] of Object.entries(element.fields)) {
|
|
139
|
+
fields[field] = withVariant(def);
|
|
140
|
+
if (fields[field] !== def) changed = true;
|
|
141
|
+
}
|
|
142
|
+
const item = withVariant(changed ? {
|
|
143
|
+
...element,
|
|
144
|
+
fields
|
|
145
|
+
} : element);
|
|
146
|
+
return item === element ? list : {
|
|
147
|
+
...list,
|
|
148
|
+
element: item
|
|
52
149
|
};
|
|
53
150
|
}
|
|
54
|
-
function
|
|
151
|
+
function resolveFields(scope, container, object) {
|
|
152
|
+
const fields = {};
|
|
153
|
+
let changed = false;
|
|
154
|
+
for (const [field, def] of Object.entries(object.fields)) {
|
|
155
|
+
fields[field] = resolveNestedItem(resolveSlot(scope, `${container}.${field}`, def));
|
|
156
|
+
if (fields[field] !== def) changed = true;
|
|
157
|
+
}
|
|
158
|
+
return changed ? {
|
|
159
|
+
...object,
|
|
160
|
+
fields
|
|
161
|
+
} : object;
|
|
162
|
+
}
|
|
163
|
+
function resolveTopLevel(scope, key, slot) {
|
|
164
|
+
if (slot.type === "object") {
|
|
165
|
+
let out = resolveFields(scope, key, slot);
|
|
166
|
+
if (out.when !== void 0) out = resolveSlot(scope, key, out);
|
|
167
|
+
return out;
|
|
168
|
+
}
|
|
169
|
+
let out = resolveSlot(scope, key, slot);
|
|
170
|
+
if (out.type === "list" && out.element !== void 0) {
|
|
171
|
+
const element = out.element;
|
|
172
|
+
const resolved = element.type === "object" ? resolveFields(scope, key, element) : resolveSlot(scope, key, element);
|
|
173
|
+
if (resolved !== element) out = {
|
|
174
|
+
...out,
|
|
175
|
+
element: resolved
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
function emitDisplay(display, scope) {
|
|
55
181
|
const out = {};
|
|
56
182
|
for (const key of ["visibility", "variant"]) {
|
|
57
183
|
const entry = display[key];
|
|
@@ -60,11 +186,11 @@ function emitDisplay(display, computed, resolveReads) {
|
|
|
60
186
|
const emitted = { cases: [...entry.cases] };
|
|
61
187
|
if (entry.locked === true) emitted.locked = true;
|
|
62
188
|
if (isComputeBinding(entry.source)) {
|
|
63
|
-
computed[at] = entry.source.fn;
|
|
64
|
-
emitted.source =
|
|
189
|
+
scope.computed[at] = entry.source.fn;
|
|
190
|
+
emitted.source = computeSource(scope, at, entry.source);
|
|
65
191
|
} else if (isFillBinding(entry.source)) emitted.fill = {
|
|
66
192
|
pick: entry.source.brief,
|
|
67
|
-
...fillMark(
|
|
193
|
+
...fillMark(resolveFill(scope, at, entry.source))
|
|
68
194
|
};
|
|
69
195
|
else if (entry.source !== void 0) emitted.source = entry.source;
|
|
70
196
|
out[key] = emitted;
|
|
@@ -73,51 +199,24 @@ function emitDisplay(display, computed, resolveReads) {
|
|
|
73
199
|
}
|
|
74
200
|
function defineSchema(input) {
|
|
75
201
|
const computed = {};
|
|
76
|
-
const
|
|
202
|
+
const rows = sectionRows(input.slots);
|
|
203
|
+
const scope = {
|
|
204
|
+
sectionKey: input.key,
|
|
205
|
+
keyOf: siblingKeys(input.slots),
|
|
206
|
+
rows,
|
|
207
|
+
members: memberResolver(rows),
|
|
208
|
+
computed
|
|
209
|
+
};
|
|
77
210
|
const meta = {
|
|
78
211
|
displayName: input.label,
|
|
79
212
|
...input.anchor !== void 0 ? { anchor: input.anchor } : {},
|
|
80
|
-
...input.display !== void 0 ? { display: emitDisplay(input.display,
|
|
81
|
-
...input.layout !== void 0 ? { groups: groupsFromLayout(input.layout) } : {}
|
|
213
|
+
...input.display !== void 0 ? { display: emitDisplay(input.display, scope) } : {}
|
|
82
214
|
};
|
|
83
215
|
const slots = {};
|
|
84
216
|
for (const [key, slot] of Object.entries(input.slots)) {
|
|
85
|
-
if (slot.type !== "
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (emitted.type === "list" && fields !== void 0) {
|
|
89
|
-
const resolvedFields = Object.fromEntries(Object.entries(fields).map(([field, def]) => {
|
|
90
|
-
const at = `${key}.${field}`;
|
|
91
|
-
let resolved = resolveFillReads(at, def, resolveReads);
|
|
92
|
-
if (isComputeBinding(def.source)) {
|
|
93
|
-
computed[at] = def.source.fn;
|
|
94
|
-
resolved = {
|
|
95
|
-
...resolved,
|
|
96
|
-
source: derivedSource(at, resolveReads(at, def.source.reads))
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
return [field, resolved];
|
|
100
|
-
}));
|
|
101
|
-
if (Object.keys(fields).some((field) => resolvedFields[field] !== fields[field])) emitted = {
|
|
102
|
-
...emitted,
|
|
103
|
-
fields: resolvedFields
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
if (isComputeBinding(slot.source)) {
|
|
107
|
-
computed[key] = slot.source.fn;
|
|
108
|
-
emitted = {
|
|
109
|
-
...emitted,
|
|
110
|
-
source: derivedSource(key, resolveReads(key, slot.source.reads))
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
const when = slot.when;
|
|
114
|
-
if (when !== void 0) {
|
|
115
|
-
const rewritten = { ...emitted };
|
|
116
|
-
delete rewritten.when;
|
|
117
|
-
rewritten.variant = { cases: typeof when === "string" ? [when] : [...when] };
|
|
118
|
-
emitted = rewritten;
|
|
119
|
-
}
|
|
120
|
-
slots[key] = emitted;
|
|
217
|
+
if (slot.type !== "object" && slot.label === void 0) throw new Error(`slot "${key}" declares no \`label\` — every slot of a section states the name the editor shows it by.`);
|
|
218
|
+
refuseRegistryKeys(key, slot);
|
|
219
|
+
slots[key] = resolveTopLevel(scope, key, slot);
|
|
121
220
|
}
|
|
122
221
|
const result = {
|
|
123
222
|
meta,
|
|
@@ -1,164 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getFill, getFillSection } from "./fill-declaration.js";
|
|
3
|
-
import { isSerializedSlotRef, isSiblingSlot, serializeRef } from "./slot-ref.js";
|
|
4
|
-
import { byCodeUnit } from "../platform/order.js";
|
|
5
|
-
import { plannerForField } from "../packages/internal/fill-vocabulary/dist/row-planners.js";
|
|
6
|
-
import { isListSlot, originationFor } from "../packages/internal/fill-vocabulary/dist/origination.js";
|
|
1
|
+
import { fillSpecFromSchema as fillSpecFromSchema$1 } from "../packages/internal/template-contracts/dist/fill-spec.js";
|
|
7
2
|
|
|
8
3
|
//#region src/schema/extract-fill-spec.ts
|
|
9
|
-
function kindOf(origination) {
|
|
10
|
-
switch (origination.kind) {
|
|
11
|
-
case "write": return "text";
|
|
12
|
-
case "pick-one": return "pick";
|
|
13
|
-
default: return "list";
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function optionsOf(binding) {
|
|
17
|
-
const out = { brief: binding.brief };
|
|
18
|
-
if (binding.none !== void 0) out.none = binding.none;
|
|
19
|
-
if (binding.count !== void 0) out.count = typeof binding.count === "number" ? binding.count : { ...binding.count };
|
|
20
|
-
if (binding.cap !== void 0) out.cap = binding.cap;
|
|
21
|
-
const reads = serializedReads(binding.reads);
|
|
22
|
-
if (reads.length > 0) out.reads = reads;
|
|
23
|
-
return out;
|
|
24
|
-
}
|
|
25
|
-
function serializedReads(reads) {
|
|
26
|
-
return (reads ?? []).map((read) => {
|
|
27
|
-
if (isSiblingSlot(read)) throw new Error(`fillSpecFromSchema: a fill reads the slot "${read.label}" by its const, which only a section declared with \`section()\` resolves — read another section's slot through its ref (\`Section.slots.<key>\`).`);
|
|
28
|
-
return serializeRef(read);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function collectReads(into, binding) {
|
|
32
|
-
const ownSection = getFillSection(binding);
|
|
33
|
-
for (const read of serializedReads(binding?.reads)) if (read.kind === "fact") into.facts.add(read.key);
|
|
34
|
-
else if (isSerializedSlotRef(read) && read.section !== ownSection) into.slots.set(`${read.section} ${read.slot}`, read);
|
|
35
|
-
}
|
|
36
|
-
function editorPickedOrigin(slot) {
|
|
37
|
-
return slot.type === "poi";
|
|
38
|
-
}
|
|
39
|
-
function assertOrigin(key, slot) {
|
|
40
|
-
if (slot.source !== void 0 || getFill(slot) !== void 0) return;
|
|
41
|
-
if (editorPickedOrigin(slot)) return;
|
|
42
|
-
throw new Error(`fillSpecFromSchema: slot "${key}" declares no \`source:\` — nothing would ever write it. Bind it to a fact or a slot, \`compute()\` it, or \`fill()\` it.`);
|
|
43
|
-
}
|
|
44
|
-
function assertRowOrigins(key, slot) {
|
|
45
|
-
for (const [fieldKey, field] of Object.entries(slot.fields ?? {})) {
|
|
46
|
-
if (field.source !== void 0 || getFill(field) !== void 0) continue;
|
|
47
|
-
throw new Error(`fillSpecFromSchema: row field "${key}.${fieldKey}" declares no \`source:\` — nothing would ever write it. Bind it to a member of the row (\`row.<member>\`), \`compute()\` it, or \`fill()\` it.`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function unkeyedMessage(key, origination) {
|
|
51
|
-
if (origination.pools.length > 1) return `fillSpecFromSchema: record slot "${key}" pools rows from ${origination.pools.map((p) => `"${p}"`).join(" and ")} — a filled record list picks its rows out of ONE asset field, so bind the others with \`source:\` or drop them.`;
|
|
52
|
-
if (origination.title !== void 0) return `fillSpecFromSchema: record slot "${key}" is titled by "${origination.title}"` + (origination.titleType === void 0 ? ", which is not a field of the row" : `, a ${origination.titleType} field`) + " — a filled record list is keyed on its `title:` field, which must be a `text` field the model writes or a `select({ options })` it picks from.";
|
|
53
|
-
return `fillSpecFromSchema: record slot "${key}" has no field to key its rows on — title the list by the \`text\` field that names a row, give the row exactly one \`select({ options })\` field, or give it one unbound \`image\`/\`video\`/\`tour\`/\`document\` field to pick rows from.`;
|
|
54
|
-
}
|
|
55
|
-
function rowFieldDecision(key, fieldKey, field, binding) {
|
|
56
|
-
if (plannerForField(field) === void 0) throw new Error(`fillSpecFromSchema: row field "${key}.${fieldKey}" (type "${String(field.type)}") is filled, but a row cannot fill one — a row field is written or picked inside the list's one batched call, which plans text, a select key, an asset, or a list of text, keys or assets.`);
|
|
57
|
-
return optionsOf(binding);
|
|
58
|
-
}
|
|
59
|
-
function recordListDecision(key, slot, reads) {
|
|
60
|
-
assertRowOrigins(key, slot);
|
|
61
|
-
const fields = {};
|
|
62
|
-
for (const [fieldKey, rowField] of Object.entries(slot.fields ?? {})) {
|
|
63
|
-
const binding = getFill(rowField);
|
|
64
|
-
if (binding === void 0) continue;
|
|
65
|
-
collectReads(reads, binding);
|
|
66
|
-
fields[fieldKey] = rowFieldDecision(key, fieldKey, rowField, binding);
|
|
67
|
-
}
|
|
68
|
-
const binding = getFill(slot);
|
|
69
|
-
collectReads(reads, binding);
|
|
70
|
-
if (binding === void 0 && Object.keys(fields).length === 0) {
|
|
71
|
-
assertOrigin(key, slot);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const origination = originationFor(slot, Object.keys(fields));
|
|
75
|
-
if (binding === void 0) {
|
|
76
|
-
if (origination?.kind === "bound-rows") return {
|
|
77
|
-
id: key,
|
|
78
|
-
kind: "list",
|
|
79
|
-
produces: [key],
|
|
80
|
-
fields
|
|
81
|
-
};
|
|
82
|
-
throw new Error(`fillSpecFromSchema: record slot "${key}" fills row fields but its rows have no origin — bind the list to a facts array with \`source:\`, or \`fill()\` the list so the model originates its rows.`);
|
|
83
|
-
}
|
|
84
|
-
if (origination?.kind === "unkeyed-rows") throw new Error(unkeyedMessage(key, origination));
|
|
85
|
-
if (origination === void 0) throw new Error(`fillSpecFromSchema: record slot "${key}" originates no rows.`);
|
|
86
|
-
return {
|
|
87
|
-
id: key,
|
|
88
|
-
kind: "list",
|
|
89
|
-
produces: [key],
|
|
90
|
-
...optionsOf(binding),
|
|
91
|
-
fields
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function assertNotRowOnly(key, slot) {
|
|
95
|
-
if (slot.type !== "select") return;
|
|
96
|
-
throw new Error(`fillSpecFromSchema: select slot "${key}" is filled, which only a record row's select field may be — a top-level select is bound with \`source:\`; fill the row field instead.`);
|
|
97
|
-
}
|
|
98
|
-
function slotDecision(key, slot, binding) {
|
|
99
|
-
if (!isListSlot(slot)) assertNotRowOnly(key, slot);
|
|
100
|
-
const origination = originationFor(slot);
|
|
101
|
-
if (origination === void 0) throw new Error(`fillSpecFromSchema: slot "${key}" (type "${String(slot.type)}") is filled, but no fill produces that type.`);
|
|
102
|
-
return {
|
|
103
|
-
id: key,
|
|
104
|
-
kind: kindOf(origination),
|
|
105
|
-
produces: [key],
|
|
106
|
-
...optionsOf(binding)
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
const DISPLAY_DECISION_ID = "display";
|
|
110
|
-
function displayDecision(schema, reads) {
|
|
111
|
-
const display = schema.meta.display;
|
|
112
|
-
if (display === void 0) return void 0;
|
|
113
|
-
const entries = DISPLAY_ENTRIES.filter((entry) => display[entry]?.fill !== void 0);
|
|
114
|
-
if (entries.length === 0) return void 0;
|
|
115
|
-
const declared = /* @__PURE__ */ new Map();
|
|
116
|
-
for (const entry of entries) {
|
|
117
|
-
const binding = getFill(display[entry]?.fill);
|
|
118
|
-
collectReads(reads, binding);
|
|
119
|
-
for (const read of serializedReads(binding?.reads)) if (read.kind === "fact") declared.set(`fact ${read.key}`, read);
|
|
120
|
-
else if (isSerializedSlotRef(read)) declared.set(`slot ${read.section} ${read.slot}`, read);
|
|
121
|
-
}
|
|
122
|
-
if (DISPLAY_DECISION_ID in schema.slots) throw new Error(`fillSpecFromSchema: slot "${DISPLAY_DECISION_ID}" collides with the decision id reserved for \`meta.display\`'s own fill — rename the slot.`);
|
|
123
|
-
return {
|
|
124
|
-
id: DISPLAY_DECISION_ID,
|
|
125
|
-
kind: "display",
|
|
126
|
-
entries,
|
|
127
|
-
produces: [],
|
|
128
|
-
...declared.size === 0 ? {} : { reads: [...declared.values()] }
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
function sortedRefs(slots) {
|
|
132
|
-
return [...slots.values()].sort((a, b) => byCodeUnit(a.section, b.section) || byCodeUnit(a.slot, b.slot));
|
|
133
|
-
}
|
|
134
4
|
function fillSpecFromSchema(schema) {
|
|
135
|
-
|
|
136
|
-
const reads = {
|
|
137
|
-
facts: /* @__PURE__ */ new Set(),
|
|
138
|
-
slots: /* @__PURE__ */ new Map()
|
|
139
|
-
};
|
|
140
|
-
for (const [key, slot] of Object.entries(schema.slots)) {
|
|
141
|
-
const shape = slot;
|
|
142
|
-
if (shape.type === "list" && shape.fields !== void 0) {
|
|
143
|
-
const decision = recordListDecision(key, shape, reads);
|
|
144
|
-
if (decision !== void 0) decisions.push(decision);
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
const binding = getFill(slot);
|
|
148
|
-
if (binding === void 0) {
|
|
149
|
-
assertOrigin(key, shape);
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
collectReads(reads, binding);
|
|
153
|
-
decisions.push(slotDecision(key, shape, binding));
|
|
154
|
-
}
|
|
155
|
-
const display = displayDecision(schema, reads);
|
|
156
|
-
if (display !== void 0) decisions.push(display);
|
|
157
|
-
return {
|
|
158
|
-
reads: [...reads.facts].sort(),
|
|
159
|
-
slot_reads: sortedRefs(reads.slots),
|
|
160
|
-
decisions
|
|
161
|
-
};
|
|
5
|
+
return fillSpecFromSchema$1(schema);
|
|
162
6
|
}
|
|
163
7
|
|
|
164
8
|
//#endregion
|
package/dist/schema/fact.d.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AddressMember, AddressValue } from "../packages/internal/template-contracts/dist/address-value.js";
|
|
2
|
+
import { FACT_GRAPH, FactGraphName, REGISTRY_TABLE_KEYS, RegistryTable, SOURCE_FIELDS, SourceFieldContainer, SourceFieldName } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
3
|
+
import { MediaListKey, RegistryFactKey, RegistryFactValue } from "../packages/internal/template-contracts/dist/fact-keys.js";
|
|
4
|
+
import { RegistryTableRow } from "../packages/internal/template-contracts/dist/table-members.js";
|
|
5
|
+
import { FactRef } from "../packages/internal/template-contracts/dist/slot-ref.js";
|
|
6
|
+
import { PropertyFactRegistry } from "../packages/internal/template-contracts/dist/fact-registry.js";
|
|
7
|
+
import { DocumentMediaValue } from "../packages/internal/template-contracts/dist/registry-facts.js";
|
|
3
8
|
import { FactValue } from "../packages/internal/template-contracts/dist/facts-view.js";
|
|
9
|
+
import "./facts-view.js";
|
|
4
10
|
//#region src/schema/fact.d.ts
|
|
5
11
|
type SourceFields = typeof SOURCE_FIELDS;
|
|
6
12
|
type Graph = typeof FACT_GRAPH;
|
|
7
13
|
/**
|
|
8
|
-
* A slot's
|
|
9
|
-
*
|
|
10
|
-
* members, so one value serves `source:` and a declaration's `reads` alike.
|
|
14
|
+
* A slot's fact binding by a legacy field name: a `home` ref to the canonical field — a typed {@link FactRef}, so one
|
|
15
|
+
* value serves `source:` and a declaration's `reads` alike.
|
|
11
16
|
*/
|
|
12
17
|
type DirectFactRef<F extends SourceFieldName> = FactRef<F, FactValue<F & FactGraphName>>;
|
|
13
18
|
/**
|
|
14
19
|
* A slot's `derived` binding: a value the section's own `compute()` fn
|
|
15
20
|
* produces, keyed by the slot's own name. No `fact.*` entry emits one — the
|
|
16
|
-
* fact namespace
|
|
21
|
+
* fact namespace hands out only home refs — so `defineSchema`'s `compute()` rewrite is
|
|
17
22
|
* the sole producer of this shape.
|
|
18
23
|
*/
|
|
19
24
|
type DerivedFactRef = {
|
|
@@ -38,26 +43,63 @@ type ReadableName = { [K in FactGraphName]: Graph[K] extends {
|
|
|
38
43
|
primary_of: string;
|
|
39
44
|
} ? never : K : never; }[FactGraphName];
|
|
40
45
|
type Readables = { [K in ReadableName]: FactRef<K, FactValue<K>>; };
|
|
46
|
+
/** A ref to a fact the registry declares, by its registry key (`property.address.city`). */
|
|
47
|
+
type RegistryFactRef<K extends RegistryFactKey> = FactRef<K, RegistryFactValue<K>>;
|
|
48
|
+
type PropertyPages = PropertyFactRegistry["pages"];
|
|
49
|
+
type PartRefs<Path extends string> = { readonly [M in keyof AddressValue as M extends AddressMember ? M : never]: RegistryFactRef<`${Path}.${M & string}` & RegistryFactKey>; };
|
|
50
|
+
type RegistryRefs = { readonly [K in keyof PropertyPages as PropertyPages[K]["declaration"] extends {
|
|
51
|
+
readonly type: "list";
|
|
52
|
+
} ? never : K]: RegistryFactRef<`property.${K & string}` & RegistryFactKey> & (PropertyPages[K]["declaration"] extends {
|
|
53
|
+
readonly type: "address";
|
|
54
|
+
} ? PartRefs<`property.${K & string}`> : unknown); };
|
|
55
|
+
type ColumnRefs<T extends RegistryTable> = { readonly [M in keyof RegistryTableRow<T> as M extends "id" ? never : M & string]: FactRef<`${(typeof REGISTRY_TABLE_KEYS)[T]}.${M & string}`, readonly (RegistryTableRow<T>[M] | null)[]>; };
|
|
56
|
+
type RegistryTableRefs = { readonly [T in RegistryTable]: FactRef<(typeof REGISTRY_TABLE_KEYS)[T], readonly RegistryTableRow<T>[]> & ColumnRefs<T>; };
|
|
57
|
+
type MediaListRefs = { readonly [K in keyof PropertyPages as `property.${K & string}` extends MediaListKey ? K : never]: FactRef<`property.${K & string}`, readonly DocumentMediaValue[]>; };
|
|
58
|
+
type PropertyBranch = Omit<FieldsIn<"property"> & ProjectionsIn<"property">, keyof RegistryRefs | RegistryTable | keyof MediaListRefs> & RegistryRefs & RegistryTableRefs & MediaListRefs;
|
|
41
59
|
/**
|
|
42
60
|
* The shape of `fact`: one branch per source-field container (`property`,
|
|
43
61
|
* `unit`, `contact`), each holding an entry for every canonical field in that
|
|
44
62
|
* container plus one per declared alias, and beside them one entry per
|
|
45
|
-
* readable-only fact.
|
|
46
|
-
*
|
|
63
|
+
* readable-only fact. The `property` branch spells the facts the fact registry
|
|
64
|
+
* declares as it nests them (`fact.property.address.city`), and each table by its
|
|
65
|
+
* registry key (`fact.property.units`). Every entry is a value you pass to a slot
|
|
66
|
+
* builder's `source` or to a declaration's `reads`, not a call you make.
|
|
47
67
|
*/
|
|
48
|
-
type FactNamespace = {
|
|
68
|
+
type FactNamespace = {
|
|
69
|
+
property: PropertyBranch;
|
|
70
|
+
} & { [C in Exclude<SourceFieldContainer, "property">]: FieldsIn<C> & ProjectionsIn<C>; } & Readables;
|
|
49
71
|
/**
|
|
50
72
|
* Where a slot's value comes from, and what a declaration reads: a bindable fact
|
|
51
73
|
* as `fact.<container>.<field>`, a readable-only one as `fact.<key>`.
|
|
52
74
|
*
|
|
53
75
|
* The container is the resolution rule: `fact.property.*` reads the property
|
|
54
|
-
* root, `fact.unit.*` the primary unit
|
|
55
|
-
*
|
|
76
|
+
* root, `fact.unit.*` the primary unit, `fact.contact.*` the primary contact
|
|
77
|
+
* card — a table's other rows are read through a `row()`. Hover
|
|
56
78
|
* any entry for its writability — a writable field draws the editor's
|
|
57
|
-
* "Update everywhere" toggle, a read-only one does not.
|
|
58
|
-
*
|
|
59
|
-
*
|
|
79
|
+
* "Update everywhere" toggle, a read-only one does not.
|
|
80
|
+
*
|
|
81
|
+
* The property's media is three lists, each named in a `compute`'s or a fill's `reads`
|
|
82
|
+
* and read as its assets' records (`Media`): `fact.property.uploads`, every upload;
|
|
83
|
+
* `fact.property.property_media`, what shows the property — its photos, videos and tours; and
|
|
84
|
+
* `fact.property.floor_plans`, its plans. A media slot is never sourced by one: it
|
|
85
|
+
* picks `from` one (`image({ from: fact.property.property_media, source: fill.pick({ brief }) })`).
|
|
86
|
+
* The property's cover photo, `fact.property.hero`, is one image picked from its media:
|
|
87
|
+
* an `image` slot binds it (`image({ source: fact.property.hero })`), and a `compute()`
|
|
88
|
+
* reads it as its asset's record (`Media`), `null` when the property has none.
|
|
89
|
+
*
|
|
90
|
+
* A table (`fact.property.units`, `.commercial_spaces`, `.contacts`, `.comparables`) is a list's `source:` and
|
|
91
|
+
* a row's `from`. One row's members are read through a row slot —
|
|
92
|
+
* `const agent = row({ label: "Agent", from: fact.property.contacts })`, then
|
|
93
|
+
* `agent.phone` — never off the table itself. A row offers what the facts document holds:
|
|
94
|
+
* a unit's `label`, `null` for an unanswered member, a comparable's `address` as an
|
|
95
|
+
* address whose parts read as `comp.address.city`. In a `compute()`'s `reads` a table is
|
|
96
|
+
* its rows, each its `id` beside those members.
|
|
97
|
+
*
|
|
98
|
+
* A table's column — `fact.property.units.beds` — is one member over every row, in row
|
|
99
|
+
* order, `null` where a row leaves it unanswered: read it where a declaration needs that
|
|
100
|
+
* member and not the whole row, since a whole-table read counts every member as used.
|
|
101
|
+
* `fact.unit.beds` stays the primary row's member.
|
|
60
102
|
*/
|
|
61
103
|
declare const fact: FactNamespace;
|
|
62
104
|
//#endregion
|
|
63
|
-
export { DerivedFactRef, DirectFactRef, FactNamespace, fact };
|
|
105
|
+
export { DerivedFactRef, DirectFactRef, FactNamespace, RegistryFactRef, fact };
|
package/dist/schema/fact.js
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
import { FACT_GRAPH, FACT_PROJECTIONS, SOURCE_FIELDS } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
1
|
+
import { FACT_GRAPH, FACT_PROJECTIONS, REGISTRY_TABLE_KEYS, SOURCE_FIELDS } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { mediaListKeys, registryFactKeys } from "../packages/internal/template-contracts/dist/fact-keys.js";
|
|
3
|
+
import { registryMemberNames } from "../packages/internal/template-contracts/dist/table-members.js";
|
|
2
4
|
|
|
3
5
|
//#region src/schema/fact.ts
|
|
4
6
|
const PROJECTIONS = FACT_PROJECTIONS;
|
|
7
|
+
function withMembers(base, path, members) {
|
|
8
|
+
const refs = new Map(members.map((member) => [member, {
|
|
9
|
+
kind: "home",
|
|
10
|
+
key: `${path}.${member}`
|
|
11
|
+
}]));
|
|
12
|
+
return new Proxy(base, { get(target, key, receiver) {
|
|
13
|
+
if (typeof key === "string" && !(key in target)) {
|
|
14
|
+
const ref = refs.get(key);
|
|
15
|
+
if (ref !== void 0) return ref;
|
|
16
|
+
}
|
|
17
|
+
return Reflect.get(target, key, receiver);
|
|
18
|
+
} });
|
|
19
|
+
}
|
|
5
20
|
function buildNamespace() {
|
|
6
21
|
const containers = {
|
|
7
22
|
property: {},
|
|
@@ -9,17 +24,37 @@ function buildNamespace() {
|
|
|
9
24
|
contact: {}
|
|
10
25
|
};
|
|
11
26
|
for (const [field, descriptor] of Object.entries(SOURCE_FIELDS)) containers[descriptor.container][field] = {
|
|
12
|
-
kind: "
|
|
13
|
-
field
|
|
27
|
+
kind: "home",
|
|
28
|
+
key: field
|
|
14
29
|
};
|
|
15
30
|
for (const [container, entries] of Object.entries(PROJECTIONS)) for (const [name, field] of Object.entries(entries)) containers[container][name] = {
|
|
16
|
-
kind: "
|
|
17
|
-
field
|
|
31
|
+
kind: "home",
|
|
32
|
+
key: field
|
|
33
|
+
};
|
|
34
|
+
const property = containers.property;
|
|
35
|
+
for (const [table, key] of Object.entries(REGISTRY_TABLE_KEYS)) property[table] = withMembers({
|
|
36
|
+
kind: "home",
|
|
37
|
+
key
|
|
38
|
+
}, key, registryMemberNames(table));
|
|
39
|
+
for (const key of mediaListKeys()) property[key.slice(9)] = {
|
|
40
|
+
kind: "home",
|
|
41
|
+
key
|
|
18
42
|
};
|
|
43
|
+
const keys = registryFactKeys();
|
|
44
|
+
for (const key of keys) {
|
|
45
|
+
const name = key.slice(9);
|
|
46
|
+
if (name.includes(".")) continue;
|
|
47
|
+
const parts = keys.filter((other) => other.startsWith(`${key}.`)).map((part) => part.slice(key.length + 1));
|
|
48
|
+
const ref = {
|
|
49
|
+
kind: "home",
|
|
50
|
+
key
|
|
51
|
+
};
|
|
52
|
+
property[name] = parts.length > 0 ? withMembers(ref, key, parts) : ref;
|
|
53
|
+
}
|
|
19
54
|
const namespace = { ...containers };
|
|
20
55
|
for (const [key, entry] of Object.entries(FACT_GRAPH)) if (entry.role === "readable" && entry.primary_of === void 0) namespace[key] = {
|
|
21
|
-
kind: "
|
|
22
|
-
|
|
56
|
+
kind: "home",
|
|
57
|
+
key
|
|
23
58
|
};
|
|
24
59
|
return namespace;
|
|
25
60
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RegistryTableRow } from "../packages/internal/template-contracts/dist/table-members.js";
|
|
2
|
+
import { AsRead } from "../packages/internal/template-contracts/dist/slot-ref.js";
|
|
3
|
+
import { FactValue, FactsAddress, FactsRow } from "../packages/internal/template-contracts/dist/facts-view.js";
|
|
4
|
+
//#region src/schema/facts-view.d.ts
|
|
5
|
+
/** One unit of `fact.property.units`, as a `compute()` reading the table receives it. */
|
|
6
|
+
type FactsUnit = AsRead<RegistryTableRow<"units">>;
|
|
7
|
+
/** One contact of `fact.property.contacts`, as a `compute()` reading the table receives it. */
|
|
8
|
+
type FactsContact = AsRead<RegistryTableRow<"contacts">>;
|
|
9
|
+
/** One commercial space of `fact.property.commercial_spaces`, as a `compute()` reading the table receives it. */
|
|
10
|
+
type FactsCommercialSpace = AsRead<RegistryTableRow<"commercial_spaces">>;
|
|
11
|
+
/** One comparable of `fact.property.comparables`, as a `compute()` reading the table receives it. */
|
|
12
|
+
type FactsComparable = AsRead<RegistryTableRow<"comparables">>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { type FactValue, type FactsAddress, FactsCommercialSpace, FactsComparable, FactsContact, FactsUnit };
|