@homepages/concrete 9.1.0 → 11.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 +81 -0
- package/README.md +1 -1
- package/codemods/manifest.json +5 -148
- package/dist/artifact/playground/client/assets/index-ByeGGedv.js +1259 -0
- package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +42 -42
- package/dist/base.css +1 -8
- package/dist/cli/build/artifact.js +3 -2
- package/dist/cli/build/fixtures.js +2 -0
- package/dist/cli/check/render/inputs.js +3 -3
- package/dist/cli/check/stages/sections.js +6 -7
- package/dist/cli/dev/workspace-reader.js +10 -2
- package/dist/css/compile.js +3 -6
- package/dist/css/rules.js +1 -51
- package/dist/design-system/format-variants.js +1 -1
- package/dist/fixtures/media-store.js +3 -3
- package/dist/fixtures/resolve.js +28 -16
- package/dist/fixtures/rows.js +2 -2
- package/dist/fixtures/synthesize-empties.js +3 -1
- package/dist/fixtures.d.ts +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +8 -6
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +8 -4
- package/dist/packages/internal/fill-bake/dist/index.js +1 -1
- package/dist/packages/internal/fill-bake/dist/item-merge.js +32 -6
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +5 -5
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +4 -26
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +3 -14
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
- package/dist/packages/internal/media-resolution/dist/document.js +17 -16
- package/dist/packages/internal/media-resolution/dist/image.js +41 -95
- package/dist/packages/internal/media-resolution/dist/index.js +1 -1
- package/dist/packages/internal/media-resolution/dist/list.js +11 -11
- package/dist/packages/internal/media-resolution/dist/media.js +17 -16
- package/dist/packages/internal/media-resolution/dist/records.js +4 -2
- package/dist/packages/internal/media-resolution/dist/slot.js +5 -5
- package/dist/packages/internal/media-resolution/dist/tour.js +17 -16
- package/dist/packages/internal/media-resolution/dist/video.js +24 -24
- package/dist/packages/internal/property-facts/dist/registry-facts.js +8 -1
- package/dist/packages/internal/section-contracts/dist/catalog.js +1 -5
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +2 -3
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +6 -3
- package/dist/packages/internal/section-contracts/dist/index.js +0 -1
- package/dist/packages/internal/section-contracts/dist/object-contract.js +4 -2
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +4 -2
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +7 -8
- package/dist/packages/internal/section-contracts/dist/runners.js +2 -11
- package/dist/packages/internal/section-contracts/dist/select-contract.js +7 -1
- package/dist/packages/internal/section-contracts/dist/source-contract.js +14 -10
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +0 -2
- package/dist/packages/internal/section-contracts/dist/table-member.js +5 -8
- package/dist/packages/internal/source-resolution/dist/index.js +21 -188
- package/dist/packages/internal/template-artifact/dist/index.js +1 -1
- package/dist/packages/internal/template-artifact/dist/layout.js +12 -10
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +26 -14
- package/dist/packages/internal/template-contracts/dist/content-pick.js +24 -1
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +4 -6
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +3 -2
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +19 -43
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +24 -3
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +10 -3
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +2 -6
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +4 -1
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +7 -6
- package/dist/packages/internal/template-contracts/dist/list.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/list.js +7 -29
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +2 -2
- package/dist/packages/internal/template-contracts/dist/object.js +3 -2
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +1 -1
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/read-graph.js +5 -32
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +10 -6
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +13 -24
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +20 -4
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +69 -11
- package/dist/packages/internal/template-contracts/dist/row-planners.js +1 -1
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +4 -7
- package/dist/packages/internal/template-contracts/dist/row-ref.js +7 -23
- package/dist/packages/internal/template-contracts/dist/row-sources.js +3 -3
- package/dist/packages/internal/template-contracts/dist/row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/row.js +6 -7
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +11 -27
- package/dist/packages/internal/template-contracts/dist/section-schema-types.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +29 -37
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +3 -8
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +2 -702
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +2 -498
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +4 -1
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +10 -5
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +2 -1
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +5 -12
- package/dist/packages/internal/template-contracts/dist/table-members.js +7 -37
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +4 -6
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +3 -4
- package/dist/primitives/Image.d.ts +4 -4
- package/dist/primitives/Tour.d.ts +2 -2
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/slot-bindings.js +6 -13
- package/dist/primitives/slot-document.d.ts +1 -1
- package/dist/primitives/slot-download.d.ts +4 -2
- package/dist/primitives/slot-media.d.ts +6 -3
- package/dist/primitives/slot-media.js +1 -1
- package/dist/rules/registry.js +0 -6
- package/dist/schema/fact.d.ts +19 -52
- package/dist/schema/fact.js +6 -25
- package/dist/schema/facts-view.d.ts +1 -2
- package/dist/schema/format-presets.d.ts +1 -1
- package/dist/schema/property-facts.d.ts +1 -62
- package/dist/schema/section-schema.d.ts +6 -6
- package/dist/schema/section-schema.js +1 -1
- package/dist/styles.css +4 -4
- package/dist/template/define-template.js +0 -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 +2 -4
- package/package.json +2 -2
- package/codemods/fill-is-a-source.mjs +0 -533
- package/codemods/framework-namespace.mjs +0 -107
- package/codemods/list-grammar.mjs +0 -923
- package/codemods/object-form-only.mjs +0 -39
- package/codemods/platform-namespace.mjs +0 -83
- package/codemods/process-builders.mjs +0 -198
- package/codemods/reads-replace-reconcile.mjs +0 -285
- package/codemods/slot-object.mjs +0 -1097
- package/codemods/steps/content-object-fields.mjs +0 -324
- package/codemods/steps/list-object-form.mjs +0 -687
- package/codemods/steps/select-object-form.mjs +0 -210
- package/codemods/table-rows.mjs +0 -568
- package/codemods/theme-collapse.mjs +0 -396
- package/codemods/unlayer-author-css.mjs +0 -194
- package/codemods/unwrap-object-fields.mjs +0 -310
- package/codemods/viewer-slot-document.mjs +0 -131
- package/codemods/write-property-as-facts-document.mjs +0 -716
- package/codemods/write-the-address-line.mjs +0 -255
- package/codemods/write-the-registry-members.mjs +0 -653
- package/codemods/write-the-select-from.mjs +0 -141
- package/codemods/write-the-sole-from.mjs +0 -369
- package/codemods/write-the-table-from.mjs +0 -267
- package/codemods/write-the-whole-item.mjs +0 -512
- package/codemods/writeback-drop.mjs +0 -168
- package/codemods/written-contact-address.mjs +0 -162
- package/codemods/written-media-category.mjs +0 -227
- package/codemods/written-ref-kinds-name-the-layer.mjs +0 -172
- package/codemods/written-uploads-replace-pool-reads.mjs +0 -454
- package/codemods/written-uploads-sort-into-lists.mjs +0 -405
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +0 -295
- package/codemods/written-video-sources-drop.mjs +0 -144
- package/codemods/written-without-pick-none.mjs +0 -146
- package/codemods/written-without-retired-knowledge.mjs +0 -223
- package/codemods/written-without-the-media-key.mjs +0 -202
- package/codemods/written-without-the-property-type.mjs +0 -249
- package/dist/artifact/playground/client/assets/index-BOYbgBnP.js +0 -1259
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +0 -1
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +0 -22
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +0 -19
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +0 -62
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +0 -167
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +0 -77
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { addressMember, isAddressMember, normalizeAddressValue } from "../../template-contracts/dist/address-value.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { rowIdentityKey, tableFields, tableRowMember } from "../../template-contracts/dist/table-members.js";
|
|
2
|
+
import { memberValueType, tableColumnOfKey, tableOf } from "../../template-contracts/dist/registry-shape.js";
|
|
3
|
+
import { isMediaListKey, isRegistryFactKey, readRegistryFact } from "../../template-contracts/dist/fact-keys.js";
|
|
4
|
+
import { tableFields, tableRowMember } from "../../template-contracts/dist/table-members.js";
|
|
6
5
|
import { elementRowKeys, rowMemberSources } from "../../template-contracts/dist/row-sources.js";
|
|
7
|
-
import { readLegacyFact, readLegacyRows } from "../../template-contracts/dist/legacy-facts.js";
|
|
8
6
|
|
|
9
7
|
//#region ../../internal/source-resolution/dist/index.js
|
|
10
|
-
function
|
|
11
|
-
return typeof table === "string" ? {
|
|
12
|
-
table,
|
|
13
|
-
reading: "legacy"
|
|
14
|
-
} : table;
|
|
15
|
-
}
|
|
16
|
-
function registryTableRows(table, facts) {
|
|
8
|
+
function tableRows(table, facts) {
|
|
17
9
|
const addresses = Object.entries(tableFields(table)).filter(([, declaration]) => memberValueType(declaration) === "address").map(([name]) => name);
|
|
18
10
|
return facts[table].map((item) => {
|
|
19
11
|
const row = { ...item };
|
|
@@ -21,104 +13,8 @@ function registryTableRows(table, facts) {
|
|
|
21
13
|
return row;
|
|
22
14
|
});
|
|
23
15
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const REFERRAL_FIELD_SET = new Set(REFERRAL_FIELDS);
|
|
28
|
-
const REFERRAL_IMAGE_FIELD_SET = new Set(REFERRAL_IMAGE_FIELDS);
|
|
29
|
-
const LOGO_VARIANT_FALLBACK = {
|
|
30
|
-
logo_dark: {
|
|
31
|
-
other: "logo_light",
|
|
32
|
-
mask: "black"
|
|
33
|
-
},
|
|
34
|
-
logo_light: {
|
|
35
|
-
other: "logo_dark",
|
|
36
|
-
mask: "white"
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
function resolveContactCardField(contact, field) {
|
|
40
|
-
if (!REFERRAL_FIELD_SET.has(field)) return null;
|
|
41
|
-
const raw = contact?.[field] ?? null;
|
|
42
|
-
if (REFERRAL_IMAGE_FIELD_SET.has(field)) {
|
|
43
|
-
const assetId = typeof raw === "string" && raw.trim().length > 0 ? raw.trim() : null;
|
|
44
|
-
if (assetId !== null) return { asset_id: assetId };
|
|
45
|
-
const fb = LOGO_VARIANT_FALLBACK[field];
|
|
46
|
-
if (fb !== void 0) {
|
|
47
|
-
const otherRaw = contact?.[fb.other] ?? null;
|
|
48
|
-
const otherId = typeof otherRaw === "string" && otherRaw.trim().length > 0 ? otherRaw.trim() : null;
|
|
49
|
-
if (otherId !== null) return {
|
|
50
|
-
asset_id: otherId,
|
|
51
|
-
mask: fb.mask
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
if (raw === null || raw === void 0) return "";
|
|
57
|
-
return typeof raw === "string" ? raw : String(raw);
|
|
58
|
-
}
|
|
59
|
-
const PRIMARY_CONTACT_FACT_TO_CONTACT_MEMBER = {
|
|
60
|
-
primary_contact_name: "name",
|
|
61
|
-
primary_contact_title: "title",
|
|
62
|
-
primary_contact_bio: "bio",
|
|
63
|
-
primary_contact_email: "email",
|
|
64
|
-
primary_contact_phone: "phone",
|
|
65
|
-
primary_contact_address: "address",
|
|
66
|
-
primary_contact_website_url: "website",
|
|
67
|
-
primary_contact_avatar_upload_id: "headshot",
|
|
68
|
-
primary_contact_logo_dark_upload_id: "logo_dark",
|
|
69
|
-
primary_contact_logo_light_upload_id: "logo_light",
|
|
70
|
-
primary_contact_instagram_url: "instagram",
|
|
71
|
-
primary_contact_linkedin_url: "linkedin",
|
|
72
|
-
primary_contact_x_url: "x",
|
|
73
|
-
primary_contact_facebook_url: "facebook"
|
|
74
|
-
};
|
|
75
|
-
function primaryContactFactValue(facts, factKey) {
|
|
76
|
-
const key = PRIMARY_CONTACT_FACT_TO_CONTACT_MEMBER[factKey];
|
|
77
|
-
if (key === void 0) return void 0;
|
|
78
|
-
const raw = contactsOf(facts)[0]?.[key] ?? null;
|
|
79
|
-
return typeof raw === "string" ? raw : null;
|
|
80
|
-
}
|
|
81
|
-
function tableRowsOf(table, facts) {
|
|
82
|
-
const key = tableKey(table);
|
|
83
|
-
return key.reading === "legacy" ? readLegacyRows(facts, key.table) : registryTableRows(key.table, facts);
|
|
84
|
-
}
|
|
85
|
-
const CONTACT_MEMBER_FACT = Object.fromEntries(Object.entries(FACT_GRAPH.contacts.row).filter(([, member]) => member.primary === true).map(([name]) => [name, FACT_PROJECTIONS.contact[name] ?? name]));
|
|
86
|
-
function mediaRefOf(raw) {
|
|
87
|
-
if (typeof raw !== "string") return null;
|
|
88
|
-
const assetId = raw.trim();
|
|
89
|
-
return assetId.length > 0 ? { asset_id: assetId } : null;
|
|
90
|
-
}
|
|
91
|
-
function mediaRefListOf(raw) {
|
|
92
|
-
if (!Array.isArray(raw)) return [];
|
|
93
|
-
return [...raw].sort((a, b) => (typeof a["position"] === "number" ? a["position"] : 0) - (typeof b["position"] === "number" ? b["position"] : 0)).flatMap((element) => {
|
|
94
|
-
const ref = mediaRefOf(element["id"]);
|
|
95
|
-
if (ref === null) return [];
|
|
96
|
-
if ("floor_label" in element) ref.floor_label = typeof element["floor_label"] === "string" ? element["floor_label"] : null;
|
|
97
|
-
return [ref];
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function readMemberOf(table, row, member) {
|
|
101
|
-
const key = tableKey(table);
|
|
102
|
-
if (key.reading === "legacy") return readLegacyMemberOf(key.table, row, member);
|
|
103
|
-
return readRegistryMemberOf(key.table, row, member);
|
|
104
|
-
}
|
|
105
|
-
function readLegacyMemberOf(table, row, member) {
|
|
106
|
-
const descriptor = FACT_GRAPH[table].row[member];
|
|
107
|
-
if (descriptor === void 0) return null;
|
|
108
|
-
if (table === "contacts") {
|
|
109
|
-
const fact = CONTACT_MEMBER_FACT[member];
|
|
110
|
-
if (fact !== void 0) return resolveContactScalar(row, fact);
|
|
111
|
-
}
|
|
112
|
-
const raw = row[member] ?? null;
|
|
113
|
-
if (descriptor.value_type === "image") return mediaRefOf(raw);
|
|
114
|
-
if (descriptor.value_type === "image_list") return mediaRefListOf(raw);
|
|
115
|
-
return raw;
|
|
116
|
-
}
|
|
117
|
-
function readRegistryMemberOf(table, row, path) {
|
|
118
|
-
const lookup = tableRowMember({
|
|
119
|
-
table,
|
|
120
|
-
reading: "registry"
|
|
121
|
-
}, path);
|
|
16
|
+
function readMemberOf(table, row, path) {
|
|
17
|
+
const lookup = tableRowMember(table, path);
|
|
122
18
|
if (lookup.kind === "identity") return row["id"] ?? null;
|
|
123
19
|
if (lookup.kind === "unknown") return null;
|
|
124
20
|
const dot = path.indexOf(".");
|
|
@@ -127,15 +23,10 @@ function readRegistryMemberOf(table, row, path) {
|
|
|
127
23
|
return isAddressMember(part) ? addressMember(row[path.slice(0, dot)], part) : null;
|
|
128
24
|
}
|
|
129
25
|
function tableRowIds(table, facts) {
|
|
130
|
-
|
|
131
|
-
return tableRowsOf(table, facts).flatMap((row) => {
|
|
132
|
-
const id = row[idKey];
|
|
133
|
-
return typeof id === "string" ? [id] : [];
|
|
134
|
-
});
|
|
26
|
+
return tableRows(table, facts).map((row) => row.id);
|
|
135
27
|
}
|
|
136
28
|
function tableRowById(table, id, facts) {
|
|
137
|
-
|
|
138
|
-
return tableRowsOf(table, facts).find((row) => row[idKey] === id);
|
|
29
|
+
return tableRows(table, facts).find((row) => row.id === id);
|
|
139
30
|
}
|
|
140
31
|
function readRowMember(table, id, member, facts) {
|
|
141
32
|
const row = tableRowById(table, id, facts);
|
|
@@ -143,86 +34,28 @@ function readRowMember(table, id, member, facts) {
|
|
|
143
34
|
}
|
|
144
35
|
function projectTableRows(table, facts, fields, rowComputes = {}, ids) {
|
|
145
36
|
const elementRows = elementRowKeys(fields);
|
|
146
|
-
return projectRows(
|
|
37
|
+
return projectRows(table, facts, rowMemberSources(fields), elementRows, rowComputes, ids);
|
|
147
38
|
}
|
|
148
|
-
function projectRows(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const row = tableRowById(key, id, facts);
|
|
39
|
+
function projectRows(table, facts, members, elementRows, rowComputes, ids) {
|
|
40
|
+
return (ids === void 0 ? tableRows(table, facts) : ids.flatMap((id) => {
|
|
41
|
+
const row = tableRowById(table, id, facts);
|
|
152
42
|
return row === void 0 ? [] : [row];
|
|
153
43
|
})).map((row) => {
|
|
154
|
-
const out = { id: row
|
|
155
|
-
for (const field of elementRows) out[field] = row
|
|
156
|
-
for (const [field, member] of Object.entries(members)) out[field] = readMemberOf(
|
|
157
|
-
for (const [field, compute] of Object.entries(rowComputes)) out[field] = compute((member) => readMemberOf(
|
|
44
|
+
const out = { id: row.id };
|
|
45
|
+
for (const field of elementRows) out[field] = row.id;
|
|
46
|
+
for (const [field, member] of Object.entries(members)) out[field] = readMemberOf(table, row, member);
|
|
47
|
+
for (const [field, compute] of Object.entries(rowComputes)) out[field] = compute((member) => readMemberOf(table, row, member), row.id);
|
|
158
48
|
return out;
|
|
159
49
|
});
|
|
160
50
|
}
|
|
161
|
-
function firstUnit(facts) {
|
|
162
|
-
return tableRowsOf("units", facts)[0];
|
|
163
|
-
}
|
|
164
|
-
function resolveUnitScalar(unit, field) {
|
|
165
|
-
switch (field) {
|
|
166
|
-
case "beds": return unit?.beds ?? null;
|
|
167
|
-
case "baths": return unit?.baths ?? null;
|
|
168
|
-
case "sqft": return unit?.sqft ?? null;
|
|
169
|
-
case "price": return unit?.price ?? null;
|
|
170
|
-
case "unit_label": return unit?.unit_label ?? null;
|
|
171
|
-
default: return null;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function resolvePropertyScalar(facts, field) {
|
|
175
|
-
const address = readLegacyFact(facts, "address");
|
|
176
|
-
if (field === "address") {
|
|
177
|
-
if (address && typeof address === "object") return address.display ?? null;
|
|
178
|
-
return address;
|
|
179
|
-
}
|
|
180
|
-
const part = ADDRESS_PARTS[field];
|
|
181
|
-
if (part !== void 0) return readAddressPart(address, part);
|
|
182
|
-
const virtual = primaryContactFactValue(facts, field);
|
|
183
|
-
if (virtual !== void 0) return virtual;
|
|
184
|
-
return readLegacyFact(facts, field);
|
|
185
|
-
}
|
|
186
|
-
const CONTACT_FIELD_TO_CONTACT_MEMBER = Object.fromEntries(Object.entries(CONTACT_MEMBER_FACT).map(([member, fact]) => [fact, member]));
|
|
187
|
-
function resolveContactScalar(contact, field) {
|
|
188
|
-
if (REFERRAL_FIELD_SET.has(field)) return resolveContactCardField(contact, field);
|
|
189
|
-
const key = CONTACT_FIELD_TO_CONTACT_MEMBER[field];
|
|
190
|
-
if (key === void 0) return null;
|
|
191
|
-
const raw = contact?.[key] ?? null;
|
|
192
|
-
if (typeof raw !== "string") return null;
|
|
193
|
-
const trimmed = raw.trim();
|
|
194
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
195
|
-
}
|
|
196
51
|
function readFactRef(facts, key) {
|
|
197
|
-
if (isRegistryFactKey(key)) return readRegistryFact(key,
|
|
52
|
+
if (isRegistryFactKey(key)) return readRegistryFact(key, facts);
|
|
198
53
|
if (isMediaListKey(key)) return facts[key.slice(9)];
|
|
199
|
-
const table =
|
|
200
|
-
if (table
|
|
54
|
+
const table = tableOf(key);
|
|
55
|
+
if (table !== null) return tableRows(table, facts);
|
|
201
56
|
const column = tableColumnOfKey(key);
|
|
202
|
-
if (column !== null) return
|
|
203
|
-
return readLegacyFact(facts, key);
|
|
204
|
-
}
|
|
205
|
-
function readFrom(field, ctx) {
|
|
206
|
-
if (isRegistryFactKey(field)) return readFactRef(ctx.facts, field);
|
|
207
|
-
const desc = SOURCE_FIELDS[field];
|
|
208
|
-
if (!desc) return null;
|
|
209
|
-
if (Object.hasOwn(TABLES, field)) return null;
|
|
210
|
-
if (desc.container === "contact") return resolveContactScalar(ctx.contact ?? contactsOf(ctx.facts)[0], field);
|
|
211
|
-
if (desc.container === "unit") return resolveUnitScalar(ctx.unit ?? firstUnit(ctx.facts), field);
|
|
212
|
-
return resolvePropertyScalar(ctx.facts, field);
|
|
213
|
-
}
|
|
214
|
-
const ADDRESS_PARTS = {
|
|
215
|
-
address_street: "street",
|
|
216
|
-
address_unit: "unit",
|
|
217
|
-
address_city: "city",
|
|
218
|
-
address_state: "state",
|
|
219
|
-
address_postal: "postal"
|
|
220
|
-
};
|
|
221
|
-
function readAddressPart(address, part) {
|
|
222
|
-
if (!address || typeof address !== "object") return null;
|
|
223
|
-
const trimmed = (address[part] ?? "").trim();
|
|
224
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
57
|
+
if (column !== null) return tableRows(column.table, facts).map((row) => row[column.member] ?? null);
|
|
225
58
|
}
|
|
226
59
|
|
|
227
60
|
//#endregion
|
|
228
|
-
export {
|
|
61
|
+
export { projectTableRows, readFactRef, readRowMember, tableRowById, tableRowIds, tableRows };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ASSETS_DIR, ASSET_URL_PREFIX, CAPTURES_DIR, CAPTURE_FILES, FIXTURES_DIR, FIXTURE_FILES, MANIFEST_FILE, PLAYGROUND_CLIENT_DIR, PLAYGROUND_DIR, PLAYGROUND_FILES, SECTIONS_DIR, SECTION_FILES, SECTION_ISLANDS_DIR, STATIC_DIR, TEMPLATE_DIR, TEMPLATE_FILES, UNHASHED_DIRS, assetPath, boundFiles, capturePath, fixturePath, isFixtureId, isSectionKey, isTemplateKey, islandPath, playgroundPath, publishedSectionKey, sectionDir, sectionOfIslandKey, sectionPath, staticPath, templatePath } from "./layout.js";
|
|
1
|
+
import { ASSETS_DIR, ASSET_URL_PREFIX, CAPTURES_DIR, CAPTURE_FILES, FIXTURES_DIR, FIXTURE_FILES, MANIFEST_FILE, PLAYGROUND_CANVAS_ISLAND_HOST, PLAYGROUND_CLIENT_DIR, PLAYGROUND_DIR, PLAYGROUND_FILES, SECTIONS_DIR, SECTION_FILES, SECTION_ISLANDS_DIR, STATIC_DIR, STORED_DIRS, TEMPLATE_DIR, TEMPLATE_FILES, UNHASHED_DIRS, assetPath, boundFiles, capturePath, fixturePath, isFixtureId, isSectionKey, isTemplateKey, islandPath, playgroundPath, publishedSectionKey, sectionDir, sectionOfIslandKey, sectionPath, staticPath, templatePath } from "./layout.js";
|
|
2
2
|
import { sha256Hex } from "./sha256.js";
|
|
3
3
|
import { listingDigest, sectionContentHash, sourceDigest, templateContentHash } from "./hash.js";
|
|
4
4
|
import { ArtifactManifest, ArtifactScope, ArtifactSection, readArtifactSchema } from "./manifest.js";
|
|
@@ -14,8 +14,10 @@ const UNHASHED_DIRS = [
|
|
|
14
14
|
PLAYGROUND_DIR,
|
|
15
15
|
CAPTURES_DIR
|
|
16
16
|
];
|
|
17
|
+
const STORED_DIRS = [ASSETS_DIR, CAPTURES_DIR];
|
|
17
18
|
const FIXTURE_FILES = {
|
|
18
19
|
contentDoc: "content-doc.json",
|
|
20
|
+
settledDoc: "settled-doc.json",
|
|
19
21
|
property: "property.json",
|
|
20
22
|
meta: "meta.json"
|
|
21
23
|
};
|
|
@@ -24,9 +26,11 @@ const CAPTURE_FILES = {
|
|
|
24
26
|
document: "document.pdf"
|
|
25
27
|
};
|
|
26
28
|
const ASSET_URL_PREFIX = "/section-assets/";
|
|
29
|
+
const PLAYGROUND_CANVAS_ISLAND_HOST = "island-canvas-host.mjs";
|
|
27
30
|
const PLAYGROUND_FILES = {
|
|
28
31
|
host: "host.mjs",
|
|
29
|
-
clientShell: `${PLAYGROUND_CLIENT_DIR}/index.html
|
|
32
|
+
clientShell: `${PLAYGROUND_CLIENT_DIR}/index.html`,
|
|
33
|
+
canvasIslandHost: `${PLAYGROUND_CLIENT_DIR}/${PLAYGROUND_CANVAS_ISLAND_HOST}`
|
|
30
34
|
};
|
|
31
35
|
function playgroundPath(file) {
|
|
32
36
|
return `${PLAYGROUND_DIR}/${file}`;
|
|
@@ -107,19 +111,17 @@ function boundFiles(binding) {
|
|
|
107
111
|
for (const facade of Object.values(binding.react_vendor ?? {})) ref(staticPath(facade.filename), facade);
|
|
108
112
|
if (binding.react_vendor_core !== null) ref(staticPath(binding.react_vendor_core.filename), binding.react_vendor_core);
|
|
109
113
|
if (binding.analytics !== null) ref(staticPath(binding.analytics.filename), binding.analytics);
|
|
110
|
-
for (const filename of Object.values(binding.masters
|
|
114
|
+
for (const filename of Object.values(binding.masters)) out.push({
|
|
111
115
|
path: assetPath(filename),
|
|
112
116
|
filename
|
|
113
117
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
ref(assetPath(apple_touch.filename), apple_touch);
|
|
120
|
-
}
|
|
118
|
+
const { ico, svg, png, apple_touch } = binding.icons;
|
|
119
|
+
ref(assetPath(ico.filename), ico);
|
|
120
|
+
if (svg !== null) ref(assetPath(svg.filename), svg);
|
|
121
|
+
for (const size of Object.values(png)) ref(assetPath(size.filename), size);
|
|
122
|
+
ref(assetPath(apple_touch.filename), apple_touch);
|
|
121
123
|
return out;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
//#endregion
|
|
125
|
-
export { ASSETS_DIR, ASSET_URL_PREFIX, CAPTURES_DIR, CAPTURE_FILES, FIXTURES_DIR, FIXTURE_FILES, MANIFEST_FILE, PLAYGROUND_CLIENT_DIR, PLAYGROUND_DIR, PLAYGROUND_FILES, SECTIONS_DIR, SECTION_FILES, SECTION_ISLANDS_DIR, STATIC_DIR, TEMPLATE_DIR, TEMPLATE_FILES, UNHASHED_DIRS, assetPath, boundFiles, capturePath, fixturePath, isFixtureId, isSectionKey, isTemplateKey, islandPath, playgroundPath, publishedSectionKey, sectionDir, sectionOfIslandKey, sectionPath, staticPath, templatePath };
|
|
127
|
+
export { ASSETS_DIR, ASSET_URL_PREFIX, CAPTURES_DIR, CAPTURE_FILES, FIXTURES_DIR, FIXTURE_FILES, MANIFEST_FILE, PLAYGROUND_CANVAS_ISLAND_HOST, PLAYGROUND_CLIENT_DIR, PLAYGROUND_DIR, PLAYGROUND_FILES, SECTIONS_DIR, SECTION_FILES, SECTION_ISLANDS_DIR, STATIC_DIR, STORED_DIRS, TEMPLATE_DIR, TEMPLATE_FILES, UNHASHED_DIRS, assetPath, boundFiles, capturePath, fixturePath, isFixtureId, isSectionKey, isTemplateKey, islandPath, playgroundPath, publishedSectionKey, sectionDir, sectionOfIslandKey, sectionPath, staticPath, templatePath };
|
|
@@ -11,7 +11,7 @@ const ArtifactSection = z.object({
|
|
|
11
11
|
content_hash: Sha256
|
|
12
12
|
}).strict();
|
|
13
13
|
const ArtifactManifest = z.object({
|
|
14
|
-
artifact_schema: z.literal(
|
|
14
|
+
artifact_schema: z.literal(4),
|
|
15
15
|
framework_version: z.string().min(1),
|
|
16
16
|
key: z.string().refine(isTemplateKey, "a template key: one path segment"),
|
|
17
17
|
display_name: z.string().min(1),
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { ASSETS_DIR, ASSET_URL_PREFIX, FIXTURES_DIR, FIXTURE_FILES, MANIFEST_FILE, PLAYGROUND_CLIENT_DIR, PLAYGROUND_DIR, PLAYGROUND_FILES, SECTIONS_DIR, SECTION_FILES, SECTION_ISLANDS_DIR, STATIC_DIR, TEMPLATE_DIR, TEMPLATE_FILES, UNHASHED_DIRS, boundFiles, fixturePath, playgroundPath, sectionPath, templatePath } from "./layout.js";
|
|
1
|
+
import { ASSETS_DIR, ASSET_URL_PREFIX, FIXTURES_DIR, FIXTURE_FILES, MANIFEST_FILE, PLAYGROUND_CLIENT_DIR, PLAYGROUND_DIR, PLAYGROUND_FILES, SECTIONS_DIR, SECTION_FILES, SECTION_ISLANDS_DIR, STATIC_DIR, STORED_DIRS, TEMPLATE_DIR, TEMPLATE_FILES, UNHASHED_DIRS, boundFiles, fixturePath, playgroundPath, sectionPath, templatePath } from "./layout.js";
|
|
2
2
|
import { sha256Hex } from "./sha256.js";
|
|
3
3
|
import { sectionContentHash, templateContentHash } from "./hash.js";
|
|
4
4
|
import { ArtifactManifest, readArtifactSchema } from "./manifest.js";
|
|
5
5
|
|
|
6
6
|
//#region ../../internal/template-artifact/dist/verify.js
|
|
7
7
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const TEMPLATE_FILE_NAMES = /* @__PURE__ */ new Set([...Object.values(TEMPLATE_FILES), RETIRED_FILE]);
|
|
8
|
+
const SECTION_FILE_NAMES = new Set(Object.values(SECTION_FILES));
|
|
9
|
+
const TEMPLATE_FILE_NAMES = new Set(Object.values(TEMPLATE_FILES));
|
|
11
10
|
const ISLAND_CHUNK = new RegExp(`^${SECTION_ISLANDS_DIR}/[A-Za-z0-9._-]+\\.mjs$`);
|
|
12
11
|
const FLAT_FILE = /^[A-Za-z0-9._-]+$/;
|
|
13
12
|
const CLIENT_SEGMENT = /^(?!\.{1,2}$)[A-Za-z0-9._-]+$/;
|
|
@@ -47,18 +46,27 @@ function composedSections(composition) {
|
|
|
47
46
|
}
|
|
48
47
|
return keys;
|
|
49
48
|
}
|
|
50
|
-
function verifyArtifact(files) {
|
|
49
|
+
function verifyArtifact(files, stored = /* @__PURE__ */ new Map()) {
|
|
51
50
|
const problems = [];
|
|
51
|
+
const present = (path) => files.has(path) || stored.has(path);
|
|
52
|
+
for (const path of stored.keys()) if (files.has(path)) problems.push({
|
|
53
|
+
path,
|
|
54
|
+
message: "is carried both as bytes and as a stored file"
|
|
55
|
+
});
|
|
56
|
+
else if (!STORED_DIRS.includes(path.split("/")[0])) problems.push({
|
|
57
|
+
path,
|
|
58
|
+
message: `is held as a stored file, which only ${STORED_DIRS.map((dir) => `${dir}/`).join(" and ")} may be`
|
|
59
|
+
});
|
|
52
60
|
const raw = readJson(files, MANIFEST_FILE, problems);
|
|
53
61
|
if (raw === null) return {
|
|
54
62
|
manifest: null,
|
|
55
63
|
problems
|
|
56
64
|
};
|
|
57
65
|
const schema = readArtifactSchema(raw.value);
|
|
58
|
-
if (schema !==
|
|
66
|
+
if (schema !== 4) {
|
|
59
67
|
problems.push({
|
|
60
68
|
path: MANIFEST_FILE,
|
|
61
|
-
message: schema === null ? `carries no integer artifact_schema; this reader knows ${String(
|
|
69
|
+
message: schema === null ? `carries no integer artifact_schema; this reader knows ${String(4)}` : `artifact_schema ${String(schema)} is not one this reader knows (it knows ${String(4)})`
|
|
62
70
|
});
|
|
63
71
|
return {
|
|
64
72
|
manifest: null,
|
|
@@ -78,7 +86,7 @@ function verifyArtifact(files) {
|
|
|
78
86
|
}
|
|
79
87
|
const manifest = parsed.data;
|
|
80
88
|
const listed = new Set(manifest.sections.map((section) => section.key));
|
|
81
|
-
for (const path of files.keys()) {
|
|
89
|
+
for (const path of [...files.keys(), ...stored.keys()]) {
|
|
82
90
|
if (path === "manifest.json") continue;
|
|
83
91
|
const slash = path.indexOf("/");
|
|
84
92
|
const top = slash < 0 ? path : path.slice(0, slash);
|
|
@@ -138,7 +146,7 @@ function verifyArtifact(files) {
|
|
|
138
146
|
for (const id of manifest.fixtures) for (const file of Object.values(FIXTURE_FILES)) {
|
|
139
147
|
const path = fixturePath(id, file);
|
|
140
148
|
if (readJson(files, path, problems) === null) continue;
|
|
141
|
-
for (const match of decoder.decode(files.get(path)).matchAll(ASSET_URL)) if (!
|
|
149
|
+
for (const match of decoder.decode(files.get(path)).matchAll(ASSET_URL)) if (!present(`${"assets"}/${match[1]}`)) problems.push({
|
|
142
150
|
path,
|
|
143
151
|
message: `names ${match[0]}, which ${ASSETS_DIR}/ does not carry`
|
|
144
152
|
});
|
|
@@ -219,14 +227,18 @@ function verifyArtifact(files) {
|
|
|
219
227
|
for (const file of bound ?? []) {
|
|
220
228
|
boundPaths.add(file.path);
|
|
221
229
|
const bytes = files.get(file.path);
|
|
222
|
-
|
|
230
|
+
const digest = stored.get(file.path)?.sha256;
|
|
231
|
+
if (bytes === void 0 && digest === void 0) problems.push({
|
|
223
232
|
path: file.path,
|
|
224
233
|
message: `named by the binding as ${file.filename}, and missing`
|
|
225
234
|
});
|
|
226
|
-
else if (file.contentHash !== void 0
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
235
|
+
else if (file.contentHash !== void 0) {
|
|
236
|
+
const actual = digest ?? sha256Hex(bytes);
|
|
237
|
+
if (actual !== file.contentHash) problems.push({
|
|
238
|
+
path: file.path,
|
|
239
|
+
message: `the binding states content hash ${file.contentHash} for ${file.filename}; the bytes hash to ${actual}`
|
|
240
|
+
});
|
|
241
|
+
}
|
|
230
242
|
}
|
|
231
243
|
if (bound !== void 0) for (const path of files.keys()) {
|
|
232
244
|
const parts = path.split("/");
|
|
@@ -4,6 +4,29 @@ import "./fact-registry.js";
|
|
|
4
4
|
|
|
5
5
|
//#region ../../internal/template-contracts/dist/content-pick.js
|
|
6
6
|
const DEFAULT_SLOT_ASPECT = 16 / 10;
|
|
7
|
+
function storedCrop(crop) {
|
|
8
|
+
if (crop === null || typeof crop !== "object") return null;
|
|
9
|
+
const box = crop;
|
|
10
|
+
const [x, y, width, height] = [
|
|
11
|
+
"x",
|
|
12
|
+
"y",
|
|
13
|
+
"width",
|
|
14
|
+
"height"
|
|
15
|
+
].map((key) => box[key]);
|
|
16
|
+
if (![
|
|
17
|
+
x,
|
|
18
|
+
y,
|
|
19
|
+
width,
|
|
20
|
+
height
|
|
21
|
+
].every((n) => typeof n === "number" && Number.isFinite(n))) return null;
|
|
22
|
+
if (x === 0 && y === 0 && width === 1 && height === 1) return null;
|
|
23
|
+
return {
|
|
24
|
+
x,
|
|
25
|
+
y,
|
|
26
|
+
width,
|
|
27
|
+
height
|
|
28
|
+
};
|
|
29
|
+
}
|
|
7
30
|
function slotCropAspects(crop) {
|
|
8
31
|
if (crop === null || typeof crop !== "object") return {
|
|
9
32
|
mode: "free",
|
|
@@ -48,4 +71,4 @@ function placeCrop(stored, imageAspect, aspects, framing) {
|
|
|
48
71
|
}
|
|
49
72
|
|
|
50
73
|
//#endregion
|
|
51
|
-
export { DEFAULT_SLOT_ASPECT, defaultCrop, placeCrop, sameCrop, slotCropAspects };
|
|
74
|
+
export { DEFAULT_SLOT_ASPECT, defaultCrop, placeCrop, sameCrop, slotCropAspects, storedCrop };
|
|
@@ -10,8 +10,8 @@ import { ResponsiveImage } from "./responsive-image.js";
|
|
|
10
10
|
* poster.
|
|
11
11
|
*/
|
|
12
12
|
type DocumentValue = {
|
|
13
|
-
/** The
|
|
14
|
-
|
|
13
|
+
/** The media this slot points at — the whole stored value, under the one member every resolved media value names its media by. */
|
|
14
|
+
id: string;
|
|
15
15
|
/**
|
|
16
16
|
* Served source — the editor gets a presigned URL, a published page gets the
|
|
17
17
|
* relative asset path. Same pivot as an image's or a video's `url`, so a
|
|
@@ -32,13 +32,11 @@ type DocumentValue = {
|
|
|
32
32
|
* The first page's preview URL, or `''` when there is none — a preview is
|
|
33
33
|
* rendered after the upload lands, and only for a PDF. Named like a video's
|
|
34
34
|
* and a tour's poster because it plays the same part: the still `<Slot.Image>`
|
|
35
|
-
* draws for a slot whose
|
|
35
|
+
* draws for a slot whose media is not itself an image.
|
|
36
36
|
*/
|
|
37
37
|
poster: string;
|
|
38
38
|
/** The preview's responsive ladder, when one exists. Absent, `<Image>` falls back to `poster`. */
|
|
39
39
|
poster_responsive?: ResponsiveImage;
|
|
40
40
|
};
|
|
41
|
-
/** A document list slot's runtime value: an ordered array of `DocumentValue`, possibly empty. */
|
|
42
|
-
type DocumentCollectionValue = DocumentValue[];
|
|
43
41
|
//#endregion
|
|
44
|
-
export {
|
|
42
|
+
export { DocumentValue };
|
|
@@ -2,6 +2,7 @@ import { AddressMember, AddressValue } from "./address-value.js";
|
|
|
2
2
|
import { MediaKind } from "./slot-catalog.js";
|
|
3
3
|
import { PropertyFactRegistry } from "./fact-registry.js";
|
|
4
4
|
import { MediaReference } from "./registry-facts.js";
|
|
5
|
+
import "./section-schema-types.js";
|
|
5
6
|
//#region ../../internal/template-contracts/dist/fact-keys.d.ts
|
|
6
7
|
type PropertyPages = PropertyFactRegistry["pages"];
|
|
7
8
|
type PageName = keyof PropertyPages & string;
|
|
@@ -21,7 +22,7 @@ type AddressRegistryFactKey = `property.${AddressPageName}`;
|
|
|
21
22
|
/**
|
|
22
23
|
* The value a fact ref or a bound slot receives for registry key `K` — `readFacts`'
|
|
23
24
|
* (./registry-shape) reading of its declaration, typed: an address its value, a part
|
|
24
|
-
* its part, a number a number, an image its media reference (a read hands its
|
|
25
|
+
* its part, a number a number, an image its media reference (a read hands its media
|
|
25
26
|
* record), every other scalar text.
|
|
26
27
|
*/
|
|
27
28
|
type RegistryFactValue<K extends RegistryFactKey> = K extends `${AddressRegistryFactKey}.${infer M extends AddressMember}` ? AddressValue[M] : K extends `property.${infer P extends FactPageName}` ? DeclarationOf<P> extends {
|
|
@@ -38,7 +39,7 @@ type MediaListName = { [P in PageName]: DeclarationOf<P> extends {
|
|
|
38
39
|
readonly type: MediaKind | "media";
|
|
39
40
|
};
|
|
40
41
|
} ? P : never; }[PageName];
|
|
41
|
-
/** A media list's registry key — what a media declaration's `from` names and a `compute()` reads as its
|
|
42
|
+
/** A media list's registry key — what a media declaration's `from` names and a `compute()` reads as its media records. */
|
|
42
43
|
type MediaListKey = `property.${MediaListName}`;
|
|
43
44
|
//#endregion
|
|
44
45
|
export { AddressRegistryFactKey, MediaListKey, MediaListName, RegistryFactKey, RegistryFactValue };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { normalizeAddressValue } from "./address-value.js";
|
|
2
|
-
import {
|
|
2
|
+
import { declaredKinds } from "./slot-catalog.js";
|
|
3
3
|
import { mediaIdOf } from "./registry-facts.js";
|
|
4
|
-
import { mediaListKeysOf, registryFactsOf, tableColumnOfKey } from "./registry-shape.js";
|
|
5
|
-
import { legacyFactKey } from "./registry-aliases.js";
|
|
4
|
+
import { mediaListKeysOf, registryFactsOf, tableColumnOfKey, tableOf } from "./registry-shape.js";
|
|
6
5
|
import { propertyFacts } from "./fact-registry.js";
|
|
7
6
|
|
|
8
7
|
//#region ../../internal/template-contracts/dist/fact-keys.js
|
|
@@ -20,19 +19,6 @@ function registryFact(key) {
|
|
|
20
19
|
function registryFactValueType(key) {
|
|
21
20
|
return registryFact(key).value_type;
|
|
22
21
|
}
|
|
23
|
-
function sourceFieldDescriptor(field) {
|
|
24
|
-
const fields = SOURCE_FIELDS;
|
|
25
|
-
if (!isRegistryFactKey(field)) {
|
|
26
|
-
const legacy = legacyFactKey(field);
|
|
27
|
-
return Object.hasOwn(fields, legacy) ? fields[legacy] : void 0;
|
|
28
|
-
}
|
|
29
|
-
const value_type = registryFactValueType(field);
|
|
30
|
-
return {
|
|
31
|
-
container: "property",
|
|
32
|
-
value_type,
|
|
33
|
-
...value_type === "image" ? { image: true } : {}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
22
|
function mediaListKeys() {
|
|
37
23
|
return mediaListKeysOf(propertyFacts);
|
|
38
24
|
}
|
|
@@ -45,19 +31,12 @@ function mediaListKinds(key) {
|
|
|
45
31
|
return element === void 0 ? void 0 : declaredKinds(element);
|
|
46
32
|
}
|
|
47
33
|
function isReadableFactKey(key) {
|
|
48
|
-
|
|
49
|
-
return Object.hasOwn(FACT_GRAPH, key);
|
|
34
|
+
return isRegistryFactKey(key) || isMediaListKey(key) || tableOf(key) !== null || tableColumnOfKey(key) !== null;
|
|
50
35
|
}
|
|
51
|
-
function
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
lon: facts.address.longitude,
|
|
56
|
-
listing_intent: facts.listing_intent,
|
|
57
|
-
description: facts.description,
|
|
58
|
-
hero: facts.hero,
|
|
59
|
-
site_url: facts.site_url
|
|
60
|
-
};
|
|
36
|
+
function factSelectValues(key) {
|
|
37
|
+
if (!isRegistryFactKey(key)) return void 0;
|
|
38
|
+
const declaration = registryFact(key).declaration;
|
|
39
|
+
return declaration.type === "select" ? declaration.values : void 0;
|
|
61
40
|
}
|
|
62
41
|
function text(value) {
|
|
63
42
|
return typeof value === "string" ? value : null;
|
|
@@ -66,23 +45,20 @@ function mediaRef(value) {
|
|
|
66
45
|
const id = mediaIdOf(value);
|
|
67
46
|
return id === void 0 ? null : { media: id };
|
|
68
47
|
}
|
|
69
|
-
function readRegistryFact(key,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
case "
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...root.address !== null && typeof root.address === "object" ? root.address : {},
|
|
78
|
-
latitude: root.lat,
|
|
79
|
-
longitude: root.lon
|
|
80
|
-
});
|
|
81
|
-
if (key === "property.address") return address;
|
|
82
|
-
return address === null ? null : address[key.slice(17)];
|
|
48
|
+
function readRegistryFact(key, facts) {
|
|
49
|
+
const [, name = "", part] = key.split(".");
|
|
50
|
+
const value = facts[name];
|
|
51
|
+
switch (registryFactValueType(`property.${name}`)) {
|
|
52
|
+
case "address": {
|
|
53
|
+
const address = normalizeAddressValue(value);
|
|
54
|
+
if (part === void 0) return address;
|
|
55
|
+
return address === null ? null : address[part];
|
|
83
56
|
}
|
|
57
|
+
case "image": return mediaRef(value);
|
|
58
|
+
case "number": return typeof value === "number" ? value : null;
|
|
59
|
+
case "text": return text(value);
|
|
84
60
|
}
|
|
85
61
|
}
|
|
86
62
|
|
|
87
63
|
//#endregion
|
|
88
|
-
export { isMediaListKey, isReadableFactKey, isRegistryFactKey,
|
|
64
|
+
export { factSelectValues, isMediaListKey, isReadableFactKey, isRegistryFactKey, mediaListKeys, mediaListKinds, readRegistryFact, registryFact, registryFactKeys, registryFactValueType };
|
|
@@ -106,6 +106,23 @@ type FactRegistry<H extends FactHome = FactHome, P extends Readonly<Record<strin
|
|
|
106
106
|
} & (string extends keyof P ? unknown : PageRefs<H, P>);
|
|
107
107
|
/** The registry's facts, each a page: a bare declaration as a fact with no page. */
|
|
108
108
|
type FactEntries<P> = { readonly [K in keyof P]: P[K] extends FactPage<unknown> ? P[K] : PagelessFact<P[K]>; };
|
|
109
|
+
declare const libraryContacts: PagedFact<ListSlotDef<NoInfer<ObjectSlotDef<{
|
|
110
|
+
readonly headshot: ImageSlotDef & FillMark;
|
|
111
|
+
readonly name: TextSlotDef<"short"> & FillMark;
|
|
112
|
+
readonly title: TextSlotDef<"short"> & FillMark;
|
|
113
|
+
readonly org_name: TextSlotDef<"short"> & FillMark;
|
|
114
|
+
readonly email: EmailSlotDef & FillMark;
|
|
115
|
+
readonly phone: PhoneSlotDef & FillMark;
|
|
116
|
+
readonly website: UrlSlotDef & FillMark;
|
|
117
|
+
readonly address: AddressSlotDef & AddressMembers & FillMark;
|
|
118
|
+
readonly bio: TextSlotDef<"long"> & FillMark;
|
|
119
|
+
readonly logo_dark: ImageSlotDef & FillMark;
|
|
120
|
+
readonly logo_light: ImageSlotDef & FillMark;
|
|
121
|
+
readonly instagram: UrlSlotDef & FillMark;
|
|
122
|
+
readonly linkedin: UrlSlotDef & FillMark;
|
|
123
|
+
readonly x: UrlSlotDef & FillMark;
|
|
124
|
+
readonly facebook: UrlSlotDef & FillMark;
|
|
125
|
+
}>>, null, number> & FillMark>;
|
|
109
126
|
/**
|
|
110
127
|
* The org's facts: what is stored once per org and reused on every property. Today that
|
|
111
128
|
* is the contacts; a template's library facts join it later (T10).
|
|
@@ -199,7 +216,7 @@ declare const propertyFacts: FactRegistry<"property", FactEntries<{
|
|
|
199
216
|
readonly listing_intent: PagedFact<SelectSlotDef & FillMark>;
|
|
200
217
|
/** The property's description, the substrate every text decision is grounded in. Read-only. */
|
|
201
218
|
readonly description: PagedFact<TextSlotDef<"long"> & FillMark>;
|
|
202
|
-
/** Every upload the property holds — photos, floor plans, videos, tours and documents — in the list's order. A `compute()` reads it as `readonly Media[]`, each upload its
|
|
219
|
+
/** Every upload the property holds — photos, floor plans, videos, tours and documents — in the list's order. A `compute()` reads it as `readonly Media[]`, each upload its media record; a media slot picks `from` it. Read-only, and binds no slot. */
|
|
203
220
|
readonly uploads: PagedFact<ListSlotDef<NoInfer<MediaSlotDef<"image" | "video" | "tour" | "document"> & FillMark>, null, number> & FillMark>;
|
|
204
221
|
/** What shows the property — its photos, videos and tours, sorted out of the uploads. A `compute()` reads it as `readonly Media[]`; a media slot picks `from` it. */
|
|
205
222
|
readonly property_media: ListSlotDef<NoInfer<MediaSlotDef<"image" | "video" | "tour"> & FillMark>, null, number> & FillMark;
|
|
@@ -207,7 +224,7 @@ declare const propertyFacts: FactRegistry<"property", FactEntries<{
|
|
|
207
224
|
readonly floor_plans: ListSlotDef<NoInfer<ImageSlotDef & FillMark>, null, number> & FillMark;
|
|
208
225
|
/** The property's informational documents — what sets out its figures, finances, terms, legal record, condition or plans — sorted out of the uploads. A `compute()` reads it as `readonly Media[]`; a media slot picks `from` it. */
|
|
209
226
|
readonly property_documents: ListSlotDef<NoInfer<MediaSlotDef<"image" | "video" | "document"> & FillMark>, null, number> & FillMark;
|
|
210
|
-
/** The property's cover photo, picked from its media. An `image` slot binds it (`source: fact.property.hero`) and a `compute()` reads it, each as its
|
|
227
|
+
/** The property's cover photo, picked from its media. An `image` slot binds it (`source: fact.property.hero`) and a `compute()` reads it, each as its media record (`Media`). Read-only. */
|
|
211
228
|
readonly hero: ImageSlotDef & FillMark;
|
|
212
229
|
/** The property's website address, `https://` and its chosen hostname, `null` when the property has no domain. It exists from the moment a domain is chosen, before the site is first published. A `compute()` reads it (`reads: [fact.property.site_url]`). Read-only. */
|
|
213
230
|
readonly site_url: UrlSlotDef & FillMark;
|
|
@@ -276,6 +293,10 @@ declare const propertyFacts: FactRegistry<"property", FactEntries<{
|
|
|
276
293
|
type PropertyFactRegistry = typeof propertyFacts;
|
|
277
294
|
/** The library registry's type — what `libraryFacts` declares. */
|
|
278
295
|
type LibraryFactRegistry = typeof libraryFacts;
|
|
296
|
+
/** The library's tables' pages, typed apart from `libraryFacts` as the property's are: a table's name is read off them. */
|
|
297
|
+
interface LibraryTablePages {
|
|
298
|
+
readonly contacts: typeof libraryContacts;
|
|
299
|
+
}
|
|
279
300
|
/**
|
|
280
301
|
* The property's own tables' pages, typed apart from `propertyFacts`: a row's member
|
|
281
302
|
* types read their items here (./table-members), because the registry declares the
|
|
@@ -287,4 +308,4 @@ interface PropertyTablePages {
|
|
|
287
308
|
readonly commercial_spaces: typeof commercial_spaces;
|
|
288
309
|
}
|
|
289
310
|
//#endregion
|
|
290
|
-
export { FACT_HOMES, FactDeclaration, FactHead, FactHome, FactPage, FactRegistry, FactSource, LibraryFactRegistry, ListDeclaration, MediaDeclaration, ObjectDeclaration, PageHead, PagedFact, PagelessFact, PropertyFactRegistry, PropertyTablePages, RowDeclaration, ValueDeclaration, libraryFacts, propertyFacts };
|
|
311
|
+
export { FACT_HOMES, FactDeclaration, FactHead, FactHome, FactPage, FactRegistry, FactSource, LibraryFactRegistry, LibraryTablePages, ListDeclaration, MediaDeclaration, ObjectDeclaration, PageHead, PagedFact, PagelessFact, PropertyFactRegistry, PropertyTablePages, RowDeclaration, ValueDeclaration, libraryFacts, propertyFacts };
|