@homepages/concrete 5.0.0 → 6.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 +336 -0
- package/README.md +28 -17
- package/codemods/fill-is-a-source.mjs +533 -0
- package/codemods/manifest.json +12 -0
- package/codemods/reads-replace-reconcile.mjs +285 -0
- package/dist/artifact/playground/client/assets/{index-D1fwOGVK.js → index-u3T7DiSN.js} +96 -96
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +23 -23
- package/dist/base.css +3 -8
- package/dist/browser/site-config.js +1 -16
- package/dist/browser/submit-lead.js +0 -31
- package/dist/cli/build/artifact.js +16 -23
- package/dist/cli/build/captures.js +0 -6
- package/dist/cli/build/esbuild.js +0 -17
- package/dist/cli/build/fixtures.js +15 -30
- package/dist/cli/build/icons.js +0 -3
- package/dist/cli/build/index.js +1 -1
- package/dist/cli/build/playground.js +4 -8
- package/dist/cli/build/sections.js +9 -30
- package/dist/cli/build/source.js +52 -27
- package/dist/cli/build/static.js +4 -25
- package/dist/cli/capture/bundle.js +0 -9
- package/dist/cli/capture/capture-browser.js +0 -14
- package/dist/cli/capture/capture.js +1 -8
- package/dist/cli/check/analyze.js +2 -5
- package/dist/cli/check/index.js +1 -1
- package/dist/cli/check/line-endings.js +52 -0
- package/dist/cli/check/load-workspace.js +3 -8
- package/dist/cli/check/portable-names.js +48 -0
- package/dist/cli/check/render/class-conflicts.js +0 -5
- package/dist/cli/check/render/html.js +0 -1
- package/dist/cli/check/render/invariants.js +0 -5
- package/dist/cli/check/render/island-frames.js +0 -25
- package/dist/cli/check/render/marker-coverage.js +0 -20
- package/dist/cli/check/render/nav.js +0 -33
- package/dist/cli/check/report.js +0 -3
- package/dist/cli/check/stages/bundles.js +1 -9
- package/dist/cli/check/stages/composition.js +3 -2
- package/dist/cli/check/stages/dependencies.js +7 -38
- package/dist/cli/check/stages/fixtures.js +3 -31
- package/dist/cli/check/stages/lint.js +2 -2
- package/dist/cli/check/stages/logic.js +3 -34
- package/dist/cli/check/stages/relations.js +46 -0
- package/dist/cli/check/stages/render.js +0 -1
- package/dist/cli/check/stages/sections.js +3 -3
- package/dist/cli/check/stages/stylesheet.js +1 -1
- package/dist/cli/check/stages/typecheck.js +5 -11
- package/dist/cli/check/stages/workspace.js +36 -14
- package/dist/cli/commands.js +9 -56
- package/dist/cli/currency/cache.js +4 -17
- package/dist/cli/currency/decide.js +0 -14
- package/dist/cli/currency/opt-out.js +0 -7
- package/dist/cli/currency/preamble.js +3 -24
- package/dist/cli/currency/prompt.js +0 -1
- package/dist/cli/currency/refresh.js +5 -12
- package/dist/cli/currency/resolve-latest.js +3 -64
- package/dist/cli/currency/version-order.js +0 -12
- package/dist/cli/dev/crop.js +0 -2
- package/dist/cli/dev/http.js +0 -13
- package/dist/cli/dev/index.js +3 -4
- package/dist/cli/dev/islands.js +25 -70
- package/dist/cli/dev/listen.js +26 -0
- package/dist/cli/dev/load-template.js +0 -1
- package/dist/cli/dev/request-error.js +0 -4
- package/dist/cli/dev/server.js +46 -52
- package/dist/cli/dev/tsconfig-paths.js +0 -13
- package/dist/cli/dev/vite.js +9 -38
- package/dist/cli/dev/workspace-reader.js +4 -34
- package/dist/cli/media/cache.js +4 -51
- package/dist/cli/media/derive.js +2 -94
- package/dist/cli/media/deriver-plugin.js +0 -2
- package/dist/cli/media/frame-rung-floor.js +0 -6
- package/dist/cli/property/index.js +0 -4
- package/dist/cli/property/library.js +6 -24
- package/dist/cli/publish/client.js +0 -1
- package/dist/cli/publish/freshness.js +0 -2
- package/dist/cli/publish/git.js +2 -8
- package/dist/cli/publish/index.js +8 -15
- package/dist/cli/publish/pack.js +5 -6
- package/dist/cli/publish/report.js +0 -6
- package/dist/cli/publish/target.js +16 -13
- package/dist/cli/publish/wire.js +0 -6
- package/dist/cli/tar.js +2 -9
- package/dist/cli/upgrade/codemod.js +0 -8
- package/dist/cli/upgrade/index.js +0 -24
- package/dist/cli/upgrade/manifest.js +0 -12
- package/dist/cli/upgrade/plan.js +0 -17
- package/dist/cli/upgrade/stage.js +12 -15
- package/dist/cli/version.js +0 -8
- package/dist/cli/workspace.js +2 -34
- package/dist/cli.js +4 -21
- package/dist/css/compile.js +25 -28
- package/dist/css/graph.js +3 -10
- package/dist/css/inline.js +3 -13
- package/dist/css/rules.js +6 -43
- package/dist/design-system/format-variants.js +0 -22
- package/dist/eslint/authoring.js +0 -2
- package/dist/eslint/correctness.js +0 -7
- package/dist/eslint/rules/editor-reason.js +0 -11
- package/dist/eslint/rules/island-ids.js +0 -1
- package/dist/eslint/rules/jsx-visitor.js +0 -13
- package/dist/eslint/rules/no-editor-globals.js +0 -2
- package/dist/eslint/rules/no-raw-values.js +0 -1
- package/dist/fixtures/brand.js +0 -1
- package/dist/fixtures/bundle-rule.js +4 -9
- package/dist/fixtures/canonical.d.ts +20 -0
- package/dist/fixtures/image-dimensions.js +0 -1
- package/dist/fixtures/load.js +8 -17
- package/dist/fixtures/media-plugin.js +4 -31
- package/dist/fixtures/media.js +0 -21
- package/dist/fixtures/package-stylesheets.js +0 -6
- package/dist/fixtures/property.js +16 -15
- package/dist/fixtures/resolve.js +102 -29
- package/dist/fixtures/rows.js +12 -11
- package/dist/fixtures/synthesize-empties.js +0 -4
- package/dist/fixtures.d.ts +19 -4
- package/dist/fixtures.js +0 -18
- package/dist/index.d.ts +8 -9
- package/dist/index.js +2 -11
- package/dist/islands/client-module.js +0 -11
- package/dist/islands/marker.js +0 -33
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +0 -20
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +21 -35
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +4 -0
- package/dist/packages/internal/fill-bake/dist/derive-source.js +40 -0
- package/dist/packages/internal/fill-bake/dist/display.js +0 -1
- package/dist/packages/internal/fill-bake/dist/index.js +4 -4
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +106 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -49
- package/dist/packages/internal/format-geometry/dist/capture.js +10 -240
- package/dist/packages/internal/format-geometry/dist/geometry.js +0 -6
- package/dist/packages/internal/image-ladder/dist/crop.js +0 -12
- package/dist/packages/internal/image-ladder/dist/policy.js +0 -14
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +0 -13
- package/dist/packages/internal/island-runtime/dist/contract.js +0 -34
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/index.js +0 -34
- package/dist/packages/internal/island-runtime/dist/island-id-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +0 -15
- package/dist/packages/internal/island-runtime/dist/use-editor.js +0 -10
- package/dist/packages/internal/island-runtime/dist/use-island-id.js +0 -32
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +2 -17
- package/dist/packages/internal/property-facts/dist/index.js +1 -1
- package/dist/packages/internal/property-facts/dist/{property-facts-CSdkSuD7.js → property-facts-5pxZnlkh.js} +13 -2
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +1 -18
- package/dist/packages/internal/section-contracts/dist/catalog.js +16 -8
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +12 -16
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +5 -11
- package/dist/packages/internal/section-contracts/dist/display-contract.js +2 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +2 -8
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +13 -0
- package/dist/packages/internal/section-contracts/dist/index.js +2 -1
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +16 -42
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +24 -43
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +11 -18
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +10 -12
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +3 -13
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -18
- package/dist/packages/internal/section-contracts/dist/runners.js +21 -13
- package/dist/packages/internal/section-contracts/dist/source-contract.js +13 -2
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +31 -0
- package/dist/packages/internal/source-resolution/dist/index.js +1 -9
- package/dist/packages/internal/template-artifact/dist/hash.js +0 -8
- package/dist/packages/internal/template-artifact/dist/index.js +1 -1
- package/dist/packages/internal/template-artifact/dist/layout.js +0 -39
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -9
- package/dist/packages/internal/template-artifact/dist/sha256.js +0 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +2 -4
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -16
- package/dist/packages/internal/template-contracts/dist/content-categories.js +0 -4
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +16 -10
- package/dist/packages/internal/template-contracts/dist/facts-view.js +15 -28
- package/dist/packages/internal/template-contracts/dist/layout.js +0 -7
- package/dist/packages/internal/template-contracts/dist/markers.js +0 -29
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -6
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +56 -34
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +22 -389
- package/dist/platform/file-url.js +8 -0
- package/dist/platform/fs.js +73 -0
- package/dist/platform/names.js +63 -0
- package/dist/platform/order.js +7 -0
- package/dist/platform/paths.js +62 -0
- package/dist/platform/process.js +97 -0
- package/dist/playground/host/page-state.js +0 -2
- package/dist/playground/host/paths.js +0 -1
- package/dist/playground/layout.js +0 -7
- package/dist/playground/wire.js +0 -8
- package/dist/primitives/FrameShell.js +0 -18
- package/dist/primitives/Image.d.ts +5 -1
- package/dist/primitives/Image.js +2 -68
- package/dist/primitives/Section.js +0 -13
- package/dist/primitives/Tour.js +0 -26
- package/dist/primitives/Video.js +0 -32
- package/dist/primitives/embed-playback.js +0 -1
- package/dist/primitives/marker-attrs.js +0 -17
- package/dist/primitives/picture-sources.js +6 -1
- package/dist/primitives/probe-context.js +0 -7
- package/dist/primitives/slot-bindings.js +0 -46
- package/dist/primitives/slot-document.js +0 -11
- package/dist/primitives/slot-group.js +0 -9
- package/dist/primitives/slot-media.js +0 -27
- package/dist/primitives/slot-scalar.js +0 -4
- package/dist/primitives/slot.js +0 -6
- package/dist/rules/registry.js +42 -24
- package/dist/schema/compute.d.ts +46 -8
- package/dist/schema/compute.js +21 -15
- package/dist/schema/define-schema.d.ts +1 -1
- package/dist/schema/define-schema.js +37 -17
- package/dist/schema/extract-fill-spec.js +93 -180
- package/dist/schema/extract-used-facts.js +16 -158
- package/dist/schema/fact.d.ts +25 -12
- package/dist/schema/fact.js +7 -11
- package/dist/schema/fill-builders.d.ts +91 -366
- package/dist/schema/fill-builders.js +21 -259
- package/dist/schema/fill-declaration.d.ts +7 -69
- package/dist/schema/fill-declaration.js +5 -34
- package/dist/schema/fill-spec.js +59 -148
- package/dist/schema/format-presets.js +0 -12
- package/dist/schema/format.js +0 -7
- package/dist/schema/layout.js +0 -10
- package/dist/schema/manifest.js +0 -39
- package/dist/schema/property-facts.d.ts +20 -0
- package/dist/schema/section-nav.js +0 -15
- package/dist/schema/section-schema.d.ts +0 -1
- package/dist/schema/section-schema.js +4 -20
- package/dist/schema/slot-builders.d.ts +128 -117
- package/dist/schema/slot-builders.js +18 -201
- package/dist/schema/slot-ref.d.ts +63 -0
- package/dist/schema/slot-ref.js +33 -0
- package/dist/schema/slot-types.d.ts +3 -2
- package/dist/schema/slot-types.js +11 -20
- package/dist/section/declare.d.ts +14 -10
- package/dist/section/declare.js +13 -2
- package/dist/section/discovery.js +6 -21
- package/dist/section/groups.js +0 -6
- package/dist/section/materialize.js +0 -5
- package/dist/section/placements.js +0 -4
- package/dist/section/section.d.ts +8 -5
- package/dist/section/section.js +7 -29
- package/dist/styles.css +5 -0
- package/dist/template/define-template.d.ts +0 -4
- package/dist/template/define-template.js +1 -15
- package/dist/template/logic-build.js +8 -35
- package/dist/template/logic-shim.d.ts +4 -5
- package/dist/template/logic-shim.js +2 -6
- package/dist/template/logic-transform.js +0 -6
- package/dist/template/materialize.js +52 -43
- package/dist/template/mirror-types.js +43 -0
- package/dist/template/running-copy.js +5 -20
- package/dist/template/section-reads.js +83 -0
- package/guide/reference/cli/INDEX.md +12 -6
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +3 -3
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +4 -2
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +26 -13
- package/package.json +4 -2
- package/dist/packages/internal/fact-interpolation/dist/index.js +0 -22
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +0 -170
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +0 -32
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +0 -131
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +0 -11
- package/dist/schema/fill-spec.d.ts +0 -18
- package/dist/template/reconcile.d.ts +0 -67
- package/dist/template/reconcile.js +0 -25
|
@@ -1,214 +1,136 @@
|
|
|
1
|
-
import { DISPLAY_ENTRIES
|
|
2
|
-
import { getFill
|
|
3
|
-
import {
|
|
1
|
+
import { DISPLAY_ENTRIES } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { getFill } from "./fill-declaration.js";
|
|
3
|
+
import { serializeRef } from "./slot-ref.js";
|
|
4
|
+
import { byCodeUnit } from "../platform/order.js";
|
|
5
|
+
import { plannerForField } from "../packages/internal/fill-vocabulary/dist/row-planners.js";
|
|
6
|
+
import { isListSlot, originationFor } from "../packages/internal/fill-vocabulary/dist/origination.js";
|
|
4
7
|
|
|
5
8
|
//#region src/schema/extract-fill-spec.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
9
|
+
function kindOf(origination) {
|
|
10
|
+
switch (origination.kind) {
|
|
11
|
+
case "write": return "text";
|
|
12
|
+
case "pick-one": return "pick";
|
|
13
|
+
default: return "list";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function optionsOf(binding) {
|
|
17
|
+
const out = { brief: binding.brief };
|
|
18
|
+
if (binding.none !== void 0) out.none = binding.none;
|
|
19
|
+
if (binding.count !== void 0) out.count = typeof binding.count === "number" ? binding.count : { ...binding.count };
|
|
20
|
+
if (binding.cap !== void 0) out.cap = binding.cap;
|
|
21
|
+
const reads = serializedReads(binding.reads);
|
|
22
|
+
if (reads.length > 0) out.reads = reads;
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
function serializedReads(reads) {
|
|
26
|
+
return (reads ?? []).map(serializeRef);
|
|
27
|
+
}
|
|
28
|
+
function collectReads(into, binding) {
|
|
29
|
+
for (const read of serializedReads(binding?.reads)) if (read.kind === "fact") into.facts.add(read.key);
|
|
30
|
+
else into.slots.set(`${read.section} ${read.slot}`, read);
|
|
17
31
|
}
|
|
18
32
|
function editorPickedOrigin(slot) {
|
|
19
33
|
return slot.type === "poi";
|
|
20
34
|
}
|
|
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
35
|
function assertOrigin(key, slot) {
|
|
32
36
|
if (slot.source !== void 0) return;
|
|
33
37
|
if (editorPickedOrigin(slot)) return;
|
|
34
|
-
throw new Error(`fillSpecFromSchema: slot "${key}" declares
|
|
38
|
+
throw new Error(`fillSpecFromSchema: slot "${key}" declares no \`source:\` — nothing would ever write it. Bind it to a fact or a slot, \`compute()\` it, or \`fill()\` it.`);
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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 })\`.`);
|
|
40
|
+
function unkeyedMessage(key, origination) {
|
|
41
|
+
if (origination.pools.length > 1) return `fillSpecFromSchema: record slot "${key}" pools rows from ${origination.pools.map((p) => `"${p}"`).join(" and ")} — a filled record list picks its rows out of ONE asset field, so bind the others with \`source:\` or drop them.`;
|
|
42
|
+
if (origination.title !== void 0) return `fillSpecFromSchema: record slot "${key}" is titled by "${origination.title}"` + (origination.titleType === void 0 ? ", which is not a field of the row" : `, a ${origination.titleType} field`) + " — a filled record list is keyed on its `title:` field, which must be a `text` field the model writes or a `select.of([...])` it picks from.";
|
|
43
|
+
return `fillSpecFromSchema: record slot "${key}" has no field to key its rows on — title the list by the \`text\` field that names a row, give the row exactly one \`select.of([...])\` field, or give it one unbound \`image\`/\`video\`/\`tour\`/\`document\` field to pick rows from.`;
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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);
|
|
45
|
+
function rowFieldDecision(key, fieldKey, field, binding) {
|
|
46
|
+
if (plannerForField(field) === void 0) throw new Error(`fillSpecFromSchema: row field "${key}.${fieldKey}" (type "${String(field.type)}") is filled, but a row cannot fill one — a row field is written or picked inside the list's one batched call, which plans text, a select key, an asset, or a list of text, keys or assets.`);
|
|
47
|
+
return optionsOf(binding);
|
|
115
48
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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.`);
|
|
49
|
+
function assertKeyFieldTakesNoFill(key, slot, origination) {
|
|
50
|
+
if (origination.kind !== "keyed-rows" || origination.keys !== "written") return;
|
|
51
|
+
if (getFill(slot.fields?.[origination.keyField]) === void 0) return;
|
|
52
|
+
throw new Error(`fillSpecFromSchema: slot "${key}" keys rows by "${origination.keyField}", which is filled itself — the list's own fill writes each row's name into that field, so drop the field's fill and say the name's shape in the list's brief.`);
|
|
126
53
|
}
|
|
127
54
|
function recordListDecision(key, slot, reads) {
|
|
128
55
|
const fields = {};
|
|
129
56
|
for (const [fieldKey, rowField] of Object.entries(slot.fields ?? {})) {
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
collectReads(reads,
|
|
133
|
-
|
|
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 };
|
|
57
|
+
const binding = getFill(rowField);
|
|
58
|
+
if (binding === void 0) continue;
|
|
59
|
+
collectReads(reads, binding);
|
|
60
|
+
fields[fieldKey] = rowFieldDecision(key, fieldKey, rowField, binding);
|
|
138
61
|
}
|
|
139
|
-
const
|
|
140
|
-
collectReads(reads,
|
|
141
|
-
if (
|
|
62
|
+
const binding = getFill(slot);
|
|
63
|
+
collectReads(reads, binding);
|
|
64
|
+
if (binding === void 0 && Object.keys(fields).length === 0) {
|
|
142
65
|
assertOrigin(key, slot);
|
|
143
66
|
return;
|
|
144
67
|
}
|
|
145
|
-
const origination =
|
|
68
|
+
const origination = originationFor(slot);
|
|
69
|
+
if (binding === void 0) {
|
|
70
|
+
if (origination?.kind === "bound-rows") return {
|
|
71
|
+
id: key,
|
|
72
|
+
kind: "list",
|
|
73
|
+
produces: [key],
|
|
74
|
+
fields
|
|
75
|
+
};
|
|
76
|
+
throw new Error(`fillSpecFromSchema: record slot "${key}" fills row fields but its rows have no origin — bind the list to a facts array with \`source:\`, or \`fill()\` the list so the model originates its rows.`);
|
|
77
|
+
}
|
|
78
|
+
if (origination?.kind === "unkeyed-rows") throw new Error(unkeyedMessage(key, origination));
|
|
79
|
+
if (origination === void 0) throw new Error(`fillSpecFromSchema: record slot "${key}" originates no rows.`);
|
|
80
|
+
assertKeyFieldTakesNoFill(key, slot, origination);
|
|
146
81
|
return {
|
|
147
82
|
id: key,
|
|
83
|
+
kind: "list",
|
|
148
84
|
produces: [key],
|
|
149
|
-
|
|
150
|
-
...origination,
|
|
85
|
+
...optionsOf(binding),
|
|
151
86
|
fields
|
|
152
87
|
};
|
|
153
88
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
89
|
+
function assertNotRowOnly(key, slot) {
|
|
90
|
+
if (slot.type !== "select") return;
|
|
91
|
+
throw new Error(`fillSpecFromSchema: select slot "${key}" is filled, which only a record row's select field may be — a top-level select is bound with \`source:\`; fill the row field instead.`);
|
|
92
|
+
}
|
|
93
|
+
function slotDecision(key, slot, binding) {
|
|
94
|
+
if (!isListSlot(slot)) assertNotRowOnly(key, slot);
|
|
95
|
+
const origination = originationFor(slot);
|
|
96
|
+
if (origination === void 0) throw new Error(`fillSpecFromSchema: slot "${key}" (type "${String(slot.type)}") is filled, but no fill produces that type.`);
|
|
161
97
|
return {
|
|
162
98
|
id: key,
|
|
99
|
+
kind: kindOf(origination),
|
|
163
100
|
produces: [key],
|
|
164
|
-
|
|
165
|
-
mode: derivedListMode(slot),
|
|
166
|
-
...config
|
|
101
|
+
...optionsOf(binding)
|
|
167
102
|
};
|
|
168
103
|
}
|
|
169
104
|
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
105
|
function displayDecision(schema, reads) {
|
|
177
106
|
const display = schema.meta.display;
|
|
178
107
|
if (display === void 0) return void 0;
|
|
179
108
|
const entries = DISPLAY_ENTRIES.filter((entry) => display[entry]?.fill !== void 0);
|
|
180
109
|
if (entries.length === 0) return void 0;
|
|
181
|
-
|
|
110
|
+
const declared = /* @__PURE__ */ new Map();
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
const binding = getFill(display[entry]?.fill);
|
|
113
|
+
collectReads(reads, binding);
|
|
114
|
+
for (const read of serializedReads(binding?.reads)) declared.set(read.kind === "fact" ? `fact ${read.key}` : `slot ${read.section} ${read.slot}`, read);
|
|
115
|
+
}
|
|
182
116
|
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
117
|
return {
|
|
184
118
|
id: DISPLAY_DECISION_ID,
|
|
185
|
-
|
|
119
|
+
kind: "display",
|
|
186
120
|
entries,
|
|
187
|
-
produces: []
|
|
121
|
+
produces: [],
|
|
122
|
+
...declared.size === 0 ? {} : { reads: [...declared.values()] }
|
|
188
123
|
};
|
|
189
124
|
}
|
|
190
|
-
function
|
|
191
|
-
|
|
125
|
+
function sortedRefs(slots) {
|
|
126
|
+
return [...slots.values()].sort((a, b) => byCodeUnit(a.section, b.section) || byCodeUnit(a.slot, b.slot));
|
|
192
127
|
}
|
|
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
128
|
function fillSpecFromSchema(schema) {
|
|
210
129
|
const decisions = [];
|
|
211
|
-
const reads =
|
|
130
|
+
const reads = {
|
|
131
|
+
facts: /* @__PURE__ */ new Set(),
|
|
132
|
+
slots: /* @__PURE__ */ new Map()
|
|
133
|
+
};
|
|
212
134
|
for (const [key, slot] of Object.entries(schema.slots)) {
|
|
213
135
|
const shape = slot;
|
|
214
136
|
if (shape.type === "list" && shape.fields !== void 0) {
|
|
@@ -216,28 +138,19 @@ function fillSpecFromSchema(schema) {
|
|
|
216
138
|
if (decision !== void 0) decisions.push(decision);
|
|
217
139
|
continue;
|
|
218
140
|
}
|
|
219
|
-
const
|
|
220
|
-
if (
|
|
141
|
+
const binding = getFill(slot);
|
|
142
|
+
if (binding === void 0) {
|
|
221
143
|
assertOrigin(key, shape);
|
|
222
144
|
continue;
|
|
223
145
|
}
|
|
224
|
-
collectReads(reads,
|
|
225
|
-
|
|
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
|
-
});
|
|
146
|
+
collectReads(reads, binding);
|
|
147
|
+
decisions.push(slotDecision(key, shape, binding));
|
|
236
148
|
}
|
|
237
149
|
const display = displayDecision(schema, reads);
|
|
238
150
|
if (display !== void 0) decisions.push(display);
|
|
239
151
|
return {
|
|
240
|
-
reads: [...reads].sort(),
|
|
152
|
+
reads: [...reads.facts].sort(),
|
|
153
|
+
slot_reads: sortedRefs(reads.slots),
|
|
241
154
|
decisions
|
|
242
155
|
};
|
|
243
156
|
}
|
|
@@ -1,174 +1,32 @@
|
|
|
1
|
-
import { FACT_GRAPH
|
|
2
|
-
import { getComputed } from "./compute.js";
|
|
3
|
-
import { projectFactsView } from "../packages/internal/template-contracts/dist/facts-view.js";
|
|
1
|
+
import { FACT_GRAPH } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
4
2
|
import { fillSpecFromSchema } from "./extract-fill-spec.js";
|
|
5
3
|
|
|
6
4
|
//#region src/schema/extract-used-facts.ts
|
|
7
|
-
|
|
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) {
|
|
5
|
+
function collectSource(slot, into) {
|
|
146
6
|
const source = slot.source;
|
|
147
|
-
if (source?.kind === "direct" && source.field !== void 0 && source.field in
|
|
7
|
+
if (source?.kind === "direct" && source.field !== void 0 && source.field in FACT_GRAPH) {
|
|
8
|
+
into.add(source.field);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (source?.kind !== "derived") return;
|
|
12
|
+
for (const ref of source.reads ?? []) if (ref.kind === "fact" && ref.key in FACT_GRAPH) into.add(ref.key);
|
|
148
13
|
}
|
|
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
14
|
function usedFactsFromSchema(schema) {
|
|
161
15
|
const used = /* @__PURE__ */ new Set();
|
|
162
16
|
for (const slot of Object.values(schema.slots)) {
|
|
163
17
|
const shape = slot;
|
|
164
|
-
|
|
165
|
-
for (const rowField of Object.values(shape.fields ?? {}))
|
|
18
|
+
collectSource(shape, used);
|
|
19
|
+
for (const rowField of Object.values(shape.fields ?? {})) collectSource(rowField, used);
|
|
20
|
+
}
|
|
21
|
+
const display = schema.meta.display;
|
|
22
|
+
for (const entry of ["visibility", "variant"]) {
|
|
23
|
+
const declared = display?.[entry];
|
|
24
|
+
if (declared !== void 0) collectSource(declared, used);
|
|
166
25
|
}
|
|
167
26
|
for (const read of fillSpecFromSchema(schema).reads) {
|
|
168
27
|
const base = read.split(".")[0];
|
|
169
|
-
if (base in
|
|
28
|
+
if (base in FACT_GRAPH) used.add(base);
|
|
170
29
|
}
|
|
171
|
-
for (const fn of Object.values(getComputed(schema))) traceCompute(fn, used);
|
|
172
30
|
return [...used].sort();
|
|
173
31
|
}
|
|
174
32
|
|
package/dist/schema/fact.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { SOURCE_FIELDS, SourceFieldContainer, SourceFieldName } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
1
|
+
import { FACT_GRAPH, FactGraphName, SOURCE_FIELDS, SourceFieldContainer, SourceFieldName } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { FactValue } from "../packages/internal/template-contracts/dist/facts-view.js";
|
|
2
3
|
import { ComparableRow, UnitRow } from "./property-facts.js";
|
|
3
4
|
import { ContactRow } from "./runtime-values.js";
|
|
5
|
+
import { FactRef } from "./slot-ref.js";
|
|
4
6
|
//#region src/schema/fact.d.ts
|
|
5
7
|
type SourceFields = typeof SOURCE_FIELDS;
|
|
8
|
+
type Graph = typeof FACT_GRAPH;
|
|
6
9
|
/**
|
|
7
10
|
* The members each bakeable fact array projects onto every row, whatever the
|
|
8
11
|
* slot declares — one entry per collection a record list may bind whole-row
|
|
@@ -18,11 +21,12 @@ type CollectionRowValues = {
|
|
|
18
21
|
contacts: ContactRow;
|
|
19
22
|
comparables: ComparableRow;
|
|
20
23
|
};
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* A slot's `direct` binding: the canonical field itself, writable when the catalog
|
|
26
|
+
* gives it a writeback — and a typed {@link FactRef} on the very same two runtime
|
|
27
|
+
* members, so one value serves `source:` and a declaration's `reads` alike.
|
|
28
|
+
*/
|
|
29
|
+
type DirectFactRef<F extends SourceFieldName> = FactRef<F, FactValue<F & FactGraphName>>;
|
|
26
30
|
/**
|
|
27
31
|
* A slot's `derived` binding: a value the section's own `compute()` fn
|
|
28
32
|
* produces, keyed by the slot's own name. No `fact.*` entry emits one — the
|
|
@@ -45,22 +49,31 @@ declare const PROJECTIONS: {
|
|
|
45
49
|
};
|
|
46
50
|
type Projections = typeof PROJECTIONS;
|
|
47
51
|
type ProjectionsIn<C extends SourceFieldContainer> = C extends keyof Projections ? { [K in keyof Projections[C]]: DirectFactRef<Projections[C][K] & SourceFieldName>; } : Record<never, never>;
|
|
52
|
+
type ReadableName = { [K in FactGraphName]: Graph[K] extends {
|
|
53
|
+
role: "readable";
|
|
54
|
+
} ? Graph[K] extends {
|
|
55
|
+
primary_of: string;
|
|
56
|
+
} ? never : K : never; }[FactGraphName];
|
|
57
|
+
type Readables = { [K in ReadableName]: FactRef<K, FactValue<K>>; };
|
|
48
58
|
/**
|
|
49
59
|
* The shape of `fact`: one branch per source-field container (`property`,
|
|
50
60
|
* `unit`, `contact`), each holding an entry for every canonical field in that
|
|
51
|
-
* container plus one per declared alias
|
|
52
|
-
*
|
|
53
|
-
* you make.
|
|
61
|
+
* container plus one per declared alias, and beside them one entry per
|
|
62
|
+
* readable-only fact. Every entry is a value you pass to a slot builder's
|
|
63
|
+
* `source` or to a declaration's `reads`, not a call you make.
|
|
54
64
|
*/
|
|
55
|
-
type FactNamespace = { [C in SourceFieldContainer]: FieldsIn<C> & ProjectionsIn<C>; };
|
|
65
|
+
type FactNamespace = { [C in SourceFieldContainer]: FieldsIn<C> & ProjectionsIn<C>; } & Readables;
|
|
56
66
|
/**
|
|
57
|
-
* Where a slot's value comes from,
|
|
67
|
+
* Where a slot's value comes from, and what a declaration reads: a bindable fact
|
|
68
|
+
* as `fact.<container>.<field>`, a readable-only one as `fact.<key>`.
|
|
58
69
|
*
|
|
59
70
|
* The container is the resolution rule: `fact.property.*` reads the property
|
|
60
71
|
* root, `fact.unit.*` the primary unit (or the current row inside an
|
|
61
72
|
* record list), `fact.contact.*` the primary contact card (likewise). Hover
|
|
62
73
|
* any entry for its writability — a writable field draws the editor's
|
|
63
|
-
* "Update everywhere" toggle, a read-only one does not.
|
|
74
|
+
* "Update everywhere" toggle, a read-only one does not. A pool entry is
|
|
75
|
+
* readable only: it may be named in a `compute`'s or a fill decision's `reads`,
|
|
76
|
+
* never bound as a slot's `source:`.
|
|
64
77
|
*/
|
|
65
78
|
declare const fact: FactNamespace;
|
|
66
79
|
//#endregion
|
package/dist/schema/fact.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FACT_PROJECTIONS, SOURCE_FIELDS } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
1
|
+
import { FACT_GRAPH, FACT_PROJECTIONS, SOURCE_FIELDS } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
2
|
|
|
3
3
|
//#region src/schema/fact.ts
|
|
4
4
|
const PROJECTIONS = FACT_PROJECTIONS;
|
|
@@ -16,17 +16,13 @@ function buildNamespace() {
|
|
|
16
16
|
kind: "direct",
|
|
17
17
|
field
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
const namespace = { ...containers };
|
|
20
|
+
for (const [key, entry] of Object.entries(FACT_GRAPH)) if (entry.role === "readable" && entry.primary_of === void 0) namespace[key] = {
|
|
21
|
+
kind: "direct",
|
|
22
|
+
field: key
|
|
23
|
+
};
|
|
24
|
+
return namespace;
|
|
20
25
|
}
|
|
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
26
|
const fact = buildNamespace();
|
|
31
27
|
|
|
32
28
|
//#endregion
|