@homepages/concrete 9.1.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +81 -0
- package/README.md +1 -1
- package/codemods/manifest.json +5 -148
- package/dist/artifact/playground/client/assets/index-ByeGGedv.js +1259 -0
- package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +42 -42
- package/dist/base.css +1 -8
- package/dist/cli/build/artifact.js +3 -2
- package/dist/cli/build/fixtures.js +2 -0
- package/dist/cli/check/render/inputs.js +3 -3
- package/dist/cli/check/stages/sections.js +6 -7
- package/dist/cli/dev/workspace-reader.js +10 -2
- package/dist/css/compile.js +3 -6
- package/dist/css/rules.js +1 -51
- package/dist/design-system/format-variants.js +1 -1
- package/dist/fixtures/media-store.js +3 -3
- package/dist/fixtures/resolve.js +28 -16
- package/dist/fixtures/rows.js +2 -2
- package/dist/fixtures/synthesize-empties.js +3 -1
- package/dist/fixtures.d.ts +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +8 -6
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +8 -4
- package/dist/packages/internal/fill-bake/dist/index.js +1 -1
- package/dist/packages/internal/fill-bake/dist/item-merge.js +32 -6
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +5 -5
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +4 -26
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +3 -14
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
- package/dist/packages/internal/media-resolution/dist/document.js +17 -16
- package/dist/packages/internal/media-resolution/dist/image.js +41 -95
- package/dist/packages/internal/media-resolution/dist/index.js +1 -1
- package/dist/packages/internal/media-resolution/dist/list.js +11 -11
- package/dist/packages/internal/media-resolution/dist/media.js +17 -16
- package/dist/packages/internal/media-resolution/dist/records.js +4 -2
- package/dist/packages/internal/media-resolution/dist/slot.js +5 -5
- package/dist/packages/internal/media-resolution/dist/tour.js +17 -16
- package/dist/packages/internal/media-resolution/dist/video.js +24 -24
- package/dist/packages/internal/property-facts/dist/registry-facts.js +8 -1
- package/dist/packages/internal/section-contracts/dist/catalog.js +1 -5
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +2 -3
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +6 -3
- package/dist/packages/internal/section-contracts/dist/index.js +0 -1
- package/dist/packages/internal/section-contracts/dist/object-contract.js +4 -2
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +4 -2
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +7 -8
- package/dist/packages/internal/section-contracts/dist/runners.js +2 -11
- package/dist/packages/internal/section-contracts/dist/select-contract.js +7 -1
- package/dist/packages/internal/section-contracts/dist/source-contract.js +14 -10
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +0 -2
- package/dist/packages/internal/section-contracts/dist/table-member.js +5 -8
- package/dist/packages/internal/source-resolution/dist/index.js +21 -188
- package/dist/packages/internal/template-artifact/dist/index.js +1 -1
- package/dist/packages/internal/template-artifact/dist/layout.js +12 -10
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +26 -14
- package/dist/packages/internal/template-contracts/dist/content-pick.js +24 -1
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +4 -6
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +3 -2
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +19 -43
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +24 -3
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +10 -3
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +2 -6
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +4 -1
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +7 -6
- package/dist/packages/internal/template-contracts/dist/list.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/list.js +7 -29
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +2 -2
- package/dist/packages/internal/template-contracts/dist/object.js +3 -2
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +1 -1
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/read-graph.js +5 -32
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +10 -6
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +13 -24
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +20 -4
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +69 -11
- package/dist/packages/internal/template-contracts/dist/row-planners.js +1 -1
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +4 -7
- package/dist/packages/internal/template-contracts/dist/row-ref.js +7 -23
- package/dist/packages/internal/template-contracts/dist/row-sources.js +3 -3
- package/dist/packages/internal/template-contracts/dist/row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/row.js +6 -7
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +11 -27
- package/dist/packages/internal/template-contracts/dist/section-schema-types.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +29 -37
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +3 -8
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +2 -702
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +2 -498
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +4 -1
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +10 -5
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +2 -1
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +5 -12
- package/dist/packages/internal/template-contracts/dist/table-members.js +7 -37
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +4 -6
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +3 -4
- package/dist/primitives/Image.d.ts +4 -4
- package/dist/primitives/Tour.d.ts +2 -2
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/slot-bindings.js +6 -13
- package/dist/primitives/slot-document.d.ts +1 -1
- package/dist/primitives/slot-download.d.ts +4 -2
- package/dist/primitives/slot-media.d.ts +6 -3
- package/dist/primitives/slot-media.js +1 -1
- package/dist/rules/registry.js +0 -6
- package/dist/schema/fact.d.ts +19 -52
- package/dist/schema/fact.js +6 -25
- package/dist/schema/facts-view.d.ts +1 -2
- package/dist/schema/format-presets.d.ts +1 -1
- package/dist/schema/property-facts.d.ts +1 -62
- package/dist/schema/section-schema.d.ts +6 -6
- package/dist/schema/section-schema.js +1 -1
- package/dist/styles.css +4 -4
- package/dist/template/define-template.js +0 -1
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +2 -4
- package/package.json +2 -2
- package/codemods/fill-is-a-source.mjs +0 -533
- package/codemods/framework-namespace.mjs +0 -107
- package/codemods/list-grammar.mjs +0 -923
- package/codemods/object-form-only.mjs +0 -39
- package/codemods/platform-namespace.mjs +0 -83
- package/codemods/process-builders.mjs +0 -198
- package/codemods/reads-replace-reconcile.mjs +0 -285
- package/codemods/slot-object.mjs +0 -1097
- package/codemods/steps/content-object-fields.mjs +0 -324
- package/codemods/steps/list-object-form.mjs +0 -687
- package/codemods/steps/select-object-form.mjs +0 -210
- package/codemods/table-rows.mjs +0 -568
- package/codemods/theme-collapse.mjs +0 -396
- package/codemods/unlayer-author-css.mjs +0 -194
- package/codemods/unwrap-object-fields.mjs +0 -310
- package/codemods/viewer-slot-document.mjs +0 -131
- package/codemods/write-property-as-facts-document.mjs +0 -716
- package/codemods/write-the-address-line.mjs +0 -255
- package/codemods/write-the-registry-members.mjs +0 -653
- package/codemods/write-the-select-from.mjs +0 -141
- package/codemods/write-the-sole-from.mjs +0 -369
- package/codemods/write-the-table-from.mjs +0 -267
- package/codemods/write-the-whole-item.mjs +0 -512
- package/codemods/writeback-drop.mjs +0 -168
- package/codemods/written-contact-address.mjs +0 -162
- package/codemods/written-media-category.mjs +0 -227
- package/codemods/written-ref-kinds-name-the-layer.mjs +0 -172
- package/codemods/written-uploads-replace-pool-reads.mjs +0 -454
- package/codemods/written-uploads-sort-into-lists.mjs +0 -405
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +0 -295
- package/codemods/written-video-sources-drop.mjs +0 -144
- package/codemods/written-without-pick-none.mjs +0 -146
- package/codemods/written-without-retired-knowledge.mjs +0 -223
- package/codemods/written-without-the-media-key.mjs +0 -202
- package/codemods/written-without-the-property-type.mjs +0 -249
- package/dist/artifact/playground/client/assets/index-BOYbgBnP.js +0 -1259
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +0 -1
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +0 -22
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +0 -19
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +0 -62
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +0 -167
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +0 -77
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import "../../template-contracts/dist/registry-facts.js";
|
|
2
|
+
|
|
1
3
|
//#region ../../internal/media-resolution/dist/records.js
|
|
2
|
-
function recordsOf(
|
|
3
|
-
return new Map(Object.entries(
|
|
4
|
+
function recordsOf(byId) {
|
|
5
|
+
return new Map(Object.entries(byId ?? {}));
|
|
4
6
|
}
|
|
5
7
|
|
|
6
8
|
//#endregion
|
|
@@ -11,11 +11,11 @@ async function resolveSlotValue(value, slot, ctx) {
|
|
|
11
11
|
if (slot === void 0) return value;
|
|
12
12
|
if (itemContentOf(slot) !== null) return resolveListSlot(value, slot, ctx);
|
|
13
13
|
switch (slot.type) {
|
|
14
|
-
case "image": return resolveImageSlot(value, ctx.
|
|
15
|
-
case "video": return resolveVideoSlot(value, ctx.
|
|
16
|
-
case "tour": return resolveTourSlot(value, ctx.
|
|
17
|
-
case "document": return resolveDocumentSlot(value, ctx.
|
|
18
|
-
case "media": return resolveMediaSlot(value, slot, ctx.
|
|
14
|
+
case "image": return resolveImageSlot(value, ctx.records, ctx.store, slotCropAspects(slot.crop));
|
|
15
|
+
case "video": return resolveVideoSlot(value, ctx.records, ctx.store);
|
|
16
|
+
case "tour": return resolveTourSlot(value, ctx.records, ctx.store);
|
|
17
|
+
case "document": return resolveDocumentSlot(value, ctx.records, ctx.store);
|
|
18
|
+
case "media": return resolveMediaSlot(value, slot, ctx.records, ctx.store);
|
|
19
19
|
case "poi": return ctx.resolvePoi(value);
|
|
20
20
|
case "object": return resolveObject(value, slot, ctx);
|
|
21
21
|
default: return value;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { tourEmbedUrl } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { contentMediaIdOf } from "../../template-contracts/dist/registry-facts.js";
|
|
2
3
|
import { readLadder } from "./store.js";
|
|
3
4
|
|
|
4
5
|
//#region ../../internal/media-resolution/dist/tour.js
|
|
5
6
|
const DEFAULT = {
|
|
6
|
-
|
|
7
|
+
id: "",
|
|
7
8
|
url: "",
|
|
8
9
|
poster: "",
|
|
9
10
|
alt: ""
|
|
@@ -14,41 +15,41 @@ async function attachPosterResponsive(out, previewKey, store) {
|
|
|
14
15
|
if (responsive) out.poster_responsive = responsive;
|
|
15
16
|
return out;
|
|
16
17
|
}
|
|
17
|
-
async function resolveTourSlot(value,
|
|
18
|
+
async function resolveTourSlot(value, records, store) {
|
|
18
19
|
if (value === null) return null;
|
|
19
20
|
if (typeof value !== "object") return DEFAULT;
|
|
20
21
|
const v = value;
|
|
21
|
-
const tourId =
|
|
22
|
+
const tourId = contentMediaIdOf(v) ?? "";
|
|
22
23
|
if (!tourId) return DEFAULT;
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
store.log?.warn({
|
|
24
|
+
const record = records.get(tourId);
|
|
25
|
+
if (record === void 0) {
|
|
26
|
+
store.log?.warn({ media_id: tourId }, "resolve-tour-slot: no tour media the render may reach");
|
|
26
27
|
return DEFAULT;
|
|
27
28
|
}
|
|
28
|
-
if (
|
|
29
|
+
if (record.kind !== "tour") {
|
|
29
30
|
store.log?.warn({
|
|
30
|
-
|
|
31
|
-
kind:
|
|
32
|
-
}, "resolve-tour-slot:
|
|
31
|
+
media_id: tourId,
|
|
32
|
+
kind: record.kind
|
|
33
|
+
}, "resolve-tour-slot: media is not a tour");
|
|
33
34
|
return DEFAULT;
|
|
34
35
|
}
|
|
35
36
|
try {
|
|
36
|
-
const embed = tourEmbedUrl(
|
|
37
|
+
const embed = tourEmbedUrl(record.url);
|
|
37
38
|
if (embed === null) {
|
|
38
|
-
store.log?.warn({
|
|
39
|
+
store.log?.warn({ media_id: tourId }, "resolve-tour-slot: tour link embeds nowhere");
|
|
39
40
|
return DEFAULT;
|
|
40
41
|
}
|
|
41
|
-
const posterKey =
|
|
42
|
+
const posterKey = record.renditions.poster?.key ?? null;
|
|
42
43
|
return attachPosterResponsive({
|
|
43
|
-
|
|
44
|
+
id: tourId,
|
|
44
45
|
url: embed,
|
|
45
46
|
poster: posterKey ? await store.fileUrl(posterKey) : "",
|
|
46
47
|
alt: typeof v.alt === "string" ? v.alt : "",
|
|
47
|
-
provider:
|
|
48
|
+
provider: record.provider
|
|
48
49
|
}, posterKey, store);
|
|
49
50
|
} catch (err) {
|
|
50
51
|
store.log?.error({
|
|
51
|
-
|
|
52
|
+
media_id: tourId,
|
|
52
53
|
err: err.message
|
|
53
54
|
}, "resolve-tour-slot: presign failed; soft-empty tour");
|
|
54
55
|
return DEFAULT;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { videoEmbedUrl } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { videoSourceOf } from "../../template-contracts/dist/registry-facts.js";
|
|
2
|
+
import { contentMediaIdOf, videoSourceOf } from "../../template-contracts/dist/registry-facts.js";
|
|
3
3
|
import { readLadder } from "./store.js";
|
|
4
4
|
|
|
5
5
|
//#region ../../internal/media-resolution/dist/video.js
|
|
6
6
|
const DEFAULT = {
|
|
7
|
-
|
|
7
|
+
id: "",
|
|
8
8
|
url: "",
|
|
9
9
|
poster: "",
|
|
10
10
|
alt: ""
|
|
@@ -15,64 +15,64 @@ async function attachPosterResponsive(out, previewKey, store) {
|
|
|
15
15
|
if (responsive) out.poster_responsive = responsive;
|
|
16
16
|
return out;
|
|
17
17
|
}
|
|
18
|
-
async function resolveVideoSlot(value,
|
|
18
|
+
async function resolveVideoSlot(value, records, store) {
|
|
19
19
|
if (value === null) return null;
|
|
20
20
|
if (typeof value !== "object") return DEFAULT;
|
|
21
21
|
const v = value;
|
|
22
|
-
const videoId =
|
|
22
|
+
const videoId = contentMediaIdOf(v) ?? "";
|
|
23
23
|
if (!videoId) return DEFAULT;
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
store.log?.warn({
|
|
24
|
+
const record = records.get(videoId);
|
|
25
|
+
if (record === void 0) {
|
|
26
|
+
store.log?.warn({ media_id: videoId }, "resolve-video-slot: no video media the render may reach");
|
|
27
27
|
return DEFAULT;
|
|
28
28
|
}
|
|
29
|
-
if (
|
|
29
|
+
if (record.kind !== "video") {
|
|
30
30
|
store.log?.warn({
|
|
31
|
-
|
|
32
|
-
kind:
|
|
33
|
-
}, "resolve-video-slot:
|
|
31
|
+
media_id: videoId,
|
|
32
|
+
kind: record.kind
|
|
33
|
+
}, "resolve-video-slot: media is not a video");
|
|
34
34
|
return DEFAULT;
|
|
35
35
|
}
|
|
36
|
-
const posterKey =
|
|
36
|
+
const posterKey = record.renditions.poster?.key ?? null;
|
|
37
37
|
const alt = typeof v.alt === "string" ? v.alt : "";
|
|
38
38
|
try {
|
|
39
|
-
if (videoSourceOf(
|
|
40
|
-
const url =
|
|
39
|
+
if (videoSourceOf(record) === "link") {
|
|
40
|
+
const url = record.url;
|
|
41
41
|
const embed = videoEmbedUrl(url);
|
|
42
42
|
if (!embed) {
|
|
43
|
-
store.log?.warn({
|
|
43
|
+
store.log?.warn({ media_id: videoId }, "resolve-video-slot: link upload embeds nowhere");
|
|
44
44
|
return DEFAULT;
|
|
45
45
|
}
|
|
46
46
|
const out = {
|
|
47
|
-
|
|
47
|
+
id: videoId,
|
|
48
48
|
url: embed,
|
|
49
49
|
poster: posterKey ? await store.fileUrl(posterKey) : "",
|
|
50
50
|
alt,
|
|
51
51
|
source: "link"
|
|
52
52
|
};
|
|
53
|
-
if (
|
|
53
|
+
if (record.provider !== null) out.provider = record.provider;
|
|
54
54
|
return attachPosterResponsive(out, posterKey, store);
|
|
55
55
|
}
|
|
56
56
|
const poster = posterKey ? await store.fileUrl(posterKey) : "";
|
|
57
|
-
const encode =
|
|
57
|
+
const encode = record.renditions.encode;
|
|
58
58
|
if (encode === null) {
|
|
59
59
|
store.log?.warn({
|
|
60
|
-
|
|
61
|
-
state:
|
|
60
|
+
media_id: videoId,
|
|
61
|
+
state: record.state
|
|
62
62
|
}, "resolve-video-slot: no encode; poster-only");
|
|
63
|
-
if (
|
|
63
|
+
if (record.state !== "failed") store.notePending?.({
|
|
64
64
|
kind: "video",
|
|
65
65
|
id: videoId
|
|
66
66
|
});
|
|
67
67
|
return attachPosterResponsive({
|
|
68
|
-
|
|
68
|
+
id: videoId,
|
|
69
69
|
url: "",
|
|
70
70
|
poster,
|
|
71
71
|
alt
|
|
72
72
|
}, posterKey, store);
|
|
73
73
|
}
|
|
74
74
|
const out = {
|
|
75
|
-
|
|
75
|
+
id: videoId,
|
|
76
76
|
url: await store.fileUrl(encode.key),
|
|
77
77
|
poster,
|
|
78
78
|
alt
|
|
@@ -82,7 +82,7 @@ async function resolveVideoSlot(value, assets, store) {
|
|
|
82
82
|
return attachPosterResponsive(out, posterKey, store);
|
|
83
83
|
} catch (err) {
|
|
84
84
|
store.log?.error({
|
|
85
|
-
|
|
85
|
+
media_id: videoId,
|
|
86
86
|
err: err.message
|
|
87
87
|
}, "resolve-video-slot: presign failed; soft-empty video");
|
|
88
88
|
return DEFAULT;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ADDRESS_SOURCES } from "../../template-contracts/dist/address-value.js";
|
|
2
|
-
import { FILE_RENDITION_NAMES, PLACE_RENDITION_NAMES, RENDITION_NAMES, fileNameOf, framedAt, framingOver, hasOwnFraming, isHomeMediaValue, isMediaReference, mediaIdOf, mediaRecords, mergeMedia, readAsRecords, recordOf, splitMedia, videoSourceOf } from "../../template-contracts/dist/registry-facts.js";
|
|
2
|
+
import { FILE_RENDITION_NAMES, PLACE_RENDITION_NAMES, RENDITION_NAMES, contentMediaIdOf, fileNameOf, framedAt, framingOver, hasOwnFraming, isHomeMediaValue, isMediaReference, mediaIdOf, mediaRecords, mergeMedia, readAsRecords, recordOf, splitMedia, videoSourceOf } from "../../template-contracts/dist/registry-facts.js";
|
|
3
3
|
import { libraryFacts, listKeyOf, propertyFacts } from "../../template-contracts/dist/fact-registry.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
@@ -178,6 +178,13 @@ const MediaReferenceSchema = z.object({
|
|
|
178
178
|
crop: CropSchema.nullable().optional(),
|
|
179
179
|
renditions: placeRenditions.partial().strict().optional()
|
|
180
180
|
}).strict();
|
|
181
|
+
const StoredHomeValueSchema = z.object({
|
|
182
|
+
id: z.string(),
|
|
183
|
+
file: z.string(),
|
|
184
|
+
crop: CropSchema.nullable(),
|
|
185
|
+
name: z.string().nullable(),
|
|
186
|
+
renditions: placeRenditions.partial().strict()
|
|
187
|
+
}).strict();
|
|
181
188
|
const REGISTRIES = {
|
|
182
189
|
property: propertyFacts,
|
|
183
190
|
library: libraryFacts
|
|
@@ -86,11 +86,7 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
id: "select",
|
|
89
|
-
summary: "A select
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: "option-source",
|
|
93
|
-
summary: "A select with an option source names a source the platform provides."
|
|
89
|
+
summary: "A select names its choices in exactly one place: its values, or a fact it is bound to that declares them."
|
|
94
90
|
},
|
|
95
91
|
{
|
|
96
92
|
id: "url",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tableBounds, tableForSlot } from "../../template-contracts/dist/registry-shape.js";
|
|
2
|
+
import "../../template-contracts/dist/table-members.js";
|
|
2
3
|
|
|
3
4
|
//#region ../../internal/section-contracts/dist/directly-linked-list-contract.js
|
|
4
5
|
function assertDirectlyLinkedListContract(schema, sectionKey) {
|
|
@@ -9,8 +10,6 @@ function assertDirectlyLinkedListContract(schema, sectionKey) {
|
|
|
9
10
|
if (slot.source?.kind !== "home") continue;
|
|
10
11
|
const table = tableForSlot(slot);
|
|
11
12
|
if (table === null) continue;
|
|
12
|
-
const entry = isLegacyTable(table) ? TABLES[table] : null;
|
|
13
|
-
if (entry !== null && !entry.ownership) throw new Error(`Section "${sectionKey}": ${label} table "${table}" declares no ownership in TABLES. TABLES is a closed registry owned by @homepages/concrete — this is a framework defect, not something a workspace can fix.`);
|
|
14
13
|
const inherited = tableBounds(table);
|
|
15
14
|
if (inherited.max !== void 0 && slot.max !== void 0 && slot.max >= inherited.max) throw new Error(`Section "${sectionKey}": ${label} declares max ${slot.max}, but table "${table}" already caps membership at ${inherited.max}. An explicit max is legal only if it is strictly lower; drop it to inherit ${inherited.max}.`);
|
|
16
15
|
if (inherited.min !== void 0 && slot.min !== void 0 && slot.min <= inherited.min) throw new Error(`Section "${sectionKey}": ${label} declares min ${slot.min}, but table "${table}" already requires at least ${inherited.min}. An explicit min is legal only if it is strictly higher; drop it to inherit ${inherited.min}.`);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { SLOT_TYPES
|
|
1
|
+
import { SLOT_TYPES } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
2
|
import { readMediaOf } from "../../template-contracts/dist/media-candidates.js";
|
|
3
|
+
import { tableOf } from "../../template-contracts/dist/registry-shape.js";
|
|
3
4
|
import { isMediaListKey } from "../../template-contracts/dist/fact-keys.js";
|
|
5
|
+
import "../../template-contracts/dist/table-members.js";
|
|
4
6
|
import { FINDABLE_KINDS, isFindableKind } from "../../template-contracts/dist/findable.js";
|
|
5
7
|
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
6
8
|
import { readFillVerb } from "../../fill-vocabulary/dist/verbs.js";
|
|
@@ -19,7 +21,7 @@ function checkCandidates(of, where) {
|
|
|
19
21
|
if (!isRecord(of)) throw new Error(`${where} picks \`of\` ${JSON.stringify(of)}, which is no list of candidates.`);
|
|
20
22
|
if (of["type"] === "media") {
|
|
21
23
|
const from = readMediaOf(of)?.from;
|
|
22
|
-
if (from === void 0 || !from.every((list) => isMediaListKey(list))) throw new Error(`${where} picks \`of\` ${JSON.stringify(of)} — a media pick states the media list of the property it picks \`from\` and its \`kinds\`; a media slot with no \`from\` owns its
|
|
24
|
+
if (from === void 0 || !from.every((list) => isMediaListKey(list))) throw new Error(`${where} picks \`of\` ${JSON.stringify(of)} — a media pick states the media list of the property it picks \`from\` and its \`kinds\`; a media slot with no \`from\` owns its media, and nothing picks it.`);
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
27
|
if (typeof of["type"] === "string") {
|
|
@@ -28,7 +30,7 @@ function checkCandidates(of, where) {
|
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
32
|
const { kind, key, section, slot, transform } = of;
|
|
31
|
-
if (kind === "home" && typeof key === "string" &&
|
|
33
|
+
if (kind === "home" && typeof key === "string" && tableOf(key) !== null) return;
|
|
32
34
|
if (kind === "section" && typeof section === "string" && typeof slot === "string") return;
|
|
33
35
|
if (kind === "derived" && typeof transform === "string") return;
|
|
34
36
|
throw new Error(`${where} picks \`of\` ${JSON.stringify(of)}, which is not a list of candidates — a table, a media slot's \`from\` list, a list slot, a compute, or a select's values.`);
|
|
@@ -40,6 +42,7 @@ function checkNode(node, where) {
|
|
|
40
42
|
if (typeof node["brief"] !== "string" || node["brief"] === "") throw new Error(`${where} declares no \`brief\` — the brief is the whole instruction.`);
|
|
41
43
|
if (verb === "pick") {
|
|
42
44
|
if (node["of"] === void 0) throw new Error(`${where} picks with no \`of\` — a pick names its candidates on every holder.`);
|
|
45
|
+
if (node["none"] !== void 0) throw new Error(`${where} picks with \`none\` — a pick's verdict may always select nothing, so it states no \`none\`.`);
|
|
43
46
|
checkCandidates(node["of"], where);
|
|
44
47
|
} else if (node["of"] !== void 0) throw new Error(verb === "write" ? `${where} writes \`of\` something — the kind a write produces is its holder's (a text slot's own, a list's \`item\`), so a write takes no \`of\`.` : `${where} finds \`of\` something — the platform's lookup supplies what a find yields, so it takes no \`of\`.`);
|
|
45
48
|
return verb;
|
|
@@ -10,7 +10,6 @@ import { assertNestedSlotTypes } from "./nested-slot-contract.js";
|
|
|
10
10
|
import { assertDirectlyLinkedListContract } from "./directly-linked-list-contract.js";
|
|
11
11
|
import { assertFillVerbContract } from "./fill-verb-contract.js";
|
|
12
12
|
import { assertObjectContract } from "./object-contract.js";
|
|
13
|
-
import { assertOptionSourceContract } from "./option-source-contract.js";
|
|
14
13
|
import { assertPoiCurationContract } from "./poi-curation-contract.js";
|
|
15
14
|
import { assertReadsAcyclicContract } from "./reads-acyclic-contract.js";
|
|
16
15
|
import { assertRowFillContract } from "./row-fill-contract.js";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { OBJECT_BINDING_OWN_KEYS, SLOT_TYPES
|
|
1
|
+
import { OBJECT_BINDING_OWN_KEYS, SLOT_TYPES } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { tableOf } from "../../template-contracts/dist/registry-shape.js";
|
|
3
|
+
import "../../template-contracts/dist/table-members.js";
|
|
2
4
|
import { fillOf, grammarSlots, nestedItemOf } from "./grammar-scope.js";
|
|
3
5
|
|
|
4
6
|
//#region ../../internal/section-contracts/dist/object-contract.js
|
|
@@ -67,7 +69,7 @@ function checkNestedField(ctx, field) {
|
|
|
67
69
|
const where = `Section "${ctx.key}": "${field.path}"`;
|
|
68
70
|
const source = field.def.source;
|
|
69
71
|
if (source === void 0) return;
|
|
70
|
-
if (source.kind === "element" && field.def.type === "row" &&
|
|
72
|
+
if (source.kind === "element" && field.def.type === "row" && tableOf(field.def.from) !== null) throw new Error(`${where} is 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.`);
|
|
71
73
|
if (source.kind === "element") return;
|
|
72
74
|
if (field.def.type !== "row" && source.kind === "row" && typeof source.slot === "string" && field.siblings?.[source.slot]?.type === "row") return;
|
|
73
75
|
throw new Error(`${where} is sourced by ${JSON.stringify(source)} — an item of a list inside an object reads its element, a row \`from\` its member, or a row beside it; ${NESTED_HOME}.`);
|
|
@@ -20,7 +20,7 @@ function assertRowFillContract(schema, decision, sectionKey) {
|
|
|
20
20
|
if (!rowField) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" field "${field}" is not a declared field of "${slotId}" (declared: ${declared.length > 0 ? declared.join(", ") : "none"}).`);
|
|
21
21
|
if (rowField.source) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" fills field "${field}" of "${slotId}", which is source-bound (source.kind "${rowField.source.kind ?? "?"}") — the fact bakes it; drop the decision.`);
|
|
22
22
|
if (rowField.type === "row") continue;
|
|
23
|
-
if (plannerForField(rowField) === void 0) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" fills field "${field}" of "${slotId}" (type "${rowField.type}"), which no row can be filled with — a row field is written or picked inside the list's one batched call: text, a date, an email, a phone, a url, a select key,
|
|
23
|
+
if (plannerForField(rowField) === void 0) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" fills field "${field}" of "${slotId}" (type "${rowField.type}"), which no row can be filled with — a row field is written or picked inside the list's one batched call: text, a date, an email, a phone, a url, a select key, a media value, or a list of those.`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { ADDRESS_MEMBERS, isAddressMember } from "../../template-contracts/dist/address-value.js";
|
|
2
|
+
import { tableKey } from "../../template-contracts/dist/registry-shape.js";
|
|
2
3
|
import { rowTableOf } from "../../template-contracts/dist/ref-locate.js";
|
|
4
|
+
import "../../template-contracts/dist/table-members.js";
|
|
3
5
|
import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
4
6
|
import { fillOf, grammarSlots, insideItem, slotInScope } from "./grammar-scope.js";
|
|
5
7
|
import { fittingTypes, memberFits, refuseIndexedRow } from "./source-contract.js";
|
|
6
|
-
import {
|
|
8
|
+
import { tableMemberOrRefuse } from "./table-member.js";
|
|
7
9
|
|
|
8
10
|
//#region ../../internal/section-contracts/dist/row-rule-contract.js
|
|
9
11
|
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
10
12
|
function memberOf(table, field, where) {
|
|
11
13
|
return tableMemberOrRefuse(table, field, where, {
|
|
12
14
|
noun: "member",
|
|
13
|
-
identity: `"${field}" is the "${
|
|
15
|
+
identity: `"${field}" is the "${tableKey(table)}" row's identity, which the row slot's value already is — read a member of the row instead.`
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
18
|
function resolveHolder(ctx, reader, rowKey, where) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { memberListOfKey } from "../../template-contracts/dist/registry-shape.js";
|
|
1
|
+
import { memberListOfKey, tableKey, tableNames, tableOf } from "../../template-contracts/dist/registry-shape.js";
|
|
3
2
|
import { listSourceRefusal } from "../../template-contracts/dist/row.js";
|
|
4
3
|
import "../../template-contracts/dist/table-members.js";
|
|
5
4
|
import { elementTableOf, fillOf, grammarSlots, insideItem, sameSectionSlot, sectionSlotAt } from "./grammar-scope.js";
|
|
@@ -8,24 +7,24 @@ import { elementTableOf, fillOf, grammarSlots, insideItem, sameSectionSlot, sect
|
|
|
8
7
|
const ORIGINS = "the element inside an item, a row slot, a `compute()`, or a `fill.pick`";
|
|
9
8
|
function originTable(ctx, row) {
|
|
10
9
|
const source = row.def.source;
|
|
11
|
-
if (source?.kind === "element" && row.container !== void 0) return elementTableOf(ctx, row.container)
|
|
10
|
+
if (source?.kind === "element" && row.container !== void 0) return elementTableOf(ctx, row.container);
|
|
12
11
|
if (source?.kind !== "section") return null;
|
|
13
12
|
const target = sameSectionSlot(ctx, source);
|
|
14
13
|
const def = target === null ? void 0 : sectionSlotAt(ctx.schema, target)?.def;
|
|
15
14
|
if (def?.type !== "row" || typeof def.from !== "string") return null;
|
|
16
|
-
return
|
|
15
|
+
return tableOf(def.from) ?? def.from;
|
|
17
16
|
}
|
|
18
17
|
function checkRow(ctx, row) {
|
|
19
18
|
const where = `Section "${ctx.key}": row "${row.path}"`;
|
|
20
19
|
const from = row.def.from;
|
|
21
20
|
if (from === void 0) throw new Error(`${where} declares no \`from\` — a row names its table: \`row({ label, from: fact.property.contacts })\`; rebuild the section with the current Concrete.`);
|
|
22
21
|
if (Array.isArray(from)) for (const [index, key] of from.entries()) {
|
|
23
|
-
if (
|
|
22
|
+
if (tableOf(key) === null) throw new Error(`${where}'s \`from\` lists ${JSON.stringify(key)}, which is no table — a row's list of \`from\` names tables.`);
|
|
24
23
|
if (from.indexOf(key) !== index) throw new Error(`${where} names the table ${JSON.stringify(key)} twice in \`from\`.`);
|
|
25
24
|
}
|
|
26
|
-
const table = Array.isArray(from) ?
|
|
25
|
+
const table = Array.isArray(from) ? tableOf(from[0]) : tableOf(from);
|
|
27
26
|
if (table === null) {
|
|
28
|
-
if (memberListOfKey(from) === null) throw new Error(`${where}'s \`from\` is ${JSON.stringify(from)}, which is neither a table nor a table's list-valued member — a row's \`from\` is one of ${
|
|
27
|
+
if (memberListOfKey(from) === null) throw new Error(`${where}'s \`from\` is ${JSON.stringify(from)}, which is neither a table nor a table's list-valued member — a row's \`from\` is one of ${tableNames().map((table) => `"${tableKey(table)}"`).join(", ")}, or \`<table>.<member>\` for a list-valued member.`);
|
|
29
28
|
if (row.def.source?.kind !== "element" || !insideItem(row)) throw new Error(`${where} is \`from\` the list-valued member ${JSON.stringify(from)} but holds no element — a row from a member holds an item of the list over it: \`source: entry\`.`);
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
@@ -57,7 +56,7 @@ function checkRow(ctx, row) {
|
|
|
57
56
|
default: throw new Error(`${where} is sourced by ${JSON.stringify(source)} — a row's source is ${ORIGINS}.`);
|
|
58
57
|
}
|
|
59
58
|
const held = originTable(ctx, row);
|
|
60
|
-
if (held !== null && held !== table
|
|
59
|
+
if (held !== null && held !== table) throw new Error(`${where} is \`from\` the ${table} table but its source holds rows of ${held} — a row's source yields a row of its own \`from\`.`);
|
|
61
60
|
}
|
|
62
61
|
function assertRowSourceContract(ctx) {
|
|
63
62
|
for (const slot of grammarSlots(ctx.schema)) if (slot.def.type === "row") checkRow(ctx, slot);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { FACT_GRAPH } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { legacyFactKey } from "../../template-contracts/dist/registry-aliases.js";
|
|
3
1
|
import { isReadableFactKey } from "../../template-contracts/dist/fact-keys.js";
|
|
4
2
|
import { SECTION_CONTRACT_CATALOG } from "./catalog.js";
|
|
5
3
|
import { producedSlot } from "./grammar-scope.js";
|
|
@@ -14,7 +12,6 @@ import { assertNestedSlotTypes } from "./nested-slot-contract.js";
|
|
|
14
12
|
import { assertDirectlyLinkedListContract } from "./directly-linked-list-contract.js";
|
|
15
13
|
import { assertFillVerbContract } from "./fill-verb-contract.js";
|
|
16
14
|
import { assertObjectContract } from "./object-contract.js";
|
|
17
|
-
import { assertOptionSourceContract } from "./option-source-contract.js";
|
|
18
15
|
import { DECISION_KINDS } from "./fill-spec-view.js";
|
|
19
16
|
import { assertPoiCurationContract } from "./poi-curation-contract.js";
|
|
20
17
|
import { assertReadsAcyclicContract } from "./reads-acyclic-contract.js";
|
|
@@ -54,7 +51,7 @@ function decisionReadNodes(decision) {
|
|
|
54
51
|
const CONTRACTS = {
|
|
55
52
|
"reads-readable": {
|
|
56
53
|
implementation: bySection(({ key, fillSpec }) => {
|
|
57
|
-
for (const r of fillSpec.reads ?? []) if (!isReadableFactKey(r)
|
|
54
|
+
for (const r of fillSpec.reads ?? []) if (!isReadableFactKey(r)) throw new Error(`Section "${key}": fill-spec reads "${r}", which is not a fact the registry declares.`);
|
|
58
55
|
for (const d of fillSpec.decisions) for (const [at, node] of decisionReadNodes(d)) assertDeclaredRefs(`Section "${key}": fill-spec decision "${d.id}"${at}`, node.reads);
|
|
59
56
|
}),
|
|
60
57
|
assertions: []
|
|
@@ -62,10 +59,8 @@ const CONTRACTS = {
|
|
|
62
59
|
"decision-kind": {
|
|
63
60
|
implementation: byDecision(({ key }, d) => {
|
|
64
61
|
if (d.kind !== void 0 && DECISION_KINDS.includes(d.kind)) return;
|
|
65
|
-
const { type } = d;
|
|
66
62
|
const found = d.kind === void 0 ? "declares no `kind`" : `declares kind "${d.kind}"`;
|
|
67
|
-
|
|
68
|
-
throw new Error(`Section "${key}": fill-spec decision "${d.id}" ${found}${retired}. A decision's kind is one of ${DECISION_KINDS.map((k) => `"${k}"`).join(", ")}; rebuild the section with the current Concrete.`);
|
|
63
|
+
throw new Error(`Section "${key}": fill-spec decision "${d.id}" ${found}. A decision's kind is one of ${DECISION_KINDS.map((k) => `"${k}"`).join(", ")}; rebuild the section with the current Concrete.`);
|
|
69
64
|
}),
|
|
70
65
|
assertions: []
|
|
71
66
|
},
|
|
@@ -158,10 +153,6 @@ const CONTRACTS = {
|
|
|
158
153
|
implementation: bySection(({ key, schema }) => assertSelectContract(schema, key)),
|
|
159
154
|
assertions: [assertSelectContract]
|
|
160
155
|
},
|
|
161
|
-
"option-source": {
|
|
162
|
-
implementation: bySection(({ key, schema }) => assertOptionSourceContract(schema, key)),
|
|
163
|
-
assertions: [assertOptionSourceContract]
|
|
164
|
-
},
|
|
165
156
|
url: {
|
|
166
157
|
implementation: bySection(({ key, schema }) => assertUrlContract(schema, key)),
|
|
167
158
|
assertions: [assertUrlContract]
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { factSelectValues } from "../../template-contracts/dist/fact-keys.js";
|
|
2
|
+
|
|
1
3
|
//#region ../../internal/section-contracts/dist/select-contract.js
|
|
2
4
|
function checkSelectSlot(slot, label, sectionKey) {
|
|
3
5
|
if (slot.type !== "select") return;
|
|
4
|
-
|
|
6
|
+
const hasValues = slot.values != null;
|
|
7
|
+
const fact = slot.source?.kind === "home" ? slot.source.key : void 0;
|
|
8
|
+
if (hasValues && fact !== void 0) throw new Error(`Section "${sectionKey}": ${label} declares both \`values\` and a fact source — name its choices in one place.`);
|
|
9
|
+
if (!hasValues && fact === void 0) throw new Error(`Section "${sectionKey}": ${label} needs its choices: \`values\`, or a fact source whose fact declares them.`);
|
|
10
|
+
if (fact !== void 0 && factSelectValues(fact) === void 0) throw new Error(`Section "${sectionKey}": ${label} is bound to ${JSON.stringify(fact)}, which declares no choices, so the dropdown would be empty — bind a fact that declares them (\`fact.property.listing_intent\`), or name the choices as its \`from\`.`);
|
|
5
11
|
}
|
|
6
12
|
function assertSelectContract(schema, sectionKey) {
|
|
7
13
|
for (const [slotId, slotUnknown] of Object.entries(schema.slots)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tableOf } from "../../template-contracts/dist/registry-shape.js";
|
|
2
2
|
import { mirrorKindOf } from "../../template-contracts/dist/mirror-kind.js";
|
|
3
|
-
import { isMediaListKey,
|
|
3
|
+
import { isMediaListKey, isRegistryFactKey, registryFactValueType } from "../../template-contracts/dist/fact-keys.js";
|
|
4
|
+
import "../../template-contracts/dist/table-members.js";
|
|
4
5
|
import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
5
6
|
import { objectFieldOf } from "../../template-contracts/dist/slot-overrides.js";
|
|
6
7
|
|
|
@@ -16,15 +17,18 @@ function assertOne(path, key, slot, section) {
|
|
|
16
17
|
if (src.kind === "home") {
|
|
17
18
|
const field = src.key ?? "";
|
|
18
19
|
if (isMediaListKey(field)) throw new Error(`${path}: "${field}" is read, never bound — a \`compute()\` reads a media list; a media slot or a list of media picks from it, naming it as its \`from\` (\`fill.pick\`).`);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
20
|
+
if (tableOf(field) !== null) {
|
|
21
|
+
if (!(slot.type === "list" && (slot.element?.type === "row" || slot.element?.type === "object"))) throw new Error(`${path}: table source "${field}" needs an item that declares a row (\`list({ item: (el) => object({ … }) })\`) — a fact row cannot project onto one slot.`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!isRegistryFactKey(field)) throw new Error(`${path}: unknown fact "${String(src.key)}"`);
|
|
25
|
+
const valueType = registryFactValueType(field);
|
|
26
|
+
if (valueType === "image" && slot.type !== "image") throw new Error(`${path}: image source field "${src.key}" must sit on an image slot`);
|
|
27
|
+
if (valueType === "address" && slot.type !== "address") throw new Error(`${path}: "${field}" is a whole address, which only an \`address\` slot holds — bind it to an \`address()\`, or show the line you want with a \`compute()\` reading it.`);
|
|
28
|
+
if (slot.type === "address" && valueType !== "address") throw new Error(`${path}: an \`address\` slot bound to "${field}", which is not an address — bind it to the property's address, or compute the value.`);
|
|
25
29
|
return;
|
|
26
30
|
}
|
|
27
|
-
if (typeof src.kind !== "string") throw new Error(`${path} is sourced by a ref without a "kind" —
|
|
31
|
+
if (typeof src.kind !== "string") throw new Error(`${path} is sourced by a ref without a "kind" — every ref names its kind.`);
|
|
28
32
|
if (src.kind === "item") throw new Error(`${path} is sourced by a field of its own item ({ kind: "item" }) — a section's item fields do not read one another; read the element, or a member through a row.`);
|
|
29
33
|
if (src.kind !== "derived") return;
|
|
30
34
|
if (src.transform !== key) throw new Error(`${path}: unknown transform "${String(src.transform)}". A "derived" source is a compute() binding, and its transform must equal its own slot key ("${key}") — it does not, which means the schema was hand-authored with a mismatched transform rather than produced by defineSchema's compute() path. Author a derived value with compute() ("slot({ source: compute({ reads }, fn) })").`);
|
|
@@ -58,7 +62,7 @@ function assertDeclaredRefs(path, reads) {
|
|
|
58
62
|
if (kind === "section" && typeof section === "string" && typeof slot === "string") return;
|
|
59
63
|
refuseIndexedRow(`${path}: reads[${String(i)}]`, record);
|
|
60
64
|
if (kind === "row" && "slot" in record || kind === "element") return;
|
|
61
|
-
throw new Error(kind ===
|
|
65
|
+
throw new Error(kind === "item" ? `${path}: reads[${String(i)}] reads a field of its own item ({ kind: "item" }) — a section's item fields do not read one another; read the element, or a member through a row.` : kind === "row" ? `${path}: reads[${String(i)}] reads the row member "${String(field)}" without naming its row slot — read it through a row: \`{ kind: "row", slot, field }\`.` : `${path}: reads[${String(i)}] is not a home ref ({ kind: "home", key }) or a section ref ({ kind: "section", section, slot }).`);
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
function assertSourceContract(schema) {
|
|
@@ -16,7 +16,6 @@ function isBound(slot) {
|
|
|
16
16
|
return kind !== void 0 && BINDING_KINDS.has(kind);
|
|
17
17
|
}
|
|
18
18
|
function check(slot, sectionKey, path, inherited, picked = false) {
|
|
19
|
-
if (slot.sources !== void 0) throw new Error(`Section "${sectionKey}": slot "${path}" declares \`sources\`. A media slot takes a pasted link wherever a link provider claims its kind (a video, a tour) and declares nothing for it — \`concrete upgrade\` removes it.`);
|
|
20
19
|
const holdsPick = picked && slot.source?.kind === "element" && isMediaType(slot.type ?? "");
|
|
21
20
|
checkMediaFilter(slot, sectionKey, path, inherited || isBound(slot) && !holdsPick);
|
|
22
21
|
if (slot.element) {
|
|
@@ -27,7 +26,6 @@ function check(slot, sectionKey, path, inherited, picked = false) {
|
|
|
27
26
|
}
|
|
28
27
|
function checkMediaFilter(slot, sectionKey, path, bound) {
|
|
29
28
|
const kind = slot.type ?? "";
|
|
30
|
-
if ("category" in slot) throw new Error(`Section "${sectionKey}": slot "${path}" declares \`category\`. A media slot names the list it picks from in \`from\` (${mediaListKeys().map((key) => `"${key}"`).join(", ")}), or owns its asset without one.`);
|
|
31
29
|
if (!isMediaType(kind)) {
|
|
32
30
|
if (slot.from !== void 0 && kind !== "row") throw new Error(`Section "${sectionKey}": slot "${path}" declares \`from\`, but a section's ${kind === "select" ? "select states its values" : "slot names no candidates of its own"} — a media slot picks \`from\` a media list, a row from its table.`);
|
|
33
31
|
if (slot.process !== void 0) throw new Error(`Section "${sectionKey}": slot "${path}" declares \`process\`, which only a media slot (image, video, tour, document, media) carries.`);
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tableKey } from "../../template-contracts/dist/registry-shape.js";
|
|
2
2
|
import { tableRowMember } from "../../template-contracts/dist/table-members.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/section-contracts/dist/table-member.js
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
function tableMemberOrRefuse(key, field, at, refusal) {
|
|
9
|
-
const found = tableRowMember(key, field);
|
|
5
|
+
function tableMemberOrRefuse(table, field, at, refusal) {
|
|
6
|
+
const found = tableRowMember(table, field);
|
|
10
7
|
if (found.kind === "identity") throw new Error(`${at}: ${refusal.identity}`);
|
|
11
|
-
if (found.kind === "unknown") throw new Error(`${at}: unknown ${refusal.noun} "${field}" — a "${
|
|
8
|
+
if (found.kind === "unknown") throw new Error(`${at}: unknown ${refusal.noun} "${field}" — a "${tableKey(table)}" row offers ${found.offers.map((name) => `"${name}"`).join(", ")}.`);
|
|
12
9
|
return found;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
12
|
//#endregion
|
|
16
|
-
export {
|
|
13
|
+
export { tableMemberOrRefuse };
|