@homepages/concrete 8.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1005 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +64 -0
- package/codemods/process-builders.mjs +198 -0
- package/codemods/slot-object.mjs +1097 -0
- package/codemods/steps/content-object-fields.mjs +324 -0
- package/codemods/steps/list-object-form.mjs +6 -7
- package/codemods/table-rows.mjs +568 -0
- package/codemods/unwrap-object-fields.mjs +310 -0
- package/codemods/viewer-slot-document.mjs +131 -0
- package/codemods/write-property-as-facts-document.mjs +716 -0
- package/codemods/write-the-address-line.mjs +255 -0
- package/codemods/write-the-registry-members.mjs +653 -0
- package/codemods/write-the-select-from.mjs +141 -0
- package/codemods/write-the-sole-from.mjs +369 -0
- package/codemods/write-the-table-from.mjs +267 -0
- package/codemods/write-the-whole-item.mjs +512 -0
- package/codemods/writeback-drop.mjs +168 -0
- package/codemods/written-contact-address.mjs +162 -0
- package/codemods/written-media-category.mjs +227 -0
- package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
- package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
- package/codemods/written-uploads-sort-into-lists.mjs +405 -0
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
- package/codemods/written-video-sources-drop.mjs +144 -0
- package/codemods/written-without-pick-none.mjs +146 -0
- package/codemods/written-without-retired-knowledge.mjs +223 -0
- package/codemods/written-without-the-media-key.mjs +202 -0
- package/codemods/written-without-the-property-type.mjs +249 -0
- package/dist/artifact/playground/client/assets/index-BOYbgBnP.js +1259 -0
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +61 -27
- package/dist/base.css +58 -1
- package/dist/cli/build/artifact.js +6 -9
- package/dist/cli/build/captures.js +2 -12
- package/dist/cli/build/esbuild.js +1 -25
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/static.js +2 -2
- package/dist/cli/capture/capture.js +8 -9
- package/dist/cli/check/analyze.js +8 -1
- package/dist/cli/check/load-outdir.js +47 -0
- package/dist/cli/check/load-workspace.js +4 -4
- package/dist/cli/check/render/html.js +1 -2
- package/dist/cli/check/render/inputs.js +10 -3
- package/dist/cli/check/render/island-frames.js +2 -1
- package/dist/cli/check/render/marker-coverage.js +23 -15
- package/dist/cli/check/report.js +5 -0
- package/dist/cli/check/stages/bundles.js +1 -1
- package/dist/cli/check/stages/relations.js +1 -1
- package/dist/cli/check/stages/render.js +48 -33
- package/dist/cli/check/stages/sections.js +83 -31
- package/dist/cli/check/stages/workspace.js +2 -0
- package/dist/cli/check/template-key.js +16 -0
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/crop.js +1 -1
- package/dist/cli/dev/fixture-ladders.js +96 -0
- package/dist/cli/dev/islands.js +12 -123
- package/dist/cli/dev/listen.js +20 -1
- package/dist/cli/dev/load-template.js +1 -1
- package/dist/cli/dev/server.js +35 -10
- package/dist/cli/dev/vite.js +9 -7
- package/dist/cli/dev/workspace-reader.js +16 -16
- package/dist/cli/media/derive.js +43 -57
- package/dist/cli/media/frame-rung-floor.js +0 -1
- package/dist/cli/property/index.js +1 -6
- package/dist/css/inline.js +1 -22
- package/dist/eslint/rules/no-marker-literal.js +1 -1
- package/dist/fixtures/load.js +16 -7
- package/dist/fixtures/media-plugin.js +17 -12
- package/dist/fixtures/media-store.js +115 -0
- package/dist/fixtures/property.js +345 -126
- package/dist/fixtures/resolve.js +260 -251
- package/dist/fixtures/rows.js +4 -11
- package/dist/fixtures.d.ts +234 -109
- package/dist/index.d.ts +25 -16
- package/dist/index.js +10 -6
- package/dist/islands/marker.js +2 -1
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
- package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
- package/dist/packages/internal/capture-settle/dist/index.js +3 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
- package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
- package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +250 -46
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +361 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +25 -18
- package/dist/packages/internal/fill-bake/dist/index.js +9 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +113 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +38 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +174 -0
- package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +363 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +60 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
- package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
- package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
- package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
- package/dist/packages/internal/image-ladder/dist/index.js +3 -3
- package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
- package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
- package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
- package/dist/packages/internal/island-runtime/dist/index.js +2 -1
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
- package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
- package/dist/packages/internal/media-resolution/dist/document.js +63 -0
- package/dist/packages/internal/media-resolution/dist/image.js +226 -0
- package/dist/packages/internal/media-resolution/dist/index.js +11 -0
- package/dist/packages/internal/media-resolution/dist/list.js +112 -0
- package/dist/packages/internal/media-resolution/dist/media.js +59 -0
- package/dist/packages/internal/media-resolution/dist/records.js +7 -0
- package/dist/packages/internal/media-resolution/dist/slot.js +37 -0
- package/dist/packages/internal/media-resolution/dist/store.js +19 -0
- package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
- package/dist/packages/internal/media-resolution/dist/video.js +93 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +245 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +34 -14
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
- package/dist/packages/internal/section-contracts/dist/index.js +7 -2
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +2 -36
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -21
- package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +9 -5
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -17
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +80 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +77 -18
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +89 -95
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
- package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +39 -23
- package/dist/packages/internal/source-resolution/dist/index.js +113 -73
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
- package/dist/packages/internal/street-address/dist/index.js +72 -0
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
- package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
- package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
- package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +81 -0
- package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
- package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +10 -24
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
- package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +93 -0
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
- package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
- package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
- package/dist/packages/internal/template-contracts/dist/list-editing.js +93 -0
- package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
- package/dist/packages/internal/template-contracts/dist/list.js +258 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
- package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
- package/dist/packages/internal/template-contracts/dist/object.js +131 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
- package/dist/packages/internal/template-contracts/dist/read-graph.js +240 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +176 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +270 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
- package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
- package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
- package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +127 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +41 -5
- package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/row.js +84 -0
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +233 -405
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +331 -227
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.js +139 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +95 -0
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
- package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
- package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
- package/dist/platform/fs.js +5 -2
- package/dist/playground/canvas-island-host.d.ts +11 -0
- package/dist/playground/canvas-island-host.js +29 -0
- package/dist/playground/canvas-markers.js +14 -0
- package/dist/playground-island-runtime.d.ts +3 -2
- package/dist/playground-island-runtime.js +3 -2
- package/dist/primitives/FrameShell.js +0 -1
- package/dist/primitives/Image.d.ts +5 -4
- package/dist/primitives/Tour.d.ts +1 -1
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/index.d.ts +2 -3
- package/dist/primitives/picture-sources.js +2 -2
- package/dist/primitives/probe-context.js +2 -12
- package/dist/primitives/slot-address.d.ts +44 -0
- package/dist/primitives/slot-address.js +19 -0
- package/dist/primitives/slot-bindings.d.ts +65 -26
- package/dist/primitives/slot-bindings.js +104 -46
- package/dist/primitives/slot-document.d.ts +23 -18
- package/dist/primitives/slot-document.js +39 -14
- package/dist/primitives/slot-download.d.ts +39 -0
- package/dist/primitives/slot-download.js +39 -0
- package/dist/primitives/slot-list.d.ts +3 -3
- package/dist/primitives/slot-list.js +0 -2
- package/dist/primitives/slot-media.d.ts +24 -5
- package/dist/primitives/slot-media.js +6 -9
- package/dist/primitives/slot-object.d.ts +49 -0
- package/dist/primitives/slot-object.js +20 -0
- package/dist/primitives/slot-scalar.d.ts +27 -2
- package/dist/primitives/slot-scalar.js +50 -7
- package/dist/primitives/slot.d.ts +13 -6
- package/dist/primitives/slot.js +10 -3
- package/dist/rules/registry.js +25 -30
- package/dist/schema/define-schema.d.ts +4 -8
- package/dist/schema/define-schema.js +178 -79
- package/dist/schema/extract-fill-spec.js +2 -153
- package/dist/schema/fact.d.ts +57 -15
- package/dist/schema/fact.js +42 -7
- package/dist/schema/facts-view.d.ts +14 -0
- package/dist/schema/format.d.ts +1 -0
- package/dist/schema/format.js +2 -1
- package/dist/schema/manifest.js +24 -0
- package/dist/schema/property-facts.d.ts +8 -12
- package/dist/schema/section-props.d.ts +2 -66
- package/dist/schema/section-schema.d.ts +8 -11
- package/dist/schema/section-schema.js +27 -10
- package/dist/section/declare.d.ts +18 -7
- package/dist/section/declare.js +18 -5
- package/dist/section/materialize.js +3 -8
- package/dist/section/section.d.ts +12 -8
- package/dist/section/section.js +1 -1
- package/dist/template/logic-shim.d.ts +14 -7
- package/dist/template/logic-shim.js +14 -7
- package/dist/template/materialize.js +17 -18
- package/dist/template/mirror-types.js +30 -31
- package/dist/template/section-reads.js +85 -9
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +29 -25
- package/package.json +9 -8
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
- package/dist/artifact/playground/client/assets/index-Dn_xT16-.js +0 -1101
- package/dist/fixtures/canonical.d.ts +0 -166
- package/dist/fixtures/media.js +0 -163
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -51
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
- package/dist/packages/internal/format-geometry/dist/index.js +0 -4
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
- package/dist/packages/internal/property-facts/dist/index.js +0 -3
- package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
- package/dist/packages/internal/section-contracts/dist/group-contract.js +0 -19
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
- package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -104
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
- package/dist/primitives/slot-group.d.ts +0 -40
- package/dist/primitives/slot-group.js +0 -36
- package/dist/schema/extract-used-facts.js +0 -34
- package/dist/schema/fill-builders.d.ts +0 -115
- package/dist/schema/fill-builders.js +0 -25
- package/dist/schema/fill-declaration.d.ts +0 -14
- package/dist/schema/fill-spec.js +0 -98
- package/dist/schema/layout.d.ts +0 -30
- package/dist/schema/layout.js +0 -14
- package/dist/schema/row-fields.js +0 -88
- package/dist/schema/row-ref.d.ts +0 -59
- package/dist/schema/row-ref.js +0 -28
- package/dist/schema/runtime-values.d.ts +0 -71
- package/dist/schema/section-nav.js +0 -14
- package/dist/schema/slot-builders.d.ts +0 -633
- package/dist/schema/slot-builders.js +0 -177
- package/dist/schema/slot-ref.d.ts +0 -79
- package/dist/schema/slot-ref.js +0 -41
- package/dist/schema/slot-types.d.ts +0 -111
- package/dist/schema/slot-types.js +0 -214
- package/dist/section/groups.js +0 -68
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { mediaRecords } from "../packages/internal/template-contracts/dist/registry-facts.js";
|
|
2
|
+
import { cropKeyOwner } from "../packages/internal/media-resolution/dist/crop-key.js";
|
|
3
|
+
import { recordsOf } from "../packages/internal/media-resolution/dist/records.js";
|
|
4
|
+
import { resolveSlotValue } from "../packages/internal/media-resolution/dist/slot.js";
|
|
5
|
+
import "../packages/internal/media-resolution/dist/index.js";
|
|
6
|
+
|
|
7
|
+
//#region src/fixtures/media-store.ts
|
|
8
|
+
const clamp01 = (n) => n < 0 ? 0 : n > 1 ? 1 : n;
|
|
9
|
+
function cropRectOf(value) {
|
|
10
|
+
if (typeof value !== "object" || value === null) return null;
|
|
11
|
+
const { nx = 0, ny = 0, nw = 1, nh = 1 } = value;
|
|
12
|
+
if (![
|
|
13
|
+
nx,
|
|
14
|
+
ny,
|
|
15
|
+
nw,
|
|
16
|
+
nh
|
|
17
|
+
].every((n) => typeof n === "number" && Number.isFinite(n))) return null;
|
|
18
|
+
const x = clamp01(nx);
|
|
19
|
+
const y = clamp01(ny);
|
|
20
|
+
const rect = {
|
|
21
|
+
nx: x,
|
|
22
|
+
ny: y,
|
|
23
|
+
nw: Math.min(clamp01(nw), 1 - x),
|
|
24
|
+
nh: Math.min(clamp01(nh), 1 - y)
|
|
25
|
+
};
|
|
26
|
+
if (rect.nw <= 0 || rect.nh <= 0) return null;
|
|
27
|
+
return rect.nx === 0 && rect.ny === 0 && rect.nw === 1 && rect.nh === 1 ? null : rect;
|
|
28
|
+
}
|
|
29
|
+
const CROP_KEY = /^processed\/crops\/([^/]+)\/(-?[\d.e-]+)_(-?[\d.e-]+)_(-?[\d.e-]+)_(-?[\d.e-]+)$/;
|
|
30
|
+
function cropOfKey(key) {
|
|
31
|
+
const match = CROP_KEY.exec(key);
|
|
32
|
+
if (match === null || cropKeyOwner(key) === null) return null;
|
|
33
|
+
const rect = cropRectOf({
|
|
34
|
+
nx: Number(match[2]),
|
|
35
|
+
ny: Number(match[3]),
|
|
36
|
+
nw: Number(match[4]),
|
|
37
|
+
nh: Number(match[5])
|
|
38
|
+
});
|
|
39
|
+
return rect === null ? null : {
|
|
40
|
+
id: match[1],
|
|
41
|
+
rect
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function keyOf(file) {
|
|
45
|
+
if (file === null || file === void 0) return null;
|
|
46
|
+
return typeof file === "string" ? file : file.url;
|
|
47
|
+
}
|
|
48
|
+
function fixtureMediaStore(media, serving = {}) {
|
|
49
|
+
const serve = serving.url ?? ((path) => path);
|
|
50
|
+
const files = /* @__PURE__ */ new Map();
|
|
51
|
+
for (const entry of media.values()) for (const file of [entry.file, entry.posterFile]) {
|
|
52
|
+
const key = keyOf(file);
|
|
53
|
+
if (key !== null) files.set(key, file);
|
|
54
|
+
}
|
|
55
|
+
const fileUrl = (key) => files.has(key) ? serve(key) : key;
|
|
56
|
+
const responsiveOf = (key) => {
|
|
57
|
+
const file = key === null ? void 0 : files.get(key);
|
|
58
|
+
if (file === void 0 || typeof file === "string" || file.responsive === null) return null;
|
|
59
|
+
return {
|
|
60
|
+
...file.responsive,
|
|
61
|
+
sources: file.responsive.sources.map((source) => ({
|
|
62
|
+
...source,
|
|
63
|
+
srcset: serveSrcset(source.srcset, serve)
|
|
64
|
+
}))
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
servedUrl: (key) => {
|
|
69
|
+
const crop = cropOfKey(key);
|
|
70
|
+
if (crop === null) return Promise.resolve(fileUrl(key));
|
|
71
|
+
const source = keyOf(media.get(crop.id)?.file);
|
|
72
|
+
if (source === null) return Promise.reject(/* @__PURE__ */ new Error(`no image "${crop.id}" to crop`));
|
|
73
|
+
return Promise.resolve(serving.crop === void 0 ? serve(source) : serving.crop(source, crop.rect));
|
|
74
|
+
},
|
|
75
|
+
fileUrl: (key) => Promise.resolve(fileUrl(key)),
|
|
76
|
+
ladder: () => Promise.resolve({ responsiveFor: (key) => Promise.resolve(responsiveOf(key)) })
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function serveSrcset(srcset, serve) {
|
|
80
|
+
return srcset.split(",").map((rung) => {
|
|
81
|
+
const [url = "", ...descriptors] = rung.trim().split(/\s+/);
|
|
82
|
+
return [serve(url), ...descriptors].join(" ");
|
|
83
|
+
}).join(", ");
|
|
84
|
+
}
|
|
85
|
+
function fixtureAssetRecords(facts, media, sizeOf) {
|
|
86
|
+
const records = recordsOf(facts === null ? null : mediaRecords(facts));
|
|
87
|
+
const sized = /* @__PURE__ */ new Map();
|
|
88
|
+
for (const entry of media.values()) {
|
|
89
|
+
const key = keyOf(entry.file);
|
|
90
|
+
if (key !== null && entry.sizeBytes !== void 0) sized.set(key, entry.sizeBytes);
|
|
91
|
+
}
|
|
92
|
+
return new Map([...records].map(([id, record]) => {
|
|
93
|
+
const bytes = record.bytes ?? (record.key === null ? void 0 : sized.get(record.key) ?? sizeOf?.(record.key));
|
|
94
|
+
return [id, bytes === void 0 || bytes === record.bytes ? record : {
|
|
95
|
+
...record,
|
|
96
|
+
bytes
|
|
97
|
+
}];
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
async function resolveFixtureSlots(input) {
|
|
101
|
+
const ctx = {
|
|
102
|
+
store: input.store,
|
|
103
|
+
assets: input.assets,
|
|
104
|
+
resolvePoi: (value) => value
|
|
105
|
+
};
|
|
106
|
+
const out = {};
|
|
107
|
+
for (const [id, value] of Object.entries(input.slots)) {
|
|
108
|
+
const def = input.declared[id];
|
|
109
|
+
out[id] = await resolveSlotValue(value, def, ctx);
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { cropRectOf, fixtureAssetRecords, fixtureMediaStore, resolveFixtureSlots };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../packages/internal/
|
|
1
|
+
import { storedAddressView } from "../packages/internal/template-contracts/dist/address-value.js";
|
|
2
|
+
import { derivedMembers } from "../packages/internal/template-contracts/dist/fact-compute.js";
|
|
3
|
+
import { splitMedia } from "../packages/internal/template-contracts/dist/registry-facts.js";
|
|
4
|
+
import { propertyFacts } from "../packages/internal/template-contracts/dist/fact-registry.js";
|
|
5
|
+
import { RegistryFactsSchema } from "../packages/internal/property-facts/dist/registry-facts.js";
|
|
3
6
|
import { basename, extname } from "node:path";
|
|
4
7
|
|
|
5
8
|
//#region src/fixtures/property.ts
|
|
@@ -25,6 +28,22 @@ const MIME_BY_EXTENSION = {
|
|
|
25
28
|
".svg": "image/svg+xml",
|
|
26
29
|
".zip": "application/zip"
|
|
27
30
|
};
|
|
31
|
+
const CONTACT_IMAGE_FIELDS = [
|
|
32
|
+
"headshot",
|
|
33
|
+
"logo_dark",
|
|
34
|
+
"logo_light"
|
|
35
|
+
];
|
|
36
|
+
const ADDRESS_PARTS = /* @__PURE__ */ new Set([
|
|
37
|
+
"street",
|
|
38
|
+
"unit",
|
|
39
|
+
"city",
|
|
40
|
+
"state",
|
|
41
|
+
"postal",
|
|
42
|
+
"latitude",
|
|
43
|
+
"longitude",
|
|
44
|
+
"source"
|
|
45
|
+
]);
|
|
46
|
+
const COMPARABLE_FIELDS = propertyFacts.pages.comparables.declaration.element.fields;
|
|
28
47
|
function mediaUrl(file) {
|
|
29
48
|
return typeof file === "string" ? file : file.url;
|
|
30
49
|
}
|
|
@@ -39,9 +58,156 @@ function isMediaFile(value) {
|
|
|
39
58
|
if (typeof value === "string") return value.length > 0;
|
|
40
59
|
return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.width === "number" && typeof value.height === "number";
|
|
41
60
|
}
|
|
61
|
+
function isRecord(value) {
|
|
62
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
63
|
+
}
|
|
64
|
+
const ENTRY_SUBSTITUTIONS = /* @__PURE__ */ new Set([
|
|
65
|
+
"id",
|
|
66
|
+
"file",
|
|
67
|
+
"poster",
|
|
68
|
+
"preview",
|
|
69
|
+
"thumbnail_source_url",
|
|
70
|
+
"source"
|
|
71
|
+
]);
|
|
72
|
+
const FIXTURE_EPOCH = Date.UTC(2026, 0, 1);
|
|
73
|
+
function addedAt(index) {
|
|
74
|
+
return new Date(FIXTURE_EPOCH + index * 1e3).toISOString();
|
|
75
|
+
}
|
|
76
|
+
const NOTHING_STATED = {
|
|
77
|
+
crop: null,
|
|
78
|
+
key: null,
|
|
79
|
+
mime: null,
|
|
80
|
+
bytes: null,
|
|
81
|
+
url: null,
|
|
82
|
+
provider: null,
|
|
83
|
+
account: null,
|
|
84
|
+
page_count: null,
|
|
85
|
+
duration_ms: null,
|
|
86
|
+
width: null,
|
|
87
|
+
height: null,
|
|
88
|
+
captured_at: null,
|
|
89
|
+
scan_count: null,
|
|
90
|
+
poster_at_ms: null,
|
|
91
|
+
renditions: {
|
|
92
|
+
master: null,
|
|
93
|
+
crop: null,
|
|
94
|
+
cutout: null,
|
|
95
|
+
mask_white: null,
|
|
96
|
+
mask_black: null,
|
|
97
|
+
poster: null,
|
|
98
|
+
encode: null
|
|
99
|
+
},
|
|
100
|
+
state: "ready"
|
|
101
|
+
};
|
|
102
|
+
function fixtureRecord(id, kind, name, added, stated) {
|
|
103
|
+
return {
|
|
104
|
+
...NOTHING_STATED,
|
|
105
|
+
id,
|
|
106
|
+
file: id,
|
|
107
|
+
kind,
|
|
108
|
+
name,
|
|
109
|
+
added_at: added,
|
|
110
|
+
...stated
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function linkName(url) {
|
|
114
|
+
return typeof url === "string" ? url.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "") : "";
|
|
115
|
+
}
|
|
116
|
+
function renditionsOf(held) {
|
|
117
|
+
return {
|
|
118
|
+
master: null,
|
|
119
|
+
crop: null,
|
|
120
|
+
cutout: null,
|
|
121
|
+
mask_white: null,
|
|
122
|
+
mask_black: null,
|
|
123
|
+
poster: null,
|
|
124
|
+
encode: null,
|
|
125
|
+
...held
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function renditionOf(file, mime = null) {
|
|
129
|
+
const sized = typeof file === "string" ? null : file;
|
|
130
|
+
return {
|
|
131
|
+
key: mediaUrl(file),
|
|
132
|
+
mime,
|
|
133
|
+
width: sized?.width ?? null,
|
|
134
|
+
height: sized?.height ?? null,
|
|
135
|
+
bytes: null
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function thumbnailRendition(url) {
|
|
139
|
+
return {
|
|
140
|
+
key: url,
|
|
141
|
+
mime: null,
|
|
142
|
+
width: null,
|
|
143
|
+
height: null,
|
|
144
|
+
bytes: null
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const AUTHORED_LISTS = /* @__PURE__ */ new Set([
|
|
148
|
+
"address",
|
|
149
|
+
"uploads",
|
|
150
|
+
"property_media",
|
|
151
|
+
"floor_plans",
|
|
152
|
+
"property_documents",
|
|
153
|
+
"hero",
|
|
154
|
+
"units",
|
|
155
|
+
"commercial_spaces",
|
|
156
|
+
"contacts",
|
|
157
|
+
"comparables"
|
|
158
|
+
]);
|
|
159
|
+
const UNSTATED_UNIT_MEMBERS = {
|
|
160
|
+
floor: null,
|
|
161
|
+
hoa_monthly: null,
|
|
162
|
+
parking: null,
|
|
163
|
+
lot_sqft: null,
|
|
164
|
+
amenities: []
|
|
165
|
+
};
|
|
166
|
+
const UNSTATED_SPACE_MEMBERS = {
|
|
167
|
+
use: null,
|
|
168
|
+
sqft: null,
|
|
169
|
+
price: null,
|
|
170
|
+
floor: null,
|
|
171
|
+
parking: null,
|
|
172
|
+
amenities: []
|
|
173
|
+
};
|
|
174
|
+
const SORTED_LISTS = {
|
|
175
|
+
property_media: {
|
|
176
|
+
kinds: [
|
|
177
|
+
"image",
|
|
178
|
+
"video",
|
|
179
|
+
"tour"
|
|
180
|
+
],
|
|
181
|
+
what: "a photo, video or tour"
|
|
182
|
+
},
|
|
183
|
+
floor_plans: {
|
|
184
|
+
kinds: ["image"],
|
|
185
|
+
what: "a floor plan"
|
|
186
|
+
},
|
|
187
|
+
property_documents: {
|
|
188
|
+
kinds: [
|
|
189
|
+
"document",
|
|
190
|
+
"image",
|
|
191
|
+
"video"
|
|
192
|
+
],
|
|
193
|
+
what: "a document, image or video"
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
function omit(record, keys) {
|
|
197
|
+
return Object.fromEntries(Object.entries(record).filter(([key]) => !keys.has(key)));
|
|
198
|
+
}
|
|
199
|
+
function listOf(value) {
|
|
200
|
+
return Array.isArray(value) ? value : [];
|
|
201
|
+
}
|
|
42
202
|
function canonicalizeProperty(property, file) {
|
|
43
203
|
const violations = [];
|
|
44
204
|
const media = /* @__PURE__ */ new Map();
|
|
205
|
+
const files = {};
|
|
206
|
+
const owning = (record) => {
|
|
207
|
+
const { file, value } = splitMedia(record);
|
|
208
|
+
files[file.id] = file;
|
|
209
|
+
return value;
|
|
210
|
+
};
|
|
45
211
|
const invalid = (message) => {
|
|
46
212
|
violations.push({
|
|
47
213
|
rule: "fixtures/property-invalid",
|
|
@@ -50,15 +216,15 @@ function canonicalizeProperty(property, file) {
|
|
|
50
216
|
});
|
|
51
217
|
};
|
|
52
218
|
const seen = /* @__PURE__ */ new Map();
|
|
53
|
-
const admit = (
|
|
219
|
+
const admit = (list, id, path) => {
|
|
54
220
|
if (typeof id !== "string" || id === "") {
|
|
55
221
|
invalid(`${path}: every entry needs a non-empty string id`);
|
|
56
222
|
return false;
|
|
57
223
|
}
|
|
58
|
-
let ids = seen.get(
|
|
59
|
-
if (ids === void 0) seen.set(
|
|
224
|
+
let ids = seen.get(list);
|
|
225
|
+
if (ids === void 0) seen.set(list, ids = /* @__PURE__ */ new Set());
|
|
60
226
|
if (ids.has(id)) {
|
|
61
|
-
invalid(`${path}: id "${id}" is repeated within ${
|
|
227
|
+
invalid(`${path}: id "${id}" is repeated within ${list}`);
|
|
62
228
|
return false;
|
|
63
229
|
}
|
|
64
230
|
ids.add(id);
|
|
@@ -69,122 +235,171 @@ function canonicalizeProperty(property, file) {
|
|
|
69
235
|
invalid(`${path}: expected an imported media file`);
|
|
70
236
|
return false;
|
|
71
237
|
};
|
|
72
|
-
const photos = [];
|
|
73
|
-
for (const [i, photo] of (property.photos ?? []).entries()) {
|
|
74
|
-
const path = `photos[${i}]`;
|
|
75
|
-
if (!admit("photos", photo.id, path) || !admitFile(photo.file, `${path}.file`)) continue;
|
|
76
|
-
const { file: photoFile, ...row } = photo;
|
|
77
|
-
photos.push(row);
|
|
78
|
-
media.set(photo.id, entry(photo.id, "image", photoFile, photo.caption ?? ""));
|
|
79
|
-
}
|
|
80
|
-
const floorPlans = [];
|
|
81
|
-
for (const [i, plan] of (property.floor_plans ?? []).entries()) {
|
|
82
|
-
const path = `floor_plans[${i}]`;
|
|
83
|
-
if (!admit("floor_plans", plan.id, path) || !admitFile(plan.file, `${path}.file`)) continue;
|
|
84
|
-
const { file: planFile, ...row } = plan;
|
|
85
|
-
floorPlans.push({
|
|
86
|
-
...row,
|
|
87
|
-
processed_s3_key: mediaUrl(planFile)
|
|
88
|
-
});
|
|
89
|
-
media.set(plan.id, entry(plan.id, "image", planFile, ""));
|
|
90
|
-
}
|
|
91
238
|
const admitThumbnail = (value, path) => {
|
|
92
239
|
if (value === void 0) return {};
|
|
93
240
|
if (typeof value === "string" && value !== "") return { posterUrl: value };
|
|
94
241
|
invalid(`${path}.thumbnail_source_url: expected a non-empty URL`);
|
|
95
242
|
return null;
|
|
96
243
|
};
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
244
|
+
const uploads = [];
|
|
245
|
+
const pooled = (id, record, catalog) => {
|
|
246
|
+
uploads.push(owning(record));
|
|
247
|
+
media.set(id, catalog);
|
|
248
|
+
};
|
|
249
|
+
for (const [i, raw] of listOf(property.uploads).entries()) {
|
|
250
|
+
const path = `uploads[${i}]`;
|
|
251
|
+
if (!isRecord(raw)) {
|
|
252
|
+
invalid(`${path}: expected an upload entry`);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (!admit("uploads", raw["id"], path)) continue;
|
|
256
|
+
const id = raw["id"];
|
|
257
|
+
const { file: entryFile, poster, preview, thumbnail_source_url: thumbnail } = raw;
|
|
258
|
+
const stated = omit(raw, ENTRY_SUBSTITUTIONS);
|
|
259
|
+
const added = addedAt(i);
|
|
260
|
+
const fileNamed = (file, held = {}) => ({
|
|
261
|
+
mime: mimeOf(mediaUrl(file)),
|
|
262
|
+
...stated,
|
|
263
|
+
key: mediaUrl(file),
|
|
264
|
+
renditions: renditionsOf(held)
|
|
265
|
+
});
|
|
266
|
+
const kind = raw["kind"];
|
|
267
|
+
if (kind === "video" && raw["source"] !== "upload" && raw["source"] !== "link") {
|
|
268
|
+
invalid(`${path}.source: expected "upload" or "link"`);
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (kind === "image") {
|
|
272
|
+
if (!admitFile(entryFile, `${path}.file`)) continue;
|
|
273
|
+
pooled(id, fixtureRecord(id, "image", displayName(mediaUrl(entryFile)), added, fileNamed(entryFile)), entry(id, "image", entryFile));
|
|
274
|
+
} else if (kind === "video" && raw["source"] === "upload") {
|
|
275
|
+
if (!admitFile(entryFile, `${path}.file`)) continue;
|
|
104
276
|
if (poster !== void 0 && !admitFile(poster, `${path}.poster`)) continue;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
...entry(video.id, "video", videoFile, video.caption ?? ""),
|
|
277
|
+
const held = {
|
|
278
|
+
encode: renditionOf(entryFile, mimeOf(mediaUrl(entryFile))),
|
|
279
|
+
...poster === void 0 ? {} : { poster: renditionOf(poster) }
|
|
280
|
+
};
|
|
281
|
+
pooled(id, fixtureRecord(id, "video", displayName(mediaUrl(entryFile)), added, fileNamed(entryFile, held)), {
|
|
282
|
+
...entry(id, "video", entryFile),
|
|
112
283
|
...poster === void 0 ? {} : { posterFile: poster }
|
|
113
284
|
});
|
|
114
|
-
} else {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
285
|
+
} else if (kind === "video" || kind === "tour") {
|
|
286
|
+
const thumb = admitThumbnail(thumbnail, path);
|
|
287
|
+
if (thumb === null) continue;
|
|
288
|
+
const held = thumb.posterUrl === void 0 ? {} : { poster: thumbnailRendition(thumb.posterUrl) };
|
|
289
|
+
pooled(id, fixtureRecord(id, kind, linkName(raw["url"]), added, {
|
|
290
|
+
...stated,
|
|
291
|
+
renditions: renditionsOf(held)
|
|
292
|
+
}), {
|
|
293
|
+
...entry(id, kind, null),
|
|
294
|
+
url: typeof raw["url"] === "string" ? raw["url"] : null,
|
|
295
|
+
provider: typeof raw["provider"] === "string" ? raw["provider"] : null,
|
|
296
|
+
...thumb
|
|
124
297
|
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
media.set(tour.id, {
|
|
136
|
-
...entry(tour.id, "tour", null, ""),
|
|
137
|
-
url: tour.url,
|
|
138
|
-
provider: tour.provider,
|
|
139
|
-
...poster
|
|
140
|
-
});
|
|
298
|
+
} else if (kind === "document") {
|
|
299
|
+
if (!admitFile(entryFile, `${path}.file`)) continue;
|
|
300
|
+
if (preview !== void 0 && !admitFile(preview, `${path}.preview`)) continue;
|
|
301
|
+
const url = mediaUrl(entryFile);
|
|
302
|
+
const held = preview === void 0 ? {} : { poster: renditionOf(preview) };
|
|
303
|
+
pooled(id, fixtureRecord(id, "document", displayName(url), added, fileNamed(entryFile, held)), {
|
|
304
|
+
...entry(id, "document", entryFile),
|
|
305
|
+
...preview === void 0 ? {} : { posterFile: preview }
|
|
306
|
+
});
|
|
307
|
+
} else invalid(`${path}.kind: expected "image", "video", "tour" or "document"`);
|
|
141
308
|
}
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
media.set(doc.id, entry(doc.id, "document", docFile, ""));
|
|
309
|
+
const statedKinds = new Map(listOf(property.uploads).flatMap((raw) => isRecord(raw) && typeof raw["id"] === "string" ? [[raw["id"], raw["kind"]]] : []));
|
|
310
|
+
const sorted = {
|
|
311
|
+
property_media: [],
|
|
312
|
+
floor_plans: [],
|
|
313
|
+
property_documents: []
|
|
314
|
+
};
|
|
315
|
+
for (const list of Object.keys(SORTED_LISTS)) {
|
|
316
|
+
const { kinds, what } = SORTED_LISTS[list];
|
|
317
|
+
for (const [i, value] of listOf(property[list]).entries()) {
|
|
318
|
+
const path = `${list}[${i}]`;
|
|
319
|
+
const id = isRecord(value) ? value["id"] : void 0;
|
|
320
|
+
const kind = typeof id === "string" ? statedKinds.get(id) : void 0;
|
|
321
|
+
if (typeof id !== "string" || !kinds.includes(kind)) invalid(`${path}: expected ${what} among the property's uploads`);
|
|
322
|
+
else if (admit(list, id, path)) sorted[list].push({ media: id });
|
|
323
|
+
}
|
|
159
324
|
}
|
|
325
|
+
const picked = (value, list, path) => {
|
|
326
|
+
const id = isRecord(value) ? value["id"] : void 0;
|
|
327
|
+
if (typeof id !== "string" || files[id]?.["kind"] !== "image" || !sorted[list].some((ref) => ref.media === id)) {
|
|
328
|
+
invalid(`${path}: expected ${list === "property_media" ? "a photo" : "a floor plan"} among the property's ${list}`);
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
return { media: id };
|
|
332
|
+
};
|
|
333
|
+
const hero = property.hero === void 0 || property.hero === null ? null : picked(property.hero, "property_media", "hero");
|
|
334
|
+
const owned = (value, id, path) => {
|
|
335
|
+
if (value === null || value === void 0) return null;
|
|
336
|
+
if (!admitFile(value, path)) return null;
|
|
337
|
+
media.set(id, entry(id, "image", value));
|
|
338
|
+
return owning(fixtureRecord(id, "image", displayName(mediaUrl(value)), addedAt(0), {
|
|
339
|
+
mime: mimeOf(mediaUrl(value)),
|
|
340
|
+
key: mediaUrl(value)
|
|
341
|
+
}));
|
|
342
|
+
};
|
|
343
|
+
const rowsPicking = (list, rows, unstated) => {
|
|
344
|
+
const out = [];
|
|
345
|
+
for (const [i, raw] of listOf(rows).entries()) {
|
|
346
|
+
const path = `${list}[${i}]`;
|
|
347
|
+
if (!isRecord(raw) || !admit(list, raw["id"], path)) continue;
|
|
348
|
+
const floorPlans = listOf(raw["floor_plans"]).flatMap((plan, j) => {
|
|
349
|
+
const at = `${path}.floor_plans[${j}]`;
|
|
350
|
+
if (!isRecord(plan)) {
|
|
351
|
+
invalid(`${at}: expected a floor plan the row holds`);
|
|
352
|
+
return [];
|
|
353
|
+
}
|
|
354
|
+
const { image, ...rest } = plan;
|
|
355
|
+
const ref = picked(image, "floor_plans", `${at}.image`);
|
|
356
|
+
return ref === null ? [] : [{
|
|
357
|
+
id: ref.media,
|
|
358
|
+
image: ref,
|
|
359
|
+
...rest
|
|
360
|
+
}];
|
|
361
|
+
});
|
|
362
|
+
const photos = listOf(raw["photos"]).flatMap((photo, j) => {
|
|
363
|
+
const ref = picked(photo, "property_media", `${path}.photos[${j}]`);
|
|
364
|
+
return ref === null ? [] : [ref];
|
|
365
|
+
});
|
|
366
|
+
out.push({
|
|
367
|
+
...unstated,
|
|
368
|
+
...raw,
|
|
369
|
+
floor_plans: floorPlans,
|
|
370
|
+
photos
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return out;
|
|
374
|
+
};
|
|
375
|
+
const units = rowsPicking("units", property.units, UNSTATED_UNIT_MEMBERS);
|
|
376
|
+
const commercialSpaces = rowsPicking("commercial_spaces", property.commercial_spaces, UNSTATED_SPACE_MEMBERS);
|
|
377
|
+
const statedAddress = (value, path) => {
|
|
378
|
+
if (value !== null && value !== void 0 && !isRecord(value)) invalid(`${path}: expected an address — its parts and its pin — or null`);
|
|
379
|
+
for (const [key, part] of Object.entries(isRecord(value) ? value : {})) if (!ADDRESS_PARTS.has(key)) invalid(`${path}.${key}: not a member an address states (its parts and its pin)`);
|
|
380
|
+
else if (part !== null && part !== void 0) {
|
|
381
|
+
const coordinate = key === "latitude" || key === "longitude";
|
|
382
|
+
if (coordinate ? typeof part !== "number" : typeof part !== "string") invalid(`${path}.${key}: expected ${coordinate ? "a number" : "a string"} or null`);
|
|
383
|
+
}
|
|
384
|
+
return storedAddressView(value);
|
|
385
|
+
};
|
|
160
386
|
const contacts = [];
|
|
161
|
-
for (const [i,
|
|
387
|
+
for (const [i, raw] of listOf(property.contacts).entries()) {
|
|
162
388
|
const path = `contacts[${i}]`;
|
|
163
|
-
if (!admit("contacts",
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const id = contactImageId(contact.id, field);
|
|
169
|
-
media.set(id, entry(id, "image", value, contact.name ?? ""));
|
|
170
|
-
return id;
|
|
171
|
-
};
|
|
172
|
-
contacts.push({
|
|
173
|
-
...row,
|
|
174
|
-
avatar_upload_id: image(avatar, "avatar"),
|
|
175
|
-
logo_dark_upload_id: image(logoDark, "logo_dark"),
|
|
176
|
-
logo_light_upload_id: image(logoLight, "logo_light")
|
|
177
|
-
});
|
|
389
|
+
if (!isRecord(raw) || !admit("contacts", raw["id"], path)) continue;
|
|
390
|
+
const contact = { ...raw };
|
|
391
|
+
for (const field of CONTACT_IMAGE_FIELDS) contact[field] = owned(raw[field], contactImageId(raw["id"], field), `${path}.${field}`);
|
|
392
|
+
contact["address"] = statedAddress(raw["address"], `${path}.address`);
|
|
393
|
+
contacts.push(contact);
|
|
178
394
|
}
|
|
395
|
+
const subject = statedAddress(property.address, "address");
|
|
179
396
|
const comparables = [];
|
|
180
|
-
for (const [i,
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
comparables.push({
|
|
397
|
+
for (const [i, raw] of listOf(property.comparables).entries()) {
|
|
398
|
+
const path = `comparables[${i}]`;
|
|
399
|
+
if (!isRecord(raw) || !admit("comparables", raw["id"], path)) continue;
|
|
400
|
+
const { photo, ...row } = raw;
|
|
401
|
+
const address = statedAddress(raw["address"], `${path}.address`);
|
|
402
|
+
const comparable = {
|
|
188
403
|
year_built: null,
|
|
189
404
|
lot_sqft: null,
|
|
190
405
|
stories: null,
|
|
@@ -194,9 +409,16 @@ function canonicalizeProperty(property, file) {
|
|
|
194
409
|
listed_date: null,
|
|
195
410
|
mls_number: null,
|
|
196
411
|
description: null,
|
|
197
|
-
property_type: null,
|
|
198
412
|
...row,
|
|
199
|
-
|
|
413
|
+
address,
|
|
414
|
+
photo: owned(photo, comparableImageId(raw["id"]), `${path}.photo`)
|
|
415
|
+
};
|
|
416
|
+
comparables.push({
|
|
417
|
+
...comparable,
|
|
418
|
+
...derivedMembers(COMPARABLE_FIELDS, comparable, {
|
|
419
|
+
address: subject,
|
|
420
|
+
listing_intent: property.listing_intent
|
|
421
|
+
})
|
|
200
422
|
});
|
|
201
423
|
}
|
|
202
424
|
if (violations.length > 0) return {
|
|
@@ -205,23 +427,21 @@ function canonicalizeProperty(property, file) {
|
|
|
205
427
|
violations
|
|
206
428
|
};
|
|
207
429
|
const candidate = {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
430
|
+
site_url: null,
|
|
431
|
+
...omit(property, AUTHORED_LISTS),
|
|
432
|
+
address: subject,
|
|
433
|
+
uploads,
|
|
434
|
+
property_media: sorted.property_media,
|
|
435
|
+
floor_plans: sorted.floor_plans,
|
|
436
|
+
property_documents: sorted.property_documents,
|
|
437
|
+
hero,
|
|
438
|
+
units,
|
|
439
|
+
commercial_spaces: commercialSpaces,
|
|
440
|
+
contacts,
|
|
216
441
|
comparables,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
document_notes: documentNotes,
|
|
221
|
-
documents,
|
|
222
|
-
contacts
|
|
223
|
-
};
|
|
224
|
-
const parsed = PropertyFactsSchema.safeParse(candidate);
|
|
442
|
+
files
|
|
443
|
+
};
|
|
444
|
+
const parsed = RegistryFactsSchema.safeParse(candidate);
|
|
225
445
|
if (!parsed.success) {
|
|
226
446
|
for (const issue of parsed.error.issues) invalid(`${issue.path.map(String).join(".") || "(root)"}: ${issue.message}`);
|
|
227
447
|
return {
|
|
@@ -236,7 +456,7 @@ function canonicalizeProperty(property, file) {
|
|
|
236
456
|
violations
|
|
237
457
|
};
|
|
238
458
|
}
|
|
239
|
-
function entry(id, kind, file
|
|
459
|
+
function entry(id, kind, file) {
|
|
240
460
|
const url = file === null ? "" : mediaUrl(file);
|
|
241
461
|
return {
|
|
242
462
|
id,
|
|
@@ -244,7 +464,6 @@ function entry(id, kind, file, alt) {
|
|
|
244
464
|
file,
|
|
245
465
|
url: null,
|
|
246
466
|
provider: null,
|
|
247
|
-
alt,
|
|
248
467
|
filename: url === "" ? "" : displayName(url),
|
|
249
468
|
mime: url === "" ? "" : mimeOf(url)
|
|
250
469
|
};
|