@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,263 +1,25 @@
|
|
|
1
|
-
import { withReads } from "./fill-declaration.js";
|
|
2
|
-
|
|
3
1
|
//#region src/schema/fill-builders.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
* // On list.of(image()) — picks and orders from the property's photos.
|
|
26
|
-
* listFill({ count: { min: 3, max: 8 }, pick: "The strongest set." });
|
|
27
|
-
*
|
|
28
|
-
* // On a row's list.of(document()) — files a subset of the property's documents
|
|
29
|
-
* // into each row; a document lands in at most one row, and the section's
|
|
30
|
-
* // later list fills draw from what remains.
|
|
31
|
-
* listFill({ count: { min: 1, max: 8 }, pick: "The files that belong in this folder." });
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
function listFill(i) {
|
|
35
|
-
const { reads, ...config } = i;
|
|
36
|
-
return withReads(compact({
|
|
37
|
-
type: "list-fill",
|
|
38
|
-
...config
|
|
39
|
-
}), reads);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Fills a single `image` slot by having the model choose one photo from the
|
|
43
|
-
* property's full pool. `pick` is the selection-brief prose. This builder always
|
|
44
|
-
* emits the prompt-driven form (`pick`) — it has no fact-seeded
|
|
45
|
-
* counterpart.
|
|
46
|
-
*
|
|
47
|
-
* A `fallback` chains a `contactAssign` behind the photo pick: when the photo
|
|
48
|
-
* pool yields nothing — the model abstained under `none`, or the property has no
|
|
49
|
-
* photos — the contact pick fills the same slot with the chosen card's logo or
|
|
50
|
-
* headshot. That is how a slot prefers a mark the property uploaded and still
|
|
51
|
-
* lands on a contact's when none was.
|
|
52
|
-
* @example
|
|
53
|
-
* ```ts
|
|
54
|
-
* import { contactAssign, imageAssign } from "@homepages/concrete";
|
|
55
|
-
*
|
|
56
|
-
* imageAssign({ pick: "Pick the striking exterior." });
|
|
57
|
-
*
|
|
58
|
-
* // The builder's own mark from the uploads; else the developer's card, else the primary's.
|
|
59
|
-
* imageAssign({
|
|
60
|
-
* pick: "The builder's or developer's own mark among the uploads.",
|
|
61
|
-
* none: "No upload is a builder's mark.",
|
|
62
|
-
* fallback: contactAssign({ pick: "The developer or builder; else the primary contact.", field: "logo_dark" }),
|
|
63
|
-
* });
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
function imageAssign(i) {
|
|
67
|
-
const fallback = "fallback" in i ? compact({ ...i.fallback }) : void 0;
|
|
68
|
-
return compact({
|
|
69
|
-
type: "image-assign",
|
|
70
|
-
pick: i.pick,
|
|
71
|
-
none: i.none,
|
|
72
|
-
fallback
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Fills a single `video` slot by having the model choose one clip from the
|
|
77
|
-
* property's video pool. `pick` is the selection-brief prose. Unlike
|
|
78
|
-
* `imageAssign`, there is no fact-seeded mode — a video only ever reaches a
|
|
79
|
-
* slot by selection.
|
|
80
|
-
*/
|
|
81
|
-
function videoAssign(i) {
|
|
82
|
-
return compact({
|
|
83
|
-
type: "video-assign",
|
|
84
|
-
pick: i.pick,
|
|
85
|
-
none: i.none
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Fills a single `tour` slot by having the model choose one 3D tour from the
|
|
90
|
-
* property's tour pool. `pick` is the selection-brief prose. Like `videoAssign`
|
|
91
|
-
* there is no fact-seeded mode — a tour only ever reaches a slot by selection —
|
|
92
|
-
* and the candidates the model sees are the property's tour links, never its
|
|
93
|
-
* videos: the pool is named by the decision type, not by a parameter.
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* import { tourAssign } from "@homepages/concrete";
|
|
97
|
-
*
|
|
98
|
-
* tourAssign({ pick: "The whole-home walkthrough, not a single-room scan." });
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
function tourAssign(i) {
|
|
102
|
-
return compact({
|
|
103
|
-
type: "tour-assign",
|
|
104
|
-
pick: i.pick,
|
|
105
|
-
none: i.none
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Fills a single `document` slot by having the model choose one file from the
|
|
110
|
-
* documents stored on the property. `pick` is the selection-brief prose — and it
|
|
111
|
-
* is the whole brief, so write it against what a document IS: the model sees each
|
|
112
|
-
* candidate's filename, file type, and whatever text was distilled out of it (a
|
|
113
|
-
* spreadsheet or slide deck carries none, so name the file type when it matters).
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* import { documentAssign } from "@homepages/concrete";
|
|
117
|
-
*
|
|
118
|
-
* documentAssign({ pick: "The offering brochure — a multi-page PDF about the whole property, not a single-unit floor plan." });
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
function documentAssign(i) {
|
|
122
|
-
return compact({
|
|
123
|
-
type: "document-assign",
|
|
124
|
-
pick: i.pick,
|
|
125
|
-
none: i.none
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Fills a single `image` or `text` slot from ONE of the property's attached
|
|
130
|
-
* contacts, chosen by the model against `pick`. The property's contact cards
|
|
131
|
-
* are the candidates (name, title, organisation, and which one is primary); the
|
|
132
|
-
* chosen card's `field` is what the slot receives — so the same decision puts a
|
|
133
|
-
* developer's logo on an `image` slot or a builder's name on a `text` slot.
|
|
134
|
-
* Write the brief against what a card SHOWS: a card carries no role, so "the
|
|
135
|
-
* developer" is read off its title and organisation. Say what to do when no
|
|
136
|
-
* card fits ("else the primary contact"); with exactly one card, or none, no
|
|
137
|
-
* model call is made.
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* import { contactAssign } from "@homepages/concrete";
|
|
141
|
-
*
|
|
142
|
-
* contactAssign({ pick: "The developer or builder of the property; else the primary contact.", field: "logo_dark" });
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
function contactAssign(i) {
|
|
146
|
-
return compact({
|
|
147
|
-
type: "contact-assign",
|
|
148
|
-
pick: i.pick,
|
|
149
|
-
field: i.field,
|
|
150
|
-
none: i.none
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Fills a `text` slot with model-generated prose. `structure` is the prose
|
|
155
|
-
* shape to generate. `perspective` is the required grammatical person the copy
|
|
156
|
-
* is written in — there is no omitted mode, so a reader never has to know a
|
|
157
|
-
* default. `voice` is the required tone/style brief; `content` is an optional
|
|
158
|
-
* additional prompt.
|
|
159
|
-
*
|
|
160
|
-
* The character budget lives on the slot: omit `cap` and the executor writes to
|
|
161
|
-
* the slot's own `cap`. State one here only to ask the model for a STRICTLY
|
|
162
|
-
* SHORTER piece than the slot holds — a cap at or above the slot's is rejected
|
|
163
|
-
* at validation, as a restatement and a silent trim respectively.
|
|
164
|
-
*
|
|
165
|
-
* `reads` puts facts beyond the slice's standing contents in front of the model
|
|
166
|
-
* for THIS brief — `reads: ["photos"]` when the copy describes what the photos
|
|
167
|
-
* show. The section's `reads` is the union over its decisions.
|
|
168
|
-
* @example
|
|
169
|
-
* ```ts
|
|
170
|
-
* import { textBlock } from "@homepages/concrete";
|
|
171
|
-
*
|
|
172
|
-
* // The slot declares the budget: text.medium({ cap: 60, label: "Headline" })
|
|
173
|
-
* textBlock({
|
|
174
|
-
* structure: "single_sentence",
|
|
175
|
-
* perspective: "third",
|
|
176
|
-
* voice: "Confident premium-listing voice.",
|
|
177
|
-
* content: "Write a marketing headline.",
|
|
178
|
-
* });
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
function textBlock(i) {
|
|
182
|
-
return withReads(compact({
|
|
183
|
-
type: "text-block",
|
|
184
|
-
cap: i.cap,
|
|
185
|
-
structure: i.structure,
|
|
186
|
-
perspective: i.perspective,
|
|
187
|
-
voice: i.voice,
|
|
188
|
-
content: i.content,
|
|
189
|
-
none: i.none
|
|
190
|
-
}), i.reads);
|
|
191
|
-
}
|
|
192
|
-
function chooseFrom(i) {
|
|
193
|
-
if (i.count === void 0) return withReads({
|
|
194
|
-
mode: "choose",
|
|
195
|
-
pick: i.pick
|
|
196
|
-
}, i.reads);
|
|
197
|
-
return withReads(i.none === void 0 ? {
|
|
198
|
-
mode: "choose",
|
|
199
|
-
count: i.count,
|
|
200
|
-
pick: i.pick
|
|
201
|
-
} : {
|
|
202
|
-
mode: "choose",
|
|
203
|
-
count: i.count,
|
|
204
|
-
pick: i.pick,
|
|
205
|
-
none: i.none
|
|
206
|
-
}, i.reads);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Rows the model originates by NAMING each one — `count.min`..`count.max` of
|
|
210
|
-
* them, steered by `pick` prose. `chooseFrom`'s sibling for the case where no
|
|
211
|
-
* closed vocabulary can be written down in advance: a document library's
|
|
212
|
-
* folders are named for the files a particular property happens to carry, so a
|
|
213
|
-
* fixed list either misses the name that fits or offers names nothing fills.
|
|
214
|
-
*
|
|
215
|
-
* WHICH FIELD the name lands in is not authored — the list's own `title:`
|
|
216
|
-
* already names the field the editor titles a row with, and that is the field
|
|
217
|
-
* the model writes. Its `cap` is the name's character budget, for the same
|
|
218
|
-
* reason: it is already declared. Extraction rejects a slot whose `title:` is
|
|
219
|
-
* absent or names a field that is not `text`, and a titled field that declares
|
|
220
|
-
* a `fill:` of its own: the model writes that field, so state the name's shape
|
|
221
|
-
* in `structureHint` instead.
|
|
222
|
-
*
|
|
223
|
-
* Rows are deduped case-insensitively (first wins) and capped at `count.max`.
|
|
224
|
-
* There is no top-up to `count.min` the way `chooseFrom` has one: a closed
|
|
225
|
-
* vocabulary has unused keys to fall back on, an open one has nothing.
|
|
226
|
-
* @example
|
|
227
|
-
* ```ts
|
|
228
|
-
* import { document, list, listFill, nameRows, text } from "@homepages/concrete";
|
|
229
|
-
*
|
|
230
|
-
* list.of(
|
|
231
|
-
* {
|
|
232
|
-
* folder_name: text.short({ cap: 40, label: "Folder name" }),
|
|
233
|
-
* documents: list.of(document({ label: "Document" }), {
|
|
234
|
-
* label: "Folder documents",
|
|
235
|
-
* max: 8,
|
|
236
|
-
* fill: listFill({ count: { min: 1, max: 8 }, pick: "The files under this name." }),
|
|
237
|
-
* }),
|
|
238
|
-
* },
|
|
239
|
-
* {
|
|
240
|
-
* label: "Document folders",
|
|
241
|
-
* title: "folder_name",
|
|
242
|
-
* max: 6,
|
|
243
|
-
* fill: nameRows({
|
|
244
|
-
* count: { min: 0, max: 4 },
|
|
245
|
-
* pick: "Name a folder only where several files plainly group under one heading.",
|
|
246
|
-
* structureHint: "Title Case.",
|
|
247
|
-
* }),
|
|
248
|
-
* },
|
|
249
|
-
* );
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
function nameRows(i) {
|
|
253
|
-
return withReads(compact({
|
|
254
|
-
mode: "name",
|
|
255
|
-
count: i.count,
|
|
256
|
-
pick: i.pick,
|
|
257
|
-
structureHint: i.structureHint,
|
|
258
|
-
none: i.none
|
|
259
|
-
}), i.reads);
|
|
2
|
+
const FILL_KEYS = /* @__PURE__ */ new Set([
|
|
3
|
+
"brief",
|
|
4
|
+
"reads",
|
|
5
|
+
"none",
|
|
6
|
+
"count",
|
|
7
|
+
"cap"
|
|
8
|
+
]);
|
|
9
|
+
function fill(options) {
|
|
10
|
+
if (typeof options.brief !== "string" || options.brief.trim() === "") throw new Error("fill(): `brief` is required — it is the whole instruction the model is given.");
|
|
11
|
+
const binding = { kind: "fill" };
|
|
12
|
+
for (const [key, value] of Object.entries(options)) {
|
|
13
|
+
if (!FILL_KEYS.has(key)) throw new Error(`fill(): "${key}" is not an option — a fill takes ${[...FILL_KEYS].map((k) => `\`${k}\``).join(", ")}, and everything the model should know goes in the brief.`);
|
|
14
|
+
if (key === "none" && value !== void 0 && value !== true) throw new Error("fill(): `none` is `true` or absent — it admits the empty answer, and the brief's last sentence says when nothing is right.");
|
|
15
|
+
if (value === void 0) continue;
|
|
16
|
+
binding[key] = key === "reads" ? [...value] : value;
|
|
17
|
+
}
|
|
18
|
+
return binding;
|
|
19
|
+
}
|
|
20
|
+
function isFillBinding(x) {
|
|
21
|
+
return typeof x === "object" && x !== null && "kind" in x && x.kind === "fill" && "brief" in x && typeof x.brief === "string";
|
|
260
22
|
}
|
|
261
23
|
|
|
262
24
|
//#endregion
|
|
263
|
-
export {
|
|
25
|
+
export { fill, isFillBinding };
|
|
@@ -1,76 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ComputeBinding } from "./compute.js";
|
|
3
|
-
import { BuiltDecision, ChosenRows, DecisionKind, NamedRows } from "./fill-builders.js";
|
|
4
|
-
import { SlotSource } from "./slot-builders.js";
|
|
1
|
+
import { FillBinding } from "./fill-builders.js";
|
|
5
2
|
//#region src/schema/fill-declaration.d.ts
|
|
6
3
|
/**
|
|
7
|
-
* The key a slot builder attaches its `fill
|
|
8
|
-
*
|
|
4
|
+
* The key a slot builder attaches its `fill()` binding under. Symbol-keyed so the
|
|
5
|
+
* binding never reaches the serialized schema — read it back through
|
|
9
6
|
* `fillSpecFromSchema` rather than off the slot.
|
|
10
7
|
*/
|
|
11
8
|
declare const FILL: unique symbol;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* segment is the entire claim — the remainder documents which part of the fact
|
|
16
|
-
* the prompts use.
|
|
17
|
-
*/
|
|
18
|
-
type DeclarableRead = ReadableFactsKey | `${ReadableFactsKey}.${string}`;
|
|
19
|
-
/**
|
|
20
|
-
* The `[FILL]` member a slot builder's return type carries: the decision kind
|
|
21
|
-
* that slot may be filled with, present exactly when the author declared one.
|
|
22
|
-
*
|
|
23
|
-
* Deliberately keyed on the KIND rather than on the exact decision the author
|
|
24
|
-
* passed. Carrying the precise type would mean a builder type parameter
|
|
25
|
-
* inferred from `fill:`, and every slot inside `defineSchema` is contextually
|
|
26
|
-
* typed by `Slot` — which fixes such a parameter before the argument is looked
|
|
27
|
-
* at, rejecting the declaration the call just took.
|
|
28
|
-
*/
|
|
29
|
-
type FillMark<D> = {
|
|
30
|
-
[FILL]?: D;
|
|
9
|
+
/** The `[FILL]` member a slot builder's return type carries, present exactly when the slot is filled. */
|
|
10
|
+
type FillMark = {
|
|
11
|
+
[FILL]?: FillBinding;
|
|
31
12
|
};
|
|
32
|
-
/**
|
|
33
|
-
* The `fill:` key a builder's options admit, decided by whether the slot is
|
|
34
|
-
* source-bound. A slot declares EXACTLY ONE of `source:` / `fill:` — a value
|
|
35
|
-
* baked from a fact is not also generated — so a source binding collapses this
|
|
36
|
-
* to `fill?: never`. `Legal` is the decision type that slot kind accepts;
|
|
37
|
-
* the binding-only kinds (`url`, `number`, a fact-sourced `select`) intersect
|
|
38
|
-
* nothing at all and so admit no `fill` key in either state. A hand-authored
|
|
39
|
-
* `select.of` is the exception: its vocabulary is written out, so a row field
|
|
40
|
-
* of that shape takes the countless `chooseFrom` and is planned per row.
|
|
41
|
-
*
|
|
42
|
-
* The naked (distributive) `HasSource` mirrors `SourceMark`/`WritebackOption`
|
|
43
|
-
* and is what makes the PERMISSIVE branch the fallback: inside `defineSchema` an
|
|
44
|
-
* unsourced builder call resolves `HasSource` to its whole constraint, which a
|
|
45
|
-
* `[HasSource] extends [undefined]` test would read as source-bound and reject
|
|
46
|
-
* the fill. Distributing leaves the unsourced arm in the union.
|
|
47
|
-
*/
|
|
48
|
-
type FillOption<HasSource, Legal> = HasSource extends SlotSource | ComputeBinding<unknown> ? {
|
|
49
|
-
fill?: never;
|
|
50
|
-
} : {
|
|
51
|
-
fill?: Legal;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* What a slot's `fill:` may hold: a built decision for an ordinary fillable
|
|
55
|
-
* slot, or — for a model-originated record list — the row origination itself
|
|
56
|
-
* (`chooseFrom` over a closed vocabulary, `nameRows` over an open one), which IS
|
|
57
|
-
* that slot's whole fill declaration.
|
|
58
|
-
*/
|
|
59
|
-
type SlotFill = BuiltDecision<DecisionKind> | ChosenRows | NamedRows;
|
|
60
|
-
/**
|
|
61
|
-
* The `reads` option every decision whose executor reads the fact slice admits:
|
|
62
|
-
* the fact keys THIS decision's brief needs beyond the slice's standing contents
|
|
63
|
-
* (the address, the units, the narrative, the primary contact), optionally dotted
|
|
64
|
-
* to name a path within one. Declared on the decision because its reason is that
|
|
65
|
-
* brief's wording. A `source:`-bound slot is baked from the full property facts
|
|
66
|
-
* and needs none.
|
|
67
|
-
*/
|
|
68
|
-
interface Readable {
|
|
69
|
-
/**
|
|
70
|
-
* Fact keys this decision's brief needs on the slice — `photos`, `tours`,
|
|
71
|
-
* `floor_plans`. The section's `reads` is the union over its decisions.
|
|
72
|
-
*/
|
|
73
|
-
reads?: readonly DeclarableRead[];
|
|
74
|
-
}
|
|
75
13
|
//#endregion
|
|
76
|
-
export {
|
|
14
|
+
export { FILL, FillMark };
|
|
@@ -1,43 +1,14 @@
|
|
|
1
|
+
import { isFillBinding } from "./fill-builders.js";
|
|
2
|
+
|
|
1
3
|
//#region src/schema/fill-declaration.ts
|
|
2
|
-
/**
|
|
3
|
-
* The key a slot builder attaches its `fill:` declaration under. Symbol-keyed so
|
|
4
|
-
* the declaration never reaches the serialized schema — read it back through
|
|
5
|
-
* `fillSpecFromSchema` rather than off the slot.
|
|
6
|
-
*/
|
|
7
4
|
const FILL = Symbol.for("@homepages/concrete:fill:declaration");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* unlike `FILL`, and that difference is load-bearing: extraction assembles each
|
|
11
|
-
* emitted decision by spreading the built one, and a spread skips a
|
|
12
|
-
* non-enumerable key, so the list never reaches a decision literal on the wire.
|
|
13
|
-
* The section's `reads` is materialized from these (`fillSpecFromSchema`).
|
|
14
|
-
*/
|
|
15
|
-
const READS = Symbol.for("@homepages/concrete:fill:reads");
|
|
16
|
-
/** The `[FILL]` property a builder spreads into its emitted slot — nothing when no fill was declared. */
|
|
17
|
-
function fillMark(fill) {
|
|
18
|
-
return fill !== void 0 ? { [FILL]: fill } : {};
|
|
5
|
+
function fillMark(source) {
|
|
6
|
+
return isFillBinding(source) ? { [FILL]: source } : {};
|
|
19
7
|
}
|
|
20
|
-
/** Reads a slot's colocated `fill:` declaration, or `undefined` when it declares none. */
|
|
21
8
|
function getFill(slot) {
|
|
22
9
|
if (typeof slot !== "object" || slot === null) return void 0;
|
|
23
10
|
return slot[FILL];
|
|
24
11
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Attaches a built decision's `reads` (non-enumerable, see `READS`) and returns
|
|
27
|
-
* the same object. No list, no key: an undeclaring decision reads as `[]`.
|
|
28
|
-
*/
|
|
29
|
-
function withReads(decision, reads) {
|
|
30
|
-
if (reads !== void 0) Object.defineProperty(decision, READS, {
|
|
31
|
-
value: [...reads],
|
|
32
|
-
enumerable: false
|
|
33
|
-
});
|
|
34
|
-
return decision;
|
|
35
|
-
}
|
|
36
|
-
/** Reads a decision's `reads` list, or `[]` when it declared none. */
|
|
37
|
-
function getReads(decision) {
|
|
38
|
-
if (typeof decision !== "object" || decision === null) return [];
|
|
39
|
-
return decision[READS] ?? [];
|
|
40
|
-
}
|
|
41
12
|
|
|
42
13
|
//#endregion
|
|
43
|
-
export { FILL,
|
|
14
|
+
export { FILL, fillMark, getFill };
|
package/dist/schema/fill-spec.js
CHANGED
|
@@ -1,170 +1,81 @@
|
|
|
1
|
-
import { DISPLAY_ENTRIES
|
|
1
|
+
import { DISPLAY_ENTRIES } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/schema/fill-spec.ts
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
pick: z.string(),
|
|
10
|
-
field: z.enum(REFERRAL_FIELDS),
|
|
11
|
-
none: AbstentionBrief,
|
|
12
|
-
produces: z.array(z.string()).min(1)
|
|
13
|
-
}).strict();
|
|
14
|
-
const ImageAssignBase = z.object({
|
|
15
|
-
id: z.string(),
|
|
16
|
-
type: z.literal("image-assign"),
|
|
17
|
-
pick: z.string(),
|
|
18
|
-
none: AbstentionBrief,
|
|
19
|
-
produces: z.array(z.string()).min(1)
|
|
5
|
+
const SlotReadRef = z.object({
|
|
6
|
+
kind: z.literal("slot").default("slot"),
|
|
7
|
+
section: z.string().min(1),
|
|
8
|
+
slot: z.string().min(1)
|
|
20
9
|
}).strict();
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}).optional() }).strict();
|
|
25
|
-
const VideoAssignDecision = z.object({
|
|
26
|
-
id: z.string(),
|
|
27
|
-
type: z.literal("video-assign"),
|
|
28
|
-
pick: z.string(),
|
|
29
|
-
none: AbstentionBrief,
|
|
30
|
-
produces: z.array(z.string()).min(1)
|
|
10
|
+
const FactReadRef = z.object({
|
|
11
|
+
kind: z.literal("fact"),
|
|
12
|
+
key: z.string().min(1)
|
|
31
13
|
}).strict();
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
const DecisionReads = z.array(z.union([FactReadRef, SlotReadRef])).min(1).optional();
|
|
15
|
+
const Brief = z.string().min(1);
|
|
16
|
+
const Abstention = z.literal(true).optional();
|
|
17
|
+
const Count = z.union([
|
|
18
|
+
z.number().int().positive(),
|
|
19
|
+
z.object({ max: z.number().int().positive() }).strict(),
|
|
20
|
+
z.object({
|
|
21
|
+
min: z.number().int().positive(),
|
|
22
|
+
max: z.number().int().positive()
|
|
23
|
+
}).strict()
|
|
24
|
+
]).optional();
|
|
25
|
+
const Cap = z.number().int().positive().optional();
|
|
26
|
+
const RowFieldDecision = z.object({
|
|
27
|
+
brief: Brief,
|
|
28
|
+
none: Abstention,
|
|
29
|
+
count: Count,
|
|
30
|
+
cap: Cap,
|
|
31
|
+
reads: DecisionReads
|
|
38
32
|
}).strict();
|
|
39
|
-
const
|
|
33
|
+
const TextDecision = z.object({
|
|
40
34
|
id: z.string(),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
kind: z.literal("text"),
|
|
36
|
+
produces: z.array(z.string()).min(1),
|
|
37
|
+
brief: Brief,
|
|
38
|
+
none: Abstention,
|
|
39
|
+
cap: Cap,
|
|
40
|
+
reads: DecisionReads
|
|
45
41
|
}).strict();
|
|
46
|
-
|
|
47
|
-
* The shapes a `text-block` decision may ask the model for — the whole
|
|
48
|
-
* `structure` vocabulary, declared once so the meta-schema below and the
|
|
49
|
-
* `textBlock` builder's authoring type are the same fact rather than two.
|
|
50
|
-
*
|
|
51
|
-
* Three are prose. `value` is not: it is a bare figure, name or label with its
|
|
52
|
-
* unit ("$4,250,000", "5.85%", "Built 1978") for a fact-sheet cell, and the
|
|
53
|
-
* executor tells the model to write no sentence around it. Without it every
|
|
54
|
-
* short text slot came back as a sentence, because `single_sentence` was the
|
|
55
|
-
* shortest shape an author could ask for.
|
|
56
|
-
*/
|
|
57
|
-
const TEXT_STRUCTURES = [
|
|
58
|
-
"single_sentence",
|
|
59
|
-
"paragraph",
|
|
60
|
-
"bullet_list",
|
|
61
|
-
"value"
|
|
62
|
-
];
|
|
63
|
-
const TextBlockDecision = z.object({
|
|
42
|
+
const PickDecision = z.object({
|
|
64
43
|
id: z.string(),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"second",
|
|
71
|
-
"third"
|
|
72
|
-
]).optional(),
|
|
73
|
-
voice: z.string(),
|
|
74
|
-
content: z.string().optional(),
|
|
75
|
-
none: AbstentionBrief,
|
|
76
|
-
produces: z.array(z.string()).min(1)
|
|
77
|
-
}).strict();
|
|
78
|
-
function nested(full) {
|
|
79
|
-
return full.omit({
|
|
80
|
-
id: true,
|
|
81
|
-
produces: true
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
const NestedListFillDecision = z.object({
|
|
85
|
-
type: z.literal("list-fill"),
|
|
86
|
-
count: z.union([z.number().int().positive(), z.object({
|
|
87
|
-
min: z.number().int().nonnegative().optional(),
|
|
88
|
-
max: z.number().int().positive().optional()
|
|
89
|
-
}).strict()]).optional(),
|
|
90
|
-
cap: z.number().int().positive().optional(),
|
|
91
|
-
pick: z.string().optional(),
|
|
92
|
-
structureHint: z.string().optional(),
|
|
93
|
-
voice: z.string().optional(),
|
|
94
|
-
content: z.string().optional(),
|
|
95
|
-
none: AbstentionBrief
|
|
44
|
+
kind: z.literal("pick"),
|
|
45
|
+
produces: z.array(z.string()).min(1),
|
|
46
|
+
brief: Brief,
|
|
47
|
+
none: Abstention,
|
|
48
|
+
reads: DecisionReads
|
|
96
49
|
}).strict();
|
|
97
|
-
const
|
|
98
|
-
type: z.literal("select-assign"),
|
|
99
|
-
pick: z.string(),
|
|
100
|
-
none: AbstentionBrief
|
|
101
|
-
}).strict();
|
|
102
|
-
const NestedDecision = z.discriminatedUnion("type", [
|
|
103
|
-
nested(ImageAssignBase),
|
|
104
|
-
nested(VideoAssignDecision),
|
|
105
|
-
nested(TourAssignDecision),
|
|
106
|
-
nested(DocumentAssignDecision),
|
|
107
|
-
nested(TextBlockDecision),
|
|
108
|
-
NestedListFillDecision,
|
|
109
|
-
SelectAssignNested
|
|
110
|
-
]);
|
|
111
|
-
const ListFillDecision = z.object({
|
|
50
|
+
const ListDecision = z.object({
|
|
112
51
|
id: z.string(),
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
]),
|
|
122
|
-
count: z.union([z.number().int().positive(), z.object({
|
|
123
|
-
min: z.number().int().nonnegative().optional(),
|
|
124
|
-
max: z.number().int().positive().optional()
|
|
125
|
-
}).strict()]).optional(),
|
|
126
|
-
order: z.literal("walkthrough").optional(),
|
|
127
|
-
cap: z.number().int().positive().optional(),
|
|
128
|
-
pick: z.string().optional(),
|
|
129
|
-
structureHint: z.string().optional(),
|
|
130
|
-
voice: z.string().optional(),
|
|
131
|
-
content: z.string().optional(),
|
|
132
|
-
iterate: z.string().optional(),
|
|
133
|
-
none: AbstentionBrief,
|
|
134
|
-
fields: z.record(z.string(), NestedDecision).optional(),
|
|
135
|
-
produces: z.array(z.string()).min(1)
|
|
52
|
+
kind: z.literal("list"),
|
|
53
|
+
produces: z.array(z.string()).min(1),
|
|
54
|
+
brief: Brief.optional(),
|
|
55
|
+
none: Abstention,
|
|
56
|
+
count: Count,
|
|
57
|
+
cap: Cap,
|
|
58
|
+
reads: DecisionReads,
|
|
59
|
+
fields: z.record(z.string(), RowFieldDecision).optional()
|
|
136
60
|
}).strict();
|
|
137
|
-
const
|
|
61
|
+
const DisplayDecision = z.object({
|
|
138
62
|
id: z.string(),
|
|
139
|
-
|
|
63
|
+
kind: z.literal("display"),
|
|
64
|
+
produces: z.array(z.string()).max(0),
|
|
140
65
|
entries: z.array(z.enum(DISPLAY_ENTRIES)).min(1),
|
|
141
|
-
|
|
66
|
+
reads: DecisionReads
|
|
142
67
|
}).strict();
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*/
|
|
149
|
-
const Decision = z.discriminatedUnion("type", [
|
|
150
|
-
ListFillDecision,
|
|
151
|
-
ImageAssignDecision,
|
|
152
|
-
VideoAssignDecision,
|
|
153
|
-
TourAssignDecision,
|
|
154
|
-
DocumentAssignDecision,
|
|
155
|
-
ContactAssignDecision,
|
|
156
|
-
TextBlockDecision,
|
|
157
|
-
DisplaySelectDecision
|
|
68
|
+
const Decision = z.discriminatedUnion("kind", [
|
|
69
|
+
TextDecision,
|
|
70
|
+
PickDecision,
|
|
71
|
+
ListDecision,
|
|
72
|
+
DisplayDecision
|
|
158
73
|
]);
|
|
159
|
-
/**
|
|
160
|
-
* A section's whole authored fill spec: the fact paths it `reads` (defaults
|
|
161
|
-
* to `[]` when omitted) plus its ordered `decisions`. The serialized form
|
|
162
|
-
* lands in the section's published fill spec.
|
|
163
|
-
*/
|
|
164
74
|
const FillSpec = z.object({
|
|
165
75
|
reads: z.array(z.string()).default([]),
|
|
76
|
+
slot_reads: z.array(SlotReadRef).default([]),
|
|
166
77
|
decisions: z.array(Decision)
|
|
167
78
|
}).strict();
|
|
168
79
|
|
|
169
80
|
//#endregion
|
|
170
|
-
export { Decision, FillSpec,
|
|
81
|
+
export { Decision, FillSpec, SlotReadRef };
|
|
@@ -17,11 +17,6 @@ const print = (id, label, category, width, height, bleed) => ({
|
|
|
17
17
|
dpi: 300,
|
|
18
18
|
bleed
|
|
19
19
|
});
|
|
20
|
-
/**
|
|
21
|
-
* The v1 preset library, exported from the kit root. `presets.website` is the
|
|
22
|
-
* geometry-less singleton every website template's format set holds; the rest
|
|
23
|
-
* are the known social/print/deck sizes the picker renders as branded.
|
|
24
|
-
*/
|
|
25
20
|
const presets = {
|
|
26
21
|
instagramSquare: image("instagram-square", "Instagram Square Post", "social-post", 1080, 1080),
|
|
27
22
|
instagramPortrait: image("instagram-portrait", "Instagram Portrait Post", "social-post", 1080, 1350),
|
|
@@ -51,13 +46,6 @@ const presets = {
|
|
|
51
46
|
}
|
|
52
47
|
};
|
|
53
48
|
const RENDERED_PRESETS_BY_TAG = new Map(Object.values(presets).filter((preset) => preset.width !== void 0).map((preset) => [preset.id, preset]));
|
|
54
|
-
/**
|
|
55
|
-
* Whether a format's `preset` provenance tag is truthful. Untagged formats
|
|
56
|
-
* pass; a tagged one passes only when its geometry — width, height, dpi,
|
|
57
|
-
* bleed — exactly matches the library entry the tag names. Identity fields are
|
|
58
|
-
* NOT compared: re-labeling or re-categorizing a preset keeps the tag, because
|
|
59
|
-
* the category is browsing metadata, not geometry.
|
|
60
|
-
*/
|
|
61
49
|
function presetGeometryMatches(format) {
|
|
62
50
|
if (format.preset === void 0) return true;
|
|
63
51
|
const library = RENDERED_PRESETS_BY_TAG.get(format.preset);
|