@homepages/concrete 7.0.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 +19 -0
- package/codemods/manifest.json +6 -0
- package/dist/artifact/playground/client/assets/{index-D8eepVr-.js → index-Dn_xT16-.js} +115 -115
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +7 -7
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +5 -6
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +2 -62
- package/dist/packages/internal/section-contracts/dist/catalog.js +2 -18
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -0
- package/dist/packages/internal/section-contracts/dist/index.js +0 -4
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +15 -6
- package/dist/packages/internal/section-contracts/dist/runners.js +3 -23
- package/dist/packages/internal/section-contracts/dist/source-contract.js +21 -24
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +8 -4
- package/dist/packages/internal/source-resolution/dist/index.js +3 -49
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +2 -12
- package/dist/packages/internal/template-contracts/dist/facts-view.js +4 -11
- package/dist/packages/internal/template-contracts/dist/row-sources.js +1 -7
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1 -5
- package/dist/schema/extract-fill-spec.js +2 -7
- package/dist/schema/fill-spec.js +9 -0
- package/dist/schema/property-facts.d.ts +4 -3
- package/dist/schema/slot-builders.d.ts +25 -5
- 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 -7
- package/package.json +1 -1
- 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 -22
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +0 -15
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { COLLECTIONS, FACT_GRAPH, FACT_PROJECTIONS, REFERRAL_FIELDS, REFERRAL_IMAGE_FIELDS, SOURCE_FIELDS } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { rowMemberOf, rowMemberSources
|
|
2
|
+
import { rowMemberOf, rowMemberSources } from "../../template-contracts/dist/row-sources.js";
|
|
3
3
|
import { projectFactsView } from "../../template-contracts/dist/facts-view.js";
|
|
4
4
|
|
|
5
5
|
//#region ../../internal/source-resolution/dist/index.js
|
|
6
|
-
function rowFieldSources(fields) {
|
|
7
|
-
const map = {};
|
|
8
|
-
for (const [key, field] of Object.entries(fields ?? {})) {
|
|
9
|
-
const source = field.source;
|
|
10
|
-
if (source?.kind === "direct" && typeof source.field === "string") map[key] = source.field;
|
|
11
|
-
}
|
|
12
|
-
return map;
|
|
13
|
-
}
|
|
14
6
|
function primaryContact(facts) {
|
|
15
7
|
return facts.contacts?.find((c) => c.primary) ?? facts.contacts?.[0];
|
|
16
8
|
}
|
|
@@ -87,43 +79,6 @@ function singleUnitLabelDefault(propertyType) {
|
|
|
87
79
|
default: return null;
|
|
88
80
|
}
|
|
89
81
|
}
|
|
90
|
-
function resolveContactRowField(c, field) {
|
|
91
|
-
return resolveContactScalar(c, field);
|
|
92
|
-
}
|
|
93
|
-
function buildContactsList(facts, fields) {
|
|
94
|
-
return contactsOf(facts).map((c) => {
|
|
95
|
-
const row = { id: c.id };
|
|
96
|
-
for (const [key, field] of Object.entries(fields)) row[key] = resolveContactRowField(c, field);
|
|
97
|
-
return row;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function buildUnitsList(facts, fields) {
|
|
101
|
-
const fallback = singleUnitLabelDefault(facts.property_type);
|
|
102
|
-
return [...facts.units].sort((a, b) => a.position - b.position).map((u) => {
|
|
103
|
-
const base = {
|
|
104
|
-
...u,
|
|
105
|
-
unit_label: u.unit_label ?? fallback
|
|
106
|
-
};
|
|
107
|
-
const row = { ...base };
|
|
108
|
-
for (const [key, field] of Object.entries(fields)) row[key] = resolveUnitScalar(base, field);
|
|
109
|
-
return row;
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
function buildUnitFloorplanList(facts) {
|
|
113
|
-
return [...facts.units].sort((a, b) => a.position - b.position).map((u) => ({
|
|
114
|
-
unit_id: u.unit_id,
|
|
115
|
-
unit_label: u.unit_label,
|
|
116
|
-
floorplans: [...u.floor_plans].sort((a, b) => a.position - b.position)
|
|
117
|
-
}));
|
|
118
|
-
}
|
|
119
|
-
function buildComparablesList(facts) {
|
|
120
|
-
return comparablesOf(facts).map((row) => ({ ...row }));
|
|
121
|
-
}
|
|
122
|
-
const COLLECTION_PROJECTIONS = {
|
|
123
|
-
units: buildUnitsList,
|
|
124
|
-
contacts: buildContactsList,
|
|
125
|
-
comparables: buildComparablesList
|
|
126
|
-
};
|
|
127
82
|
function collectionRowsOf(collection, facts) {
|
|
128
83
|
switch (collection) {
|
|
129
84
|
case "units": return [...facts.units].sort((a, b) => a.position - b.position);
|
|
@@ -160,7 +115,6 @@ function readRowMember(collection, row, member, facts) {
|
|
|
160
115
|
return raw;
|
|
161
116
|
}
|
|
162
117
|
function projectCollectionRows(collection, facts, fields, rowComputes = {}) {
|
|
163
|
-
if (!usesRowSources(fields)) return COLLECTION_PROJECTIONS[collection](facts, rowFieldSources(fields));
|
|
164
118
|
const idKey = COLLECTIONS[collection].idKey;
|
|
165
119
|
const members = rowMemberSources(fields);
|
|
166
120
|
return collectionRowsOf(collection, facts).map((row) => {
|
|
@@ -212,7 +166,7 @@ function resolveContactScalar(contact, field) {
|
|
|
212
166
|
function readFrom(field, ctx) {
|
|
213
167
|
const desc = SOURCE_FIELDS[field];
|
|
214
168
|
if (!desc) return null;
|
|
215
|
-
if (Object.hasOwn(
|
|
169
|
+
if (Object.hasOwn(COLLECTIONS, field)) return null;
|
|
216
170
|
if (desc.container === "contact") return resolveContactScalar(ctx.contact ?? primaryContact(ctx.facts), field);
|
|
217
171
|
if (desc.container === "unit") return resolveUnitScalar(ctx.unit ?? firstUnit(ctx.facts), field);
|
|
218
172
|
return resolvePropertyScalar(ctx.facts, field);
|
|
@@ -231,4 +185,4 @@ function readAddressPart(address, part) {
|
|
|
231
185
|
}
|
|
232
186
|
|
|
233
187
|
//#endregion
|
|
234
|
-
export {
|
|
188
|
+
export { primaryContact, primaryContactFactValue, projectCollectionRows, projectFactsView, readFrom, readRowMember, resolveContactCardField, rowMemberSources, singleUnitLabelDefault };
|
|
@@ -13,24 +13,14 @@ type FactPoolName = { [K in FactGraphName]: Graph[K] extends {
|
|
|
13
13
|
type PoolRow<P extends FactPoolName> = Graph[P] extends {
|
|
14
14
|
row: infer R extends FactShapeDescriptor;
|
|
15
15
|
} ? R : never;
|
|
16
|
-
type HasPrimaryRow<P extends FactPoolName> = { [K in FactGraphName]: Graph[K] extends {
|
|
17
|
-
primary_of: P;
|
|
18
|
-
} ? K : never; }[FactGraphName] extends never ? false : true;
|
|
19
|
-
type StoredUnderOtherName<P extends FactPoolName> = HasPrimaryRow<P> extends true ? never : { [M in keyof PoolRow<P>]: PoolRow<P>[M] extends {
|
|
20
|
-
path: infer S extends string;
|
|
21
|
-
} ? S extends M ? never : M : never; }[keyof PoolRow<P>];
|
|
22
|
-
type StoredName<P extends FactPoolName, M> = M extends keyof PoolRow<P> ? PoolRow<P>[M] extends {
|
|
23
|
-
path: infer S extends string;
|
|
24
|
-
} ? S : never : never;
|
|
25
16
|
/**
|
|
26
17
|
* One row of pool `P`, as the derive-time view carries it: exactly the
|
|
27
18
|
* registry row descriptor's members, each under its author-facing name —
|
|
28
19
|
* `website`, stored as `website_url`; a comparable's `photo`, stored as
|
|
29
20
|
* `photo_upload_id` — so one spelling serves `fact.contact.*`, a row reference
|
|
30
|
-
* and the row.
|
|
31
|
-
* its storage key, for computes written before its rows took author names.
|
|
21
|
+
* and the row.
|
|
32
22
|
*/
|
|
33
|
-
type FactsRow<P extends FactPoolName> = { readonly [M in keyof PoolRow<P>]: MemberType<PoolRow<P>[M]>; }
|
|
23
|
+
type FactsRow<P extends FactPoolName> = { readonly [M in keyof PoolRow<P>]: MemberType<PoolRow<P>[M]>; };
|
|
34
24
|
type EntryValue<K extends FactGraphName> = Graph[K] extends {
|
|
35
25
|
primary_of: infer P extends FactPoolName;
|
|
36
26
|
} ? FactsRow<P> | null : Graph[K] extends {
|
|
@@ -41,17 +41,10 @@ function authorFacingName(key, container) {
|
|
|
41
41
|
}
|
|
42
42
|
return key;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
function rowValue(pool, shape, raw) {
|
|
44
|
+
function rowValue(shape, raw) {
|
|
46
45
|
const source = raw !== null && typeof raw === "object" ? raw : {};
|
|
47
|
-
const keepsStoredName = !PRIMARY_ROW_POOLS.has(pool);
|
|
48
46
|
const out = {};
|
|
49
|
-
for (const [member, desc] of Object.entries(shape))
|
|
50
|
-
const stored = desc.path ?? member;
|
|
51
|
-
const value = memberValue(desc, source[stored]);
|
|
52
|
-
out[member] = value;
|
|
53
|
-
if (keepsStoredName && stored !== member) out[stored] = value;
|
|
54
|
-
}
|
|
47
|
+
for (const [member, desc] of Object.entries(shape)) out[member] = memberValue(desc, source[desc.path ?? member]);
|
|
55
48
|
return out;
|
|
56
49
|
}
|
|
57
50
|
const POOL_ORDER = { units: (rows) => [...rows].sort((a, b) => (num(a.position) ?? 0) - (num(b.position) ?? 0)) };
|
|
@@ -81,11 +74,11 @@ function projectFactsView(canonical) {
|
|
|
81
74
|
const poolEntry = FACT_GRAPH[pool];
|
|
82
75
|
const rows = poolRows(pool, entry.path);
|
|
83
76
|
const primary = POOL_PRIMARY[pool]?.(rows);
|
|
84
|
-
view[key] = primary === void 0 || poolEntry.row === void 0 ? null : rowValue(
|
|
77
|
+
view[key] = primary === void 0 || poolEntry.row === void 0 ? null : rowValue(poolEntry.row, primary);
|
|
85
78
|
continue;
|
|
86
79
|
}
|
|
87
80
|
if (entry.row !== void 0) {
|
|
88
|
-
target[key] = poolRows(key, entry.path).map((r) => rowValue(
|
|
81
|
+
target[key] = poolRows(key, entry.path).map((r) => rowValue(entry.row, r));
|
|
89
82
|
continue;
|
|
90
83
|
}
|
|
91
84
|
if (entry.fields !== void 0) {
|
|
@@ -7,12 +7,6 @@ function rowMemberOf(source) {
|
|
|
7
7
|
if (src?.["kind"] !== "row") return null;
|
|
8
8
|
return typeof src["field"] === "string" ? src["field"] : null;
|
|
9
9
|
}
|
|
10
|
-
function usesRowSources(fields) {
|
|
11
|
-
return Object.values(fields ?? {}).some((field) => {
|
|
12
|
-
const kind = sourceRecord(field.source)?.["kind"];
|
|
13
|
-
return kind === "row" || kind === "derived";
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
10
|
function rowMemberSources(fields) {
|
|
17
11
|
const map = {};
|
|
18
12
|
for (const [key, field] of Object.entries(fields ?? {})) {
|
|
@@ -23,4 +17,4 @@ function rowMemberSources(fields) {
|
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
//#endregion
|
|
26
|
-
export { rowMemberOf, rowMemberSources
|
|
20
|
+
export { rowMemberOf, rowMemberSources };
|
|
@@ -500,7 +500,7 @@ declare const COLLECTION_FACTS: {
|
|
|
500
500
|
readonly column: "sqft";
|
|
501
501
|
};
|
|
502
502
|
};
|
|
503
|
-
/** The comparable's photo — an upload the comp itself owns, never one of the property's own photos, so no media pool offers it. Stored as the upload's id (`photo_upload_id`); a `compute()` over `fact.property.comparables` reads that id as `photo`
|
|
503
|
+
/** The comparable's photo — an upload the comp itself owns, never one of the property's own photos, so no media pool offers it. Stored as the upload's id (`photo_upload_id`); a `compute()` over `fact.property.comparables` reads that id as `photo` and renders it through an `image` value (`{ photo_id, url: "", alt }`). An `image` row field bound to this member receives it already as a media reference. Null when the user uploaded none. */
|
|
504
504
|
readonly photo: {
|
|
505
505
|
readonly path: "photo_upload_id";
|
|
506
506
|
readonly value_type: "image";
|
|
@@ -17,10 +17,6 @@ const COLLECTION_SLOT_TYPES = ["list"];
|
|
|
17
17
|
function isCollectionSlotType(type) {
|
|
18
18
|
return COLLECTION_SLOT_TYPES.includes(type);
|
|
19
19
|
}
|
|
20
|
-
const SOURCE_FILTERS = ["floorplans"];
|
|
21
|
-
function isSourceFilter(value) {
|
|
22
|
-
return SOURCE_FILTERS.includes(value);
|
|
23
|
-
}
|
|
24
20
|
const REFERRAL_FIELDS = [
|
|
25
21
|
"name",
|
|
26
22
|
"title",
|
|
@@ -781,4 +777,4 @@ function tourEmbedUrl(raw) {
|
|
|
781
777
|
}
|
|
782
778
|
|
|
783
779
|
//#endregion
|
|
784
|
-
export { COLLECTIONS, COLLECTION_SLOT_TYPES, CONTENT_SLOT_TYPES, DISPLAY_ENTRIES, FACT_GRAPH, FACT_PROJECTIONS, INPUT_GROUPS, INPUT_GROUP_REQUIREMENT, LINK_KINDS, LINK_PROVIDERS, OPTION_SOURCES, REFERRAL_FIELDS, REFERRAL_IMAGE_FIELDS, REF_SLOT_TYPES, SLOT_TYPES, SOURCE_FIELDS,
|
|
780
|
+
export { COLLECTIONS, COLLECTION_SLOT_TYPES, CONTENT_SLOT_TYPES, DISPLAY_ENTRIES, FACT_GRAPH, FACT_PROJECTIONS, INPUT_GROUPS, INPUT_GROUP_REQUIREMENT, LINK_KINDS, LINK_PROVIDERS, OPTION_SOURCES, REFERRAL_FIELDS, REFERRAL_IMAGE_FIELDS, REF_SLOT_TYPES, SLOT_TYPES, SOURCE_FIELDS, VIDEO_SOURCES, VISIBILITY_CASES, acceptsLink, collectionBounds, collectionForSlot, isCollectionSlotType, isLinkAccepts, isOptionSource, isWritableSourceField, matchLinkProvider, stampCollectionBounds, tourEmbedUrl, videoEmbedUrl };
|
|
@@ -9,6 +9,7 @@ import { isListSlot, originationFor } from "../packages/internal/fill-vocabulary
|
|
|
9
9
|
function kindOf(origination) {
|
|
10
10
|
switch (origination.kind) {
|
|
11
11
|
case "write": return "text";
|
|
12
|
+
case "estimate": return "number";
|
|
12
13
|
case "pick-one": return "pick";
|
|
13
14
|
default: return "list";
|
|
14
15
|
}
|
|
@@ -47,11 +48,6 @@ function assertRowOrigins(key, slot) {
|
|
|
47
48
|
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
|
}
|
|
49
50
|
}
|
|
50
|
-
function unkeyedMessage(key, origination) {
|
|
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.`;
|
|
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.`;
|
|
54
|
-
}
|
|
55
51
|
function rowFieldDecision(key, fieldKey, field, binding) {
|
|
56
52
|
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.`);
|
|
57
53
|
return optionsOf(binding);
|
|
@@ -81,8 +77,7 @@ function recordListDecision(key, slot, reads) {
|
|
|
81
77
|
};
|
|
82
78
|
throw new Error(`fillSpecFromSchema: record slot "${key}" fills row fields but its rows have no origin — bind the list to a facts array with \`source:\`, or \`fill()\` the list so the model originates its rows.`);
|
|
83
79
|
}
|
|
84
|
-
if (origination
|
|
85
|
-
if (origination === void 0) throw new Error(`fillSpecFromSchema: record slot "${key}" originates no rows.`);
|
|
80
|
+
if (origination === void 0) throw new Error(`fillSpecFromSchema: record slot "${key}" fills its rows but no row field is filled — a filled record list is written field by field, so give its row fields their own \`fill()\`.`);
|
|
86
81
|
return {
|
|
87
82
|
id: key,
|
|
88
83
|
kind: "list",
|
package/dist/schema/fill-spec.js
CHANGED
|
@@ -47,6 +47,14 @@ const TextDecision = z.object({
|
|
|
47
47
|
cap: Cap,
|
|
48
48
|
reads: DecisionReads
|
|
49
49
|
}).strict();
|
|
50
|
+
const NumberDecision = z.object({
|
|
51
|
+
id: z.string(),
|
|
52
|
+
kind: z.literal("number"),
|
|
53
|
+
produces: z.array(z.string()).min(1),
|
|
54
|
+
brief: Brief,
|
|
55
|
+
none: Abstention,
|
|
56
|
+
reads: DecisionReads
|
|
57
|
+
}).strict();
|
|
50
58
|
const PickDecision = z.object({
|
|
51
59
|
id: z.string(),
|
|
52
60
|
kind: z.literal("pick"),
|
|
@@ -75,6 +83,7 @@ const DisplayDecision = z.object({
|
|
|
75
83
|
}).strict();
|
|
76
84
|
const Decision = z.discriminatedUnion("kind", [
|
|
77
85
|
TextDecision,
|
|
86
|
+
NumberDecision,
|
|
78
87
|
PickDecision,
|
|
79
88
|
ListDecision,
|
|
80
89
|
DisplayDecision
|
|
@@ -44,9 +44,10 @@ type ComparableRow = {
|
|
|
44
44
|
/**
|
|
45
45
|
* The comp's photo: the id of an upload the comparable itself owns — never one of the
|
|
46
46
|
* property's own photos, so no media pool offers it. `null` when none was uploaded. A
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* `compute()` over `fact.property.comparables` reads it as `photo` and draws it
|
|
48
|
+
* through an `image` value built from the id,
|
|
49
|
+
* `{ photo_id: comp.photo, url: "", alt: comp.address }`, and the render attaches
|
|
50
|
+
* the served URL and ladder by `photo_id`, as it does for any image.
|
|
50
51
|
*/
|
|
51
52
|
photo_upload_id: string | null;
|
|
52
53
|
/** The year the comparable was built. */
|
|
@@ -152,7 +152,12 @@ declare const text: {
|
|
|
152
152
|
source?: HasSource | undefined;
|
|
153
153
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, string | null>) => TextSlotDef<"long"> & SourceMark<HasSource> & FillMark;
|
|
154
154
|
};
|
|
155
|
-
|
|
155
|
+
/**
|
|
156
|
+
* The fill a `number` slot takes: the model ESTIMATES the figure, so only `none`
|
|
157
|
+
* binds — there is no character budget to lower and no count of one value.
|
|
158
|
+
*/
|
|
159
|
+
type NumberFill = FillFor<"none">;
|
|
160
|
+
interface NumberOptions extends CommonOptions<number | null, NumberFill> {
|
|
156
161
|
prefix?: string;
|
|
157
162
|
suffix?: string;
|
|
158
163
|
thousandsSep?: boolean;
|
|
@@ -174,18 +179,33 @@ interface NumberSlotDef extends Head {
|
|
|
174
179
|
* toggles decimal display, and `maxDigits` caps the digit count — all read by
|
|
175
180
|
* the renderer's number formatting, not enforced as an input range.
|
|
176
181
|
*
|
|
177
|
-
*
|
|
178
|
-
* `compute()
|
|
182
|
+
* A figure the platform holds is a fact: bind it (`source:` a fact, a slot or a
|
|
183
|
+
* `compute()`). `source: fill({ brief, reads })` is for a figure that is a
|
|
184
|
+
* judgement rather than a fact — an ESTIMATE the model proposes and the user
|
|
185
|
+
* confirms, such as a suggested price band. The model returns a number, rounded to
|
|
186
|
+
* a whole one unless the slot declares `decimals`; `none: true` lets it leave the
|
|
187
|
+
* slot empty. A fill takes no `cap` and no `count`, and a record row's number field
|
|
188
|
+
* takes no fill at all.
|
|
179
189
|
* @example
|
|
180
190
|
* ```ts
|
|
181
|
-
* import { fact, number } from "@homepages/concrete";
|
|
191
|
+
* import { fact, fill, number } from "@homepages/concrete";
|
|
182
192
|
*
|
|
183
193
|
* number({ source: fact.unit.sqft, writeback: true, label: "Square feet", thousandsSep: true, suffix: "sqft", maxDigits: 7 });
|
|
194
|
+
*
|
|
195
|
+
* number({
|
|
196
|
+
* label: "Suggested list price",
|
|
197
|
+
* prefix: "$",
|
|
198
|
+
* thousandsSep: true,
|
|
199
|
+
* source: fill({
|
|
200
|
+
* reads: [fact.property.units, fact.property.comparables],
|
|
201
|
+
* brief: "The most likely sale price, in whole dollars, rounded to $5,000.",
|
|
202
|
+
* }),
|
|
203
|
+
* });
|
|
184
204
|
* ```
|
|
185
205
|
*/
|
|
186
206
|
declare function number<const HasSource extends SourceBinding | undefined = undefined>(opts: NumberOptions & {
|
|
187
207
|
source?: HasSource;
|
|
188
|
-
} & WritebackOption<HasSource> & MirrorOption<HasSource, number | null>): NumberSlotDef & SourceMark<HasSource
|
|
208
|
+
} & WritebackOption<HasSource> & MirrorOption<HasSource, number | null>): NumberSlotDef & SourceMark<HasSource> & FillMark;
|
|
189
209
|
/** One authored select choice: a bare string (value === label) or a stored key with display text. */
|
|
190
210
|
type SelectOptionInput = string | {
|
|
191
211
|
value: string;
|
|
@@ -3,7 +3,7 @@ purpose: Every `concrete` command, with its full flag surface, exit codes and co
|
|
|
3
3
|
mode: reference
|
|
4
4
|
status: generated
|
|
5
5
|
generated_from: the concrete command table
|
|
6
|
-
applies_to: "@homepages/concrete >=
|
|
6
|
+
applies_to: "@homepages/concrete >=8.0.0 <9.0.0"
|
|
7
7
|
related: [INDEX.md]
|
|
8
8
|
---
|
|
9
9
|
# Command reference
|
|
@@ -79,7 +79,7 @@ of its flags.
|
|
|
79
79
|
|
|
80
80
|
## Versions
|
|
81
81
|
|
|
82
|
-
These pages describe `@homepages/concrete` **>=
|
|
82
|
+
These pages describe `@homepages/concrete` **>=8.0.0 <9.0.0**. The range, rather than
|
|
83
83
|
the exact version they were generated from: this reference is committed build output,
|
|
84
84
|
so a page stamped with a patch version would be stale the day it shipped.
|
|
85
85
|
`concrete --version` prints the installed one.
|
|
@@ -3,7 +3,7 @@ purpose: The `concrete build` command — its flags, exit codes and constraints.
|
|
|
3
3
|
mode: reference
|
|
4
4
|
status: generated
|
|
5
5
|
generated_from: the concrete command table
|
|
6
|
-
applies_to: "@homepages/concrete >=
|
|
6
|
+
applies_to: "@homepages/concrete >=8.0.0 <9.0.0"
|
|
7
7
|
related: [reference/cli/INDEX.md]
|
|
8
8
|
---
|
|
9
9
|
# concrete build
|
|
@@ -3,7 +3,7 @@ purpose: The `concrete check` command — its flags, exit codes and constraints.
|
|
|
3
3
|
mode: reference
|
|
4
4
|
status: generated
|
|
5
5
|
generated_from: the concrete command table
|
|
6
|
-
applies_to: "@homepages/concrete >=
|
|
6
|
+
applies_to: "@homepages/concrete >=8.0.0 <9.0.0"
|
|
7
7
|
related: [reference/cli/INDEX.md]
|
|
8
8
|
---
|
|
9
9
|
# concrete check
|
|
@@ -3,7 +3,7 @@ purpose: The `concrete dev` command — its flags, exit codes and constraints.
|
|
|
3
3
|
mode: reference
|
|
4
4
|
status: generated
|
|
5
5
|
generated_from: the concrete command table
|
|
6
|
-
applies_to: "@homepages/concrete >=
|
|
6
|
+
applies_to: "@homepages/concrete >=8.0.0 <9.0.0"
|
|
7
7
|
related: [reference/cli/INDEX.md]
|
|
8
8
|
---
|
|
9
9
|
# concrete dev
|
|
@@ -3,7 +3,7 @@ purpose: The `concrete property add` command — its flags, exit codes and const
|
|
|
3
3
|
mode: reference
|
|
4
4
|
status: generated
|
|
5
5
|
generated_from: the concrete command table
|
|
6
|
-
applies_to: "@homepages/concrete >=
|
|
6
|
+
applies_to: "@homepages/concrete >=8.0.0 <9.0.0"
|
|
7
7
|
related: [reference/cli/INDEX.md]
|
|
8
8
|
---
|
|
9
9
|
# concrete property add
|
|
@@ -3,7 +3,7 @@ purpose: The `concrete property list` command — its flags, exit codes and cons
|
|
|
3
3
|
mode: reference
|
|
4
4
|
status: generated
|
|
5
5
|
generated_from: the concrete command table
|
|
6
|
-
applies_to: "@homepages/concrete >=
|
|
6
|
+
applies_to: "@homepages/concrete >=8.0.0 <9.0.0"
|
|
7
7
|
related: [reference/cli/INDEX.md]
|
|
8
8
|
---
|
|
9
9
|
# concrete property list
|
|
@@ -3,7 +3,7 @@ purpose: The `concrete publish` command — its flags, exit codes and constraint
|
|
|
3
3
|
mode: reference
|
|
4
4
|
status: generated
|
|
5
5
|
generated_from: the concrete command table
|
|
6
|
-
applies_to: "@homepages/concrete >=
|
|
6
|
+
applies_to: "@homepages/concrete >=8.0.0 <9.0.0"
|
|
7
7
|
related: [reference/cli/INDEX.md]
|
|
8
8
|
---
|
|
9
9
|
# concrete publish
|
|
@@ -3,7 +3,7 @@ purpose: The `concrete upgrade` command — its flags, exit codes and constraint
|
|
|
3
3
|
mode: reference
|
|
4
4
|
status: generated
|
|
5
5
|
generated_from: the concrete command table
|
|
6
|
-
applies_to: "@homepages/concrete >=
|
|
6
|
+
applies_to: "@homepages/concrete >=8.0.0 <9.0.0"
|
|
7
7
|
related: [reference/cli/INDEX.md]
|
|
8
8
|
---
|
|
9
9
|
# concrete upgrade
|
|
@@ -3,7 +3,7 @@ purpose: Every rule `concrete check` grades, by the stage that grades it, in the
|
|
|
3
3
|
mode: reference
|
|
4
4
|
status: generated
|
|
5
5
|
generated_from: the concrete rule registry
|
|
6
|
-
applies_to: "@homepages/concrete >=
|
|
6
|
+
applies_to: "@homepages/concrete >=8.0.0 <9.0.0"
|
|
7
7
|
related: [reference/cli/check.md]
|
|
8
8
|
---
|
|
9
9
|
# Rule reference
|
|
@@ -141,13 +141,10 @@ Every placed section's schema and fill spec satisfy the contract assertions publ
|
|
|
141
141
|
| Rule | Venue | What it requires |
|
|
142
142
|
|---|---|---|
|
|
143
143
|
| `concrete/contract/reads-readable` | contract | Every fact a section reads is one the fact registry declares. |
|
|
144
|
-
| `concrete/contract/decision-kind` | contract | Every fill decision names a kind the platform runs: text, pick, list or display. |
|
|
144
|
+
| `concrete/contract/decision-kind` | contract | Every fill decision names a kind the platform runs: text, number, pick, list or display. |
|
|
145
145
|
| `concrete/contract/produces-known-slot` | contract | Every fill decision produces only slots the section declares. |
|
|
146
146
|
| `concrete/contract/poi-curation` | contract | A points-of-interest curation decision produces exactly one slot, a list of points of interest. |
|
|
147
|
-
| `concrete/contract/list-fill` | contract | A list fill declares what the slot's own origination needs: a brief where the model originates rows, a bound where it writes them
|
|
148
|
-
| `concrete/contract/choose-select` | contract | A record list the model originates is keyed by its title field, else by exactly one select field with declared values. |
|
|
149
|
-
| `concrete/contract/name-title` | contract | A list keyed by a written name needs that field to be capped text that carries no fill of its own. |
|
|
150
|
-
| `concrete/contract/pooling-field` | contract | A list fill's record item declares at most one unbound pooled asset field. |
|
|
147
|
+
| `concrete/contract/list-fill` | contract | 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. |
|
|
151
148
|
| `concrete/contract/row-fill` | contract | A list fill plans only unbound fields its record item declares, each of a type a row can be filled with. |
|
|
152
149
|
| `concrete/contract/count-bounds` | contract | Every item count a decision requests fits the bounds of the slot or row field that holds the items. |
|
|
153
150
|
| `concrete/contract/cap` | contract | Every generated text value has one character budget, declared on its slot, and a fill cap may only be lower. |
|
|
@@ -161,7 +158,6 @@ Every placed section's schema and fill spec satisfy the contract assertions publ
|
|
|
161
158
|
| `concrete/contract/select` | contract | A select declares exactly one of values or options, and a creatable select's keys are normalized. |
|
|
162
159
|
| `concrete/contract/option-source` | contract | A select with an option source names a source the platform provides. |
|
|
163
160
|
| `concrete/contract/url` | contract | A url slot's accepts names a link kind or provider that a registered provider implements. |
|
|
164
|
-
| `concrete/contract/source-filter` | contract | A media slot's source filter names a filter the platform supports. |
|
|
165
161
|
| `concrete/contract/sources` | contract | Only a video slot declares sources, as a non-empty list of distinct known video sources. |
|
|
166
162
|
| `concrete/contract/interpolation` | contract | A fill brief refers to its facts through reads and never interpolates one. |
|
|
167
163
|
| `concrete/contract/group` | contract | Group ids are unique, every group names real slots, and no slot sits in two groups. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homepages/concrete",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Concrete, the HomePages template framework: the authoring API, the contract primitives, the styles, the lint preset and the `concrete` command in one package that owns its whole toolchain.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
-
import { isListFill, plannedFieldsOf } from "./fill-spec-view.js";
|
|
3
|
-
|
|
4
|
-
//#region ../../internal/section-contracts/dist/choose-select-contract.js
|
|
5
|
-
function assertChooseSelectContract(schema, decision, sectionKey) {
|
|
6
|
-
if (!isListFill(decision)) return;
|
|
7
|
-
for (const slotId of decision.produces) {
|
|
8
|
-
const slot = schema.slots[slotId];
|
|
9
|
-
if (slot === void 0) continue;
|
|
10
|
-
const origination = originationFor(slot, plannedFieldsOf(decision));
|
|
11
|
-
if (origination?.kind !== "unkeyed-rows") continue;
|
|
12
|
-
const where = `Section "${sectionKey}": list fill "${decision.id}" originates rows of "${slotId}"`;
|
|
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({ 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
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { assertChooseSelectContract };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
-
import { isListFill, plannedFieldsOf } from "./fill-spec-view.js";
|
|
3
|
-
|
|
4
|
-
//#region ../../internal/section-contracts/dist/name-title-contract.js
|
|
5
|
-
function assertNameTitleContract(schema, decision, sectionKey) {
|
|
6
|
-
if (!isListFill(decision)) return;
|
|
7
|
-
for (const slotId of decision.produces) {
|
|
8
|
-
const slot = schema.slots[slotId];
|
|
9
|
-
if (slot === void 0) continue;
|
|
10
|
-
const origination = originationFor(slot, plannedFieldsOf(decision));
|
|
11
|
-
if (origination?.kind !== "keyed-rows" || origination.keys !== "written") continue;
|
|
12
|
-
const key = origination.keyField;
|
|
13
|
-
const where = `Section "${sectionKey}": list fill "${decision.id}" writes each row of "${slotId}" into "${key}"`;
|
|
14
|
-
if (typeof (slot.fields?.[key])?.cap !== "number") throw new Error(`${where}, which declares no \`cap\` — a written name needs its character budget.`);
|
|
15
|
-
if (decision.fields?.[key] !== void 0) throw new Error(`${where}, which also carries its own fill — the written name is that field's value, so it takes none.`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { assertNameTitleContract };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { poolingPrimitiveOf } from "../../fill-vocabulary/dist/row-planners.js";
|
|
2
|
-
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
3
|
-
import { isListFill, plannedFieldsOf } from "./fill-spec-view.js";
|
|
4
|
-
|
|
5
|
-
//#region ../../internal/section-contracts/dist/pooling-field-contract.js
|
|
6
|
-
function poolingDeclarationsOf(slot) {
|
|
7
|
-
if (slot.fields !== void 0) return Object.entries(slot.fields).filter(([, field]) => field.source === void 0 && poolingPrimitiveOf(field) !== void 0).map(([name]) => name);
|
|
8
|
-
return poolingPrimitiveOf(slot.element ?? {}) !== void 0 ? ["element"] : [];
|
|
9
|
-
}
|
|
10
|
-
function assertPoolingFieldContract(schema, decision, sectionKey) {
|
|
11
|
-
if (!isListFill(decision)) return;
|
|
12
|
-
for (const slotId of decision.produces) {
|
|
13
|
-
const slot = schema.slots[slotId];
|
|
14
|
-
if (!slot) continue;
|
|
15
|
-
if (originationFor(slot, plannedFieldsOf(decision))?.kind === "filled-rows") continue;
|
|
16
|
-
const pooling = poolingDeclarationsOf(slot);
|
|
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.`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { assertPoolingFieldContract };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { SOURCE_FILTERS, isSourceFilter } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
-
|
|
3
|
-
//#region ../../internal/section-contracts/dist/source-filter-contract.js
|
|
4
|
-
function assertSourceFilterContract(schema, sectionKey) {
|
|
5
|
-
for (const [slotId, slot] of Object.entries(schema.slots)) check(slot, sectionKey, slotId);
|
|
6
|
-
}
|
|
7
|
-
function check(slot, sectionKey, path) {
|
|
8
|
-
const filter = slot.sourceFilter;
|
|
9
|
-
if (filter !== void 0 && !isSourceFilter(filter)) throw new Error(`Section "${sectionKey}": image "${path}" declares unknown sourceFilter ${JSON.stringify(filter)} (allowed: ${SOURCE_FILTERS.join(", ")}). An unknown tag silently falls back to the property photo pool.`);
|
|
10
|
-
if (slot.element) check(slot.element, sectionKey, `${path}.element`);
|
|
11
|
-
if (slot.fields) for (const [fieldId, field] of Object.entries(slot.fields)) check(field, sectionKey, `${path}.${fieldId}`);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { assertSourceFilterContract };
|