@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
|
@@ -83,7 +83,7 @@ function resolveMediaLists(at, from, scope) {
|
|
|
83
83
|
function resolveMediaList(at, from, scope) {
|
|
84
84
|
const key = typeof from === "object" && from !== null ? scope.pages.get(from) : void 0;
|
|
85
85
|
const resolved = typeof from === "string" ? from : key === void 0 ? void 0 : `${scope.home}.${key}`;
|
|
86
|
-
if (resolved === void 0 || !scope.mediaLists.has(resolved)) throw new Error(`${at} picks \`from\` something other than one of this registry's media lists — a media field picks from a list of media (the \`uploads\` page, a sorted list), by its const, or owns its
|
|
86
|
+
if (resolved === void 0 || !scope.mediaLists.has(resolved)) throw new Error(`${at} picks \`from\` something other than one of this registry's media lists — a media field picks from a list of media (the \`uploads\` page, a sorted list), by its const, or owns its media.`);
|
|
87
87
|
return resolved;
|
|
88
88
|
}
|
|
89
89
|
function resolveCompute(at, binding, scope) {
|
|
@@ -105,6 +105,11 @@ function refuseHolderKeys(at, slot) {
|
|
|
105
105
|
if (slot["required"] !== void 0) throw new Error(`${at} declares \`required\` — a fact requires nothing on its own account; what a property must answer is what its templates require.`);
|
|
106
106
|
if (slot["type"] === "poi") throw new Error(`${at} is a poi — a place the platform builds is no fact.`);
|
|
107
107
|
}
|
|
108
|
+
function refuseHomeFills(at, home, slot) {
|
|
109
|
+
const fills = getFills(slot) ?? [];
|
|
110
|
+
if (home === "library" && fills.length > 0) throw new Error(`${at} declares a fill — a library's facts are the org's own, and nothing fills them.`);
|
|
111
|
+
if (fills.some((binding) => binding.verb === "find")) throw new Error(`${at} declares a \`find\` — a home's fact is answered, written or picked, never looked up.`);
|
|
112
|
+
}
|
|
108
113
|
function refuseObjectPicks(at, element) {
|
|
109
114
|
const { type, fields } = element;
|
|
110
115
|
if (type !== "object" || fields === void 0) return;
|
|
@@ -119,6 +124,7 @@ function fieldScope(objectSlot) {
|
|
|
119
124
|
}
|
|
120
125
|
function resolveDeclaration(at, slot, scope) {
|
|
121
126
|
refuseHolderKeys(at, slot);
|
|
127
|
+
refuseHomeFills(at, scope.home, slot);
|
|
122
128
|
let out = plainSlot(mapSlotRefs(slot, (read) => resolveRead(at, read, scope)));
|
|
123
129
|
if (out["from"] !== void 0 && (isMediaKind(String(out["type"])) || out["type"] === "media")) out = {
|
|
124
130
|
...out,
|
|
@@ -251,7 +257,7 @@ function comparableDistanceMeters(comp, subject) {
|
|
|
251
257
|
if (comp?.latitude == null || comp.longitude == null || subject?.latitude == null || subject.longitude == null) return null;
|
|
252
258
|
return Math.round(haversineMeters(subject.latitude, subject.longitude, comp.latitude, comp.longitude));
|
|
253
259
|
}
|
|
254
|
-
const
|
|
260
|
+
const libraryContacts = page({
|
|
255
261
|
title: "Your contacts",
|
|
256
262
|
description: "The people your listings name, with the headshots and logos they carry."
|
|
257
263
|
}, list({
|
|
@@ -297,7 +303,8 @@ const libraryFacts = defineFacts("library", { contacts: page({
|
|
|
297
303
|
}
|
|
298
304
|
});
|
|
299
305
|
}
|
|
300
|
-
}))
|
|
306
|
+
}));
|
|
307
|
+
const libraryFacts = defineFacts("library", { contacts: libraryContacts });
|
|
301
308
|
linkRegistry(libraryFacts);
|
|
302
309
|
const propertyAddress = page({
|
|
303
310
|
title: "What’s the address?",
|
|
@@ -101,7 +101,7 @@ type NoOtherKeys<O, Allowed> = { [K in Exclude<keyof O, keyof Allowed>]: never;
|
|
|
101
101
|
declare function write<const O extends WriteInput>(options: O & NoOtherKeys<O, WriteInput>): WriteFill<O>;
|
|
102
102
|
/**
|
|
103
103
|
* The model PICKS from candidates that exist: its holder's candidates — the property's
|
|
104
|
-
*
|
|
104
|
+
* media of a media slot's `from` list of its kinds, every value a select lists, a row's table
|
|
105
105
|
* — and on a list its item's one candidate-holding field, between the list's `min` and `max`. The answer always names a
|
|
106
106
|
* candidate; a pick is a set (`unique` defaults to `true`), and a list's items take the
|
|
107
107
|
* order the answer gives them: best first, or the order the brief names ("order them as
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { readsWithRequires } from "./slot-ref.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../internal/template-contracts/dist/fill-builders.js
|
|
4
|
-
const PICK_NONE_CODEMOD = "written-without-pick-none";
|
|
5
4
|
const VERB_KEYS = {
|
|
6
5
|
write: /* @__PURE__ */ new Set([
|
|
7
6
|
"brief",
|
|
@@ -31,10 +30,7 @@ function verbBinding(verb, options) {
|
|
|
31
30
|
verb
|
|
32
31
|
};
|
|
33
32
|
for (const [key, value] of Object.entries(options)) {
|
|
34
|
-
if (!allowed.has(key)) {
|
|
35
|
-
const hint = key === "none" && verb === "pick" ? ` A pick judges every candidate, so selecting none is already an outcome its brief steers — \`concrete upgrade\` drops \`none\` from every \`fill.pick\` (the \`${PICK_NONE_CODEMOD}\` codemod).` : key === "count" ? " A fill takes no count: the list's own `min` and `max` bound how many items it fills." : key === "cap" ? " A write's budget is its holder's `cap` — a text slot's own, or a list's `item: text.short({ cap })`." : key === "of" && verb === "find" ? " A find names no candidates: the platform's lookup for its holder's kind supplies the value." : key === "of" && verb === "pick" ? " A pick chooses from its holder's candidates — a select's values, a media slot's `from` list of its kinds, a row's table, a list's item's." : key === "of" ? " The kind a write produces is its holder's — a text slot's own, a list's `item`, a label's text slot." : "";
|
|
36
|
-
throw new Error(`${at}: "${key}" is not an option — it takes ${[...allowed].map((k) => `\`${k}\``).join(", ")}, and everything the model should know goes in the brief.${hint}`);
|
|
37
|
-
}
|
|
33
|
+
if (!allowed.has(key)) throw new Error(`${at}: "${key}" is not an option — it takes ${[...allowed].map((k) => `\`${k}\``).join(", ")}, and everything the model should know goes in the brief.`);
|
|
38
34
|
if (key === "none" && value !== void 0 && value !== true) throw new Error(`${at}: \`none\` is \`true\` or absent — it admits the empty answer, and the brief's last sentence says when nothing is right.`);
|
|
39
35
|
if (key === "unique" && value !== void 0 && typeof value !== "boolean") throw new Error(`${at}: \`unique\` is a boolean — \`false\` lets a pick repeat an element.`);
|
|
40
36
|
if (key === "requires" && value !== void 0 && (!Array.isArray(value) || value.length === 0)) throw new Error(`${at}: \`requires\` names at least one read — omit it when the fill needs none.`);
|
|
@@ -76,4 +72,4 @@ function isFillBinding(x) {
|
|
|
76
72
|
}
|
|
77
73
|
|
|
78
74
|
//#endregion
|
|
79
|
-
export {
|
|
75
|
+
export { fill, fillsOfSource, isFillBinding, isFillSource };
|
|
@@ -31,7 +31,10 @@ function fillOf(verbs) {
|
|
|
31
31
|
none: Abstention,
|
|
32
32
|
reads: DecisionReads,
|
|
33
33
|
requires: DecisionReads
|
|
34
|
-
}).strict()
|
|
34
|
+
}).strict().refine((fill) => fill.verb !== "pick" || fill.none === void 0, {
|
|
35
|
+
path: ["none"],
|
|
36
|
+
message: "a pick abstains by its verdict and states no `none`"
|
|
37
|
+
});
|
|
35
38
|
}
|
|
36
39
|
function fillsOf(verbs) {
|
|
37
40
|
return z.array(fillOf(verbs)).min(1);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DISPLAY_ENTRIES, isMediaType
|
|
1
|
+
import { DISPLAY_ENTRIES, isMediaType } from "./slot-catalog.js";
|
|
2
2
|
import { isFactRef, isSerializedSectionRef, isSiblingPage, isSiblingSlot, serializeRef } from "./slot-ref.js";
|
|
3
3
|
import { getFillSection, getFills } from "./fill-declaration.js";
|
|
4
4
|
import { fromListsOf, mediaFilterOf, mediaOf } from "./media-candidates.js";
|
|
5
|
+
import { tableOf } from "./registry-shape.js";
|
|
5
6
|
import { FINDABLE_KINDS, isFindableKind } from "./findable.js";
|
|
6
7
|
import { isValueKind } from "./value-contracts.js";
|
|
7
8
|
import { plannerForField } from "./row-planners.js";
|
|
@@ -64,7 +65,7 @@ function assertNoStatedOf(at, binding) {
|
|
|
64
65
|
function assertWriteComposes(at, element) {
|
|
65
66
|
const birthed = element !== void 0 && isMediaType(element.type ?? "") ? "a list of media" : Object.entries(element?.type === "object" ? element.fields ?? {} : {}).find(([, field]) => isMediaType(field.type ?? "") && field.source?.kind === "element")?.[0];
|
|
66
67
|
if (birthed === void 0) return;
|
|
67
|
-
throw new Error(`${at} is filled by \`fill.write\`, but ${birthed === "a list of media" ? birthed : `its item's media member "${birthed}"`} would hold what the write answers — a write composes, it does not birth
|
|
68
|
+
throw new Error(`${at} is filled by \`fill.write\`, but ${birthed === "a list of media" ? birthed : `its item's media member "${birthed}"`} would hold what the write answers — a write composes, it does not birth media: pick it (\`fill.pick\`).`);
|
|
68
69
|
}
|
|
69
70
|
const FOUND = "places and addresses";
|
|
70
71
|
const FINDABLE = FINDABLE_KINDS.map((kind) => `\`${kind}()\``).join(", ");
|
|
@@ -89,8 +90,8 @@ function heldOf(path, slot) {
|
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
92
|
const filter = mediaFilterOf(slot);
|
|
92
|
-
if (filter === null) throw new Error(`fillSpecFromSchema: ${String(slot.type)} "${path}" is picked, but holds no candidates — a pick chooses a row of a table, a select's value or a media slot's
|
|
93
|
-
if (filter.from === void 0) throw new Error(`fillSpecFromSchema: ${String(slot.type)} "${path}" is picked but names no \`from\` — a pick chooses from its holder's \`from\` (\`from: fact.property.property_media\`); a media slot without one owns its
|
|
93
|
+
if (filter === null) throw new Error(`fillSpecFromSchema: ${String(slot.type)} "${path}" is picked, but holds no candidates — a pick chooses a row of a table, a select's value or a media slot's media value.`);
|
|
94
|
+
if (filter.from === void 0) throw new Error(`fillSpecFromSchema: ${String(slot.type)} "${path}" is picked but names no \`from\` — a pick chooses from its holder's \`from\` (\`from: fact.property.property_media\`); a media slot without one owns its media.`);
|
|
94
95
|
return mediaOf(filter);
|
|
95
96
|
}
|
|
96
97
|
function holdsElement(slot) {
|
|
@@ -143,7 +144,7 @@ function collectReads(into, bindings, of) {
|
|
|
143
144
|
for (const read of serializedReads(binding.reads)) if (read.kind === "home") into.facts.add(read.key);
|
|
144
145
|
else if (isSerializedSectionRef(read) && read.section !== ownSection) into.slots.set(`${read.section} ${read.slot}`, read);
|
|
145
146
|
}
|
|
146
|
-
for (const table of Array.isArray(of) ? of : [of]) if (isFactRef(table) &&
|
|
147
|
+
for (const table of Array.isArray(of) ? of : [of]) if (isFactRef(table) && tableOf(table.key) !== null) into.facts.add(table.key);
|
|
147
148
|
}
|
|
148
149
|
function editorPickedOrigin(slot) {
|
|
149
150
|
return slot.type === "poi";
|
|
@@ -174,7 +175,7 @@ function slotDecision(path, slot, bindings) {
|
|
|
174
175
|
}
|
|
175
176
|
function itemFieldFill(path, field, bindings, tree) {
|
|
176
177
|
for (const binding of bindings) assertVerbFits(path, field, binding);
|
|
177
|
-
if (!(tree.userAnswers && field.type === "list" && bindings.every((binding) => binding.verb === "pick")) && field.type !== "row" && plannerForField(field) === void 0) throw new Error(`fillSpecFromSchema: item field "${path}" (type "${String(field.type)}") is filled, but an item cannot fill one — an item's fields are written or picked inside the list's one batched call, which plans text, a date, an email, a phone, a url, a select key,
|
|
178
|
+
if (!(tree.userAnswers && field.type === "list" && bindings.every((binding) => binding.verb === "pick")) && field.type !== "row" && plannerForField(field) === void 0) throw new Error(`fillSpecFromSchema: item field "${path}" (type "${String(field.type)}") is filled, but an item cannot fill one — an item's fields are written or picked inside the list's one batched call, which plans text, a date, an email, a phone, a url, a select key, a media value, a row, or a list of text, dates, emails, phones, urls, keys or media.`);
|
|
178
179
|
const { of, fills } = fillsOf(path, field, bindings);
|
|
179
180
|
return {
|
|
180
181
|
...of === void 0 ? {} : { of },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RegistryTableKey } from "./slot-catalog.js";
|
|
2
1
|
import { ImageValue } from "./runtime-values.js";
|
|
2
|
+
import { RegistryTableKey } from "./registry-shape.js";
|
|
3
3
|
import { ComputeBinding } from "./compute.js";
|
|
4
4
|
import { ElementOf, ElementTableOf } from "./row-ref.js";
|
|
5
5
|
import { ListItemSlot } from "./slot-types.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isMediaKind } from "./slot-catalog.js";
|
|
2
2
|
import { ELEMENT_OF, elementOwner, isElementRef, isFactRef, isSiblingSlot, isSlotRef, rowOfMember } from "./slot-ref.js";
|
|
3
3
|
import { isComputeBinding } from "./compute.js";
|
|
4
4
|
import { fillsOfSource, isFillSource } from "./fill-builders.js";
|
|
5
5
|
import { getFills } from "./fill-declaration.js";
|
|
6
|
-
import {
|
|
6
|
+
import { tableMemberValueType, tableOf } from "./registry-shape.js";
|
|
7
7
|
import { TABLE_OF, carriedTable, rowDefinition, withTable } from "./row-ref.js";
|
|
8
8
|
import { mapSlotRefs, plainSlot } from "./resolve-scope.js";
|
|
9
9
|
import { headWith } from "./slot-builders.js";
|
|
@@ -13,7 +13,7 @@ import { itemRowTablesOf } from "./ref-locate.js";
|
|
|
13
13
|
//#region ../../internal/template-contracts/dist/list.js
|
|
14
14
|
function bakeListSource(source, label) {
|
|
15
15
|
if (isFactRef(source)) {
|
|
16
|
-
if (
|
|
16
|
+
if (tableOf(source.key) === null) throw new Error(`list: "${label}" is sourced by the fact "${source.key}", which is no table — a list's source is a table, a list slot, a list-valued member, a \`compute()\` or a fill; a list of the property's media is picked (\`fill.pick\`) from its item's \`from\`, or computed over a media list (\`compute({ reads: [fact.property.property_media] }, …)\`).`);
|
|
17
17
|
return {
|
|
18
18
|
kind: "home",
|
|
19
19
|
key: source.key
|
|
@@ -32,7 +32,7 @@ function bakeListSource(source, label) {
|
|
|
32
32
|
throw new Error(`list: "${label}" declares a source that is no list.`);
|
|
33
33
|
}
|
|
34
34
|
function elementTable(source) {
|
|
35
|
-
if (isFactRef(source)) return
|
|
35
|
+
if (isFactRef(source)) return tableOf(source.key);
|
|
36
36
|
if (isSiblingSlot(source) && source.type === "list") return carriedTable(source);
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
@@ -49,7 +49,7 @@ function kindOf(slot) {
|
|
|
49
49
|
return kind;
|
|
50
50
|
}
|
|
51
51
|
function identityItem(source, label) {
|
|
52
|
-
if (isFactRef(source) &&
|
|
52
|
+
if (isFactRef(source) && tableOf(source.key) !== null) return {
|
|
53
53
|
type: "row",
|
|
54
54
|
from: source.key,
|
|
55
55
|
source: { kind: "element" }
|
|
@@ -63,18 +63,10 @@ function identityItem(source, label) {
|
|
|
63
63
|
const member = rowOfMember(source);
|
|
64
64
|
if (member !== void 0) {
|
|
65
65
|
const table = carriedTable(member);
|
|
66
|
-
if (table !== null &&
|
|
66
|
+
if (table !== null && tableMemberValueType(table, source.field) === "image_list") return { type: "image" };
|
|
67
67
|
}
|
|
68
68
|
throw new Error(`list: "${label}" declares no \`item\`, and its source does not say what its elements are — declare \`item\`: a plain slot (\`item: image()\`), or a function of the element (\`item: (el) => object({ … })\`).`);
|
|
69
69
|
}
|
|
70
|
-
function memberValueTypeOf(table, field) {
|
|
71
|
-
if (table.reading === "legacy") {
|
|
72
|
-
const row = FACT_GRAPH[table.table].row;
|
|
73
|
-
return Object.hasOwn(row, field) ? row[field].value_type : void 0;
|
|
74
|
-
}
|
|
75
|
-
const declaration = fieldOf(linkedTableFields(table.table), field);
|
|
76
|
-
return declaration === void 0 ? void 0 : memberValueType(declaration) ?? void 0;
|
|
77
|
-
}
|
|
78
70
|
function writtenItemRefusal(label, what) {
|
|
79
71
|
return `list: "${label}" is written by a \`fill.write\` and ${what} — the item is the kind every written element is: a value slot (\`item: text.short({ cap: 80 })\`), an object exactly one field of which holds the element (\`question: text.medium({ label: "Question", cap: 48, source: el })\`), or an object declared plainly whose members the write answers (\`item: object({ label: text.short({ label: "Unit" }), fields: { … } })\`).`;
|
|
80
72
|
}
|
|
@@ -129,7 +121,7 @@ function heldElement(slot) {
|
|
|
129
121
|
function pickedTable(item, key) {
|
|
130
122
|
if (key === void 0) return null;
|
|
131
123
|
const def = rowDefinition(key === null ? item : (declaredFields(item) ?? item.fields)[key]);
|
|
132
|
-
return def.type === "row" ?
|
|
124
|
+
return def.type === "row" ? tableOf(def.from) : null;
|
|
133
125
|
}
|
|
134
126
|
function heldPickElement(item, key) {
|
|
135
127
|
if (key === null) return heldElement(item);
|
|
@@ -223,20 +215,6 @@ function listTable(opts, label) {
|
|
|
223
215
|
}
|
|
224
216
|
function list(opts) {
|
|
225
217
|
const label = opts.label ?? "list";
|
|
226
|
-
for (const key of [
|
|
227
|
-
"fields",
|
|
228
|
-
"title",
|
|
229
|
-
"unique",
|
|
230
|
-
"count"
|
|
231
|
-
]) {
|
|
232
|
-
if (opts[key] === void 0) continue;
|
|
233
|
-
throw new Error(`list: "${label}" declares \`${key}\`, which a list no longer takes — ${{
|
|
234
|
-
fields: "declare `item: (el) => object({ fields })` — an item function returning an object",
|
|
235
|
-
title: "give the item's object a `label` — a string, or a text slot",
|
|
236
|
-
unique: "a pick is unique by default (`fill.pick({ unique: false })` lifts it)",
|
|
237
|
-
count: "`min` and `max` bound how many items any source yields"
|
|
238
|
-
}[key]}.`);
|
|
239
|
-
}
|
|
240
218
|
const source = opts.source;
|
|
241
219
|
const fills = fillsOfSource(source, `list: "${label}"`);
|
|
242
220
|
const openWrite = answersMembers(opts.item);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tableOf } from "./registry-shape.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../internal/template-contracts/dist/mirror-kind.js
|
|
4
4
|
const STRING_KINDS = /* @__PURE__ */ new Set([
|
|
@@ -11,7 +11,7 @@ const STRING_KINDS = /* @__PURE__ */ new Set([
|
|
|
11
11
|
]);
|
|
12
12
|
function rowOf(from) {
|
|
13
13
|
if (typeof from !== "string") return void 0;
|
|
14
|
-
return
|
|
14
|
+
return tableOf(from) ?? from;
|
|
15
15
|
}
|
|
16
16
|
function holderOf(item) {
|
|
17
17
|
if (item.type !== "object") {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { OBJECT_BINDING_OWN_KEYS
|
|
1
|
+
import { OBJECT_BINDING_OWN_KEYS } from "./slot-catalog.js";
|
|
2
2
|
import { isFactRef, isSiblingSlot, isSiblingSource, isSlotRef } from "./slot-ref.js";
|
|
3
3
|
import { isComputeBinding } from "./compute.js";
|
|
4
4
|
import { isFillBinding, isFillSource } from "./fill-builders.js";
|
|
5
5
|
import { getFills } from "./fill-declaration.js";
|
|
6
|
+
import { tableOf } from "./registry-shape.js";
|
|
6
7
|
import { mapSlotRefs, memberResolver, ownKeyRead, ownKeyRefusal, plainSlot, rowScope } from "./resolve-scope.js";
|
|
7
8
|
import { text } from "./slot-builders.js";
|
|
8
9
|
|
|
@@ -82,7 +83,7 @@ function nestedFieldRefusal(field, siblings) {
|
|
|
82
83
|
if (source === void 0) return void 0;
|
|
83
84
|
if (isComputeBinding(source)) return `a \`compute()\` — an item of a list inside an object reads its element, or a row \`from\` its member; ${NESTED_HOME}`;
|
|
84
85
|
const { kind, slot } = source;
|
|
85
|
-
if (kind === "element" && field.type === "row" &&
|
|
86
|
+
if (kind === "element" && field.type === "row" && tableOf(field.from) !== null) return "a table's row holding the element — the element of a list inside an object is a member's item: hold it in a row `from` that member (`row({ label, from: unit.floor_plans, source: entry })`)";
|
|
86
87
|
if (kind === "element") return void 0;
|
|
87
88
|
if (field.type !== "row" && kind === "row" && typeof slot === "string" && siblings[slot]?.type === "row") return void 0;
|
|
88
89
|
return "bound to something outside its item — an item of a list inside an object reads its element, a row `from` its member, or a row beside it";
|
|
@@ -63,9 +63,9 @@ declare function cutout<const O extends CutoutInput>(options?: O & NoOtherKeys<O
|
|
|
63
63
|
*/
|
|
64
64
|
declare function autocrop<const O extends AutocropInput>(options: O & NoOtherKeys<O, AutocropInput>): AutocropProcess;
|
|
65
65
|
/**
|
|
66
|
-
* The processes a media declaration lists in `process`, each run on every
|
|
66
|
+
* The processes a media declaration lists in `process`, each run on every media value that
|
|
67
67
|
* becomes its value: `process.cutout()` removes the background, `process.autocrop({ brief })`
|
|
68
|
-
* crops to the subject. Declare one where
|
|
68
|
+
* crops to the subject. Declare one where a file first lands; a declaration picking
|
|
69
69
|
* from a list that declares it reads the result and declares nothing. Order among them
|
|
70
70
|
* means nothing — a crop runs before every rendition.
|
|
71
71
|
*/
|
|
@@ -1,45 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { memberListOfKey, tableColumnOfKey } from "./registry-shape.js";
|
|
3
|
-
import { REGISTRY_FACT_LEGACY, registryMemberOfLegacy } from "./registry-aliases.js";
|
|
1
|
+
import { memberListOfKey, tableColumnOfKey, tableOf } from "./registry-shape.js";
|
|
4
2
|
import "./ref-locate.js";
|
|
5
3
|
import { isMediaListKey, isRegistryFactKey } from "./fact-keys.js";
|
|
6
4
|
|
|
7
5
|
//#region ../../internal/template-contracts/dist/read-graph.js
|
|
8
|
-
function tableBase(key) {
|
|
9
|
-
const table = tableKeyOf(key);
|
|
10
|
-
if (table === null) return null;
|
|
11
|
-
return table.reading === "registry" ? key : REGISTRY_TABLE_KEYS[table.table];
|
|
12
|
-
}
|
|
13
6
|
function rowBaseOf(from) {
|
|
14
7
|
const member = memberListOfKey(from);
|
|
15
8
|
if (member !== null) return `${from.slice(0, from.length - member.member.length - 1)}[].${member.member}`;
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
function primaryRowMember(table, container, legacy) {
|
|
19
|
-
const aliases = FACT_PROJECTIONS[container] ?? {};
|
|
20
|
-
const authored = Object.keys(aliases).find((name) => aliases[name] === legacy) ?? legacy;
|
|
21
|
-
return registryMemberOfLegacy(table, authored) ?? authored;
|
|
22
|
-
}
|
|
23
|
-
const LEGACY_REGISTRY = new Map(Object.entries(REGISTRY_FACT_LEGACY).map(([registry, legacy]) => [legacy, registry]));
|
|
24
|
-
const PRIMARY_ROW_TABLES = {
|
|
25
|
-
unit: "units",
|
|
26
|
-
contact: "contacts"
|
|
27
|
-
};
|
|
9
|
+
return tableOf(from) === null ? null : from;
|
|
10
|
+
}
|
|
28
11
|
function factPathOf(key) {
|
|
29
12
|
const column = tableColumnOfKey(key);
|
|
30
13
|
if (column !== null) return `${column.tableKey}[].${column.member}`;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (isRegistryFactKey(key) || isMediaListKey(key)) return key;
|
|
34
|
-
const registry = LEGACY_REGISTRY.get(key);
|
|
35
|
-
if (registry !== void 0) return registry;
|
|
36
|
-
const graph = FACT_GRAPH;
|
|
37
|
-
const entry = Object.hasOwn(graph, key) ? graph[key] : void 0;
|
|
38
|
-
if (entry?.primary_of !== void 0) return tableBase(entry.primary_of);
|
|
39
|
-
const container = entry?.container;
|
|
40
|
-
const primary = container === void 0 ? void 0 : PRIMARY_ROW_TABLES[container];
|
|
41
|
-
if (container === void 0 || primary === void 0) return null;
|
|
42
|
-
return `${REGISTRY_TABLE_KEYS[primary]}[0].${primaryRowMember(primary, container, key)}`;
|
|
14
|
+
if (tableOf(key) !== null || isRegistryFactKey(key) || isMediaListKey(key)) return key;
|
|
15
|
+
return null;
|
|
43
16
|
}
|
|
44
17
|
function fromList(from) {
|
|
45
18
|
return from === void 0 ? [] : typeof from === "string" ? [from] : [...from];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tableOf, tableOfSource } from "./registry-shape.js";
|
|
2
2
|
import "./mirror-kind.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/template-contracts/dist/ref-locate.js
|
|
@@ -82,20 +82,20 @@ function holderOf(slots, reader, key) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
function rowTableOf(row) {
|
|
85
|
-
return
|
|
85
|
+
return tableOf(row.from);
|
|
86
86
|
}
|
|
87
87
|
function rowTablesOf(row) {
|
|
88
88
|
if (!Array.isArray(row.from)) {
|
|
89
89
|
const table = rowTableOf(row);
|
|
90
90
|
return table === null ? [] : [table];
|
|
91
91
|
}
|
|
92
|
-
return row.from.flatMap((key) =>
|
|
92
|
+
return row.from.flatMap((key) => tableOf(key) ?? []);
|
|
93
93
|
}
|
|
94
94
|
function attributedRows(facts, tables) {
|
|
95
95
|
const seen = /* @__PURE__ */ new Set();
|
|
96
96
|
const out = [];
|
|
97
97
|
for (const table of tables) {
|
|
98
|
-
const rows = facts[table
|
|
98
|
+
const rows = facts[table];
|
|
99
99
|
for (const row of rows) {
|
|
100
100
|
const id = nonEmpty(row["id"]);
|
|
101
101
|
if (id === null || seen.has(id)) continue;
|
|
@@ -153,7 +153,7 @@ function tablesAt(scope, section, slots, id, seen) {
|
|
|
153
153
|
function listTables(scope, section, slots, list, seen) {
|
|
154
154
|
const source = isRecord(list.source) ? list.source : void 0;
|
|
155
155
|
if (source === void 0 || source["kind"] === "authored" || source["kind"] === "derived") return itemRowTablesOf(list.element);
|
|
156
|
-
const table =
|
|
156
|
+
const table = tableOfSource(source);
|
|
157
157
|
if (table !== null) return [table];
|
|
158
158
|
const { kind, section: target, slot } = source;
|
|
159
159
|
if (kind !== "section" || typeof target !== "string" || typeof slot !== "string") return [];
|
|
@@ -169,7 +169,11 @@ function elementIdentity(element, table = null) {
|
|
|
169
169
|
}
|
|
170
170
|
function elementIdentityField(element) {
|
|
171
171
|
if (!isRecord(element)) return null;
|
|
172
|
-
return [
|
|
172
|
+
return [
|
|
173
|
+
"id",
|
|
174
|
+
"media",
|
|
175
|
+
"file"
|
|
176
|
+
].find((key) => nonEmpty(element[key]) !== null) ?? null;
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
//#endregion
|
|
@@ -183,7 +183,7 @@ interface PlaceRendition extends Rendition {
|
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* The place members a record carries: a home value's, `name` resolved. `id` is the media
|
|
186
|
-
* id and `file` the file's — one id
|
|
186
|
+
* id and `file` the file's — one id for a value born over its own file.
|
|
187
187
|
*/
|
|
188
188
|
interface PlaceMembers {
|
|
189
189
|
id: string;
|
|
@@ -81,24 +81,23 @@ function isMediaRecord(value) {
|
|
|
81
81
|
return typeof id === "string" && typeof kind === "string" && isMediaKind(kind) && isObject(renditions);
|
|
82
82
|
}
|
|
83
83
|
function isHomeMediaValue(value) {
|
|
84
|
-
return isObject(value) && typeof value["id"] === "string" && typeof value["file"] === "string" && isObject(value["renditions"]) && !("kind" in value);
|
|
84
|
+
return isObject(value) && typeof value["id"] === "string" && typeof value["file"] === "string" && isObject(value["renditions"]) && !("kind" in value) && !("picked" in value);
|
|
85
85
|
}
|
|
86
86
|
function isContentMediaValue(value) {
|
|
87
|
-
return isObject(value) && typeof value["file"] === "string" && "
|
|
87
|
+
return isObject(value) && typeof value["file"] === "string" && value["file"] !== "" && !isHomeMediaValue(value) && !isMediaRecord(value);
|
|
88
88
|
}
|
|
89
89
|
function isMediaReference(value) {
|
|
90
90
|
return isObject(value) && typeof value["media"] === "string" && value["media"] !== "";
|
|
91
91
|
}
|
|
92
|
-
function storedReferenceOf(value) {
|
|
93
|
-
const id = value["asset_id"];
|
|
94
|
-
return typeof id === "string" && id !== "" ? id : void 0;
|
|
95
|
-
}
|
|
96
92
|
function mediaIdOf(value) {
|
|
97
93
|
if (!isObject(value)) return void 0;
|
|
98
94
|
if (isMediaReference(value)) return value.media;
|
|
99
95
|
if (isHomeMediaValue(value) || isMediaRecord(value)) return value.id;
|
|
100
96
|
if (isContentMediaValue(value)) return value.picked ?? value.file;
|
|
101
|
-
|
|
97
|
+
}
|
|
98
|
+
function contentMediaIdOf(value) {
|
|
99
|
+
if (isMediaReference(value)) return value.media;
|
|
100
|
+
if (isContentMediaValue(value)) return value.file;
|
|
102
101
|
}
|
|
103
102
|
function collectOwning(value, into) {
|
|
104
103
|
if (Array.isArray(value)) for (const item of value) collectOwning(item, into);
|
|
@@ -126,17 +125,6 @@ function mediaRecords(document) {
|
|
|
126
125
|
}
|
|
127
126
|
return out;
|
|
128
127
|
}
|
|
129
|
-
function copyRecordOf(value, document) {
|
|
130
|
-
const file = fileIn(document, value.file);
|
|
131
|
-
if (file === void 0) return null;
|
|
132
|
-
return mergeMedia(file, {
|
|
133
|
-
id: value.picked ?? value.file,
|
|
134
|
-
file: value.file,
|
|
135
|
-
crop: value.crop,
|
|
136
|
-
name: value.name,
|
|
137
|
-
renditions: value.renditions
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
128
|
function hasOwnFraming(own) {
|
|
141
129
|
return Object.hasOwn(own, "crop") || own.renditions !== void 0;
|
|
142
130
|
}
|
|
@@ -178,10 +166,8 @@ function readAsRecords(value, document) {
|
|
|
178
166
|
});
|
|
179
167
|
if (!isObject(at) || isMediaRecord(at)) return at;
|
|
180
168
|
if (isHomeMediaValue(at)) return recordOf(at, document);
|
|
181
|
-
if (isContentMediaValue(at)) return
|
|
169
|
+
if (isContentMediaValue(at)) return resolve(at.file);
|
|
182
170
|
if (isMediaReference(at)) return framedAt(resolve(at.media), at);
|
|
183
|
-
const stored = storedReferenceOf(at);
|
|
184
|
-
if (stored !== void 0) return resolve(stored);
|
|
185
171
|
const out = {};
|
|
186
172
|
for (const [key, member] of Object.entries(at)) out[key] = read(member);
|
|
187
173
|
return out;
|
|
@@ -191,12 +177,15 @@ function readAsRecords(value, document) {
|
|
|
191
177
|
function storedAsRefs(value) {
|
|
192
178
|
if (Array.isArray(value)) return value.map(storedAsRefs);
|
|
193
179
|
if (!isObject(value)) return value;
|
|
194
|
-
if (isMediaRecord(value) || isHomeMediaValue(value)) return {
|
|
195
|
-
if (isMediaReference(value))
|
|
180
|
+
if (isMediaRecord(value) || isHomeMediaValue(value)) return { media: value.id };
|
|
181
|
+
if (isMediaReference(value)) {
|
|
182
|
+
const { crop: _crop, renditions: _renditions, ...context } = value;
|
|
183
|
+
return context;
|
|
184
|
+
}
|
|
196
185
|
const out = {};
|
|
197
186
|
for (const [key, member] of Object.entries(value)) out[key] = storedAsRefs(member);
|
|
198
187
|
return out;
|
|
199
188
|
}
|
|
200
189
|
|
|
201
190
|
//#endregion
|
|
202
|
-
export { FILE_RENDITION_NAMES, PLACE_RENDITION_NAMES, RENDITION_NAMES, cropsPart, fileNameOf, framedAt, framingOver, hasOwnFraming, isContentMediaValue, isHomeMediaValue, isMediaRecord, isMediaReference, mediaIdOf, mediaRecords, mergeMedia, owningValues, readAsRecords, recordOf, splitMedia, storedAsRefs, videoSourceOf };
|
|
191
|
+
export { FILE_RENDITION_NAMES, PLACE_RENDITION_NAMES, RENDITION_NAMES, contentMediaIdOf, cropsPart, fileNameOf, framedAt, framingOver, hasOwnFraming, isContentMediaValue, isHomeMediaValue, isMediaRecord, isMediaReference, mediaIdOf, mediaRecords, mergeMedia, owningValues, readAsRecords, recordOf, splitMedia, storedAsRefs, videoSourceOf };
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LibraryFactRegistry, PropertyTablePages } from "./fact-registry.js";
|
|
1
|
+
import { LibraryTablePages, PropertyTablePages } from "./fact-registry.js";
|
|
3
2
|
//#region ../../internal/template-contracts/dist/registry-shape.d.ts
|
|
3
|
+
type LibraryTable = keyof LibraryTablePages & string;
|
|
4
|
+
/**
|
|
5
|
+
* A table's name — a list of objects a home declares, by its page: the property's own and
|
|
6
|
+
* the library's (`contacts`). Typed off each home's table pages (`PropertyTablePages`,
|
|
7
|
+
* `LibraryTablePages`), which the registries' own types cannot be read for: the grammar
|
|
8
|
+
* that builds them reads this type. `fact-registry.test.ts` holds both to `tableNames()`.
|
|
9
|
+
*/
|
|
10
|
+
type RegistryTable = (keyof PropertyTablePages & string) | LibraryTable;
|
|
11
|
+
/** A table's registry key: a property list reading it (`property.units`, `property.contacts`), or the library list holding it (`library.contacts`). */
|
|
12
|
+
type RegistryTableKey = `property.${RegistryTable}` | `library.${LibraryTable}`;
|
|
4
13
|
type ItemFieldsOf<Page> = Page extends {
|
|
5
14
|
readonly declaration: {
|
|
6
15
|
readonly element: {
|
|
@@ -8,6 +17,13 @@ type ItemFieldsOf<Page> = Page extends {
|
|
|
8
17
|
};
|
|
9
18
|
};
|
|
10
19
|
} ? F : never;
|
|
20
|
+
/** The item declaration of a table's list, as the registry types it — off the table's own page (see {@link TableFieldsOf}). */
|
|
21
|
+
type TableElementOf<T extends RegistryTable> = T extends LibraryTable ? ItemOf<LibraryTablePages[T]> : T extends keyof PropertyTablePages ? ItemOf<PropertyTablePages[T]> : never;
|
|
22
|
+
type ItemOf<Page> = Page extends {
|
|
23
|
+
readonly declaration: {
|
|
24
|
+
readonly element: infer E;
|
|
25
|
+
};
|
|
26
|
+
} ? E : never;
|
|
11
27
|
/**
|
|
12
28
|
* The declarations of a table's members, as the registry types them — the library's
|
|
13
29
|
* contacts, the property's other lists. A property table is read off its own page
|
|
@@ -15,7 +31,7 @@ type ItemFieldsOf<Page> = Page extends {
|
|
|
15
31
|
* contacts from a row's members, which are typed here, so it cannot be read while it is
|
|
16
32
|
* being typed.
|
|
17
33
|
*/
|
|
18
|
-
type TableFieldsOf<T extends RegistryTable> = T extends
|
|
34
|
+
type TableFieldsOf<T extends RegistryTable> = T extends LibraryTable ? ItemFieldsOf<LibraryTablePages[T]> : T extends keyof PropertyTablePages ? ItemFieldsOf<PropertyTablePages[T]> : never;
|
|
19
35
|
/** {@link memberValueType}, at the type level. */
|
|
20
36
|
type MemberValueTypeOf<D> = D extends {
|
|
21
37
|
readonly type: "list";
|
|
@@ -38,4 +54,4 @@ type MemberValueTypeOf<D> = D extends {
|
|
|
38
54
|
readonly type: "text" | "select" | "email" | "phone" | "url" | "date";
|
|
39
55
|
} ? "text" : never;
|
|
40
56
|
//#endregion
|
|
41
|
-
export { MemberValueTypeOf, TableFieldsOf };
|
|
57
|
+
export { MemberValueTypeOf, RegistryTable, RegistryTableKey, TableElementOf, TableFieldsOf };
|