@homepages/concrete 6.2.0 → 7.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 +133 -0
- package/codemods/manifest.json +13 -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-D8eepVr-.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 +31 -8
- 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 -1
- 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 +0 -4
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +4 -4
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +5 -1
- package/dist/packages/internal/section-contracts/dist/group-contract.js +1 -3
- package/dist/packages/internal/section-contracts/dist/index.js +0 -1
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +3 -3
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +1 -5
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +2 -2
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +3 -1
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +14 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +0 -5
- package/dist/packages/internal/section-contracts/dist/source-contract.js +80 -4
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +12 -6
- package/dist/packages/internal/source-resolution/dist/index.js +57 -20
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +16 -17
- package/dist/packages/internal/template-contracts/dist/facts-view.js +6 -18
- package/dist/packages/internal/template-contracts/dist/row-sources.js +26 -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 -289
- 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 +15 -13
- package/dist/schema/fact.d.ts +2 -19
- package/dist/schema/fill-builders.d.ts +4 -3
- package/dist/schema/fill-spec.js +9 -1
- package/dist/schema/layout.d.ts +6 -8
- package/dist/schema/layout.js +3 -9
- package/dist/schema/property-facts.d.ts +16 -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 +222 -117
- 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 +1 -2
- 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/row-contract.js +0 -37
- 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
1
|
import { DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import {
|
|
2
|
+
import { rowMemberSources, usesRowSources } from "../../template-contracts/dist/row-sources.js";
|
|
3
|
+
import { COLLECTION_PROJECTIONS, buildUnitFloorplanList, 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,8 +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(COLLECTION_PROJECTIONS, field)) return
|
|
15
|
+
function resolveDirectField(field, facts, fields, rowComputes) {
|
|
16
|
+
if (Object.hasOwn(COLLECTION_PROJECTIONS, field)) return projectCollectionRows(field, facts, fields, rowComputes);
|
|
16
17
|
if (field === "unit_floorplans") return buildUnitFloorplanList(facts);
|
|
17
18
|
return readFrom(field, { facts });
|
|
18
19
|
}
|
|
@@ -31,7 +32,7 @@ function bakePropertyRefSlots(schema, facts, ctx) {
|
|
|
31
32
|
const dField = directField(def);
|
|
32
33
|
if (dField !== null) {
|
|
33
34
|
try {
|
|
34
|
-
out[name] = resolveDirectField(dField, facts,
|
|
35
|
+
out[name] = resolveDirectField(dField, facts, def.fields, rowComputesOf(name, def.fields, deriveFacts, ctx));
|
|
35
36
|
} catch {
|
|
36
37
|
out[name] = null;
|
|
37
38
|
}
|
|
@@ -41,17 +42,39 @@ function bakePropertyRefSlots(schema, facts, ctx) {
|
|
|
41
42
|
if (derived !== null) {
|
|
42
43
|
if (readsAnySlot(def.source)) continue;
|
|
43
44
|
const resolved = resolveDerivedHandle(derived.transform, def.source, deriveFacts, ctx, { slot_id: name });
|
|
44
|
-
out[name] = resolved === null ? null : resolved.value;
|
|
45
|
+
out[name] = resolved === null ? null : projectComputedRows(resolved.value, def.fields, rowComputesOf(name, def.fields, deriveFacts, ctx));
|
|
45
46
|
continue;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
return out;
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function rowComputesOf(listKey, fields, deriveFacts, ctx) {
|
|
52
|
+
const computes = {};
|
|
53
|
+
for (const [fieldKey, field] of Object.entries(fields ?? {})) {
|
|
54
|
+
const derived = derivedSource(field);
|
|
55
|
+
if (derived === null) continue;
|
|
56
|
+
computes[fieldKey] = (readRow) => resolveDerivedHandle(derived.transform, field.source, deriveFacts, ctx, { slot_id: `${listKey}.${fieldKey}` }, void 0, readRow)?.value ?? null;
|
|
57
|
+
}
|
|
58
|
+
return computes;
|
|
59
|
+
}
|
|
60
|
+
function projectComputedRows(value, fields, rowComputes) {
|
|
61
|
+
if (!Array.isArray(value) || !usesRowSources(fields)) return value;
|
|
62
|
+
const members = rowMemberSources(fields);
|
|
63
|
+
return value.map((computed) => {
|
|
64
|
+
const computedRow = computed !== null && typeof computed === "object" ? computed : {};
|
|
65
|
+
const readMember = (member) => computedRow[member] ?? null;
|
|
66
|
+
const out = {};
|
|
67
|
+
if (typeof computedRow["id"] === "string") out["id"] = computedRow["id"];
|
|
68
|
+
for (const [key, member] of Object.entries(members)) out[key] = readMember(member);
|
|
69
|
+
for (const [key, compute] of Object.entries(rowComputes)) out[key] = compute(readMember);
|
|
70
|
+
return out;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function resolveDerivedHandle(derivedHandle, source, deriveFacts, ctx, target, readSlot, readRow) {
|
|
51
74
|
const authored = ctx?.computed[derivedHandle];
|
|
52
75
|
try {
|
|
53
76
|
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) };
|
|
77
|
+
return { value: callDerived(authored, source, deriveFacts, readSlot, readRow) };
|
|
55
78
|
} catch (err) {
|
|
56
79
|
ctx?.log?.error({
|
|
57
80
|
event: "derive_function_threw",
|
|
@@ -94,4 +117,4 @@ function inDeclaredCases(def, entry, value, ctx) {
|
|
|
94
117
|
}
|
|
95
118
|
|
|
96
119
|
//#endregion
|
|
97
|
-
export { bakeDisplayEntries, bakePropertyRefSlots, derivedSource, directField, inDeclaredCases, resolveDerivedHandle, resolveDirectField };
|
|
120
|
+
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 };
|
|
@@ -55,7 +55,11 @@ function keyRows(slot, fields) {
|
|
|
55
55
|
};
|
|
56
56
|
return { kind: "no-key" };
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function everyFieldFilled(fields, filled) {
|
|
59
|
+
if (filled.size === 0) return false;
|
|
60
|
+
return Object.entries(fields).every(([name, def]) => def.source !== void 0 || filled.has(name));
|
|
61
|
+
}
|
|
62
|
+
function originationFor(slot, filled = []) {
|
|
59
63
|
if (isListSlot(slot)) {
|
|
60
64
|
const fields = slot.fields;
|
|
61
65
|
if (fields !== void 0) {
|
|
@@ -64,6 +68,7 @@ function originationFor(slot) {
|
|
|
64
68
|
kind: "bound-rows",
|
|
65
69
|
iterate: bound.field
|
|
66
70
|
};
|
|
71
|
+
if (everyFieldFilled(fields, new Set(filled))) return { kind: "filled-rows" };
|
|
67
72
|
const pooled = pooledFieldsOf(fields);
|
|
68
73
|
const key = keyRows(slot, fields);
|
|
69
74
|
if (pooled.length === 1 && !(key.kind === "keyed-rows" && key.keys === "picked")) return {
|
|
@@ -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(),
|
|
@@ -99,10 +99,6 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
99
99
|
{
|
|
100
100
|
id: "group",
|
|
101
101
|
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
102
|
}
|
|
107
103
|
];
|
|
108
104
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
-
import { isListFill } from "./fill-spec-view.js";
|
|
2
|
+
import { isListFill, plannedFieldsOf } from "./fill-spec-view.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/section-contracts/dist/choose-select-contract.js
|
|
5
5
|
function assertChooseSelectContract(schema, decision, sectionKey) {
|
|
@@ -7,12 +7,12 @@ function assertChooseSelectContract(schema, decision, sectionKey) {
|
|
|
7
7
|
for (const slotId of decision.produces) {
|
|
8
8
|
const slot = schema.slots[slotId];
|
|
9
9
|
if (slot === void 0) continue;
|
|
10
|
-
const origination = originationFor(slot);
|
|
10
|
+
const origination = originationFor(slot, plannedFieldsOf(decision));
|
|
11
11
|
if (origination?.kind !== "unkeyed-rows") continue;
|
|
12
12
|
const where = `Section "${sectionKey}": list fill "${decision.id}" originates rows of "${slotId}"`;
|
|
13
13
|
const declared = Object.keys(slot.fields ?? {});
|
|
14
|
-
if (origination.title !== void 0) throw new Error(`${where}, keyed by \`title: "${origination.title}"\` — ${origination.titleType === void 0 ? "which is not one of its declared fields" : `a \`${origination.titleType}\` field${origination.titleType === "select" ? " with no declared `values`" : ""}`}. Rows are keyed on a \`text\` field the model writes or a \`select
|
|
15
|
-
throw new Error(`${where}, but declares neither a \`title:\` to key them by nor exactly one \`select\` field with \`
|
|
14
|
+
if (origination.title !== void 0) throw new Error(`${where}, keyed by \`title: "${origination.title}"\` — ${origination.titleType === void 0 ? "which is not one of its declared fields" : `a \`${origination.titleType}\` field${origination.titleType === "select" ? " with no declared `values`" : ""}`}. Rows are keyed on a \`text\` field the model writes or a \`select({ options })\` field it picks from, so point \`title:\` at one of those.`);
|
|
15
|
+
throw new Error(`${where}, but declares neither a \`title:\` to key them by nor exactly one \`select\` field with \`options\` to fall back to (found ${origination.selects.length}; declared: ${declared.length > 0 ? declared.join(", ") : "none"}). Title the list by the field that names a row, give the row exactly one \`select({ label, options })\` field, or give every row field its own \`fill()\`.`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -8,6 +8,10 @@ const DECISION_KINDS = [
|
|
|
8
8
|
function isListFill(decision) {
|
|
9
9
|
return decision.kind === "list";
|
|
10
10
|
}
|
|
11
|
+
function plannedFieldsOf(decision) {
|
|
12
|
+
const fields = decision.fields;
|
|
13
|
+
return fields !== null && typeof fields === "object" ? Object.keys(fields) : [];
|
|
14
|
+
}
|
|
11
15
|
|
|
12
16
|
//#endregion
|
|
13
|
-
export { DECISION_KINDS, isListFill };
|
|
17
|
+
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);
|
|
@@ -13,7 +13,6 @@ import { assertRecordCollectionContract } from "./record-collection-contract.js"
|
|
|
13
13
|
import { assertOptionSourceContract } from "./option-source-contract.js";
|
|
14
14
|
import { assertPoiCurationContract } from "./poi-curation-contract.js";
|
|
15
15
|
import { assertPoolingFieldContract } from "./pooling-field-contract.js";
|
|
16
|
-
import { assertRowContract } from "./row-contract.js";
|
|
17
16
|
import { assertRowFillContract } from "./row-fill-contract.js";
|
|
18
17
|
import { assertSourceContract } from "./source-contract.js";
|
|
19
18
|
import { assertDisplayContract } from "./display-contract.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
-
import { isListFill } from "./fill-spec-view.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"];
|
|
@@ -9,7 +9,7 @@ function assertListFillContract(schema, decision, sectionKey) {
|
|
|
9
9
|
for (const slotId of decision.produces) {
|
|
10
10
|
const slot = schema.slots[slotId];
|
|
11
11
|
if (slot === void 0) continue;
|
|
12
|
-
const origination = originationFor(slot);
|
|
12
|
+
const origination = originationFor(slot, plannedFieldsOf(decision));
|
|
13
13
|
if (origination === void 0 || origination.kind === "unkeyed-rows") continue;
|
|
14
14
|
assertOrigination(fill, origination, slot, `Section "${sectionKey}": list fill "${decision.id}"`);
|
|
15
15
|
}
|
|
@@ -25,7 +25,7 @@ function assertOrigination(fill, origination, slot, where) {
|
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
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 === "keyed-rows" && origination.keys === "written") && 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\`.`);
|
|
28
|
+
if ((origination.kind === "write-items" || origination.kind === "filled-rows" || origination.kind === "keyed-rows" && origination.keys === "written") && 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
29
|
const band = fill.count;
|
|
30
30
|
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
31
|
}
|
|
@@ -19,10 +19,7 @@ function checkSelectListVocabulary(element, label, sectionKey) {
|
|
|
19
19
|
if (!Array.isArray(element.values) || element.values.length === 0) throw new Error(`Section "${sectionKey}": ${label} element is a \`select\` with no \`values\` — a select-list's vocabulary must be a non-empty static \`values\` array.`);
|
|
20
20
|
}
|
|
21
21
|
function checkSingleItem(slot, label, sectionKey) {
|
|
22
|
-
if (slot.title !== void 0
|
|
23
|
-
const offending = slot.title !== void 0 ? "title" : "layout";
|
|
24
|
-
throw new Error(`Section "${sectionKey}": ${label} declares \`${offending}\` beside \`element\` — the row surface belongs to a record item (\`fields\`) only.`);
|
|
25
|
-
}
|
|
22
|
+
if (slot.title !== void 0) throw new Error(`Section "${sectionKey}": ${label} declares \`title\` beside \`element\` — the row surface belongs to a record item (\`fields\`) only.`);
|
|
26
23
|
const element = slot.element;
|
|
27
24
|
if (element == null) throw new Error(`Section "${sectionKey}": ${label} must declare its item — \`element\` (a single slot) or \`fields\` (a record of slots).`);
|
|
28
25
|
if (!LIST_ITEM_TYPES.has(element.type ?? "")) throw new Error(`Section "${sectionKey}": ${label} element must be a single value primitive (${[...LIST_ITEM_TYPES].join("|")}) — never a list or a record, got "${element.type}".`);
|
|
@@ -49,7 +46,6 @@ function checkRecordItem(slot, label, sectionKey) {
|
|
|
49
46
|
if (field.type === "list") checkSingleItem(field, `${label} field "${fieldId}"`, sectionKey);
|
|
50
47
|
}
|
|
51
48
|
if (slot.title !== void 0 && !Object.hasOwn(fields, slot.title)) throw new Error(`Section "${sectionKey}": ${label} \`title\` names "${slot.title}", which is not a declared field.`);
|
|
52
|
-
for (const row of slot.layout ?? []) for (const fieldId of Array.isArray(row) ? row : [row]) if (!Object.hasOwn(fields, fieldId)) throw new Error(`Section "${sectionKey}": ${label} \`layout\` names "${fieldId}", which is not a declared field.`);
|
|
53
49
|
}
|
|
54
50
|
function checkListSlot(slot, label, sectionKey) {
|
|
55
51
|
if (slot.element != null && slot.fields != null) throw new Error(`Section "${sectionKey}": ${label} declares both \`element\` and \`fields\` — the item is exactly one of the two.`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
-
import { isListFill } from "./fill-spec-view.js";
|
|
2
|
+
import { isListFill, plannedFieldsOf } from "./fill-spec-view.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/section-contracts/dist/name-title-contract.js
|
|
5
5
|
function assertNameTitleContract(schema, decision, sectionKey) {
|
|
@@ -7,7 +7,7 @@ function assertNameTitleContract(schema, decision, sectionKey) {
|
|
|
7
7
|
for (const slotId of decision.produces) {
|
|
8
8
|
const slot = schema.slots[slotId];
|
|
9
9
|
if (slot === void 0) continue;
|
|
10
|
-
const origination = originationFor(slot);
|
|
10
|
+
const origination = originationFor(slot, plannedFieldsOf(decision));
|
|
11
11
|
if (origination?.kind !== "keyed-rows" || origination.keys !== "written") continue;
|
|
12
12
|
const key = origination.keyField;
|
|
13
13
|
const where = `Section "${sectionKey}": list fill "${decision.id}" writes each row of "${slotId}" into "${key}"`;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { poolingPrimitiveOf } from "../../fill-vocabulary/dist/row-planners.js";
|
|
2
|
-
import {
|
|
2
|
+
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
3
|
+
import { isListFill, plannedFieldsOf } from "./fill-spec-view.js";
|
|
3
4
|
|
|
4
5
|
//#region ../../internal/section-contracts/dist/pooling-field-contract.js
|
|
5
6
|
function poolingDeclarationsOf(slot) {
|
|
@@ -11,6 +12,7 @@ function assertPoolingFieldContract(schema, decision, sectionKey) {
|
|
|
11
12
|
for (const slotId of decision.produces) {
|
|
12
13
|
const slot = schema.slots[slotId];
|
|
13
14
|
if (!slot) continue;
|
|
15
|
+
if (originationFor(slot, plannedFieldsOf(decision))?.kind === "filled-rows") continue;
|
|
14
16
|
const pooling = poolingDeclarationsOf(slot);
|
|
15
17
|
if (pooling.length > 1) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" produces "${slotId}", whose item declares ${pooling.length} pooled fields (${pooling.join(", ")}) — a record item carries at most one, since the pool it draws from IS where its rows come from. Bind all but one to a fact with \`source:\`, or split the list.`);
|
|
16
18
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { plannerForField } from "../../fill-vocabulary/dist/row-planners.js";
|
|
2
2
|
import { isListFill } from "./fill-spec-view.js";
|
|
3
|
+
import { rowReadFields } from "../../fill-vocabulary/dist/row-reads.js";
|
|
3
4
|
|
|
4
5
|
//#region ../../internal/section-contracts/dist/row-fill-contract.js
|
|
5
6
|
function assertRowFillContract(schema, decision, sectionKey) {
|
|
@@ -18,9 +19,22 @@ function assertRowFillContract(schema, decision, sectionKey) {
|
|
|
18
19
|
if (!rowField) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" field "${field}" is not a declared field of "${slotId}" (declared: ${declared.length > 0 ? declared.join(", ") : "none"}).`);
|
|
19
20
|
if (rowField.source) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" fills field "${field}" of "${slotId}", which is source-bound (source.kind "${rowField.source.kind ?? "?"}") — the fact bakes it; drop the decision.`);
|
|
20
21
|
if (plannerForField(rowField) === void 0) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" fills field "${field}" of "${slotId}" (type "${rowField.type}"), which no row can be filled with — a row field is written or picked inside the list's one batched call: text, a select key, an asset, or a list of text, keys or assets.`);
|
|
22
|
+
if (slot.source === void 0) {
|
|
23
|
+
const reads = fill.fields?.[field]?.reads;
|
|
24
|
+
assertEarlierRowReads(declared, field, reads, `Section "${sectionKey}": list fill "${decision.id}" field "${field}" of "${slotId}"`);
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
}
|
|
29
|
+
function assertEarlierRowReads(declared, field, reads, where) {
|
|
30
|
+
const position = declared.indexOf(field);
|
|
31
|
+
for (const read of rowReadFields(reads)) {
|
|
32
|
+
const at = declared.indexOf(read);
|
|
33
|
+
if (at === -1) throw new Error(`${where} reads row field "${read}", which the row does not declare (declared: ${declared.join(", ")}).`);
|
|
34
|
+
if (at === position) throw new Error(`${where} reads itself — a row fill reads only fields declared before it.`);
|
|
35
|
+
if (at > position) throw new Error(`${where} reads row field "${read}", declared after it — the model writes a row top to bottom, so a fill reads only earlier fields. Declare "${read}" first, or drop the read.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
24
38
|
|
|
25
39
|
//#endregion
|
|
26
40
|
export { assertRowFillContract };
|
|
@@ -15,7 +15,6 @@ import { assertRecordCollectionContract } from "./record-collection-contract.js"
|
|
|
15
15
|
import { assertOptionSourceContract } from "./option-source-contract.js";
|
|
16
16
|
import { assertPoiCurationContract } from "./poi-curation-contract.js";
|
|
17
17
|
import { assertPoolingFieldContract } from "./pooling-field-contract.js";
|
|
18
|
-
import { assertRowContract } from "./row-contract.js";
|
|
19
18
|
import { assertRowFillContract } from "./row-fill-contract.js";
|
|
20
19
|
import { assertSourceContract } from "./source-contract.js";
|
|
21
20
|
import { assertDisplayContract } from "./display-contract.js";
|
|
@@ -147,10 +146,6 @@ const CONTRACTS = {
|
|
|
147
146
|
group: {
|
|
148
147
|
implementation: bySection(({ key, schema }) => assertGroupContract(schema, key)),
|
|
149
148
|
assertions: [assertGroupContract]
|
|
150
|
-
},
|
|
151
|
-
row: {
|
|
152
|
-
implementation: bySection(({ key, schema }) => assertRowContract(schema, key)),
|
|
153
|
-
assertions: [assertRowContract]
|
|
154
149
|
}
|
|
155
150
|
};
|
|
156
151
|
function toSectionRunner(implementation) {
|