@homepages/concrete 8.0.0 → 9.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 +988 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +60 -0
- package/codemods/process-builders.mjs +198 -0
- package/codemods/slot-object.mjs +1097 -0
- package/codemods/steps/content-object-fields.mjs +324 -0
- package/codemods/steps/list-object-form.mjs +6 -7
- package/codemods/table-rows.mjs +568 -0
- package/codemods/unwrap-object-fields.mjs +310 -0
- package/codemods/viewer-slot-document.mjs +131 -0
- package/codemods/write-property-as-facts-document.mjs +716 -0
- package/codemods/write-the-address-line.mjs +255 -0
- package/codemods/write-the-registry-members.mjs +653 -0
- package/codemods/write-the-select-from.mjs +141 -0
- package/codemods/write-the-sole-from.mjs +369 -0
- package/codemods/write-the-table-from.mjs +267 -0
- package/codemods/write-the-whole-item.mjs +512 -0
- package/codemods/writeback-drop.mjs +168 -0
- package/codemods/written-contact-address.mjs +162 -0
- package/codemods/written-media-category.mjs +227 -0
- package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
- package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
- package/codemods/written-uploads-sort-into-lists.mjs +405 -0
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
- package/codemods/written-video-sources-drop.mjs +144 -0
- package/codemods/written-without-pick-none.mjs +146 -0
- package/codemods/written-without-retired-knowledge.mjs +223 -0
- package/codemods/written-without-the-media-key.mjs +202 -0
- package/codemods/written-without-the-property-type.mjs +249 -0
- package/dist/artifact/playground/client/assets/index-BUmdDDX5.js +1259 -0
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +61 -27
- package/dist/base.css +58 -1
- package/dist/cli/build/artifact.js +6 -9
- package/dist/cli/build/captures.js +2 -12
- package/dist/cli/build/esbuild.js +1 -25
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/static.js +2 -2
- package/dist/cli/capture/capture.js +8 -9
- package/dist/cli/check/analyze.js +8 -1
- package/dist/cli/check/load-outdir.js +47 -0
- package/dist/cli/check/load-workspace.js +4 -4
- package/dist/cli/check/render/html.js +1 -2
- package/dist/cli/check/render/inputs.js +10 -3
- package/dist/cli/check/render/island-frames.js +2 -1
- package/dist/cli/check/render/marker-coverage.js +23 -15
- package/dist/cli/check/report.js +5 -0
- package/dist/cli/check/stages/bundles.js +1 -1
- package/dist/cli/check/stages/relations.js +1 -1
- package/dist/cli/check/stages/render.js +48 -33
- package/dist/cli/check/stages/sections.js +83 -31
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/crop.js +1 -1
- package/dist/cli/dev/fixture-ladders.js +96 -0
- package/dist/cli/dev/islands.js +12 -123
- package/dist/cli/dev/listen.js +20 -1
- package/dist/cli/dev/load-template.js +1 -1
- package/dist/cli/dev/server.js +35 -10
- package/dist/cli/dev/vite.js +9 -7
- package/dist/cli/dev/workspace-reader.js +16 -16
- package/dist/cli/media/derive.js +43 -57
- package/dist/cli/media/frame-rung-floor.js +0 -1
- package/dist/cli/property/index.js +1 -6
- package/dist/css/inline.js +1 -22
- package/dist/eslint/rules/no-marker-literal.js +1 -1
- package/dist/fixtures/load.js +16 -7
- package/dist/fixtures/media-plugin.js +17 -12
- package/dist/fixtures/media-store.js +115 -0
- package/dist/fixtures/property.js +345 -126
- package/dist/fixtures/resolve.js +263 -251
- package/dist/fixtures/rows.js +4 -11
- package/dist/fixtures.d.ts +234 -109
- package/dist/index.d.ts +25 -16
- package/dist/index.js +10 -6
- package/dist/islands/marker.js +2 -1
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
- package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
- package/dist/packages/internal/capture-settle/dist/index.js +3 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
- package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
- package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +251 -33
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +365 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +35 -21
- package/dist/packages/internal/fill-bake/dist/index.js +8 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +119 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +28 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +40 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +175 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +390 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +75 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
- package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
- package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
- package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
- package/dist/packages/internal/image-ladder/dist/index.js +3 -3
- package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
- package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
- package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
- package/dist/packages/internal/island-runtime/dist/index.js +2 -1
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
- package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
- package/dist/packages/internal/media-resolution/dist/document.js +63 -0
- package/dist/packages/internal/media-resolution/dist/image.js +228 -0
- package/dist/packages/internal/media-resolution/dist/index.js +11 -0
- package/dist/packages/internal/media-resolution/dist/list.js +112 -0
- package/dist/packages/internal/media-resolution/dist/media.js +59 -0
- package/dist/packages/internal/media-resolution/dist/records.js +7 -0
- package/dist/packages/internal/media-resolution/dist/slot.js +34 -0
- package/dist/packages/internal/media-resolution/dist/store.js +19 -0
- package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
- package/dist/packages/internal/media-resolution/dist/video.js +93 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +244 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +34 -10
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
- package/dist/packages/internal/section-contracts/dist/index.js +7 -1
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +15 -20
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -7
- package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +5 -5
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +7 -4
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +83 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +74 -10
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +103 -46
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
- package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +42 -21
- package/dist/packages/internal/source-resolution/dist/index.js +113 -72
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
- package/dist/packages/internal/street-address/dist/index.js +72 -0
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
- package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
- package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
- package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +85 -0
- package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
- package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +10 -24
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
- package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +158 -0
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
- package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
- package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
- package/dist/packages/internal/template-contracts/dist/list-editing.js +94 -0
- package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
- package/dist/packages/internal/template-contracts/dist/list.js +258 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
- package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
- package/dist/packages/internal/template-contracts/dist/object.js +131 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
- package/dist/packages/internal/template-contracts/dist/read-graph.js +250 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +192 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +268 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
- package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
- package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
- package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +133 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +49 -3
- package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/row.js +84 -0
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +243 -384
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +335 -227
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.js +140 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
- package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
- package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
- package/dist/platform/fs.js +5 -2
- package/dist/playground/canvas-island-host.d.ts +11 -0
- package/dist/playground/canvas-island-host.js +29 -0
- package/dist/playground/canvas-markers.js +14 -0
- package/dist/playground-island-runtime.d.ts +3 -2
- package/dist/playground-island-runtime.js +3 -2
- package/dist/primitives/FrameShell.js +0 -1
- package/dist/primitives/Image.d.ts +5 -4
- package/dist/primitives/Tour.d.ts +1 -1
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/index.d.ts +2 -3
- package/dist/primitives/picture-sources.js +2 -2
- package/dist/primitives/probe-context.js +2 -12
- package/dist/primitives/slot-address.d.ts +44 -0
- package/dist/primitives/slot-address.js +19 -0
- package/dist/primitives/slot-bindings.d.ts +65 -26
- package/dist/primitives/slot-bindings.js +104 -46
- package/dist/primitives/slot-document.d.ts +23 -18
- package/dist/primitives/slot-document.js +39 -14
- package/dist/primitives/slot-download.d.ts +39 -0
- package/dist/primitives/slot-download.js +39 -0
- package/dist/primitives/slot-list.d.ts +3 -3
- package/dist/primitives/slot-list.js +0 -2
- package/dist/primitives/slot-media.d.ts +24 -5
- package/dist/primitives/slot-media.js +6 -9
- package/dist/primitives/slot-object.d.ts +49 -0
- package/dist/primitives/slot-object.js +20 -0
- package/dist/primitives/slot-scalar.d.ts +27 -2
- package/dist/primitives/slot-scalar.js +50 -7
- package/dist/primitives/slot.d.ts +13 -6
- package/dist/primitives/slot.js +10 -3
- package/dist/rules/registry.js +19 -30
- package/dist/schema/define-schema.d.ts +4 -8
- package/dist/schema/define-schema.js +178 -79
- package/dist/schema/extract-fill-spec.js +2 -153
- package/dist/schema/fact.d.ts +57 -15
- package/dist/schema/fact.js +42 -7
- package/dist/schema/facts-view.d.ts +14 -0
- package/dist/schema/format.d.ts +1 -0
- package/dist/schema/format.js +2 -1
- package/dist/schema/manifest.js +24 -0
- package/dist/schema/property-facts.d.ts +8 -12
- package/dist/schema/section-props.d.ts +2 -66
- package/dist/schema/section-schema.d.ts +8 -11
- package/dist/schema/section-schema.js +27 -10
- package/dist/section/declare.d.ts +18 -7
- package/dist/section/declare.js +18 -5
- package/dist/section/materialize.js +3 -8
- package/dist/section/section.d.ts +12 -8
- package/dist/section/section.js +1 -1
- package/dist/template/logic-shim.d.ts +14 -7
- package/dist/template/logic-shim.js +14 -7
- package/dist/template/materialize.js +17 -18
- package/dist/template/mirror-types.js +30 -31
- package/dist/template/section-reads.js +85 -9
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +28 -24
- package/package.json +9 -8
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
- package/dist/artifact/playground/client/assets/index-Dn_xT16-.js +0 -1101
- package/dist/fixtures/canonical.d.ts +0 -166
- package/dist/fixtures/media.js +0 -163
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -51
- package/dist/packages/internal/format-geometry/dist/index.js +0 -4
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
- package/dist/packages/internal/property-facts/dist/index.js +0 -3
- package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
- package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -104
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
- package/dist/primitives/slot-group.d.ts +0 -40
- package/dist/primitives/slot-group.js +0 -36
- package/dist/schema/extract-used-facts.js +0 -34
- package/dist/schema/fill-builders.d.ts +0 -115
- package/dist/schema/fill-builders.js +0 -25
- package/dist/schema/fill-declaration.d.ts +0 -14
- package/dist/schema/fill-spec.js +0 -98
- package/dist/schema/layout.d.ts +0 -30
- package/dist/schema/layout.js +0 -14
- package/dist/schema/row-fields.js +0 -88
- package/dist/schema/row-ref.d.ts +0 -59
- package/dist/schema/row-ref.js +0 -28
- package/dist/schema/runtime-values.d.ts +0 -71
- package/dist/schema/section-nav.js +0 -14
- package/dist/schema/slot-builders.d.ts +0 -633
- package/dist/schema/slot-builders.js +0 -177
- package/dist/schema/slot-ref.d.ts +0 -79
- package/dist/schema/slot-ref.js +0 -41
- package/dist/schema/slot-types.d.ts +0 -111
- package/dist/schema/slot-types.js +0 -214
- package/dist/section/groups.js +0 -68
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { normalizeAddressValue } from "../../template-contracts/dist/address-value.js";
|
|
2
|
+
import { storedAsRefs } from "../../template-contracts/dist/registry-facts.js";
|
|
3
|
+
import { attributedRows, elementIdentity, elementIdentityKey } from "../../template-contracts/dist/ref-locate.js";
|
|
4
|
+
import { elementRowKeys, memberSourceOf, rowMemberOf, rowMemberSources } from "../../template-contracts/dist/row-sources.js";
|
|
5
|
+
import { projectTableRows, readRowMember } from "../../source-resolution/dist/index.js";
|
|
6
|
+
|
|
7
|
+
//#region ../../internal/fill-bake/dist/list-grammar.js
|
|
8
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
9
|
+
function isGrammarList(def) {
|
|
10
|
+
return def.type === "list" && def.fields === void 0 && def.element !== void 0;
|
|
11
|
+
}
|
|
12
|
+
function objectElementFields(def) {
|
|
13
|
+
return def.element?.type === "object" ? def.element.fields ?? {} : void 0;
|
|
14
|
+
}
|
|
15
|
+
function decisionProducing(scope, path) {
|
|
16
|
+
return scope.decisions?.find((decision) => decision.produces?.includes(path) === true);
|
|
17
|
+
}
|
|
18
|
+
function rowIdentity(element, table) {
|
|
19
|
+
if (typeof element === "string") return element === "" ? null : element;
|
|
20
|
+
return elementIdentity(element, table);
|
|
21
|
+
}
|
|
22
|
+
function computedRow(element, tables, facts) {
|
|
23
|
+
const [first] = tables;
|
|
24
|
+
if (first === void 0) return {
|
|
25
|
+
table: null,
|
|
26
|
+
id: rowIdentity(element, null),
|
|
27
|
+
element
|
|
28
|
+
};
|
|
29
|
+
if (tables.length > 1) for (const table of tables) {
|
|
30
|
+
const id = rowIdentity(element, table);
|
|
31
|
+
if (id !== null && attributedRows(facts, [table]).some((row) => row.id === id)) return {
|
|
32
|
+
table,
|
|
33
|
+
id
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
table: first,
|
|
38
|
+
id: rowIdentity(element, first)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function registryReadingOf(table) {
|
|
42
|
+
return {
|
|
43
|
+
table: table.table,
|
|
44
|
+
reading: "registry"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function readResolvedRowMember(row, member, facts) {
|
|
48
|
+
if (row.table !== null) return row.id === null ? null : storedAsRefs(readRowMember(row.table, row.id, member, facts));
|
|
49
|
+
return isRecord(row.element) ? row.element[member] ?? null : null;
|
|
50
|
+
}
|
|
51
|
+
function fnv1a(text) {
|
|
52
|
+
let hash = 2166136261;
|
|
53
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
54
|
+
hash ^= text.charCodeAt(i);
|
|
55
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
56
|
+
}
|
|
57
|
+
return hash.toString(16).padStart(8, "0");
|
|
58
|
+
}
|
|
59
|
+
function contentIdentities(elements) {
|
|
60
|
+
const seen = /* @__PURE__ */ new Map();
|
|
61
|
+
return elements.map((element) => {
|
|
62
|
+
const base = elementIdentity(element, null) ?? `el_${fnv1a(JSON.stringify(element) ?? "undefined")}`;
|
|
63
|
+
const count = seen.get(base) ?? 0;
|
|
64
|
+
seen.set(base, count + 1);
|
|
65
|
+
return count === 0 ? base : `${base}_${String(count)}`;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function projectElements(elements, projection) {
|
|
69
|
+
const { element, table, facts, computes } = projection;
|
|
70
|
+
const fields = element.type === "object" ? element.fields ?? {} : void 0;
|
|
71
|
+
if (table !== null) {
|
|
72
|
+
if (fields === void 0) return elements.map((identified) => identified.id);
|
|
73
|
+
const idKey = elementIdentityKey(table.table);
|
|
74
|
+
const members = rowMemberSources(fields);
|
|
75
|
+
return elements.flatMap(({ element: held, id }) => {
|
|
76
|
+
const rowId = typeof held === "string" ? held : id;
|
|
77
|
+
const [projected] = storedAsRefs(projectTableRows(table, facts, fields, computes, [rowId]));
|
|
78
|
+
if (projected === void 0) return [];
|
|
79
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
80
|
+
const nested = nestedItemOf(field);
|
|
81
|
+
const member = members[key];
|
|
82
|
+
if (nested !== void 0 && member !== void 0 && readsElementRows(nested)) projected[key] = storedAsRefs(readRowMember(registryReadingOf(table), rowId, member, facts));
|
|
83
|
+
}
|
|
84
|
+
return [withNestedLists({
|
|
85
|
+
...projected,
|
|
86
|
+
[idKey]: id
|
|
87
|
+
}, fields, facts)];
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (element.type === "row") return elements.map((identified) => identified.id);
|
|
91
|
+
if (fields === void 0) return elements.map((identified) => identified.element);
|
|
92
|
+
return elements.map((identified) => withNestedLists(projectContentItem(identified, fields, computes), fields, facts));
|
|
93
|
+
}
|
|
94
|
+
function nestedItemOf(def) {
|
|
95
|
+
return isGrammarList(def) && def.element?.type === "object" ? def.element : void 0;
|
|
96
|
+
}
|
|
97
|
+
function readsElementRows(declaration) {
|
|
98
|
+
const fields = declaration.fields ?? {};
|
|
99
|
+
return elementRowKeys(fields).length > 0 || Object.keys(rowMemberSources(fields)).length > 0;
|
|
100
|
+
}
|
|
101
|
+
function readNestedMember(row, member, nestedItem, facts) {
|
|
102
|
+
if (row.table !== null && row.id !== null && readsElementRows(nestedItem)) return storedAsRefs(readRowMember(registryReadingOf(row.table), row.id, member, facts));
|
|
103
|
+
return readResolvedRowMember(row, member, facts);
|
|
104
|
+
}
|
|
105
|
+
function projectNestedList(value, nestedItem, facts) {
|
|
106
|
+
if (!Array.isArray(value)) return value;
|
|
107
|
+
const ids = contentIdentities(value);
|
|
108
|
+
return projectElements(value.map((element, i) => ({
|
|
109
|
+
element,
|
|
110
|
+
id: ids[i]
|
|
111
|
+
})), {
|
|
112
|
+
element: nestedItem,
|
|
113
|
+
table: null,
|
|
114
|
+
facts,
|
|
115
|
+
computes: {}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function withNestedLists(projected, fields, facts) {
|
|
119
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
120
|
+
const nested = nestedItemOf(field);
|
|
121
|
+
if (nested !== void 0 && Object.hasOwn(projected, key)) projected[key] = projectNestedList(projected[key], nested, facts);
|
|
122
|
+
}
|
|
123
|
+
return projected;
|
|
124
|
+
}
|
|
125
|
+
function projectContentItem({ element, id, storedItem }, fields, computes) {
|
|
126
|
+
const elementRows = new Set(elementRowKeys(fields));
|
|
127
|
+
const readMember = (member) => isRecord(element) ? element[member] ?? null : null;
|
|
128
|
+
const out = { id };
|
|
129
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
130
|
+
if (elementRows.has(key)) {
|
|
131
|
+
out[key] = id;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (isRecord(field.source) && field.source["kind"] === "element") {
|
|
135
|
+
out[key] = element;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const member = memberSourceOf(field.source);
|
|
139
|
+
if (member !== null && elementRows.has(member.slot)) {
|
|
140
|
+
out[key] = readMember(member.field);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const enclosing = rowMemberOf(field.source);
|
|
144
|
+
if (enclosing !== null) out[key] = readMember(enclosing);
|
|
145
|
+
}
|
|
146
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
147
|
+
const member = memberSourceOf(field.source);
|
|
148
|
+
if (member === null || fields[member.slot]?.type !== "address") continue;
|
|
149
|
+
const address = normalizeAddressValue(Object.hasOwn(out, member.slot) ? out[member.slot] : storedItem?.[member.slot]);
|
|
150
|
+
out[key] = isRecord(address) ? address[member.field] ?? null : null;
|
|
151
|
+
}
|
|
152
|
+
for (const [key, compute] of Object.entries(computes)) out[key] = compute(readMember, element);
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
function storedElements(stored, fields, table) {
|
|
156
|
+
if (!Array.isArray(stored)) return [];
|
|
157
|
+
const elementRows = elementRowKeys(fields);
|
|
158
|
+
const elementField = Object.entries(fields).find(([, field]) => isRecord(field.source) && field.source["kind"] === "element" && field.type !== "row")?.[0];
|
|
159
|
+
return stored.flatMap((storedItem) => {
|
|
160
|
+
const id = elementIdentity(storedItem, table);
|
|
161
|
+
if (id === null || !isRecord(storedItem)) return [];
|
|
162
|
+
if (table !== null) return [{
|
|
163
|
+
element: elementRows.map((key) => storedItem[key]).find((value) => typeof value === "string" && value !== "") ?? id,
|
|
164
|
+
id
|
|
165
|
+
}];
|
|
166
|
+
return [{
|
|
167
|
+
element: elementField !== void 0 ? storedItem[elementField] : elementRows.length > 0 ? id : void 0,
|
|
168
|
+
id,
|
|
169
|
+
storedItem
|
|
170
|
+
}];
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
export { computedRow, contentIdentities, decisionProducing, isGrammarList, nestedItemOf, objectElementFields, projectElements, projectNestedList, readNestedMember, readResolvedRowMember, readsElementRows, rowIdentity, storedElements };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { poolingPrimitiveOf } from "../../template-contracts/dist/row-planners.js";
|
|
2
|
+
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
3
|
+
import "./row-planners.js";
|
|
4
|
+
|
|
5
|
+
//#region ../../internal/fill-vocabulary/dist/holder.js
|
|
6
|
+
const LEGACY_COLLECTION_ITEM = {
|
|
7
|
+
image_collection: "image",
|
|
8
|
+
video_collection: "video",
|
|
9
|
+
poi_list: "poi"
|
|
10
|
+
};
|
|
11
|
+
function isListSlot(slot) {
|
|
12
|
+
return slot.type === "list" || slot.type !== void 0 && slot.type in LEGACY_COLLECTION_ITEM;
|
|
13
|
+
}
|
|
14
|
+
function listItemTypeOf(slot) {
|
|
15
|
+
return slot.element?.type ?? LEGACY_COLLECTION_ITEM[slot.type ?? ""];
|
|
16
|
+
}
|
|
17
|
+
function poolOfKind(kind) {
|
|
18
|
+
return kind === void 0 ? void 0 : poolingPrimitiveOf({ type: kind });
|
|
19
|
+
}
|
|
20
|
+
function bindsElement(field) {
|
|
21
|
+
const source = field.source;
|
|
22
|
+
return field.type !== "row" && source?.kind === "element";
|
|
23
|
+
}
|
|
24
|
+
function holderOf(slot) {
|
|
25
|
+
if (!isListSlot(slot)) return {
|
|
26
|
+
shape: "one",
|
|
27
|
+
type: slot.type
|
|
28
|
+
};
|
|
29
|
+
const fields = listItemFieldsOf(slot);
|
|
30
|
+
if (fields === void 0) return {
|
|
31
|
+
shape: "list",
|
|
32
|
+
item: listItemTypeOf(slot)
|
|
33
|
+
};
|
|
34
|
+
const bound = slot.source?.kind === "home" ? slot.source.key : void 0;
|
|
35
|
+
return {
|
|
36
|
+
shape: "objects",
|
|
37
|
+
...bound === void 0 ? {} : { bound },
|
|
38
|
+
bindsElement: Object.values(fields).some(bindsElement)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function isFactBound(holder) {
|
|
42
|
+
return holder?.shape === "objects" && holder.bound !== void 0;
|
|
43
|
+
}
|
|
44
|
+
function holderLabel(holder) {
|
|
45
|
+
if (holder.shape === "one") return String(holder.type);
|
|
46
|
+
if (holder.shape === "list") return `list<${String(holder.item)}>`;
|
|
47
|
+
return "objects";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { bindsElement, holderLabel, holderOf, isFactBound, isListSlot, listItemTypeOf, poolOfKind };
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { isValueKind } from "../../template-contracts/dist/value-contracts.js";
|
|
2
|
+
import { plannerForField } from "../../template-contracts/dist/row-planners.js";
|
|
3
|
+
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
4
|
+
import "./row-planners.js";
|
|
5
|
+
import { bindsElement, holderLabel, holderOf, isFactBound } from "./holder.js";
|
|
6
|
+
import { impliedVerbOf, pickIsUnique, readFillVerb, verbRunsOn, writesElements } from "./verbs.js";
|
|
7
|
+
|
|
8
|
+
//#region ../../internal/fill-vocabulary/dist/resolved-decision.js
|
|
9
|
+
function producedSlotOf(slots, id) {
|
|
10
|
+
if (Object.hasOwn(slots, id)) return slots[id];
|
|
11
|
+
const dot = id.indexOf(".");
|
|
12
|
+
if (dot <= 0) return void 0;
|
|
13
|
+
const object = slots[id.slice(0, dot)];
|
|
14
|
+
const fields = object?.type === "object" ? object.fields : void 0;
|
|
15
|
+
const field = id.slice(dot + 1);
|
|
16
|
+
return fields !== void 0 && Object.hasOwn(fields, field) ? fields[field] : void 0;
|
|
17
|
+
}
|
|
18
|
+
function declaredCountOf(raw) {
|
|
19
|
+
if (typeof raw === "number") return raw;
|
|
20
|
+
if (raw === null || typeof raw !== "object") return void 0;
|
|
21
|
+
const { min, max } = raw;
|
|
22
|
+
return {
|
|
23
|
+
...typeof min === "number" ? { min } : {},
|
|
24
|
+
...typeof max === "number" ? { max } : {}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function capHolderOf(slot) {
|
|
28
|
+
if (isValueKind(slot.type) || slot.type === "list" && isValueKind(slot.element?.type)) return null;
|
|
29
|
+
if (listItemFieldsOf(slot) !== void 0) return null;
|
|
30
|
+
const planner = plannerForField(slot);
|
|
31
|
+
if (planner === "text") return {
|
|
32
|
+
holder: slot,
|
|
33
|
+
suffix: ""
|
|
34
|
+
};
|
|
35
|
+
if (planner === "list") return {
|
|
36
|
+
holder: slot.element ?? {},
|
|
37
|
+
suffix: "'s element"
|
|
38
|
+
};
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
function effectiveCap(fillCap, slot) {
|
|
42
|
+
if (typeof fillCap === "number") return fillCap;
|
|
43
|
+
return capHolderOf(slot)?.holder.cap;
|
|
44
|
+
}
|
|
45
|
+
const HONOURED = {
|
|
46
|
+
write: {
|
|
47
|
+
one: /* @__PURE__ */ new Set([
|
|
48
|
+
"brief",
|
|
49
|
+
"reads",
|
|
50
|
+
"cap",
|
|
51
|
+
"none"
|
|
52
|
+
]),
|
|
53
|
+
list: /* @__PURE__ */ new Set([
|
|
54
|
+
"brief",
|
|
55
|
+
"reads",
|
|
56
|
+
"count",
|
|
57
|
+
"cap",
|
|
58
|
+
"none"
|
|
59
|
+
]),
|
|
60
|
+
objects: /* @__PURE__ */ new Set([
|
|
61
|
+
"brief",
|
|
62
|
+
"reads",
|
|
63
|
+
"count",
|
|
64
|
+
"cap",
|
|
65
|
+
"none"
|
|
66
|
+
])
|
|
67
|
+
},
|
|
68
|
+
pick: {
|
|
69
|
+
one: /* @__PURE__ */ new Set([
|
|
70
|
+
"brief",
|
|
71
|
+
"reads",
|
|
72
|
+
"none"
|
|
73
|
+
]),
|
|
74
|
+
list: /* @__PURE__ */ new Set([
|
|
75
|
+
"brief",
|
|
76
|
+
"reads",
|
|
77
|
+
"count",
|
|
78
|
+
"none"
|
|
79
|
+
]),
|
|
80
|
+
objects: /* @__PURE__ */ new Set([
|
|
81
|
+
"brief",
|
|
82
|
+
"reads",
|
|
83
|
+
"count",
|
|
84
|
+
"none"
|
|
85
|
+
])
|
|
86
|
+
},
|
|
87
|
+
find: {
|
|
88
|
+
one: /* @__PURE__ */ new Set([
|
|
89
|
+
"brief",
|
|
90
|
+
"reads",
|
|
91
|
+
"none"
|
|
92
|
+
]),
|
|
93
|
+
list: /* @__PURE__ */ new Set([
|
|
94
|
+
"brief",
|
|
95
|
+
"reads",
|
|
96
|
+
"count",
|
|
97
|
+
"none"
|
|
98
|
+
])
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const HONOURED_BOUND = /* @__PURE__ */ new Set(["reads"]);
|
|
102
|
+
function writesCharacters(holder) {
|
|
103
|
+
if (holder.shape === "one") return holder.type !== "number";
|
|
104
|
+
if (holder.shape === "objects") return holder.bindsElement;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function honouredOn(verb, holder) {
|
|
108
|
+
if (verb === void 0) return holder.shape === "objects" && holder.bound !== void 0 ? HONOURED_BOUND : void 0;
|
|
109
|
+
const base = HONOURED[verb][holder.shape];
|
|
110
|
+
if (base === void 0 || verb !== "write" || writesCharacters(holder)) return base;
|
|
111
|
+
const narrowed = new Set(base);
|
|
112
|
+
narrowed.delete("cap");
|
|
113
|
+
return narrowed;
|
|
114
|
+
}
|
|
115
|
+
const HONOURED_BY_PLANNER = {
|
|
116
|
+
text: /* @__PURE__ */ new Set([
|
|
117
|
+
"brief",
|
|
118
|
+
"reads",
|
|
119
|
+
"cap",
|
|
120
|
+
"none"
|
|
121
|
+
]),
|
|
122
|
+
list: /* @__PURE__ */ new Set([
|
|
123
|
+
"brief",
|
|
124
|
+
"reads",
|
|
125
|
+
"count",
|
|
126
|
+
"cap",
|
|
127
|
+
"none"
|
|
128
|
+
]),
|
|
129
|
+
select: /* @__PURE__ */ new Set([
|
|
130
|
+
"brief",
|
|
131
|
+
"reads",
|
|
132
|
+
"count",
|
|
133
|
+
"none"
|
|
134
|
+
]),
|
|
135
|
+
choice: /* @__PURE__ */ new Set([
|
|
136
|
+
"brief",
|
|
137
|
+
"reads",
|
|
138
|
+
"none"
|
|
139
|
+
]),
|
|
140
|
+
assets: /* @__PURE__ */ new Set([
|
|
141
|
+
"brief",
|
|
142
|
+
"reads",
|
|
143
|
+
"count",
|
|
144
|
+
"none"
|
|
145
|
+
]),
|
|
146
|
+
image: /* @__PURE__ */ new Set([
|
|
147
|
+
"brief",
|
|
148
|
+
"reads",
|
|
149
|
+
"none"
|
|
150
|
+
]),
|
|
151
|
+
video: /* @__PURE__ */ new Set([
|
|
152
|
+
"brief",
|
|
153
|
+
"reads",
|
|
154
|
+
"none"
|
|
155
|
+
]),
|
|
156
|
+
tour: /* @__PURE__ */ new Set([
|
|
157
|
+
"brief",
|
|
158
|
+
"reads",
|
|
159
|
+
"none"
|
|
160
|
+
]),
|
|
161
|
+
document: /* @__PURE__ */ new Set([
|
|
162
|
+
"brief",
|
|
163
|
+
"reads",
|
|
164
|
+
"none"
|
|
165
|
+
]),
|
|
166
|
+
media: /* @__PURE__ */ new Set([
|
|
167
|
+
"brief",
|
|
168
|
+
"reads",
|
|
169
|
+
"none"
|
|
170
|
+
])
|
|
171
|
+
};
|
|
172
|
+
const HONOURED_BY_DISPLAY = /* @__PURE__ */ new Set(["reads"]);
|
|
173
|
+
function whyNot(option, subject, bound) {
|
|
174
|
+
if (bound) return option === "none" ? "a fact-bound list has no discretion to abstain — its rows come from the facts it is bound to. Drop `none`, or give a row field its own." : "its rows are the facts' it is bound to — only its row fields are filled. Drop it, or declare it on a row field.";
|
|
175
|
+
return `${subject} ${{
|
|
176
|
+
brief: "takes no prose of its own",
|
|
177
|
+
reads: "shows the model nothing",
|
|
178
|
+
count: "counts nothing — it holds one value, or rows it does not originate",
|
|
179
|
+
cap: "writes no characters of its own",
|
|
180
|
+
none: "has no discretion to abstain"
|
|
181
|
+
}[option]}. Drop it.`;
|
|
182
|
+
}
|
|
183
|
+
function readsOf(raw) {
|
|
184
|
+
return Array.isArray(raw) ? [...raw] : [];
|
|
185
|
+
}
|
|
186
|
+
function declared(node, option) {
|
|
187
|
+
return node[option] !== void 0;
|
|
188
|
+
}
|
|
189
|
+
const OPTIONS = [
|
|
190
|
+
"brief",
|
|
191
|
+
"reads",
|
|
192
|
+
"count",
|
|
193
|
+
"cap",
|
|
194
|
+
"none"
|
|
195
|
+
];
|
|
196
|
+
function refusalsOf(node, honoured, label, where, subject, bound = false) {
|
|
197
|
+
const out = [];
|
|
198
|
+
for (const option of OPTIONS) {
|
|
199
|
+
if (!declared(node, option) || honoured.has(option)) continue;
|
|
200
|
+
out.push({
|
|
201
|
+
option,
|
|
202
|
+
where,
|
|
203
|
+
message: `${label} declares \`${option}\`, but ${whyNot(option, subject, bound)}`
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
function noneOf(node, label) {
|
|
209
|
+
if (node.none === void 0) return false;
|
|
210
|
+
if (node.none === true) return true;
|
|
211
|
+
throw new Error(`${label}: \`none\` is \`true\` or absent, never ${JSON.stringify(node.none)}`);
|
|
212
|
+
}
|
|
213
|
+
const PICKING_PLANNERS = /* @__PURE__ */ new Set([
|
|
214
|
+
"select",
|
|
215
|
+
"choice",
|
|
216
|
+
"assets",
|
|
217
|
+
"image",
|
|
218
|
+
"video",
|
|
219
|
+
"tour",
|
|
220
|
+
"document",
|
|
221
|
+
"media"
|
|
222
|
+
]);
|
|
223
|
+
function abstainsByVerdict(verb, planner) {
|
|
224
|
+
if (verb !== void 0) return verb === "pick";
|
|
225
|
+
return planner !== void 0 && PICKING_PLANNERS.has(planner);
|
|
226
|
+
}
|
|
227
|
+
function findsPlaces(verb, holders) {
|
|
228
|
+
return verb === "find" && holders.length > 0 && holders.every((holder) => holder !== void 0 && holdsPlaces(holder));
|
|
229
|
+
}
|
|
230
|
+
function holdsPlaces(holder) {
|
|
231
|
+
return holder.shape === "one" && holder.type === "poi" || holder.shape === "list" && holder.item === "poi";
|
|
232
|
+
}
|
|
233
|
+
function writtenKindOfDeclared(declared) {
|
|
234
|
+
if (declared === void 0 || !isValueKind(declared.type)) return void 0;
|
|
235
|
+
return typeof declared.accepts === "string" ? {
|
|
236
|
+
kind: declared.type,
|
|
237
|
+
accepts: declared.accepts
|
|
238
|
+
} : { kind: declared.type };
|
|
239
|
+
}
|
|
240
|
+
function writtenKindOfTarget(verb, holder, slot) {
|
|
241
|
+
if (verb !== "write") return void 0;
|
|
242
|
+
if (holder.shape === "one") return writtenKindOfDeclared(slot);
|
|
243
|
+
if (holder.shape === "list") return writtenKindOfDeclared(slot.element);
|
|
244
|
+
if (writesElements(verb, holder)) return writtenKindOfDeclared(Object.values(listItemFieldsOf(slot) ?? {}).find(bindsElement));
|
|
245
|
+
}
|
|
246
|
+
function writtenKindOfField(field, planner) {
|
|
247
|
+
if (planner === "text") return writtenKindOfDeclared(field);
|
|
248
|
+
if (planner === "list") return writtenKindOfDeclared(field.element);
|
|
249
|
+
}
|
|
250
|
+
function normalizedVerbOf(decision, slots) {
|
|
251
|
+
if (decision.verb !== void 0) return readFillVerb(decision.verb);
|
|
252
|
+
if (decision.kind === "display") return "pick";
|
|
253
|
+
const planned = decision.fields !== null && typeof decision.fields === "object" ? Object.keys(decision.fields) : [];
|
|
254
|
+
for (const id of decision.produces) {
|
|
255
|
+
const slot = producedSlotOf(slots, id);
|
|
256
|
+
const verb = slot === void 0 ? void 0 : impliedVerbOf(slot, planned);
|
|
257
|
+
if (verb !== void 0) return verb;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function honouredFor(base, written) {
|
|
261
|
+
if (written === void 0) return base;
|
|
262
|
+
const narrowed = new Set(base);
|
|
263
|
+
narrowed.delete("cap");
|
|
264
|
+
return narrowed;
|
|
265
|
+
}
|
|
266
|
+
function resolveDecision(decision, slots) {
|
|
267
|
+
const fieldWires = decision.fields !== null && typeof decision.fields === "object" ? decision.fields : {};
|
|
268
|
+
const planned = Object.keys(fieldWires);
|
|
269
|
+
const refused = [];
|
|
270
|
+
const label = `fill "${decision.id}"`;
|
|
271
|
+
const declaresVerb = decision.verb !== void 0;
|
|
272
|
+
const verb = normalizedVerbOf(decision, slots);
|
|
273
|
+
if (declaresVerb && decision.count !== void 0) refused.push({
|
|
274
|
+
option: "count",
|
|
275
|
+
where: decision.produces[0] ?? "",
|
|
276
|
+
message: `${label} declares \`count\` beside the verb \`${String(decision.verb)}\`, but a fill verb takes no count — the list's own \`min\` and \`max\` bound how many items it fills. Drop it.`
|
|
277
|
+
});
|
|
278
|
+
let mayAbstain = noneOf(decision, label);
|
|
279
|
+
const targets = decision.produces.map((slotId) => {
|
|
280
|
+
const slot = producedSlotOf(slots, slotId);
|
|
281
|
+
if (slot === void 0) return {
|
|
282
|
+
slot: slotId,
|
|
283
|
+
holder: void 0,
|
|
284
|
+
runs: false
|
|
285
|
+
};
|
|
286
|
+
const holder = holderOf(slot);
|
|
287
|
+
const honouredHere = (verb === void 0 ? !declaresVerb && isFactBound(holder) : verbRunsOn(verb, slot, planned)) ? honouredOn(verb, holder) : void 0;
|
|
288
|
+
if (honouredHere === void 0) return {
|
|
289
|
+
slot: slotId,
|
|
290
|
+
holder,
|
|
291
|
+
runs: false
|
|
292
|
+
};
|
|
293
|
+
const writtenKind = writtenKindOfTarget(verb, holder, slot);
|
|
294
|
+
const honoured = honouredFor(honouredHere, writtenKind);
|
|
295
|
+
const judged = declaresVerb ? {
|
|
296
|
+
...decision,
|
|
297
|
+
count: void 0
|
|
298
|
+
} : decision;
|
|
299
|
+
const runsAs = `${verb ?? "no verb"} of ${holderLabel(holder)}`;
|
|
300
|
+
const subject = writtenKind === void 0 || holder.shape !== "objects" ? `"${slotId}" (${runsAs})` : `"${slotId}" (${runsAs}, ${writtenKind.kind})`;
|
|
301
|
+
refused.push(...refusalsOf(judged, honoured, label, slotId, subject, verb === void 0));
|
|
302
|
+
if (!honoured.has("none")) mayAbstain = false;
|
|
303
|
+
return {
|
|
304
|
+
slot: slotId,
|
|
305
|
+
holder,
|
|
306
|
+
runs: true,
|
|
307
|
+
...writtenKind === void 0 ? {} : { writtenKind },
|
|
308
|
+
...countEntry(honoured, declaresVerb, decision, slot),
|
|
309
|
+
...honoured.has("cap") ? capEntry(decision.cap, slot, writesElements(verb, holder)) : {}
|
|
310
|
+
};
|
|
311
|
+
});
|
|
312
|
+
if (decision.kind === "display") {
|
|
313
|
+
refused.push(...refusalsOf(decision, HONOURED_BY_DISPLAY, label, "display", "a display verdict, whose entries carry their own prose,"));
|
|
314
|
+
mayAbstain = false;
|
|
315
|
+
}
|
|
316
|
+
const rowSlot = decision.produces.length === 1 ? producedSlotOf(slots, decision.produces[0]) : void 0;
|
|
317
|
+
const itemFields = rowSlot === void 0 ? void 0 : listItemFieldsOf(rowSlot);
|
|
318
|
+
const fields = planned.map((name) => {
|
|
319
|
+
const wire = fieldWires[name] ?? {};
|
|
320
|
+
const fieldSlot = itemFields?.[name];
|
|
321
|
+
const planner = fieldSlot === void 0 ? void 0 : plannerForField(fieldSlot);
|
|
322
|
+
const fieldVerb = readFillVerb(wire.verb);
|
|
323
|
+
const base = {
|
|
324
|
+
name,
|
|
325
|
+
planner,
|
|
326
|
+
verb: fieldVerb,
|
|
327
|
+
unique: pickIsUnique(fieldVerb, wire),
|
|
328
|
+
...wire.of === void 0 ? {} : { of: wire.of },
|
|
329
|
+
brief: typeof wire.brief === "string" ? wire.brief : "",
|
|
330
|
+
reads: readsOf(wire.reads),
|
|
331
|
+
mayAbstain: noneOf(wire, `${label} field "${name}"`) || abstainsByVerdict(fieldVerb)
|
|
332
|
+
};
|
|
333
|
+
if (fieldSlot === void 0 || planner === void 0) return base;
|
|
334
|
+
const writtenKind = writtenKindOfField(fieldSlot, planner);
|
|
335
|
+
const honoured = honouredFor(HONOURED_BY_PLANNER[planner], writtenKind);
|
|
336
|
+
const where = `${decision.produces[0]}.${name}`;
|
|
337
|
+
refused.push(...refusalsOf(wire, honoured, `${label} field "${name}"`, where, `row field "${where}" (${planner})`));
|
|
338
|
+
const declaredCount = wire.verb !== void 0 ? boundsOf(fieldSlot) : declaredCountOf(wire.count);
|
|
339
|
+
return {
|
|
340
|
+
...base,
|
|
341
|
+
...writtenKind === void 0 ? {} : { writtenKind },
|
|
342
|
+
mayAbstain: abstainsByVerdict(fieldVerb, planner) || base.mayAbstain && honoured.has("none"),
|
|
343
|
+
...honoured.has("count") ? { count: {
|
|
344
|
+
declared: declaredCount,
|
|
345
|
+
holderMax: fieldSlot.max
|
|
346
|
+
} } : {},
|
|
347
|
+
...honoured.has("cap") ? capEntry(wire.cap, fieldSlot) : {}
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
return {
|
|
351
|
+
id: decision.id,
|
|
352
|
+
kind: decision.kind,
|
|
353
|
+
verb,
|
|
354
|
+
declaresVerb,
|
|
355
|
+
of: decision.of,
|
|
356
|
+
unique: pickIsUnique(verb, decision),
|
|
357
|
+
produces: [...decision.produces],
|
|
358
|
+
brief: typeof decision.brief === "string" ? decision.brief : "",
|
|
359
|
+
mayAbstain: decision.kind === "display" ? false : abstainsByVerdict(verb) || findsPlaces(verb, targets.map((target) => target.holder)) || mayAbstain,
|
|
360
|
+
reads: readsOf(decision.reads),
|
|
361
|
+
targets,
|
|
362
|
+
fields,
|
|
363
|
+
refused
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function boundsOf(slot) {
|
|
367
|
+
return {
|
|
368
|
+
...typeof slot.min === "number" ? { min: slot.min } : {},
|
|
369
|
+
...typeof slot.max === "number" ? { max: slot.max } : {}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
function countEntry(honoured, declaresVerb, decision, slot) {
|
|
373
|
+
if (!honoured.has("count")) return {};
|
|
374
|
+
return { count: {
|
|
375
|
+
declared: declaresVerb ? boundsOf(slot) : declaredCountOf(decision.count),
|
|
376
|
+
holderMax: slot.max
|
|
377
|
+
} };
|
|
378
|
+
}
|
|
379
|
+
function capEntry(fillCap, slot, elements = false) {
|
|
380
|
+
if (elements) {
|
|
381
|
+
if (typeof fillCap === "number") return { cap: fillCap };
|
|
382
|
+
const bound = Object.values(listItemFieldsOf(slot) ?? {}).find(bindsElement);
|
|
383
|
+
return typeof bound?.cap === "number" ? { cap: bound.cap } : {};
|
|
384
|
+
}
|
|
385
|
+
const cap = effectiveCap(fillCap, slot);
|
|
386
|
+
return cap === void 0 ? {} : { cap };
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
//#endregion
|
|
390
|
+
export { HONOURED, HONOURED_BOUND, HONOURED_BY_PLANNER, capHolderOf, effectiveCap, honouredOn, normalizedVerbOf, producedSlotOf, resolveDecision };
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
const POOLING_PRIMITIVES = [
|
|
3
|
-
"image",
|
|
4
|
-
"video",
|
|
5
|
-
"tour",
|
|
6
|
-
"document"
|
|
7
|
-
];
|
|
8
|
-
function poolingPrimitiveOf(field) {
|
|
9
|
-
return POOLING_PRIMITIVES.includes(field.type ?? "") ? field.type : void 0;
|
|
10
|
-
}
|
|
11
|
-
function plannerForField(field) {
|
|
12
|
-
if (field.type === "list") {
|
|
13
|
-
const element = field.element?.type;
|
|
14
|
-
if (element === "select") return "select";
|
|
15
|
-
if (element === "poi") return void 0;
|
|
16
|
-
if (poolingPrimitiveOf({ type: element }) !== void 0) return "assets";
|
|
17
|
-
return "list";
|
|
18
|
-
}
|
|
19
|
-
if (field.type === "text") return "text";
|
|
20
|
-
if (field.type === "select") return "choice";
|
|
21
|
-
return poolingPrimitiveOf(field);
|
|
22
|
-
}
|
|
1
|
+
import { POOLING_PRIMITIVES, plannerForField, poolingPrimitiveOf } from "../../template-contracts/dist/row-planners.js";
|
|
23
2
|
|
|
24
|
-
//#endregion
|
|
25
3
|
export { POOLING_PRIMITIVES, plannerForField, poolingPrimitiveOf };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region ../../internal/fill-vocabulary/dist/row-reads.js
|
|
2
2
|
function isRowRead(entry) {
|
|
3
|
-
if (entry === null || typeof entry !== "object") return false;
|
|
3
|
+
if (entry === null || typeof entry !== "object" || "slot" in entry) return false;
|
|
4
4
|
const { kind, field } = entry;
|
|
5
5
|
return kind === "row" && typeof field === "string" && field !== "";
|
|
6
6
|
}
|