@homepages/concrete 8.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1005 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +64 -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-BOYbgBnP.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/check/stages/workspace.js +2 -0
- package/dist/cli/check/template-key.js +16 -0
- 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 +260 -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 +250 -46
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +361 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +25 -18
- package/dist/packages/internal/fill-bake/dist/index.js +9 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +113 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +38 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +174 -0
- package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +363 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +60 -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 +226 -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 +37 -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 +245 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +34 -14
- 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 +21 -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 -5
- 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 -2
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +2 -36
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -21
- 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 +9 -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 +6 -17
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +80 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +77 -18
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +89 -95
- 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 +39 -23
- package/dist/packages/internal/source-resolution/dist/index.js +113 -73
- 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 +81 -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 +10 -24
- 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 +93 -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 +93 -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 +240 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +176 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +270 -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 +127 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +41 -5
- 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 +233 -405
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +331 -227
- 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 +139 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +95 -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 +25 -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 -153
- 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 -12
- 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 -25
- package/package.json +9 -8
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
- package/dist/artifact/playground/client/assets/index-Dn_xT16-.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 -51
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
- 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/group-contract.js +0 -19
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
- package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -104
- 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 -98
- 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 -633
- 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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region ../../internal/template-contracts/dist/slot-overrides.js
|
|
2
|
+
function isSlotOverridden(overrides, slotId) {
|
|
3
|
+
return overrides?.scalar?.[slotId] === true;
|
|
4
|
+
}
|
|
5
|
+
function objectFieldSlotId(objectId, field) {
|
|
6
|
+
return `${objectId}.${field}`;
|
|
7
|
+
}
|
|
8
|
+
function objectFieldOf(slotId) {
|
|
9
|
+
const dot = slotId.indexOf(".");
|
|
10
|
+
if (dot <= 0 || dot === slotId.length - 1 || slotId.includes(".", dot + 1)) return null;
|
|
11
|
+
return {
|
|
12
|
+
object: slotId.slice(0, dot),
|
|
13
|
+
field: slotId.slice(dot + 1)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function itemOverridesForSlot(overrides, slotId) {
|
|
17
|
+
return { ...overrides?.items?.[slotId] ?? {} };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { isSlotOverridden, itemOverridesForSlot, objectFieldOf, objectFieldSlotId };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { DocumentValue } from "./document-value.js";
|
|
2
|
+
import { TourValue } from "./tour-value.js";
|
|
3
|
+
import { VideoValue } from "./video-value.js";
|
|
4
|
+
import { ImageValue } from "./runtime-values.js";
|
|
5
|
+
import { SlotValue } from "./slot-value.js";
|
|
6
|
+
import { Slot } from "./slot-types.js";
|
|
7
|
+
import { DocumentMedia, DocumentMediaValue, ImageMedia, Media, TourMedia, VideoMedia } from "./registry-facts.js";
|
|
8
|
+
//#region ../../internal/template-contracts/dist/slot-ref.d.ts
|
|
9
|
+
/** The reserved `slot` prefix a display entry's ref is addressed by. */
|
|
10
|
+
declare const DISPLAY_REF_PREFIX = "display.";
|
|
11
|
+
/** The two `meta.display` entries a section may declare, and so may be read. */
|
|
12
|
+
type DisplayEntryName = "visibility" | "variant";
|
|
13
|
+
/**
|
|
14
|
+
* A slot of a section, or one of its two display entries, by name — what a
|
|
15
|
+
* declaration `reads`. Both string halves are literal on a section value
|
|
16
|
+
* (`Hero.slots.hero_image` is `SlotRef<"hero", "hero_image", ImageValue | null>`),
|
|
17
|
+
* which is what types the positional value a compute callback receives.
|
|
18
|
+
*/
|
|
19
|
+
interface SlotRef<Section extends string = string, SlotId extends string = string, Value = unknown> {
|
|
20
|
+
readonly section: Section;
|
|
21
|
+
readonly slot: SlotId;
|
|
22
|
+
/**
|
|
23
|
+
* Phantom: the referent's own value type. Never present at runtime —
|
|
24
|
+
* `declareSection` builds `{ section, slot }` — and never serialized.
|
|
25
|
+
*/
|
|
26
|
+
readonly __value?: Value;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* One fact of a home, by its registry key — what every `fact.*` entry IS, and its wire
|
|
30
|
+
* form byte for byte (see the module header). `Key` is the registry key and `Value` the
|
|
31
|
+
* phantom type the entry reads at.
|
|
32
|
+
*/
|
|
33
|
+
interface FactRef<Key extends string = string, Value = unknown> {
|
|
34
|
+
readonly kind: "home";
|
|
35
|
+
readonly key: Key;
|
|
36
|
+
/** Phantom: the value a `compute()` callback receives for this ref. Never present at runtime. */
|
|
37
|
+
readonly __value?: Value;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One member of the row a row slot holds — what `agent.phone` IS, read off the value
|
|
41
|
+
* `row()` returned. Inside a section it carries the row slot itself, invisibly;
|
|
42
|
+
* `defineSchema` resolves that to the row's key, and the wire form is
|
|
43
|
+
* `{kind:"row", slot, field}` — a slot's `source:` and a declaration's `reads` alike.
|
|
44
|
+
*/
|
|
45
|
+
interface RowRef<Field extends string = string, Value = unknown, Read = Value> {
|
|
46
|
+
readonly kind: "row";
|
|
47
|
+
readonly field: Field;
|
|
48
|
+
/** The row slot's key, once `defineSchema` resolved it. Absent on a ref as authored. */
|
|
49
|
+
readonly slot?: string;
|
|
50
|
+
/** Phantom: the member's value type, as a slot sourced by it holds it. Never present at runtime. */
|
|
51
|
+
readonly __value?: Value;
|
|
52
|
+
/**
|
|
53
|
+
* Phantom: what the member holds as a `compute()` reads it — its value, but on a table's
|
|
54
|
+
* row what the facts document holds (an image's `{ asset_id }`, which `ReadValue` hands
|
|
55
|
+
* as its asset's record). Never present at runtime.
|
|
56
|
+
*/
|
|
57
|
+
readonly __read?: Read;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The element an item function receives — `(el) => …` in `list({ source, item })`.
|
|
61
|
+
* Read whole (`image({ source: photo })`, `reads: [question]`) it is `{kind:"element"}`
|
|
62
|
+
* on the wire; its members are read only through a row declared from it
|
|
63
|
+
* (`row({ source: el })`). `Value` is the element's own value type, and `Table` the fact
|
|
64
|
+
* table whose row the element is, or `null` for any other element.
|
|
65
|
+
*/
|
|
66
|
+
interface ElementRef<Value = unknown, Table extends string | null = string | null> {
|
|
67
|
+
readonly kind: "element";
|
|
68
|
+
/** Phantom: the element's value type. Never present at runtime. */
|
|
69
|
+
readonly __value?: Value;
|
|
70
|
+
/** Phantom: the table whose row the element is. Never present at runtime. */
|
|
71
|
+
readonly __table?: Table;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A typed handle on one value the platform can resolve — what `source:`, a
|
|
75
|
+
* `compute`'s `reads` and a fill decision's `reads` all take. A new kind is
|
|
76
|
+
* additive: it answers where its value comes from and when it settles, and
|
|
77
|
+
* changes no consumer.
|
|
78
|
+
*/
|
|
79
|
+
type Ref = FactRef | SlotRef | RowRef | ElementRef;
|
|
80
|
+
/** A slot of the declaring section, named by its own const — see the module header. */
|
|
81
|
+
type SiblingSlot = Slot;
|
|
82
|
+
/**
|
|
83
|
+
* A list's or a row's `source:` naming a sibling list or row by its const, until
|
|
84
|
+
* `defineSchema` — which alone knows the section's keys — writes it as a slot ref to
|
|
85
|
+
* the declaring section.
|
|
86
|
+
*/
|
|
87
|
+
interface SiblingSource {
|
|
88
|
+
readonly kind: "sibling";
|
|
89
|
+
readonly of: SiblingSlot;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A top-level fact of the declaring registry, named by the const its page was declared
|
|
93
|
+
* with — the registry's sibling read, as a sibling slot is a section's. `defineFacts`
|
|
94
|
+
* resolves it by identity to its key and serializes it as a fact read; a section
|
|
95
|
+
* refuses one, since a section reads the registry through `fact.*`.
|
|
96
|
+
*/
|
|
97
|
+
interface SiblingPage<Declaration = unknown> {
|
|
98
|
+
readonly head: object;
|
|
99
|
+
readonly declaration: Declaration;
|
|
100
|
+
}
|
|
101
|
+
/** What a `compute`'s or a fill's `reads` (and a mirror's `source:`) may name: any ref, a sibling slot, or a sibling page. */
|
|
102
|
+
type ComputeRead = Ref | SiblingSlot | SiblingPage;
|
|
103
|
+
/**
|
|
104
|
+
* The entries of `Requires` not already among `Reads` — what a function's `requires`
|
|
105
|
+
* appends to its `reads`, so a callback is handed the read once wherever it was named.
|
|
106
|
+
* Matched by type: two `fact.*` refs are one entry iff they carry the same key.
|
|
107
|
+
*/
|
|
108
|
+
type RequiresBeyond<Requires extends readonly unknown[], Reads extends readonly unknown[]> = Requires extends readonly [infer Head, ...infer Rest] ? [Head] extends [Reads[number]] ? RequiresBeyond<Rest, Reads> : [Head, ...RequiresBeyond<Rest, [...Reads, Head]>] : [];
|
|
109
|
+
/** The value a ref refers to, read off the phantom member. */
|
|
110
|
+
type RefValue<R> = R extends {
|
|
111
|
+
readonly __value?: infer V;
|
|
112
|
+
} ? V : unknown;
|
|
113
|
+
/**
|
|
114
|
+
* `V` as a read hands it: each media value in it — a reference, or a slot's media value —
|
|
115
|
+
* its asset's record, narrowed by kind where the value says it, at any depth. The type
|
|
116
|
+
* half of the read step (./registry-facts `readAsRecords`).
|
|
117
|
+
*/
|
|
118
|
+
type AsRead<V> = V extends ImageValue ? ImageMedia : V extends VideoValue ? VideoMedia : V extends TourValue ? TourMedia : V extends DocumentValue ? DocumentMedia : V extends DocumentMediaValue ? Media : V extends readonly unknown[] ? { [I in keyof V]: AsRead<V[I]>; } : V extends object ? { [K in keyof V]: AsRead<V[K]>; } : V;
|
|
119
|
+
/**
|
|
120
|
+
* The value ONE ref hands a declaration that reads it, each media value in it its asset's
|
|
121
|
+
* record (`AsRead`). A slot read is always `| undefined` — the upstream section's page may
|
|
122
|
+
* be disabled, the section unplaced on a given composition, the slot empty — so a body
|
|
123
|
+
* must say what it does with nothing. A fact settles at intake and carries its own null.
|
|
124
|
+
*/
|
|
125
|
+
type ReadValue<R> = AsRead<R extends SlotRef ? RefValue<R> | undefined : R extends SiblingSlot ? SlotValue<R> | undefined : R extends SiblingPage<infer D> ? SlotValue<D> | null : R extends RowRef<string, unknown, infer Read> ? Read : RefValue<R>>;
|
|
126
|
+
/**
|
|
127
|
+
* The positional arguments a reads-declaring callback receives: one value per ref,
|
|
128
|
+
* in `reads` order, each at that ref's own value type. Mutable so the tuple is
|
|
129
|
+
* legal in a rest parameter; the list it maps is the author's `const` one.
|
|
130
|
+
*/
|
|
131
|
+
type RefValues<Reads extends readonly ComputeRead[]> = { -readonly [I in keyof Reads]: ReadValue<Reads[I]>; };
|
|
132
|
+
/** A home ref on the wire: a fact by its registry key. */
|
|
133
|
+
interface SerializedHomeRef {
|
|
134
|
+
readonly kind: "home";
|
|
135
|
+
readonly key: string;
|
|
136
|
+
}
|
|
137
|
+
/** A section ref on the wire: a section's LOCAL key, and a slot id, a dotted `<object>.<field>` or `display.<entry>`. */
|
|
138
|
+
interface SerializedSectionRef {
|
|
139
|
+
readonly kind: "section";
|
|
140
|
+
readonly section: string;
|
|
141
|
+
readonly slot: string;
|
|
142
|
+
}
|
|
143
|
+
/** A member ref on the wire: member `field` of the row (or address) the slot `slot` holds. */
|
|
144
|
+
interface SerializedRowRef {
|
|
145
|
+
readonly kind: "row";
|
|
146
|
+
readonly slot: string;
|
|
147
|
+
readonly field: string;
|
|
148
|
+
}
|
|
149
|
+
/** A member of the item the reader sits in — the fact registry's own-item sibling read; legal only inside an item. */
|
|
150
|
+
interface SerializedItemRef {
|
|
151
|
+
readonly kind: "item";
|
|
152
|
+
readonly field: string;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { AsRead, ComputeRead, DISPLAY_REF_PREFIX, DisplayEntryName, ElementRef, FactRef, ReadValue, Ref, RefValue, RefValues, RequiresBeyond, RowRef, SerializedHomeRef, SerializedItemRef, SerializedRowRef, SerializedSectionRef, SiblingPage, SiblingSlot, SiblingSource, SlotRef };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region ../../internal/template-contracts/dist/slot-ref.js
|
|
2
|
+
const DISPLAY_REF_PREFIX = "display.";
|
|
3
|
+
const ROW_OF = Symbol.for("@homepages/concrete:row:of");
|
|
4
|
+
const ELEMENT_OF = Symbol.for("@homepages/concrete:element:of");
|
|
5
|
+
function isSiblingSource(x) {
|
|
6
|
+
return typeof x === "object" && x !== null && x.kind === "sibling" && isSiblingSlot(x.of);
|
|
7
|
+
}
|
|
8
|
+
function sameRead(a, b) {
|
|
9
|
+
return a === b || isFactRef(a) && isFactRef(b) && a.key === b.key;
|
|
10
|
+
}
|
|
11
|
+
function readsWithRequires(reads, requires) {
|
|
12
|
+
const out = [...reads];
|
|
13
|
+
for (const required of requires ?? []) if (!out.some((read) => sameRead(read, required))) out.push(required);
|
|
14
|
+
return out;
|
|
15
|
+
}
|
|
16
|
+
function isSlotRef(x) {
|
|
17
|
+
return typeof x === "object" && x !== null && "section" in x && typeof x.section === "string" && "slot" in x && typeof x.slot === "string";
|
|
18
|
+
}
|
|
19
|
+
function isRowRef(x) {
|
|
20
|
+
return typeof x === "object" && x !== null && "kind" in x && x.kind === "row" && "field" in x && typeof x.field === "string";
|
|
21
|
+
}
|
|
22
|
+
function rowOfMember(x) {
|
|
23
|
+
if (!isRowRef(x)) return void 0;
|
|
24
|
+
const row = x[ROW_OF];
|
|
25
|
+
return typeof row === "object" && row !== null ? row : void 0;
|
|
26
|
+
}
|
|
27
|
+
function isElementRef(x) {
|
|
28
|
+
return typeof x === "object" && x !== null && "kind" in x && x.kind === "element";
|
|
29
|
+
}
|
|
30
|
+
function elementOwner(x) {
|
|
31
|
+
if (!isElementRef(x)) return void 0;
|
|
32
|
+
const owner = x[ELEMENT_OF];
|
|
33
|
+
return typeof owner === "object" && owner !== null ? owner : void 0;
|
|
34
|
+
}
|
|
35
|
+
function isFactRef(x) {
|
|
36
|
+
return typeof x === "object" && x !== null && "kind" in x && x.kind === "home" && "key" in x && typeof x.key === "string";
|
|
37
|
+
}
|
|
38
|
+
function isSiblingPage(x) {
|
|
39
|
+
return typeof x === "object" && x !== null && "head" in x && typeof x.head === "object" && "declaration" in x && isSiblingSlot(x.declaration);
|
|
40
|
+
}
|
|
41
|
+
function isSiblingSlot(x) {
|
|
42
|
+
return typeof x === "object" && x !== null && "type" in x && typeof x.type === "string";
|
|
43
|
+
}
|
|
44
|
+
function serializeRowRef(ref) {
|
|
45
|
+
if (typeof ref.slot !== "string") throw new Error(`the row member "${ref.field}" is read through a row that is not in scope — declare the row beside its reader (a field of the same object or item) or at the top level, and read its member there.`);
|
|
46
|
+
return {
|
|
47
|
+
kind: "row",
|
|
48
|
+
slot: ref.slot,
|
|
49
|
+
field: ref.field
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function serializeSectionRef(ref) {
|
|
53
|
+
return {
|
|
54
|
+
kind: "section",
|
|
55
|
+
section: ref.section,
|
|
56
|
+
slot: ref.slot
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function serializeRef(ref) {
|
|
60
|
+
if (isSlotRef(ref)) return serializeSectionRef(ref);
|
|
61
|
+
if (isRowRef(ref)) return serializeRowRef(ref);
|
|
62
|
+
if (isElementRef(ref)) return { kind: "element" };
|
|
63
|
+
return {
|
|
64
|
+
kind: "home",
|
|
65
|
+
key: ref.key
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function isSerializedSectionRef(ref) {
|
|
69
|
+
return ref.kind === "section";
|
|
70
|
+
}
|
|
71
|
+
function serializedSectionRefs(reads) {
|
|
72
|
+
return reads.filter(isSerializedSectionRef);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { DISPLAY_REF_PREFIX, ELEMENT_OF, ROW_OF, elementOwner, isElementRef, isFactRef, isRowRef, isSerializedSectionRef, isSiblingPage, isSiblingSlot, isSiblingSource, isSlotRef, readsWithRequires, rowOfMember, serializeRef, serializeRowRef, serializeSectionRef, serializedSectionRefs };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import "./primitive-descriptors.js";
|
|
2
|
+
import { FillBinding } from "./fill-builders.js";
|
|
3
|
+
import { FILL } from "./fill-declaration.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region ../../internal/template-contracts/dist/slot-types.d.ts
|
|
6
|
+
type SlotBase = {
|
|
7
|
+
[FILL]?: readonly FillBinding[];
|
|
8
|
+
locked?: boolean;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
source?: {
|
|
11
|
+
kind: string;
|
|
12
|
+
key?: string;
|
|
13
|
+
field?: string;
|
|
14
|
+
transform?: string;
|
|
15
|
+
slot?: string;
|
|
16
|
+
section?: string;
|
|
17
|
+
};
|
|
18
|
+
label?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
variant?: {
|
|
21
|
+
cases: readonly string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/** Kind-level def type for a `text` slot — `SlotBinding<TextSlot>` accepts any text slot. */
|
|
25
|
+
type TextSlot = SlotBase & {
|
|
26
|
+
type: "text";
|
|
27
|
+
size?: string;
|
|
28
|
+
cap?: number;
|
|
29
|
+
};
|
|
30
|
+
/** Kind-level def type for a `number` slot — `SlotBinding<NumberSlot>` accepts any number slot. */
|
|
31
|
+
type NumberSlot = SlotBase & {
|
|
32
|
+
type: "number";
|
|
33
|
+
thousandsSep?: boolean;
|
|
34
|
+
decimals?: boolean;
|
|
35
|
+
maxDigits?: number;
|
|
36
|
+
};
|
|
37
|
+
/** Kind-level def type for a `select` slot — `SlotBinding<SelectSlot>` accepts any select slot. */
|
|
38
|
+
type SelectSlot = SlotBase & {
|
|
39
|
+
type: "select";
|
|
40
|
+
values?: (string | {
|
|
41
|
+
value: string;
|
|
42
|
+
label: string;
|
|
43
|
+
icon?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
})[];
|
|
46
|
+
options?: {
|
|
47
|
+
source: string;
|
|
48
|
+
};
|
|
49
|
+
creatable?: boolean;
|
|
50
|
+
};
|
|
51
|
+
/** Kind-level def type for an `image` slot — `SlotBinding<ImageSlot>` accepts any image slot. */
|
|
52
|
+
type ImageSlot = SlotBase & {
|
|
53
|
+
type: "image";
|
|
54
|
+
crop?: unknown;
|
|
55
|
+
};
|
|
56
|
+
/** Kind-level def type for a `video` slot — `SlotBinding<VideoSlot>` accepts any video slot. */
|
|
57
|
+
type VideoSlot = SlotBase & {
|
|
58
|
+
type: "video";
|
|
59
|
+
playback?: unknown;
|
|
60
|
+
};
|
|
61
|
+
/** Kind-level def type for a `tour` slot — `SlotBinding<TourSlot>` accepts any tour slot. */
|
|
62
|
+
type TourSlot = SlotBase & {
|
|
63
|
+
type: "tour";
|
|
64
|
+
};
|
|
65
|
+
/** Kind-level def type for a `poi` slot — one platform-built place; `SlotBinding<PoiSlot>` accepts any poi slot. */
|
|
66
|
+
type PoiSlot = SlotBase & {
|
|
67
|
+
type: "poi";
|
|
68
|
+
};
|
|
69
|
+
/** Kind-level def type for a `url` slot — `SlotBinding<UrlSlot>` accepts any url slot. */
|
|
70
|
+
type UrlSlot = SlotBase & {
|
|
71
|
+
type: "url";
|
|
72
|
+
accepts?: string;
|
|
73
|
+
};
|
|
74
|
+
/** Kind-level def type for an `address` slot — one place; `SlotBinding<AddressSlot>` accepts any address slot. */
|
|
75
|
+
type AddressSlot = SlotBase & {
|
|
76
|
+
type: "address";
|
|
77
|
+
};
|
|
78
|
+
/** Kind-level def type for a `date` slot — `SlotBinding<DateSlot>` accepts any date slot. */
|
|
79
|
+
type DateSlot = SlotBase & {
|
|
80
|
+
type: "date";
|
|
81
|
+
};
|
|
82
|
+
/** Kind-level def type for an `email` slot — `SlotBinding<EmailSlot>` accepts any email slot. */
|
|
83
|
+
type EmailSlot = SlotBase & {
|
|
84
|
+
type: "email";
|
|
85
|
+
};
|
|
86
|
+
/** Kind-level def type for a `phone` slot — `SlotBinding<PhoneSlot>` accepts any phone slot. */
|
|
87
|
+
type PhoneSlot = SlotBase & {
|
|
88
|
+
type: "phone";
|
|
89
|
+
};
|
|
90
|
+
/** Kind-level def type for a `document` slot — `SlotBinding<DocumentSlot>` accepts any document slot. */
|
|
91
|
+
type DocumentSlot = SlotBase & {
|
|
92
|
+
type: "document";
|
|
93
|
+
};
|
|
94
|
+
/** Kind-level def type for an open-kind `media` slot — `SlotBinding<MediaSlot>` accepts any media slot. */
|
|
95
|
+
type MediaSlot = SlotBase & {
|
|
96
|
+
type: "media";
|
|
97
|
+
kinds?: readonly string[];
|
|
98
|
+
};
|
|
99
|
+
/** Every kind that holds one value. */
|
|
100
|
+
type ValueSlot = TextSlot | NumberSlot | SelectSlot | ImageSlot | VideoSlot | TourSlot | PoiSlot | UrlSlot | AddressSlot | DateSlot | EmailSlot | PhoneSlot | DocumentSlot | MediaSlot;
|
|
101
|
+
/**
|
|
102
|
+
* Kind-level def type for a `list` slot. Its `element` is the item function's
|
|
103
|
+
* returned slot: a value slot, a row (a selection), or an object.
|
|
104
|
+
*/
|
|
105
|
+
type ListSlot = SlotBase & {
|
|
106
|
+
type: "list";
|
|
107
|
+
min?: number;
|
|
108
|
+
max?: number;
|
|
109
|
+
element?: ListItemSlot;
|
|
110
|
+
};
|
|
111
|
+
/** Kind-level def type for a `row` slot — one row of its `from` table, read through its members. */
|
|
112
|
+
type RowSlot = SlotBase & {
|
|
113
|
+
type: "row";
|
|
114
|
+
from: string | readonly string[];
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Kind-level def type for an `object` slot — a pure container: no source and no value
|
|
118
|
+
* of its own, its value its fields'. The same at the top level and as a list's item.
|
|
119
|
+
*/
|
|
120
|
+
type ObjectSlot = {
|
|
121
|
+
type: "object";
|
|
122
|
+
/** The field whose value titles the card, when the label names one; any other label is the field keyed `label`. */
|
|
123
|
+
label?: {
|
|
124
|
+
field: string;
|
|
125
|
+
};
|
|
126
|
+
fields: Record<string, ObjectFieldSlot>;
|
|
127
|
+
/** Build-stamped field order — the declaration order, which JSONB would drop. */
|
|
128
|
+
item_order?: string[];
|
|
129
|
+
locked?: boolean;
|
|
130
|
+
variant?: {
|
|
131
|
+
cases: readonly string[];
|
|
132
|
+
};
|
|
133
|
+
source?: undefined;
|
|
134
|
+
placeholder?: undefined;
|
|
135
|
+
[FILL]?: undefined;
|
|
136
|
+
};
|
|
137
|
+
/** Every slot kind an author may declare at a section's top level. */
|
|
138
|
+
type Slot = ValueSlot | ListSlot | ObjectSlot | RowSlot;
|
|
139
|
+
/** The slot kinds legal as a list's item — a value slot, a row, or an object. */
|
|
140
|
+
type ListItemSlot = ValueSlot | RowSlot | ObjectSlot;
|
|
141
|
+
/**
|
|
142
|
+
* The slot kinds legal as a nested object's field — the item of an object's list of
|
|
143
|
+
* objects: a value slot, a row, or a list whose item is a value slot. A list of objects
|
|
144
|
+
* never nests a second level.
|
|
145
|
+
*/
|
|
146
|
+
type NestedObjectFieldSlot = ValueSlot | RowSlot | (ListSlot & {
|
|
147
|
+
element?: ValueSlot;
|
|
148
|
+
});
|
|
149
|
+
/** The item of an object's list of objects: an object whose fields hold no list of objects. */
|
|
150
|
+
type NestedObjectSlot = Omit<ObjectSlot, "fields"> & {
|
|
151
|
+
fields: Record<string, NestedObjectFieldSlot>;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* The slot kinds legal as an object's field — a value slot, a row, or a list whose item
|
|
155
|
+
* is a value slot or a nested object. An object is never a field, nor a list of rows. A
|
|
156
|
+
* list of objects is ONE field, its items part of that field's value, so identity stays
|
|
157
|
+
* a flat 4-tuple and there is no fifth element to address through.
|
|
158
|
+
*/
|
|
159
|
+
type ObjectFieldSlot = NestedObjectFieldSlot | (ListSlot & {
|
|
160
|
+
element?: ValueSlot | NestedObjectSlot;
|
|
161
|
+
});
|
|
162
|
+
//#endregion
|
|
163
|
+
export { AddressSlot, DateSlot, DocumentSlot, EmailSlot, ImageSlot, ListItemSlot, ListSlot, MediaSlot, NestedObjectFieldSlot, NestedObjectSlot, NumberSlot, ObjectFieldSlot, ObjectSlot, PhoneSlot, PoiSlot, RowSlot, SelectSlot, Slot, TextSlot, TourSlot, UrlSlot, ValueSlot, VideoSlot };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { PRIMITIVE_DESCRIPTORS } from "./primitive-descriptors.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/template-contracts/dist/slot-types.js
|
|
5
|
+
const slotHeadShape = {
|
|
6
|
+
locked: z.boolean().optional(),
|
|
7
|
+
required: z.literal(true).optional()
|
|
8
|
+
};
|
|
9
|
+
const HomeRefDef = z.object({
|
|
10
|
+
kind: z.literal("home"),
|
|
11
|
+
key: z.string().min(1)
|
|
12
|
+
}).strict();
|
|
13
|
+
const SectionRefDef = z.object({
|
|
14
|
+
kind: z.literal("section"),
|
|
15
|
+
section: z.string().min(1),
|
|
16
|
+
slot: z.string().min(1)
|
|
17
|
+
}).strict();
|
|
18
|
+
const RowRefDef = z.object({
|
|
19
|
+
kind: z.literal("row"),
|
|
20
|
+
slot: z.string().min(1),
|
|
21
|
+
field: z.string().min(1)
|
|
22
|
+
}).strict();
|
|
23
|
+
const ItemRefDef = z.object({
|
|
24
|
+
kind: z.literal("item"),
|
|
25
|
+
field: z.string().min(1)
|
|
26
|
+
}).strict();
|
|
27
|
+
const ElementRefDef = z.object({ kind: z.literal("element") }).strict();
|
|
28
|
+
const SerializedRefDef = z.discriminatedUnion("kind", [
|
|
29
|
+
HomeRefDef,
|
|
30
|
+
SectionRefDef,
|
|
31
|
+
RowRefDef,
|
|
32
|
+
ItemRefDef,
|
|
33
|
+
ElementRefDef
|
|
34
|
+
]);
|
|
35
|
+
const SerializedReads = z.array(SerializedRefDef).min(1).optional();
|
|
36
|
+
const DerivedSourceDef = z.object({
|
|
37
|
+
kind: z.literal("derived"),
|
|
38
|
+
transform: z.string(),
|
|
39
|
+
reads: SerializedReads,
|
|
40
|
+
requires: SerializedReads
|
|
41
|
+
}).strict();
|
|
42
|
+
const variantShape = { variant: z.object({ cases: z.array(z.string().min(1)).min(1) }).strict().optional() };
|
|
43
|
+
const slotMetadataShape = {
|
|
44
|
+
label: z.string().min(1).optional(),
|
|
45
|
+
placeholder: z.string().optional(),
|
|
46
|
+
...variantShape,
|
|
47
|
+
source: z.union([
|
|
48
|
+
z.object({ kind: z.literal("authored") }),
|
|
49
|
+
SerializedRefDef,
|
|
50
|
+
DerivedSourceDef
|
|
51
|
+
]).optional()
|
|
52
|
+
};
|
|
53
|
+
function slotMember(type, shape) {
|
|
54
|
+
return z.object({
|
|
55
|
+
type: z.literal(type),
|
|
56
|
+
...slotHeadShape,
|
|
57
|
+
...shape,
|
|
58
|
+
...slotMetadataShape
|
|
59
|
+
}).strict();
|
|
60
|
+
}
|
|
61
|
+
const VALUE_DEF_MEMBERS = [
|
|
62
|
+
slotMember("text", PRIMITIVE_DESCRIPTORS.text.shape),
|
|
63
|
+
slotMember("number", PRIMITIVE_DESCRIPTORS.number.shape),
|
|
64
|
+
slotMember("select", PRIMITIVE_DESCRIPTORS.select.shape),
|
|
65
|
+
slotMember("image", PRIMITIVE_DESCRIPTORS.image.shape),
|
|
66
|
+
slotMember("video", PRIMITIVE_DESCRIPTORS.video.shape),
|
|
67
|
+
slotMember("tour", PRIMITIVE_DESCRIPTORS.tour.shape),
|
|
68
|
+
slotMember("poi", PRIMITIVE_DESCRIPTORS.poi.shape),
|
|
69
|
+
slotMember("url", PRIMITIVE_DESCRIPTORS.url.shape),
|
|
70
|
+
slotMember("address", PRIMITIVE_DESCRIPTORS.address.shape),
|
|
71
|
+
slotMember("date", PRIMITIVE_DESCRIPTORS.date.shape),
|
|
72
|
+
slotMember("email", PRIMITIVE_DESCRIPTORS.email.shape),
|
|
73
|
+
slotMember("phone", PRIMITIVE_DESCRIPTORS.phone.shape),
|
|
74
|
+
slotMember("document", PRIMITIVE_DESCRIPTORS.document.shape),
|
|
75
|
+
slotMember("media", PRIMITIVE_DESCRIPTORS.media.shape)
|
|
76
|
+
];
|
|
77
|
+
const ValueSlotDef = z.discriminatedUnion("type", [...VALUE_DEF_MEMBERS]);
|
|
78
|
+
const RowDef = z.object({
|
|
79
|
+
type: z.literal("row"),
|
|
80
|
+
...slotHeadShape,
|
|
81
|
+
label: z.string().min(1).optional(),
|
|
82
|
+
placeholder: z.string().optional(),
|
|
83
|
+
...variantShape,
|
|
84
|
+
from: z.union([z.string().min(1), z.array(z.string().min(1)).min(2)]),
|
|
85
|
+
source: z.union([
|
|
86
|
+
SectionRefDef,
|
|
87
|
+
DerivedSourceDef,
|
|
88
|
+
ElementRefDef
|
|
89
|
+
]).optional()
|
|
90
|
+
}).strict();
|
|
91
|
+
const VALUE_LIST_DEF_MEMBER = slotMember("list", {
|
|
92
|
+
...PRIMITIVE_DESCRIPTORS.list.shape,
|
|
93
|
+
element: ValueSlotDef
|
|
94
|
+
});
|
|
95
|
+
function objectDef(field) {
|
|
96
|
+
return z.object({
|
|
97
|
+
type: z.literal("object"),
|
|
98
|
+
locked: slotHeadShape.locked,
|
|
99
|
+
label: z.object({ field: z.string().min(1) }).strict().optional(),
|
|
100
|
+
fields: z.record(z.string(), field),
|
|
101
|
+
item_order: z.array(z.string()).optional(),
|
|
102
|
+
...variantShape
|
|
103
|
+
}).strict();
|
|
104
|
+
}
|
|
105
|
+
const NestedObjectFieldDef = z.discriminatedUnion("type", [
|
|
106
|
+
...VALUE_DEF_MEMBERS,
|
|
107
|
+
RowDef,
|
|
108
|
+
VALUE_LIST_DEF_MEMBER
|
|
109
|
+
]);
|
|
110
|
+
const NestedObjectDef = objectDef(NestedObjectFieldDef);
|
|
111
|
+
const FIELD_LIST_DEF_MEMBER = slotMember("list", {
|
|
112
|
+
...PRIMITIVE_DESCRIPTORS.list.shape,
|
|
113
|
+
element: z.discriminatedUnion("type", [...VALUE_DEF_MEMBERS, NestedObjectDef])
|
|
114
|
+
});
|
|
115
|
+
const ObjectFieldDef = z.discriminatedUnion("type", [
|
|
116
|
+
...VALUE_DEF_MEMBERS,
|
|
117
|
+
RowDef,
|
|
118
|
+
FIELD_LIST_DEF_MEMBER
|
|
119
|
+
]);
|
|
120
|
+
const ObjectDef = objectDef(ObjectFieldDef);
|
|
121
|
+
const ListElementDef = z.discriminatedUnion("type", [
|
|
122
|
+
...VALUE_DEF_MEMBERS,
|
|
123
|
+
RowDef,
|
|
124
|
+
ObjectDef
|
|
125
|
+
]);
|
|
126
|
+
const LIST_DEF_MEMBER = slotMember("list", {
|
|
127
|
+
...PRIMITIVE_DESCRIPTORS.list.shape,
|
|
128
|
+
element: ListElementDef
|
|
129
|
+
});
|
|
130
|
+
const SLOT_DEF_MEMBERS = [
|
|
131
|
+
...VALUE_DEF_MEMBERS,
|
|
132
|
+
LIST_DEF_MEMBER,
|
|
133
|
+
ObjectDef,
|
|
134
|
+
RowDef
|
|
135
|
+
];
|
|
136
|
+
const SlotDef = z.discriminatedUnion("type", [...SLOT_DEF_MEMBERS]);
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
export { HomeRefDef, ListElementDef, NestedObjectFieldDef, ObjectFieldDef, SectionRefDef, SerializedReads, SerializedRefDef, SlotDef, ValueSlotDef };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { AddressValue } from "./address-value.js";
|
|
2
|
+
import { DocumentValue } from "./document-value.js";
|
|
3
|
+
import { MediaKind, RegistryTableKey } from "./slot-catalog.js";
|
|
4
|
+
import { TourValue } from "./tour-value.js";
|
|
5
|
+
import { VideoValue } from "./video-value.js";
|
|
6
|
+
import { PoiRow } from "./poi-row.js";
|
|
7
|
+
import { ImageValue, MediaValue } from "./runtime-values.js";
|
|
8
|
+
import { RowId } from "./row-ref.js";
|
|
9
|
+
//#region ../../internal/template-contracts/dist/slot-value.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Maps one slot definition (as authored under a section schema's `slots`) to
|
|
12
|
+
* the runtime value shape a renderer receives at `props.slots[<key>]`, as
|
|
13
|
+
* normalized by the binding layer. String-valued kinds (`text`, `select`,
|
|
14
|
+
* `url`, `email`, `phone`) are plain `string` — the canonical blank is `""`, never
|
|
15
|
+
* `null`; a `number`, `date`, `image`, `poi`, `address` or `document` slot's blank is `null`. A `list` slot is always an
|
|
16
|
+
* array, never `null` — an empty list is the absent state. An `object` is its fields'
|
|
17
|
+
* values by key; a `row` is its element's identity, or `null`. An item of a list of
|
|
18
|
+
* objects is its identity plus its fields under `id`: a fact row's identity where the
|
|
19
|
+
* elements are a table's rows, the platform-minted id otherwise.
|
|
20
|
+
*/
|
|
21
|
+
type SlotValue<S> = S extends {
|
|
22
|
+
type: "text";
|
|
23
|
+
} ? string : S extends {
|
|
24
|
+
type: "number";
|
|
25
|
+
} ? number | null : S extends {
|
|
26
|
+
type: "select";
|
|
27
|
+
} ? string : S extends {
|
|
28
|
+
type: "image";
|
|
29
|
+
} ? ImageValue | null : S extends {
|
|
30
|
+
type: "video";
|
|
31
|
+
} ? VideoValue | null : S extends {
|
|
32
|
+
type: "tour";
|
|
33
|
+
} ? TourValue | null : S extends {
|
|
34
|
+
type: "list";
|
|
35
|
+
} ? ListValue<S> : S extends {
|
|
36
|
+
type: "object";
|
|
37
|
+
fields: infer F;
|
|
38
|
+
} ? ObjectValue<F> : S extends {
|
|
39
|
+
type: "row";
|
|
40
|
+
} ? RowId<TableOf<S>> | null : S extends {
|
|
41
|
+
type: "poi";
|
|
42
|
+
} ? PoiRow | null : S extends {
|
|
43
|
+
type: "url";
|
|
44
|
+
} ? string : S extends {
|
|
45
|
+
type: "date";
|
|
46
|
+
} ? string | null : S extends {
|
|
47
|
+
type: "email";
|
|
48
|
+
} ? string : S extends {
|
|
49
|
+
type: "phone";
|
|
50
|
+
} ? string : S extends {
|
|
51
|
+
type: "address";
|
|
52
|
+
} ? AddressValue | null : S extends {
|
|
53
|
+
type: "document";
|
|
54
|
+
} ? DocumentValue | null : S extends {
|
|
55
|
+
type: "media";
|
|
56
|
+
} ? MediaValue<DeclaredKinds<S>> | null : never;
|
|
57
|
+
/** The kinds a `media` declaration holds — its `kinds`, all four when it states none. */
|
|
58
|
+
type DeclaredKinds<S> = S extends {
|
|
59
|
+
kinds?: readonly (infer K extends MediaKind)[];
|
|
60
|
+
} ? ([K] extends [never] ? MediaKind : K) : MediaKind;
|
|
61
|
+
/** The table a list's or a row's phantom names, or `null`. */
|
|
62
|
+
type TableOf<S> = S extends {
|
|
63
|
+
readonly __table?: infer T;
|
|
64
|
+
} ? (T extends RegistryTableKey ? T : null) : null;
|
|
65
|
+
type ListValue<S> = S extends {
|
|
66
|
+
type: "list";
|
|
67
|
+
element: {
|
|
68
|
+
type: "object";
|
|
69
|
+
fields: infer F;
|
|
70
|
+
};
|
|
71
|
+
} ? (ItemIdentity<TableOf<S>> & ObjectValue<F>)[] : S extends {
|
|
72
|
+
type: "list";
|
|
73
|
+
element: infer E extends {
|
|
74
|
+
type: "row";
|
|
75
|
+
};
|
|
76
|
+
} ? RowId<TableOf<E> extends RegistryTableKey ? TableOf<E> : TableOf<S>>[] : S extends {
|
|
77
|
+
type: "list";
|
|
78
|
+
element: infer E;
|
|
79
|
+
} ? NonNullable<SlotValue<E>>[] : unknown[];
|
|
80
|
+
/**
|
|
81
|
+
* The value of an `object` — at a section's top level, or as one item of a list —
|
|
82
|
+
* derived from its declared fields: each field typed by its own definition, and a
|
|
83
|
+
* label read from a source under `label` (a label naming one of the fields adds no
|
|
84
|
+
* key). Closed (no index signature), so an undeclared field is a compile error.
|
|
85
|
+
*/
|
|
86
|
+
type ObjectValue<F> = { -readonly [K in keyof F]: SlotValue<F[K]>; };
|
|
87
|
+
/**
|
|
88
|
+
* The identity an item of a list of objects carries beside its fields: `id` — the row's
|
|
89
|
+
* identity where the elements are table `T`'s rows, the platform-minted id otherwise.
|
|
90
|
+
*/
|
|
91
|
+
type ItemIdentity<T = unknown> = T extends unknown ? {
|
|
92
|
+
id: string;
|
|
93
|
+
} : never;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { ItemIdentity, ObjectValue, SlotValue };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AddressValue } from "./address-value.js";
|
|
2
|
+
import { RegistryTable } from "./slot-catalog.js";
|
|
3
|
+
import { MemberValueTypeOf, TableFieldsOf } from "./registry-shape.js";
|
|
4
|
+
import { LibraryFactRegistry, PropertyTablePages } from "./fact-registry.js";
|
|
5
|
+
import { FactItem } from "./registry-facts.js";
|
|
6
|
+
//#region ../../internal/template-contracts/dist/table-members.d.ts
|
|
7
|
+
interface RegistryItems {
|
|
8
|
+
units: FactItem<PropertyTablePages["units"]["declaration"]["element"]>;
|
|
9
|
+
comparables: FactItem<PropertyTablePages["comparables"]["declaration"]["element"]>;
|
|
10
|
+
commercial_spaces: FactItem<PropertyTablePages["commercial_spaces"]["declaration"]["element"]>;
|
|
11
|
+
contacts: FactItem<LibraryFactRegistry["pages"]["contacts"]["declaration"]["element"]>;
|
|
12
|
+
}
|
|
13
|
+
type RegistryItem<T extends RegistryTable> = RegistryItems[T];
|
|
14
|
+
type AddressMemberOf<T extends RegistryTable> = { [M in keyof TableFieldsOf<T>]: TableFieldsOf<T>[M] extends {
|
|
15
|
+
readonly type: "address";
|
|
16
|
+
} ? M : never; }[keyof TableFieldsOf<T>];
|
|
17
|
+
/**
|
|
18
|
+
* One row of table `T` under its registry reading: the facts document's item, its
|
|
19
|
+
* identity `id` beside its members, an address-valued member read as an address slot
|
|
20
|
+
* holds it (`AddressValue`, `null` when it holds no place). What a `compute()` reading
|
|
21
|
+
* the table's registry key receives per row, and what each member read reads.
|
|
22
|
+
*/
|
|
23
|
+
type RegistryTableRow<T extends RegistryTable> = Omit<RegistryItem<T>, AddressMemberOf<T>> & { [M in AddressMemberOf<T> & string]: AddressValue | null; };
|
|
24
|
+
//#endregion
|
|
25
|
+
export { RegistryTableRow };
|