@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,27 @@
|
|
|
1
|
+
import { GroupDefOf, GroupIdsOfLayout, SectionLayoutEntry } from "./layout.js";
|
|
2
|
+
import { DisplayEntryInput } from "./slot-builders.js";
|
|
3
|
+
import { Slot } from "./slot-types.js";
|
|
4
|
+
//#region src/schema/define-schema.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The authored `display:` block: section `visibility` and `variant`, each an
|
|
7
|
+
* optional entry built by the `select(cases, opts)` display overload. Omitting
|
|
8
|
+
* the block, or either entry, reproduces the defaults — always shown, no
|
|
9
|
+
* variant.
|
|
10
|
+
*/
|
|
11
|
+
interface DisplayInput {
|
|
12
|
+
visibility?: DisplayEntryInput;
|
|
13
|
+
variant?: DisplayEntryInput;
|
|
14
|
+
}
|
|
15
|
+
/** The layout grammar admitted for a given slot record: every position a real slot key. */
|
|
16
|
+
type SectionLayoutOf<Slots> = readonly SectionLayoutEntry<Extract<keyof Slots, string>>[];
|
|
17
|
+
type DefinedSchema<Slots extends Record<string, Slot>, Display extends DisplayInput, Layout extends SectionLayoutOf<Slots>> = {
|
|
18
|
+
meta: {
|
|
19
|
+
displayName: string;
|
|
20
|
+
anchor?: string;
|
|
21
|
+
display: Display;
|
|
22
|
+
groups?: GroupDefOf<GroupIdsOfLayout<Layout>>[];
|
|
23
|
+
};
|
|
24
|
+
slots: Slots;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { DefinedSchema, DisplayInput, SectionLayoutOf };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { COMPUTED, isComputeBinding } from "./compute.js";
|
|
2
|
+
import { getReads, withReads } from "./fill-declaration.js";
|
|
3
|
+
import { groupsFromLayout } from "./layout.js";
|
|
4
|
+
|
|
5
|
+
//#region src/schema/define-schema.ts
|
|
6
|
+
function emitDisplay(display, computed) {
|
|
7
|
+
const out = {};
|
|
8
|
+
for (const key of ["visibility", "variant"]) {
|
|
9
|
+
const entry = display[key];
|
|
10
|
+
if (entry === void 0) continue;
|
|
11
|
+
const emitted = { cases: [...entry.cases] };
|
|
12
|
+
if (entry.locked === true) emitted.locked = true;
|
|
13
|
+
if (isComputeBinding(entry.source)) {
|
|
14
|
+
computed[`display.${key}`] = entry.source.fn;
|
|
15
|
+
emitted.source = {
|
|
16
|
+
kind: "derived",
|
|
17
|
+
transform: `display.${key}`
|
|
18
|
+
};
|
|
19
|
+
} else if (entry.source !== void 0) emitted.source = entry.source;
|
|
20
|
+
if (entry.fill !== void 0) emitted.fill = withReads({ pick: entry.fill.pick }, getReads(entry.fill));
|
|
21
|
+
out[key] = emitted;
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Declare a section's schema from `label` + per-kind slot builders. Returns the
|
|
27
|
+
* authored `{ meta, slots }` shape CI serializes, with `SectionProps<typeof
|
|
28
|
+
* schema>` byte-identical to the hand-written `as const` form.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
function defineSchema(input) {
|
|
32
|
+
const computed = {};
|
|
33
|
+
const meta = {
|
|
34
|
+
displayName: input.label,
|
|
35
|
+
...input.anchor !== void 0 ? { anchor: input.anchor } : {},
|
|
36
|
+
...input.display !== void 0 ? { display: emitDisplay(input.display, computed) } : {},
|
|
37
|
+
...input.layout !== void 0 ? { groups: groupsFromLayout(input.layout) } : {}
|
|
38
|
+
};
|
|
39
|
+
const slots = {};
|
|
40
|
+
for (const [key, slot] of Object.entries(input.slots)) {
|
|
41
|
+
let emitted = slot;
|
|
42
|
+
if (isComputeBinding(slot.source)) {
|
|
43
|
+
computed[key] = slot.source.fn;
|
|
44
|
+
emitted = {
|
|
45
|
+
...emitted,
|
|
46
|
+
source: {
|
|
47
|
+
kind: "derived",
|
|
48
|
+
transform: key
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const when = slot.when;
|
|
53
|
+
if (when !== void 0) {
|
|
54
|
+
const rewritten = { ...emitted };
|
|
55
|
+
delete rewritten.when;
|
|
56
|
+
rewritten.variant = { cases: typeof when === "string" ? [when] : [...when] };
|
|
57
|
+
emitted = rewritten;
|
|
58
|
+
}
|
|
59
|
+
slots[key] = emitted;
|
|
60
|
+
}
|
|
61
|
+
const result = {
|
|
62
|
+
meta,
|
|
63
|
+
slots
|
|
64
|
+
};
|
|
65
|
+
Object.defineProperty(result, COMPUTED, {
|
|
66
|
+
value: computed,
|
|
67
|
+
enumerable: false
|
|
68
|
+
});
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { defineSchema };
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { DISPLAY_ENTRIES, REFERRAL_IMAGE_FIELDS } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { getFill, getReads } from "./fill-declaration.js";
|
|
3
|
+
import { EXECUTABLE_NESTED_TYPES, PLANNER_DECISION_TYPES, plannerForField, poolingPrimitiveOf } from "../packages/internal/fill-vocabulary/dist/row-planners.js";
|
|
4
|
+
|
|
5
|
+
//#region src/schema/extract-fill-spec.ts
|
|
6
|
+
const LEGACY_COLLECTION_ITEM = {
|
|
7
|
+
image_collection: "image",
|
|
8
|
+
video_collection: "video",
|
|
9
|
+
poi_list: "poi"
|
|
10
|
+
};
|
|
11
|
+
function derivedListMode(slot) {
|
|
12
|
+
const item = slot.element?.type ?? LEGACY_COLLECTION_ITEM[slot.type ?? ""];
|
|
13
|
+
if (item === "poi") return "curate";
|
|
14
|
+
if (poolingPrimitiveOf({ type: item }) !== void 0) return "pool";
|
|
15
|
+
if (item === "select") return "choose";
|
|
16
|
+
return "extract";
|
|
17
|
+
}
|
|
18
|
+
function editorPickedOrigin(slot) {
|
|
19
|
+
return slot.type === "poi";
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Every top-level slot declares EXACTLY ONE origin — a `source:` binding or a
|
|
23
|
+
* `fill:` decision. The builders' types carry the *not both* half; this carries
|
|
24
|
+
* the *at least one* half, which has no type-level form. Without it an unsourced,
|
|
25
|
+
* unfilled slot publishes as a field nothing will ever write.
|
|
26
|
+
*
|
|
27
|
+
* ROW FIELDS ARE EXEMPT, deliberately and not by omission: a row field is written
|
|
28
|
+
* by the list's own origination — amenities' category `select` is picked by its
|
|
29
|
+
* `chooseFrom` — so the same declaration is legal one level down.
|
|
30
|
+
*/
|
|
31
|
+
function assertOrigin(key, slot) {
|
|
32
|
+
if (slot.source !== void 0) return;
|
|
33
|
+
if (editorPickedOrigin(slot)) return;
|
|
34
|
+
throw new Error(`fillSpecFromSchema: slot "${key}" declares neither \`source:\` nor \`fill:\` — nothing would ever write it. Bind it to a fact with \`source:\`, or give it a \`fill:\` decision.`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `nameRows` writes each row's name into the field the slot's `title:` already
|
|
38
|
+
* points at — which is what keeps a second "the naming field is …" declaration
|
|
39
|
+
* off the authoring surface. That derivation only holds if the pointer resolves
|
|
40
|
+
* to somewhere a written name can land, so both halves are checked here rather
|
|
41
|
+
* than left to fail at fill time as an absent slot on a customer's property.
|
|
42
|
+
* The titled field takes no `fill:` of its own for the same reason: the written
|
|
43
|
+
* name IS its value, and a second fill would plan the same field twice in one
|
|
44
|
+
* response schema, which the model provider rejects outright.
|
|
45
|
+
*/
|
|
46
|
+
function assertTitledTextField(key, slot) {
|
|
47
|
+
const title = slot.title;
|
|
48
|
+
if (title === void 0) throw new Error(`fillSpecFromSchema: slot "${key}" declares \`fill: nameRows(…)\` but no \`title:\` — the model writes each row's name into the titled field, so name one with \`title: "<field>"\`.`);
|
|
49
|
+
const field = slot.fields?.[title];
|
|
50
|
+
if (field?.type !== "text") throw new Error(`fillSpecFromSchema: slot "${key}" titles rows by "${title}", which is ${field === void 0 ? "not a declared field" : `a \`${field.type}\` field`} — \`nameRows\` writes a name, so the titled field must be \`text\`.`);
|
|
51
|
+
if (getFill(field) !== void 0) throw new Error(`fillSpecFromSchema: slot "${key}" titles rows by "${title}", which declares its own \`fill:\` — \`nameRows\` writes each row's name into that field, so drop its fill and say the name's shape in \`nameRows({ structureHint })\`.`);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The rows of a record list come from exactly one place: the slot's own
|
|
55
|
+
* `fill: chooseFrom(…)`/`nameRows(…)` when the model originates them, otherwise
|
|
56
|
+
* the slot's own `source`, one row per entry of the bound facts array. Restating
|
|
57
|
+
* either would be a second name for one fact, so neither is authored on the
|
|
58
|
+
* decision.
|
|
59
|
+
*/
|
|
60
|
+
function rowOriginationOf(key, slot, fill) {
|
|
61
|
+
if (fill !== void 0) {
|
|
62
|
+
const { type, ...config } = fill;
|
|
63
|
+
if (type === void 0) {
|
|
64
|
+
if (config.mode === "name") assertTitledTextField(key, slot);
|
|
65
|
+
return { ...config };
|
|
66
|
+
}
|
|
67
|
+
if (type === "list-fill") {
|
|
68
|
+
if (Object.values(slot.fields ?? {}).some((field) => poolingPrimitiveOf(field) !== void 0)) return {
|
|
69
|
+
mode: "pool",
|
|
70
|
+
...config
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
throw new Error(`fillSpecFromSchema: record slot "${key}" declares a ${type} fill, which originates no rows here — a record list's rows come from \`chooseFrom\`, from a pooling media field, or from the slot's own \`source:\`.`);
|
|
74
|
+
}
|
|
75
|
+
const source = slot.source;
|
|
76
|
+
if (source?.kind === "direct" && source.field !== void 0) return {
|
|
77
|
+
mode: "facts",
|
|
78
|
+
iterate: source.field
|
|
79
|
+
};
|
|
80
|
+
throw new Error(`fillSpecFromSchema: record slot "${key}" has row fields to fill but no row origination — bind the slot with \`source:\` or declare \`fill: chooseFrom({ count, pick })\`.`);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A `contactAssign` bakes ONE referral field of the chosen card, and that field's
|
|
84
|
+
* value type must be the slot's: a logo or headshot lands on an `image` slot, a
|
|
85
|
+
* scalar on a `text` slot. Both builders admit the decision kind (the field is
|
|
86
|
+
* data, not a type parameter — see `FillMark`), so the pairing is checked here,
|
|
87
|
+
* where the alternative is a published spec whose bake writes an image value
|
|
88
|
+
* into a text slot.
|
|
89
|
+
*/
|
|
90
|
+
function assertContactField(key, slot, fill) {
|
|
91
|
+
const built = fill;
|
|
92
|
+
if (built.type === "image-assign" && built.fallback !== void 0) {
|
|
93
|
+
assertFallback(key, slot, built);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (built.type !== "contact-assign") return;
|
|
97
|
+
const field = built.field ?? "";
|
|
98
|
+
const imageField = REFERRAL_IMAGE_FIELDS.includes(field);
|
|
99
|
+
if (slot.type === "image" && !imageField) throw new Error(`fillSpecFromSchema: image slot "${key}" declares contactAssign({ field: "${field}" }), a scalar contact field — an image slot bakes one of ${REFERRAL_IMAGE_FIELDS.join(" / ")}.`);
|
|
100
|
+
if (slot.type === "text" && imageField) throw new Error(`fillSpecFromSchema: text slot "${key}" declares contactAssign({ field: "${field}" }), a contact image field — a text slot bakes a scalar contact field (name, title, org_name, …).`);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A photo pick's `fallback` is a contact pick baking onto the SAME slot, so its
|
|
104
|
+
* `field` takes the pairing check above. And the chain only ever reaches it
|
|
105
|
+
* through the outer `none` — a required photo pick can never abstain, so a
|
|
106
|
+
* fallback behind one would run on an empty pool alone, which is not what an
|
|
107
|
+
* author declaring one means. The builder's types require `none` beside
|
|
108
|
+
* `fallback`; this is where a hand-built literal meets the same rule.
|
|
109
|
+
*/
|
|
110
|
+
function assertFallback(key, slot, built) {
|
|
111
|
+
if (typeof built.none !== "string" || built.none.trim() === "") throw new Error(`fillSpecFromSchema: image slot "${key}" declares a fallback but no \`none\` — the contact pick runs only when the photo pick produces nothing, so say when that is right.`);
|
|
112
|
+
const fallback = built.fallback;
|
|
113
|
+
if (fallback.type !== "contact-assign") throw new Error(`fillSpecFromSchema: image slot "${key}" declares a ${String(fallback.type)} fallback — only \`contactAssign({ pick, field })\` may stand behind a photo pick.`);
|
|
114
|
+
assertContactField(key, slot, fallback);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* `select-assign` is a ROW planner and nothing else: it picks one key per row
|
|
118
|
+
* inside the list's batched call, and no top-level executor runs it. The type
|
|
119
|
+
* admits `chooseFrom({ pick })` on any `select.of` — the builder cannot see its
|
|
120
|
+
* own position — so the placement is refused here, where the spec it would
|
|
121
|
+
* emit is one the fill worker cannot run.
|
|
122
|
+
*/
|
|
123
|
+
function assertRowOnlyFill(key, slot, fill) {
|
|
124
|
+
if (slot.type !== "select" || fill.type !== "select-assign") return;
|
|
125
|
+
throw new Error(`fillSpecFromSchema: select slot "${key}" declares \`fill: chooseFrom({ pick })\`, which only a record row's select field takes — a top-level select is bound with \`source:\`; declare the pick on the row field instead.`);
|
|
126
|
+
}
|
|
127
|
+
function recordListDecision(key, slot, reads) {
|
|
128
|
+
const fields = {};
|
|
129
|
+
for (const [fieldKey, rowField] of Object.entries(slot.fields ?? {})) {
|
|
130
|
+
const built = getFill(rowField);
|
|
131
|
+
if (built === void 0) continue;
|
|
132
|
+
collectReads(reads, built);
|
|
133
|
+
const builtType = built.type;
|
|
134
|
+
const planner = plannerForField(rowField);
|
|
135
|
+
const expected = planner === void 0 ? void 0 : PLANNER_DECISION_TYPES[planner];
|
|
136
|
+
if (builtType === void 0 || expected === void 0 || builtType !== expected) throw new Error(`fillSpecFromSchema: row field "${key}.${fieldKey}" declares a ${String(builtType)} fill, which no row can be filled with — a row field takes ${EXECUTABLE_NESTED_TYPES.join(" / ")}, each on the item content that selects it.`);
|
|
137
|
+
fields[fieldKey] = { ...built };
|
|
138
|
+
}
|
|
139
|
+
const fill = getFill(slot);
|
|
140
|
+
collectReads(reads, fill);
|
|
141
|
+
if (fill === void 0 && Object.keys(fields).length === 0) {
|
|
142
|
+
assertOrigin(key, slot);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const origination = rowOriginationOf(key, slot, fill);
|
|
146
|
+
return {
|
|
147
|
+
id: key,
|
|
148
|
+
produces: [key],
|
|
149
|
+
type: "list-fill",
|
|
150
|
+
...origination,
|
|
151
|
+
fields
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function valueListDecision(key, slot, fill) {
|
|
155
|
+
const { type, ...config } = fill;
|
|
156
|
+
if (type !== "list-fill") return {
|
|
157
|
+
id: key,
|
|
158
|
+
produces: [key],
|
|
159
|
+
...fill
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
id: key,
|
|
163
|
+
produces: [key],
|
|
164
|
+
type: "list-fill",
|
|
165
|
+
mode: derivedListMode(slot),
|
|
166
|
+
...config
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const DISPLAY_DECISION_ID = "display";
|
|
170
|
+
/**
|
|
171
|
+
* The section's `display-select` decision, or `undefined` when no entry has a
|
|
172
|
+
* `fill:` origin — a `source:` entry bakes at fill time and asks the model
|
|
173
|
+
* nothing. The decision names only WHICH entries it resolves: their cases and
|
|
174
|
+
* `pick` prose stay on the schema's own display entry (see ./fill-spec.ts).
|
|
175
|
+
*/
|
|
176
|
+
function displayDecision(schema, reads) {
|
|
177
|
+
const display = schema.meta.display;
|
|
178
|
+
if (display === void 0) return void 0;
|
|
179
|
+
const entries = DISPLAY_ENTRIES.filter((entry) => display[entry]?.fill !== void 0);
|
|
180
|
+
if (entries.length === 0) return void 0;
|
|
181
|
+
for (const entry of entries) collectReads(reads, display[entry]?.fill);
|
|
182
|
+
if (DISPLAY_DECISION_ID in schema.slots) throw new Error(`fillSpecFromSchema: slot "${DISPLAY_DECISION_ID}" collides with the decision id reserved for \`meta.display\`'s own fill — rename the slot.`);
|
|
183
|
+
return {
|
|
184
|
+
id: DISPLAY_DECISION_ID,
|
|
185
|
+
type: "display-select",
|
|
186
|
+
entries,
|
|
187
|
+
produces: []
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function collectReads(into, decision) {
|
|
191
|
+
for (const read of getReads(decision)) into.add(read);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Extract a section's published fill spec from its `defineSchema` declaration:
|
|
195
|
+
* one decision per slot carrying a colocated `fill:`, in slot-declaration order,
|
|
196
|
+
* each `id`/`produces` minted from the slot key, plus `reads`: the sorted,
|
|
197
|
+
* deduplicated union of every decision's own `reads` — row fields, row
|
|
198
|
+
* originations and display entries included. A section none of whose decisions
|
|
199
|
+
* declares one, or whose slots are all source-bound, yields `reads: []`.
|
|
200
|
+
*
|
|
201
|
+
* A `meta.display` entry with a `fill:` origin adds the one decision that
|
|
202
|
+
* produces no slot — the section's own display verdict.
|
|
203
|
+
*
|
|
204
|
+
* Throws on a declaration no fill spec can express: a top-level slot declaring
|
|
205
|
+
* neither `source:` nor `fill:` (nothing would ever write it), a record list
|
|
206
|
+
* with row fills but no row origination (neither a `source` binding nor a
|
|
207
|
+
* `chooseFrom`), or a row field declaring a decision kind rows cannot take.
|
|
208
|
+
*/
|
|
209
|
+
function fillSpecFromSchema(schema) {
|
|
210
|
+
const decisions = [];
|
|
211
|
+
const reads = /* @__PURE__ */ new Set();
|
|
212
|
+
for (const [key, slot] of Object.entries(schema.slots)) {
|
|
213
|
+
const shape = slot;
|
|
214
|
+
if (shape.type === "list" && shape.fields !== void 0) {
|
|
215
|
+
const decision = recordListDecision(key, shape, reads);
|
|
216
|
+
if (decision !== void 0) decisions.push(decision);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const built = getFill(slot);
|
|
220
|
+
if (built === void 0) {
|
|
221
|
+
assertOrigin(key, shape);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
collectReads(reads, built);
|
|
225
|
+
if (shape.type === "list" || (shape.type ?? "") in LEGACY_COLLECTION_ITEM) {
|
|
226
|
+
decisions.push(valueListDecision(key, shape, built));
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
assertRowOnlyFill(key, shape, built);
|
|
230
|
+
assertContactField(key, shape, built);
|
|
231
|
+
decisions.push({
|
|
232
|
+
id: key,
|
|
233
|
+
produces: [key],
|
|
234
|
+
...built
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const display = displayDecision(schema, reads);
|
|
238
|
+
if (display !== void 0) decisions.push(display);
|
|
239
|
+
return {
|
|
240
|
+
reads: [...reads].sort(),
|
|
241
|
+
decisions
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
//#endregion
|
|
246
|
+
export { fillSpecFromSchema };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { FACT_GRAPH, FACT_PROJECTIONS } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { getComputed } from "./compute.js";
|
|
3
|
+
import { projectFactsView } from "../packages/internal/template-contracts/dist/facts-view.js";
|
|
4
|
+
import { fillSpecFromSchema } from "./extract-fill-spec.js";
|
|
5
|
+
|
|
6
|
+
//#region src/schema/extract-used-facts.ts
|
|
7
|
+
const GRAPH = FACT_GRAPH;
|
|
8
|
+
const KEY_BY_PATH = /* @__PURE__ */ new Map();
|
|
9
|
+
const ROW_KEY_BY_NAME = /* @__PURE__ */ new Map();
|
|
10
|
+
function authorFacingName(key, container) {
|
|
11
|
+
const aliases = FACT_PROJECTIONS[container];
|
|
12
|
+
if (aliases !== void 0) {
|
|
13
|
+
for (const [alias, target] of Object.entries(aliases)) if (target === key) return alias;
|
|
14
|
+
}
|
|
15
|
+
return key;
|
|
16
|
+
}
|
|
17
|
+
for (const [key, entry] of Object.entries(GRAPH)) {
|
|
18
|
+
const path = entry.path;
|
|
19
|
+
if (typeof path !== "string") continue;
|
|
20
|
+
const rowBound = /^(\w+)\[\]\.(\w+)$/.exec(path);
|
|
21
|
+
if (rowBound !== null) {
|
|
22
|
+
const pool = rowBound[1];
|
|
23
|
+
const name = entry.role === "bindable" ? authorFacingName(key, entry.container) : rowBound[2];
|
|
24
|
+
let names = ROW_KEY_BY_NAME.get(pool);
|
|
25
|
+
if (names === void 0) {
|
|
26
|
+
names = /* @__PURE__ */ new Map();
|
|
27
|
+
ROW_KEY_BY_NAME.set(pool, names);
|
|
28
|
+
}
|
|
29
|
+
names.set(name, key);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (!KEY_BY_PATH.has(path)) KEY_BY_PATH.set(path, key);
|
|
33
|
+
}
|
|
34
|
+
function resolveMember(scope, member) {
|
|
35
|
+
switch (scope.kind) {
|
|
36
|
+
case "root": {
|
|
37
|
+
if (member === "property") return { next: { kind: "property" } };
|
|
38
|
+
const entry = GRAPH[member];
|
|
39
|
+
if (entry === void 0 || entry.role !== "readable") return void 0;
|
|
40
|
+
return {
|
|
41
|
+
key: member,
|
|
42
|
+
next: scopeOf(member)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
case "property": {
|
|
46
|
+
const key = FACT_PROJECTIONS.property[member] ?? member;
|
|
47
|
+
const entry = GRAPH[key];
|
|
48
|
+
if (entry === void 0 || entry.role !== "bindable" || entry.container !== "property") return;
|
|
49
|
+
return {
|
|
50
|
+
key,
|
|
51
|
+
next: scopeOf(key)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
case "row": {
|
|
55
|
+
const key = ROW_KEY_BY_NAME.get(scope.pool)?.get(member);
|
|
56
|
+
return key === void 0 ? void 0 : {
|
|
57
|
+
key,
|
|
58
|
+
next: scopeOf(key)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
case "shape": {
|
|
62
|
+
const key = KEY_BY_PATH.get(`${scope.path}.${member}`);
|
|
63
|
+
return key === void 0 ? void 0 : {
|
|
64
|
+
key,
|
|
65
|
+
next: scopeOf(key)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function scopeOf(key) {
|
|
71
|
+
const entry = GRAPH[key];
|
|
72
|
+
if (entry === void 0) return void 0;
|
|
73
|
+
if (entry.role === "readable" && entry.primary_of !== void 0) return {
|
|
74
|
+
kind: "row",
|
|
75
|
+
pool: entry.primary_of
|
|
76
|
+
};
|
|
77
|
+
if (entry.row !== void 0) return {
|
|
78
|
+
kind: "row",
|
|
79
|
+
pool: key
|
|
80
|
+
};
|
|
81
|
+
if (entry.fields !== void 0) return {
|
|
82
|
+
kind: "shape",
|
|
83
|
+
path: entry.path ?? key
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function recording(value, scope, into) {
|
|
87
|
+
if (Array.isArray(value)) return value.map((item) => recording(item, scope, into));
|
|
88
|
+
if (value === null || typeof value !== "object") return value;
|
|
89
|
+
return new Proxy(value, { get(target, prop, receiver) {
|
|
90
|
+
const raw = Reflect.get(target, prop, receiver);
|
|
91
|
+
if (typeof prop !== "string") return raw;
|
|
92
|
+
const resolved = resolveMember(scope, prop);
|
|
93
|
+
if (resolved === void 0) return raw;
|
|
94
|
+
if (resolved.key !== void 0) into.add(resolved.key);
|
|
95
|
+
return resolved.next === void 0 ? raw : recording(raw, resolved.next, into);
|
|
96
|
+
} });
|
|
97
|
+
}
|
|
98
|
+
function sampleScalar(valueType) {
|
|
99
|
+
switch (valueType) {
|
|
100
|
+
case "number": return 1;
|
|
101
|
+
case "boolean": return true;
|
|
102
|
+
case "text_list": return ["sample"];
|
|
103
|
+
default: return "sample";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function sampleMember(desc) {
|
|
107
|
+
return desc.row !== void 0 ? [sampleShape(desc.row)] : sampleScalar(desc.value_type);
|
|
108
|
+
}
|
|
109
|
+
function sampleShape(shape) {
|
|
110
|
+
const out = {};
|
|
111
|
+
for (const [member, desc] of Object.entries(shape)) out[member] = sampleMember(desc);
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
function sampleCanonical() {
|
|
115
|
+
const root = {};
|
|
116
|
+
const paths = Object.values(GRAPH).filter((entry) => typeof entry.path === "string" && !entry.path.includes("[]")).sort((a, b) => a.path.split(".").length - b.path.split(".").length);
|
|
117
|
+
for (const entry of paths) {
|
|
118
|
+
const segments = entry.path.split(".");
|
|
119
|
+
const leaf = segments.pop();
|
|
120
|
+
let cursor = root;
|
|
121
|
+
for (const segment of segments) {
|
|
122
|
+
const next = cursor[segment];
|
|
123
|
+
cursor = next !== null && typeof next === "object" ? next : cursor[segment] = {};
|
|
124
|
+
}
|
|
125
|
+
if (entry.row !== void 0) cursor[leaf] = [sampleShape(entry.row)];
|
|
126
|
+
else if (entry.fields !== void 0) cursor[leaf] = sampleShape(entry.fields);
|
|
127
|
+
else if (cursor[leaf] === void 0) cursor[leaf] = sampleScalar(entry.value_type);
|
|
128
|
+
}
|
|
129
|
+
return root;
|
|
130
|
+
}
|
|
131
|
+
const VALENCES = [{}, sampleCanonical()];
|
|
132
|
+
/**
|
|
133
|
+
* Runs `fn` against each valence's recording view and banks every registry
|
|
134
|
+
* entry it reaches. Never throws: a compute that fails on the shape it was
|
|
135
|
+
* handed has already contributed the reads it made before failing.
|
|
136
|
+
*/
|
|
137
|
+
function traceCompute(fn, into) {
|
|
138
|
+
for (const canonical of VALENCES) {
|
|
139
|
+
const view = recording(projectFactsView(canonical), { kind: "root" }, into);
|
|
140
|
+
try {
|
|
141
|
+
fn(view);
|
|
142
|
+
} catch {}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function collectBinding(slot, into) {
|
|
146
|
+
const source = slot.source;
|
|
147
|
+
if (source?.kind === "direct" && source.field !== void 0 && source.field in GRAPH) into.add(source.field);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The registry keys a section asks of the property — the union of its slot
|
|
151
|
+
* bindings, its declared `reads`, and every fact its `compute()` callbacks are
|
|
152
|
+
* traced reading. Sorted and deduplicated, so the serialized value is stable
|
|
153
|
+
* across builds and safe to fold into a content hash.
|
|
154
|
+
*
|
|
155
|
+
* Takes the section's RAW `defineSchema` result, never the parsed schema: the
|
|
156
|
+
* `reads` list and the compute handle→fn map ride on symbol keys, which is
|
|
157
|
+
* exactly what keeps them out of the serialized schema jsonb, and parsing
|
|
158
|
+
* returns a fresh object carrying neither.
|
|
159
|
+
*/
|
|
160
|
+
function usedFactsFromSchema(schema) {
|
|
161
|
+
const used = /* @__PURE__ */ new Set();
|
|
162
|
+
for (const slot of Object.values(schema.slots)) {
|
|
163
|
+
const shape = slot;
|
|
164
|
+
collectBinding(shape, used);
|
|
165
|
+
for (const rowField of Object.values(shape.fields ?? {})) collectBinding(rowField, used);
|
|
166
|
+
}
|
|
167
|
+
for (const read of fillSpecFromSchema(schema).reads) {
|
|
168
|
+
const base = read.split(".")[0];
|
|
169
|
+
if (base in GRAPH) used.add(base);
|
|
170
|
+
}
|
|
171
|
+
for (const fn of Object.values(getComputed(schema))) traceCompute(fn, used);
|
|
172
|
+
return [...used].sort();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
export { usedFactsFromSchema };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { SOURCE_FIELDS, SourceFieldContainer, SourceFieldName } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { ComparableRow, UnitRow } from "./property-facts.js";
|
|
3
|
+
import { ContactRow } from "./runtime-values.js";
|
|
4
|
+
//#region src/schema/fact.d.ts
|
|
5
|
+
type SourceFields = typeof SOURCE_FIELDS;
|
|
6
|
+
/**
|
|
7
|
+
* The row type each bakeable fact array projects — one entry per collection an
|
|
8
|
+
* record list may bind whole-row (`source: fact.property.units` /
|
|
9
|
+
* `fact.property.contacts`). `SlotValue` uses the bound collection's entry as
|
|
10
|
+
* the base row type for such a slot, so `SectionProps` types its rows as the
|
|
11
|
+
* projection the renderer actually receives rather than synthesizing a row
|
|
12
|
+
* from the declared fields.
|
|
13
|
+
*/
|
|
14
|
+
type CollectionRowValues = {
|
|
15
|
+
units: UnitRow;
|
|
16
|
+
contacts: ContactRow;
|
|
17
|
+
comparables: ComparableRow;
|
|
18
|
+
};
|
|
19
|
+
/** A slot's `direct` binding: the canonical field itself, writable when the catalog gives it a writeback. */
|
|
20
|
+
type DirectFactRef<F extends SourceFieldName> = {
|
|
21
|
+
kind: "direct";
|
|
22
|
+
field: F;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A slot's `derived` binding: a value the section's own `compute()` fn
|
|
26
|
+
* produces, keyed by the slot's own name. No `fact.*` entry emits one — the
|
|
27
|
+
* fact namespace is direct-only — so `defineSchema`'s `compute()` rewrite is
|
|
28
|
+
* the sole producer of this shape.
|
|
29
|
+
*/
|
|
30
|
+
type DerivedFactRef = {
|
|
31
|
+
kind: "derived";
|
|
32
|
+
transform: string;
|
|
33
|
+
};
|
|
34
|
+
type FieldsIn<C extends SourceFieldContainer> = { [F in keyof SourceFields as SourceFields[F]["container"] extends C ? F : never]: DirectFactRef<F & SourceFieldName>; };
|
|
35
|
+
declare const PROJECTIONS: {
|
|
36
|
+
readonly property: {
|
|
37
|
+
readonly latitude: "lat";
|
|
38
|
+
readonly longitude: "lon";
|
|
39
|
+
};
|
|
40
|
+
readonly contact: {
|
|
41
|
+
readonly address: "contact_address";
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
type Projections = typeof PROJECTIONS;
|
|
45
|
+
type ProjectionsIn<C extends SourceFieldContainer> = C extends keyof Projections ? { [K in keyof Projections[C]]: DirectFactRef<Projections[C][K] & SourceFieldName>; } : Record<never, never>;
|
|
46
|
+
/**
|
|
47
|
+
* The shape of `fact`: one branch per source-field container (`property`,
|
|
48
|
+
* `unit`, `contact`), each holding an entry for every canonical field in that
|
|
49
|
+
* container plus one per declared alias. Every entry emits the same `direct`
|
|
50
|
+
* literal, and all are values you pass to a slot builder's `source`, not calls
|
|
51
|
+
* you make.
|
|
52
|
+
*/
|
|
53
|
+
type FactNamespace = { [C in SourceFieldContainer]: FieldsIn<C> & ProjectionsIn<C>; };
|
|
54
|
+
/**
|
|
55
|
+
* Where a slot's value comes from, addressed as `fact.<container>.<field>`.
|
|
56
|
+
*
|
|
57
|
+
* The container is the resolution rule: `fact.property.*` reads the property
|
|
58
|
+
* root, `fact.unit.*` the primary unit (or the current row inside an
|
|
59
|
+
* record list), `fact.contact.*` the primary contact card (likewise). Hover
|
|
60
|
+
* any entry for its writability — a writable field draws the editor's
|
|
61
|
+
* "Update everywhere" toggle, a read-only one does not.
|
|
62
|
+
*/
|
|
63
|
+
declare const fact: FactNamespace;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { CollectionRowValues, DerivedFactRef, DirectFactRef, FactNamespace, fact };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FACT_PROJECTIONS, SOURCE_FIELDS } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
|
|
3
|
+
//#region src/schema/fact.ts
|
|
4
|
+
const PROJECTIONS = FACT_PROJECTIONS;
|
|
5
|
+
function buildNamespace() {
|
|
6
|
+
const containers = {
|
|
7
|
+
property: {},
|
|
8
|
+
unit: {},
|
|
9
|
+
contact: {}
|
|
10
|
+
};
|
|
11
|
+
for (const [field, descriptor] of Object.entries(SOURCE_FIELDS)) containers[descriptor.container][field] = {
|
|
12
|
+
kind: "direct",
|
|
13
|
+
field
|
|
14
|
+
};
|
|
15
|
+
for (const [container, entries] of Object.entries(PROJECTIONS)) for (const [name, field] of Object.entries(entries)) containers[container][name] = {
|
|
16
|
+
kind: "direct",
|
|
17
|
+
field
|
|
18
|
+
};
|
|
19
|
+
return containers;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Where a slot's value comes from, addressed as `fact.<container>.<field>`.
|
|
23
|
+
*
|
|
24
|
+
* The container is the resolution rule: `fact.property.*` reads the property
|
|
25
|
+
* root, `fact.unit.*` the primary unit (or the current row inside an
|
|
26
|
+
* record list), `fact.contact.*` the primary contact card (likewise). Hover
|
|
27
|
+
* any entry for its writability — a writable field draws the editor's
|
|
28
|
+
* "Update everywhere" toggle, a read-only one does not.
|
|
29
|
+
*/
|
|
30
|
+
const fact = buildNamespace();
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { fact };
|