@homepages/concrete 7.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1007 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +66 -0
- package/codemods/process-builders.mjs +198 -0
- package/codemods/slot-object.mjs +1097 -0
- package/codemods/steps/content-object-fields.mjs +324 -0
- package/codemods/steps/list-object-form.mjs +6 -7
- package/codemods/table-rows.mjs +568 -0
- package/codemods/unwrap-object-fields.mjs +310 -0
- package/codemods/viewer-slot-document.mjs +131 -0
- package/codemods/write-property-as-facts-document.mjs +716 -0
- package/codemods/write-the-address-line.mjs +255 -0
- package/codemods/write-the-registry-members.mjs +653 -0
- package/codemods/write-the-select-from.mjs +141 -0
- package/codemods/write-the-sole-from.mjs +369 -0
- package/codemods/write-the-table-from.mjs +267 -0
- package/codemods/write-the-whole-item.mjs +512 -0
- package/codemods/writeback-drop.mjs +168 -0
- package/codemods/written-contact-address.mjs +162 -0
- package/codemods/written-media-category.mjs +227 -0
- package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
- package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
- package/codemods/written-uploads-sort-into-lists.mjs +405 -0
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
- package/codemods/written-video-sources-drop.mjs +144 -0
- package/codemods/written-without-pick-none.mjs +146 -0
- package/codemods/written-without-retired-knowledge.mjs +223 -0
- package/codemods/written-without-the-media-key.mjs +202 -0
- package/codemods/written-without-the-property-type.mjs +249 -0
- package/dist/artifact/playground/client/assets/index-BUmdDDX5.js +1259 -0
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +61 -27
- package/dist/base.css +58 -1
- package/dist/cli/build/artifact.js +6 -9
- package/dist/cli/build/captures.js +2 -12
- package/dist/cli/build/esbuild.js +1 -25
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/static.js +2 -2
- package/dist/cli/capture/capture.js +8 -9
- package/dist/cli/check/analyze.js +8 -1
- package/dist/cli/check/load-outdir.js +47 -0
- package/dist/cli/check/load-workspace.js +4 -4
- package/dist/cli/check/render/html.js +1 -2
- package/dist/cli/check/render/inputs.js +10 -3
- package/dist/cli/check/render/island-frames.js +2 -1
- package/dist/cli/check/render/marker-coverage.js +23 -15
- package/dist/cli/check/report.js +5 -0
- package/dist/cli/check/stages/bundles.js +1 -1
- package/dist/cli/check/stages/relations.js +1 -1
- package/dist/cli/check/stages/render.js +48 -33
- package/dist/cli/check/stages/sections.js +83 -31
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/crop.js +1 -1
- package/dist/cli/dev/fixture-ladders.js +96 -0
- package/dist/cli/dev/islands.js +12 -123
- package/dist/cli/dev/listen.js +20 -1
- package/dist/cli/dev/load-template.js +1 -1
- package/dist/cli/dev/server.js +35 -10
- package/dist/cli/dev/vite.js +9 -7
- package/dist/cli/dev/workspace-reader.js +16 -16
- package/dist/cli/media/derive.js +43 -57
- package/dist/cli/media/frame-rung-floor.js +0 -1
- package/dist/cli/property/index.js +1 -6
- package/dist/css/inline.js +1 -22
- package/dist/eslint/rules/no-marker-literal.js +1 -1
- package/dist/fixtures/load.js +16 -7
- package/dist/fixtures/media-plugin.js +17 -12
- package/dist/fixtures/media-store.js +115 -0
- package/dist/fixtures/property.js +345 -126
- package/dist/fixtures/resolve.js +263 -251
- package/dist/fixtures/rows.js +4 -11
- package/dist/fixtures.d.ts +234 -109
- package/dist/index.d.ts +25 -16
- package/dist/index.js +10 -6
- package/dist/islands/marker.js +2 -1
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
- package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
- package/dist/packages/internal/capture-settle/dist/index.js +3 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
- package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
- package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +252 -35
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +365 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +35 -21
- package/dist/packages/internal/fill-bake/dist/index.js +8 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +119 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +28 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +40 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +175 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +390 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +75 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
- package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
- package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
- package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
- package/dist/packages/internal/image-ladder/dist/index.js +3 -3
- package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
- package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
- package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
- package/dist/packages/internal/island-runtime/dist/index.js +2 -1
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
- package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
- package/dist/packages/internal/media-resolution/dist/document.js +63 -0
- package/dist/packages/internal/media-resolution/dist/image.js +228 -0
- package/dist/packages/internal/media-resolution/dist/index.js +11 -0
- package/dist/packages/internal/media-resolution/dist/list.js +112 -0
- package/dist/packages/internal/media-resolution/dist/media.js +59 -0
- package/dist/packages/internal/media-resolution/dist/records.js +7 -0
- package/dist/packages/internal/media-resolution/dist/slot.js +34 -0
- package/dist/packages/internal/media-resolution/dist/store.js +19 -0
- package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
- package/dist/packages/internal/media-resolution/dist/video.js +93 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +244 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +35 -27
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -0
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
- package/dist/packages/internal/section-contracts/dist/index.js +7 -5
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +23 -19
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -7
- package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +5 -5
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +7 -4
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +83 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +77 -33
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +120 -66
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
- package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +43 -18
- package/dist/packages/internal/source-resolution/dist/index.js +113 -118
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
- package/dist/packages/internal/street-address/dist/index.js +72 -0
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
- package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
- package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
- package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +85 -0
- package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
- package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +12 -36
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
- package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +158 -0
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
- package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
- package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
- package/dist/packages/internal/template-contracts/dist/list-editing.js +94 -0
- package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
- package/dist/packages/internal/template-contracts/dist/list.js +258 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
- package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
- package/dist/packages/internal/template-contracts/dist/object.js +131 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
- package/dist/packages/internal/template-contracts/dist/read-graph.js +250 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +192 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +268 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
- package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
- package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
- package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +133 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +48 -8
- package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/row.js +84 -0
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +243 -384
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +334 -230
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.js +140 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
- package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
- package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
- package/dist/platform/fs.js +5 -2
- package/dist/playground/canvas-island-host.d.ts +11 -0
- package/dist/playground/canvas-island-host.js +29 -0
- package/dist/playground/canvas-markers.js +14 -0
- package/dist/playground-island-runtime.d.ts +3 -2
- package/dist/playground-island-runtime.js +3 -2
- package/dist/primitives/FrameShell.js +0 -1
- package/dist/primitives/Image.d.ts +5 -4
- package/dist/primitives/Tour.d.ts +1 -1
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/index.d.ts +2 -3
- package/dist/primitives/picture-sources.js +2 -2
- package/dist/primitives/probe-context.js +2 -12
- package/dist/primitives/slot-address.d.ts +44 -0
- package/dist/primitives/slot-address.js +19 -0
- package/dist/primitives/slot-bindings.d.ts +65 -26
- package/dist/primitives/slot-bindings.js +104 -46
- package/dist/primitives/slot-document.d.ts +23 -18
- package/dist/primitives/slot-document.js +39 -14
- package/dist/primitives/slot-download.d.ts +39 -0
- package/dist/primitives/slot-download.js +39 -0
- package/dist/primitives/slot-list.d.ts +3 -3
- package/dist/primitives/slot-list.js +0 -2
- package/dist/primitives/slot-media.d.ts +24 -5
- package/dist/primitives/slot-media.js +6 -9
- package/dist/primitives/slot-object.d.ts +49 -0
- package/dist/primitives/slot-object.js +20 -0
- package/dist/primitives/slot-scalar.d.ts +27 -2
- package/dist/primitives/slot-scalar.js +50 -7
- package/dist/primitives/slot.d.ts +13 -6
- package/dist/primitives/slot.js +10 -3
- package/dist/rules/registry.js +19 -30
- package/dist/schema/define-schema.d.ts +4 -8
- package/dist/schema/define-schema.js +178 -79
- package/dist/schema/extract-fill-spec.js +2 -158
- package/dist/schema/fact.d.ts +57 -15
- package/dist/schema/fact.js +42 -7
- package/dist/schema/facts-view.d.ts +14 -0
- package/dist/schema/format.d.ts +1 -0
- package/dist/schema/format.js +2 -1
- package/dist/schema/manifest.js +24 -0
- package/dist/schema/property-facts.d.ts +8 -11
- package/dist/schema/section-props.d.ts +2 -66
- package/dist/schema/section-schema.d.ts +8 -11
- package/dist/schema/section-schema.js +27 -10
- package/dist/section/declare.d.ts +18 -7
- package/dist/section/declare.js +18 -5
- package/dist/section/materialize.js +3 -8
- package/dist/section/section.d.ts +12 -8
- package/dist/section/section.js +1 -1
- package/dist/template/logic-shim.d.ts +14 -7
- package/dist/template/logic-shim.js +14 -7
- package/dist/template/materialize.js +17 -18
- package/dist/template/mirror-types.js +30 -31
- package/dist/template/section-reads.js +85 -9
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +29 -29
- package/package.json +9 -8
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
- package/dist/artifact/playground/client/assets/index-D8eepVr-.js +0 -1101
- package/dist/fixtures/canonical.d.ts +0 -166
- package/dist/fixtures/media.js +0 -163
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -111
- package/dist/packages/internal/format-geometry/dist/index.js +0 -4
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
- package/dist/packages/internal/property-facts/dist/index.js +0 -3
- package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +0 -22
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +0 -15
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
- package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -111
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
- package/dist/primitives/slot-group.d.ts +0 -40
- package/dist/primitives/slot-group.js +0 -36
- package/dist/schema/extract-used-facts.js +0 -34
- package/dist/schema/fill-builders.d.ts +0 -115
- package/dist/schema/fill-builders.js +0 -25
- package/dist/schema/fill-declaration.d.ts +0 -14
- package/dist/schema/fill-spec.js +0 -89
- package/dist/schema/layout.d.ts +0 -30
- package/dist/schema/layout.js +0 -14
- package/dist/schema/row-fields.js +0 -88
- package/dist/schema/row-ref.d.ts +0 -59
- package/dist/schema/row-ref.js +0 -28
- package/dist/schema/runtime-values.d.ts +0 -71
- package/dist/schema/section-nav.js +0 -14
- package/dist/schema/slot-builders.d.ts +0 -613
- package/dist/schema/slot-builders.js +0 -177
- package/dist/schema/slot-ref.d.ts +0 -79
- package/dist/schema/slot-ref.js +0 -41
- package/dist/schema/slot-types.d.ts +0 -111
- package/dist/schema/slot-types.js +0 -214
- package/dist/section/groups.js +0 -68
package/dist/fixtures/resolve.js
CHANGED
|
@@ -1,26 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { normalizeAddressValue } from "../packages/internal/template-contracts/dist/address-value.js";
|
|
2
|
+
import { REGISTRY_TABLE_KEYS, declaredKinds, isEmailValue, isIsoDateValue, isMediaType, isPhoneValue } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
3
|
+
import { getComputed } from "../packages/internal/template-contracts/dist/compute.js";
|
|
4
|
+
import { elementIdentityKey, heldRowTableOf, listTableOf, placementOf, rowTablesOf } from "../packages/internal/template-contracts/dist/ref-locate.js";
|
|
5
|
+
import { fillSpecFromSchema } from "../schema/extract-fill-spec.js";
|
|
6
|
+
import { elementRowKeys, listSourceOf, memberSourceOf } from "../packages/internal/template-contracts/dist/row-sources.js";
|
|
7
|
+
import { objectFieldSlotId } from "../packages/internal/template-contracts/dist/slot-overrides.js";
|
|
8
|
+
import { tableRowIds } from "../packages/internal/source-resolution/dist/index.js";
|
|
9
|
+
import { bakeDisplayEntries, bakePropertyRefSlots } from "../packages/internal/fill-bake/dist/bake-property-ref.js";
|
|
10
|
+
import { applyComputeReads } from "../packages/internal/fill-bake/dist/compute-reads.js";
|
|
8
11
|
import "../packages/internal/fill-bake/dist/index.js";
|
|
9
12
|
import { canonicalizeProperty, contactImageId } from "./property.js";
|
|
10
|
-
import { blankForField
|
|
13
|
+
import { blankForField } from "./rows.js";
|
|
11
14
|
|
|
12
15
|
//#region src/fixtures/resolve.ts
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const VALIDATED_KINDS = {
|
|
17
|
+
date: {
|
|
18
|
+
admits: (value) => value === null || isIsoDateValue(value),
|
|
19
|
+
expected: "a real calendar day written \"YYYY-MM-DD\", or null for none"
|
|
20
|
+
},
|
|
21
|
+
email: {
|
|
22
|
+
admits: (value) => value == null || value === "" || isEmailValue(value),
|
|
23
|
+
expected: "an email address"
|
|
24
|
+
},
|
|
25
|
+
phone: {
|
|
26
|
+
admits: (value) => value == null || value === "" || isPhoneValue(value),
|
|
27
|
+
expected: "a phone number a dialer can call"
|
|
28
|
+
}
|
|
29
|
+
};
|
|
19
30
|
function emptyValueFor(type) {
|
|
20
|
-
|
|
31
|
+
if (type === "list") return [];
|
|
32
|
+
return type === "object" ? {} : null;
|
|
21
33
|
}
|
|
22
34
|
function isEmptyValue(value, type) {
|
|
23
|
-
|
|
35
|
+
if (type === "list") return Array.isArray(value) && value.length === 0;
|
|
36
|
+
if (type === "object") return typeof value === "object" && value !== null && Object.keys(value).length === 0;
|
|
37
|
+
return value === null || value === void 0;
|
|
24
38
|
}
|
|
25
39
|
function uniquePlacements(placements) {
|
|
26
40
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -51,29 +65,50 @@ function resolveFixture(loaded, options) {
|
|
|
51
65
|
if (entriesByInstance.has(instance)) throw new Error(`Fixture "${loaded.id}" (${module}) states content twice for instance "${instance}".`);
|
|
52
66
|
entriesByInstance.set(instance, entry);
|
|
53
67
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
const ctx = {
|
|
69
|
+
facts,
|
|
70
|
+
media,
|
|
71
|
+
module,
|
|
72
|
+
fixtureId: loaded.id,
|
|
73
|
+
log: options.log,
|
|
74
|
+
violations
|
|
75
|
+
};
|
|
76
|
+
const filled = placements.map((placement) => fillInstance(placement, entriesByInstance.get(placement.instance), ctx));
|
|
77
|
+
const pages = [{
|
|
78
|
+
id: "fixture",
|
|
79
|
+
sections: placements.map((p) => ({
|
|
80
|
+
section: p.key,
|
|
81
|
+
instance_id: p.instance
|
|
82
|
+
}))
|
|
83
|
+
}];
|
|
84
|
+
const settled = applyComputeReads({
|
|
85
|
+
contentDoc: { instances: filled.map((f) => f.instance) },
|
|
86
|
+
facts,
|
|
87
|
+
sections: new Map(filled.map((f) => [f.instance.instance_id, f.section])),
|
|
88
|
+
placement: placementOf(pages)
|
|
89
|
+
}).contentDoc;
|
|
69
90
|
const instances = [];
|
|
70
91
|
const provenance = {};
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
settled.instances.forEach((instance, index) => {
|
|
93
|
+
const { placement, values } = filled[index];
|
|
94
|
+
const schemaSlots = placement.section.schema.slots;
|
|
95
|
+
const slots = {};
|
|
96
|
+
const provenanceOf = {};
|
|
97
|
+
for (const [id, def] of Object.entries(schemaSlots)) {
|
|
98
|
+
const cases = def.variant?.cases;
|
|
99
|
+
if (cases !== void 0 && (instance.variant === void 0 || !cases.includes(instance.variant))) continue;
|
|
100
|
+
slots[id] = instance.slots[id];
|
|
101
|
+
provenanceOf[id] = provenanceFor(def, id, values[id], slots[id], facts);
|
|
102
|
+
}
|
|
103
|
+
instances.push({
|
|
104
|
+
instance_id: instance.instance_id,
|
|
105
|
+
section_key: placement.section.key,
|
|
106
|
+
enabled: instance.enabled,
|
|
107
|
+
...instance.variant === void 0 ? {} : { variant: instance.variant },
|
|
108
|
+
slots
|
|
109
|
+
});
|
|
110
|
+
provenance[instance.instance_id] = provenanceOf;
|
|
111
|
+
});
|
|
77
112
|
return {
|
|
78
113
|
resolved: {
|
|
79
114
|
id: loaded.id,
|
|
@@ -88,254 +123,229 @@ function resolveFixture(loaded, options) {
|
|
|
88
123
|
violations
|
|
89
124
|
};
|
|
90
125
|
}
|
|
91
|
-
function
|
|
92
|
-
const sections = /* @__PURE__ */ new Map();
|
|
93
|
-
for (const placement of placements) if (!sections.has(placement.key)) sections.set(placement.key, placement.section);
|
|
94
|
-
const rank = new Map(buildReadGraph(sections).order.map((key, index) => [key, index]));
|
|
95
|
-
return [...placements].sort((a, b) => (rank.get(a.key) ?? 0) - (rank.get(b.key) ?? 0));
|
|
96
|
-
}
|
|
97
|
-
function valuesFor(reads, facts, settled, own) {
|
|
98
|
-
return reads.map((ref) => {
|
|
99
|
-
if (ref.kind === "fact") return readFact(facts, ref.key);
|
|
100
|
-
if (ref.kind === "row") return void 0;
|
|
101
|
-
if (ref.section === own?.section) return own.slots[ref.slot];
|
|
102
|
-
const from = settled.get(ref.section);
|
|
103
|
-
if (from === void 0) return void 0;
|
|
104
|
-
if (ref.slot === "display.visibility") return from.visibility;
|
|
105
|
-
if (ref.slot === "display.variant") return from.variant;
|
|
106
|
-
return from.slots[ref.slot];
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
function sameSectionOrder(sectionKey, declared) {
|
|
110
|
-
const ordered = [];
|
|
111
|
-
const visited = /* @__PURE__ */ new Set();
|
|
112
|
-
const visit = (id) => {
|
|
113
|
-
const slot = declared.get(id);
|
|
114
|
-
if (slot === void 0 || visited.has(id)) return;
|
|
115
|
-
visited.add(id);
|
|
116
|
-
for (const ref of slot.reads) if (isSerializedSlotRef(ref) && ref.section === sectionKey) visit(ref.slot);
|
|
117
|
-
ordered.push([id, slot]);
|
|
118
|
-
};
|
|
119
|
-
for (const id of declared.keys()) visit(id);
|
|
120
|
-
return ordered;
|
|
121
|
-
}
|
|
122
|
-
function declaredReads(source) {
|
|
123
|
-
if (typeof source !== "object" || source === null) return [];
|
|
124
|
-
const reads = source.reads;
|
|
125
|
-
return Array.isArray(reads) ? reads : [];
|
|
126
|
-
}
|
|
127
|
-
function runDeclared(fns, transform, values) {
|
|
128
|
-
const fn = fns[transform];
|
|
129
|
-
if (fn === void 0) return null;
|
|
126
|
+
function pickDecisions(schema) {
|
|
130
127
|
try {
|
|
131
|
-
return
|
|
128
|
+
return fillSpecFromSchema(schema).decisions;
|
|
132
129
|
} catch {
|
|
133
|
-
return
|
|
130
|
+
return [];
|
|
134
131
|
}
|
|
135
132
|
}
|
|
136
|
-
function
|
|
137
|
-
const declared = /* @__PURE__ */ new Set();
|
|
138
|
-
const record = (source) => {
|
|
139
|
-
const reads = declaredReads(source);
|
|
140
|
-
const transform = source?.transform;
|
|
141
|
-
if (reads.length > 0 && typeof transform === "string") declared.add(transform);
|
|
142
|
-
};
|
|
143
|
-
for (const slot of Object.values(schema.slots)) record(slot.source);
|
|
144
|
-
const display = schema.meta.display;
|
|
145
|
-
for (const entry of ["visibility", "variant"]) record(display?.[entry]?.source);
|
|
146
|
-
return Object.fromEntries(Object.entries(getComputed(schema)).filter(([handle]) => !declared.has(handle)));
|
|
147
|
-
}
|
|
148
|
-
function resolveInstance(placement, entry, ctx) {
|
|
133
|
+
function fillInstance(placement, entry, ctx) {
|
|
149
134
|
const section = placement.section;
|
|
150
135
|
const { schema } = section;
|
|
151
|
-
const
|
|
152
|
-
|
|
136
|
+
const schemaSlots = schema.slots;
|
|
137
|
+
const bakeContext = {
|
|
138
|
+
computed: getComputed(schema),
|
|
153
139
|
section_key: section.key,
|
|
154
140
|
log: ctx.log
|
|
155
141
|
};
|
|
156
|
-
const
|
|
157
|
-
const display = schema.meta.display ?? {};
|
|
158
|
-
const resolvedDisplay = bakeDisplayEntries({ display }, ctx.facts, bakeCtx);
|
|
159
|
-
const computeFns = getComputed(schema);
|
|
160
|
-
const factsView = buildDeriveFactsView(ctx.facts);
|
|
142
|
+
const decisions = pickDecisions(schema);
|
|
161
143
|
const values = entry?.values ?? {};
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
144
|
+
const fill = {
|
|
145
|
+
decisions,
|
|
146
|
+
heldRows: {},
|
|
147
|
+
at: (slot) => ({
|
|
148
|
+
...ctx,
|
|
149
|
+
instance: placement.instance,
|
|
150
|
+
slot
|
|
151
|
+
})
|
|
169
152
|
};
|
|
170
|
-
|
|
171
|
-
for (const [
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
let own;
|
|
176
|
-
if (reads.some((ref) => isSerializedSlotRef(ref) && ref.section === section.key)) {
|
|
177
|
-
ungated ??= buildSlots(slotPass, {
|
|
178
|
-
...ctx,
|
|
179
|
-
violations: [],
|
|
180
|
-
log: void 0
|
|
181
|
-
}, null).slots;
|
|
182
|
-
own = {
|
|
183
|
-
section: section.key,
|
|
184
|
-
slots: ungated
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
const answered = runDeclared(computeFns, transform, valuesFor(reads, factsView, ctx.settled, own));
|
|
188
|
-
const answer = typeof answered?.value === "string" ? answered.value : "";
|
|
189
|
-
if (entryDef?.cases?.includes(answer) === true) resolvedDisplay[entryName] = answer;
|
|
190
|
-
else delete resolvedDisplay[entryName];
|
|
153
|
+
const stated = {};
|
|
154
|
+
for (const [id, def] of Object.entries(schemaSlots)) {
|
|
155
|
+
const value = statedValue(fill, def, id, values[id], true);
|
|
156
|
+
if (value !== void 0) stated[id] = value;
|
|
157
|
+
reportRows(ctx, placement.instance, def, id, values[id]);
|
|
191
158
|
}
|
|
192
|
-
const
|
|
193
|
-
|
|
159
|
+
const bakeScope = {
|
|
160
|
+
decisions,
|
|
161
|
+
heldRows: fill.heldRows,
|
|
162
|
+
stored: stated
|
|
163
|
+
};
|
|
164
|
+
const baked = bakePropertyRefSlots(schema, ctx.facts, bakeContext, bakeScope);
|
|
165
|
+
const slots = {};
|
|
166
|
+
for (const [id, def] of Object.entries(schemaSlots)) slots[id] = slotValue(def, id, Object.hasOwn(baked, id) ? { value: baked[id] } : void 0, stated[id], decisions);
|
|
167
|
+
const display = schema.meta.display ?? {};
|
|
168
|
+
const baked_display = bakeDisplayEntries({
|
|
169
|
+
display,
|
|
170
|
+
slots: schemaSlots
|
|
171
|
+
}, ctx.facts, bakeContext, bakeScope);
|
|
172
|
+
const visibility = baked_display.visibility ?? display.visibility?.cases?.[0];
|
|
194
173
|
const declaredCases = display.variant?.cases;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
174
|
+
if (typeof values.variant === "string" && declaredCases?.includes(values.variant) !== true) throw new Error(`Fixture "${ctx.fixtureId}" (${ctx.module}): content for "${placement.instance}" names variant "${values.variant}", which section "${section.key}" does not declare.`);
|
|
175
|
+
const variant = typeof values.variant === "string" ? values.variant : baked_display.variant ?? declaredCases?.[0];
|
|
176
|
+
const overrides = {
|
|
177
|
+
...typeof values.enabled === "boolean" ? { visibility: true } : {},
|
|
178
|
+
...typeof values.variant === "string" ? { variant: true } : {}
|
|
179
|
+
};
|
|
201
180
|
return {
|
|
181
|
+
placement,
|
|
202
182
|
instance: {
|
|
203
183
|
instance_id: placement.instance,
|
|
204
|
-
|
|
205
|
-
enabled,
|
|
184
|
+
enabled: typeof values.enabled === "boolean" ? values.enabled : visibility === void 0 ? true : visibility !== "hidden",
|
|
206
185
|
...variant === void 0 ? {} : { variant },
|
|
207
|
-
slots
|
|
208
|
-
},
|
|
209
|
-
provenance,
|
|
210
|
-
settled: {
|
|
211
186
|
slots,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
187
|
+
...Object.keys(overrides).length === 0 ? {} : { display_overrides: overrides }
|
|
188
|
+
},
|
|
189
|
+
section: {
|
|
190
|
+
localKey: section.key,
|
|
191
|
+
schema: {
|
|
192
|
+
slots: schema.slots,
|
|
193
|
+
display
|
|
194
|
+
},
|
|
195
|
+
bakeContext
|
|
196
|
+
},
|
|
197
|
+
values
|
|
215
198
|
};
|
|
216
199
|
}
|
|
217
|
-
function
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const reads = declaredReads(source);
|
|
243
|
-
if (reads.length > 0) {
|
|
244
|
-
const fields = def.type === "list" ? def.fields : void 0;
|
|
245
|
-
declared.set(id, {
|
|
246
|
-
transform: source.transform,
|
|
247
|
-
reads,
|
|
248
|
-
type: def.type,
|
|
249
|
-
...fields === void 0 ? {} : { fields }
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
slots[id] = baked[id] ?? null;
|
|
253
|
-
provenance[id] = {
|
|
254
|
-
kind: "computed",
|
|
255
|
-
ref: source.transform
|
|
200
|
+
function statedValue(fill, def, path, value, holds) {
|
|
201
|
+
if (value === void 0 || value === null) return void 0;
|
|
202
|
+
if (def.type === "row") {
|
|
203
|
+
if (typeof value !== "string") return void 0;
|
|
204
|
+
if (holds) fill.heldRows[path] = value;
|
|
205
|
+
return value;
|
|
206
|
+
}
|
|
207
|
+
if (def.type === "object") {
|
|
208
|
+
if (!isRecord(value)) return void 0;
|
|
209
|
+
return statedFields(fill, def.fields, path, value, holds);
|
|
210
|
+
}
|
|
211
|
+
if (def.type === "list" && def.element?.type === "object") {
|
|
212
|
+
if (!Array.isArray(value)) return void 0;
|
|
213
|
+
const fields = def.element.fields;
|
|
214
|
+
const table = filledListTable(def);
|
|
215
|
+
const identityKey = elementIdentityKey(table?.table ?? null);
|
|
216
|
+
const elementRows = elementRowKeys(fields);
|
|
217
|
+
return value.map((item, i) => {
|
|
218
|
+
const record = isRecord(item) ? item : {};
|
|
219
|
+
const out = statedFields(fill, fields, path, record, false);
|
|
220
|
+
const held = elementRows.map((key) => record[key]).find((id) => typeof id === "string" && id !== "");
|
|
221
|
+
const id = table === null ? record["id"] ?? `${path}-${String(i + 1)}` : held ?? record[identityKey] ?? record["id"];
|
|
222
|
+
return {
|
|
223
|
+
[identityKey]: id,
|
|
224
|
+
...out
|
|
256
225
|
};
|
|
257
|
-
continue;
|
|
258
|
-
}
|
|
259
|
-
const stated = values[id];
|
|
260
|
-
if (stated === void 0 || stated === null) {
|
|
261
|
-
slots[id] = emptyValueFor(def.type);
|
|
262
|
-
provenance[id] = { kind: "empty" };
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
slots[id] = authoredValue(def, stated, {
|
|
266
|
-
...ctx,
|
|
267
|
-
instance: placement.instance,
|
|
268
|
-
slot: id
|
|
269
226
|
});
|
|
270
|
-
provenance[id] = { kind: "authored" };
|
|
271
227
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
228
|
+
if (def.type === "list" && def.element?.type === "row") return Array.isArray(value) ? value.filter((id) => typeof id === "string") : void 0;
|
|
229
|
+
return authoredValue(def, value, fill.at(path));
|
|
230
|
+
}
|
|
231
|
+
function statedFields(fill, fields, path, value, holds) {
|
|
232
|
+
const out = {};
|
|
233
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
234
|
+
const stated = statedValue(fill, field, objectFieldSlotId(path, key), value[key], holds);
|
|
235
|
+
if (stated !== void 0) out[key] = stated;
|
|
279
236
|
}
|
|
280
|
-
return
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
237
|
+
return out;
|
|
238
|
+
}
|
|
239
|
+
function filledListTable(def) {
|
|
240
|
+
if (listSourceOf(def).kind !== "none" || memberSourceOf(def.source) !== null) return null;
|
|
241
|
+
return listTableOf({ slots: {} }, def);
|
|
284
242
|
}
|
|
285
|
-
function
|
|
286
|
-
if (!Array.isArray(
|
|
287
|
-
if (
|
|
288
|
-
const
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
243
|
+
function reportRows(ctx, instance, def, path, value) {
|
|
244
|
+
if (def.type !== "list" || !Array.isArray(value)) return;
|
|
245
|
+
if (listSourceOf(def).kind !== "table") return;
|
|
246
|
+
const table = listTableOf({ slots: {} }, def);
|
|
247
|
+
const carried = table === null ? 0 : tableRowIds(table, ctx.facts).length;
|
|
248
|
+
if (value.length <= carried) return;
|
|
249
|
+
ctx.violations.push({
|
|
292
250
|
rule: "fixtures/rows-not-in-property",
|
|
293
251
|
file: ctx.module,
|
|
294
|
-
message: `fixture "${ctx.fixtureId}": "${
|
|
252
|
+
message: `fixture "${ctx.fixtureId}": "${instance}".${path} states ${String(value.length)} items, but its property carries ${String(carried)} — the rows of a list sourced by a table are the property's`
|
|
295
253
|
});
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
const statedRow = statedRows[index];
|
|
307
|
-
if (typeof statedRow !== "object" || statedRow === null || Array.isArray(statedRow)) return out;
|
|
308
|
-
for (const [field, fieldDef] of Object.entries(fields)) {
|
|
309
|
-
if (fieldDef.source !== void 0) continue;
|
|
310
|
-
const value = statedRow[field];
|
|
311
|
-
if (value === void 0 || value === null) continue;
|
|
312
|
-
out[field] = authoredValue(fieldDef, value, ctx);
|
|
254
|
+
}
|
|
255
|
+
function slotValue(def, path, baked, stated, decisions) {
|
|
256
|
+
if (def.type === "object") {
|
|
257
|
+
const fields = def.fields;
|
|
258
|
+
const bakedFields = isRecord(baked?.value) ? baked.value : {};
|
|
259
|
+
const statedFields = isRecord(stated) ? stated : {};
|
|
260
|
+
const out = {};
|
|
261
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
262
|
+
const fieldPath = objectFieldSlotId(path, key);
|
|
263
|
+
out[key] = Object.hasOwn(bakedFields, key) ? fieldValue(field, fieldPath, { value: bakedFields[key] }, statedFields[key], decisions) : fieldValue(field, fieldPath, void 0, statedFields[key], decisions);
|
|
313
264
|
}
|
|
314
265
|
return out;
|
|
266
|
+
}
|
|
267
|
+
if (def.type === "list" && def.element?.type === "object" && Array.isArray(baked?.value)) return itemsValue(def, path, baked.value, stated, decisions);
|
|
268
|
+
if (baked !== void 0) return baked.value ?? emptyValueFor(def.type);
|
|
269
|
+
if (def.source === void 0 && stated !== void 0) return stated;
|
|
270
|
+
return emptyValueFor(def.type);
|
|
271
|
+
}
|
|
272
|
+
function fieldValue(def, path, baked, stated, decisions) {
|
|
273
|
+
if (def.type === "object" || def.type === "list" && def.element?.type === "object" && Array.isArray(baked?.value)) return slotValue(def, path, baked, stated, decisions);
|
|
274
|
+
if (baked !== void 0) return baked.value;
|
|
275
|
+
if (def.source === void 0 && stated !== void 0) return stated;
|
|
276
|
+
return blankForField(def);
|
|
277
|
+
}
|
|
278
|
+
function itemsValue(def, path, items, stated, decisions) {
|
|
279
|
+
const fields = def.element?.fields ?? {};
|
|
280
|
+
const identityKey = elementIdentityKey(listTableOf({ slots: {} }, def)?.table ?? null);
|
|
281
|
+
const statedItems = Array.isArray(stated) ? stated.filter(isRecord) : [];
|
|
282
|
+
const byIdentity = listSourceOf(def).kind === "none" && memberSourceOf(def.source) === null;
|
|
283
|
+
return items.map((item, i) => {
|
|
284
|
+
const baked = isRecord(item) ? item : {};
|
|
285
|
+
const statedItem = byIdentity ? statedItems.find((candidate) => candidate[identityKey] === baked[identityKey]) : statedItems[i];
|
|
286
|
+
const out = { [identityKey]: baked[identityKey] };
|
|
287
|
+
for (const [key, field] of Object.entries(fields)) out[key] = fieldValue(field, `${path}.${key}`, Object.hasOwn(baked, key) ? { value: baked[key] } : void 0, statedItem?.[key], decisions);
|
|
288
|
+
return out;
|
|
315
289
|
});
|
|
316
290
|
}
|
|
291
|
+
function storedTableKey(key) {
|
|
292
|
+
return key.reading === "legacy" ? key.table : REGISTRY_TABLE_KEYS[key.table];
|
|
293
|
+
}
|
|
294
|
+
function provenanceFor(def, id, stated, value, facts) {
|
|
295
|
+
const source = def.source;
|
|
296
|
+
if (def.type === "object") return { kind: "authored" };
|
|
297
|
+
if (def.type === "row") {
|
|
298
|
+
if (typeof stated === "string") return { kind: "authored" };
|
|
299
|
+
const table = heldRowTableOf(facts, rowTablesOf(def), typeof value === "string" ? value : null);
|
|
300
|
+
return table !== null ? {
|
|
301
|
+
kind: "fact",
|
|
302
|
+
ref: storedTableKey(table)
|
|
303
|
+
} : { kind: "empty" };
|
|
304
|
+
}
|
|
305
|
+
if (source?.kind === "home") return {
|
|
306
|
+
kind: "fact",
|
|
307
|
+
ref: String(source.key)
|
|
308
|
+
};
|
|
309
|
+
if (source?.kind === "derived") return {
|
|
310
|
+
kind: "computed",
|
|
311
|
+
ref: String(source.transform)
|
|
312
|
+
};
|
|
313
|
+
if (source?.kind === "section") return {
|
|
314
|
+
kind: "computed",
|
|
315
|
+
ref: id
|
|
316
|
+
};
|
|
317
|
+
const member = memberSourceOf(source);
|
|
318
|
+
if (member !== null) return {
|
|
319
|
+
kind: "fact",
|
|
320
|
+
ref: `${member.slot}.${member.field}`
|
|
321
|
+
};
|
|
322
|
+
if (source?.kind === "element") return {
|
|
323
|
+
kind: "fact",
|
|
324
|
+
ref: "element"
|
|
325
|
+
};
|
|
326
|
+
return isEmptyValue(value, def.type) ? { kind: "empty" } : { kind: "authored" };
|
|
327
|
+
}
|
|
328
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
317
329
|
function authoredValue(def, value, ctx) {
|
|
318
|
-
if (
|
|
319
|
-
if (def.type === "
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return value.map((item) => authoredValue(element, item, ctx));
|
|
333
|
-
}
|
|
330
|
+
if (isMediaType(def.type)) return mediaRef(def, value, ctx);
|
|
331
|
+
if (def.type === "address") return normalizeAddressValue(value);
|
|
332
|
+
const validated = VALIDATED_KINDS[def.type];
|
|
333
|
+
if (validated !== void 0 && !validated.admits(value)) {
|
|
334
|
+
ctx.violations.push({
|
|
335
|
+
rule: "fixtures/value-invalid",
|
|
336
|
+
file: ctx.module,
|
|
337
|
+
message: `fixture "${ctx.fixtureId}": "${ctx.instance}".${ctx.slot} (${def.type}) states ${JSON.stringify(value)}; it takes ${validated.expected}`
|
|
338
|
+
});
|
|
339
|
+
return emptyValueFor(def.type);
|
|
340
|
+
}
|
|
341
|
+
if (def.type === "list" && Array.isArray(value) && def.element !== void 0 && def.element.type !== "object" && def.element.type !== "row") {
|
|
342
|
+
const element = def.element;
|
|
343
|
+
return value.map((item) => authoredValue(element, item, ctx)).filter((item) => item !== null && item !== void 0);
|
|
334
344
|
}
|
|
335
345
|
return value;
|
|
336
346
|
}
|
|
337
347
|
const CONTACT_IMAGE_FIELDS = /* @__PURE__ */ new Set([
|
|
338
|
-
"
|
|
348
|
+
"headshot",
|
|
339
349
|
"logo_dark",
|
|
340
350
|
"logo_light"
|
|
341
351
|
]);
|
|
@@ -351,11 +361,13 @@ function contactImage(value) {
|
|
|
351
361
|
field
|
|
352
362
|
};
|
|
353
363
|
}
|
|
354
|
-
function mediaRef(
|
|
355
|
-
const
|
|
364
|
+
function mediaRef(def, value, ctx) {
|
|
365
|
+
const kind = def.type;
|
|
366
|
+
const kinds = declaredKinds(def);
|
|
367
|
+
const stated = kinds.includes("image") ? contactImage(value) : null;
|
|
356
368
|
const id = stated?.id ?? (typeof value === "object" && value !== null ? value.id : void 0);
|
|
357
369
|
const carried = typeof id === "string" ? ctx.media.get(id) : void 0;
|
|
358
|
-
if (carried === void 0 || carried.kind
|
|
370
|
+
if (carried === void 0 || !kinds.includes(carried.kind)) {
|
|
359
371
|
const what = stated !== null ? `the "${stated.field}" of contact "${stated.contact}", which its property does not carry` : typeof id === "string" ? `${kind} "${id}", which its property does not carry` : `a value that is not a ${kind} entry of its property`;
|
|
360
372
|
ctx.violations.push({
|
|
361
373
|
rule: "fixtures/media-not-in-property",
|
package/dist/fixtures/rows.js
CHANGED
|
@@ -3,7 +3,9 @@ function blankForField(def) {
|
|
|
3
3
|
switch (def.type) {
|
|
4
4
|
case "text":
|
|
5
5
|
case "select":
|
|
6
|
-
case "url":
|
|
6
|
+
case "url":
|
|
7
|
+
case "email":
|
|
8
|
+
case "phone": return "";
|
|
7
9
|
case "video": return {
|
|
8
10
|
video_id: "",
|
|
9
11
|
url: "",
|
|
@@ -20,15 +22,6 @@ function blankForField(def) {
|
|
|
20
22
|
default: return null;
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
function canonicalizeRows(slot, value) {
|
|
24
|
-
if (!Array.isArray(value)) return value;
|
|
25
|
-
const blank = {};
|
|
26
|
-
for (const [field, def] of Object.entries(slot.fields ?? {})) blank[field] = blankForField(def);
|
|
27
|
-
return value.map((row) => typeof row === "object" && row !== null && !Array.isArray(row) ? {
|
|
28
|
-
...blank,
|
|
29
|
-
...row
|
|
30
|
-
} : row);
|
|
31
|
-
}
|
|
32
25
|
|
|
33
26
|
//#endregion
|
|
34
|
-
export { blankForField
|
|
27
|
+
export { blankForField };
|