@homepages/concrete 12.0.0 → 13.0.1
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 +192 -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 +15 -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,494 @@
|
|
|
1
|
+
import { isOverridable } from "./overridable.js";
|
|
2
|
+
import { MediaSchema } from "../../../property-facts/dist/registry-facts.js";
|
|
3
|
+
import { canonicalizeProperty, uploadEntryMedia } from "./property.js";
|
|
4
|
+
import { catalogRef, croppedPick, resolveStated, uniquePlacements } from "./resolve.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/playground/dist/host/fixture-documents.js
|
|
7
|
+
const ANNOTATIONS = ["$schema", "notes"];
|
|
8
|
+
const LIST_KEYS = /* @__PURE__ */ new Set([
|
|
9
|
+
"properties",
|
|
10
|
+
"fixtures",
|
|
11
|
+
...ANNOTATIONS
|
|
12
|
+
]);
|
|
13
|
+
const FIXTURE_KEYS = /* @__PURE__ */ new Set([
|
|
14
|
+
"property",
|
|
15
|
+
"content",
|
|
16
|
+
"page_state",
|
|
17
|
+
"files",
|
|
18
|
+
...ANNOTATIONS
|
|
19
|
+
]);
|
|
20
|
+
const FIXTURE_KEYS_AND_LABEL = /* @__PURE__ */ new Set([...FIXTURE_KEYS, "label"]);
|
|
21
|
+
const INSTANCE_KEYS = /* @__PURE__ */ new Set([
|
|
22
|
+
"slots",
|
|
23
|
+
"slot_overrides",
|
|
24
|
+
"enabled",
|
|
25
|
+
"variant"
|
|
26
|
+
]);
|
|
27
|
+
const OVERRIDE_KEYS = /* @__PURE__ */ new Set([
|
|
28
|
+
"scalar",
|
|
29
|
+
"items",
|
|
30
|
+
"items_removed",
|
|
31
|
+
"order"
|
|
32
|
+
]);
|
|
33
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34
|
+
function dirOf(path) {
|
|
35
|
+
const slash = path.lastIndexOf("/");
|
|
36
|
+
return slash === -1 ? "" : path.slice(0, slash);
|
|
37
|
+
}
|
|
38
|
+
function resolveReference(from, reference) {
|
|
39
|
+
if (typeof reference !== "string" || reference === "") return { problem: "expected a path relative to this file" };
|
|
40
|
+
if (reference.startsWith("/") || reference.includes("\\") || /^[a-z][a-z0-9+.-]*:/i.test(reference)) return { problem: `"${reference}" is not a path relative to this file` };
|
|
41
|
+
const parts = [];
|
|
42
|
+
for (const part of reference.split("/")) {
|
|
43
|
+
if (part === "" || part === ".") continue;
|
|
44
|
+
if (part === "..") {
|
|
45
|
+
if (parts.length === 0) return { problem: `"${reference}" names a file outside this file's own folder` };
|
|
46
|
+
parts.pop();
|
|
47
|
+
} else parts.push(part);
|
|
48
|
+
}
|
|
49
|
+
if (parts.length === 0) return { problem: `"${reference}" names a folder, not a file` };
|
|
50
|
+
const dir = dirOf(from);
|
|
51
|
+
return { path: dir === "" ? parts.join("/") : `${dir}/${parts.join("/")}` };
|
|
52
|
+
}
|
|
53
|
+
function dataFixtureId(path) {
|
|
54
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
55
|
+
return base.endsWith(".json") ? base.slice(0, -5) : base;
|
|
56
|
+
}
|
|
57
|
+
function propertyName(path) {
|
|
58
|
+
const dir = dirOf(path);
|
|
59
|
+
return dir.slice(dir.lastIndexOf("/") + 1);
|
|
60
|
+
}
|
|
61
|
+
async function loadDataFixtures(input) {
|
|
62
|
+
const { store } = input;
|
|
63
|
+
const violations = [];
|
|
64
|
+
const report = (rule, file, message) => {
|
|
65
|
+
violations.push({
|
|
66
|
+
rule,
|
|
67
|
+
file,
|
|
68
|
+
message
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const none = (list) => ({
|
|
72
|
+
properties: [],
|
|
73
|
+
fixtures: [],
|
|
74
|
+
list,
|
|
75
|
+
violations
|
|
76
|
+
});
|
|
77
|
+
const listRef = resolveReference(input.listedIn, input.list);
|
|
78
|
+
if ("problem" in listRef) {
|
|
79
|
+
report("fixtures/reference-invalid", input.listedIn, `fixtures: ${listRef.problem}`);
|
|
80
|
+
return none(null);
|
|
81
|
+
}
|
|
82
|
+
const list = listRef.path;
|
|
83
|
+
const listDoc = await readDocument(store, list, input.listedIn, "fixtures", report);
|
|
84
|
+
if (listDoc === null) return none(null);
|
|
85
|
+
unknownKeys(listDoc, LIST_KEYS, list, "", report);
|
|
86
|
+
const namedProperties = listDoc["properties"];
|
|
87
|
+
const named = listDoc["fixtures"];
|
|
88
|
+
if (!Array.isArray(namedProperties)) report("fixtures/document-invalid", list, "properties: expected a list of property document paths");
|
|
89
|
+
if (!Array.isArray(named)) report("fixtures/document-invalid", list, "fixtures: expected a list of content fixture paths");
|
|
90
|
+
if (!Array.isArray(namedProperties) || !Array.isArray(named)) return none(list);
|
|
91
|
+
const propertyPaths = listedPaths(list, "properties", namedProperties, propertyName, "a property's name is its folder's", report);
|
|
92
|
+
const fixturePaths = listedPaths(list, "fixtures", named, dataFixtureId, "a content fixture's name is its file name", report);
|
|
93
|
+
ownFolders(list, propertyPaths, fixturePaths, report);
|
|
94
|
+
const properties = /* @__PURE__ */ new Map();
|
|
95
|
+
const loadedProperties = [];
|
|
96
|
+
for (const { at, path } of propertyPaths) {
|
|
97
|
+
const pending = loadProperty(store, path, list, at, report);
|
|
98
|
+
properties.set(path, pending);
|
|
99
|
+
const property = await pending;
|
|
100
|
+
if (property?.facts != null) loadedProperties.push({
|
|
101
|
+
name: propertyName(path),
|
|
102
|
+
file: path,
|
|
103
|
+
facts: property.facts,
|
|
104
|
+
media: property.media
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const placements = uniquePlacements(input.placements);
|
|
108
|
+
const fixtures = [];
|
|
109
|
+
for (const { at, path } of fixturePaths) {
|
|
110
|
+
const doc = await readDocument(store, path, list, at, report);
|
|
111
|
+
if (doc === null) continue;
|
|
112
|
+
const fixture = await loadContentFixture({
|
|
113
|
+
id: dataFixtureId(path),
|
|
114
|
+
file: path,
|
|
115
|
+
list,
|
|
116
|
+
doc,
|
|
117
|
+
store,
|
|
118
|
+
placements,
|
|
119
|
+
properties,
|
|
120
|
+
report,
|
|
121
|
+
log: input.log
|
|
122
|
+
});
|
|
123
|
+
if (fixture === null) continue;
|
|
124
|
+
violations.push(...fixture.violations);
|
|
125
|
+
fixtures.push(fixture.resolved);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
properties: loadedProperties,
|
|
129
|
+
fixtures,
|
|
130
|
+
list,
|
|
131
|
+
violations
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function listedPaths(list, member, entries, nameOf, rule, report) {
|
|
135
|
+
const seen = /* @__PURE__ */ new Map();
|
|
136
|
+
const listed = [];
|
|
137
|
+
for (const [i, reference] of entries.entries()) {
|
|
138
|
+
const at = `${member}[${String(i)}]`;
|
|
139
|
+
const ref = resolveReference(list, reference);
|
|
140
|
+
if ("problem" in ref) {
|
|
141
|
+
report("fixtures/reference-invalid", list, `${at}: ${ref.problem}`);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const name = nameOf(ref.path);
|
|
145
|
+
const prior = seen.get(name);
|
|
146
|
+
if (prior !== void 0) {
|
|
147
|
+
report("fixtures/document-invalid", list, `${at}: "${ref.path}" has the name "${name}" that "${prior}" has; ${rule}, and names are unique across the template`);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
seen.set(name, ref.path);
|
|
151
|
+
listed.push({
|
|
152
|
+
at,
|
|
153
|
+
path: ref.path
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return listed;
|
|
157
|
+
}
|
|
158
|
+
function ownFolders(list, properties, fixtures, report) {
|
|
159
|
+
for (const { at, path } of properties) {
|
|
160
|
+
const folder = `${dirOf(path)}/`;
|
|
161
|
+
const others = [
|
|
162
|
+
list,
|
|
163
|
+
...fixtures.map((f) => f.path),
|
|
164
|
+
...properties.filter((p) => p.path !== path).map((p) => p.path)
|
|
165
|
+
];
|
|
166
|
+
const shared = dirOf(path) === "" ? list : others.find((other) => other.startsWith(folder));
|
|
167
|
+
if (shared !== void 0) report("fixtures/document-invalid", list, `${at}: "${path}" shares its folder with "${shared}"; a property's document sits in a folder of its own`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async function readDocument(store, path, namedIn, at, report) {
|
|
171
|
+
const text = await store.readText(path);
|
|
172
|
+
if (text === null) {
|
|
173
|
+
report("fixtures/reference-invalid", namedIn, `${at}: "${path}" does not exist`);
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
let parsed;
|
|
177
|
+
try {
|
|
178
|
+
parsed = JSON.parse(text);
|
|
179
|
+
} catch (cause) {
|
|
180
|
+
report("fixtures/document-invalid", path, `does not parse as JSON: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
if (!isRecord(parsed)) {
|
|
184
|
+
report("fixtures/document-invalid", path, "expected a JSON object");
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return parsed;
|
|
188
|
+
}
|
|
189
|
+
function unknownKeys(doc, allowed, file, at, report) {
|
|
190
|
+
for (const key of Object.keys(doc)) if (!allowed.has(key)) report("fixtures/document-invalid", file, `${at === "" ? "" : `${at}.`}${key}: not a member this document states`);
|
|
191
|
+
}
|
|
192
|
+
async function loadContentFixture(input) {
|
|
193
|
+
const { id, file, doc, report } = input;
|
|
194
|
+
if (doc["label"] !== void 0) report("fixtures/document-invalid", file, `label: not a member this document states; a content fixture's one name is its file name ("${id}"), so rename the file to rename it`);
|
|
195
|
+
unknownKeys(doc, FIXTURE_KEYS_AND_LABEL, file, "", report);
|
|
196
|
+
const propertyRef = resolveReference(file, doc["property"]);
|
|
197
|
+
if ("problem" in propertyRef) {
|
|
198
|
+
report("fixtures/reference-invalid", file, `property: ${propertyRef.problem}`);
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
const pending = input.properties.get(propertyRef.path);
|
|
202
|
+
if (pending === void 0) {
|
|
203
|
+
report("fixtures/reference-invalid", file, `property: "${propertyRef.path}" is not in the fixture list's properties; list it in ${input.list}`);
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
const property = await pending;
|
|
207
|
+
if (property === null || property.facts === null) return null;
|
|
208
|
+
const entries = statedEntries(doc["content"], file, input.placements, report);
|
|
209
|
+
const own = await loadOwnedFiles(input.store, file, doc["files"], property.media, report);
|
|
210
|
+
const { violations, ...resolved } = resolveStated({
|
|
211
|
+
id,
|
|
212
|
+
label: id,
|
|
213
|
+
module: file,
|
|
214
|
+
facts: property.facts,
|
|
215
|
+
media: new Map([...property.media, ...own.catalog]),
|
|
216
|
+
placements: input.placements,
|
|
217
|
+
entries,
|
|
218
|
+
spelling: DATA_SPELLING,
|
|
219
|
+
property: propertyRef.path,
|
|
220
|
+
...input.log === void 0 ? {} : { log: input.log }
|
|
221
|
+
});
|
|
222
|
+
const pages = pageState(doc["page_state"], file, report);
|
|
223
|
+
const owned = Object.keys(own.records).length === 0 ? {} : { owned: own.records };
|
|
224
|
+
return {
|
|
225
|
+
resolved: {
|
|
226
|
+
...resolved,
|
|
227
|
+
...owned,
|
|
228
|
+
...pages === void 0 ? {} : { pages }
|
|
229
|
+
},
|
|
230
|
+
violations
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
async function loadOwnedFiles(store, file, raw, property, report) {
|
|
234
|
+
const catalog = /* @__PURE__ */ new Map();
|
|
235
|
+
const records = {};
|
|
236
|
+
if (raw === void 0) return {
|
|
237
|
+
catalog,
|
|
238
|
+
records
|
|
239
|
+
};
|
|
240
|
+
if (!Array.isArray(raw)) {
|
|
241
|
+
report("fixtures/document-invalid", file, "files: expected a list of upload entries");
|
|
242
|
+
return {
|
|
243
|
+
catalog,
|
|
244
|
+
records
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
for (const [i, value] of raw.entries()) {
|
|
248
|
+
const at = `files[${String(i)}]`;
|
|
249
|
+
let faulty = false;
|
|
250
|
+
const invalid = (message) => {
|
|
251
|
+
faulty = true;
|
|
252
|
+
report("fixtures/document-invalid", file, message);
|
|
253
|
+
};
|
|
254
|
+
if (!isRecord(value)) {
|
|
255
|
+
invalid(`${at}: expected an upload entry`);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const id = value["id"];
|
|
259
|
+
if (typeof id !== "string" || id === "") {
|
|
260
|
+
invalid(`${at}: every entry needs a non-empty string id`);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (catalog.has(id) || property.has(id)) {
|
|
264
|
+
invalid(`${at}: id "${id}" is ${catalog.has(id) ? "repeated within files" : "its property's media's too"}; a file a slot owns has an id of its own`);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
const entry = { ...value };
|
|
268
|
+
for (const member of UPLOAD_FILE_MEMBERS) {
|
|
269
|
+
if (entry[member] === void 0) continue;
|
|
270
|
+
const ref = resolveReference(file, entry[member]);
|
|
271
|
+
if ("problem" in ref) {
|
|
272
|
+
report("fixtures/reference-invalid", file, `${at}.${member}: ${ref.problem}`);
|
|
273
|
+
faulty = true;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
const media = await store.mediaFile(ref.path);
|
|
277
|
+
if (media === null) {
|
|
278
|
+
report("fixtures/reference-invalid", file, `${at}.${member}: "${ref.path}" does not exist`);
|
|
279
|
+
faulty = true;
|
|
280
|
+
}
|
|
281
|
+
entry[member] = media;
|
|
282
|
+
}
|
|
283
|
+
if (faulty) continue;
|
|
284
|
+
const read = uploadEntryMedia(entry, i, at, invalid);
|
|
285
|
+
if (read === null) continue;
|
|
286
|
+
const parsed = MediaSchema.safeParse(read.record);
|
|
287
|
+
if (!parsed.success) {
|
|
288
|
+
invalid(`${at}: ${parsed.error.issues.map((issue) => `${issue.path.join(".") || "(entry)"}: ${issue.message}`).join("; ")}`);
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
catalog.set(id, read.catalog);
|
|
292
|
+
records[id] = parsed.data;
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
catalog,
|
|
296
|
+
records
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function pageState(raw, file, report) {
|
|
300
|
+
if (raw === void 0) return void 0;
|
|
301
|
+
if (!Array.isArray(raw)) {
|
|
302
|
+
report("fixtures/document-invalid", file, "page_state: expected a list of { page_id, enabled }");
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const pages = {};
|
|
306
|
+
raw.forEach((entry, i) => {
|
|
307
|
+
if (isRecord(entry) && typeof entry["page_id"] === "string" && typeof entry["enabled"] === "boolean" && Object.keys(entry).length === 2) pages[entry["page_id"]] = { enabled: entry["enabled"] };
|
|
308
|
+
else report("fixtures/document-invalid", file, `page_state[${String(i)}]: expected { "page_id": <page id>, "enabled": true or false }`);
|
|
309
|
+
});
|
|
310
|
+
return Object.keys(pages).length === 0 ? void 0 : pages;
|
|
311
|
+
}
|
|
312
|
+
function statedEntries(content, file, placements, report) {
|
|
313
|
+
if (content === void 0) return [];
|
|
314
|
+
if (!isRecord(content)) {
|
|
315
|
+
report("fixtures/document-invalid", file, "content: expected an object of instances, by instance id");
|
|
316
|
+
return [];
|
|
317
|
+
}
|
|
318
|
+
const entries = [];
|
|
319
|
+
for (const [instance, raw] of Object.entries(content)) {
|
|
320
|
+
const at = `content.${instance}`;
|
|
321
|
+
if (!isRecord(raw)) {
|
|
322
|
+
report("fixtures/document-invalid", file, `${at}: expected what the instance states`);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
unknownKeys(raw, INSTANCE_KEYS, file, at, report);
|
|
326
|
+
const placement = placements.find((p) => p.instance === instance);
|
|
327
|
+
const section = placement?.key ?? "(unplaced)";
|
|
328
|
+
const declared = placement?.section.slots ?? {};
|
|
329
|
+
const marks = isRecord(raw["slot_overrides"]) ? raw["slot_overrides"] : {};
|
|
330
|
+
if (raw["slot_overrides"] !== void 0 && !isRecord(raw["slot_overrides"])) report("fixtures/document-invalid", file, `${at}.slot_overrides: expected an object`);
|
|
331
|
+
unknownKeys(marks, OVERRIDE_KEYS, file, `${at}.slot_overrides`, report);
|
|
332
|
+
const scalar = isRecord(marks["scalar"]) ? marks["scalar"] : {};
|
|
333
|
+
const slots = isRecord(raw["slots"]) ? raw["slots"] : {};
|
|
334
|
+
if (raw["slots"] !== void 0 && !isRecord(raw["slots"])) report("fixtures/document-invalid", file, `${at}.slots: expected an object of slot values, by slot id`);
|
|
335
|
+
const values = {};
|
|
336
|
+
const overrides = {};
|
|
337
|
+
for (const [slot, value] of Object.entries(slots)) {
|
|
338
|
+
const def = declared[slot];
|
|
339
|
+
if (def === void 0 || placement === void 0) {
|
|
340
|
+
values[slot] = value;
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (scalar[slot] === true) {
|
|
344
|
+
overrides[slot] = value;
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
if (def.type === "object" && isRecord(value)) {
|
|
348
|
+
const fields = def.fields;
|
|
349
|
+
const stated = {};
|
|
350
|
+
const overridden = {};
|
|
351
|
+
for (const [field, fieldValue] of Object.entries(value)) {
|
|
352
|
+
const fieldDef = fields[field];
|
|
353
|
+
if (scalar[`${slot}.${field}`] === true) overridden[field] = fieldValue;
|
|
354
|
+
else if (fieldDef !== void 0 && isOverridable(fieldDef)) sourcedUnmarked(`${at}.slots.${slot}.${field}`, `${slot}.${field}`);
|
|
355
|
+
else stated[field] = fieldValue;
|
|
356
|
+
}
|
|
357
|
+
values[slot] = stated;
|
|
358
|
+
if (Object.keys(overridden).length > 0) overrides[slot] = overridden;
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (isOverridable(def)) sourcedUnmarked(`${at}.slots.${slot}`, slot);
|
|
362
|
+
else values[slot] = value;
|
|
363
|
+
}
|
|
364
|
+
for (const marked of Object.keys(scalar)) {
|
|
365
|
+
const dot = marked.indexOf(".");
|
|
366
|
+
const statedSlot = slots[dot === -1 ? marked : marked.slice(0, dot)];
|
|
367
|
+
if (!(dot === -1 ? statedSlot !== void 0 : isRecord(statedSlot) && statedSlot[marked.slice(dot + 1)] !== void 0)) report("fixtures/document-invalid", file, `${at}.slot_overrides.scalar.${marked}: marks a value the instance does not state`);
|
|
368
|
+
}
|
|
369
|
+
const enabled = raw["enabled"];
|
|
370
|
+
const variant = raw["variant"];
|
|
371
|
+
if (enabled !== void 0 && typeof enabled !== "boolean") report("fixtures/document-invalid", file, `${at}.enabled: expected true or false`);
|
|
372
|
+
if (variant !== void 0 && typeof variant !== "string") report("fixtures/document-invalid", file, `${at}.variant: expected a variant case`);
|
|
373
|
+
entries.push({
|
|
374
|
+
section,
|
|
375
|
+
instance,
|
|
376
|
+
values,
|
|
377
|
+
display: {
|
|
378
|
+
...typeof enabled === "boolean" ? { enabled } : {},
|
|
379
|
+
...typeof variant === "string" ? { variant } : {}
|
|
380
|
+
},
|
|
381
|
+
overrides,
|
|
382
|
+
marks: listMarks(marks)
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
return entries;
|
|
386
|
+
function sourcedUnmarked(path, mark) {
|
|
387
|
+
report("fixtures/document-invalid", file, `${path}: a sourced slot is stated only as the user's override — mark it in slot_overrides.scalar["${mark}"], or leave it to its source`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function listMarks(marks) {
|
|
391
|
+
const out = {};
|
|
392
|
+
if (isRecord(marks["items"])) out.items = marks["items"];
|
|
393
|
+
if (isRecord(marks["items_removed"])) out.items_removed = marks["items_removed"];
|
|
394
|
+
if (isRecord(marks["order"])) out.order = marks["order"];
|
|
395
|
+
return out;
|
|
396
|
+
}
|
|
397
|
+
const UPLOAD_FILE_MEMBERS = [
|
|
398
|
+
"file",
|
|
399
|
+
"poster",
|
|
400
|
+
"preview"
|
|
401
|
+
];
|
|
402
|
+
const CONTACT_FILE_MEMBERS = [
|
|
403
|
+
"headshot",
|
|
404
|
+
"logo_dark",
|
|
405
|
+
"logo_light"
|
|
406
|
+
];
|
|
407
|
+
async function loadProperty(store, path, namedIn, at, report) {
|
|
408
|
+
const doc = await readDocument(store, path, namedIn, at, report);
|
|
409
|
+
if (doc === null) return null;
|
|
410
|
+
const property = {};
|
|
411
|
+
for (const [key, value] of Object.entries(doc)) if (!ANNOTATIONS.includes(key)) property[key] = value;
|
|
412
|
+
const file = async (reference, at) => {
|
|
413
|
+
const ref = resolveReference(path, reference);
|
|
414
|
+
if ("problem" in ref) {
|
|
415
|
+
report("fixtures/reference-invalid", path, `${at}: ${ref.problem}`);
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
const media = await store.mediaFile(ref.path);
|
|
419
|
+
if (media === null) report("fixtures/reference-invalid", path, `${at}: "${ref.path}" does not exist`);
|
|
420
|
+
return media;
|
|
421
|
+
};
|
|
422
|
+
const records = (value) => Array.isArray(value) ? value.filter(isRecord) : [];
|
|
423
|
+
const pick = (value, at) => {
|
|
424
|
+
if (!isRecord(value) || typeof value["media"] !== "string") return value;
|
|
425
|
+
for (const key of Object.keys(value)) if (key !== "media") report("fixtures/document-invalid", path, `${at}.${key}: not a member a pick states — it takes { "media": <id> }`);
|
|
426
|
+
return { id: value["media"] };
|
|
427
|
+
};
|
|
428
|
+
const picks = (value, at) => Array.isArray(value) ? value.map((item, i) => pick(item, `${at}[${String(i)}]`)) : value;
|
|
429
|
+
if (Array.isArray(property["uploads"])) property["uploads"] = await Promise.all(property["uploads"].map(async (raw, i) => {
|
|
430
|
+
if (!isRecord(raw)) return raw;
|
|
431
|
+
const entry = { ...raw };
|
|
432
|
+
for (const member of UPLOAD_FILE_MEMBERS) if (entry[member] !== void 0) entry[member] = await file(entry[member], `uploads[${String(i)}].${member}`);
|
|
433
|
+
return entry;
|
|
434
|
+
}));
|
|
435
|
+
for (const list of [
|
|
436
|
+
"property_media",
|
|
437
|
+
"floor_plans",
|
|
438
|
+
"property_documents"
|
|
439
|
+
]) if (property[list] !== void 0) property[list] = picks(property[list], list);
|
|
440
|
+
if (property["hero"] !== void 0) property["hero"] = pick(property["hero"], "hero");
|
|
441
|
+
for (const list of ["units", "commercial_spaces"]) {
|
|
442
|
+
if (!Array.isArray(property[list])) continue;
|
|
443
|
+
property[list] = property[list].map((raw, i) => {
|
|
444
|
+
if (!isRecord(raw)) return raw;
|
|
445
|
+
const at = `${list}[${String(i)}]`;
|
|
446
|
+
const row = { ...raw };
|
|
447
|
+
if (row["photos"] !== void 0) row["photos"] = picks(row["photos"], `${at}.photos`);
|
|
448
|
+
if (Array.isArray(row["floor_plans"])) row["floor_plans"] = row["floor_plans"].map((plan, j) => isRecord(plan) ? {
|
|
449
|
+
...plan,
|
|
450
|
+
image: pick(plan["image"], `${at}.floor_plans[${String(j)}].image`)
|
|
451
|
+
} : plan);
|
|
452
|
+
return row;
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
if (Array.isArray(property["contacts"])) property["contacts"] = await Promise.all(records(property["contacts"]).map(async (raw, i) => {
|
|
456
|
+
const contact = { ...raw };
|
|
457
|
+
for (const member of CONTACT_FILE_MEMBERS) if (typeof contact[member] === "string") contact[member] = await file(contact[member], `contacts[${String(i)}].${member}`);
|
|
458
|
+
return contact;
|
|
459
|
+
}));
|
|
460
|
+
if (Array.isArray(property["comparables"])) property["comparables"] = await Promise.all(records(property["comparables"]).map(async (raw, i) => {
|
|
461
|
+
const comparable = { ...raw };
|
|
462
|
+
if (typeof comparable["photo"] === "string") comparable["photo"] = await file(comparable["photo"], `comparables[${String(i)}].photo`);
|
|
463
|
+
return comparable;
|
|
464
|
+
}));
|
|
465
|
+
const canonical = canonicalizeProperty(property, path);
|
|
466
|
+
for (const violation of canonical.violations) report(violation.rule, violation.file, violation.message);
|
|
467
|
+
return canonical;
|
|
468
|
+
}
|
|
469
|
+
const DATA_SPELLING = {
|
|
470
|
+
media: dataMedia,
|
|
471
|
+
kinds: true
|
|
472
|
+
};
|
|
473
|
+
function dataMedia(def, value, ctx) {
|
|
474
|
+
const allowed = def.type === "image" ? [
|
|
475
|
+
"media",
|
|
476
|
+
"crop",
|
|
477
|
+
"mobile"
|
|
478
|
+
] : ["media"];
|
|
479
|
+
if (!isRecord(value) || typeof value["media"] !== "string" || Object.keys(value).some((key) => !allowed.includes(key))) {
|
|
480
|
+
ctx.violations.push({
|
|
481
|
+
rule: "fixtures/document-invalid",
|
|
482
|
+
file: ctx.module,
|
|
483
|
+
message: `fixture "${ctx.fixtureId}": "${ctx.instance}".${ctx.slot} (${def.type}) states ${JSON.stringify(value)}; it takes { "media": <id> }${def.type === "image" ? ", with a \"crop\" beside it when cropped" : ""}`
|
|
484
|
+
});
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
const id = value["media"];
|
|
488
|
+
const ref = catalogRef(def, id, `${def.type} "${id}", which its property does not carry`, ctx);
|
|
489
|
+
if (ref === null || value["crop"] === void 0 && value["mobile"] === void 0) return ref;
|
|
490
|
+
return croppedPick(ref.media, value["crop"], isRecord(value["mobile"]) ? value["mobile"]["crop"] : void 0, ctx);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
//#endregion
|
|
494
|
+
export { DATA_SPELLING, dataFixtureId, loadDataFixtures, propertyName, resolveReference };
|