@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,245 @@
|
|
|
1
|
+
import { ADDRESS_SOURCES } from "../../template-contracts/dist/address-value.js";
|
|
2
|
+
import { FILE_RENDITION_NAMES, PLACE_RENDITION_NAMES, RENDITION_NAMES, fileNameOf, framedAt, framingOver, hasOwnFraming, isHomeMediaValue, isMediaReference, mediaIdOf, mediaRecords, mergeMedia, readAsRecords, recordOf, splitMedia, videoSourceOf } from "../../template-contracts/dist/registry-facts.js";
|
|
3
|
+
import { libraryFacts, listKeyOf, propertyFacts } from "../../template-contracts/dist/fact-registry.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/property-facts/dist/registry-facts.js
|
|
7
|
+
const RenditionSchema = z.object({
|
|
8
|
+
key: z.string(),
|
|
9
|
+
mime: z.string().nullable(),
|
|
10
|
+
width: z.number().int().nullable(),
|
|
11
|
+
height: z.number().int().nullable(),
|
|
12
|
+
bytes: z.number().int().nullable()
|
|
13
|
+
}).strict();
|
|
14
|
+
const ServedRenditionSchema = RenditionSchema.extend({ url: z.string() }).strict();
|
|
15
|
+
const CropSchema = z.object({
|
|
16
|
+
x: z.number(),
|
|
17
|
+
y: z.number(),
|
|
18
|
+
width: z.number(),
|
|
19
|
+
height: z.number()
|
|
20
|
+
}).strict();
|
|
21
|
+
const RenditionInputsSchema = z.object({
|
|
22
|
+
crop: CropSchema.nullable(),
|
|
23
|
+
options: z.record(z.string(), z.unknown()),
|
|
24
|
+
version: z.string().optional()
|
|
25
|
+
}).strict();
|
|
26
|
+
const PlaceRenditionSchema = RenditionSchema.extend({ over: RenditionInputsSchema }).strict();
|
|
27
|
+
const ServedPlaceRenditionSchema = ServedRenditionSchema.extend({ over: RenditionInputsSchema }).strict();
|
|
28
|
+
const nothing = z.null();
|
|
29
|
+
const text = z.string().nullable();
|
|
30
|
+
const count = z.number().int().nullable();
|
|
31
|
+
function renditionsSchema(rendition, placed, has, names = RENDITION_NAMES) {
|
|
32
|
+
const isPlace = (name) => PLACE_RENDITION_NAMES.includes(name);
|
|
33
|
+
const slots = Object.fromEntries(names.map((name) => [name, has.includes(name) ? (isPlace(name) ? placed : rendition).nullable() : nothing]));
|
|
34
|
+
return z.object(slots).strict();
|
|
35
|
+
}
|
|
36
|
+
const placeMembers = {
|
|
37
|
+
id: z.string(),
|
|
38
|
+
file: z.string(),
|
|
39
|
+
crop: CropSchema.nullable(),
|
|
40
|
+
name: z.string()
|
|
41
|
+
};
|
|
42
|
+
const members = {
|
|
43
|
+
key: text,
|
|
44
|
+
mime: text,
|
|
45
|
+
bytes: count,
|
|
46
|
+
url: text,
|
|
47
|
+
provider: text,
|
|
48
|
+
added_at: z.string(),
|
|
49
|
+
account: text,
|
|
50
|
+
page_count: count,
|
|
51
|
+
duration_ms: count,
|
|
52
|
+
width: count,
|
|
53
|
+
height: count,
|
|
54
|
+
captured_at: text,
|
|
55
|
+
scan_count: count,
|
|
56
|
+
poster_at_ms: count,
|
|
57
|
+
state: z.enum([
|
|
58
|
+
"processing",
|
|
59
|
+
"ready",
|
|
60
|
+
"failed"
|
|
61
|
+
]),
|
|
62
|
+
...placeMembers
|
|
63
|
+
};
|
|
64
|
+
function mediaSchemaOf(rendition, placed, extras) {
|
|
65
|
+
const image = z.object({
|
|
66
|
+
...members,
|
|
67
|
+
kind: z.literal("image"),
|
|
68
|
+
key: z.string(),
|
|
69
|
+
url: nothing,
|
|
70
|
+
provider: nothing,
|
|
71
|
+
page_count: nothing,
|
|
72
|
+
duration_ms: nothing,
|
|
73
|
+
poster_at_ms: nothing,
|
|
74
|
+
captured_at: nothing,
|
|
75
|
+
scan_count: nothing,
|
|
76
|
+
renditions: renditionsSchema(rendition, placed, [
|
|
77
|
+
"master",
|
|
78
|
+
"crop",
|
|
79
|
+
"cutout",
|
|
80
|
+
"mask_white",
|
|
81
|
+
"mask_black"
|
|
82
|
+
]),
|
|
83
|
+
...extras.image
|
|
84
|
+
}).strict();
|
|
85
|
+
const video = z.object({
|
|
86
|
+
...members,
|
|
87
|
+
kind: z.literal("video"),
|
|
88
|
+
crop: nothing,
|
|
89
|
+
page_count: nothing,
|
|
90
|
+
scan_count: nothing,
|
|
91
|
+
renditions: renditionsSchema(rendition, placed, ["poster", "encode"]),
|
|
92
|
+
...extras.video
|
|
93
|
+
}).strict();
|
|
94
|
+
const tour = z.object({
|
|
95
|
+
...members,
|
|
96
|
+
kind: z.literal("tour"),
|
|
97
|
+
crop: nothing,
|
|
98
|
+
key: nothing,
|
|
99
|
+
mime: nothing,
|
|
100
|
+
bytes: nothing,
|
|
101
|
+
url: z.string(),
|
|
102
|
+
provider: z.string(),
|
|
103
|
+
page_count: nothing,
|
|
104
|
+
duration_ms: nothing,
|
|
105
|
+
poster_at_ms: nothing,
|
|
106
|
+
width: nothing,
|
|
107
|
+
height: nothing,
|
|
108
|
+
renditions: renditionsSchema(rendition, placed, ["poster"]),
|
|
109
|
+
...extras.tour
|
|
110
|
+
}).strict();
|
|
111
|
+
const document = z.object({
|
|
112
|
+
...members,
|
|
113
|
+
kind: z.literal("document"),
|
|
114
|
+
crop: nothing,
|
|
115
|
+
key: z.string(),
|
|
116
|
+
url: nothing,
|
|
117
|
+
provider: nothing,
|
|
118
|
+
duration_ms: nothing,
|
|
119
|
+
poster_at_ms: nothing,
|
|
120
|
+
width: nothing,
|
|
121
|
+
height: nothing,
|
|
122
|
+
captured_at: nothing,
|
|
123
|
+
scan_count: nothing,
|
|
124
|
+
renditions: renditionsSchema(rendition, placed, ["poster"]),
|
|
125
|
+
...extras.document
|
|
126
|
+
}).strict();
|
|
127
|
+
return z.discriminatedUnion("kind", [
|
|
128
|
+
image,
|
|
129
|
+
video,
|
|
130
|
+
tour,
|
|
131
|
+
document
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
const MediaSchema = mediaSchemaOf(RenditionSchema, PlaceRenditionSchema, {
|
|
135
|
+
image: {},
|
|
136
|
+
video: {},
|
|
137
|
+
tour: {},
|
|
138
|
+
document: {}
|
|
139
|
+
});
|
|
140
|
+
const SERVED_EXTRAS = {
|
|
141
|
+
image: { file_url: z.string() },
|
|
142
|
+
video: { file_url: text },
|
|
143
|
+
tour: { file_url: nothing },
|
|
144
|
+
document: { file_url: z.string() }
|
|
145
|
+
};
|
|
146
|
+
const ServedMediaSchema = mediaSchemaOf(ServedRenditionSchema, ServedPlaceRenditionSchema, SERVED_EXTRAS);
|
|
147
|
+
function fileSchemaOf(rendition, extras) {
|
|
148
|
+
const [image, video, tour, document] = mediaSchemaOf(rendition, rendition, extras).options;
|
|
149
|
+
const place = {
|
|
150
|
+
file: true,
|
|
151
|
+
crop: true,
|
|
152
|
+
name: true
|
|
153
|
+
};
|
|
154
|
+
return z.discriminatedUnion("kind", [
|
|
155
|
+
image.omit(place).extend({ renditions: renditionsSchema(rendition, rendition, ["master"], FILE_RENDITION_NAMES) }),
|
|
156
|
+
video.omit(place).extend({ renditions: renditionsSchema(rendition, rendition, ["poster", "encode"], FILE_RENDITION_NAMES) }),
|
|
157
|
+
tour.omit(place).extend({ renditions: renditionsSchema(rendition, rendition, ["poster"], FILE_RENDITION_NAMES) }),
|
|
158
|
+
document.omit(place).extend({ renditions: renditionsSchema(rendition, rendition, ["poster"], FILE_RENDITION_NAMES) })
|
|
159
|
+
]);
|
|
160
|
+
}
|
|
161
|
+
const MediaFileSchema = fileSchemaOf(RenditionSchema, {
|
|
162
|
+
image: {},
|
|
163
|
+
video: {},
|
|
164
|
+
tour: {},
|
|
165
|
+
document: {}
|
|
166
|
+
});
|
|
167
|
+
const ServedFileSchema = fileSchemaOf(ServedRenditionSchema, SERVED_EXTRAS);
|
|
168
|
+
const placeRenditions = renditionsSchema(RenditionSchema, PlaceRenditionSchema, PLACE_RENDITION_NAMES, PLACE_RENDITION_NAMES);
|
|
169
|
+
const HomeMediaValueSchema = z.object({
|
|
170
|
+
id: z.string(),
|
|
171
|
+
file: z.string(),
|
|
172
|
+
crop: CropSchema.nullable(),
|
|
173
|
+
name: z.string().nullable(),
|
|
174
|
+
renditions: placeRenditions
|
|
175
|
+
}).strict();
|
|
176
|
+
const MediaReferenceSchema = z.object({
|
|
177
|
+
media: z.string(),
|
|
178
|
+
crop: CropSchema.nullable().optional(),
|
|
179
|
+
renditions: placeRenditions.partial().strict().optional()
|
|
180
|
+
}).strict();
|
|
181
|
+
const REGISTRIES = {
|
|
182
|
+
property: propertyFacts,
|
|
183
|
+
library: libraryFacts
|
|
184
|
+
};
|
|
185
|
+
const nullableText = z.string().nullable();
|
|
186
|
+
const AddressViewSchema = z.object({
|
|
187
|
+
street: nullableText,
|
|
188
|
+
unit: nullableText,
|
|
189
|
+
city: nullableText,
|
|
190
|
+
state: nullableText,
|
|
191
|
+
postal: nullableText,
|
|
192
|
+
latitude: z.number().nullable(),
|
|
193
|
+
longitude: z.number().nullable(),
|
|
194
|
+
source: z.enum(ADDRESS_SOURCES).nullable(),
|
|
195
|
+
display: nullableText,
|
|
196
|
+
street_no_type: nullableText
|
|
197
|
+
}).strict();
|
|
198
|
+
function rowElement(from) {
|
|
199
|
+
const list = listKeyOf(from);
|
|
200
|
+
const listed = REGISTRIES[list.home].pages[list.key]?.declaration;
|
|
201
|
+
if (listed?.type !== "list") throw new Error(`registry facts: ${from} is not a list fact`);
|
|
202
|
+
return listed.element;
|
|
203
|
+
}
|
|
204
|
+
function selectSchema(values, creatable) {
|
|
205
|
+
const [first, ...rest] = (values ?? []).map((option) => typeof option === "string" ? option : option.value);
|
|
206
|
+
return creatable === true || first === void 0 ? nullableText : z.enum([first, ...rest]).nullable();
|
|
207
|
+
}
|
|
208
|
+
function valueSchema(declaration) {
|
|
209
|
+
switch (declaration.type) {
|
|
210
|
+
case "list": return z.array(itemSchema(declaration.element));
|
|
211
|
+
case "object": return z.object(Object.fromEntries(Object.entries(declaration.fields).map(([key, field]) => [key, valueSchema(field)]))).strict();
|
|
212
|
+
case "row": return itemSchema(rowElement(declaration.from));
|
|
213
|
+
case "address": return AddressViewSchema;
|
|
214
|
+
case "image":
|
|
215
|
+
case "video":
|
|
216
|
+
case "tour":
|
|
217
|
+
case "document":
|
|
218
|
+
case "media": return (declaration.from === void 0 ? HomeMediaValueSchema : MediaReferenceSchema).nullable();
|
|
219
|
+
case "number": return (declaration.decimals === true ? z.number() : z.number().int()).nullable();
|
|
220
|
+
case "select": return selectSchema(declaration.values, declaration.creatable);
|
|
221
|
+
case "date": return z.string().regex(/^\d{4}-\d{2}-\d{2}$/).nullable();
|
|
222
|
+
case "text":
|
|
223
|
+
case "url":
|
|
224
|
+
case "email":
|
|
225
|
+
case "phone": return nullableText;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function itemSchema(element) {
|
|
229
|
+
if (element.type === "object") {
|
|
230
|
+
const fields = Object.entries(element.fields);
|
|
231
|
+
return z.object({
|
|
232
|
+
...Object.fromEntries(fields.map(([key, field]) => [key, valueSchema(field)])),
|
|
233
|
+
id: z.string()
|
|
234
|
+
}).strict();
|
|
235
|
+
}
|
|
236
|
+
if (element.type === "row") return valueSchema(element);
|
|
237
|
+
return valueSchema(element).unwrap();
|
|
238
|
+
}
|
|
239
|
+
const RegistryFactsSchema = z.object({
|
|
240
|
+
...Object.fromEntries(Object.entries(REGISTRIES.property.pages).map(([key, page]) => [key, valueSchema(page.declaration)])),
|
|
241
|
+
files: z.record(z.string(), MediaFileSchema)
|
|
242
|
+
}).strict();
|
|
243
|
+
|
|
244
|
+
//#endregion
|
|
245
|
+
export { HomeMediaValueSchema, MediaFileSchema, MediaReferenceSchema, RegistryFactsSchema };
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
2
|
+
import { capHolderOf } from "../../fill-vocabulary/dist/resolved-decision.js";
|
|
3
|
+
import { producedSlot } from "./grammar-scope.js";
|
|
4
|
+
import { assertOptionsHonoured } from "./fill-options.js";
|
|
2
5
|
|
|
3
6
|
//#region ../../internal/section-contracts/dist/cap-contract.js
|
|
4
|
-
function capHolder(slot) {
|
|
5
|
-
if (slot.fields !== void 0) return null;
|
|
6
|
-
const planner = plannerForField(slot);
|
|
7
|
-
if (planner === "text") return {
|
|
8
|
-
holder: slot,
|
|
9
|
-
suffix: ""
|
|
10
|
-
};
|
|
11
|
-
if (planner === "list") return {
|
|
12
|
-
holder: slot.element ?? {},
|
|
13
|
-
suffix: "'s element"
|
|
14
|
-
};
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
7
|
function checkAgainstSlot(node, slot, where, decisionId, sectionKey) {
|
|
18
8
|
if (slot === void 0) return;
|
|
19
|
-
const resolved =
|
|
9
|
+
const resolved = capHolderOf(slot);
|
|
20
10
|
if (resolved === null) return;
|
|
21
11
|
const label = `${where}${resolved.suffix}`;
|
|
22
12
|
const slotCap = resolved.holder.cap;
|
|
@@ -28,14 +18,15 @@ function checkAgainstSlot(node, slot, where, decisionId, sectionKey) {
|
|
|
28
18
|
function checkNode(node, slot, slotId, field, decisionId, sectionKey) {
|
|
29
19
|
checkAgainstSlot(node, slot, field === void 0 ? `slot "${slotId}"` : `inner slot "${field}" of "${slotId}"`, decisionId, sectionKey);
|
|
30
20
|
for (const [planned, plan] of Object.entries(node.fields ?? {})) {
|
|
31
|
-
const rowField = slot?.
|
|
21
|
+
const rowField = slot === void 0 ? void 0 : listItemFieldsOf(slot)?.[planned];
|
|
32
22
|
if (!rowField) continue;
|
|
33
23
|
checkNode(plan, rowField, slotId, planned, decisionId, sectionKey);
|
|
34
24
|
}
|
|
35
25
|
}
|
|
36
26
|
function assertCapContract(schema, decision, sectionKey) {
|
|
27
|
+
assertOptionsHonoured(schema, decision, sectionKey, ["cap"]);
|
|
37
28
|
const node = decision;
|
|
38
|
-
for (const slotId of decision.produces) checkNode(node, schema
|
|
29
|
+
for (const slotId of decision.produces) checkNode(node, producedSlot(schema, slotId), slotId, void 0, decision.id, sectionKey);
|
|
39
30
|
}
|
|
40
31
|
|
|
41
32
|
//#endregion
|
|
@@ -12,21 +12,25 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
12
12
|
id: "produces-known-slot",
|
|
13
13
|
summary: "Every fill decision produces only slots the section declares."
|
|
14
14
|
},
|
|
15
|
+
{
|
|
16
|
+
id: "fill-verb",
|
|
17
|
+
summary: "A fill names its verb and brief, a pick names its candidates with of and no other verb takes one, and a filled list declares max."
|
|
18
|
+
},
|
|
15
19
|
{
|
|
16
20
|
id: "poi-curation",
|
|
17
21
|
summary: "A points-of-interest curation decision produces exactly one slot, a list of points of interest."
|
|
18
22
|
},
|
|
19
23
|
{
|
|
20
24
|
id: "list-fill",
|
|
21
|
-
summary: "A list fill declares what the
|
|
25
|
+
summary: "A list fill declares what its source needs: a brief wherever the model yields the items, a max wherever it writes rather than picks them, and nothing of the model's on a list bound to a table."
|
|
22
26
|
},
|
|
23
27
|
{
|
|
24
28
|
id: "row-fill",
|
|
25
|
-
summary: "A list fill plans only unbound fields its
|
|
29
|
+
summary: "A list fill plans only unbound fields its object item declares, each of a kind an item field can be filled with."
|
|
26
30
|
},
|
|
27
31
|
{
|
|
28
32
|
id: "count-bounds",
|
|
29
|
-
summary: "
|
|
33
|
+
summary: "The items a fill is asked for fit the min and max of the list that holds them, at the top level or inside an item."
|
|
30
34
|
},
|
|
31
35
|
{
|
|
32
36
|
id: "cap",
|
|
@@ -34,7 +38,7 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
34
38
|
},
|
|
35
39
|
{
|
|
36
40
|
id: "writer-reads-fact",
|
|
37
|
-
summary: "A fill that writes text, its
|
|
41
|
+
summary: "A fill that writes text, its item fields included, reads at least one fact to ground what it writes."
|
|
38
42
|
},
|
|
39
43
|
{
|
|
40
44
|
id: "display",
|
|
@@ -46,23 +50,43 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
46
50
|
},
|
|
47
51
|
{
|
|
48
52
|
id: "source",
|
|
49
|
-
summary: "Every slot and
|
|
53
|
+
summary: "Every slot and item field source names a known fact, another slot or its own compute binding; the uploads are read, never bound."
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "object",
|
|
57
|
+
summary: "An object groups value slots, rows, lists of value slots and lists of objects one level deep, holds no value of its own, is labelled by its label field, and names no field like its binding's own keys."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "list-source",
|
|
61
|
+
summary: "A list's source is a list, a table, a list slot or a compute, and its item can take the source's element."
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: "row-source",
|
|
65
|
+
summary: "A row names its table in `from`; its source is a row slot it mirrors, a compute, the element inside an item, or a pick, and is never a table or a list."
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "row-rule",
|
|
69
|
+
summary: "A member is read only through a row slot or an address in scope that offers it, and fits the slot that reads it."
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: "reads-acyclic",
|
|
73
|
+
summary: "No slot reads itself through its sources, rows and reads."
|
|
50
74
|
},
|
|
51
75
|
{
|
|
52
76
|
id: "record-collection",
|
|
53
|
-
summary: "A
|
|
77
|
+
summary: "A list bound to a fact binds a registry table and may only narrow its min and max."
|
|
54
78
|
},
|
|
55
79
|
{
|
|
56
80
|
id: "nested-slot-types",
|
|
57
|
-
summary: "
|
|
81
|
+
summary: "An object's fields, a nested list item's included, are each a value slot, a row or a list, of a kind the catalog declares."
|
|
58
82
|
},
|
|
59
83
|
{
|
|
60
84
|
id: "list-scalar",
|
|
61
|
-
summary: "A list declares exactly one legal item, a value element or a
|
|
85
|
+
summary: "A list declares exactly one legal item, a value element, an object or a row, with satisfiable bounds."
|
|
62
86
|
},
|
|
63
87
|
{
|
|
64
88
|
id: "select",
|
|
65
|
-
summary: "A select declares exactly one of values or options
|
|
89
|
+
summary: "A select declares exactly one of values or options."
|
|
66
90
|
},
|
|
67
91
|
{
|
|
68
92
|
id: "option-source",
|
|
@@ -74,15 +98,11 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
74
98
|
},
|
|
75
99
|
{
|
|
76
100
|
id: "sources",
|
|
77
|
-
summary: "
|
|
101
|
+
summary: "No slot declares sources, since a media slot takes a pasted link wherever a link provider claims its kind; a media slot picks `from` a media list of the property, or owns its asset without one, and processes only what its kind takes; a slot bound to a fact states neither."
|
|
78
102
|
},
|
|
79
103
|
{
|
|
80
104
|
id: "interpolation",
|
|
81
105
|
summary: "A fill brief refers to its facts through reads and never interpolates one."
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: "group",
|
|
85
|
-
summary: "Group ids are unique, every group names real slots, and no slot sits in two groups."
|
|
86
106
|
}
|
|
87
107
|
];
|
|
88
108
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
2
|
+
import { producedSlot } from "./grammar-scope.js";
|
|
3
|
+
import { assertOptionsHonoured } from "./fill-options.js";
|
|
4
|
+
|
|
1
5
|
//#region ../../internal/section-contracts/dist/count-bounds-contract.js
|
|
2
6
|
function requestedCount(raw) {
|
|
3
7
|
if (typeof raw === "number") return {
|
|
@@ -30,11 +34,16 @@ function checkNode(node, holder, slotId, field, decisionId, sectionKey) {
|
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
function assertCountBoundsContract(schema, decision, sectionKey) {
|
|
37
|
+
assertOptionsHonoured(schema, decision, sectionKey, ["count"]);
|
|
33
38
|
const node = decision;
|
|
34
39
|
for (const slotId of decision.produces) {
|
|
35
|
-
const slot = schema
|
|
40
|
+
const slot = producedSlot(schema, slotId);
|
|
36
41
|
if (!slot) continue;
|
|
37
|
-
checkNode(node,
|
|
42
|
+
checkNode(node, {
|
|
43
|
+
min: slot.min,
|
|
44
|
+
max: slot.max,
|
|
45
|
+
fields: listItemFieldsOf(slot)
|
|
46
|
+
}, slotId, void 0, decision.id, sectionKey);
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TABLES, isLegacyTable, tableBounds, tableForSlot } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/section-contracts/dist/directly-linked-list-contract.js
|
|
4
|
+
function assertDirectlyLinkedListContract(schema, sectionKey) {
|
|
5
|
+
for (const [slotId, slotUnknown] of Object.entries(schema.slots)) {
|
|
6
|
+
const slot = slotUnknown;
|
|
7
|
+
if (slot.type !== "list" || slot.element?.type !== "object" && slot.element?.type !== "row") continue;
|
|
8
|
+
const label = `list "${slotId}"`;
|
|
9
|
+
if (slot.source?.kind !== "home") continue;
|
|
10
|
+
const table = tableForSlot(slot);
|
|
11
|
+
if (table === null) continue;
|
|
12
|
+
const entry = isLegacyTable(table) ? TABLES[table] : null;
|
|
13
|
+
if (entry !== null && !entry.ownership) throw new Error(`Section "${sectionKey}": ${label} table "${table}" declares no ownership in TABLES. TABLES is a closed registry owned by @homepages/concrete — this is a framework defect, not something a workspace can fix.`);
|
|
14
|
+
const inherited = tableBounds(table);
|
|
15
|
+
if (inherited.max !== void 0 && slot.max !== void 0 && slot.max >= inherited.max) throw new Error(`Section "${sectionKey}": ${label} declares max ${slot.max}, but table "${table}" already caps membership at ${inherited.max}. An explicit max is legal only if it is strictly lower; drop it to inherit ${inherited.max}.`);
|
|
16
|
+
if (inherited.min !== void 0 && slot.min !== void 0 && slot.min <= inherited.min) throw new Error(`Section "${sectionKey}": ${label} declares min ${slot.min}, but table "${table}" already requires at least ${inherited.min}. An explicit min is legal only if it is strictly higher; drop it to inherit ${inherited.min}.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { assertDirectlyLinkedListContract };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { resolveDecision } from "../../fill-vocabulary/dist/resolved-decision.js";
|
|
2
|
+
import { producedSlots } from "./grammar-scope.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/section-contracts/dist/fill-options.js
|
|
5
|
+
function assertOptionsHonoured(schema, decision, sectionKey, options) {
|
|
6
|
+
const { refused } = resolveDecision(decision, producedSlots(schema, decision.produces));
|
|
7
|
+
const first = refused.find((refusal) => options.includes(refusal.option));
|
|
8
|
+
if (first !== void 0) throw new Error(`Section "${sectionKey}": ${first.message}`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { assertOptionsHonoured };
|
|
@@ -9,10 +9,6 @@ const DECISION_KINDS = [
|
|
|
9
9
|
function isListFill(decision) {
|
|
10
10
|
return decision.kind === "list";
|
|
11
11
|
}
|
|
12
|
-
function plannedFieldsOf(decision) {
|
|
13
|
-
const fields = decision.fields;
|
|
14
|
-
return fields !== null && typeof fields === "object" ? Object.keys(fields) : [];
|
|
15
|
-
}
|
|
16
12
|
|
|
17
13
|
//#endregion
|
|
18
|
-
export { DECISION_KINDS, isListFill
|
|
14
|
+
export { DECISION_KINDS, isListFill };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { SLOT_TYPES, tableKeyOf } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { readMediaOf } from "../../template-contracts/dist/media-candidates.js";
|
|
3
|
+
import { isMediaListKey } from "../../template-contracts/dist/fact-keys.js";
|
|
4
|
+
import { FINDABLE_KINDS, isFindableKind } from "../../template-contracts/dist/findable.js";
|
|
5
|
+
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
6
|
+
import { readFillVerb } from "../../fill-vocabulary/dist/verbs.js";
|
|
7
|
+
import { producedSlot } from "./grammar-scope.js";
|
|
8
|
+
|
|
9
|
+
//#region ../../internal/section-contracts/dist/fill-verb-contract.js
|
|
10
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11
|
+
function checkCandidates(of, where) {
|
|
12
|
+
if (Array.isArray(of) && of.length > 0) {
|
|
13
|
+
for (const table of of) {
|
|
14
|
+
if (!isRecord(table) || table["kind"] !== "home") throw new Error(`${where} picks \`of\` ${JSON.stringify(of)} — a list of candidates names tables, one \`home\` ref each.`);
|
|
15
|
+
checkCandidates(table, where);
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!isRecord(of)) throw new Error(`${where} picks \`of\` ${JSON.stringify(of)}, which is no list of candidates.`);
|
|
20
|
+
if (of["type"] === "media") {
|
|
21
|
+
const from = readMediaOf(of)?.from;
|
|
22
|
+
if (from === void 0 || !from.every((list) => isMediaListKey(list))) throw new Error(`${where} picks \`of\` ${JSON.stringify(of)} — a media pick states the media list of the property it picks \`from\` and its \`kinds\`; a media slot with no \`from\` owns its asset, and nothing picks it.`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (typeof of["type"] === "string") {
|
|
26
|
+
if (!SLOT_TYPES.includes(of["type"])) throw new Error(`${where} picks \`of\` a kind of unknown type "${of["type"]}".`);
|
|
27
|
+
if (of["type"] !== "select") throw new Error(`${where} picks \`of\` a "${of["type"]}" kind — a pick's candidates are a table, a media slot's \`from\` list, a list slot, a compute, or a select's options.`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const { kind, key, section, slot, transform } = of;
|
|
31
|
+
if (kind === "home" && typeof key === "string" && tableKeyOf(key) !== null) return;
|
|
32
|
+
if (kind === "section" && typeof section === "string" && typeof slot === "string") return;
|
|
33
|
+
if (kind === "derived" && typeof transform === "string") return;
|
|
34
|
+
throw new Error(`${where} picks \`of\` ${JSON.stringify(of)}, which is not a list of candidates — a table, a media slot's \`from\` list, a list slot, a compute, or a select's values.`);
|
|
35
|
+
}
|
|
36
|
+
function checkNode(node, where) {
|
|
37
|
+
const verb = readFillVerb(node["verb"]);
|
|
38
|
+
if (verb === void 0) throw new Error(`${where} declares the verb ${JSON.stringify(node["verb"])} — a fill is \`write\`, \`pick\` or \`find\`.`);
|
|
39
|
+
if (node["unique"] !== void 0 && (verb !== "pick" || typeof node["unique"] !== "boolean")) throw new Error(`${where} declares \`unique\` ${verb === "pick" ? "that is not a boolean" : `on a \`${verb}\``} — distinctness is a pick's, \`true\` unless it says \`unique: false\`.`);
|
|
40
|
+
if (typeof node["brief"] !== "string" || node["brief"] === "") throw new Error(`${where} declares no \`brief\` — the brief is the whole instruction.`);
|
|
41
|
+
if (verb === "pick") {
|
|
42
|
+
if (node["of"] === void 0) throw new Error(`${where} picks with no \`of\` — a pick names its candidates on every holder.`);
|
|
43
|
+
checkCandidates(node["of"], where);
|
|
44
|
+
} else if (node["of"] !== void 0) throw new Error(verb === "write" ? `${where} writes \`of\` something — the kind a write produces is its holder's (a text slot's own, a list's \`item\`), so a write takes no \`of\`.` : `${where} finds \`of\` something — the platform's lookup supplies what a find yields, so it takes no \`of\`.`);
|
|
45
|
+
return verb;
|
|
46
|
+
}
|
|
47
|
+
function checkTarget(verb, node, slot, where) {
|
|
48
|
+
if (slot.type === "object") throw new Error(`${where} fills an object, which holds no value of its own — fill its fields.`);
|
|
49
|
+
if (slot.type === "row") {
|
|
50
|
+
if (verb !== "pick") throw new Error(`${where} fills a row with \`fill.${verb}\` — a row holds an element that exists, which only a \`fill.pick\` yields.`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (slot.type === "list") {
|
|
54
|
+
if (slot.source !== void 0 && slot.source.kind !== "authored") throw new Error(`${where} fills a list that declares its own source (${String(slot.source.kind)}) — a fill IS the list's source; keep one.`);
|
|
55
|
+
if (verb === "find" && !isFindableKind(slot.element?.type)) throw new Error(`${where} finds a list of "${String(slot.element?.type)}" — ${FINDS}.`);
|
|
56
|
+
if (verb !== "find" && isFindableKind(slot.element?.type)) throw new Error(`${where} ${VERBED[verb] ?? verb} a list of "${String(slot.element?.type)}" — ${ONLY_FOUND}.`);
|
|
57
|
+
if (typeof slot.max !== "number") throw new Error(`${where} fills a list that declares no \`max\` — a fill is an open supply, so the list it sources must bound it.`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (verb === "find" && !isFindableKind(slot.type)) throw new Error(`${where} finds a "${String(slot.type)}" slot — ${FINDS}.`);
|
|
61
|
+
if (verb !== "find" && isFindableKind(slot.type)) throw new Error(`${where} ${VERBED[verb] ?? verb} a "${String(slot.type)}" slot — ${ONLY_FOUND}.`);
|
|
62
|
+
}
|
|
63
|
+
const FINDS = `a find locates what a platform lookup finds — a ${FINDABLE_KINDS.map((k) => `"${k}"`).join(", ")}, or a list of them`;
|
|
64
|
+
const ONLY_FOUND = "its value is located by the platform's lookup, never written or picked — fill it with `fill.find`";
|
|
65
|
+
const VERBED = {
|
|
66
|
+
write: "writes",
|
|
67
|
+
pick: "picks"
|
|
68
|
+
};
|
|
69
|
+
function assertFillVerbContract(ctx, decision) {
|
|
70
|
+
const where = `Section "${ctx.key}": fill "${decision.id}"`;
|
|
71
|
+
const node = decision;
|
|
72
|
+
if (decision.verb === void 0) {
|
|
73
|
+
for (const option of ["of", "unique"]) if (decision[option] !== void 0) throw new Error(`${where} declares \`${option}\` but no verb — \`${option}\` belongs to a \`fill.pick\`.`);
|
|
74
|
+
} else {
|
|
75
|
+
const verb = checkNode(node, where);
|
|
76
|
+
for (const id of decision.produces) {
|
|
77
|
+
const slot = producedSlot(ctx.schema, id);
|
|
78
|
+
if (slot !== void 0) checkTarget(verb, node, slot, `${where} (producing "${id}")`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const fields = node["fields"];
|
|
82
|
+
if (!isRecord(fields)) return;
|
|
83
|
+
const list = decision.produces.length === 1 ? producedSlot(ctx.schema, decision.produces[0]) : void 0;
|
|
84
|
+
const itemFields = list === void 0 ? void 0 : listItemFieldsOf(list);
|
|
85
|
+
for (const [name, entry] of Object.entries(fields)) {
|
|
86
|
+
if (!isRecord(entry)) continue;
|
|
87
|
+
const at = `${where} field "${name}"`;
|
|
88
|
+
const verb = checkNode(entry, at);
|
|
89
|
+
const field = itemFields?.[name];
|
|
90
|
+
if (field !== void 0) checkTarget(verb, entry, field, at);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
export { assertFillVerbContract };
|