@homepages/concrete 1.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 +59 -0
- package/README.md +174 -0
- package/codemods/manifest.json +9 -0
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
- package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
- package/dist/artifact/playground/client/index.html +13 -0
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
- package/dist/artifact/playground/host.mjs +127 -0
- package/dist/asset-modules.d.ts +99 -0
- package/dist/base.css +220 -0
- package/dist/browser/site-config.d.ts +18 -0
- package/dist/browser/site-config.js +56 -0
- package/dist/browser/submit-lead.d.ts +98 -0
- package/dist/browser/submit-lead.js +188 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +4 -0
- package/dist/cli/build/artifact.js +225 -0
- package/dist/cli/build/captures.js +67 -0
- package/dist/cli/build/esbuild.js +127 -0
- package/dist/cli/build/fixtures.js +96 -0
- package/dist/cli/build/icons.js +76 -0
- package/dist/cli/build/index.js +38 -0
- package/dist/cli/build/playground.js +31 -0
- package/dist/cli/build/sections.js +236 -0
- package/dist/cli/build/source.js +62 -0
- package/dist/cli/build/static.js +156 -0
- package/dist/cli/capture/bundle.js +37 -0
- package/dist/cli/capture/capture-browser.js +51 -0
- package/dist/cli/capture/capture.js +121 -0
- package/dist/cli/check/analyze.js +95 -0
- package/dist/cli/check/index.js +19 -0
- package/dist/cli/check/load-workspace.js +119 -0
- package/dist/cli/check/messages.js +16 -0
- package/dist/cli/check/render/class-conflicts.js +39 -0
- package/dist/cli/check/render/html.js +86 -0
- package/dist/cli/check/render/inputs.js +53 -0
- package/dist/cli/check/render/invariants.js +58 -0
- package/dist/cli/check/render/island-frames.js +72 -0
- package/dist/cli/check/render/marker-coverage.js +102 -0
- package/dist/cli/check/render/nav.js +64 -0
- package/dist/cli/check/report.js +73 -0
- package/dist/cli/check/stages/bundles.js +129 -0
- package/dist/cli/check/stages/composition.js +67 -0
- package/dist/cli/check/stages/contracts.js +22 -0
- package/dist/cli/check/stages/dependencies.js +261 -0
- package/dist/cli/check/stages/fixtures.js +74 -0
- package/dist/cli/check/stages/lint.js +41 -0
- package/dist/cli/check/stages/logic.js +63 -0
- package/dist/cli/check/stages/render.js +144 -0
- package/dist/cli/check/stages/sections.js +83 -0
- package/dist/cli/check/stages/stylesheet.js +31 -0
- package/dist/cli/check/stages/typecheck.js +68 -0
- package/dist/cli/check/stages/workspace.js +26 -0
- package/dist/cli/commands.js +342 -0
- package/dist/cli/currency/cache.js +89 -0
- package/dist/cli/currency/decide.js +65 -0
- package/dist/cli/currency/opt-out.js +16 -0
- package/dist/cli/currency/preamble.js +183 -0
- package/dist/cli/currency/prompt.js +28 -0
- package/dist/cli/currency/refresh.js +44 -0
- package/dist/cli/currency/resolve-latest.js +185 -0
- package/dist/cli/currency/version-order.js +38 -0
- package/dist/cli/dev/crop.js +22 -0
- package/dist/cli/dev/hmr.js +26 -0
- package/dist/cli/dev/http.js +129 -0
- package/dist/cli/dev/index.js +70 -0
- package/dist/cli/dev/islands.js +390 -0
- package/dist/cli/dev/load-template.js +46 -0
- package/dist/cli/dev/request-error.js +22 -0
- package/dist/cli/dev/server.js +307 -0
- package/dist/cli/dev/tsconfig-paths.js +95 -0
- package/dist/cli/dev/vite.js +85 -0
- package/dist/cli/dev/workspace-reader.js +274 -0
- package/dist/cli/io.d.ts +14 -0
- package/dist/cli/media/cache.js +125 -0
- package/dist/cli/media/derive.js +252 -0
- package/dist/cli/media/deriver-plugin.js +71 -0
- package/dist/cli/property/index.js +180 -0
- package/dist/cli/property/library.js +137 -0
- package/dist/cli/publish/client.js +119 -0
- package/dist/cli/publish/freshness.js +66 -0
- package/dist/cli/publish/git.js +43 -0
- package/dist/cli/publish/index.js +207 -0
- package/dist/cli/publish/pack.js +78 -0
- package/dist/cli/publish/report.js +98 -0
- package/dist/cli/publish/target.js +87 -0
- package/dist/cli/publish/wire.js +29 -0
- package/dist/cli/tar.js +87 -0
- package/dist/cli/upgrade/codemod.js +56 -0
- package/dist/cli/upgrade/index.js +263 -0
- package/dist/cli/upgrade/manifest.js +72 -0
- package/dist/cli/upgrade/plan.js +68 -0
- package/dist/cli/upgrade/stage.js +71 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.js +15 -0
- package/dist/cli/workspace.js +108 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +94 -0
- package/dist/css/compile.js +77 -0
- package/dist/css/graph.js +109 -0
- package/dist/css/inline.js +132 -0
- package/dist/css/rules.js +65 -0
- package/dist/design-system/format-variants.js +127 -0
- package/dist/eslint/authoring.js +46 -0
- package/dist/eslint/correctness.js +42 -0
- package/dist/eslint/rules/editor-declaration.js +103 -0
- package/dist/eslint/rules/editor-reason.js +135 -0
- package/dist/eslint/rules/island-imports.js +20 -0
- package/dist/eslint/rules/jsx-visitor.js +20 -0
- package/dist/eslint/rules/no-client-runtime.js +88 -0
- package/dist/eslint/rules/no-editor-globals.js +60 -0
- package/dist/eslint/rules/no-hard-coded-color.js +183 -0
- package/dist/eslint/rules/no-inline-style.js +24 -0
- package/dist/eslint/rules/no-marker-literal.js +37 -0
- package/dist/eslint/rules/no-nondeterminism.js +44 -0
- package/dist/eslint/rules/no-px-breakpoint.js +44 -0
- package/dist/eslint/rules/no-raw-values.js +45 -0
- package/dist/eslint/rules/serializable-props.js +95 -0
- package/dist/eslint.d.ts +6 -0
- package/dist/eslint.js +26 -0
- package/dist/fixtures/brand.d.ts +4 -0
- package/dist/fixtures/brand.js +9 -0
- package/dist/fixtures/bundle-rule.js +67 -0
- package/dist/fixtures/canonical.d.ts +149 -0
- package/dist/fixtures/image-dimensions.js +59 -0
- package/dist/fixtures/load.js +154 -0
- package/dist/fixtures/media-plugin.js +141 -0
- package/dist/fixtures/media.js +165 -0
- package/dist/fixtures/property.js +210 -0
- package/dist/fixtures/resolve.js +202 -0
- package/dist/fixtures/rows.js +108 -0
- package/dist/fixtures/synthesize-empties.js +42 -0
- package/dist/fixtures.d.ts +213 -0
- package/dist/fixtures.js +37 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +37 -0
- package/dist/islands/client-module.js +97 -0
- package/dist/islands/marker.d.ts +43 -0
- package/dist/islands/marker.js +44 -0
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
- package/dist/packages/external/concrete/package.js +5 -0
- package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
- package/dist/packages/internal/fill-bake/dist/display.js +9 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -0
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
- package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
- package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
- package/dist/packages/internal/format-geometry/dist/index.js +4 -0
- package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
- package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
- package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
- package/dist/packages/internal/image-ladder/dist/index.js +4 -0
- package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
- package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
- package/dist/packages/internal/island-runtime/dist/index.js +163 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
- package/dist/packages/internal/property-facts/dist/index.js +3 -0
- package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
- package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
- package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/index.js +26 -0
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
- package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
- package/dist/packages/internal/source-resolution/dist/index.js +222 -0
- package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
- package/dist/packages/internal/template-artifact/dist/index.js +7 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
- package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
- package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
- package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
- package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
- package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
- package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
- package/dist/playground/host/page-state.js +12 -0
- package/dist/playground/host/paths.js +9 -0
- package/dist/playground/layout.js +24 -0
- package/dist/playground/wire.js +36 -0
- package/dist/playground-island-runtime.d.ts +3 -0
- package/dist/playground-island-runtime.js +4 -0
- package/dist/primitives/FrameShell.d.ts +29 -0
- package/dist/primitives/FrameShell.js +34 -0
- package/dist/primitives/Image.d.ts +119 -0
- package/dist/primitives/Image.js +173 -0
- package/dist/primitives/Section.d.ts +22 -0
- package/dist/primitives/Section.js +26 -0
- package/dist/primitives/Tour.d.ts +43 -0
- package/dist/primitives/Tour.js +72 -0
- package/dist/primitives/Video.d.ts +57 -0
- package/dist/primitives/Video.js +116 -0
- package/dist/primitives/embed-playback.js +50 -0
- package/dist/primitives/index.d.ts +11 -0
- package/dist/primitives/marker-attrs.js +44 -0
- package/dist/primitives/object-fit.js +11 -0
- package/dist/primitives/picture-sources.d.ts +24 -0
- package/dist/primitives/picture-sources.js +52 -0
- package/dist/primitives/probe-context.js +24 -0
- package/dist/primitives/slot-bindings.d.ts +96 -0
- package/dist/primitives/slot-bindings.js +226 -0
- package/dist/primitives/slot-document.d.ts +35 -0
- package/dist/primitives/slot-document.js +37 -0
- package/dist/primitives/slot-group.d.ts +40 -0
- package/dist/primitives/slot-group.js +45 -0
- package/dist/primitives/slot-list.d.ts +21 -0
- package/dist/primitives/slot-list.js +23 -0
- package/dist/primitives/slot-media.d.ts +71 -0
- package/dist/primitives/slot-media.js +98 -0
- package/dist/primitives/slot-scalar.d.ts +53 -0
- package/dist/primitives/slot-scalar.js +98 -0
- package/dist/primitives/slot.d.ts +26 -0
- package/dist/primitives/slot.js +28 -0
- package/dist/rules/registry.js +479 -0
- package/dist/schema/compute.d.ts +22 -0
- package/dist/schema/compute.js +30 -0
- package/dist/schema/define-schema.d.ts +27 -0
- package/dist/schema/define-schema.js +73 -0
- package/dist/schema/extract-fill-spec.js +246 -0
- package/dist/schema/extract-used-facts.js +176 -0
- package/dist/schema/fact.d.ts +65 -0
- package/dist/schema/fact.js +33 -0
- package/dist/schema/fill-builders.d.ts +387 -0
- package/dist/schema/fill-builders.js +263 -0
- package/dist/schema/fill-declaration.d.ts +76 -0
- package/dist/schema/fill-declaration.js +43 -0
- package/dist/schema/fill-spec.d.ts +18 -0
- package/dist/schema/fill-spec.js +170 -0
- package/dist/schema/format-presets.d.ts +27 -0
- package/dist/schema/format-presets.js +76 -0
- package/dist/schema/format.d.ts +22 -0
- package/dist/schema/format.js +40 -0
- package/dist/schema/formats.d.ts +6 -0
- package/dist/schema/formats.js +7 -0
- package/dist/schema/layout.d.ts +32 -0
- package/dist/schema/layout.js +30 -0
- package/dist/schema/manifest.js +300 -0
- package/dist/schema/property-facts.d.ts +83 -0
- package/dist/schema/runtime-values.d.ts +88 -0
- package/dist/schema/section-nav.d.ts +38 -0
- package/dist/schema/section-nav.js +29 -0
- package/dist/schema/section-props.d.ts +98 -0
- package/dist/schema/section-schema.d.ts +53 -0
- package/dist/schema/section-schema.js +54 -0
- package/dist/schema/slot-builders.d.ts +497 -0
- package/dist/schema/slot-builders.js +331 -0
- package/dist/schema/slot-types.d.ts +110 -0
- package/dist/schema/slot-types.js +187 -0
- package/dist/section/declare.d.ts +44 -0
- package/dist/section/declare.js +27 -0
- package/dist/section/discovery.js +76 -0
- package/dist/section/groups.js +74 -0
- package/dist/section/materialize.js +28 -0
- package/dist/section/placements.js +28 -0
- package/dist/section/section.d.ts +69 -0
- package/dist/section/section.js +101 -0
- package/dist/site-analytics.d.ts +1 -0
- package/dist/site-analytics.js +15 -0
- package/dist/site-runtime/analytics.js +97 -0
- package/dist/site-runtime/site-integrations.js +97 -0
- package/dist/styles.css +60 -0
- package/dist/template/define-template.d.ts +139 -0
- package/dist/template/define-template.js +98 -0
- package/dist/template/logic-build.js +191 -0
- package/dist/template/logic-shim.d.ts +43 -0
- package/dist/template/logic-shim.js +52 -0
- package/dist/template/logic-transform.js +92 -0
- package/dist/template/materialize.js +107 -0
- package/dist/template/reconcile.d.ts +67 -0
- package/dist/template/reconcile.js +25 -0
- package/dist/template/running-copy.js +58 -0
- package/guide/reference/cli/INDEX.md +79 -0
- package/guide/reference/cli/build.md +48 -0
- package/guide/reference/cli/check.md +49 -0
- package/guide/reference/cli/dev.md +46 -0
- package/guide/reference/cli/property-add.md +53 -0
- package/guide/reference/cli/property-list.md +46 -0
- package/guide/reference/cli/publish.md +54 -0
- package/guide/reference/cli/upgrade.md +48 -0
- package/guide/reference/rules/INDEX.md +190 -0
- package/package.json +137 -0
- package/tsconfig.base.json +16 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { COLLECTION_PROJECTIONS, buildUnitFloorplanList, readFrom, rowFieldSources } from "../../source-resolution/dist/index.js";
|
|
3
|
+
import { buildDeriveFactsView } from "../../property-facts/dist/derive-facts-view.js";
|
|
4
|
+
import { declaredDisplay } from "./display.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/fill-bake/dist/bake-property-ref.js
|
|
7
|
+
function directField(def) {
|
|
8
|
+
if (def.source === null || def.source === void 0 || typeof def.source !== "object") return null;
|
|
9
|
+
const src = def.source;
|
|
10
|
+
if (src["kind"] !== "direct") return null;
|
|
11
|
+
return typeof src["field"] === "string" ? src["field"] : null;
|
|
12
|
+
}
|
|
13
|
+
function resolveDirectField(field, facts, rowFields) {
|
|
14
|
+
if (Object.hasOwn(COLLECTION_PROJECTIONS, field)) return COLLECTION_PROJECTIONS[field](facts, rowFields);
|
|
15
|
+
if (field === "unit_floorplans") return buildUnitFloorplanList(facts);
|
|
16
|
+
return readFrom(field, { facts });
|
|
17
|
+
}
|
|
18
|
+
function derivedSource(def) {
|
|
19
|
+
if (def.source === null || def.source === void 0 || typeof def.source !== "object") return null;
|
|
20
|
+
const src = def.source;
|
|
21
|
+
if (src["kind"] !== "derived") return null;
|
|
22
|
+
return typeof src["transform"] === "string" ? { transform: src["transform"] } : null;
|
|
23
|
+
}
|
|
24
|
+
function bakePropertyRefSlots(schema, facts, ctx) {
|
|
25
|
+
const slots = schema.slots ?? {};
|
|
26
|
+
const out = {};
|
|
27
|
+
let factsView;
|
|
28
|
+
const deriveFacts = () => factsView ??= buildDeriveFactsView(facts);
|
|
29
|
+
for (const [name, def] of Object.entries(slots)) {
|
|
30
|
+
const dField = directField(def);
|
|
31
|
+
if (dField !== null) {
|
|
32
|
+
try {
|
|
33
|
+
out[name] = resolveDirectField(dField, facts, rowFieldSources(def.fields));
|
|
34
|
+
} catch {
|
|
35
|
+
out[name] = null;
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const derived = derivedSource(def);
|
|
40
|
+
if (derived !== null) {
|
|
41
|
+
const resolved = resolveDerivedHandle(derived.transform, deriveFacts, ctx, { slot_id: name });
|
|
42
|
+
out[name] = resolved === null ? null : resolved.value;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* One authored `compute()` handle, bound to the derive-time facts view. Returns
|
|
50
|
+
* `null` when the bundle does not carry the handle at all or the fn threw —
|
|
51
|
+
* one failure channel for both, with one structured log. An unresolvable handle
|
|
52
|
+
* is raised into that channel rather than resolving quietly: with the registry
|
|
53
|
+
* gone this log is the only thing that makes a stale section pin — a
|
|
54
|
+
* schema naming a handle its logic bundle never exported — observable in
|
|
55
|
+
* production. What an unresolved handle MEANS is the caller's: a slot bakes
|
|
56
|
+
* null, a display entry falls back to its first declared case.
|
|
57
|
+
*/
|
|
58
|
+
function resolveDerivedHandle(derivedHandle, deriveFacts, ctx, target) {
|
|
59
|
+
const authored = ctx?.computed?.[derivedHandle];
|
|
60
|
+
try {
|
|
61
|
+
if (authored === void 0) throw new Error(`derived handle "${derivedHandle}" is not in the section's computed map`);
|
|
62
|
+
return { value: authored(deriveFacts()) };
|
|
63
|
+
} catch (err) {
|
|
64
|
+
ctx?.log?.error({
|
|
65
|
+
event: "derive_function_threw",
|
|
66
|
+
section_key: ctx.section_key,
|
|
67
|
+
...target,
|
|
68
|
+
derived_handle: derivedHandle,
|
|
69
|
+
err
|
|
70
|
+
}, "derive: authored function threw or is missing; resolved to nothing");
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The `source`-origin entries of a section's `display` block, resolved from the
|
|
76
|
+
* same facts bundle its slots bake from. `fill`-origin entries are absent by
|
|
77
|
+
* design — the `display-select` decision decides those — and so is any entry
|
|
78
|
+
* whose compute failed or answered outside its declared cases: an unresolved
|
|
79
|
+
* entry falls back to its first declared case at completion (./display.ts).
|
|
80
|
+
*
|
|
81
|
+
* An entry's origin is always the `derived` literal `defineSchema` rewrites a
|
|
82
|
+
* `compute()` binding to, so there is no `direct` axis to dispatch here.
|
|
83
|
+
*/
|
|
84
|
+
function bakeDisplayEntries(schema, facts, ctx) {
|
|
85
|
+
const display = declaredDisplay(schema);
|
|
86
|
+
const out = {};
|
|
87
|
+
let factsView;
|
|
88
|
+
const deriveFacts = () => factsView ??= buildDeriveFactsView(facts);
|
|
89
|
+
for (const entry of DISPLAY_ENTRIES) {
|
|
90
|
+
const def = display[entry];
|
|
91
|
+
const derivedHandle = def?.source?.transform;
|
|
92
|
+
if (def === void 0 || typeof derivedHandle !== "string") continue;
|
|
93
|
+
const resolved = resolveDerivedHandle(derivedHandle, deriveFacts, ctx, { display_entry: entry });
|
|
94
|
+
if (resolved === null) continue;
|
|
95
|
+
const answer = typeof resolved.value === "string" ? resolved.value : "";
|
|
96
|
+
if (def.cases?.includes(answer) !== true) {
|
|
97
|
+
ctx?.log?.error({
|
|
98
|
+
event: "display_compute_out_of_vocabulary",
|
|
99
|
+
section_key: ctx.section_key,
|
|
100
|
+
display_entry: entry,
|
|
101
|
+
answer: resolved.value
|
|
102
|
+
}, "display: source compute answered outside its declared cases; falling back to the first case");
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
out[entry] = answer;
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
export { bakeDisplayEntries, bakePropertyRefSlots, derivedSource, directField, resolveDirectField };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region ../../internal/fill-bake/dist/display.js
|
|
2
|
+
/** The section's declared display entries, defensive against loose JSONB. */
|
|
3
|
+
function declaredDisplay(schema) {
|
|
4
|
+
const display = schema.display;
|
|
5
|
+
return display !== null && typeof display === "object" ? display : {};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { declaredDisplay };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { buildDeriveFactsView } from "../../property-facts/dist/derive-facts-view.js";
|
|
2
|
+
import { declaredDisplay } from "./display.js";
|
|
3
|
+
import { bakeDisplayEntries, bakePropertyRefSlots, derivedSource, directField, resolveDirectField } from "./bake-property-ref.js";
|
|
4
|
+
import { applyReconcile } from "./reconcile-cross-section.js";
|
|
5
|
+
|
|
6
|
+
export { applyReconcile, bakeDisplayEntries, bakePropertyRefSlots };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { buildDeriveFactsView } from "../../property-facts/dist/derive-facts-view.js";
|
|
2
|
+
import { isSlotOverridden } from "../../template-contracts/dist/slot-overrides.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/fill-bake/dist/reconcile-cross-section.js
|
|
5
|
+
function buildSite(doc, instances) {
|
|
6
|
+
const byInstanceId = new Map(doc.instances.map((inst) => [inst.instance_id, inst]));
|
|
7
|
+
const site = {};
|
|
8
|
+
for (const { key, instanceId } of instances) site[key] = { ...byInstanceId.get(instanceId)?.slots };
|
|
9
|
+
return site;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Wraps each section's slot bag in a read-tracing Proxy, warning once per slot when
|
|
13
|
+
* a rule reads something it did not declare in `reads`. The declaration drives the
|
|
14
|
+
* editor's propagate trigger, so a drifted one silently stops a user edit from
|
|
15
|
+
* re-running this rule, and this is what keeps that observable rather than silent.
|
|
16
|
+
*
|
|
17
|
+
* Warn-only: it never throws and never alters an edit, matching how this interpreter
|
|
18
|
+
* already treats a rule that throws or returns malformed data. Reading a whole
|
|
19
|
+
* section (`{...site.slider}`, `Object.values(site.slider)`) trips the trap for every
|
|
20
|
+
* key, so a spread-style rule over-reports — acceptable, and it pushes authors toward
|
|
21
|
+
* over-declaring, which costs one extra propagate job rather than a stale page.
|
|
22
|
+
*/
|
|
23
|
+
function traceReads(site, instances, rule, log) {
|
|
24
|
+
if (!rule.reads) return site;
|
|
25
|
+
const instanceIdByKey = new Map(instances.map((i) => [i.key, i.instanceId]));
|
|
26
|
+
const declared = new Set(rule.reads.map((r) => `${r.instanceId} ${r.slot}`));
|
|
27
|
+
const warned = /* @__PURE__ */ new Set();
|
|
28
|
+
const traced = {};
|
|
29
|
+
for (const [key, slots] of Object.entries(site)) {
|
|
30
|
+
const instanceId = instanceIdByKey.get(key);
|
|
31
|
+
traced[key] = new Proxy(slots, { get(target, prop, receiver) {
|
|
32
|
+
if (typeof prop === "string" && instanceId !== void 0) {
|
|
33
|
+
const id = `${instanceId} ${prop}`;
|
|
34
|
+
if (!declared.has(id) && !warned.has(id)) {
|
|
35
|
+
warned.add(id);
|
|
36
|
+
log?.warn({
|
|
37
|
+
event: "reconcile_undeclared_read",
|
|
38
|
+
rule: rule.description,
|
|
39
|
+
instance_id: instanceId,
|
|
40
|
+
slot: prop
|
|
41
|
+
}, "reconcile: rule read a slot absent from its `reads` declaration; an editor edit to that slot will not re-run this rule");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return Reflect.get(target, prop, receiver);
|
|
45
|
+
} });
|
|
46
|
+
}
|
|
47
|
+
return traced;
|
|
48
|
+
}
|
|
49
|
+
function isEdit(candidate) {
|
|
50
|
+
if (candidate === null || typeof candidate !== "object") return false;
|
|
51
|
+
const edit = candidate;
|
|
52
|
+
if (typeof edit.instanceId !== "string" || edit.instanceId === "") return false;
|
|
53
|
+
if (edit.op === "hide") return true;
|
|
54
|
+
return edit.op === "set" && typeof edit.slot === "string" && edit.slot !== "";
|
|
55
|
+
}
|
|
56
|
+
function applyEdits(doc, edits, rule, log) {
|
|
57
|
+
const known = new Set(doc.instances.map((inst) => inst.instance_id));
|
|
58
|
+
const setInstanceIds = [];
|
|
59
|
+
let instances = doc.instances;
|
|
60
|
+
let changed = false;
|
|
61
|
+
for (const edit of edits) {
|
|
62
|
+
if (!known.has(edit.instanceId)) {
|
|
63
|
+
log?.warn({
|
|
64
|
+
event: "reconcile_unknown_instance",
|
|
65
|
+
rule: rule.description,
|
|
66
|
+
instance_id: edit.instanceId
|
|
67
|
+
}, "reconcile: edit names an instance absent from the content_doc; skipped");
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
instances = instances.map((inst) => {
|
|
71
|
+
if (inst.instance_id !== edit.instanceId) return inst;
|
|
72
|
+
if (edit.op === "hide") {
|
|
73
|
+
if (!inst.enabled) return inst;
|
|
74
|
+
changed = true;
|
|
75
|
+
return {
|
|
76
|
+
...inst,
|
|
77
|
+
enabled: false
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (isSlotOverridden(inst.slot_overrides, edit.slot)) {
|
|
81
|
+
log?.debug({
|
|
82
|
+
event: "reconcile_skipped_overridden_slot",
|
|
83
|
+
rule: rule.description,
|
|
84
|
+
instance_id: edit.instanceId,
|
|
85
|
+
slot: edit.slot
|
|
86
|
+
}, "reconcile: target slot carries a user override marker; edit skipped");
|
|
87
|
+
return inst;
|
|
88
|
+
}
|
|
89
|
+
changed = true;
|
|
90
|
+
setInstanceIds.push(inst.instance_id);
|
|
91
|
+
return {
|
|
92
|
+
...inst,
|
|
93
|
+
slots: {
|
|
94
|
+
...inst.slots,
|
|
95
|
+
[edit.slot]: edit.value
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return changed ? {
|
|
101
|
+
contentDoc: {
|
|
102
|
+
...doc,
|
|
103
|
+
instances
|
|
104
|
+
},
|
|
105
|
+
changed,
|
|
106
|
+
setInstanceIds
|
|
107
|
+
} : {
|
|
108
|
+
contentDoc: doc,
|
|
109
|
+
changed: false,
|
|
110
|
+
setInstanceIds: []
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Runs a template's reconcile rules over the merged content_doc, in order, each
|
|
115
|
+
* against the previous rule's output. Pure: returns a new document (or the same
|
|
116
|
+
* reference when nothing changed) and never mutates its input.
|
|
117
|
+
*
|
|
118
|
+
* A rule that throws is skipped with a warning rather than failing the job —
|
|
119
|
+
* reconciliation is fill-time repair, not an invariant, and losing one repair is
|
|
120
|
+
* strictly better than losing the whole generated website.
|
|
121
|
+
*/
|
|
122
|
+
function applyReconcile(doc, facts, logicModule, log) {
|
|
123
|
+
let cur = doc;
|
|
124
|
+
let changed = false;
|
|
125
|
+
const setInstanceIds = /* @__PURE__ */ new Set();
|
|
126
|
+
for (const rule of logicModule.reconcile) {
|
|
127
|
+
let produced;
|
|
128
|
+
try {
|
|
129
|
+
const site = traceReads(buildSite(cur, logicModule.instances), logicModule.instances, rule, log);
|
|
130
|
+
produced = rule.fn({
|
|
131
|
+
site,
|
|
132
|
+
page: site,
|
|
133
|
+
facts
|
|
134
|
+
});
|
|
135
|
+
} catch (err) {
|
|
136
|
+
log?.warn({
|
|
137
|
+
event: "reconcile_rule_threw",
|
|
138
|
+
rule: rule.description,
|
|
139
|
+
err
|
|
140
|
+
}, "reconcile: authored rule threw; skipped");
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (!Array.isArray(produced)) {
|
|
144
|
+
log?.warn({
|
|
145
|
+
event: "reconcile_rule_bad_return",
|
|
146
|
+
rule: rule.description
|
|
147
|
+
}, "reconcile: authored rule did not return an array of edits; skipped");
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const edits = produced.filter(isEdit);
|
|
151
|
+
if (edits.length !== produced.length) log?.warn({
|
|
152
|
+
event: "reconcile_malformed_edit",
|
|
153
|
+
rule: rule.description
|
|
154
|
+
}, "reconcile: authored rule returned a malformed edit; dropped");
|
|
155
|
+
const applied = applyEdits(cur, edits, rule, log);
|
|
156
|
+
if (applied.changed) {
|
|
157
|
+
cur = applied.contentDoc;
|
|
158
|
+
changed = true;
|
|
159
|
+
for (const id of applied.setInstanceIds) setInstanceIds.add(id);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
contentDoc: cur,
|
|
164
|
+
changed,
|
|
165
|
+
setInstanceIds: [...setInstanceIds]
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
export { applyReconcile };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region ../../internal/fill-vocabulary/dist/facts.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Canonical top-level ARRAY fields a fill-spec decision may `iterate:` over.
|
|
4
|
+
*
|
|
5
|
+
* `videos` is the hosted-video candidate pool and is iterable — a
|
|
6
|
+
* video_collection section renders N videos, exactly the shape `iterate:`
|
|
7
|
+
* exists for. It is deliberately absent from `FACTS_READABLE`: nothing grounds
|
|
8
|
+
* prose on the pool yet, and `reads: videos` is additive to legalize later.
|
|
9
|
+
*/
|
|
10
|
+
declare const FACTS_ARRAY_FIELDS: readonly ["units", "photos", "videos", "floor_plans", "contacts", "tours", "comparables"];
|
|
11
|
+
/** An iterable property-facts array — one of `FACTS_ARRAY_FIELDS`. */
|
|
12
|
+
type IterableFactsField = (typeof FACTS_ARRAY_FIELDS)[number];
|
|
13
|
+
/**
|
|
14
|
+
* The facts keys an author may name in a fill-spec's `reads`, and therefore
|
|
15
|
+
* the keys the fill executor's relevance slice carries on demand. The two are
|
|
16
|
+
* one set on purpose: a key legal to declare but absent from the slice
|
|
17
|
+
* validates and then grounds nothing.
|
|
18
|
+
*
|
|
19
|
+
* `tours` is BOTH readable and iterable — a section may ground prose on it and
|
|
20
|
+
* may `iterate:` it to render one row per 3D tour on the property.
|
|
21
|
+
*
|
|
22
|
+
* `comparables` is both as well: a pricing-strategy narrative grounds its prose
|
|
23
|
+
* on the rows (`reads: ["comparables"]`), and a comps table renders one row per
|
|
24
|
+
* comparable. The numbers on such a slide are never written by fill — they are
|
|
25
|
+
* a `compute()` over the same rows — which is exactly why the rows themselves
|
|
26
|
+
* must be readable.
|
|
27
|
+
*/
|
|
28
|
+
declare const FACTS_READABLE: readonly ["tours", "floor_plans", "photos", "comparables"];
|
|
29
|
+
/** A facts key an author may declare in `reads` — one of `FACTS_READABLE`. */
|
|
30
|
+
type ReadableFactsKey = (typeof FACTS_READABLE)[number];
|
|
31
|
+
//#endregion
|
|
32
|
+
export { FACTS_ARRAY_FIELDS, FACTS_READABLE, IterableFactsField, ReadableFactsKey };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
//#region ../../internal/fill-vocabulary/dist/facts.js
|
|
2
|
+
/**
|
|
3
|
+
* Canonical top-level ARRAY fields a fill-spec decision may `iterate:` over.
|
|
4
|
+
*
|
|
5
|
+
* `videos` is the hosted-video candidate pool and is iterable — a
|
|
6
|
+
* video_collection section renders N videos, exactly the shape `iterate:`
|
|
7
|
+
* exists for. It is deliberately absent from `FACTS_READABLE`: nothing grounds
|
|
8
|
+
* prose on the pool yet, and `reads: videos` is additive to legalize later.
|
|
9
|
+
*/
|
|
10
|
+
const FACTS_ARRAY_FIELDS = [
|
|
11
|
+
"units",
|
|
12
|
+
"photos",
|
|
13
|
+
"videos",
|
|
14
|
+
"floor_plans",
|
|
15
|
+
"contacts",
|
|
16
|
+
"tours",
|
|
17
|
+
"comparables"
|
|
18
|
+
];
|
|
19
|
+
/** Whether `value` names an iterable property-facts array. */
|
|
20
|
+
function isIterableFactsField(value) {
|
|
21
|
+
return FACTS_ARRAY_FIELDS.includes(value);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The facts keys an author may name in a fill-spec's `reads`, and therefore
|
|
25
|
+
* the keys the fill executor's relevance slice carries on demand. The two are
|
|
26
|
+
* one set on purpose: a key legal to declare but absent from the slice
|
|
27
|
+
* validates and then grounds nothing.
|
|
28
|
+
*
|
|
29
|
+
* `tours` is BOTH readable and iterable — a section may ground prose on it and
|
|
30
|
+
* may `iterate:` it to render one row per 3D tour on the property.
|
|
31
|
+
*
|
|
32
|
+
* `comparables` is both as well: a pricing-strategy narrative grounds its prose
|
|
33
|
+
* on the rows (`reads: ["comparables"]`), and a comps table renders one row per
|
|
34
|
+
* comparable. The numbers on such a slide are never written by fill — they are
|
|
35
|
+
* a `compute()` over the same rows — which is exactly why the rows themselves
|
|
36
|
+
* must be readable.
|
|
37
|
+
*/
|
|
38
|
+
const FACTS_READABLE = [
|
|
39
|
+
"tours",
|
|
40
|
+
"floor_plans",
|
|
41
|
+
"photos",
|
|
42
|
+
"comparables"
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* Whether `value` names a declarable read. A `reads` entry may be dotted
|
|
46
|
+
* (`"floor_plans.units"`); the slice copies whole top-level keys, so only the
|
|
47
|
+
* base segment is the claim being checked.
|
|
48
|
+
*/
|
|
49
|
+
function isReadableFactsKey(value) {
|
|
50
|
+
const base = value.split(".")[0] ?? value;
|
|
51
|
+
return FACTS_READABLE.includes(base);
|
|
52
|
+
}
|
|
53
|
+
const SCALAR = { kind: "scalar" };
|
|
54
|
+
/** Every named field terminal — the common case, since most fact leaves are strings or numbers. */
|
|
55
|
+
function scalars(...names) {
|
|
56
|
+
return Object.fromEntries(names.map((name) => [name, SCALAR]));
|
|
57
|
+
}
|
|
58
|
+
function object(fields) {
|
|
59
|
+
return {
|
|
60
|
+
kind: "object",
|
|
61
|
+
fields
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function listOf(element) {
|
|
65
|
+
return {
|
|
66
|
+
kind: "array",
|
|
67
|
+
element
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const ADDRESS = object(scalars("display", "street", "street_no_type", "city", "state", "postal", "unit"));
|
|
71
|
+
const NARRATIVE = object(scalars("description"));
|
|
72
|
+
const TOUR = object(scalars("id", "url", "provider"));
|
|
73
|
+
const DOCUMENT_NOTE = object(scalars("upload_id", "notes"));
|
|
74
|
+
const PHOTO = object({
|
|
75
|
+
...scalars("id", "caption"),
|
|
76
|
+
tags: listOf(SCALAR)
|
|
77
|
+
});
|
|
78
|
+
const UNIT = object({
|
|
79
|
+
...scalars("unit_id", "unit_label", "beds", "baths", "sqft", "price", "position"),
|
|
80
|
+
floor_plans: listOf(object(scalars("id", "upload_id", "floor_label", "position")))
|
|
81
|
+
});
|
|
82
|
+
const FLOOR_PLAN = object({
|
|
83
|
+
...scalars("id", "upload_id", "page_index", "processed_s3_key"),
|
|
84
|
+
unit_assignments: listOf(object(scalars("unit_label", "floor_label", "position")))
|
|
85
|
+
});
|
|
86
|
+
const COMPARABLE = object(scalars("id", "address_street", "address_city", "address_state", "address_postal", "address", "lat", "lng", "distance_m", "status", "price", "price_period", "sale_date", "beds", "baths", "sqft", "photo_url", "source_url", "source_name"));
|
|
87
|
+
/**
|
|
88
|
+
* Every root a `${facts.<root>…}` prompt reference may name, and the shape of
|
|
89
|
+
* what sits beneath it.
|
|
90
|
+
*
|
|
91
|
+
* This is the SLICE's key space, not the whole fact graph: the interpolator
|
|
92
|
+
* expands a prompt against the per-section relevance slice, so a root the slice
|
|
93
|
+
* does not carry substitutes the empty string and ships blank grounding with no
|
|
94
|
+
* error anywhere. That is what `assertInterpolationContract` rejects — and it
|
|
95
|
+
* rejects a bad segment BELOW a root on the same argument, which is why these
|
|
96
|
+
* are shapes rather than a flat scalar/structured flag.
|
|
97
|
+
*
|
|
98
|
+
* The `primary_contact_*` roots are VIRTUAL: they are not canonical facts keys
|
|
99
|
+
* (a contact card holds them), and the slice denormalizes them under these
|
|
100
|
+
* historical names so pinned fill-specs keep resolving. Every other root is a
|
|
101
|
+
* real `PropertyFactsSchema` top-level key whose whole shape `facts.test.ts`
|
|
102
|
+
* checks against the canonical schema.
|
|
103
|
+
*/
|
|
104
|
+
const FACTS_INTERPOLABLE_ROOTS = {
|
|
105
|
+
address: ADDRESS,
|
|
106
|
+
narrative: NARRATIVE,
|
|
107
|
+
units: listOf(UNIT),
|
|
108
|
+
photos: listOf(PHOTO),
|
|
109
|
+
document_notes: listOf(DOCUMENT_NOTE),
|
|
110
|
+
tours: listOf(TOUR),
|
|
111
|
+
floor_plans: listOf(FLOOR_PLAN),
|
|
112
|
+
comparables: listOf(COMPARABLE),
|
|
113
|
+
lat: SCALAR,
|
|
114
|
+
lon: SCALAR,
|
|
115
|
+
property_type: SCALAR,
|
|
116
|
+
listing_intent: SCALAR,
|
|
117
|
+
primary_contact_name: SCALAR,
|
|
118
|
+
primary_contact_title: SCALAR,
|
|
119
|
+
primary_contact_bio: SCALAR,
|
|
120
|
+
primary_contact_email: SCALAR,
|
|
121
|
+
primary_contact_phone: SCALAR,
|
|
122
|
+
primary_contact_address: SCALAR,
|
|
123
|
+
primary_contact_website_url: SCALAR,
|
|
124
|
+
primary_contact_instagram_url: SCALAR,
|
|
125
|
+
primary_contact_linkedin_url: SCALAR,
|
|
126
|
+
primary_contact_x_url: SCALAR,
|
|
127
|
+
primary_contact_facebook_url: SCALAR
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { FACTS_ARRAY_FIELDS, FACTS_INTERPOLABLE_ROOTS, FACTS_READABLE, isIterableFactsField, isReadableFactsKey };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region ../../internal/fill-vocabulary/dist/row-planners.js
|
|
2
|
+
/**
|
|
3
|
+
* The decision `type` each planner reads off a row field's fill declaration.
|
|
4
|
+
*
|
|
5
|
+
* Adding an entry is a claim that the executor implements it; the executor's own
|
|
6
|
+
* suite asserts its planner map against these keys, so the claim fails there
|
|
7
|
+
* rather than in a worker.
|
|
8
|
+
*/
|
|
9
|
+
const PLANNER_DECISION_TYPES = {
|
|
10
|
+
text: "text-block",
|
|
11
|
+
list: "list-fill",
|
|
12
|
+
select: "list-fill",
|
|
13
|
+
choice: "select-assign",
|
|
14
|
+
assets: "list-fill",
|
|
15
|
+
image: "image-assign",
|
|
16
|
+
video: "video-assign",
|
|
17
|
+
tour: "tour-assign",
|
|
18
|
+
document: "document-assign"
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The asset primitives a list may pool its ROWS from, and a row field may pick
|
|
22
|
+
* one of. Each names a property-level candidate pool the model selects out of by
|
|
23
|
+
* id — photos, videos, 3D tours, and stored documents.
|
|
24
|
+
*/
|
|
25
|
+
const POOLING_PRIMITIVES = [
|
|
26
|
+
"image",
|
|
27
|
+
"video",
|
|
28
|
+
"tour",
|
|
29
|
+
"document"
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* The pool a declared field draws from, or `undefined` when it draws from none.
|
|
33
|
+
*
|
|
34
|
+
* The same derivation answers both questions the family asks of a media
|
|
35
|
+
* declaration — which pool ORIGINATION draws rows from, and which pool a row
|
|
36
|
+
* field's planner picks one asset from — so "this is a media declaration"
|
|
37
|
+
* cannot mean one thing at the list level and another inside a row.
|
|
38
|
+
*/
|
|
39
|
+
function poolingPrimitiveOf(field) {
|
|
40
|
+
return POOLING_PRIMITIVES.includes(field.type ?? "") ? field.type : void 0;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The planner a row field's declared item content selects, or `undefined` when
|
|
44
|
+
* that primitive takes no fill at all. A `list` splits on its ELEMENT: a select
|
|
45
|
+
* element's own `values` are the vocabulary the select planner picks from, a
|
|
46
|
+
* pooled element's pool is the vocabulary the assets planner picks from, a
|
|
47
|
+
* scalar element is what the list planner writes — and a poi element selects NO
|
|
48
|
+
* planner: rows are filled in one batched call over the whole list, and nothing
|
|
49
|
+
* says how a Places result set would divide per row. A bare `select` is the
|
|
50
|
+
* choice planner, one key from its own `values`; `number` and `url` select none,
|
|
51
|
+
* since no model writes a figure or a link.
|
|
52
|
+
*/
|
|
53
|
+
function plannerForField(field) {
|
|
54
|
+
if (field.type === "list") {
|
|
55
|
+
const element = field.element?.type;
|
|
56
|
+
if (element === "select") return "select";
|
|
57
|
+
if (element === "poi") return void 0;
|
|
58
|
+
if (poolingPrimitiveOf({ type: element }) !== void 0) return "assets";
|
|
59
|
+
return "list";
|
|
60
|
+
}
|
|
61
|
+
if (field.type === "text") return "text";
|
|
62
|
+
if (field.type === "select") return "choice";
|
|
63
|
+
return poolingPrimitiveOf(field);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The decision types a row field may be filled with — the planner table's own
|
|
67
|
+
* values, so the set both validate surfaces reject against cannot drift from the
|
|
68
|
+
* planners the executor implements.
|
|
69
|
+
*/
|
|
70
|
+
const EXECUTABLE_NESTED_TYPES = [...new Set(Object.values(PLANNER_DECISION_TYPES))];
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { EXECUTABLE_NESTED_TYPES, PLANNER_DECISION_TYPES, POOLING_PRIMITIVES, plannerForField, poolingPrimitiveOf };
|