@homepages/concrete 12.0.0 → 13.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 +184 -0
- package/README.md +8 -10
- package/codemods/fixtures-are-data.mjs +7 -0
- package/codemods/fixtures-list-properties.mjs +6 -0
- package/codemods/manifest.json +11 -0
- package/codemods/steps/fixtures-list-properties.mjs +16 -0
- package/codemods/steps/fixtures-to-data.mjs +41 -0
- package/dist/artifact/playground/client/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
- package/dist/artifact/playground/client/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
- package/dist/artifact/playground/client/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
- package/dist/artifact/playground/client/assets/index-Bmvcss4B.js +1338 -0
- package/dist/artifact/playground/client/assets/index-C01UCAWD.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 +110 -59
- package/dist/base.css +2 -2
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/index.js +11 -10
- package/dist/cli/build/manifest.js +44 -0
- package/dist/cli/build/record.js +123 -0
- package/dist/cli/build/sections.js +28 -18
- package/dist/cli/build/source.js +1 -1
- package/dist/cli/build/static.js +8 -5
- package/dist/cli/build/template-build.js +614 -0
- package/dist/cli/check/analyze.js +18 -1
- package/dist/cli/check/load-workspace.js +2 -2
- package/dist/cli/check/portable-names.js +1 -1
- package/dist/cli/check/render/corpus.js +119 -0
- package/dist/cli/check/render/invariants.js +1 -0
- package/dist/cli/check/stages/bundles.js +15 -18
- package/dist/cli/check/stages/composition.js +8 -25
- package/dist/cli/check/stages/fixtures.js +14 -10
- package/dist/cli/check/stages/logic.js +7 -23
- package/dist/cli/check/stages/render.js +12 -14
- package/dist/cli/check/stages/sections.js +22 -66
- package/dist/cli/check/stages/stylesheet.js +4 -26
- package/dist/cli/check/stages/workspace.js +27 -22
- package/dist/cli/commands.js +51 -23
- package/dist/cli/currency/preamble.js +1 -1
- package/dist/cli/currency/resolve-latest.js +3 -2
- package/dist/cli/dev/capture-browser.js +26 -0
- package/dist/cli/dev/fixture-schema.js +441 -0
- package/dist/cli/dev/folder-files.js +244 -0
- package/dist/cli/dev/index.js +7 -3
- package/dist/cli/dev/playground-server.js +34 -0
- package/dist/cli/dev/section-ladders.js +76 -0
- package/dist/cli/dev/server.js +120 -304
- package/dist/cli/install/background.js +16 -0
- package/dist/cli/install/index.js +45 -0
- package/dist/cli/install/tools.js +27 -0
- package/dist/cli/media/derive.js +19 -13
- package/dist/cli/media/deriver-plugin.js +14 -3
- package/dist/cli/property/fixture-list.js +46 -0
- package/dist/cli/property/index.js +12 -9
- package/dist/cli/property/library.js +12 -10
- package/dist/cli/publish/artifact.js +90 -0
- package/dist/cli/publish/captures.js +61 -0
- package/dist/cli/publish/fixtures.js +17 -0
- package/dist/cli/publish/index.js +10 -18
- package/dist/cli/{build → publish}/playground.js +3 -3
- package/dist/cli/publish/report.js +15 -33
- package/dist/cli/upgrade/codemod.d.ts +14 -0
- package/dist/cli/upgrade/fixture-conversion.d.ts +11 -0
- package/dist/cli/upgrade/fixture-conversion.js +54 -0
- package/dist/cli/upgrade/fixture-modules.js +125 -0
- package/dist/cli/upgrade/fixtures-to-data.d.ts +40 -0
- package/dist/cli/upgrade/fixtures-to-data.js +498 -0
- package/dist/cli/upgrade/index.js +18 -2
- package/dist/cli/upgrade/legacy-fixtures.d.ts +34 -0
- package/dist/cli/upgrade/legacy-fixtures.js +22 -0
- package/dist/cli/upgrade/stage.js +1 -1
- package/dist/cli/workspace-fixtures.js +80 -0
- package/dist/cli.js +1 -0
- package/dist/css/compile.js +9 -3
- package/dist/fixtures/bundle-rule.js +16 -16
- package/dist/fixtures/media-plugin.js +12 -33
- package/dist/fixtures/synthesize-empties.js +3 -2
- package/dist/index.d.ts +7 -7
- package/dist/{playground-island-runtime.d.ts → island-runtime.d.ts} +1 -2
- package/dist/{playground-island-runtime.js → island-runtime.js} +1 -2
- package/dist/islands/client-module.js +1 -1
- package/dist/{cli/dev → islands}/tsconfig-paths.js +2 -14
- package/dist/islands/wrap.js +40 -0
- package/dist/node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.js +5119 -0
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/bundle-evaluation/dist/cache.js +36 -0
- package/dist/packages/internal/bundle-evaluation/dist/evaluate.js +174 -0
- package/dist/packages/internal/bundle-evaluation/dist/index.js +5 -0
- package/dist/packages/internal/bundle-evaluation/dist/section-code.js +10 -0
- package/dist/packages/internal/capture-settle/dist/index.js +2 -2
- package/dist/packages/internal/capture-settle/dist/settle.js +88 -13
- package/dist/packages/internal/code-fingerprint/dist/index.js +57 -0
- package/dist/packages/internal/content-doc-ops/dist/index.js +176 -0
- package/dist/packages/internal/content-doc-ops/dist/made-rows.js +15 -0
- package/dist/packages/internal/deliverable-reads/dist/bootstrap.js +81 -0
- package/dist/packages/internal/deliverable-reads/dist/display.js +21 -0
- package/dist/packages/internal/deliverable-reads/dist/format.js +15 -0
- package/dist/packages/internal/deliverable-reads/dist/index.js +7 -0
- package/dist/packages/internal/deliverable-reads/dist/pages.js +29 -0
- package/dist/packages/internal/deliverable-reads/dist/requirements.js +72 -0
- package/dist/{cli/capture → packages/internal/download-files/dist}/bundle.js +8 -4
- package/dist/packages/internal/download-files/dist/capture-origin.js +126 -0
- package/dist/packages/internal/download-files/dist/capture-routes.js +139 -0
- package/dist/packages/internal/download-files/dist/capture-shell.js +38 -0
- package/dist/packages/internal/download-files/dist/capture.js +74 -0
- package/dist/packages/internal/download-files/dist/egress-watch.js +38 -0
- package/dist/packages/internal/download-files/dist/files.js +7 -0
- package/dist/packages/internal/download-files/dist/finish.js +35 -0
- package/dist/packages/internal/download-files/dist/fleet.js +94 -0
- package/dist/packages/internal/download-files/dist/format.js +40 -0
- package/dist/packages/internal/download-files/dist/make.js +105 -0
- package/dist/packages/internal/download-files/dist/master-tally.js +32 -0
- package/dist/packages/internal/download-files/dist/names.js +24 -0
- package/dist/packages/internal/download-files/dist/pdf-boxes.js +33 -0
- package/dist/packages/internal/download-files/dist/pdf-image-placements.js +194 -0
- package/dist/packages/internal/download-files/dist/pdf-images.js +289 -0
- package/dist/packages/internal/file-store/dist/files.js +8 -0
- package/dist/packages/internal/file-store/dist/lru.js +40 -0
- package/dist/packages/internal/file-store/dist/refusal.js +12 -0
- package/dist/packages/internal/file-store/dist/trees.js +151 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +1 -1
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +47 -21
- package/dist/packages/internal/fill-bake/dist/index.js +5 -1
- package/dist/packages/internal/fill-bake/dist/item-merge.js +4 -3
- package/dist/packages/internal/fill-bake/dist/resolve-instance.js +9 -0
- package/dist/packages/internal/fill-bake/dist/resolve.js +3 -0
- package/dist/packages/internal/fill-bake/dist/round-trip.js +2 -0
- package/dist/packages/internal/fill-bake/dist/strip.js +6 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +1 -1
- package/dist/packages/internal/island-runtime/dist/index.js +1 -10
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +5 -0
- package/dist/packages/internal/lead-fields/dist/ingest.js +72 -0
- package/dist/packages/internal/media-resolution/dist/video.js +6 -2
- package/dist/packages/internal/page-render/dist/addresses.js +57 -0
- package/dist/packages/internal/page-render/dist/index.js +6 -0
- package/dist/packages/internal/page-render/dist/kept.js +30 -0
- package/dist/packages/internal/page-render/dist/nav.js +42 -0
- package/dist/packages/internal/page-render/dist/render.js +152 -0
- package/dist/packages/internal/page-shell/dist/assemble.js +161 -0
- package/dist/packages/internal/page-shell/dist/escape.js +10 -0
- package/dist/packages/internal/page-shell/dist/frame.js +23 -0
- package/dist/packages/internal/page-shell/dist/index.js +26 -0
- package/dist/packages/internal/playground/dist/build-fingerprint.js +18 -0
- package/dist/packages/internal/playground/dist/fixture-conversions/list-names-properties.js +76 -0
- package/dist/packages/internal/playground/dist/fixture-formats.d.ts +37 -0
- package/dist/packages/internal/playground/dist/fixture-formats.js +20 -0
- package/dist/packages/internal/playground/dist/host/bootstrap.js +108 -0
- package/dist/packages/internal/playground/dist/host/built.js +202 -0
- package/dist/packages/internal/playground/dist/host/catalog-fixture.js +53 -0
- package/dist/packages/internal/playground/dist/host/download.js +34 -0
- package/dist/packages/internal/playground/dist/host/env.js +11 -0
- package/dist/packages/internal/playground/dist/host/everywhere-saves.js +353 -0
- package/dist/packages/internal/playground/dist/host/fixture-addresses.js +52 -0
- package/dist/packages/internal/playground/dist/host/fixture-documents.js +494 -0
- package/dist/packages/internal/playground/dist/host/fixture-operations.js +364 -0
- package/dist/packages/internal/playground/dist/host/fixture-units.js +93 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/image-dimensions.js +1 -1
- package/dist/packages/internal/playground/dist/host/leads.js +41 -0
- package/dist/packages/internal/playground/dist/host/media-saves.js +309 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/media-store.js +79 -26
- package/dist/packages/internal/playground/dist/host/overridable.js +9 -0
- package/dist/packages/internal/playground/dist/host/owned-saves.js +203 -0
- package/dist/{playground → packages/internal/playground/dist}/host/page-state.js +1 -1
- package/dist/packages/internal/playground/dist/host/program.js +54 -0
- package/dist/packages/internal/playground/dist/host/property-derive.js +216 -0
- package/dist/packages/internal/playground/dist/host/property-saves.js +74 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/property.js +88 -229
- package/dist/packages/internal/playground/dist/host/provenance.js +49 -0
- package/dist/packages/internal/playground/dist/host/resolve.js +553 -0
- package/dist/packages/internal/playground/dist/host/row-images.js +41 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/rows.js +1 -1
- package/dist/packages/internal/playground/dist/host/save.js +429 -0
- package/dist/packages/internal/playground/dist/host/serve.js +952 -0
- package/dist/packages/internal/playground/dist/host/site.js +79 -0
- package/dist/packages/internal/playground/dist/host/slots.js +202 -0
- package/dist/packages/internal/playground/dist/host/stated-content.js +93 -0
- package/dist/packages/internal/playground/dist/host/stored-fixtures.js +135 -0
- package/dist/packages/internal/playground/dist/host/violations.js +7 -0
- package/dist/packages/internal/playground/dist/jobs/lanes.js +24 -0
- package/dist/packages/internal/playground/dist/jobs/memory-queue.js +112 -0
- package/dist/packages/internal/playground/dist/jobs/probe.js +37 -0
- package/dist/packages/internal/playground/dist/jobs/queue.js +28 -0
- package/dist/packages/internal/playground/dist/jobs/runner.js +207 -0
- package/dist/packages/internal/playground/dist/layout.js +14 -0
- package/dist/packages/internal/playground/dist/platform.js +33 -0
- package/dist/packages/internal/playground/dist/server/changes.js +57 -0
- package/dist/packages/internal/playground/dist/server/crop.js +47 -0
- package/dist/packages/internal/playground/dist/server/derived-files.js +88 -0
- package/dist/packages/internal/playground/dist/server/download.js +158 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/http.js +4 -12
- package/dist/packages/internal/playground/dist/server/jobs.js +29 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/listen.js +4 -11
- package/dist/packages/internal/playground/dist/server/playground-server.js +424 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/request-error.js +1 -1
- package/dist/packages/internal/playground/dist/server/size-ladders.js +170 -0
- package/dist/packages/internal/playground/dist/server/verification.js +75 -0
- package/dist/packages/internal/playground/dist/server/verify-build.js +139 -0
- package/dist/packages/internal/playground/dist/wire.js +78 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +1 -1
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
- package/dist/packages/internal/site-files/dist/head.js +59 -0
- package/dist/packages/internal/site-files/dist/index.js +4 -0
- package/dist/packages/internal/site-files/dist/site.js +211 -0
- package/dist/packages/internal/static-assets-binding/dist/index.js +32 -0
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +38 -5
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +8 -1
- package/dist/packages/internal/template-artifact/dist/build.js +148 -0
- package/dist/packages/internal/template-artifact/dist/composition.js +62 -0
- package/dist/packages/internal/template-artifact/dist/index.js +2 -2
- package/dist/packages/internal/template-artifact/dist/layout.js +48 -12
- package/dist/packages/internal/template-artifact/dist/manifest.js +3 -10
- package/dist/packages/internal/template-artifact/dist/verify.js +51 -31
- package/dist/packages/internal/template-contracts/dist/address-value.js +6 -1
- package/dist/packages/internal/template-contracts/dist/content-categories.js +10 -1
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +59 -32
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +14 -1
- package/dist/packages/internal/template-contracts/dist/list.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +67 -2
- package/dist/packages/internal/template-contracts/dist/media-offer.js +180 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +9 -2
- package/dist/packages/internal/template-contracts/dist/read-graph.js +36 -2
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +16 -1
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +9 -10
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +12 -1
- package/dist/packages/internal/template-contracts/dist/registry-graph.js +112 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +15 -2
- package/dist/packages/internal/template-contracts/dist/require-graph.js +300 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/row.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +1 -1
- package/dist/{schema → packages/internal/template-contracts/dist}/section-nav.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +4 -4
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +3 -1
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +24 -1
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +26 -1
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/table-members.js +7 -2
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +1 -1
- package/dist/packages/internal/upload-formats/dist/heic.js +35 -0
- package/dist/packages/internal/upload-formats/dist/index.js +80 -0
- package/dist/packages/internal/upload-formats/dist/magic-bytes.js +293 -0
- package/dist/platform/paths.js +1 -0
- package/dist/platform/process.js +49 -1
- package/dist/rules/registry.js +27 -3
- package/dist/schema/fact.d.ts +2 -2
- package/dist/schema/facts-view.d.ts +1 -1
- package/dist/schema/section-props.d.ts +1 -1
- package/dist/schema/section-schema.d.ts +1 -1
- package/dist/schema/section-schema.js +1 -0
- package/dist/section/declare.d.ts +1 -1
- package/dist/section/discovery.js +6 -2
- package/dist/section/publish-shape.js +38 -0
- package/dist/section/section.d.ts +1 -1
- package/dist/template/define-template.d.ts +14 -4
- package/dist/template/define-template.js +2 -0
- package/dist/template/logic-shim.d.ts +1 -1
- package/dist/template/materialize.js +1 -1
- package/dist/template/running-copy.js +0 -1
- package/dist/template/section-reads.js +1 -1
- package/guide/reference/cli/INDEX.md +6 -5
- package/guide/reference/cli/build.md +10 -8
- package/guide/reference/cli/check.md +4 -2
- package/guide/reference/cli/dev.md +6 -2
- package/guide/reference/cli/install.md +41 -0
- package/guide/reference/cli/property-add.md +5 -4
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +5 -5
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +8 -4
- package/package.json +14 -30
- package/dist/artifact/playground/client/assets/index-BcLGpWLR.js +0 -1266
- package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +0 -1
- package/dist/cli/build/artifact.js +0 -220
- package/dist/cli/build/captures.js +0 -48
- package/dist/cli/build/fixtures.js +0 -92
- package/dist/cli/capture/capture-browser.js +0 -37
- package/dist/cli/capture/capture.js +0 -115
- package/dist/cli/check/render/inputs.js +0 -60
- package/dist/cli/check/render/nav.js +0 -31
- package/dist/cli/dev/crop.js +0 -20
- package/dist/cli/dev/fixture-ladders.js +0 -96
- package/dist/cli/dev/hmr.js +0 -26
- package/dist/cli/dev/islands.js +0 -234
- package/dist/cli/dev/load-template.js +0 -52
- package/dist/cli/dev/vite.js +0 -114
- package/dist/cli/dev/workspace-reader.js +0 -249
- package/dist/cli/publish/freshness.js +0 -64
- package/dist/fixtures/brand.d.ts +0 -4
- package/dist/fixtures/brand.js +0 -8
- package/dist/fixtures/load.js +0 -159
- package/dist/fixtures/resolve.js +0 -392
- package/dist/fixtures.d.ts +0 -429
- package/dist/fixtures.js +0 -23
- package/dist/packages/internal/canvas-core/dist/island-host.js +0 -62
- package/dist/packages/internal/canvas-core/dist/island-shields.js +0 -30
- package/dist/playground/canvas-island-host.d.ts +0 -11
- package/dist/playground/canvas-island-host.js +0 -29
- package/dist/playground/canvas-markers.js +0 -14
- package/dist/playground/host/paths.js +0 -8
- package/dist/playground/layout.js +0 -17
- package/dist/playground/wire.js +0 -28
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import { normalizeAddressValue } from "../../../template-contracts/dist/address-value.js";
|
|
2
|
+
import { declaredKinds, isEmailValue, isIsoDateValue, isMediaType, isPhoneValue } from "../../../template-contracts/dist/slot-catalog.js";
|
|
3
|
+
import { getComputed } from "../../../template-contracts/dist/compute.js";
|
|
4
|
+
import { attributedRows, listTableOf, placementOf, rowTablesOf } from "../../../template-contracts/dist/ref-locate.js";
|
|
5
|
+
import { isOverridable } from "./overridable.js";
|
|
6
|
+
import { elementRowKeys, listSourceOf, memberSourceOf } from "../../../template-contracts/dist/row-sources.js";
|
|
7
|
+
import { tableRowIds } from "../../../source-resolution/dist/index.js";
|
|
8
|
+
import { isOrderOverridden, itemOverridesForSlot, objectFieldSlotId, removedItemsForSlot } from "../../../template-contracts/dist/slot-overrides.js";
|
|
9
|
+
import { bakeDisplayEntries, bakePropertyRefSlots } from "../../../fill-bake/dist/bake-property-ref.js";
|
|
10
|
+
import { mergeSourcedItems } from "../../../fill-bake/dist/item-merge.js";
|
|
11
|
+
import { applyComputeReads } from "../../../fill-bake/dist/compute-reads.js";
|
|
12
|
+
import "../../../fill-bake/dist/index.js";
|
|
13
|
+
import { fillSpecFromSchema } from "../../../template-contracts/dist/fill-spec.js";
|
|
14
|
+
import { cropRectOfStored, croppedImageCopy } from "./media-store.js";
|
|
15
|
+
import { isEmptyValue, slotProvenance } from "./provenance.js";
|
|
16
|
+
import { blankForField } from "./rows.js";
|
|
17
|
+
|
|
18
|
+
//#region ../../internal/playground/dist/host/resolve.js
|
|
19
|
+
function assertAuthored(fixture) {
|
|
20
|
+
if (fixture.settled === void 0) throw new Error(`Fixture "${fixture.id}" is synthesized: it carries no settled doc, and no playground serves it.`);
|
|
21
|
+
}
|
|
22
|
+
const VALIDATED_KINDS = {
|
|
23
|
+
date: {
|
|
24
|
+
admits: (value) => value === null || isIsoDateValue(value),
|
|
25
|
+
expected: "a real calendar day written \"YYYY-MM-DD\", or null for none"
|
|
26
|
+
},
|
|
27
|
+
email: {
|
|
28
|
+
admits: (value) => value == null || value === "" || isEmailValue(value),
|
|
29
|
+
expected: "an email address"
|
|
30
|
+
},
|
|
31
|
+
phone: {
|
|
32
|
+
admits: (value) => value == null || value === "" || isPhoneValue(value),
|
|
33
|
+
expected: "a phone number a dialer can call"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function emptyValueFor(type) {
|
|
37
|
+
if (type === "list") return [];
|
|
38
|
+
return type === "object" ? {} : null;
|
|
39
|
+
}
|
|
40
|
+
function fixtureSectionOf(section) {
|
|
41
|
+
if (!("schema" in section)) return section;
|
|
42
|
+
const { schema } = section;
|
|
43
|
+
return {
|
|
44
|
+
key: section.key,
|
|
45
|
+
slots: schema.slots,
|
|
46
|
+
display: schema.meta.display ?? {},
|
|
47
|
+
computed: getComputed(schema),
|
|
48
|
+
decisions: pickDecisions(schema)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function uniquePlacements(placements) {
|
|
52
|
+
const seen = /* @__PURE__ */ new Set();
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const p of placements) {
|
|
55
|
+
if (seen.has(p.instance)) continue;
|
|
56
|
+
seen.add(p.instance);
|
|
57
|
+
out.push({
|
|
58
|
+
key: p.key,
|
|
59
|
+
instance: p.instance,
|
|
60
|
+
section: fixtureSectionOf(p.section)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
function computeReadsOf(section, log) {
|
|
66
|
+
return {
|
|
67
|
+
localKey: section.key,
|
|
68
|
+
schema: {
|
|
69
|
+
slots: section.slots,
|
|
70
|
+
display: section.display
|
|
71
|
+
},
|
|
72
|
+
bakeContext: {
|
|
73
|
+
computed: { ...section.computed },
|
|
74
|
+
section_key: section.key,
|
|
75
|
+
log
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function settleOverPlacements(input) {
|
|
80
|
+
const pages = [{
|
|
81
|
+
id: "fixture",
|
|
82
|
+
sections: input.placements.map((p) => ({
|
|
83
|
+
section: p.section,
|
|
84
|
+
instance_id: p.instance
|
|
85
|
+
}))
|
|
86
|
+
}];
|
|
87
|
+
return applyComputeReads({
|
|
88
|
+
contentDoc: { instances: [...input.instances] },
|
|
89
|
+
facts: input.facts,
|
|
90
|
+
sections: new Map(input.sections),
|
|
91
|
+
placement: placementOf(pages)
|
|
92
|
+
}).contentDoc.instances;
|
|
93
|
+
}
|
|
94
|
+
function resolveStated(input) {
|
|
95
|
+
const { facts, media, module } = input;
|
|
96
|
+
const violations = [];
|
|
97
|
+
const placements = uniquePlacements(input.placements);
|
|
98
|
+
const named = (message, rule = "fixtures/instance-not-placed") => {
|
|
99
|
+
violations.push({
|
|
100
|
+
rule,
|
|
101
|
+
file: module,
|
|
102
|
+
message: `fixture "${input.id}" ${message}`
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const entriesByInstance = /* @__PURE__ */ new Map();
|
|
106
|
+
for (const entry of input.entries) {
|
|
107
|
+
if (placements.find((p) => p.key === entry.section && p.instance === entry.instance) === void 0) {
|
|
108
|
+
named(`states content for "${entry.section}" instance "${entry.instance}", which no page places`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (entriesByInstance.has(entry.instance)) {
|
|
112
|
+
named(`states content twice for instance "${entry.instance}"`, "fixtures/document-invalid");
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
entriesByInstance.set(entry.instance, entry);
|
|
116
|
+
}
|
|
117
|
+
const ctx = {
|
|
118
|
+
facts,
|
|
119
|
+
media,
|
|
120
|
+
module,
|
|
121
|
+
fixtureId: input.id,
|
|
122
|
+
log: input.log,
|
|
123
|
+
violations,
|
|
124
|
+
spelling: input.spelling
|
|
125
|
+
};
|
|
126
|
+
const filled = placements.map((placement) => fillInstance(placement, entriesByInstance.get(placement.instance), ctx));
|
|
127
|
+
const settled = settleOverPlacements({
|
|
128
|
+
instances: filled.map((f) => f.instance),
|
|
129
|
+
placements: placements.map((p) => ({
|
|
130
|
+
instance: p.instance,
|
|
131
|
+
section: p.key
|
|
132
|
+
})),
|
|
133
|
+
sections: new Map(filled.map((f) => [f.instance.instance_id, f.section])),
|
|
134
|
+
facts
|
|
135
|
+
});
|
|
136
|
+
const instances = [];
|
|
137
|
+
const provenance = {};
|
|
138
|
+
settled.forEach((instance, index) => {
|
|
139
|
+
const { placement, values } = filled[index];
|
|
140
|
+
const schemaSlots = placement.section.slots;
|
|
141
|
+
const slots = {};
|
|
142
|
+
const provenanceOf = {};
|
|
143
|
+
for (const [id, def] of Object.entries(schemaSlots)) {
|
|
144
|
+
provenanceOf[id] = slotProvenance(def, id, values[id], instance.slots[id], facts, instance.slot_overrides);
|
|
145
|
+
const cases = def.variant?.cases;
|
|
146
|
+
if (cases !== void 0 && (instance.variant === void 0 || !cases.includes(instance.variant))) continue;
|
|
147
|
+
slots[id] = instance.slots[id];
|
|
148
|
+
}
|
|
149
|
+
instances.push({
|
|
150
|
+
instance_id: instance.instance_id,
|
|
151
|
+
section_key: placement.section.key,
|
|
152
|
+
enabled: instance.enabled,
|
|
153
|
+
...instance.variant === void 0 ? {} : { variant: instance.variant },
|
|
154
|
+
slots,
|
|
155
|
+
...instance.slot_overrides === void 0 ? {} : { slot_overrides: instance.slot_overrides }
|
|
156
|
+
});
|
|
157
|
+
provenance[instance.instance_id] = provenanceOf;
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
id: input.id,
|
|
161
|
+
label: input.label,
|
|
162
|
+
module,
|
|
163
|
+
synthesized: false,
|
|
164
|
+
facts,
|
|
165
|
+
media,
|
|
166
|
+
contentDoc: { instances },
|
|
167
|
+
settled,
|
|
168
|
+
provenance,
|
|
169
|
+
property: input.property,
|
|
170
|
+
violations
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function pickDecisions(schema) {
|
|
174
|
+
try {
|
|
175
|
+
return fillSpecFromSchema(schema).decisions;
|
|
176
|
+
} catch {
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function fillInstance(placement, entry, ctx) {
|
|
181
|
+
const { section } = placement;
|
|
182
|
+
const schemaSlots = section.slots;
|
|
183
|
+
const bakeContext = {
|
|
184
|
+
computed: { ...section.computed },
|
|
185
|
+
section_key: section.key,
|
|
186
|
+
log: ctx.log
|
|
187
|
+
};
|
|
188
|
+
const decisions = [...section.decisions];
|
|
189
|
+
const values = entry?.values ?? {};
|
|
190
|
+
const fill = {
|
|
191
|
+
decisions,
|
|
192
|
+
heldRows: {},
|
|
193
|
+
spelling: ctx.spelling,
|
|
194
|
+
at: (slot) => ({
|
|
195
|
+
fixtureId: ctx.fixtureId,
|
|
196
|
+
module: ctx.module,
|
|
197
|
+
media: ctx.media,
|
|
198
|
+
violations: ctx.violations,
|
|
199
|
+
instance: placement.instance,
|
|
200
|
+
slot
|
|
201
|
+
})
|
|
202
|
+
};
|
|
203
|
+
for (const id of Object.keys(values)) if (schemaSlots[id] === void 0) ctx.violations.push({
|
|
204
|
+
rule: "fixtures/document-invalid",
|
|
205
|
+
file: ctx.module,
|
|
206
|
+
message: `fixture "${ctx.fixtureId}": "${placement.instance}".${id} names a slot section "${section.key}" does not declare`
|
|
207
|
+
});
|
|
208
|
+
const stated = {};
|
|
209
|
+
for (const [id, def] of Object.entries(schemaSlots)) {
|
|
210
|
+
const value = statedValue(fill, def, id, values[id], true);
|
|
211
|
+
if (value !== void 0) stated[id] = value;
|
|
212
|
+
reportRows(ctx, placement.instance, def, id, values[id]);
|
|
213
|
+
}
|
|
214
|
+
reportHeldRows(ctx, placement.instance, schemaSlots, fill.heldRows);
|
|
215
|
+
const bakeScope = {
|
|
216
|
+
decisions,
|
|
217
|
+
heldRows: fill.heldRows,
|
|
218
|
+
stored: stated
|
|
219
|
+
};
|
|
220
|
+
const baked = bakePropertyRefSlots({ slots: schemaSlots }, ctx.facts, bakeContext, bakeScope);
|
|
221
|
+
const slots = {};
|
|
222
|
+
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);
|
|
223
|
+
for (const [id, def] of Object.entries(schemaSlots)) {
|
|
224
|
+
const items = itemsMarked(def, id, stated[id], entry?.marks, slots[id]);
|
|
225
|
+
if (items !== void 0) slots[id] = items;
|
|
226
|
+
}
|
|
227
|
+
const scalar = applyOverrides(fill, schemaSlots, slots, entry?.overrides ?? {}, section.key);
|
|
228
|
+
const display = section.display;
|
|
229
|
+
const baked_display = bakeDisplayEntries({
|
|
230
|
+
display,
|
|
231
|
+
slots: schemaSlots
|
|
232
|
+
}, ctx.facts, bakeContext, bakeScope);
|
|
233
|
+
const visibility = baked_display.visibility ?? display.visibility?.cases?.[0];
|
|
234
|
+
const declaredCases = display.variant?.cases;
|
|
235
|
+
let statedVariant = entry?.display.variant;
|
|
236
|
+
if (statedVariant !== void 0 && declaredCases?.includes(statedVariant) !== true) {
|
|
237
|
+
ctx.violations.push({
|
|
238
|
+
rule: "fixtures/value-invalid",
|
|
239
|
+
file: ctx.module,
|
|
240
|
+
message: `fixture "${ctx.fixtureId}": content for "${placement.instance}" names variant "${statedVariant}", which section "${section.key}" does not declare`
|
|
241
|
+
});
|
|
242
|
+
statedVariant = void 0;
|
|
243
|
+
}
|
|
244
|
+
const statedEnabled = entry?.display.enabled;
|
|
245
|
+
const variant = statedVariant ?? baked_display.variant ?? declaredCases?.[0];
|
|
246
|
+
const overrides = {
|
|
247
|
+
...statedEnabled === void 0 ? {} : { visibility: true },
|
|
248
|
+
...statedVariant === void 0 ? {} : { variant: true }
|
|
249
|
+
};
|
|
250
|
+
return {
|
|
251
|
+
placement,
|
|
252
|
+
instance: {
|
|
253
|
+
instance_id: placement.instance,
|
|
254
|
+
enabled: statedEnabled ?? (visibility === void 0 ? true : visibility !== "hidden"),
|
|
255
|
+
...variant === void 0 ? {} : { variant },
|
|
256
|
+
slots,
|
|
257
|
+
...slotOverridesOf(scalar, entry?.marks),
|
|
258
|
+
...Object.keys(overrides).length === 0 ? {} : { display_overrides: overrides }
|
|
259
|
+
},
|
|
260
|
+
section: computeReadsOf(section, ctx.log),
|
|
261
|
+
values
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function slotOverridesOf(scalar, marks) {
|
|
265
|
+
const lists = Object.fromEntries(Object.entries(marks ?? {}).filter(([, value]) => value !== void 0 && Object.keys(value).length > 0));
|
|
266
|
+
const out = {
|
|
267
|
+
...Object.keys(scalar).length === 0 ? {} : { scalar },
|
|
268
|
+
...lists
|
|
269
|
+
};
|
|
270
|
+
return Object.keys(out).length === 0 ? {} : { slot_overrides: out };
|
|
271
|
+
}
|
|
272
|
+
function applyOverrides(fill, schemaSlots, slots, overrides, sectionKey) {
|
|
273
|
+
const scalar = {};
|
|
274
|
+
const filled = new Set(fill.decisions.flatMap((decision) => decision.produces ?? []));
|
|
275
|
+
const takesOverride = (def, path) => isOverridable(def) || filled.has(path);
|
|
276
|
+
const refuse = (path, why) => {
|
|
277
|
+
const { fixtureId, module, instance, violations } = fill.at(path);
|
|
278
|
+
violations.push({
|
|
279
|
+
rule: "fixtures/document-invalid",
|
|
280
|
+
file: module,
|
|
281
|
+
message: `fixture "${fixtureId}": content for "${instance}" overrides "${path}", ${why}`
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
for (const [id, value] of Object.entries(overrides)) {
|
|
285
|
+
if (value === void 0) continue;
|
|
286
|
+
const def = schemaSlots[id];
|
|
287
|
+
if (def === void 0) refuse(id, `which section "${sectionKey}" does not declare`);
|
|
288
|
+
else if (def.type === "object") {
|
|
289
|
+
if (!isRecord(value)) {
|
|
290
|
+
refuse(id, "which is an object: override its sourced fields by field");
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const fields = def.fields;
|
|
294
|
+
const object = isRecord(slots[id]) ? { ...slots[id] } : {};
|
|
295
|
+
for (const [key, fieldValue] of Object.entries(value)) {
|
|
296
|
+
if (fieldValue === void 0) continue;
|
|
297
|
+
const path = objectFieldSlotId(id, key);
|
|
298
|
+
const field = fields[key];
|
|
299
|
+
if (field === void 0) refuse(path, `which object "${id}" does not declare`);
|
|
300
|
+
else if (!takesOverride(field, path)) refuse(path, "which no fact, row member, compute or fill sources");
|
|
301
|
+
else {
|
|
302
|
+
object[key] = overrideValue(fill, field, fieldValue, fill.at(path));
|
|
303
|
+
scalar[path] = true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
slots[id] = object;
|
|
307
|
+
} else if (!takesOverride(def, id)) refuse(id, "which no fact, row member, compute or fill sources");
|
|
308
|
+
else {
|
|
309
|
+
slots[id] = overrideValue(fill, def, value, fill.at(id));
|
|
310
|
+
scalar[id] = true;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return scalar;
|
|
314
|
+
}
|
|
315
|
+
function overrideValue(fill, def, value, ctx) {
|
|
316
|
+
return value === null ? null : leafValue(fill.spelling, def, value, ctx);
|
|
317
|
+
}
|
|
318
|
+
function statedValue(fill, def, path, value, holds) {
|
|
319
|
+
if (value === void 0 || value === null) return void 0;
|
|
320
|
+
if (def.type === "row") {
|
|
321
|
+
if (typeof value !== "string") {
|
|
322
|
+
kindViolation(fill, def, value, fill.at(path));
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (holds) fill.heldRows[path] = value;
|
|
326
|
+
return value;
|
|
327
|
+
}
|
|
328
|
+
if (def.type === "object") {
|
|
329
|
+
if (!isRecord(value)) {
|
|
330
|
+
kindViolation(fill, def, value, fill.at(path));
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
unknownFields(fill, def.fields, path, value);
|
|
334
|
+
return statedFields(fill, def.fields, path, value, holds);
|
|
335
|
+
}
|
|
336
|
+
if (def.type === "list" && def.element?.type === "object") {
|
|
337
|
+
if (!Array.isArray(value)) {
|
|
338
|
+
kindViolation(fill, def, value, fill.at(path));
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const fields = def.element.fields;
|
|
342
|
+
const table = filledListTable(def);
|
|
343
|
+
const elementRows = elementRowKeys(fields);
|
|
344
|
+
return value.map((item, i) => {
|
|
345
|
+
const record = isRecord(item) ? item : {};
|
|
346
|
+
if (!isRecord(item)) kindViolation(fill, def.element, item, fill.at(`${path}[${String(i)}]`));
|
|
347
|
+
else unknownFields(fill, fields, `${path}[${String(i)}]`, record, ["id"]);
|
|
348
|
+
const out = statedFields(fill, fields, path, record, false);
|
|
349
|
+
const held = elementRows.map((key) => record[key]).find((id) => typeof id === "string" && id !== "");
|
|
350
|
+
return {
|
|
351
|
+
id: table === null ? record["id"] ?? `${path}-${String(i + 1)}` : held ?? record["id"],
|
|
352
|
+
...out
|
|
353
|
+
};
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
if (def.type === "list" && def.element?.type === "row") {
|
|
357
|
+
if (!Array.isArray(value)) {
|
|
358
|
+
kindViolation(fill, def, value, fill.at(path));
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
return value.filter((id) => typeof id === "string");
|
|
362
|
+
}
|
|
363
|
+
return leafValue(fill.spelling, def, value, fill.at(path));
|
|
364
|
+
}
|
|
365
|
+
function statedFields(fill, fields, path, value, holds) {
|
|
366
|
+
const out = {};
|
|
367
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
368
|
+
const stated = statedValue(fill, field, objectFieldSlotId(path, key), value[key], holds);
|
|
369
|
+
if (stated !== void 0) out[key] = stated;
|
|
370
|
+
}
|
|
371
|
+
return out;
|
|
372
|
+
}
|
|
373
|
+
function unknownFields(fill, fields, path, value, own = []) {
|
|
374
|
+
if (!fill.spelling.kinds) return;
|
|
375
|
+
for (const key of Object.keys(value)) {
|
|
376
|
+
if (fields[key] !== void 0 || own.includes(key)) continue;
|
|
377
|
+
const ctx = fill.at(path);
|
|
378
|
+
ctx.violations.push({
|
|
379
|
+
rule: "fixtures/document-invalid",
|
|
380
|
+
file: ctx.module,
|
|
381
|
+
message: `fixture "${ctx.fixtureId}": "${ctx.instance}".${path}.${key} names a field the slot does not declare`
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function filledListTable(def) {
|
|
386
|
+
if (listSourceOf(def).kind !== "none" || memberSourceOf(def.source) !== null) return null;
|
|
387
|
+
return listTableOf({ slots: {} }, def);
|
|
388
|
+
}
|
|
389
|
+
function reportRows(ctx, instance, def, path, value) {
|
|
390
|
+
if (def.type !== "list" || !Array.isArray(value)) return;
|
|
391
|
+
if (listSourceOf(def).kind !== "table") return;
|
|
392
|
+
const table = listTableOf({ slots: {} }, def);
|
|
393
|
+
const carried = table === null ? 0 : tableRowIds(table, ctx.facts).length;
|
|
394
|
+
if (value.length <= carried) return;
|
|
395
|
+
ctx.violations.push({
|
|
396
|
+
rule: "fixtures/rows-not-in-property",
|
|
397
|
+
file: ctx.module,
|
|
398
|
+
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`
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
function reportHeldRows(ctx, instance, schemaSlots, held) {
|
|
402
|
+
for (const [path, id] of Object.entries(held)) {
|
|
403
|
+
if (id === null) continue;
|
|
404
|
+
const dot = path.indexOf(".");
|
|
405
|
+
const top = schemaSlots[dot === -1 ? path : path.slice(0, dot)];
|
|
406
|
+
const def = dot === -1 ? top : top?.type === "object" ? top.fields[path.slice(dot + 1)] : void 0;
|
|
407
|
+
if (def === void 0) continue;
|
|
408
|
+
const tables = rowTablesOf(def);
|
|
409
|
+
if (tables.length === 0 || attributedRows(ctx.facts, tables).some((row) => row.id === id)) continue;
|
|
410
|
+
ctx.violations.push({
|
|
411
|
+
rule: "fixtures/held-row-not-in-property",
|
|
412
|
+
file: ctx.module,
|
|
413
|
+
message: `fixture "${ctx.fixtureId}": "${instance}".${path} holds row "${id}", which its property does not carry; it loads empty`
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function slotValue(def, path, baked, stated, decisions) {
|
|
418
|
+
if (def.type === "object") {
|
|
419
|
+
const fields = def.fields;
|
|
420
|
+
const bakedFields = isRecord(baked?.value) ? baked.value : {};
|
|
421
|
+
const statedFields = isRecord(stated) ? stated : {};
|
|
422
|
+
const out = {};
|
|
423
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
424
|
+
const fieldPath = objectFieldSlotId(path, key);
|
|
425
|
+
out[key] = Object.hasOwn(bakedFields, key) ? fieldValue(field, fieldPath, { value: bakedFields[key] }, statedFields[key], decisions) : fieldValue(field, fieldPath, void 0, statedFields[key], decisions);
|
|
426
|
+
}
|
|
427
|
+
return out;
|
|
428
|
+
}
|
|
429
|
+
if (def.type === "list" && def.element?.type === "object" && Array.isArray(baked?.value)) return itemsValue(def, path, baked.value, stated, decisions);
|
|
430
|
+
if (baked !== void 0) return baked.value ?? emptyValueFor(def.type);
|
|
431
|
+
if (def.source === void 0 && stated !== void 0) return stated;
|
|
432
|
+
return emptyValueFor(def.type);
|
|
433
|
+
}
|
|
434
|
+
function itemsMarked(def, id, stated, marks, baked) {
|
|
435
|
+
if (def.type !== "list" || def.element?.type !== "object" || !Array.isArray(stated) || marks === void 0) return void 0;
|
|
436
|
+
const overrides = itemOverridesForSlot(marks, id);
|
|
437
|
+
const removed = removedItemsForSlot(marks, id);
|
|
438
|
+
const ordered = isOrderOverridden(marks, id);
|
|
439
|
+
if (Object.keys(overrides).length === 0 && Object.keys(removed).length === 0 && !ordered) return void 0;
|
|
440
|
+
const source = listSourceOf(def).kind;
|
|
441
|
+
if (source === "none" || source === "other") return void 0;
|
|
442
|
+
if (source !== "table") return stated;
|
|
443
|
+
return mergeSourcedItems({
|
|
444
|
+
current: stated.filter(isRecord),
|
|
445
|
+
freshSource: Array.isArray(baked) ? baked.filter(isRecord) : [],
|
|
446
|
+
overrides,
|
|
447
|
+
...Object.keys(removed).length === 0 ? {} : { removed },
|
|
448
|
+
generatedFields: [],
|
|
449
|
+
membership: "table",
|
|
450
|
+
ordered
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
function fieldValue(def, path, baked, stated, decisions) {
|
|
454
|
+
if (def.type === "object" || def.type === "list" && def.element?.type === "object" && Array.isArray(baked?.value)) return slotValue(def, path, baked, stated, decisions);
|
|
455
|
+
if (baked !== void 0) return baked.value;
|
|
456
|
+
if (def.source === void 0 && stated !== void 0) return stated;
|
|
457
|
+
return blankForField(def);
|
|
458
|
+
}
|
|
459
|
+
function itemsValue(def, path, items, stated, decisions) {
|
|
460
|
+
const fields = def.element?.fields ?? {};
|
|
461
|
+
const statedItems = Array.isArray(stated) ? stated.filter(isRecord) : [];
|
|
462
|
+
const byIdentity = listSourceOf(def).kind === "none" && memberSourceOf(def.source) === null;
|
|
463
|
+
return items.map((item, i) => {
|
|
464
|
+
const baked = isRecord(item) ? item : {};
|
|
465
|
+
const statedItem = byIdentity ? statedItems.find((candidate) => candidate["id"] === baked["id"]) : statedItems[i];
|
|
466
|
+
const out = { id: baked["id"] };
|
|
467
|
+
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);
|
|
468
|
+
return out;
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
472
|
+
function leafValue(spelling, def, value, ctx) {
|
|
473
|
+
if (isMediaType(def.type)) return spelling.media(def, value, ctx);
|
|
474
|
+
if (spelling.kinds && kindProblem(def, value) !== null) {
|
|
475
|
+
kindViolation({ spelling }, def, value, ctx);
|
|
476
|
+
return emptyValueFor(def.type);
|
|
477
|
+
}
|
|
478
|
+
if (def.type === "address") return normalizeAddressValue(value);
|
|
479
|
+
const validated = VALIDATED_KINDS[def.type];
|
|
480
|
+
if (validated !== void 0 && !validated.admits(value)) {
|
|
481
|
+
ctx.violations.push({
|
|
482
|
+
rule: "fixtures/value-invalid",
|
|
483
|
+
file: ctx.module,
|
|
484
|
+
message: `fixture "${ctx.fixtureId}": "${ctx.instance}".${ctx.slot} (${def.type}) states ${JSON.stringify(value)}; it takes ${validated.expected}`
|
|
485
|
+
});
|
|
486
|
+
return emptyValueFor(def.type);
|
|
487
|
+
}
|
|
488
|
+
if (def.type === "list" && Array.isArray(value) && def.element !== void 0 && def.element.type !== "object" && def.element.type !== "row") {
|
|
489
|
+
const element = def.element;
|
|
490
|
+
return value.map((item) => leafValue(spelling, element, item, ctx)).filter((item) => item !== null && item !== void 0);
|
|
491
|
+
}
|
|
492
|
+
return value;
|
|
493
|
+
}
|
|
494
|
+
function kindProblem(def, value) {
|
|
495
|
+
if (value === null) return null;
|
|
496
|
+
switch (def.type) {
|
|
497
|
+
case "text":
|
|
498
|
+
case "select":
|
|
499
|
+
case "url":
|
|
500
|
+
case "date":
|
|
501
|
+
case "email":
|
|
502
|
+
case "phone": return typeof value === "string" ? null : "a string";
|
|
503
|
+
case "number": return typeof value === "number" && Number.isFinite(value) ? null : "a number";
|
|
504
|
+
case "address":
|
|
505
|
+
case "poi": return isRecord(value) ? null : "an object";
|
|
506
|
+
case "list": return Array.isArray(value) ? null : "a list";
|
|
507
|
+
default: return null;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
function kindViolation(fill, def, value, ctx) {
|
|
511
|
+
if (!fill.spelling.kinds) return;
|
|
512
|
+
const expected = kindProblem(def, value) ?? (def.type === "row" ? "a row id" : def.type === "object" ? "an object of its fields" : def.type === "list" ? "a list" : `a ${def.type} value`);
|
|
513
|
+
ctx.violations.push({
|
|
514
|
+
rule: "fixtures/document-invalid",
|
|
515
|
+
file: ctx.module,
|
|
516
|
+
message: `fixture "${ctx.fixtureId}": "${ctx.instance}".${ctx.slot} (${def.type}) states ${JSON.stringify(value)}; it takes ${expected}`
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
function croppedPick(media, crop, mobileCrop, ctx) {
|
|
520
|
+
const ref = { media };
|
|
521
|
+
const rect = crop === void 0 ? null : cropRectOfStored(crop);
|
|
522
|
+
const mobile = mobileCrop === void 0 ? null : cropRectOfStored(mobileCrop);
|
|
523
|
+
const malformed = [crop, mobileCrop].find((stated) => stated !== void 0 && cropRectOfStored(stated) === null && !isWholeFrame(stated));
|
|
524
|
+
if (malformed !== void 0) {
|
|
525
|
+
ctx.violations.push({
|
|
526
|
+
rule: "fixtures/value-invalid",
|
|
527
|
+
file: ctx.module,
|
|
528
|
+
message: `fixture "${ctx.fixtureId}": "${ctx.instance}".${ctx.slot} states the crop ${JSON.stringify(malformed)}; a crop takes x, y, width and height, each a share (0..1) of the image, naming a region inside it`
|
|
529
|
+
});
|
|
530
|
+
return ref;
|
|
531
|
+
}
|
|
532
|
+
if (rect === null && mobile === null) return ref;
|
|
533
|
+
return croppedImageCopy(media, rect, mobile);
|
|
534
|
+
}
|
|
535
|
+
function isWholeFrame(crop) {
|
|
536
|
+
if (!isRecord(crop)) return false;
|
|
537
|
+
return crop.x === 0 && crop.y === 0 && crop.width === 1 && crop.height === 1;
|
|
538
|
+
}
|
|
539
|
+
function catalogRef(def, id, what, ctx) {
|
|
540
|
+
const carried = typeof id === "string" ? ctx.media.get(id) : void 0;
|
|
541
|
+
if (carried === void 0 || !declaredKinds(def).includes(carried.kind)) {
|
|
542
|
+
ctx.violations.push({
|
|
543
|
+
rule: "fixtures/media-not-in-property",
|
|
544
|
+
file: ctx.module,
|
|
545
|
+
message: `fixture "${ctx.fixtureId}": "${ctx.instance}".${ctx.slot} references ${what}`
|
|
546
|
+
});
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
return { media: carried.id };
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
//#endregion
|
|
553
|
+
export { assertAuthored, catalogRef, croppedPick, emptyValueFor, fixtureSectionOf, isEmptyValue, resolveStated, settleOverPlacements, uniquePlacements };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { extensionOf } from "../../../upload-formats/dist/index.js";
|
|
2
|
+
import { ownedRowFieldAt } from "./everywhere-saves.js";
|
|
3
|
+
import { readDocument } from "./save.js";
|
|
4
|
+
import { admitFile, fileKindOfExtension, fileStem, folderOf, freshFile, isOwnFile, namedFiles } from "./media-saves.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/playground/dist/host/row-images.js
|
|
7
|
+
const ROW_IMAGE_FOLDER = "media/";
|
|
8
|
+
const isFolderFile = (id) => id.startsWith(ROW_IMAGE_FOLDER) && isOwnFile(id);
|
|
9
|
+
async function rowImageUploadSave(into, store, upload) {
|
|
10
|
+
const { doc: property } = await readDocument(store, into.property);
|
|
11
|
+
const field = ownedRowFieldAt(property, upload.target.owner);
|
|
12
|
+
admitFile(upload, field.kind === "tour" ? [] : [field.kind], "this field");
|
|
13
|
+
const folder = folderOf(into.property);
|
|
14
|
+
const file = await freshFile(store, folder, property, fileStem(upload.name), extensionOf(upload.name));
|
|
15
|
+
return {
|
|
16
|
+
writes: [{
|
|
17
|
+
path: `${folder}${file}`,
|
|
18
|
+
bytes: upload.bytes
|
|
19
|
+
}],
|
|
20
|
+
media: file,
|
|
21
|
+
file: `${folder}${file}`
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async function landedRowImages(store, propertyPath, property, ops) {
|
|
25
|
+
const named = namedFiles(property);
|
|
26
|
+
const folder = folderOf(propertyPath);
|
|
27
|
+
const landed = /* @__PURE__ */ new Map();
|
|
28
|
+
for (const op of ops) {
|
|
29
|
+
if (op.op !== "commit_media" || landed.has(op.media_id) || !isFolderFile(op.media_id) || named.has(op.media_id)) continue;
|
|
30
|
+
const kind = fileKindOfExtension(extensionOf(op.media_id));
|
|
31
|
+
if (kind === null || await store.readText(`${folder}${op.media_id}`) === null) continue;
|
|
32
|
+
landed.set(op.media_id, {
|
|
33
|
+
kind,
|
|
34
|
+
file: op.media_id
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return landed;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { landedRowImages, rowImageUploadSave };
|