@homepages/concrete 6.2.0 → 8.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 +152 -0
- package/codemods/manifest.json +19 -0
- package/codemods/object-form-only.mjs +39 -0
- package/codemods/steps/list-object-form.mjs +688 -0
- package/codemods/steps/select-object-form.mjs +210 -0
- package/dist/artifact/playground/client/assets/index-Dn_xT16-.js +1101 -0
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +14 -14
- package/dist/asset-modules.d.ts +2 -1
- package/dist/cli/check/stages/render.js +1 -1
- package/dist/cli/check/stages/sections.js +1 -1
- package/dist/fixtures/canonical.d.ts +2 -5
- package/dist/fixtures/media.js +11 -25
- package/dist/fixtures/property.js +28 -16
- package/dist/fixtures/resolve.js +31 -17
- package/dist/fixtures/rows.js +3 -83
- package/dist/fixtures.d.ts +17 -9
- package/dist/index.d.ts +9 -9
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +32 -10
- package/dist/packages/internal/fill-bake/dist/derive-source.js +15 -4
- package/dist/packages/internal/fill-bake/dist/index.js +2 -2
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +6 -61
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +15 -0
- package/dist/packages/internal/property-facts/dist/index.js +1 -1
- package/dist/packages/internal/property-facts/dist/{property-facts-5pxZnlkh.js → property-facts-Cy7-O4p0.js} +2 -5
- package/dist/packages/internal/section-contracts/dist/catalog.js +2 -22
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +6 -1
- package/dist/packages/internal/section-contracts/dist/group-contract.js +1 -3
- package/dist/packages/internal/section-contracts/dist/index.js +0 -5
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +16 -7
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +1 -5
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +14 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +3 -28
- package/dist/packages/internal/section-contracts/dist/source-contract.js +93 -20
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +19 -9
- package/dist/packages/internal/source-resolution/dist/index.js +48 -57
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +6 -17
- package/dist/packages/internal/template-contracts/dist/facts-view.js +4 -23
- package/dist/packages/internal/template-contracts/dist/row-sources.js +20 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +362 -380
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +289 -293
- package/dist/primitives/slot-bindings.d.ts +7 -40
- package/dist/primitives/slot-bindings.js +10 -12
- package/dist/schema/define-schema.d.ts +1 -1
- package/dist/schema/define-schema.js +13 -1
- package/dist/schema/extract-fill-spec.js +14 -17
- package/dist/schema/fact.d.ts +2 -19
- package/dist/schema/fill-builders.d.ts +4 -3
- package/dist/schema/fill-spec.js +18 -1
- package/dist/schema/layout.d.ts +6 -8
- package/dist/schema/layout.js +3 -9
- package/dist/schema/property-facts.d.ts +17 -47
- package/dist/schema/row-fields.js +88 -0
- package/dist/schema/row-ref.d.ts +59 -0
- package/dist/schema/row-ref.js +28 -0
- package/dist/schema/runtime-values.d.ts +8 -13
- package/dist/schema/section-props.d.ts +19 -26
- package/dist/schema/section-schema.d.ts +6 -6
- package/dist/schema/section-schema.js +2 -2
- package/dist/schema/slot-builders.d.ts +247 -122
- package/dist/schema/slot-builders.js +57 -28
- package/dist/schema/slot-ref.d.ts +18 -2
- package/dist/schema/slot-ref.js +11 -3
- package/dist/schema/slot-types.d.ts +7 -7
- package/dist/schema/slot-types.js +55 -19
- package/dist/section/declare.d.ts +1 -1
- package/dist/section/section.d.ts +3 -3
- package/dist/template/logic-shim.d.ts +1 -1
- 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 +1 -1
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +3 -8
- package/package.json +1 -1
- package/tsconfig.base.json +1 -0
- package/dist/artifact/playground/client/assets/index-Cqz-jjVw.js +0 -1101
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/row-contract.js +0 -37
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +0 -15
- package/dist/packages/internal/template-contracts/dist/layout.js +0 -10
package/dist/fixtures/rows.js
CHANGED
|
@@ -1,79 +1,4 @@
|
|
|
1
|
-
import { collectionForSlot } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { COLLECTION_PROJECTIONS } from "../packages/internal/source-resolution/dist/index.js";
|
|
3
|
-
|
|
4
1
|
//#region src/fixtures/rows.ts
|
|
5
|
-
const EMPTY_FACT_ROW = {
|
|
6
|
-
units: {
|
|
7
|
-
unit_id: "",
|
|
8
|
-
unit_label: null,
|
|
9
|
-
beds: null,
|
|
10
|
-
baths: null,
|
|
11
|
-
sqft: null,
|
|
12
|
-
price: null,
|
|
13
|
-
description: null,
|
|
14
|
-
features: [],
|
|
15
|
-
position: 0,
|
|
16
|
-
floor_plans: []
|
|
17
|
-
},
|
|
18
|
-
contacts: {
|
|
19
|
-
id: "",
|
|
20
|
-
primary: false,
|
|
21
|
-
name: null,
|
|
22
|
-
title: null,
|
|
23
|
-
org_name: null,
|
|
24
|
-
bio: null,
|
|
25
|
-
email: null,
|
|
26
|
-
phone: null,
|
|
27
|
-
address: null,
|
|
28
|
-
website_url: null,
|
|
29
|
-
instagram_url: null,
|
|
30
|
-
linkedin_url: null,
|
|
31
|
-
x_url: null,
|
|
32
|
-
facebook_url: null,
|
|
33
|
-
avatar_upload_id: null,
|
|
34
|
-
logo_dark_upload_id: null,
|
|
35
|
-
logo_light_upload_id: null
|
|
36
|
-
},
|
|
37
|
-
comparables: {
|
|
38
|
-
id: "",
|
|
39
|
-
address_street: null,
|
|
40
|
-
address_city: null,
|
|
41
|
-
address_state: null,
|
|
42
|
-
address_postal: null,
|
|
43
|
-
address: "",
|
|
44
|
-
lat: null,
|
|
45
|
-
lng: null,
|
|
46
|
-
distance_m: null,
|
|
47
|
-
status: null,
|
|
48
|
-
price: null,
|
|
49
|
-
price_period: "total",
|
|
50
|
-
sale_date: null,
|
|
51
|
-
beds: null,
|
|
52
|
-
baths: null,
|
|
53
|
-
sqft: null,
|
|
54
|
-
photo_url: null,
|
|
55
|
-
source_url: null,
|
|
56
|
-
source_name: null,
|
|
57
|
-
year_built: null,
|
|
58
|
-
lot_sqft: null,
|
|
59
|
-
stories: null,
|
|
60
|
-
units: null,
|
|
61
|
-
hoa_monthly: null,
|
|
62
|
-
days_on_market: null,
|
|
63
|
-
list_price: null,
|
|
64
|
-
listed_date: null,
|
|
65
|
-
mls_number: null,
|
|
66
|
-
description: null,
|
|
67
|
-
property_type: null
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
function blankCollectionRow(collection, facts, rowFields) {
|
|
71
|
-
const oneEmptyRow = {
|
|
72
|
-
...facts,
|
|
73
|
-
[collection]: [EMPTY_FACT_ROW[collection]]
|
|
74
|
-
};
|
|
75
|
-
return COLLECTION_PROJECTIONS[collection](oneEmptyRow, rowFields)[0] ?? {};
|
|
76
|
-
}
|
|
77
2
|
function blankForField(def) {
|
|
78
3
|
switch (def.type) {
|
|
79
4
|
case "text":
|
|
@@ -95,15 +20,10 @@ function blankForField(def) {
|
|
|
95
20
|
default: return null;
|
|
96
21
|
}
|
|
97
22
|
}
|
|
98
|
-
function
|
|
99
|
-
const row = {};
|
|
100
|
-
for (const [field, def] of Object.entries(slot.fields ?? {})) row[field] = blankForField(def);
|
|
101
|
-
return row;
|
|
102
|
-
}
|
|
103
|
-
function canonicalizeRows(slot, value, facts, rowFields) {
|
|
23
|
+
function canonicalizeRows(slot, value) {
|
|
104
24
|
if (!Array.isArray(value)) return value;
|
|
105
|
-
const
|
|
106
|
-
const
|
|
25
|
+
const blank = {};
|
|
26
|
+
for (const [field, def] of Object.entries(slot.fields ?? {})) blank[field] = blankForField(def);
|
|
107
27
|
return value.map((row) => typeof row === "object" && row !== null && !Array.isArray(row) ? {
|
|
108
28
|
...blank,
|
|
109
29
|
...row
|
package/dist/fixtures.d.ts
CHANGED
|
@@ -31,19 +31,27 @@ type FloorPlanEntry = Omit<CanonicalFloorPlan, "upload_id" | "page_index" | "pro
|
|
|
31
31
|
readonly file: MediaFile;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
|
-
* The members of a comparable
|
|
35
|
-
*
|
|
34
|
+
* The members of a comparable's listing record — everything beyond the address,
|
|
35
|
+
* the pin and the figures a comps table prints.
|
|
36
36
|
*/
|
|
37
|
-
type CollectedComparableMember = "year_built" | "lot_sqft" | "stories" | "units" | "hoa_monthly" | "
|
|
37
|
+
type CollectedComparableMember = "year_built" | "lot_sqft" | "stories" | "units" | "hoa_monthly" | "list_price" | "listed_date" | "mls_number" | "description" | "property_type";
|
|
38
38
|
/**
|
|
39
|
-
* A comparable property: the canonical row, with the
|
|
39
|
+
* A comparable property: the canonical row, with the listing-record members optional
|
|
40
|
+
* and its photo imported in place of the upload reference.
|
|
40
41
|
*
|
|
41
|
-
*
|
|
42
|
-
* fixture that cares about an age or an asking price states it and a
|
|
43
|
-
* does not says nothing. An omitted member loads as `null`, which is
|
|
44
|
-
* real bake carries for a comp whose record was never
|
|
42
|
+
* The listing-record members are the part of a comp a user or a document fills only
|
|
43
|
+
* sometimes, so a fixture that cares about an age or an asking price states it and a
|
|
44
|
+
* fixture that does not says nothing. An omitted member loads as `null`, which is
|
|
45
|
+
* exactly what a real bake carries for a comp whose record was never filled in.
|
|
45
46
|
*/
|
|
46
|
-
type ComparableEntry = Omit<CanonicalComparable, CollectedComparableMember> & Partial<Pick<CanonicalComparable, CollectedComparableMember
|
|
47
|
+
type ComparableEntry = Omit<CanonicalComparable, CollectedComparableMember | "photo_upload_id"> & Partial<Pick<CanonicalComparable, CollectedComparableMember>> & {
|
|
48
|
+
/**
|
|
49
|
+
* The comp's photo. The platform holds it on the comp rather than in a pool, so the
|
|
50
|
+
* loader mints its id (`photo_upload_id`) and registers the file as image media,
|
|
51
|
+
* with the comp's address as its alt. Absent or `null` means the comp has no photo.
|
|
52
|
+
*/
|
|
53
|
+
readonly photo?: MediaFile | null;
|
|
54
|
+
};
|
|
47
55
|
/** A hosted video: the canonical row with its file imported. */
|
|
48
56
|
type UploadVideoEntry = Omit<CanonicalVideo, "source" | "url" | "provider"> & {
|
|
49
57
|
readonly source: "upload";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, EditorBridge, EditorBridgeSelection, EditorSelection, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandComponent, IslandEditor, IslandEditorOptions, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, deserializeIslandProps, islandId, serializeIslandProps } from "./packages/internal/island-runtime/dist/contract.js";
|
|
2
2
|
import "./asset-modules.js";
|
|
3
|
-
import {
|
|
3
|
+
import { FillBinding, FillCount, FillFor, FillInput, FillOptionName, fill } from "./schema/fill-builders.js";
|
|
4
|
+
import { DocumentSlot, ImageSlot, ListFieldSlot, ListItemSlot, ListSlot, NumberSlot, PoiSlot, SelectSlot, TextSlot, TourSlot, UrlSlot, VideoSlot } from "./schema/slot-types.js";
|
|
5
|
+
import { SlotRef } from "./schema/slot-ref.js";
|
|
6
|
+
import { ComputeBinding, compute } from "./schema/compute.js";
|
|
4
7
|
import { ResponsiveImage, ResponsiveSource } from "./packages/internal/image-descriptor/dist/index.js";
|
|
5
8
|
import { VideoCollectionValue, VideoValue } from "./packages/internal/template-contracts/dist/video-value.js";
|
|
6
9
|
import { TourCollectionValue, TourValue } from "./packages/internal/template-contracts/dist/tour-value.js";
|
|
7
10
|
import { DocumentCollectionValue, DocumentValue } from "./packages/internal/template-contracts/dist/document-value.js";
|
|
8
11
|
import { PoiPhoto, PoiRow } from "./packages/internal/template-contracts/dist/poi-row.js";
|
|
9
|
-
import { ComparableRow, Coordinates,
|
|
10
|
-
import { AuthorImage,
|
|
11
|
-
import { FillBinding, FillCount, FillFor, FillInput, FillOptionName, fill } from "./schema/fill-builders.js";
|
|
12
|
-
import { DocumentSlot, ImageSlot, ListFieldSlot, ListItemSlot, ListSlot, NumberSlot, PoiSlot, SelectSlot, TextSlot, TourSlot, UrlSlot, VideoSlot } from "./schema/slot-types.js";
|
|
13
|
-
import { SlotRef } from "./schema/slot-ref.js";
|
|
14
|
-
import { CollectionRowValues, DerivedFactRef, DirectFactRef, FactNamespace, fact } from "./schema/fact.js";
|
|
12
|
+
import { ComparableRow, Coordinates, Narrative } from "./schema/property-facts.js";
|
|
13
|
+
import { AuthorImage, ImageCollectionValue, ImageValue, PlaybackConfig } from "./schema/runtime-values.js";
|
|
15
14
|
import "./schema/section-schema.js";
|
|
16
15
|
import { RowValue, SlotValue } from "./schema/section-props.js";
|
|
17
16
|
import { UseEditorResult, useEditor } from "./packages/internal/island-runtime/dist/use-editor.js";
|
|
@@ -19,7 +18,6 @@ import { useCaptureReady } from "./packages/internal/island-runtime/dist/use-cap
|
|
|
19
18
|
import { useIslandId } from "./packages/internal/island-runtime/dist/use-island-id.js";
|
|
20
19
|
import { IslandMarker, IslandMarkerProps } from "./islands/marker.js";
|
|
21
20
|
import { BoundSlotValue, FieldBinding, ItemBinding, RowBinding, SlotBinding, SlotBindingMap, bindItems } from "./primitives/slot-bindings.js";
|
|
22
|
-
import { ComputeBinding, compute } from "./schema/compute.js";
|
|
23
21
|
import { CropConfig, DisplayEntryInput, DisplayFill, DocumentSlotDef, ImageSlotDef, ListRecordSlotDef, ListSlotDef, NumberSlotDef, PoiSlotDef, SelectSlotDef, SlotSource, TextSlotDef, TourSlotDef, UrlSlotDef, VideoSlotDef, document, image, list, number, poi, select, text, tour, url, video } from "./schema/slot-builders.js";
|
|
24
22
|
import { SectionOptions } from "./section/declare.js";
|
|
25
23
|
import { SectionContractProps, SectionPlacementProps, SectionRenderBindings, SectionValue, section } from "./section/section.js";
|
|
@@ -37,6 +35,8 @@ import { Video } from "./primitives/Video.js";
|
|
|
37
35
|
import { Slot } from "./primitives/slot.js";
|
|
38
36
|
import "./primitives/index.js";
|
|
39
37
|
import { ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE } from "./packages/internal/template-contracts/dist/markers.js";
|
|
38
|
+
import { FactsAddress, FactsContact, FactsDocument, FactsDocumentNote, FactsFloorPlan, FactsPhoto, FactsTour, FactsUnit, FactsVideo } from "./packages/internal/template-contracts/dist/facts-view.js";
|
|
39
|
+
import { DerivedFactRef, DirectFactRef, FactNamespace, fact } from "./schema/fact.js";
|
|
40
40
|
import { presets } from "./schema/format-presets.js";
|
|
41
41
|
import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, instagramPortrait, instagramSquare, instagramStory, letterLandscape, letterPortrait, linkedinPost, postcard6x4, postcard7x5, website, xPost } from "./schema/formats.js";
|
|
42
42
|
//#region src/index.d.ts
|
|
@@ -50,4 +50,4 @@ import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, insta
|
|
|
50
50
|
*/
|
|
51
51
|
declare const CONCRETE_VERSION: string;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE, type AuthorImage, type BoundSlotValue, CONCRETE_VERSION, type CanvasInput, type CanvasesInput, type
|
|
53
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE, type AuthorImage, type BoundSlotValue, CONCRETE_VERSION, type CanvasInput, type CanvasesInput, type ComparableRow, type ComputeBinding, type Coordinates, type CropConfig, type DefineTemplateInput, type DerivedFactRef, type DirectFactRef, type DisplayEntryInput, type DisplayFill, type DocumentCollectionValue, type DocumentFormat, type DocumentSlot, type DocumentSlotDef, type DocumentValue, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, EditorBridge, EditorBridgeSelection, EditorSelection, type FactNamespace, type FactsAddress, type FactsContact, type FactsDocument, type FactsDocumentNote, type FactsFloorPlan, type FactsPhoto, type FactsTour, type FactsUnit, type FactsVideo, type FieldBinding, type FillBinding, type FillCount, type FillFor, type FillInput, type FillOptionName, type FormatIdentity, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, type ImageCollectionValue, type ImageFormat, type ImageSlot, type ImageSlotDef, type ImageValue, IslandComponent, IslandEditor, IslandEditorOptions, IslandMarker, type IslandMarkerProps, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, type ItemBinding, type ListFieldSlot, type ListItemSlot, type ListRecordSlotDef, type ListSlot, type ListSlotDef, type Narrative, type NumberSlot, type NumberSlotDef, type OutputClass, type PageComponent, type PhysicalLength, type PicturePlan, type PictureSourceSpec, type PlaybackConfig, type PoiPhoto, type PoiRow, type PoiSlot, type PoiSlotDef, type RenderedPage, type ResponsiveImage, type ResponsiveSource, type RowBinding, type RowValue, Section, type SectionContractProps, type SectionOptions, type SectionPlacementProps, type SectionRenderBindings, type SectionValue, type SelectSlot, type SelectSlotDef, Slot, type SlotBinding, type SlotBindingMap, SlotGroup, type SlotRef, type SlotSource, type SlotValue, type TemplateCanvas, type TemplatePage, type TemplatePreview, type TemplateScope, type TemplateValue, type TextSlot, type TextSlotDef, Tour, type TourCollectionValue, type TourSlot, type TourSlotDef, type TourValue, type UrlSlot, type UrlSlotDef, type UseEditorResult, type ValueBinding, Video, type VideoCollectionValue, type VideoSlot, type VideoSlotDef, type VideoValue, type WebsiteFormat, type WebsitePage, a4Landscape, a4Portrait, bindItems, compute, deck16x9, defineTemplate, deserializeIslandProps, document, facebookPost, fact, fill, halfLetterFlyer, image, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, number, poi, postcard6x4, postcard7x5, presets, section, select, serializeIslandProps, text, tour, url, useCaptureReady, useEditor, useIslandId, video, website, xPost };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import {
|
|
1
|
+
import { COLLECTIONS, DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { rowMemberSources } from "../../template-contracts/dist/row-sources.js";
|
|
3
|
+
import { projectCollectionRows, readFrom } from "../../source-resolution/dist/index.js";
|
|
3
4
|
import { buildDeriveFactsView } from "../../property-facts/dist/derive-facts-view.js";
|
|
4
5
|
import { callDerived, readsAnySlot } from "./derive-source.js";
|
|
5
6
|
import { declaredDisplay } from "./display.js";
|
|
@@ -11,9 +12,8 @@ function directField(def) {
|
|
|
11
12
|
if (src["kind"] !== "direct") return null;
|
|
12
13
|
return typeof src["field"] === "string" ? src["field"] : null;
|
|
13
14
|
}
|
|
14
|
-
function resolveDirectField(field, facts,
|
|
15
|
-
if (Object.hasOwn(
|
|
16
|
-
if (field === "unit_floorplans") return buildUnitFloorplanList(facts);
|
|
15
|
+
function resolveDirectField(field, facts, fields, rowComputes) {
|
|
16
|
+
if (Object.hasOwn(COLLECTIONS, field)) return projectCollectionRows(field, facts, fields, rowComputes);
|
|
17
17
|
return readFrom(field, { facts });
|
|
18
18
|
}
|
|
19
19
|
function derivedSource(def) {
|
|
@@ -31,7 +31,7 @@ function bakePropertyRefSlots(schema, facts, ctx) {
|
|
|
31
31
|
const dField = directField(def);
|
|
32
32
|
if (dField !== null) {
|
|
33
33
|
try {
|
|
34
|
-
out[name] = resolveDirectField(dField, facts,
|
|
34
|
+
out[name] = resolveDirectField(dField, facts, def.fields, rowComputesOf(name, def.fields, deriveFacts, ctx));
|
|
35
35
|
} catch {
|
|
36
36
|
out[name] = null;
|
|
37
37
|
}
|
|
@@ -41,17 +41,39 @@ function bakePropertyRefSlots(schema, facts, ctx) {
|
|
|
41
41
|
if (derived !== null) {
|
|
42
42
|
if (readsAnySlot(def.source)) continue;
|
|
43
43
|
const resolved = resolveDerivedHandle(derived.transform, def.source, deriveFacts, ctx, { slot_id: name });
|
|
44
|
-
out[name] = resolved === null ? null : resolved.value;
|
|
44
|
+
out[name] = resolved === null ? null : projectComputedRows(resolved.value, def.fields, rowComputesOf(name, def.fields, deriveFacts, ctx));
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
return out;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function rowComputesOf(listKey, fields, deriveFacts, ctx) {
|
|
51
|
+
const computes = {};
|
|
52
|
+
for (const [fieldKey, field] of Object.entries(fields ?? {})) {
|
|
53
|
+
const derived = derivedSource(field);
|
|
54
|
+
if (derived === null) continue;
|
|
55
|
+
computes[fieldKey] = (readRow) => resolveDerivedHandle(derived.transform, field.source, deriveFacts, ctx, { slot_id: `${listKey}.${fieldKey}` }, void 0, readRow)?.value ?? null;
|
|
56
|
+
}
|
|
57
|
+
return computes;
|
|
58
|
+
}
|
|
59
|
+
function projectComputedRows(value, fields, rowComputes) {
|
|
60
|
+
if (!Array.isArray(value) || fields === void 0) return value;
|
|
61
|
+
const members = rowMemberSources(fields);
|
|
62
|
+
return value.map((computed) => {
|
|
63
|
+
const computedRow = computed !== null && typeof computed === "object" ? computed : {};
|
|
64
|
+
const readMember = (member) => computedRow[member] ?? null;
|
|
65
|
+
const out = {};
|
|
66
|
+
if (typeof computedRow["id"] === "string") out["id"] = computedRow["id"];
|
|
67
|
+
for (const [key, member] of Object.entries(members)) out[key] = readMember(member);
|
|
68
|
+
for (const [key, compute] of Object.entries(rowComputes)) out[key] = compute(readMember);
|
|
69
|
+
return out;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function resolveDerivedHandle(derivedHandle, source, deriveFacts, ctx, target, readSlot, readRow) {
|
|
51
73
|
const authored = ctx?.computed[derivedHandle];
|
|
52
74
|
try {
|
|
53
75
|
if (authored === void 0) throw new Error(`derived handle "${derivedHandle}" is not in the section's computed map`);
|
|
54
|
-
return { value: callDerived(authored, source, deriveFacts, readSlot) };
|
|
76
|
+
return { value: callDerived(authored, source, deriveFacts, readSlot, readRow) };
|
|
55
77
|
} catch (err) {
|
|
56
78
|
ctx?.log?.error({
|
|
57
79
|
event: "derive_function_threw",
|
|
@@ -94,4 +116,4 @@ function inDeclaredCases(def, entry, value, ctx) {
|
|
|
94
116
|
}
|
|
95
117
|
|
|
96
118
|
//#endregion
|
|
97
|
-
export { bakeDisplayEntries, bakePropertyRefSlots, derivedSource, directField, inDeclaredCases, resolveDerivedHandle, resolveDirectField };
|
|
119
|
+
export { bakeDisplayEntries, bakePropertyRefSlots, derivedSource, directField, inDeclaredCases, projectComputedRows, resolveDerivedHandle, resolveDirectField, rowComputesOf };
|
|
@@ -16,14 +16,18 @@ function slotRefOf(entry) {
|
|
|
16
16
|
}
|
|
17
17
|
function declaredReads(source) {
|
|
18
18
|
return readsOf(source).map((entry, i) => {
|
|
19
|
-
const { kind, key } = entry ?? {};
|
|
19
|
+
const { kind, key, field } = entry ?? {};
|
|
20
20
|
if (kind === "fact" && typeof key === "string") return {
|
|
21
21
|
kind: "fact",
|
|
22
22
|
key
|
|
23
23
|
};
|
|
24
|
+
if (kind === "row" && typeof field === "string") return {
|
|
25
|
+
kind: "row",
|
|
26
|
+
field
|
|
27
|
+
};
|
|
24
28
|
const slotRef = slotRefOf(entry);
|
|
25
29
|
if (slotRef !== null) return slotRef;
|
|
26
|
-
throw new Error(`reads[${String(i)}] is not a fact or
|
|
30
|
+
throw new Error(`reads[${String(i)}] is not a fact, slot or row ref: ${JSON.stringify(entry)}`);
|
|
27
31
|
});
|
|
28
32
|
}
|
|
29
33
|
function declaredSlotRefs(source) {
|
|
@@ -32,8 +36,15 @@ function declaredSlotRefs(source) {
|
|
|
32
36
|
function readsAnySlot(source) {
|
|
33
37
|
return declaredSlotRefs(source).length > 0;
|
|
34
38
|
}
|
|
35
|
-
function callDerived(fn, source, facts, readSlot) {
|
|
36
|
-
return fn(...declaredReads(source).map((ref) =>
|
|
39
|
+
function callDerived(fn, source, facts, readSlot, readRow) {
|
|
40
|
+
return fn(...declaredReads(source).map((ref) => {
|
|
41
|
+
if (ref.kind === "fact") return readFact(facts(), ref.key);
|
|
42
|
+
if (ref.kind === "row") {
|
|
43
|
+
if (readRow === void 0) throw new Error(`reads the row member "${ref.field}" outside a record list's row`);
|
|
44
|
+
return readRow(ref.field);
|
|
45
|
+
}
|
|
46
|
+
return readSlot?.(ref);
|
|
47
|
+
}));
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { callDerived, declaredReads, declaredSlotRefs, readsAnySlot } from "./derive-source.js";
|
|
2
2
|
import { declaredDisplay } from "./display.js";
|
|
3
|
-
import { bakeDisplayEntries, bakePropertyRefSlots, derivedSource, directField, resolveDerivedHandle, resolveDirectField } from "./bake-property-ref.js";
|
|
3
|
+
import { bakeDisplayEntries, bakePropertyRefSlots, derivedSource, directField, projectComputedRows, resolveDerivedHandle, resolveDirectField, rowComputesOf } from "./bake-property-ref.js";
|
|
4
4
|
import "./compute-reads.js";
|
|
5
5
|
|
|
6
|
-
export { bakeDisplayEntries, bakePropertyRefSlots };
|
|
6
|
+
export { bakeDisplayEntries, bakePropertyRefSlots, projectComputedRows, rowComputesOf };
|
|
@@ -9,53 +9,11 @@ const LEGACY_COLLECTION_ITEM = {
|
|
|
9
9
|
function isListSlot(slot) {
|
|
10
10
|
return slot.type === "list" || slot.type !== void 0 && slot.type in LEGACY_COLLECTION_ITEM;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (def.source !== void 0) continue;
|
|
16
|
-
const pool = poolingPrimitiveOf(def);
|
|
17
|
-
if (pool !== void 0) found.push({
|
|
18
|
-
field,
|
|
19
|
-
pool
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return found;
|
|
23
|
-
}
|
|
24
|
-
function selectFieldsOf(fields) {
|
|
25
|
-
return Object.entries(fields).filter(([, def]) => def.type === "select" && Array.isArray(def.values)).map(([name]) => name);
|
|
12
|
+
function everyFieldFilled(fields, filled) {
|
|
13
|
+
if (filled.size === 0) return false;
|
|
14
|
+
return Object.entries(fields).every(([name, def]) => def.source !== void 0 || filled.has(name));
|
|
26
15
|
}
|
|
27
|
-
function
|
|
28
|
-
const selects = selectFieldsOf(fields);
|
|
29
|
-
const title = slot.title;
|
|
30
|
-
if (title !== void 0) {
|
|
31
|
-
const def = fields[title];
|
|
32
|
-
if (def?.type === "text") return {
|
|
33
|
-
kind: "keyed-rows",
|
|
34
|
-
keyField: title,
|
|
35
|
-
keys: "written"
|
|
36
|
-
};
|
|
37
|
-
if (def?.type === "select" && selects.includes(title)) return {
|
|
38
|
-
kind: "keyed-rows",
|
|
39
|
-
keyField: title,
|
|
40
|
-
keys: "picked"
|
|
41
|
-
};
|
|
42
|
-
return def?.type === void 0 ? {
|
|
43
|
-
kind: "no-key",
|
|
44
|
-
title
|
|
45
|
-
} : {
|
|
46
|
-
kind: "no-key",
|
|
47
|
-
title,
|
|
48
|
-
titleType: def.type
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
if (selects.length === 1) return {
|
|
52
|
-
kind: "keyed-rows",
|
|
53
|
-
keyField: selects[0],
|
|
54
|
-
keys: "picked"
|
|
55
|
-
};
|
|
56
|
-
return { kind: "no-key" };
|
|
57
|
-
}
|
|
58
|
-
function originationFor(slot) {
|
|
16
|
+
function originationFor(slot, filled = []) {
|
|
59
17
|
if (isListSlot(slot)) {
|
|
60
18
|
const fields = slot.fields;
|
|
61
19
|
if (fields !== void 0) {
|
|
@@ -64,21 +22,7 @@ function originationFor(slot) {
|
|
|
64
22
|
kind: "bound-rows",
|
|
65
23
|
iterate: bound.field
|
|
66
24
|
};
|
|
67
|
-
|
|
68
|
-
const key = keyRows(slot, fields);
|
|
69
|
-
if (pooled.length === 1 && !(key.kind === "keyed-rows" && key.keys === "picked")) return {
|
|
70
|
-
kind: "pick-assets",
|
|
71
|
-
pool: pooled[0].pool,
|
|
72
|
-
field: pooled[0].field
|
|
73
|
-
};
|
|
74
|
-
if (key.kind === "keyed-rows") return key;
|
|
75
|
-
const { kind: _noKey, ...pointed } = key;
|
|
76
|
-
return {
|
|
77
|
-
kind: "unkeyed-rows",
|
|
78
|
-
...pointed,
|
|
79
|
-
selects: selectFieldsOf(fields),
|
|
80
|
-
pools: pooled.map((p) => p.field)
|
|
81
|
-
};
|
|
25
|
+
return everyFieldFilled(fields, new Set(filled)) ? { kind: "filled-rows" } : void 0;
|
|
82
26
|
}
|
|
83
27
|
const item = slot.element?.type ?? LEGACY_COLLECTION_ITEM[slot.type ?? ""];
|
|
84
28
|
if (item === "poi") return { kind: "curate" };
|
|
@@ -91,6 +35,7 @@ function originationFor(slot) {
|
|
|
91
35
|
return { kind: "write-items" };
|
|
92
36
|
}
|
|
93
37
|
if (slot.type === "text") return { kind: "write" };
|
|
38
|
+
if (slot.type === "number") return { kind: "estimate" };
|
|
94
39
|
if (slot.type === "select") return {
|
|
95
40
|
kind: "pick-one",
|
|
96
41
|
from: "values"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region ../../internal/fill-vocabulary/dist/row-reads.js
|
|
2
|
+
function isRowRead(entry) {
|
|
3
|
+
if (entry === null || typeof entry !== "object") return false;
|
|
4
|
+
const { kind, field } = entry;
|
|
5
|
+
return kind === "row" && typeof field === "string" && field !== "";
|
|
6
|
+
}
|
|
7
|
+
function rowReadFields(reads) {
|
|
8
|
+
if (!Array.isArray(reads)) return [];
|
|
9
|
+
const out = [];
|
|
10
|
+
for (const entry of reads) if (isRowRead(entry) && !out.includes(entry.field)) out.push(entry.field);
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { isRowRead, rowReadFields };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as VideoSchema, S as UnitSchema, _ as PropertyFactsSchema, a as ComparableSchema, b as TourLinkSchema, c as DocumentSchema, f as ListingIntentSchema, h as PlannerUnitSchema, i as ComparablePricePeriodSchema, l as FloorPlanSchema, m as PhotoSchema, n as COMPARABLE_PRICE_PERIODS, o as ComparableStatusSchema, p as NarrativeSchema, r as COMPARABLE_STATUSES, s as ContactCardSchema, t as AddressSchema, u as FloorPlanUnitAssignmentSchema, v as PropertyTypeSchema, x as UnitFloorPlanRefSchema } from "./property-facts-
|
|
1
|
+
import { C as VideoSchema, S as UnitSchema, _ as PropertyFactsSchema, a as ComparableSchema, b as TourLinkSchema, c as DocumentSchema, f as ListingIntentSchema, h as PlannerUnitSchema, i as ComparablePricePeriodSchema, l as FloorPlanSchema, m as PhotoSchema, n as COMPARABLE_PRICE_PERIODS, o as ComparableStatusSchema, p as NarrativeSchema, r as COMPARABLE_STATUSES, s as ContactCardSchema, t as AddressSchema, u as FloorPlanUnitAssignmentSchema, v as PropertyTypeSchema, x as UnitFloorPlanRefSchema } from "./property-facts-Cy7-O4p0.js";
|
|
2
2
|
|
|
3
3
|
export { PropertyFactsSchema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
//#region ../../internal/property-facts/dist/property-facts-
|
|
3
|
+
//#region ../../internal/property-facts/dist/property-facts-Cy7-O4p0.js
|
|
4
4
|
const AddressSchema = z.object({
|
|
5
5
|
display: z.string(),
|
|
6
6
|
street: z.string(),
|
|
@@ -126,15 +126,12 @@ const ComparableSchema = z.object({
|
|
|
126
126
|
beds: z.number().int().nullable(),
|
|
127
127
|
baths: z.number().nullable(),
|
|
128
128
|
sqft: z.number().int().nullable(),
|
|
129
|
-
|
|
130
|
-
source_url: z.string().nullable(),
|
|
131
|
-
source_name: z.string().nullable(),
|
|
129
|
+
photo_upload_id: z.string().nullable(),
|
|
132
130
|
year_built: z.number().int().nullable(),
|
|
133
131
|
lot_sqft: z.number().int().nullable(),
|
|
134
132
|
stories: z.number().nullable(),
|
|
135
133
|
units: z.number().int().nullable(),
|
|
136
134
|
hoa_monthly: z.number().int().nullable(),
|
|
137
|
-
days_on_market: z.number().int().nullable(),
|
|
138
135
|
list_price: z.number().int().nullable(),
|
|
139
136
|
listed_date: z.string().nullable(),
|
|
140
137
|
mls_number: z.string().nullable(),
|
|
@@ -6,7 +6,7 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
id: "decision-kind",
|
|
9
|
-
summary: "Every fill decision names a kind the platform runs: text, pick, list or display."
|
|
9
|
+
summary: "Every fill decision names a kind the platform runs: text, number, pick, list or display."
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
id: "produces-known-slot",
|
|
@@ -18,19 +18,7 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
id: "list-fill",
|
|
21
|
-
summary: "A list fill declares what the slot's own origination needs: a brief where the model originates rows, a bound where it writes them
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
id: "choose-select",
|
|
25
|
-
summary: "A record list the model originates is keyed by its title field, else by exactly one select field with declared values."
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: "name-title",
|
|
29
|
-
summary: "A list keyed by a written name needs that field to be capped text that carries no fill of its own."
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: "pooling-field",
|
|
33
|
-
summary: "A list fill's record item declares at most one unbound pooled asset field."
|
|
21
|
+
summary: "A list fill declares what the slot's own origination needs: rows bound to facts or filled field by field, a brief where the model originates rows, a bound where it writes them."
|
|
34
22
|
},
|
|
35
23
|
{
|
|
36
24
|
id: "row-fill",
|
|
@@ -84,10 +72,6 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
84
72
|
id: "url",
|
|
85
73
|
summary: "A url slot's accepts names a link kind or provider that a registered provider implements."
|
|
86
74
|
},
|
|
87
|
-
{
|
|
88
|
-
id: "source-filter",
|
|
89
|
-
summary: "A media slot's source filter names a filter the platform supports."
|
|
90
|
-
},
|
|
91
75
|
{
|
|
92
76
|
id: "sources",
|
|
93
77
|
summary: "Only a video slot declares sources, as a non-empty list of distinct known video sources."
|
|
@@ -99,10 +83,6 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
99
83
|
{
|
|
100
84
|
id: "group",
|
|
101
85
|
summary: "Group ids are unique, every group names real slots, and no slot sits in two groups."
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: "row",
|
|
105
|
-
summary: "Every two-up row pairs adjacent short slots, and a record item's layout lists each field exactly once."
|
|
106
86
|
}
|
|
107
87
|
];
|
|
108
88
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region ../../internal/section-contracts/dist/fill-spec-view.js
|
|
2
2
|
const DECISION_KINDS = [
|
|
3
3
|
"text",
|
|
4
|
+
"number",
|
|
4
5
|
"pick",
|
|
5
6
|
"list",
|
|
6
7
|
"display"
|
|
@@ -8,6 +9,10 @@ const DECISION_KINDS = [
|
|
|
8
9
|
function isListFill(decision) {
|
|
9
10
|
return decision.kind === "list";
|
|
10
11
|
}
|
|
12
|
+
function plannedFieldsOf(decision) {
|
|
13
|
+
const fields = decision.fields;
|
|
14
|
+
return fields !== null && typeof fields === "object" ? Object.keys(fields) : [];
|
|
15
|
+
}
|
|
11
16
|
|
|
12
17
|
//#endregion
|
|
13
|
-
export { DECISION_KINDS, isListFill };
|
|
18
|
+
export { DECISION_KINDS, isListFill, plannedFieldsOf };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { flattenLayout } from "../../template-contracts/dist/layout.js";
|
|
2
|
-
|
|
3
1
|
//#region ../../internal/section-contracts/dist/group-contract.js
|
|
4
2
|
function assertGroupContract(schema, sectionKey) {
|
|
5
3
|
const groups = schema.groups;
|
|
@@ -9,7 +7,7 @@ function assertGroupContract(schema, sectionKey) {
|
|
|
9
7
|
for (const group of groups) {
|
|
10
8
|
if (seenIds.has(group.id)) throw new Error(`Section "${sectionKey}": duplicate group id "${group.id}".`);
|
|
11
9
|
seenIds.add(group.id);
|
|
12
|
-
for (const member of
|
|
10
|
+
for (const member of group.members) {
|
|
13
11
|
if (!(member in schema.slots)) throw new Error(`Section "${sectionKey}": group "${group.id}" names unknown slot "${member}".`);
|
|
14
12
|
if (seenSlots.has(member)) throw new Error(`Section "${sectionKey}": slot "${member}" appears in more than one group.`);
|
|
15
13
|
seenSlots.add(member);
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import { SECTION_CONTRACT_CATALOG } from "./catalog.js";
|
|
2
2
|
import { assertCapContract } from "./cap-contract.js";
|
|
3
|
-
import { assertChooseSelectContract } from "./choose-select-contract.js";
|
|
4
3
|
import { assertCountBoundsContract } from "./count-bounds-contract.js";
|
|
5
4
|
import { assertGroupContract } from "./group-contract.js";
|
|
6
5
|
import { assertInterpolationContract } from "./interpolation-contract.js";
|
|
7
6
|
import { assertWriterReadsFactContract } from "./writer-reads-fact-contract.js";
|
|
8
7
|
import { assertListFillContract } from "./list-fill-contract.js";
|
|
9
8
|
import { assertListScalarContract } from "./list-scalar-contract.js";
|
|
10
|
-
import { assertNameTitleContract } from "./name-title-contract.js";
|
|
11
9
|
import { assertNestedSlotTypes } from "./nested-slot-contract.js";
|
|
12
10
|
import { assertRecordCollectionContract } from "./record-collection-contract.js";
|
|
13
11
|
import { assertOptionSourceContract } from "./option-source-contract.js";
|
|
14
12
|
import { assertPoiCurationContract } from "./poi-curation-contract.js";
|
|
15
|
-
import { assertPoolingFieldContract } from "./pooling-field-contract.js";
|
|
16
|
-
import { assertRowContract } from "./row-contract.js";
|
|
17
13
|
import { assertRowFillContract } from "./row-fill-contract.js";
|
|
18
14
|
import { assertSourceContract } from "./source-contract.js";
|
|
19
15
|
import { assertDisplayContract } from "./display-contract.js";
|
|
20
16
|
import { assertDisplayEvidenceContract } from "./display-evidence-contract.js";
|
|
21
17
|
import { assertSelectContract } from "./select-contract.js";
|
|
22
|
-
import { assertSourceFilterContract } from "./source-filter-contract.js";
|
|
23
18
|
import { assertSourcesContract } from "./sources-contract.js";
|
|
24
19
|
import { assertUrlContract } from "./url-contract.js";
|
|
25
20
|
import { collectSectionContractViolations } from "./runners.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
-
import { isListFill } from "./fill-spec-view.js";
|
|
1
|
+
import { isListSlot, originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
+
import { isListFill, plannedFieldsOf } from "./fill-spec-view.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/section-contracts/dist/list-fill-contract.js
|
|
5
5
|
const NO_ABSTENTION = ["bound-rows", "curate"];
|
|
@@ -8,12 +8,21 @@ function assertListFillContract(schema, decision, sectionKey) {
|
|
|
8
8
|
if (!isListFill(decision)) return;
|
|
9
9
|
for (const slotId of decision.produces) {
|
|
10
10
|
const slot = schema.slots[slotId];
|
|
11
|
-
if (slot === void 0) continue;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
if (slot === void 0 || !isListSlot(slot)) continue;
|
|
12
|
+
const planned = plannedFieldsOf(decision);
|
|
13
|
+
const origination = originationFor(slot, planned);
|
|
14
|
+
const where = `Section "${sectionKey}": list fill "${decision.id}"`;
|
|
15
|
+
if (origination === void 0) {
|
|
16
|
+
if (slot.fields !== void 0) assertRowsOriginate(slot, planned, `${where} produces "${slotId}"`);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
assertOrigination(fill, origination, slot, where);
|
|
15
20
|
}
|
|
16
21
|
}
|
|
22
|
+
function assertRowsOriginate(slot, planned, where) {
|
|
23
|
+
const unwritten = Object.entries(slot.fields ?? {}).filter(([name, field]) => field.source === void 0 && !planned.includes(name)).map(([name]) => name);
|
|
24
|
+
throw new Error(`${where}, a record list whose rows nothing originates: it is not bound to a facts array, and ${unwritten.length > 0 ? `${unwritten.map((name) => `"${name}"`).join(", ")} ${unwritten.length === 1 ? "carries" : "carry"} no fill of its own` : "no row field carries a fill of its own"}. Bind the list with \`source:\`, or give every row field a \`fill()\`, a row member or a \`compute()\`.`);
|
|
25
|
+
}
|
|
17
26
|
function assertOrigination(fill, origination, slot, where) {
|
|
18
27
|
if (fill.none !== void 0 && NO_ABSTENTION.includes(origination.kind)) throw new Error(`${where} declares \`none\`, but ${origination.kind === "curate" ? "a curated list" : "a fact-bound list"} has no discretion to abstain — its rows come from the platform's place search or from the facts. Drop \`none\`, or give a row field its own.`);
|
|
19
28
|
if (origination.kind === "bound-rows") {
|
|
@@ -25,7 +34,7 @@ function assertOrigination(fill, origination, slot, where) {
|
|
|
25
34
|
return;
|
|
26
35
|
}
|
|
27
36
|
if (typeof fill.brief !== "string" || fill.brief.length === 0) throw new Error(`${where} originates rows but declares no \`brief\` — the brief is the whole instruction.`);
|
|
28
|
-
if ((origination.kind === "write-items" || origination.kind === "
|
|
37
|
+
if ((origination.kind === "write-items" || origination.kind === "filled-rows") && fill.count === void 0 && slot.max === void 0) throw new Error(`${where} writes its ${origination.kind === "write-items" ? "items" : "rows"} but neither it nor the slot says how many — declare a \`count\`, or give the slot a \`max\`.`);
|
|
29
38
|
const band = fill.count;
|
|
30
39
|
if (typeof band?.min === "number" && typeof band.max === "number" && band.min > band.max) throw new Error(`${where} declares count.min ${String(band.min)} above count.max ${String(band.max)} — a band the model can never answer inside.`);
|
|
31
40
|
}
|