@homepages/concrete 6.1.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 +166 -0
- package/codemods/manifest.json +17 -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 +75 -32
- 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/display-evidence-contract.js +2 -1
- 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 +32 -17
- 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
|
@@ -1,46 +1,13 @@
|
|
|
1
|
-
import { CollectionField } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { CollectionRowValues } from "../schema/fact.js";
|
|
3
1
|
import { SectionSchemaShape } from "../schema/section-schema.js";
|
|
4
|
-
import {
|
|
2
|
+
import { SlotValue } from "../schema/section-props.js";
|
|
5
3
|
//#region src/primitives/slot-bindings.d.ts
|
|
6
4
|
/**
|
|
7
|
-
* The value shape a binding holds after bind-time normalization
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* A stored record list's row (`RowValue`) is closed: anything else on it is
|
|
12
|
-
* dropped. A record list bound whole-row to a collection
|
|
13
|
-
* (`source: fact.property.comparables`) is the other case, because a section's
|
|
14
|
-
* render receives bindings and nothing else: its bound row
|
|
15
|
-
* ({@link BoundBakedRow}) also keeps every member the platform bakes onto the
|
|
16
|
-
* row, so markup reads a comparable's `status` or `lat` off
|
|
17
|
-
* `slot.comps.value[n]` (or `bindItems(slot.comps)[n].value`) without
|
|
18
|
-
* declaring it as a row field.
|
|
19
|
-
*/
|
|
20
|
-
type BoundSlotValue<D> = D extends {
|
|
21
|
-
type: "list";
|
|
22
|
-
source: {
|
|
23
|
-
kind: "direct";
|
|
24
|
-
field: infer F extends CollectionField;
|
|
25
|
-
};
|
|
26
|
-
fields: infer I;
|
|
27
|
-
} ? BoundBakedRow<F, I>[] : D extends {
|
|
28
|
-
type: "list";
|
|
29
|
-
fields: infer I;
|
|
30
|
-
} ? RowValue<I>[] : SlotValue<D>;
|
|
31
|
-
type ProjectedImageListKeys<F extends CollectionField, I> = { [K in keyof I & keyof CollectionRowValues[F]]: I[K] extends {
|
|
32
|
-
type: "image";
|
|
33
|
-
} ? CollectionRowValues[F][K] extends readonly unknown[] ? K : never : never; }[keyof I & keyof CollectionRowValues[F]];
|
|
34
|
-
/**
|
|
35
|
-
* One bound row of a whole-row-baked record list: every member the collection projects
|
|
36
|
-
* onto each row whatever the slot declares (a unit's or comparable's whole record, a
|
|
37
|
-
* contact's `id` alone), with each DECLARED field at its normalized kind — except a declared
|
|
38
|
-
* `image` field the projection carries as a list (a unit's `floor_plans`, its ordered
|
|
39
|
-
* floor-plan assignments), which keeps the projection's list. That field's own
|
|
40
|
-
* `FieldBinding` still holds the `image` kind's value, so the primitives read it
|
|
41
|
-
* exactly as before.
|
|
5
|
+
* The value shape a binding holds after bind-time normalization — the slot's own
|
|
6
|
+
* `SlotValue`. A record list's bound row is its identity plus each DECLARED field
|
|
7
|
+
* normalized by its definition, and nothing else: a member no field declares is not
|
|
8
|
+
* on the row, whether the row was stored or baked from a collection.
|
|
42
9
|
*/
|
|
43
|
-
type
|
|
10
|
+
type BoundSlotValue<D> = SlotValue<D>;
|
|
44
11
|
/**
|
|
45
12
|
* One slot: its id, the definition the section declared for it, and its runtime value.
|
|
46
13
|
*
|
|
@@ -120,4 +87,4 @@ declare function bindItems<D extends {
|
|
|
120
87
|
type: "list";
|
|
121
88
|
}>(binding: SlotBinding<D> | FieldBinding<D>): ItemBinding<D>[];
|
|
122
89
|
//#endregion
|
|
123
|
-
export {
|
|
90
|
+
export { BoundSlotValue, FieldBinding, ItemBinding, RowBinding, SlotBinding, SlotBindingMap, bindItems };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { acceptsLink } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
1
|
+
import { COLLECTIONS, acceptsLink } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
2
|
|
|
3
3
|
//#region src/primitives/slot-bindings.ts
|
|
4
4
|
const blankVideo = () => ({
|
|
@@ -70,18 +70,16 @@ function normalizeTour(value) {
|
|
|
70
70
|
alt: stringField(value.alt)
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function normalizeRow(fields, row,
|
|
73
|
+
function normalizeRow(fields, row, idKey) {
|
|
74
74
|
const source = isRecord(row) ? row : {};
|
|
75
|
-
const normalized = {
|
|
76
|
-
|
|
77
|
-
id: stringField(source.id)
|
|
78
|
-
};
|
|
79
|
-
for (const [field, def] of Object.entries(fields)) {
|
|
80
|
-
const value = source[field];
|
|
81
|
-
normalized[field] = def.type === "image" && Array.isArray(value) ? value.filter(isRecord) : normalizeValue(def, value);
|
|
82
|
-
}
|
|
75
|
+
const normalized = { [idKey]: stringField(source[idKey]) };
|
|
76
|
+
for (const [field, def] of Object.entries(fields)) normalized[field] = normalizeValue(def, source[field]);
|
|
83
77
|
return normalized;
|
|
84
78
|
}
|
|
79
|
+
function rowIdKey(source) {
|
|
80
|
+
if (!isRecord(source) || source.kind !== "direct" || typeof source.field !== "string") return "id";
|
|
81
|
+
return Object.hasOwn(COLLECTIONS, source.field) ? COLLECTIONS[source.field].idKey : "id";
|
|
82
|
+
}
|
|
85
83
|
function normalizeValue(def, value) {
|
|
86
84
|
const slot = def;
|
|
87
85
|
switch (slot.type) {
|
|
@@ -98,8 +96,8 @@ function normalizeValue(def, value) {
|
|
|
98
96
|
if (!Array.isArray(value)) return [];
|
|
99
97
|
if (isRecord(slot.fields)) {
|
|
100
98
|
const fields = slot.fields;
|
|
101
|
-
const
|
|
102
|
-
return value.map((row) => normalizeRow(fields, row,
|
|
99
|
+
const idKey = rowIdKey(slot.source);
|
|
100
|
+
return value.map((row) => normalizeRow(fields, row, idKey));
|
|
103
101
|
}
|
|
104
102
|
if (slot.element == null) return value;
|
|
105
103
|
const element = slot.element;
|
|
@@ -4,7 +4,7 @@ import { DisplayEntryInput } from "./slot-builders.js";
|
|
|
4
4
|
//#region src/schema/define-schema.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* The authored `display:` block: section `visibility` and `variant`, each an
|
|
7
|
-
* optional entry built by
|
|
7
|
+
* optional entry built by `select({ options: cases, … })` with no `label`. Omitting
|
|
8
8
|
* the block, or either entry, reproduces the defaults — always shown, no
|
|
9
9
|
* variant.
|
|
10
10
|
*/
|
|
@@ -29,39 +29,42 @@ function siblingResolver(sectionKey, slots) {
|
|
|
29
29
|
};
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
const binding = getFill(slot);
|
|
32
|
+
function resolveBindingReads(at, binding, resolveReads) {
|
|
34
33
|
const reads = binding?.reads;
|
|
35
|
-
if (binding === void 0 || reads === void 0 || !reads.some(isSiblingSlot)) return
|
|
34
|
+
if (binding === void 0 || reads === void 0 || !reads.some(isSiblingSlot)) return binding;
|
|
36
35
|
const resolved = resolveReads(at, reads) ?? [];
|
|
37
36
|
const upstream = resolved[reads.findIndex((read) => isSiblingSlot(read) && read.source !== void 0)];
|
|
38
37
|
if (upstream !== void 0 && isSlotRef(upstream)) throw new Error(`\`${at}\` is filled and reads its sibling slot "${upstream.slot}", which is sourced — a fact, a \`compute()\` or another slot settles it, not a fill. A sourced value settles at finalize, AFTER every fill has run, so the fill would read nothing. Read the refs that slot reads instead, or read a slot a fill writes.`);
|
|
39
38
|
const sibling = resolved[reads.findIndex(isSiblingSlot)];
|
|
40
39
|
const section = sibling !== void 0 && isSlotRef(sibling) ? sibling.section : void 0;
|
|
41
40
|
return {
|
|
41
|
+
...binding,
|
|
42
|
+
reads: resolved,
|
|
43
|
+
[FILL_SECTION]: section
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function resolveFillReads(at, slot, resolveReads) {
|
|
47
|
+
const binding = getFill(slot);
|
|
48
|
+
const resolved = resolveBindingReads(at, binding, resolveReads);
|
|
49
|
+
return resolved === binding ? slot : {
|
|
42
50
|
...slot,
|
|
43
|
-
[FILL]:
|
|
44
|
-
...binding,
|
|
45
|
-
reads: resolved,
|
|
46
|
-
[FILL_SECTION]: section
|
|
47
|
-
}
|
|
51
|
+
[FILL]: resolved
|
|
48
52
|
};
|
|
49
53
|
}
|
|
50
|
-
function emitDisplay(display, computed) {
|
|
54
|
+
function emitDisplay(display, computed, resolveReads) {
|
|
51
55
|
const out = {};
|
|
52
56
|
for (const key of ["visibility", "variant"]) {
|
|
53
57
|
const entry = display[key];
|
|
54
58
|
if (entry === void 0) continue;
|
|
59
|
+
const at = `display.${key}`;
|
|
55
60
|
const emitted = { cases: [...entry.cases] };
|
|
56
61
|
if (entry.locked === true) emitted.locked = true;
|
|
57
|
-
const sibling = entry.source?.reads?.find(isSiblingSlot);
|
|
58
|
-
if (sibling !== void 0) throw new Error(`\`display.${key}\` reads the section's own slot "${sibling.label}". A display entry settles which of the section's slots exist, so it may read facts and other sections only.`);
|
|
59
62
|
if (isComputeBinding(entry.source)) {
|
|
60
|
-
computed[
|
|
61
|
-
emitted.source = derivedSource(
|
|
63
|
+
computed[at] = entry.source.fn;
|
|
64
|
+
emitted.source = derivedSource(at, resolveReads(at, entry.source.reads));
|
|
62
65
|
} else if (isFillBinding(entry.source)) emitted.fill = {
|
|
63
66
|
pick: entry.source.brief,
|
|
64
|
-
...fillMark(entry.source)
|
|
67
|
+
...fillMark(resolveBindingReads(at, entry.source, resolveReads))
|
|
65
68
|
};
|
|
66
69
|
else if (entry.source !== void 0) emitted.source = entry.source;
|
|
67
70
|
out[key] = emitted;
|
|
@@ -70,19 +73,31 @@ function emitDisplay(display, computed) {
|
|
|
70
73
|
}
|
|
71
74
|
function defineSchema(input) {
|
|
72
75
|
const computed = {};
|
|
76
|
+
const resolveReads = siblingResolver(input.key, input.slots);
|
|
73
77
|
const meta = {
|
|
74
78
|
displayName: input.label,
|
|
75
79
|
...input.anchor !== void 0 ? { anchor: input.anchor } : {},
|
|
76
|
-
...input.display !== void 0 ? { display: emitDisplay(input.display, computed) } : {},
|
|
80
|
+
...input.display !== void 0 ? { display: emitDisplay(input.display, computed, resolveReads) } : {},
|
|
77
81
|
...input.layout !== void 0 ? { groups: groupsFromLayout(input.layout) } : {}
|
|
78
82
|
};
|
|
79
83
|
const slots = {};
|
|
80
|
-
const resolveReads = siblingResolver(input.key, input.slots);
|
|
81
84
|
for (const [key, slot] of Object.entries(input.slots)) {
|
|
85
|
+
if (slot.type !== "list" && slot.unique !== void 0) throw new Error(`defineSchema: slot "${key}" declares \`unique\` — it is legal only inside a list, on its item or a row field.`);
|
|
82
86
|
let emitted = resolveFillReads(key, slot, resolveReads);
|
|
83
87
|
const fields = emitted.fields;
|
|
84
88
|
if (emitted.type === "list" && fields !== void 0) {
|
|
85
|
-
const resolvedFields = Object.fromEntries(Object.entries(fields).map(([field, def]) =>
|
|
89
|
+
const resolvedFields = Object.fromEntries(Object.entries(fields).map(([field, def]) => {
|
|
90
|
+
const at = `${key}.${field}`;
|
|
91
|
+
let resolved = resolveFillReads(at, def, resolveReads);
|
|
92
|
+
if (isComputeBinding(def.source)) {
|
|
93
|
+
computed[at] = def.source.fn;
|
|
94
|
+
resolved = {
|
|
95
|
+
...resolved,
|
|
96
|
+
source: derivedSource(at, resolveReads(at, def.source.reads))
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return [field, resolved];
|
|
100
|
+
}));
|
|
86
101
|
if (Object.keys(fields).some((field) => resolvedFields[field] !== fields[field])) emitted = {
|
|
87
102
|
...emitted,
|
|
88
103
|
fields: resolvedFields
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DISPLAY_ENTRIES } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
2
|
import { getFill, getFillSection } from "./fill-declaration.js";
|
|
3
|
-
import { isSiblingSlot, serializeRef } from "./slot-ref.js";
|
|
3
|
+
import { isSerializedSlotRef, isSiblingSlot, serializeRef } from "./slot-ref.js";
|
|
4
4
|
import { byCodeUnit } from "../platform/order.js";
|
|
5
5
|
import { plannerForField } from "../packages/internal/fill-vocabulary/dist/row-planners.js";
|
|
6
6
|
import { isListSlot, originationFor } from "../packages/internal/fill-vocabulary/dist/origination.js";
|
|
@@ -31,31 +31,33 @@ function serializedReads(reads) {
|
|
|
31
31
|
function collectReads(into, binding) {
|
|
32
32
|
const ownSection = getFillSection(binding);
|
|
33
33
|
for (const read of serializedReads(binding?.reads)) if (read.kind === "fact") into.facts.add(read.key);
|
|
34
|
-
else if (read.section !== ownSection) into.slots.set(`${read.section} ${read.slot}`, read);
|
|
34
|
+
else if (isSerializedSlotRef(read) && read.section !== ownSection) into.slots.set(`${read.section} ${read.slot}`, read);
|
|
35
35
|
}
|
|
36
36
|
function editorPickedOrigin(slot) {
|
|
37
37
|
return slot.type === "poi";
|
|
38
38
|
}
|
|
39
39
|
function assertOrigin(key, slot) {
|
|
40
|
-
if (slot.source !== void 0) return;
|
|
40
|
+
if (slot.source !== void 0 || getFill(slot) !== void 0) return;
|
|
41
41
|
if (editorPickedOrigin(slot)) return;
|
|
42
42
|
throw new Error(`fillSpecFromSchema: slot "${key}" declares no \`source:\` — nothing would ever write it. Bind it to a fact or a slot, \`compute()\` it, or \`fill()\` it.`);
|
|
43
43
|
}
|
|
44
|
+
function assertRowOrigins(key, slot) {
|
|
45
|
+
for (const [fieldKey, field] of Object.entries(slot.fields ?? {})) {
|
|
46
|
+
if (field.source !== void 0 || getFill(field) !== void 0) continue;
|
|
47
|
+
throw new Error(`fillSpecFromSchema: row field "${key}.${fieldKey}" declares no \`source:\` — nothing would ever write it. Bind it to a member of the row (\`row.<member>\`), \`compute()\` it, or \`fill()\` it.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
44
50
|
function unkeyedMessage(key, origination) {
|
|
45
51
|
if (origination.pools.length > 1) return `fillSpecFromSchema: record slot "${key}" pools rows from ${origination.pools.map((p) => `"${p}"`).join(" and ")} — a filled record list picks its rows out of ONE asset field, so bind the others with \`source:\` or drop them.`;
|
|
46
|
-
if (origination.title !== void 0) return `fillSpecFromSchema: record slot "${key}" is titled by "${origination.title}"` + (origination.titleType === void 0 ? ", which is not a field of the row" : `, a ${origination.titleType} field`) + " — a filled record list is keyed on its `title:` field, which must be a `text` field the model writes or a `select
|
|
47
|
-
return `fillSpecFromSchema: record slot "${key}" has no field to key its rows on — title the list by the \`text\` field that names a row, give the row exactly one \`select
|
|
52
|
+
if (origination.title !== void 0) return `fillSpecFromSchema: record slot "${key}" is titled by "${origination.title}"` + (origination.titleType === void 0 ? ", which is not a field of the row" : `, a ${origination.titleType} field`) + " — a filled record list is keyed on its `title:` field, which must be a `text` field the model writes or a `select({ options })` it picks from.";
|
|
53
|
+
return `fillSpecFromSchema: record slot "${key}" has no field to key its rows on — title the list by the \`text\` field that names a row, give the row exactly one \`select({ options })\` field, or give it one unbound \`image\`/\`video\`/\`tour\`/\`document\` field to pick rows from.`;
|
|
48
54
|
}
|
|
49
55
|
function rowFieldDecision(key, fieldKey, field, binding) {
|
|
50
56
|
if (plannerForField(field) === void 0) throw new Error(`fillSpecFromSchema: row field "${key}.${fieldKey}" (type "${String(field.type)}") is filled, but a row cannot fill one — a row field is written or picked inside the list's one batched call, which plans text, a select key, an asset, or a list of text, keys or assets.`);
|
|
51
57
|
return optionsOf(binding);
|
|
52
58
|
}
|
|
53
|
-
function assertKeyFieldTakesNoFill(key, slot, origination) {
|
|
54
|
-
if (origination.kind !== "keyed-rows" || origination.keys !== "written") return;
|
|
55
|
-
if (getFill(slot.fields?.[origination.keyField]) === void 0) return;
|
|
56
|
-
throw new Error(`fillSpecFromSchema: slot "${key}" keys rows by "${origination.keyField}", which is filled itself — the list's own fill writes each row's name into that field, so drop the field's fill and say the name's shape in the list's brief.`);
|
|
57
|
-
}
|
|
58
59
|
function recordListDecision(key, slot, reads) {
|
|
60
|
+
assertRowOrigins(key, slot);
|
|
59
61
|
const fields = {};
|
|
60
62
|
for (const [fieldKey, rowField] of Object.entries(slot.fields ?? {})) {
|
|
61
63
|
const binding = getFill(rowField);
|
|
@@ -69,7 +71,7 @@ function recordListDecision(key, slot, reads) {
|
|
|
69
71
|
assertOrigin(key, slot);
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
|
-
const origination = originationFor(slot);
|
|
74
|
+
const origination = originationFor(slot, Object.keys(fields));
|
|
73
75
|
if (binding === void 0) {
|
|
74
76
|
if (origination?.kind === "bound-rows") return {
|
|
75
77
|
id: key,
|
|
@@ -81,7 +83,6 @@ function recordListDecision(key, slot, reads) {
|
|
|
81
83
|
}
|
|
82
84
|
if (origination?.kind === "unkeyed-rows") throw new Error(unkeyedMessage(key, origination));
|
|
83
85
|
if (origination === void 0) throw new Error(`fillSpecFromSchema: record slot "${key}" originates no rows.`);
|
|
84
|
-
assertKeyFieldTakesNoFill(key, slot, origination);
|
|
85
86
|
return {
|
|
86
87
|
id: key,
|
|
87
88
|
kind: "list",
|
|
@@ -115,7 +116,8 @@ function displayDecision(schema, reads) {
|
|
|
115
116
|
for (const entry of entries) {
|
|
116
117
|
const binding = getFill(display[entry]?.fill);
|
|
117
118
|
collectReads(reads, binding);
|
|
118
|
-
for (const read of serializedReads(binding?.reads))
|
|
119
|
+
for (const read of serializedReads(binding?.reads)) if (read.kind === "fact") declared.set(`fact ${read.key}`, read);
|
|
120
|
+
else if (isSerializedSlotRef(read)) declared.set(`slot ${read.section} ${read.slot}`, read);
|
|
119
121
|
}
|
|
120
122
|
if (DISPLAY_DECISION_ID in schema.slots) throw new Error(`fillSpecFromSchema: slot "${DISPLAY_DECISION_ID}" collides with the decision id reserved for \`meta.display\`'s own fill — rename the slot.`);
|
|
121
123
|
return {
|
package/dist/schema/fact.d.ts
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
import { FACT_GRAPH, FactGraphName, SOURCE_FIELDS, SourceFieldContainer, SourceFieldName } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { FactValue } from "../packages/internal/template-contracts/dist/facts-view.js";
|
|
3
|
-
import { ComparableRow, UnitRow } from "./property-facts.js";
|
|
4
|
-
import { ContactRow } from "./runtime-values.js";
|
|
5
2
|
import { FactRef } from "./slot-ref.js";
|
|
3
|
+
import { FactValue } from "../packages/internal/template-contracts/dist/facts-view.js";
|
|
6
4
|
//#region src/schema/fact.d.ts
|
|
7
5
|
type SourceFields = typeof SOURCE_FIELDS;
|
|
8
6
|
type Graph = typeof FACT_GRAPH;
|
|
9
|
-
/**
|
|
10
|
-
* The members each bakeable fact array projects onto every row, whatever the
|
|
11
|
-
* slot declares — one entry per collection a record list may bind whole-row
|
|
12
|
-
* (`source: fact.property.units` / `fact.property.contacts`). `SlotValue` uses
|
|
13
|
-
* the bound collection's entry as the base row type for such a slot and adds
|
|
14
|
-
* the declared fields the base does not carry, so `SectionProps` types its rows
|
|
15
|
-
* as the projection the renderer actually receives. A unit or comparable row
|
|
16
|
-
* carries its whole record; a contact row carries only its `id`, every other
|
|
17
|
-
* member being a declared field.
|
|
18
|
-
*/
|
|
19
|
-
type CollectionRowValues = {
|
|
20
|
-
units: UnitRow;
|
|
21
|
-
contacts: ContactRow;
|
|
22
|
-
comparables: ComparableRow;
|
|
23
|
-
};
|
|
24
7
|
/**
|
|
25
8
|
* A slot's `direct` binding: the canonical field itself, writable when the catalog
|
|
26
9
|
* gives it a writeback — and a typed {@link FactRef} on the very same two runtime
|
|
@@ -77,4 +60,4 @@ type FactNamespace = { [C in SourceFieldContainer]: FieldsIn<C> & ProjectionsIn<
|
|
|
77
60
|
*/
|
|
78
61
|
declare const fact: FactNamespace;
|
|
79
62
|
//#endregion
|
|
80
|
-
export {
|
|
63
|
+
export { DerivedFactRef, DirectFactRef, FactNamespace, fact };
|
|
@@ -71,8 +71,8 @@ type NoOtherKeys<O> = { [K in Exclude<keyof O, keyof FillInput>]: never; };
|
|
|
71
71
|
/**
|
|
72
72
|
* The model produces this slot's value, once, from `brief` and exactly the refs in
|
|
73
73
|
* `reads`. What it does is the slot's own fact — a `text` slot is written, an
|
|
74
|
-
* `image` picked from the property's photos, a `list
|
|
75
|
-
* a record list
|
|
74
|
+
* `image` picked from the property's photos, a `list({ item: image() })` a subset of them,
|
|
75
|
+
* a record list's set of rows, each row field then filled by its own `fill()` — so one builder
|
|
76
76
|
* serves every slot, and only the options differ:
|
|
77
77
|
*
|
|
78
78
|
* | Option | Legal on |
|
|
@@ -99,9 +99,10 @@ type NoOtherKeys<O> = { [K in Exclude<keyof O, keyof FillInput>]: never; };
|
|
|
99
99
|
* }),
|
|
100
100
|
* });
|
|
101
101
|
*
|
|
102
|
-
* list
|
|
102
|
+
* list({
|
|
103
103
|
* label: "Gallery",
|
|
104
104
|
* max: 8,
|
|
105
|
+
* item: image({ label: "Photo" }),
|
|
105
106
|
* source: fill({
|
|
106
107
|
* brief: "Every photograph of the property, ordered as a walk through it. Drop anything that is not a photograph of the property; when nothing is, produce nothing.",
|
|
107
108
|
* none: true,
|
package/dist/schema/fill-spec.js
CHANGED
|
@@ -11,7 +11,15 @@ const FactReadRef = z.object({
|
|
|
11
11
|
kind: z.literal("fact"),
|
|
12
12
|
key: z.string().min(1)
|
|
13
13
|
}).strict();
|
|
14
|
-
const
|
|
14
|
+
const RowReadRef = z.object({
|
|
15
|
+
kind: z.literal("row"),
|
|
16
|
+
field: z.string().min(1)
|
|
17
|
+
}).strict();
|
|
18
|
+
const DecisionReads = z.array(z.union([
|
|
19
|
+
FactReadRef,
|
|
20
|
+
RowReadRef,
|
|
21
|
+
SlotReadRef
|
|
22
|
+
])).min(1).optional();
|
|
15
23
|
const Brief = z.string().min(1);
|
|
16
24
|
const Abstention = z.literal(true).optional();
|
|
17
25
|
const Count = z.union([
|
package/dist/schema/layout.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
//#region src/schema/layout.d.ts
|
|
2
|
-
/** One layout row: a slot key (full-width) or a `[a, b]` 2-up pair, keyed to real slots. */
|
|
3
|
-
type LayoutRow<K extends string> = K | readonly [K, K];
|
|
4
2
|
/**
|
|
5
3
|
* A sidebar grouping card produced by `group(...)`. Structurally an object, so it
|
|
6
|
-
* is distinguishable at runtime from a bare
|
|
4
|
+
* is distinguishable at runtime from a bare slot key.
|
|
7
5
|
*
|
|
8
6
|
* `Id` is always a literal: `group` takes the id as its first argument, so every
|
|
9
7
|
* card's id is known at compile time — that literal is the key a Renderer reads
|
|
@@ -12,10 +10,10 @@ type LayoutRow<K extends string> = K | readonly [K, K];
|
|
|
12
10
|
interface GroupCard<K extends string, Id extends string = string> {
|
|
13
11
|
id: Id;
|
|
14
12
|
label: string;
|
|
15
|
-
members: readonly
|
|
13
|
+
members: readonly K[];
|
|
16
14
|
}
|
|
17
|
-
/** A section-level layout entry: a bare
|
|
18
|
-
type SectionLayoutEntry<K extends string> =
|
|
15
|
+
/** A section-level layout entry: a bare slot key or a `group(...)` card. */
|
|
16
|
+
type SectionLayoutEntry<K extends string> = K | GroupCard<K>;
|
|
19
17
|
/**
|
|
20
18
|
* One `meta.groups` entry as emitted from a `group(...)` card: `SlotGroupDefShape`
|
|
21
19
|
* with the card's id kept literal. That literal is what keeps `bindGroups` over a
|
|
@@ -24,9 +22,9 @@ type SectionLayoutEntry<K extends string> = LayoutRow<K> | GroupCard<K>;
|
|
|
24
22
|
interface GroupDefOf<Id extends string> {
|
|
25
23
|
id: Id;
|
|
26
24
|
label: string;
|
|
27
|
-
members:
|
|
25
|
+
members: string[];
|
|
28
26
|
}
|
|
29
27
|
/** The union of group ids a section layout declares; `never` when it holds no cards. */
|
|
30
28
|
type GroupIdsOfLayout<L extends readonly unknown[]> = Extract<L[number], GroupCard<string, string>>["id"];
|
|
31
29
|
//#endregion
|
|
32
|
-
export { GroupCard, GroupDefOf, GroupIdsOfLayout,
|
|
30
|
+
export { GroupCard, GroupDefOf, GroupIdsOfLayout, SectionLayoutEntry };
|
package/dist/schema/layout.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
//#region src/schema/layout.ts
|
|
2
2
|
function isGroupCard(entry) {
|
|
3
|
-
return typeof entry === "object" && entry !== null
|
|
3
|
+
return typeof entry === "object" && entry !== null;
|
|
4
4
|
}
|
|
5
5
|
function groupsFromLayout(layout) {
|
|
6
6
|
return layout.filter(isGroupCard).map((card) => ({
|
|
7
7
|
id: card.id,
|
|
8
8
|
label: card.label,
|
|
9
|
-
members:
|
|
9
|
+
members: [...card.members]
|
|
10
10
|
}));
|
|
11
11
|
}
|
|
12
|
-
function itemLayoutFromRows(rows) {
|
|
13
|
-
return toMembers(rows);
|
|
14
|
-
}
|
|
15
|
-
function toMembers(rows) {
|
|
16
|
-
return rows.map((row) => typeof row === "string" ? row : [row[0], row[1]]);
|
|
17
|
-
}
|
|
18
12
|
|
|
19
13
|
//#endregion
|
|
20
|
-
export { groupsFromLayout
|
|
14
|
+
export { groupsFromLayout };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ResponsiveImage } from "../packages/internal/image-descriptor/dist/index.js";
|
|
2
1
|
//#region src/schema/property-facts.d.ts
|
|
3
2
|
/** A geocoded point: latitude and longitude. */
|
|
4
3
|
type Coordinates = {
|
|
@@ -7,53 +6,20 @@ type Coordinates = {
|
|
|
7
6
|
};
|
|
8
7
|
/**
|
|
9
8
|
* The property's always-on prose description — the substrate every text
|
|
10
|
-
* decision is grounded in, and a fact a `compute()` reads directly.
|
|
11
|
-
*
|
|
12
|
-
* yet), never a placeholder.
|
|
9
|
+
* decision is grounded in, and a fact a `compute()` reads directly. `""` is a
|
|
10
|
+
* real state (nothing written yet), never a placeholder.
|
|
13
11
|
*/
|
|
14
12
|
type Narrative = {
|
|
15
13
|
description: string;
|
|
16
14
|
};
|
|
17
|
-
/**
|
|
18
|
-
* One floor plan attached to a unit, in the fixture/render-time view.
|
|
19
|
-
* `url`/`alt`/`responsive` are ATTACHED at render time by a resolution step —
|
|
20
|
-
* absent here means "not yet resolved", never "no plan".
|
|
21
|
-
*/
|
|
22
|
-
type FloorplanAssignment = {
|
|
23
|
-
id: string;
|
|
24
|
-
upload_id?: string;
|
|
25
|
-
url?: string;
|
|
26
|
-
alt?: string;
|
|
27
|
-
floor_label: string | null;
|
|
28
|
-
position: number;
|
|
29
|
-
responsive?: ResponsiveImage | null;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* One property unit in the fixture/render-time view: its scalar facts plus
|
|
33
|
-
* its AI-generated `description`/`features` — baked into content by the
|
|
34
|
-
* floorplan section's per-unit fill decision, not aggregated from any
|
|
35
|
-
* canonical field — and its attached `floor_plans`.
|
|
36
|
-
*/
|
|
37
|
-
type UnitRow = {
|
|
38
|
-
unit_id: string;
|
|
39
|
-
unit_label: string | null;
|
|
40
|
-
beds: number | null;
|
|
41
|
-
baths: number | null;
|
|
42
|
-
sqft: number | null;
|
|
43
|
-
price: string | null;
|
|
44
|
-
description: string | null;
|
|
45
|
-
features: string[];
|
|
46
|
-
position: number;
|
|
47
|
-
floor_plans: FloorplanAssignment[];
|
|
48
|
-
};
|
|
49
15
|
/**
|
|
50
16
|
* One comparable property — a recently sold or currently listed home similar
|
|
51
|
-
* to the subject — as the canonical fact bundle carries it
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
17
|
+
* to the subject — as the canonical fact bundle carries it: the row a
|
|
18
|
+
* `compute()` reading `fact.property.comparables` derives market numbers from.
|
|
19
|
+
* Not a bound record list's row, which is its `id` plus the fields the list
|
|
20
|
+
* declares. `address`, `distance_m` and `price_period` are the three members
|
|
55
21
|
* the live projection derives (the display line, meters from the subject, and
|
|
56
|
-
* what the price is denominated in)
|
|
22
|
+
* what the price is denominated in).
|
|
57
23
|
*/
|
|
58
24
|
type ComparableRow = {
|
|
59
25
|
id: string;
|
|
@@ -75,9 +41,14 @@ type ComparableRow = {
|
|
|
75
41
|
beds: number | null;
|
|
76
42
|
baths: number | null;
|
|
77
43
|
sqft: number | null;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The comp's photo: the id of an upload the comparable itself owns — never one of the
|
|
46
|
+
* property's own photos, so no media pool offers it. `null` when none was uploaded. A
|
|
47
|
+
* section draws it through an `image` value built from the id,
|
|
48
|
+
* `{ photo_id: comp.photo_upload_id, url: "", alt: comp.address }`, and the render
|
|
49
|
+
* attaches the served URL and ladder by `photo_id`, as it does for any image.
|
|
50
|
+
*/
|
|
51
|
+
photo_upload_id: string | null;
|
|
81
52
|
/** The year the comparable was built. */
|
|
82
53
|
year_built?: number | null;
|
|
83
54
|
/** Lot size in square feet. */
|
|
@@ -87,8 +58,6 @@ type ComparableRow = {
|
|
|
87
58
|
units?: number | null;
|
|
88
59
|
/** Monthly HOA dues in dollars. */
|
|
89
60
|
hoa_monthly?: number | null;
|
|
90
|
-
/** How long the listing has been up. Live listings only; null on a closed sale. */
|
|
91
|
-
days_on_market?: number | null;
|
|
92
61
|
/** The asking price in dollars, beside `price` — the pair is what "sold over asking" reads. */
|
|
93
62
|
list_price?: number | null;
|
|
94
63
|
/** ISO `YYYY-MM-DD` — when the listing went live, not when it closed. */
|
|
@@ -100,4 +69,4 @@ type ComparableRow = {
|
|
|
100
69
|
property_type?: "single_family" | "condo_townhome" | "multi_family" | "investment" | null;
|
|
101
70
|
};
|
|
102
71
|
//#endregion
|
|
103
|
-
export { ComparableRow, Coordinates,
|
|
72
|
+
export { ComparableRow, Coordinates, Narrative };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { isComputeBinding } from "./compute.js";
|
|
2
|
+
import { FILL, getFill } from "./fill-declaration.js";
|
|
3
|
+
import { isFactRef, isRowRef } from "./slot-ref.js";
|
|
4
|
+
import { boundCollection, collectionMembers } from "./row-ref.js";
|
|
5
|
+
|
|
6
|
+
//#region src/schema/row-fields.ts
|
|
7
|
+
function rowKindOf(source) {
|
|
8
|
+
if (boundCollection(source) !== void 0) return "collection";
|
|
9
|
+
if (source === void 0 || getFillLike(source)) return "own";
|
|
10
|
+
return "value";
|
|
11
|
+
}
|
|
12
|
+
function getFillLike(source) {
|
|
13
|
+
return typeof source === "object" && source !== null && source.kind === "fill";
|
|
14
|
+
}
|
|
15
|
+
function resolveRead(at, read, r, filled) {
|
|
16
|
+
const own = r.byConst.get(read);
|
|
17
|
+
if (own === void 0) return read;
|
|
18
|
+
if (r.rowKind !== "own") throw new Error(`list: row field "${r.list}.${at.key}" reads the row's field "${own.key}" — a row whose source is a collection, a \`compute()\` or a slot offers its members, so read the member \`row.<member>\` instead.`);
|
|
19
|
+
if (own.index >= at.index) {
|
|
20
|
+
const which = own.index === at.index ? "itself" : `"${own.key}", which comes after it`;
|
|
21
|
+
throw new Error(`list: row field "${r.list}.${at.key}" reads ${which} — a row is filled top to bottom in one call, so a field reads only the fields declared before it.`);
|
|
22
|
+
}
|
|
23
|
+
if (filled && own.field.source !== void 0) throw new Error(`list: row field "${r.list}.${at.key}" is filled and reads "${own.key}", which is sourced — a sourced field settles after every fill has run, so the fill would read nothing. Read what that field reads instead.`);
|
|
24
|
+
return {
|
|
25
|
+
kind: "row",
|
|
26
|
+
field: own.key
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function resolveReads(at, reads, r, filled) {
|
|
30
|
+
if (!reads.some((read) => r.byConst.has(read))) return void 0;
|
|
31
|
+
return reads.map((read) => resolveRead(at, read, r, filled));
|
|
32
|
+
}
|
|
33
|
+
function assertRowOrigin(at, field, r) {
|
|
34
|
+
const source = field.source;
|
|
35
|
+
if (isFactRef(source)) throw new Error(`list: row field "${at}" is bound to the fact "${source.field}", which is the same value in every row — bind the row's own member (\`row.<member>\`) instead; \`fact.unit.*\` and \`fact.contact.*\` name the primary row. A property fact belongs in the field's \`fill()\` or \`compute()\` \`reads\`.`);
|
|
36
|
+
if (!isRowRef(source)) return;
|
|
37
|
+
if (r.rowKind === "own") throw new Error(`list: row field "${at}" is bound to the row member "${source.field}", but an AI-built row has no members — fill the field.`);
|
|
38
|
+
}
|
|
39
|
+
function resolveRowFields(list, source, declared) {
|
|
40
|
+
const entries = Object.entries(declared);
|
|
41
|
+
const byConst = new Map(entries.map(([key, field], index) => [field, {
|
|
42
|
+
key,
|
|
43
|
+
index,
|
|
44
|
+
field
|
|
45
|
+
}]));
|
|
46
|
+
const r = {
|
|
47
|
+
list,
|
|
48
|
+
rowKind: rowKindOf(source),
|
|
49
|
+
byConst
|
|
50
|
+
};
|
|
51
|
+
const members = boundCollection(source);
|
|
52
|
+
const offered = members === void 0 ? void 0 : new Set(collectionMembers(members));
|
|
53
|
+
const out = {};
|
|
54
|
+
entries.forEach(([key, field], index) => {
|
|
55
|
+
const at = {
|
|
56
|
+
key,
|
|
57
|
+
index
|
|
58
|
+
};
|
|
59
|
+
assertRowOrigin(`${list}.${key}`, field, r);
|
|
60
|
+
const source = field.source;
|
|
61
|
+
if (offered !== void 0 && isRowRef(source) && !offered.has(source.field)) throw new Error(`list: row field "${list}.${key}" is bound to "${source.field}", which is not a member of the list's row.`);
|
|
62
|
+
let resolved = field;
|
|
63
|
+
const binding = getFill(field);
|
|
64
|
+
const fillReads = binding?.reads === void 0 ? void 0 : resolveReads(at, binding.reads, r, true);
|
|
65
|
+
if (fillReads !== void 0) resolved = {
|
|
66
|
+
...resolved,
|
|
67
|
+
[FILL]: {
|
|
68
|
+
...binding,
|
|
69
|
+
reads: fillReads
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
if (isComputeBinding(source)) {
|
|
73
|
+
const computeReads = resolveReads(at, source.reads, r, false);
|
|
74
|
+
if (computeReads !== void 0) resolved = {
|
|
75
|
+
...resolved,
|
|
76
|
+
source: {
|
|
77
|
+
...source,
|
|
78
|
+
reads: computeReads
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
out[key] = resolved;
|
|
83
|
+
});
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
export { resolveRowFields };
|