@homepages/concrete 9.1.0 → 10.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 +52 -0
- package/README.md +1 -1
- package/codemods/manifest.json +10 -0
- package/codemods/registry-keys-only.mjs +113 -0
- package/codemods/steps/list-object-form.mjs +2 -3
- package/codemods/steps/registry-key-reads.mjs +276 -0
- package/dist/artifact/playground/client/assets/index-BFNHB7VM.css +1 -0
- package/dist/artifact/playground/client/assets/index-Div1yo6s.js +1259 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/host.mjs +42 -42
- package/dist/cli/build/artifact.js +2 -1
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/check/render/inputs.js +3 -3
- package/dist/cli/check/stages/sections.js +5 -6
- package/dist/cli/dev/workspace-reader.js +9 -2
- package/dist/fixtures/media-store.js +3 -3
- package/dist/fixtures/resolve.js +24 -16
- package/dist/fixtures/synthesize-empties.js +3 -1
- package/dist/fixtures.d.ts +1 -1
- package/dist/index.d.ts +3 -4
- 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/resolved-decision.js +1 -1
- package/dist/packages/internal/media-resolution/dist/document.js +16 -15
- package/dist/packages/internal/media-resolution/dist/image.js +38 -92
- 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 +12 -11
- package/dist/packages/internal/media-resolution/dist/video.js +16 -16
- 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 +5 -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 +1 -8
- package/dist/packages/internal/section-contracts/dist/select-contract.js +7 -1
- package/dist/packages/internal/section-contracts/dist/source-contract.js +12 -8
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +1 -1
- 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 +2 -2
- package/dist/packages/internal/template-artifact/dist/layout.js +3 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +32 -16
- package/dist/packages/internal/template-contracts/dist/content-pick.js +24 -1
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +2 -2
- 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-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 -15
- 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/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 +5 -20
- 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 +4 -7
- 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 +4 -4
- 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 +2 -2
- package/dist/primitives/Image.d.ts +3 -3
- package/dist/primitives/slot-download.d.ts +1 -1
- package/dist/primitives/slot-media.d.ts +1 -1
- 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/property-facts.d.ts +1 -62
- package/dist/schema/section-schema.d.ts +2 -2
- package/dist/schema/section-schema.js +1 -1
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +2 -3
- package/package.json +1 -1
- 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
|
@@ -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 };
|
|
@@ -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,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);
|
|
@@ -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 };
|