@homepages/concrete 8.0.0 → 9.1.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 +1005 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +64 -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-BOYbgBnP.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/check/stages/workspace.js +2 -0
- package/dist/cli/check/template-key.js +16 -0
- 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 +260 -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 +250 -46
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +361 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +25 -18
- package/dist/packages/internal/fill-bake/dist/index.js +9 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +113 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +38 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +174 -0
- package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +363 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +60 -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 +226 -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 +37 -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 +245 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +34 -14
- 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 +21 -0
- package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
- 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 -2
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +2 -36
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -21
- 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 +9 -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 +6 -17
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +80 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +77 -18
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +89 -95
- 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 +39 -23
- package/dist/packages/internal/source-resolution/dist/index.js +113 -73
- 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 +81 -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 +93 -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 +93 -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 +240 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +176 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +270 -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 +127 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +41 -5
- 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 +233 -405
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +331 -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 +139 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +95 -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 +25 -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 +29 -25
- 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/fill-vocabulary/dist/row-reads.js +0 -15
- 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/group-contract.js +0 -19
- 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,174 @@
|
|
|
1
|
+
import { normalizeAddressValue } from "../../template-contracts/dist/address-value.js";
|
|
2
|
+
import { storedAsRefs } from "../../template-contracts/dist/registry-facts.js";
|
|
3
|
+
import { attributedRows, elementIdentity } from "../../template-contracts/dist/ref-locate.js";
|
|
4
|
+
import { rowIdentityKey } from "../../template-contracts/dist/table-members.js";
|
|
5
|
+
import { elementRowKeys, memberSourceOf, rowMemberSources } from "../../template-contracts/dist/row-sources.js";
|
|
6
|
+
import { projectTableRows, readRowMember } from "../../source-resolution/dist/index.js";
|
|
7
|
+
|
|
8
|
+
//#region ../../internal/fill-bake/dist/list-grammar.js
|
|
9
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
10
|
+
function isGrammarList(def) {
|
|
11
|
+
return def.type === "list" && def.element !== void 0;
|
|
12
|
+
}
|
|
13
|
+
function objectElementFields(def) {
|
|
14
|
+
return def.element?.type === "object" ? def.element.fields ?? {} : void 0;
|
|
15
|
+
}
|
|
16
|
+
function decisionProducing(scope, path) {
|
|
17
|
+
return scope.decisions?.find((decision) => decision.produces?.includes(path) === true);
|
|
18
|
+
}
|
|
19
|
+
function rowIdentity(element, table) {
|
|
20
|
+
if (typeof element === "string") return element === "" ? null : element;
|
|
21
|
+
if (table !== null && isRecord(element)) {
|
|
22
|
+
const id = element[rowIdentityKey(table)];
|
|
23
|
+
if (typeof id === "string" && id !== "") return id;
|
|
24
|
+
}
|
|
25
|
+
return elementIdentity(element, table);
|
|
26
|
+
}
|
|
27
|
+
function computedRow(element, tables, facts) {
|
|
28
|
+
const [first] = tables;
|
|
29
|
+
if (first === void 0) return {
|
|
30
|
+
table: null,
|
|
31
|
+
id: rowIdentity(element, null),
|
|
32
|
+
element
|
|
33
|
+
};
|
|
34
|
+
if (tables.length > 1) for (const table of tables) {
|
|
35
|
+
const id = rowIdentity(element, table);
|
|
36
|
+
if (id !== null && attributedRows(facts, [table]).some((row) => row.id === id)) return {
|
|
37
|
+
table,
|
|
38
|
+
id
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
table: first,
|
|
43
|
+
id: rowIdentity(element, first)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function registryReadingOf(table) {
|
|
47
|
+
return {
|
|
48
|
+
table: table.table,
|
|
49
|
+
reading: "registry"
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function readResolvedRowMember(row, member, facts) {
|
|
53
|
+
if (row.table !== null) return row.id === null ? null : storedAsRefs(readRowMember(row.table, row.id, member, facts));
|
|
54
|
+
return isRecord(row.element) ? row.element[member] ?? null : null;
|
|
55
|
+
}
|
|
56
|
+
function fnv1a(text) {
|
|
57
|
+
let hash = 2166136261;
|
|
58
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
59
|
+
hash ^= text.charCodeAt(i);
|
|
60
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
61
|
+
}
|
|
62
|
+
return hash.toString(16).padStart(8, "0");
|
|
63
|
+
}
|
|
64
|
+
function contentIdentities(elements) {
|
|
65
|
+
const seen = /* @__PURE__ */ new Map();
|
|
66
|
+
return elements.map((element) => {
|
|
67
|
+
const base = elementIdentity(element, null) ?? `el_${fnv1a(JSON.stringify(element) ?? "undefined")}`;
|
|
68
|
+
const count = seen.get(base) ?? 0;
|
|
69
|
+
seen.set(base, count + 1);
|
|
70
|
+
return count === 0 ? base : `${base}_${String(count)}`;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function projectElements(elements, projection) {
|
|
74
|
+
const { element, table, facts, computes } = projection;
|
|
75
|
+
const fields = element.type === "object" ? element.fields ?? {} : void 0;
|
|
76
|
+
if (table !== null) {
|
|
77
|
+
if (fields === void 0) return elements.map((identified) => identified.id);
|
|
78
|
+
const members = rowMemberSources(fields);
|
|
79
|
+
return elements.flatMap(({ element: held, id }) => {
|
|
80
|
+
const rowId = typeof held === "string" ? held : id;
|
|
81
|
+
const [projected] = storedAsRefs(projectTableRows(table, facts, fields, computes, [rowId]));
|
|
82
|
+
if (projected === void 0) return [];
|
|
83
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
84
|
+
const nested = nestedItemOf(field);
|
|
85
|
+
const member = members[key];
|
|
86
|
+
if (nested !== void 0 && member !== void 0 && readsElementRows(nested)) projected[key] = storedAsRefs(readRowMember(registryReadingOf(table), rowId, member, facts));
|
|
87
|
+
}
|
|
88
|
+
return [withNestedLists({
|
|
89
|
+
...projected,
|
|
90
|
+
id
|
|
91
|
+
}, fields, facts)];
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (element.type === "row") return elements.map((identified) => identified.id);
|
|
95
|
+
if (fields === void 0) return elements.map((identified) => identified.element);
|
|
96
|
+
return elements.map((identified) => withNestedLists(projectContentItem(identified, fields, computes), fields, facts));
|
|
97
|
+
}
|
|
98
|
+
function nestedItemOf(def) {
|
|
99
|
+
return isGrammarList(def) && def.element?.type === "object" ? def.element : void 0;
|
|
100
|
+
}
|
|
101
|
+
function readsElementRows(declaration) {
|
|
102
|
+
const fields = declaration.fields ?? {};
|
|
103
|
+
return elementRowKeys(fields).length > 0 || Object.keys(rowMemberSources(fields)).length > 0;
|
|
104
|
+
}
|
|
105
|
+
function readNestedMember(row, member, nestedItem, facts) {
|
|
106
|
+
if (row.table !== null && row.id !== null && readsElementRows(nestedItem)) return storedAsRefs(readRowMember(registryReadingOf(row.table), row.id, member, facts));
|
|
107
|
+
return readResolvedRowMember(row, member, facts);
|
|
108
|
+
}
|
|
109
|
+
function projectNestedList(value, nestedItem, facts) {
|
|
110
|
+
if (!Array.isArray(value)) return value;
|
|
111
|
+
const ids = contentIdentities(value);
|
|
112
|
+
return projectElements(value.map((element, i) => ({
|
|
113
|
+
element,
|
|
114
|
+
id: ids[i]
|
|
115
|
+
})), {
|
|
116
|
+
element: nestedItem,
|
|
117
|
+
table: null,
|
|
118
|
+
facts,
|
|
119
|
+
computes: {}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function withNestedLists(projected, fields, facts) {
|
|
123
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
124
|
+
const nested = nestedItemOf(field);
|
|
125
|
+
if (nested !== void 0 && Object.hasOwn(projected, key)) projected[key] = projectNestedList(projected[key], nested, facts);
|
|
126
|
+
}
|
|
127
|
+
return projected;
|
|
128
|
+
}
|
|
129
|
+
function projectContentItem({ element, id, storedItem }, fields, computes) {
|
|
130
|
+
const elementRows = new Set(elementRowKeys(fields));
|
|
131
|
+
const readMember = (member) => isRecord(element) ? element[member] ?? null : null;
|
|
132
|
+
const out = { id };
|
|
133
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
134
|
+
if (elementRows.has(key)) {
|
|
135
|
+
out[key] = id;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (isRecord(field.source) && field.source["kind"] === "element") {
|
|
139
|
+
out[key] = element;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const member = memberSourceOf(field.source);
|
|
143
|
+
if (member !== null && elementRows.has(member.slot)) out[key] = readMember(member.field);
|
|
144
|
+
}
|
|
145
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
146
|
+
const member = memberSourceOf(field.source);
|
|
147
|
+
if (member === null || fields[member.slot]?.type !== "address") continue;
|
|
148
|
+
const address = normalizeAddressValue(Object.hasOwn(out, member.slot) ? out[member.slot] : storedItem?.[member.slot]);
|
|
149
|
+
out[key] = isRecord(address) ? address[member.field] ?? null : null;
|
|
150
|
+
}
|
|
151
|
+
for (const [key, compute] of Object.entries(computes)) out[key] = compute(readMember, element);
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
function storedElements(stored, fields, table) {
|
|
155
|
+
if (!Array.isArray(stored)) return [];
|
|
156
|
+
const elementRows = elementRowKeys(fields);
|
|
157
|
+
const elementField = Object.entries(fields).find(([, field]) => isRecord(field.source) && field.source["kind"] === "element" && field.type !== "row")?.[0];
|
|
158
|
+
return stored.flatMap((storedItem) => {
|
|
159
|
+
const id = elementIdentity(storedItem, table);
|
|
160
|
+
if (id === null || !isRecord(storedItem)) return [];
|
|
161
|
+
if (table !== null) return [{
|
|
162
|
+
element: elementRows.map((key) => storedItem[key]).find((value) => typeof value === "string" && value !== "") ?? id,
|
|
163
|
+
id
|
|
164
|
+
}];
|
|
165
|
+
return [{
|
|
166
|
+
element: elementField !== void 0 ? storedItem[elementField] : elementRows.length > 0 ? id : void 0,
|
|
167
|
+
id,
|
|
168
|
+
storedItem
|
|
169
|
+
}];
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
//#endregion
|
|
174
|
+
export { computedRow, contentIdentities, decisionProducing, isGrammarList, nestedItemOf, objectElementFields, projectElements, projectNestedList, readNestedMember, readResolvedRowMember, readsElementRows, rowIdentity, storedElements };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./bake-property-ref.js";
|
|
@@ -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,363 @@
|
|
|
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 { 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 capHolderOf(slot) {
|
|
19
|
+
if (isValueKind(slot.type) || slot.type === "list" && isValueKind(slot.element?.type)) return null;
|
|
20
|
+
if (listItemFieldsOf(slot) !== void 0) return null;
|
|
21
|
+
const planner = plannerForField(slot);
|
|
22
|
+
if (planner === "text") return {
|
|
23
|
+
holder: slot,
|
|
24
|
+
suffix: ""
|
|
25
|
+
};
|
|
26
|
+
if (planner === "list") return {
|
|
27
|
+
holder: slot.element ?? {},
|
|
28
|
+
suffix: "'s element"
|
|
29
|
+
};
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
function effectiveCap(fillCap, slot) {
|
|
33
|
+
if (typeof fillCap === "number") return fillCap;
|
|
34
|
+
return capHolderOf(slot)?.holder.cap;
|
|
35
|
+
}
|
|
36
|
+
const HONOURED = {
|
|
37
|
+
write: {
|
|
38
|
+
one: /* @__PURE__ */ new Set([
|
|
39
|
+
"brief",
|
|
40
|
+
"reads",
|
|
41
|
+
"cap",
|
|
42
|
+
"none"
|
|
43
|
+
]),
|
|
44
|
+
list: /* @__PURE__ */ new Set([
|
|
45
|
+
"brief",
|
|
46
|
+
"reads",
|
|
47
|
+
"count",
|
|
48
|
+
"cap",
|
|
49
|
+
"none"
|
|
50
|
+
]),
|
|
51
|
+
objects: /* @__PURE__ */ new Set([
|
|
52
|
+
"brief",
|
|
53
|
+
"reads",
|
|
54
|
+
"count",
|
|
55
|
+
"cap",
|
|
56
|
+
"none"
|
|
57
|
+
])
|
|
58
|
+
},
|
|
59
|
+
pick: {
|
|
60
|
+
one: /* @__PURE__ */ new Set([
|
|
61
|
+
"brief",
|
|
62
|
+
"reads",
|
|
63
|
+
"none"
|
|
64
|
+
]),
|
|
65
|
+
list: /* @__PURE__ */ new Set([
|
|
66
|
+
"brief",
|
|
67
|
+
"reads",
|
|
68
|
+
"count",
|
|
69
|
+
"none"
|
|
70
|
+
]),
|
|
71
|
+
objects: /* @__PURE__ */ new Set([
|
|
72
|
+
"brief",
|
|
73
|
+
"reads",
|
|
74
|
+
"count",
|
|
75
|
+
"none"
|
|
76
|
+
])
|
|
77
|
+
},
|
|
78
|
+
find: {
|
|
79
|
+
one: /* @__PURE__ */ new Set([
|
|
80
|
+
"brief",
|
|
81
|
+
"reads",
|
|
82
|
+
"none"
|
|
83
|
+
]),
|
|
84
|
+
list: /* @__PURE__ */ new Set([
|
|
85
|
+
"brief",
|
|
86
|
+
"reads",
|
|
87
|
+
"count",
|
|
88
|
+
"none"
|
|
89
|
+
])
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const HONOURED_BOUND = /* @__PURE__ */ new Set(["reads"]);
|
|
93
|
+
function writesCharacters(holder) {
|
|
94
|
+
if (holder.shape === "one") return holder.type !== "number";
|
|
95
|
+
if (holder.shape === "objects") return holder.bindsElement;
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
function honouredOn(verb, holder) {
|
|
99
|
+
if (verb === void 0) return holder.shape === "objects" && holder.bound !== void 0 ? HONOURED_BOUND : void 0;
|
|
100
|
+
const base = HONOURED[verb][holder.shape];
|
|
101
|
+
if (base === void 0 || verb !== "write" || writesCharacters(holder)) return base;
|
|
102
|
+
const narrowed = new Set(base);
|
|
103
|
+
narrowed.delete("cap");
|
|
104
|
+
return narrowed;
|
|
105
|
+
}
|
|
106
|
+
const HONOURED_BY_PLANNER = {
|
|
107
|
+
text: /* @__PURE__ */ new Set([
|
|
108
|
+
"brief",
|
|
109
|
+
"reads",
|
|
110
|
+
"cap",
|
|
111
|
+
"none"
|
|
112
|
+
]),
|
|
113
|
+
list: /* @__PURE__ */ new Set([
|
|
114
|
+
"brief",
|
|
115
|
+
"reads",
|
|
116
|
+
"count",
|
|
117
|
+
"cap",
|
|
118
|
+
"none"
|
|
119
|
+
]),
|
|
120
|
+
select: /* @__PURE__ */ new Set([
|
|
121
|
+
"brief",
|
|
122
|
+
"reads",
|
|
123
|
+
"count",
|
|
124
|
+
"none"
|
|
125
|
+
]),
|
|
126
|
+
choice: /* @__PURE__ */ new Set([
|
|
127
|
+
"brief",
|
|
128
|
+
"reads",
|
|
129
|
+
"none"
|
|
130
|
+
]),
|
|
131
|
+
assets: /* @__PURE__ */ new Set([
|
|
132
|
+
"brief",
|
|
133
|
+
"reads",
|
|
134
|
+
"count",
|
|
135
|
+
"none"
|
|
136
|
+
]),
|
|
137
|
+
image: /* @__PURE__ */ new Set([
|
|
138
|
+
"brief",
|
|
139
|
+
"reads",
|
|
140
|
+
"none"
|
|
141
|
+
]),
|
|
142
|
+
video: /* @__PURE__ */ new Set([
|
|
143
|
+
"brief",
|
|
144
|
+
"reads",
|
|
145
|
+
"none"
|
|
146
|
+
]),
|
|
147
|
+
tour: /* @__PURE__ */ new Set([
|
|
148
|
+
"brief",
|
|
149
|
+
"reads",
|
|
150
|
+
"none"
|
|
151
|
+
]),
|
|
152
|
+
document: /* @__PURE__ */ new Set([
|
|
153
|
+
"brief",
|
|
154
|
+
"reads",
|
|
155
|
+
"none"
|
|
156
|
+
]),
|
|
157
|
+
media: /* @__PURE__ */ new Set([
|
|
158
|
+
"brief",
|
|
159
|
+
"reads",
|
|
160
|
+
"none"
|
|
161
|
+
])
|
|
162
|
+
};
|
|
163
|
+
const HONOURED_BY_DISPLAY = /* @__PURE__ */ new Set(["reads"]);
|
|
164
|
+
function whyNot(option, subject, bound) {
|
|
165
|
+
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.";
|
|
166
|
+
return `${subject} ${{
|
|
167
|
+
brief: "takes no prose of its own",
|
|
168
|
+
reads: "shows the model nothing",
|
|
169
|
+
count: "counts nothing — it holds one value, or rows it does not originate",
|
|
170
|
+
cap: "writes no characters of its own",
|
|
171
|
+
none: "has no discretion to abstain"
|
|
172
|
+
}[option]}. Drop it.`;
|
|
173
|
+
}
|
|
174
|
+
function readsOf(raw) {
|
|
175
|
+
return Array.isArray(raw) ? [...raw] : [];
|
|
176
|
+
}
|
|
177
|
+
function declared(node, option) {
|
|
178
|
+
return node[option] !== void 0;
|
|
179
|
+
}
|
|
180
|
+
const OPTIONS = [
|
|
181
|
+
"brief",
|
|
182
|
+
"reads",
|
|
183
|
+
"count",
|
|
184
|
+
"cap",
|
|
185
|
+
"none"
|
|
186
|
+
];
|
|
187
|
+
function refusalsOf(node, honoured, label, where, subject, bound = false) {
|
|
188
|
+
const out = [];
|
|
189
|
+
for (const option of OPTIONS) {
|
|
190
|
+
if (!declared(node, option) || honoured.has(option)) continue;
|
|
191
|
+
out.push({
|
|
192
|
+
option,
|
|
193
|
+
where,
|
|
194
|
+
message: `${label} declares \`${option}\`, but ${whyNot(option, subject, bound)}`
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return out;
|
|
198
|
+
}
|
|
199
|
+
function noneOf(node, label) {
|
|
200
|
+
if (node.none === void 0) return false;
|
|
201
|
+
if (node.none === true) return true;
|
|
202
|
+
throw new Error(`${label}: \`none\` is \`true\` or absent, never ${JSON.stringify(node.none)}`);
|
|
203
|
+
}
|
|
204
|
+
function abstainsByVerdict(verb) {
|
|
205
|
+
return verb === "pick";
|
|
206
|
+
}
|
|
207
|
+
function findsPlaces(verb, holders) {
|
|
208
|
+
return verb === "find" && holders.length > 0 && holders.every((holder) => holder !== void 0 && holdsPlaces(holder));
|
|
209
|
+
}
|
|
210
|
+
function holdsPlaces(holder) {
|
|
211
|
+
return holder.shape === "one" && holder.type === "poi" || holder.shape === "list" && holder.item === "poi";
|
|
212
|
+
}
|
|
213
|
+
function writtenKindOfDeclared(declared) {
|
|
214
|
+
if (declared === void 0 || !isValueKind(declared.type)) return void 0;
|
|
215
|
+
return typeof declared.accepts === "string" ? {
|
|
216
|
+
kind: declared.type,
|
|
217
|
+
accepts: declared.accepts
|
|
218
|
+
} : { kind: declared.type };
|
|
219
|
+
}
|
|
220
|
+
function writtenKindOfTarget(verb, holder, slot) {
|
|
221
|
+
if (verb !== "write") return void 0;
|
|
222
|
+
if (holder.shape === "one") return writtenKindOfDeclared(slot);
|
|
223
|
+
if (holder.shape === "list") return writtenKindOfDeclared(slot.element);
|
|
224
|
+
if (writesElements(verb, holder)) return writtenKindOfDeclared(Object.values(listItemFieldsOf(slot) ?? {}).find(bindsElement));
|
|
225
|
+
}
|
|
226
|
+
function writtenKindOfField(field, planner) {
|
|
227
|
+
if (planner === "text") return writtenKindOfDeclared(field);
|
|
228
|
+
if (planner === "list") return writtenKindOfDeclared(field.element);
|
|
229
|
+
}
|
|
230
|
+
function normalizedVerbOf(decision) {
|
|
231
|
+
if (decision.verb !== void 0) return readFillVerb(decision.verb);
|
|
232
|
+
return decision.kind === "display" ? "pick" : void 0;
|
|
233
|
+
}
|
|
234
|
+
function honouredFor(base, written) {
|
|
235
|
+
if (written === void 0) return base;
|
|
236
|
+
const narrowed = new Set(base);
|
|
237
|
+
narrowed.delete("cap");
|
|
238
|
+
return narrowed;
|
|
239
|
+
}
|
|
240
|
+
function resolveDecision(decision, slots) {
|
|
241
|
+
const fieldWires = decision.fields !== null && typeof decision.fields === "object" ? decision.fields : {};
|
|
242
|
+
const planned = Object.keys(fieldWires);
|
|
243
|
+
const refused = [];
|
|
244
|
+
const label = `fill "${decision.id}"`;
|
|
245
|
+
const declaresVerb = decision.verb !== void 0;
|
|
246
|
+
const verb = normalizedVerbOf(decision);
|
|
247
|
+
if (declaresVerb && decision.count !== void 0) refused.push({
|
|
248
|
+
option: "count",
|
|
249
|
+
where: decision.produces[0] ?? "",
|
|
250
|
+
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.`
|
|
251
|
+
});
|
|
252
|
+
let mayAbstain = noneOf(decision, label);
|
|
253
|
+
const targets = decision.produces.map((slotId) => {
|
|
254
|
+
const slot = producedSlotOf(slots, slotId);
|
|
255
|
+
if (slot === void 0) return {
|
|
256
|
+
slot: slotId,
|
|
257
|
+
holder: void 0,
|
|
258
|
+
runs: false
|
|
259
|
+
};
|
|
260
|
+
const holder = holderOf(slot);
|
|
261
|
+
const honouredHere = (verb === void 0 ? !declaresVerb && isFactBound(holder) : verbRunsOn(verb, slot, planned)) ? honouredOn(verb, holder) : void 0;
|
|
262
|
+
if (honouredHere === void 0) return {
|
|
263
|
+
slot: slotId,
|
|
264
|
+
holder,
|
|
265
|
+
runs: false
|
|
266
|
+
};
|
|
267
|
+
const writtenKind = writtenKindOfTarget(verb, holder, slot);
|
|
268
|
+
const honoured = honouredFor(honouredHere, writtenKind);
|
|
269
|
+
const judged = declaresVerb ? {
|
|
270
|
+
...decision,
|
|
271
|
+
count: void 0
|
|
272
|
+
} : decision;
|
|
273
|
+
const runsAs = `${verb ?? "no verb"} of ${holderLabel(holder)}`;
|
|
274
|
+
const subject = writtenKind === void 0 || holder.shape !== "objects" ? `"${slotId}" (${runsAs})` : `"${slotId}" (${runsAs}, ${writtenKind.kind})`;
|
|
275
|
+
refused.push(...refusalsOf(judged, honoured, label, slotId, subject, verb === void 0));
|
|
276
|
+
if (!honoured.has("none")) mayAbstain = false;
|
|
277
|
+
return {
|
|
278
|
+
slot: slotId,
|
|
279
|
+
holder,
|
|
280
|
+
runs: true,
|
|
281
|
+
...writtenKind === void 0 ? {} : { writtenKind },
|
|
282
|
+
...countEntry(honoured, declaresVerb, slot),
|
|
283
|
+
...honoured.has("cap") ? capEntry(decision.cap, slot, writesElements(verb, holder)) : {}
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
if (decision.kind === "display") {
|
|
287
|
+
refused.push(...refusalsOf(decision, HONOURED_BY_DISPLAY, label, "display", "a display verdict, whose entries carry their own prose,"));
|
|
288
|
+
mayAbstain = false;
|
|
289
|
+
}
|
|
290
|
+
const rowSlot = decision.produces.length === 1 ? producedSlotOf(slots, decision.produces[0]) : void 0;
|
|
291
|
+
const itemFields = rowSlot === void 0 ? void 0 : listItemFieldsOf(rowSlot);
|
|
292
|
+
const fields = planned.map((name) => {
|
|
293
|
+
const wire = fieldWires[name] ?? {};
|
|
294
|
+
const fieldSlot = itemFields?.[name];
|
|
295
|
+
const planner = fieldSlot === void 0 ? void 0 : plannerForField(fieldSlot);
|
|
296
|
+
const fieldVerb = readFillVerb(wire.verb);
|
|
297
|
+
const base = {
|
|
298
|
+
name,
|
|
299
|
+
planner,
|
|
300
|
+
verb: fieldVerb,
|
|
301
|
+
unique: pickIsUnique(fieldVerb, wire),
|
|
302
|
+
...wire.of === void 0 ? {} : { of: wire.of },
|
|
303
|
+
brief: typeof wire.brief === "string" ? wire.brief : "",
|
|
304
|
+
reads: readsOf(wire.reads),
|
|
305
|
+
mayAbstain: noneOf(wire, `${label} field "${name}"`) || abstainsByVerdict(fieldVerb)
|
|
306
|
+
};
|
|
307
|
+
if (fieldSlot === void 0 || planner === void 0) return base;
|
|
308
|
+
const writtenKind = writtenKindOfField(fieldSlot, planner);
|
|
309
|
+
const honoured = honouredFor(HONOURED_BY_PLANNER[planner], writtenKind);
|
|
310
|
+
const where = `${decision.produces[0]}.${name}`;
|
|
311
|
+
refused.push(...refusalsOf(wire, honoured, `${label} field "${name}"`, where, `row field "${where}" (${planner})`));
|
|
312
|
+
return {
|
|
313
|
+
...base,
|
|
314
|
+
...writtenKind === void 0 ? {} : { writtenKind },
|
|
315
|
+
mayAbstain: abstainsByVerdict(fieldVerb) || base.mayAbstain && honoured.has("none"),
|
|
316
|
+
...honoured.has("count") ? { count: {
|
|
317
|
+
declared: boundsOf(fieldSlot),
|
|
318
|
+
holderMax: fieldSlot.max
|
|
319
|
+
} } : {},
|
|
320
|
+
...honoured.has("cap") ? capEntry(wire.cap, fieldSlot) : {}
|
|
321
|
+
};
|
|
322
|
+
});
|
|
323
|
+
return {
|
|
324
|
+
id: decision.id,
|
|
325
|
+
kind: decision.kind,
|
|
326
|
+
verb,
|
|
327
|
+
declaresVerb,
|
|
328
|
+
of: decision.of,
|
|
329
|
+
unique: pickIsUnique(verb, decision),
|
|
330
|
+
produces: [...decision.produces],
|
|
331
|
+
brief: typeof decision.brief === "string" ? decision.brief : "",
|
|
332
|
+
mayAbstain: decision.kind === "display" ? false : abstainsByVerdict(verb) || findsPlaces(verb, targets.map((target) => target.holder)) || mayAbstain,
|
|
333
|
+
reads: readsOf(decision.reads),
|
|
334
|
+
targets,
|
|
335
|
+
fields,
|
|
336
|
+
refused
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function boundsOf(slot) {
|
|
340
|
+
return {
|
|
341
|
+
...typeof slot.min === "number" ? { min: slot.min } : {},
|
|
342
|
+
...typeof slot.max === "number" ? { max: slot.max } : {}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function countEntry(honoured, declaresVerb, slot) {
|
|
346
|
+
if (!honoured.has("count")) return {};
|
|
347
|
+
return { count: {
|
|
348
|
+
declared: declaresVerb ? boundsOf(slot) : void 0,
|
|
349
|
+
holderMax: slot.max
|
|
350
|
+
} };
|
|
351
|
+
}
|
|
352
|
+
function capEntry(fillCap, slot, elements = false) {
|
|
353
|
+
if (elements) {
|
|
354
|
+
if (typeof fillCap === "number") return { cap: fillCap };
|
|
355
|
+
const bound = Object.values(listItemFieldsOf(slot) ?? {}).find(bindsElement);
|
|
356
|
+
return typeof bound?.cap === "number" ? { cap: bound.cap } : {};
|
|
357
|
+
}
|
|
358
|
+
const cap = effectiveCap(fillCap, slot);
|
|
359
|
+
return cap === void 0 ? {} : { cap };
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
//#endregion
|
|
363
|
+
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 };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FINDABLE_KINDS, isFindableKind } from "../../template-contracts/dist/findable.js";
|
|
2
|
+
import { isValueKind } from "../../template-contracts/dist/value-contracts.js";
|
|
3
|
+
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
4
|
+
import { bindsElement, holderOf, poolOfKind } from "./holder.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/fill-vocabulary/dist/verbs.js
|
|
7
|
+
const FILL_VERBS = [
|
|
8
|
+
"write",
|
|
9
|
+
"pick",
|
|
10
|
+
"find"
|
|
11
|
+
];
|
|
12
|
+
function isFillVerb(value) {
|
|
13
|
+
return typeof value === "string" && FILL_VERBS.includes(value);
|
|
14
|
+
}
|
|
15
|
+
function readFillVerb(value) {
|
|
16
|
+
return isFillVerb(value) ? value : void 0;
|
|
17
|
+
}
|
|
18
|
+
function choosesOne(type) {
|
|
19
|
+
return type === "select" || poolOfKind(type) !== void 0;
|
|
20
|
+
}
|
|
21
|
+
function writesOne(type) {
|
|
22
|
+
return type === "text" || type === "number" || isValueKind(type);
|
|
23
|
+
}
|
|
24
|
+
function everyFieldPlanned(slot, planned) {
|
|
25
|
+
const filled = new Set(planned);
|
|
26
|
+
if (filled.size === 0) return false;
|
|
27
|
+
return Object.entries(listItemFieldsOf(slot) ?? {}).every(([name, def]) => def.source !== void 0 || filled.has(name));
|
|
28
|
+
}
|
|
29
|
+
function pickRunsOn(holder) {
|
|
30
|
+
if (holder.shape === "objects") return true;
|
|
31
|
+
const type = holder.shape === "one" ? holder.type : holder.item;
|
|
32
|
+
return choosesOne(type) || type === "row";
|
|
33
|
+
}
|
|
34
|
+
function findRunsOn(holder) {
|
|
35
|
+
if (holder.shape === "one") return isFindableKind(holder.type);
|
|
36
|
+
return holder.shape === "list" && isFindableKind(holder.item);
|
|
37
|
+
}
|
|
38
|
+
function writeRunsOn(holder, slot, planned) {
|
|
39
|
+
if (holder.shape === "one") return writesOne(holder.type);
|
|
40
|
+
if (holder.shape === "list") return holder.item !== "row" && !isFindableKind(holder.item) && !choosesOne(holder.item);
|
|
41
|
+
if (holder.bindsElement) return true;
|
|
42
|
+
return holder.bound === void 0 && everyFieldPlanned(slot, planned);
|
|
43
|
+
}
|
|
44
|
+
function verbRunsOn(verb, slot, planned = []) {
|
|
45
|
+
const holder = holderOf(slot);
|
|
46
|
+
switch (verb) {
|
|
47
|
+
case "pick": return pickRunsOn(holder);
|
|
48
|
+
case "find": return findRunsOn(holder);
|
|
49
|
+
case "write": return writeRunsOn(holder, slot, planned);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function writesElements(verb, holder) {
|
|
53
|
+
return verb === "write" && holder?.shape === "objects" && holder.bindsElement;
|
|
54
|
+
}
|
|
55
|
+
function pickIsUnique(verb, node) {
|
|
56
|
+
return verb === "pick" && node.unique !== false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { FILL_VERBS, FINDABLE_KINDS, findRunsOn, isFillVerb, isFindableKind, pickIsUnique, pickRunsOn, readFillVerb, verbRunsOn, writesElements };
|