@elytracms/studio 0.0.88 → 0.0.91
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/convex/asset-revalidate.test.ts +49 -43
- package/convex/cms.ts +3 -4
- package/convex/delivery.ts +8 -11
- package/convex/document-revalidate.test.ts +188 -0
- package/convex/redirect-revalidate.test.ts +50 -37
- package/convex/revalidate.ts +18 -30
- package/convex/triggers.ts +47 -38
- package/convex/webhooks.ts +77 -62
- package/dist/components/account/self-account-view-source.js +2 -1
- package/dist/components/account/self-account-view-source.js.map +1 -1
- package/dist/components/ai/ai-chat-panel.js +1 -1
- package/dist/components/ai/ai-chat-panel.js.map +1 -1
- package/dist/components/app-views/default-modules.js +3 -3
- package/dist/components/app-views/default-modules.js.map +1 -1
- package/dist/components/assets/asset-grid.js +1 -1
- package/dist/components/assets/asset-grid.js.map +1 -1
- package/dist/components/assets/asset-selection.d.ts +8 -9
- package/dist/components/assets/asset-selection.js +26 -16
- package/dist/components/assets/asset-selection.js.map +1 -1
- package/dist/components/assets/assets-collection-view-source.js +3 -2
- package/dist/components/assets/assets-collection-view-source.js.map +1 -1
- package/dist/components/builder/blocks-model.d.ts +7 -5
- package/dist/components/builder/blocks-model.js +11 -9
- package/dist/components/builder/blocks-model.js.map +1 -1
- package/dist/components/builder/blocks-panel.js +1 -1
- package/dist/components/builder/blocks-panel.js.map +1 -1
- package/dist/components/builder/builder-store.d.ts +11 -3
- package/dist/components/builder/builder-store.js +12 -5
- package/dist/components/builder/builder-store.js.map +1 -1
- package/dist/components/builder/canvas-dnd.d.ts +7 -1
- package/dist/components/builder/canvas-dnd.js +6 -3
- package/dist/components/builder/canvas-dnd.js.map +1 -1
- package/dist/components/builder/canvas-render-context.d.ts +13 -1
- package/dist/components/builder/canvas-render-context.js +28 -18
- package/dist/components/builder/canvas-render-context.js.map +1 -1
- package/dist/components/builder/canvas.js +1 -1
- package/dist/components/builder/canvas.js.map +1 -1
- package/dist/components/builder/clipboard-actions.d.ts +0 -6
- package/dist/components/builder/clipboard-actions.js +9 -4
- package/dist/components/builder/clipboard-actions.js.map +1 -1
- package/dist/components/builder/composition-field-editor.d.ts +22 -0
- package/dist/components/builder/composition-field-editor.js +47 -8
- package/dist/components/builder/composition-field-editor.js.map +1 -1
- package/dist/components/builder/inline-edit.d.ts +7 -4
- package/dist/components/builder/inline-edit.js +11 -8
- package/dist/components/builder/inline-edit.js.map +1 -1
- package/dist/components/builder/insert-context.js +9 -5
- package/dist/components/builder/insert-context.js.map +1 -1
- package/dist/components/builder/layout-inspector.d.ts +2 -2
- package/dist/components/builder/layout-inspector.js +8 -6
- package/dist/components/builder/layout-inspector.js.map +1 -1
- package/dist/components/builder/node-factory.d.ts +31 -14
- package/dist/components/builder/node-factory.js +73 -93
- package/dist/components/builder/node-factory.js.map +1 -1
- package/dist/components/builder/page-tree.d.ts +3 -1
- package/dist/components/builder/page-tree.js +6 -4
- package/dist/components/builder/page-tree.js.map +1 -1
- package/dist/components/builder/property-inspector.js +2 -1
- package/dist/components/builder/property-inspector.js.map +1 -1
- package/dist/components/builder/reuse-context.js +2 -2
- package/dist/components/builder/reuse-context.js.map +1 -1
- package/dist/components/builder/reuse.d.ts +7 -3
- package/dist/components/builder/reuse.js +19 -11
- package/dist/components/builder/reuse.js.map +1 -1
- package/dist/components/builder/selection-overlay.d.ts +2 -2
- package/dist/components/builder/selection-overlay.js +3 -3
- package/dist/components/builder/selection-overlay.js.map +1 -1
- package/dist/components/builder/spacing-handles.d.ts +2 -2
- package/dist/components/builder/spacing-handles.js +3 -3
- package/dist/components/builder/spacing-handles.js.map +1 -1
- package/dist/components/cms/asset-field.d.ts +1 -1
- package/dist/components/cms/asset-field.js +15 -13
- package/dist/components/cms/asset-field.js.map +1 -1
- package/dist/components/cms/asset-picker-core.js +3 -4
- package/dist/components/cms/asset-picker-core.js.map +1 -1
- package/dist/components/cms/cell-edit.d.ts +0 -6
- package/dist/components/cms/cell-edit.js +5 -23
- package/dist/components/cms/cell-edit.js.map +1 -1
- package/dist/components/cms/cms-store.d.ts +3 -2
- package/dist/components/cms/cms-store.js +23 -24
- package/dist/components/cms/cms-store.js.map +1 -1
- package/dist/components/cms/collection-table.js +14 -4
- package/dist/components/cms/collection-table.js.map +1 -1
- package/dist/components/cms/detail-editor.js +28 -24
- package/dist/components/cms/detail-editor.js.map +1 -1
- package/dist/components/cms/discard-draft.d.ts +1 -2
- package/dist/components/cms/discard-draft.js +1 -1
- package/dist/components/cms/discard-draft.js.map +1 -1
- package/dist/components/cms/duplicate-document.d.ts +3 -2
- package/dist/components/cms/duplicate-document.js +5 -5
- package/dist/components/cms/duplicate-document.js.map +1 -1
- package/dist/components/cms/editable-cell.js +11 -7
- package/dist/components/cms/editable-cell.js.map +1 -1
- package/dist/components/cms/field-control-lib.d.ts +10 -0
- package/dist/components/cms/field-control-lib.js +20 -0
- package/dist/components/cms/field-control-lib.js.map +1 -1
- package/dist/components/cms/field-control.js +10 -9
- package/dist/components/cms/field-control.js.map +1 -1
- package/dist/components/cms/object-array-field.js +3 -5
- package/dist/components/cms/object-array-field.js.map +1 -1
- package/dist/components/cms/prop-fields.d.ts +16 -3
- package/dist/components/cms/prop-fields.js +57 -12
- package/dist/components/cms/prop-fields.js.map +1 -1
- package/dist/components/cms/publish-clean.d.ts +13 -6
- package/dist/components/cms/publish-clean.js +14 -6
- package/dist/components/cms/publish-clean.js.map +1 -1
- package/dist/components/cms/rich-text/embed-props.d.ts +6 -1
- package/dist/components/cms/rich-text/embed-props.js +7 -12
- package/dist/components/cms/rich-text/embed-props.js.map +1 -1
- package/dist/components/cms/rich-text/insert.d.ts +13 -6
- package/dist/components/cms/rich-text/insert.js +16 -17
- package/dist/components/cms/rich-text/insert.js.map +1 -1
- package/dist/components/cms/use-cell-edit.js +7 -12
- package/dist/components/cms/use-cell-edit.js.map +1 -1
- package/dist/components/cms/use-discard-controller.d.ts +1 -2
- package/dist/components/cms/use-discard-controller.js +1 -2
- package/dist/components/cms/use-discard-controller.js.map +1 -1
- package/dist/components/cms/use-publish-controller.js +3 -2
- package/dist/components/cms/use-publish-controller.js.map +1 -1
- package/dist/components/cms/versions-pane.js +2 -2
- package/dist/components/cms/versions-pane.js.map +1 -1
- package/dist/components/components/component-detail.d.ts +1 -1
- package/dist/components/components/component-detail.js +2 -4
- package/dist/components/components/component-detail.js.map +1 -1
- package/dist/components/components/component-preview.js +9 -4
- package/dist/components/components/component-preview.js.map +1 -1
- package/dist/components/components/components-index.d.ts +2 -2
- package/dist/components/components/components-index.js +3 -6
- package/dist/components/components/components-index.js.map +1 -1
- package/dist/components/components/field-inspector.js +5 -2
- package/dist/components/components/field-inspector.js.map +1 -1
- package/dist/components/components/registry-browser.d.ts +6 -5
- package/dist/components/components/registry-browser.js +11 -37
- package/dist/components/components/registry-browser.js.map +1 -1
- package/dist/components/components/taxonomy.d.ts +14 -21
- package/dist/components/components/taxonomy.js +5 -29
- package/dist/components/components/taxonomy.js.map +1 -1
- package/dist/components/components/transfer-dialog.js +1 -0
- package/dist/components/components/transfer-dialog.js.map +1 -1
- package/dist/components/components/transfer.d.ts +20 -12
- package/dist/components/components/transfer.js +27 -21
- package/dist/components/components/transfer.js.map +1 -1
- package/dist/components/delivery-health-banner.d.ts +3 -2
- package/dist/components/delivery-health-banner.js +3 -2
- package/dist/components/delivery-health-banner.js.map +1 -1
- package/dist/components/redirects/redirects-collection-view-source.js +3 -2
- package/dist/components/redirects/redirects-collection-view-source.js.map +1 -1
- package/dist/components/users/users-collection-view-source.js +2 -1
- package/dist/components/users/users-collection-view-source.js.map +1 -1
- package/dist/lib/ai/apply-content.js +32 -28
- package/dist/lib/ai/apply-content.js.map +1 -1
- package/dist/lib/ai/constraints.d.ts +16 -14
- package/dist/lib/ai/constraints.js +64 -48
- package/dist/lib/ai/constraints.js.map +1 -1
- package/dist/lib/ai/translate-document.js +11 -7
- package/dist/lib/ai/translate-document.js.map +1 -1
- package/dist/lib/ai/types.d.ts +9 -5
- package/dist/lib/ai/types.js.map +1 -1
- package/dist/lib/ai/update-fields.js +15 -32
- package/dist/lib/ai/update-fields.js.map +1 -1
- package/dist/lib/ai/vite.d.ts +22 -2
- package/dist/lib/ai/vite.js +12 -3
- package/dist/lib/ai/vite.js.map +1 -1
- package/dist/lib/assets/asset-placements.d.ts +3 -10
- package/dist/lib/assets/asset-placements.js +17 -8
- package/dist/lib/assets/asset-placements.js.map +1 -1
- package/dist/lib/clipboard/paste-target.js +3 -3
- package/dist/lib/clipboard/paste-target.js.map +1 -1
- package/dist/lib/cms/published-documents.d.ts +14 -3
- package/dist/lib/cms/published-documents.js +12 -3
- package/dist/lib/cms/published-documents.js.map +1 -1
- package/dist/lib/cms-views/view-model.d.ts +4 -4
- package/dist/lib/cms-views/view-model.js +26 -20
- package/dist/lib/cms-views/view-model.js.map +1 -1
- package/dist/lib/data/collection-content.d.ts +10 -7
- package/dist/lib/data/collection-content.js +70 -29
- package/dist/lib/data/collection-content.js.map +1 -1
- package/dist/lib/delivery/instant-publish.d.ts +0 -3
- package/dist/lib/delivery/instant-publish.js +0 -1
- package/dist/lib/delivery/instant-publish.js.map +1 -1
- package/dist/lib/dnd/drop-rules.d.ts +22 -7
- package/dist/lib/dnd/drop-rules.js +21 -14
- package/dist/lib/dnd/drop-rules.js.map +1 -1
- package/dist/lib/engine-version.d.ts +1 -1
- package/dist/lib/engine-version.js +1 -1
- package/dist/lib/engine-version.js.map +1 -1
- package/dist/lib/i18n/messages.de.js +25 -9
- package/dist/lib/i18n/messages.de.js.map +1 -1
- package/dist/lib/i18n/messages.en.d.ts +21 -7
- package/dist/lib/i18n/messages.en.js +28 -9
- package/dist/lib/i18n/messages.en.js.map +1 -1
- package/dist/lib/locale/fallback.d.ts +5 -19
- package/dist/lib/locale/fallback.js +18 -39
- package/dist/lib/locale/fallback.js.map +1 -1
- package/dist/lib/locale/locale-store.js +2 -1
- package/dist/lib/locale/locale-store.js.map +1 -1
- package/dist/lib/operations/cms-persistence.js +7 -4
- package/dist/lib/operations/cms-persistence.js.map +1 -1
- package/dist/lib/operations/studio-operations.js +4 -6
- package/dist/lib/operations/studio-operations.js.map +1 -1
- package/dist/lib/persistence/backend-mode.d.ts +5 -25
- package/dist/lib/persistence/backend-mode.js +13 -30
- package/dist/lib/persistence/backend-mode.js.map +1 -1
- package/dist/lib/persona/labels.d.ts +4 -9
- package/dist/lib/persona/labels.js +5 -12
- package/dist/lib/persona/labels.js.map +1 -1
- package/dist/lib/references/reference-model.d.ts +17 -5
- package/dist/lib/references/reference-model.js +20 -28
- package/dist/lib/references/reference-model.js.map +1 -1
- package/dist/lib/references/references-store.js +7 -0
- package/dist/lib/references/references-store.js.map +1 -1
- package/dist/lib/registry/__fixtures__/demo-components.d.ts +32 -0
- package/dist/lib/registry/{project-components.js → __fixtures__/demo-components.js} +18 -5
- package/dist/lib/registry/__fixtures__/demo-components.js.map +1 -0
- package/dist/lib/registry/index.d.ts +9 -13
- package/dist/lib/registry/index.js +34 -61
- package/dist/lib/registry/index.js.map +1 -1
- package/dist/lib/registry/preview.d.ts +22 -7
- package/dist/lib/registry/preview.js +26 -89
- package/dist/lib/registry/preview.js.map +1 -1
- package/dist/lib/workspace/index.d.ts +0 -7
- package/dist/lib/workspace/index.js +0 -9
- package/dist/lib/workspace/index.js.map +1 -1
- package/dist/previews/enumerate.d.ts +23 -27
- package/dist/previews/enumerate.js +27 -48
- package/dist/previews/enumerate.js.map +1 -1
- package/dist/previews/harness.js +1 -1
- package/dist/previews/harness.js.map +1 -1
- package/package.json +4 -7
- package/dist/lib/registry/project-components.d.ts +0 -16
- package/dist/lib/registry/project-components.js.map +0 -1
- package/dist/lib/webhooks/config.d.ts +0 -15
- package/dist/lib/webhooks/config.js +0 -65
- package/dist/lib/webhooks/config.js.map +0 -1
- package/dist/lib/webhooks/dispatcher.d.ts +0 -70
- package/dist/lib/webhooks/dispatcher.js +0 -61
- package/dist/lib/webhooks/dispatcher.js.map +0 -1
- package/dist/lib/webhooks/index.d.ts +0 -11
- package/dist/lib/webhooks/index.js +0 -10
- package/dist/lib/webhooks/index.js.map +0 -1
- package/dist/lib/webhooks/signing.d.ts +0 -15
- package/dist/lib/webhooks/signing.js +0 -24
- package/dist/lib/webhooks/signing.js.map +0 -1
- package/dist/lib/webhooks/tags.d.ts +0 -25
- package/dist/lib/webhooks/tags.js +0 -289
- package/dist/lib/webhooks/tags.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContentClient, createContentContext, queryError, validateLimit, validateSort, validateWhere, } from '@elytracms/core/content';
|
|
2
|
-
import { documentKey, resolveDocumentTitle } from '@elytracms/core/cms-core';
|
|
2
|
+
import { documentKey, localeSchema, parseLocaleConfig, resolveDocumentTitle, valuesInLocale, } from '@elytracms/core/cms-core';
|
|
3
|
+
import { listingRequestOf } from '@elytracms/core/runtime-renderer';
|
|
3
4
|
import { getStudioLocale, getStudioLocaleConfig } from '../locale/locale-store.js';
|
|
4
5
|
/**
|
|
5
6
|
* Default (no-session) collection schema: EMPTY. The studio ships no demo content
|
|
@@ -43,7 +44,7 @@ export function subscribeContentSession(listener) {
|
|
|
43
44
|
export function configureContentSession(next) {
|
|
44
45
|
contentSession = next;
|
|
45
46
|
lookup = next
|
|
46
|
-
? createLookup(next.collections, next.documents, next.publishedKeys, next.assets)
|
|
47
|
+
? createLookup(next.collections, next.documents, next.publishedKeys, next.assets, next.localeConfig)
|
|
47
48
|
: createLookup(playgroundCollections, [], []);
|
|
48
49
|
clients.clear();
|
|
49
50
|
sessionEpoch += 1;
|
|
@@ -99,14 +100,25 @@ function previewLocale() {
|
|
|
99
100
|
* else the single locale actually being asked for.
|
|
100
101
|
*
|
|
101
102
|
* That last step is a DERIVATION, not an invention — it says "the only locale we
|
|
102
|
-
* know of is the one you named", so
|
|
103
|
-
*
|
|
104
|
-
* read `?? sampleLocaleConfig`, which silently declared
|
|
105
|
-
* bilingual `en/de` and resolved fallbacks through an `en`
|
|
103
|
+
* know of is the one you named", so the default-locale fallback is the requested
|
|
104
|
+
* locale itself (a no-op) and a localized read falls through to `doc.values`.
|
|
105
|
+
* Before EC-479 this line read `?? sampleLocaleConfig`, which silently declared
|
|
106
|
+
* every locale-less studio bilingual `en/de` and resolved fallbacks through an `en`
|
|
107
|
+
* no project had chosen. Only reached with no session AND no installed config, so
|
|
108
|
+
* no stored key is ever written against it.
|
|
106
109
|
*/
|
|
107
110
|
function activeLocaleConfig(locale) {
|
|
108
|
-
return
|
|
109
|
-
|
|
111
|
+
return contentSession?.localeConfig ?? getStudioLocaleConfig() ?? requestedLocaleOnly(locale);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The single-locale derivation above, through the one constructor (EC-580:
|
|
115
|
+
* `LocaleConfig` is parse-only). {@link NO_LOCALE} — or anything else that is not
|
|
116
|
+
* a locale code — becomes `und`, BCP 47's own "undetermined", which likewise
|
|
117
|
+
* matches no stored key.
|
|
118
|
+
*/
|
|
119
|
+
function requestedLocaleOnly(locale) {
|
|
120
|
+
const code = localeSchema.safeParse(locale).success ? locale : 'und';
|
|
121
|
+
return parseLocaleConfig({ default: code, locales: [code] });
|
|
110
122
|
}
|
|
111
123
|
/** Resolve a collection in the active content session (fixtures in playground). */
|
|
112
124
|
export function playgroundCollection(id) {
|
|
@@ -135,10 +147,20 @@ export function withPlaygroundFilterable(collections) {
|
|
|
135
147
|
};
|
|
136
148
|
});
|
|
137
149
|
}
|
|
138
|
-
/**
|
|
139
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Synthesize the persistence-shaped asset record the asset resolver reads. EC-580:
|
|
152
|
+
* the record's single `alt` is the DEFAULT locale's displayed value
|
|
153
|
+
* (`valuesInLocale`, the project's config default) — it used to read
|
|
154
|
+
* `localized.en.alt` whatever the project's locales were (MODE F5b, "further
|
|
155
|
+
* evidence"), so a `de`-default project's previews had no alt and a shared `alt`
|
|
156
|
+
* was never read. Without a locale model (no session config) only the shared bag
|
|
157
|
+
* can be read.
|
|
158
|
+
*/
|
|
159
|
+
function assetRecordOf(doc, collection, locales) {
|
|
140
160
|
const values = doc.values;
|
|
141
|
-
const alt =
|
|
161
|
+
const alt = collection && locales
|
|
162
|
+
? valuesInLocale(collection, doc, locales.default, locales).alt
|
|
163
|
+
: values.alt;
|
|
142
164
|
return {
|
|
143
165
|
id: doc.id,
|
|
144
166
|
projectId: 'playground',
|
|
@@ -151,7 +173,7 @@ function assetRecordOf(doc) {
|
|
|
151
173
|
updatedAt: '2026-01-01T00:00:00.000Z',
|
|
152
174
|
};
|
|
153
175
|
}
|
|
154
|
-
function createLookup(collectionDefs, documents, publishedKeys, assetRecords) {
|
|
176
|
+
function createLookup(collectionDefs, documents, publishedKeys, assetRecords, locales) {
|
|
155
177
|
const collections = new Map(collectionDefs.map((c) => [c.id, c]));
|
|
156
178
|
// EC-224: published-ness is the version POINTER, not the flat `state` enum.
|
|
157
179
|
// A hydrated session hands `publishedKeys` (the pinned set) → wrap each row as
|
|
@@ -176,8 +198,9 @@ function createLookup(collectionDefs, documents, publishedKeys, assetRecords) {
|
|
|
176
198
|
// so without these the content client resolves no nested image.
|
|
177
199
|
const assets = new Map();
|
|
178
200
|
for (const doc of documents) {
|
|
179
|
-
if (doc.collection === 'asset')
|
|
180
|
-
assets.set(doc.id, assetRecordOf(doc));
|
|
201
|
+
if (doc.collection === 'asset') {
|
|
202
|
+
assets.set(doc.id, assetRecordOf(doc, collections.get(doc.collection), locales));
|
|
203
|
+
}
|
|
181
204
|
}
|
|
182
205
|
for (const record of assetRecords ?? [])
|
|
183
206
|
assets.set(record.id, record);
|
|
@@ -250,21 +273,36 @@ export function getCollectionDocument(collectionId, idOrSlug, locale = previewLo
|
|
|
250
273
|
export function resolveCanvasRelation(ref, locale = previewLocale(), perspective = 'published') {
|
|
251
274
|
return clientFor(locale, perspective).resolveRelation(ref);
|
|
252
275
|
}
|
|
276
|
+
/** The real clock — the canvas boundary's default; tests inject a fixed one (EC-581 6a). */
|
|
277
|
+
const systemClock = () => new Date().toISOString();
|
|
278
|
+
/**
|
|
279
|
+
* A listing query as `listDocuments` input (EC-581 6a): executed through
|
|
280
|
+
* `listingRequestOf` — the phase the delivery host runs too, so canvas and site
|
|
281
|
+
* build the identical request — with `{ now: true }` read from `clock`. The
|
|
282
|
+
* operands are JSON bound from authored props; the cast hands them to the one
|
|
283
|
+
* validator (`validateWhere`/`validateLimit`), which reports anything invalid.
|
|
284
|
+
*/
|
|
285
|
+
function listDocumentsQueryOf(query, clock) {
|
|
286
|
+
const request = listingRequestOf(query, clock);
|
|
287
|
+
return {
|
|
288
|
+
where: request.where,
|
|
289
|
+
...(request.sort ? { sort: request.sort } : {}),
|
|
290
|
+
...(request.limit !== undefined ? { limit: request.limit } : {}),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
253
293
|
/**
|
|
254
294
|
* Resolve a listing block's query to its documents for the canvas (EC-255) — the
|
|
255
295
|
* studio analog of the host's baked listings map. Runs the query (collection +
|
|
256
|
-
* AND-only
|
|
257
|
-
* (published perspective, active locale), so
|
|
258
|
-
* ProductGrid keyed to a category) exactly as
|
|
259
|
-
* (structured, never thrown) or a non-list
|
|
260
|
-
*
|
|
296
|
+
* AND-only `where`, optional sort/limit; EC-581 6a: `now` read from `clock`)
|
|
297
|
+
* through the active session's client (published perspective, active locale), so
|
|
298
|
+
* the canvas previews a dynamic grid (a ProductGrid keyed to a category) exactly as
|
|
299
|
+
* delivery renders it. An invalid query (structured, never thrown) or a non-list
|
|
300
|
+
* lookup yields `[]` → the block's empty state, and the canvas notice
|
|
301
|
+
* ({@link validateCanvasListingQuery}) says why. Reuses the same `listDocuments`
|
|
302
|
+
* path as `runCollectionListQuery`.
|
|
261
303
|
*/
|
|
262
|
-
export function resolveCanvasListing(query, locale = previewLocale(), perspective = 'published') {
|
|
263
|
-
const result = clientFor(locale, perspective).listDocuments(query.collection,
|
|
264
|
-
where: query.where,
|
|
265
|
-
...(query.sort ? { sort: query.sort } : {}),
|
|
266
|
-
...(query.limit !== undefined ? { limit: query.limit } : {}),
|
|
267
|
-
});
|
|
304
|
+
export function resolveCanvasListing(query, locale = previewLocale(), perspective = 'published', clock = systemClock) {
|
|
305
|
+
const result = clientFor(locale, perspective).listDocuments(query.collection, listDocumentsQueryOf(query, clock));
|
|
268
306
|
return result.ok ? result.documents : [];
|
|
269
307
|
}
|
|
270
308
|
/**
|
|
@@ -277,7 +315,7 @@ export function resolveCanvasListing(query, locale = previewLocale(), perspectiv
|
|
|
277
315
|
* session configured (boot instants, fixtures) there is no schema to judge
|
|
278
316
|
* against, so it reports nothing rather than false-flagging every listing.
|
|
279
317
|
*/
|
|
280
|
-
export function validateCanvasListingQuery(query) {
|
|
318
|
+
export function validateCanvasListingQuery(query, clock = systemClock) {
|
|
281
319
|
if (contentSession === null)
|
|
282
320
|
return [];
|
|
283
321
|
const collection = playgroundCollection(query.collection);
|
|
@@ -286,10 +324,13 @@ export function validateCanvasListingQuery(query) {
|
|
|
286
324
|
queryError('unknown-collection', `Collection "${query.collection}" is not defined.`, ['collection'], undefined, { key: 'content.queryError.unknownCollection', vars: { collection: query.collection } }),
|
|
287
325
|
];
|
|
288
326
|
}
|
|
327
|
+
// EC-581 6a: judge the request the query EXECUTES as (`now` bound), with the
|
|
328
|
+
// same three validators `listDocuments` runs — notice and execution agree.
|
|
329
|
+
const request = listDocumentsQueryOf(query, clock);
|
|
289
330
|
return [
|
|
290
|
-
...validateWhere(collection,
|
|
291
|
-
...(
|
|
292
|
-
...(
|
|
331
|
+
...(request.where ? validateWhere(collection, request.where) : []),
|
|
332
|
+
...(request.sort ? validateSort(collection, request.sort) : []),
|
|
333
|
+
...(request.limit !== undefined ? validateLimit(request.limit) : []),
|
|
293
334
|
];
|
|
294
335
|
}
|
|
295
336
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-content.js","sourceRoot":"","sources":["../../../src/lib/data/collection-content.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,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E,CACxF;SACF,CAAA;IACH,CAAC;IACD,OAAO;QACL,GAAG,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC;QACzC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACjE,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,GAAgB,EAChB,SAAiB,aAAa,EAAE,EAChC,cAAiC,WAAW;IAE5C,OAAO,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;AACxD,CAAC;AAQD,8EAA8E;AAC9E,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,MAAM,UAAU,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAA;IACrD,MAAM,MAAM,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAA;IACnD,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,CAAA;IACzB,2EAA2E;IAC3E,2EAA2E;IAC3E,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACpC,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;KAC3E,CAAC,CAAC,CAAA;AACL,CAAC","sourcesContent":["import {\n createContentClient,\n createContentContext,\n queryError,\n validateLimit,\n validateSort,\n validateWhere,\n} from '@elytracms/core/content'\nimport type {\n ContentClient,\n ContentDocumentSource,\n ContentLookup,\n ContentQueryError,\n GetDocumentResult,\n ListDocumentsQuery,\n ListDocumentsResult,\n ResolvedDocument,\n} from '@elytracms/core/content'\nimport { documentKey, resolveDocumentTitle } from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CollectionDef,\n DocumentRef,\n Locale,\n LocaleConfig,\n OrphanedCollection,\n RouteRecord,\n} from '@elytracms/core/cms-core'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport type { ListingQuery } from '@elytracms/core/runtime-renderer'\nimport { getStudioLocale, getStudioLocaleConfig } from '../locale/locale-store'\n\n/**\n * The studio's content delivery engine for canvas previews (EC-166).\n *\n * Repeating sections and template pages preview *delivery-shaped* documents —\n * the exact shape `@elytracms/core/content` serves in production — so the canvas\n * shows what publishing will show. This module wires the canonical content\n * client (closed AD-3 query vocabulary, published perspective, EC-018 locale\n * fallback, depth-1 population, resolved assets) over a **content session**:\n *\n * - Convex mode: the project-session gate (`components/studio/project-session`)\n * configures the session with the project's HYDRATED schema + documents, so\n * \"Preview with\" lists and section previews show the live content — never\n * fixture titles (EC-177 gap 1).\n * - Playground mode (EC-361): the SAME hydration loader runs over the seeded\n * in-memory adapter (through operations — AD-17), so canvas listing/relation\n * population resolves from the in-memory session documents with identical\n * semantics. With no session configured (tests, boot instants, no persisted\n * content) the engine serves nothing.\n *\n * Nothing here invents query semantics; both modes go through the same\n * canonical client.\n */\n\n/** The schema + documents the preview engine serves (one project session). */\nexport interface ContentSessionState {\n collections: readonly CollectionDef[]\n documents: readonly CmsDocument[]\n /**\n * Published document keys via the version POINTER (EC-224). When present, the\n * preview's published perspective resolves by the pin — never the flat\n * `state` enum — so it matches what delivery serves. Absent (playground\n * fixtures / tests) → the rows' own `state` gates the perspective, unchanged.\n */\n publishedKeys?: readonly string[]\n /**\n * Locale config of the session content — the project's own, composed by\n * `contentSessionOf` from `elytra.config.ts`. Absent (a kit session, tests) →\n * the ambient studio config, then the single locale being asked for; EC-479\n * retired the engine's `sampleLocaleConfig` fallback here.\n */\n localeConfig?: LocaleConfig\n /**\n * The project's config-sourced routes (EC-207). Wired into the content client so\n * the canvas preview's `resolveLink` (EC-291) derives a rich-text link's URL from\n * the SAME routes delivery serves — the studio-live half of the host link bake.\n * Absent (playground/tests) → no routes, so `resolveLink` returns null and a\n * reference link degrades to the visible `unresolved-ref` issue.\n */\n routes?: readonly RouteRecord[]\n /**\n * The project's asset records (assets table). Wired into the lookup so the\n * content client resolves `asset`-typed FIELDS on listing/relation results\n * (e.g. a ProductGrid product's `gallery`) to delivery shape — the same assets\n * the renderer's `resolveAsset` reads for static props (EC-262). Absent\n * (playground/tests) → assets come only from `asset`-collection fixture docs.\n */\n assets?: readonly AssetRecord[]\n /**\n * EC-606 — the stored rows the session does NOT serve: per undeclared collection,\n * how many rows and how many published (`HydratedCms.orphans`, carried here by\n * `contentSessionOf`'s spread). The preview engine never reads it. It rides this\n * session because this is the one hydrated-content channel that reaches the\n * section rail in both modes: the rail renders outside `ProjectSessionProvider`,\n * so it cannot read the project session context, and a second documents query\n * would be a parallel data flow (AD-17). Read via {@link contentSessionOrphans}.\n * Absent (a kit session, tests) → none.\n */\n orphans?: readonly OrphanedCollection[]\n}\n\n/**\n * Default (no-session) collection schema: EMPTY. The studio ships no demo content\n * (Oli, 2026-06-19) — with no backend/content session configured, there is nothing\n * to preview, and the studio says so rather than serving fixtures. A real project's\n * collections + documents arrive via {@link configureContentSession} in BOTH modes\n * (EC-361): Convex hydration, or the playground's seeded in-memory adapter through\n * the same loader.\n */\nexport const playgroundCollections: readonly CollectionDef[] = []\n\n/**\n * The perspective a canvas preview resolves references against (EC-300/AD-16). The\n * canvas is draft-coherent: the editable Draft view resolves references to their\n * `'draft'` targets (so a just-made reusable shows immediately), the read-only\n * Published view resolves `'published'` (an honest preview of what delivery serves;\n * an unpublished hard ref shows the in-canvas placeholder). Delivery stays\n * published-only — this does not weaken `live-is-published-only`.\n */\nexport type CanvasPerspective = 'draft' | 'published'\n\nlet contentSession: ContentSessionState | null = null\nlet lookup: ContentLookup = createLookup(playgroundCollections, [], [])\n// Keyed by locale + perspective (EC-300) + the resolved locale CONFIG (EC-479) —\n// one deterministic client per distinct resolution context. See `clientFor`.\nconst clients = new Map<string, ContentClient>()\n\n// EC-460: a monotonically increasing session epoch + listener set, so a REACT\n// surface (the canvas render context) can re-render when the session is\n// re-pointed at fresher content. The session itself stays a module global (the\n// EC-361 design); this only makes \"it changed\" observable — `configureContentSession`\n// remains the single setter.\nlet sessionEpoch = 0\nconst sessionListeners = new Set<() => void>()\n\n/** The current content-session epoch — bumps on every `configureContentSession`. */\nexport function contentSessionEpoch(): number {\n return sessionEpoch\n}\n\n/**\n * Subscribe to content-session swaps (EC-460). The listener fires after every\n * `configureContentSession`; returns the unsubscribe. Shaped for\n * `useSyncExternalStore(subscribeContentSession, contentSessionEpoch)`.\n */\nexport function subscribeContentSession(listener: () => void): () => void {\n sessionListeners.add(listener)\n return () => sessionListeners.delete(listener)\n}\n\n/**\n * Point the preview engine at a project's hydrated content — Convex hydration\n * or the playground's in-memory persisted state (EC-361), both through the same\n * `loadHydratedCms` loader — or back at the empty no-session default (`null`).\n */\nexport function configureContentSession(next: ContentSessionState | null): void {\n contentSession = next\n lookup = next\n ? createLookup(next.collections, next.documents, next.publishedKeys, next.assets)\n : createLookup(playgroundCollections, [], [])\n clients.clear()\n sessionEpoch += 1\n for (const listener of [...sessionListeners]) listener()\n}\n\n/** Whether a hydrated content session is configured (Convex mode). */\nexport function hasContentSession(): boolean {\n return contentSession !== null\n}\n\nconst NO_ORPHANS: readonly OrphanedCollection[] = []\n\n/**\n * The active session's orphaned collections (EC-606), or an empty list with no\n * session. Referentially stable between `configureContentSession` calls (the\n * session's own array, or one shared empty constant), so it is a valid\n * `useSyncExternalStore(subscribeContentSession, contentSessionOrphans, …)`\n * snapshot — the rail foot reads it exactly that way.\n */\nexport function contentSessionOrphans(): readonly OrphanedCollection[] {\n return contentSession?.orphans ?? NO_ORPHANS\n}\n\n/** The server snapshot for {@link contentSessionOrphans}: no session exists during SSR. */\nexport function serverContentSessionOrphans(): readonly OrphanedCollection[] {\n return NO_ORPHANS\n}\n\n/** The collections the preview engine currently serves (session or fixtures). */\nfunction activeCollections(): readonly CollectionDef[] {\n return contentSession?.collections ?? playgroundCollections\n}\n\n/**\n * The sentinel {@link previewLocale} yields when NOTHING has declared a locale —\n * no ambient studio config, no content session. It is not a locale code and\n * matches no stored key, which is the point: with no session the lookup is empty\n * (`playgroundCollections` is `[]`), so every query already resolves to nothing\n * and this only fills `CacheTags.locale`, which no studio surface reads. EC-479:\n * the engine used to answer this question with its `sampleLocaleConfig` fixture's\n * `en` — a locale nobody chose, standing in for the project's own.\n */\nconst NO_LOCALE = ''\n\n/**\n * The locale a canvas preview resolves in, when the caller names none: the\n * ambient studio locale (installed from the PROJECT's config by `CmsProvider`),\n * else the active content session's own declared default (surfaces that render\n * outside a CMS session — the Components view's previews — still resolve in the\n * project's locale), else {@link NO_LOCALE}. Never an engine fixture.\n */\nfunction previewLocale(): Locale {\n return getStudioLocale() ?? contentSession?.localeConfig?.default ?? NO_LOCALE\n}\n\n/**\n * The locale set a preview resolves fallbacks against (EC-018): the session's own\n * declaration, else the ambient studio config (the project's, via `elytra.config.ts`),\n * else the single locale actually being asked for.\n *\n * That last step is a DERIVATION, not an invention — it says \"the only locale we\n * know of is the one you named\", so `documentDefaultLocale` falls back to the\n * document's own `defaultLocale` and then to `doc.values`. Before EC-479 this line\n * read `?? sampleLocaleConfig`, which silently declared every locale-less studio\n * bilingual `en/de` and resolved fallbacks through an `en` no project had chosen.\n */\nfunction activeLocaleConfig(locale: Locale): LocaleConfig {\n return (\n contentSession?.localeConfig ??\n getStudioLocaleConfig() ?? { default: locale, locales: [locale] }\n )\n}\n\n/** Resolve a collection in the active content session (fixtures in playground). */\nexport function playgroundCollection(id: string): CollectionDef | undefined {\n return activeCollections().find((collection) => collection.id === id)\n}\n\n/**\n * Overlay the active session's canonical `filterable` declarations onto a\n * schema that doesn't carry any of its own. The inspector hands the Content\n * tab fixture collection defs; the filter/sort pickers must offer exactly the\n * EC-143 declaration set the delivery engine enforces, so both ends agree. A\n * collection that declares its own filterable fields is left untouched.\n */\nexport function withPlaygroundFilterable(\n collections: readonly CollectionDef[],\n): readonly CollectionDef[] {\n return collections.map((collection) => {\n if (collection.fields.some((field) => field.filterable === true)) return collection\n const counterpart = playgroundCollection(collection.id)\n if (counterpart === undefined) return collection\n const flagged = new Set(\n counterpart.fields.filter((field) => field.filterable === true).map((field) => field.name),\n )\n if (flagged.size === 0) return collection\n return {\n ...collection,\n fields: collection.fields.map((field) =>\n flagged.has(field.name) ? { ...field, filterable: true } : field,\n ),\n }\n })\n}\n\n/** Synthesize the persistence-shaped asset record the asset resolver reads. */\nfunction assetRecordOf(doc: CmsDocument): AssetRecord {\n const values = doc.values\n const alt = doc.localized?.en?.alt\n return {\n id: doc.id,\n projectId: 'playground',\n filename: typeof values.filename === 'string' ? values.filename : doc.id,\n contentType: 'image/png',\n byteSize: 0,\n alt: typeof alt === 'string' ? alt : undefined,\n storageKey: typeof values.url === 'string' ? values.url : doc.id,\n createdAt: '2026-01-01T00:00:00.000Z',\n updatedAt: '2026-01-01T00:00:00.000Z',\n }\n}\n\nfunction createLookup(\n collectionDefs: readonly CollectionDef[],\n documents: readonly CmsDocument[],\n publishedKeys?: readonly string[],\n assetRecords?: readonly AssetRecord[],\n): ContentLookup {\n const collections = new Map(collectionDefs.map((c) => [c.id, c]))\n // EC-224: published-ness is the version POINTER, not the flat `state` enum.\n // A hydrated session hands `publishedKeys` (the pinned set) → wrap each row as\n // a `DocumentHistory` so the published perspective resolves by the pin (the\n // live row is always a draft now) with ZERO dependence on `state`. Without a\n // pointer set (playground fixtures / tests) we keep bare rows, whose own\n // `state` gates the published perspective — byte-identical to before.\n const published = publishedKeys ? new Set(publishedKeys) : null\n const toSource = (doc: CmsDocument): ContentDocumentSource => {\n if (!published) return doc\n return published.has(documentKey({ collection: doc.collection, id: doc.id }))\n ? { draft: doc, published: doc, versions: [] }\n : { draft: doc, published: undefined, versions: [] }\n }\n const byKey = new Map(\n documents.map((doc) => [`${doc.collection}:${doc.id}`, toSource(doc)] as const),\n )\n // Asset resolution source for `asset`-typed FIELDS on resolved documents\n // (listing/relation results, e.g. a product's `gallery`). Two sources, real\n // records last so they win: (1) `asset`-collection fixture documents — how\n // playground/tests model assets; (2) the project's real asset-table records\n // (EC-262) — a Convex session has its assets here, NOT as `asset` documents,\n // so without these the content client resolves no nested image.\n const assets = new Map<string, AssetRecord>()\n for (const doc of documents) {\n if (doc.collection === 'asset') assets.set(doc.id, assetRecordOf(doc))\n }\n for (const record of assetRecords ?? []) assets.set(record.id, record)\n return {\n collection: (id) => collections.get(id),\n document: (ref) => byKey.get(`${ref.collection}:${ref.id}`),\n documents: (collectionId) =>\n documents.filter((doc) => doc.collection === collectionId).map(toSource),\n asset: (id) => assets.get(id),\n // Prefer the record's resolved servable `url` — the one the renderer's\n // resolveAsset reads (EC-262). Real asset-table records carry a Convex blob\n // locator in `storageKey` and the servable URL in `url`; fixture/`asset`-document\n // records (assetRecordOf) leave `url` unset and store the servable url in\n // `storageKey`. Falling back keeps both correct.\n assetUrl: (asset) => asset.url ?? asset.storageKey,\n }\n}\n\n/**\n * One deterministic client per (locale, perspective): EC-018 locale fallback,\n * draft-or-published perspective (EC-300/AD-16, default `'published'`). The studio's\n * ambient active locale (EC-176, `lib/locale`) picks the locale at query time, so the\n * canvas previews follow the locale switcher exactly like delivery would; the canvas's\n * Draft/Published view picks the perspective. The cache resets whenever the content\n * session changes.\n */\nfunction clientFor(locale: Locale, perspective: CanvasPerspective = 'published'): ContentClient {\n const locales = activeLocaleConfig(locale)\n // EC-479: the locale CONFIG is part of the client's identity now — it may come\n // from the ambient studio store, which changes independently of the session the\n // cache is cleared on, so keying by locale alone could serve a client built\n // against a superseded locale set.\n const key = `${locale}:${perspective}:${locales.default}|${locales.locales.join(',')}`\n const existing = clients.get(key)\n if (existing) return existing\n const client = createContentClient({\n lookup,\n context: createContentContext({\n locale,\n perspective,\n locales,\n }),\n // EC-291: the routes a rich-text link resolves against (config-sourced) — the\n // studio-live half of the host link bake.\n routes: contentSession?.routes ?? [],\n })\n clients.set(key, client)\n return client\n}\n\n/**\n * Run a closed-vocabulary list query (AD-3: eq/in/lt/lte/gt/gte, AND-only,\n * filterable fields only) and return the delivery-shaped result. Invalid\n * queries come back as structured errors — never thrown, never silently\n * widened. Resolves in the studio's active locale unless one is passed.\n */\nexport function runCollectionListQuery(\n collectionId: string,\n query: ListDocumentsQuery = {},\n locale: Locale = previewLocale(),\n): ListDocumentsResult {\n return clientFor(locale).listDocuments(collectionId, query)\n}\n\n/** Resolve one document (by id or slug) into delivery shape. */\nexport function getCollectionDocument(\n collectionId: string,\n idOrSlug: string,\n locale: Locale = previewLocale(),\n): GetDocumentResult {\n return clientFor(locale).getDocument(collectionId, idOrSlug)\n}\n\n/**\n * Populate a composition-node `relation` prop to delivery shape for the canvas\n * (EC-254) — the studio analog of the host's baked relations map. Resolves the\n * ref through the active session's client (published perspective, active locale),\n * so the canvas previews a block's picked documents (a ProductGrid's products, a\n * Reusable's element) exactly as delivery renders them. `null` when the target is\n * missing or not visible → the block degrades to its own empty state.\n */\nexport function resolveCanvasRelation(\n ref: DocumentRef,\n locale: Locale = previewLocale(),\n perspective: CanvasPerspective = 'published',\n): ResolvedDocument | null {\n return clientFor(locale, perspective).resolveRelation(ref)\n}\n\n/**\n * Resolve a listing block's query to its documents for the canvas (EC-255) — the\n * studio analog of the host's baked listings map. Runs the query (collection +\n * AND-only filter, optional sort/limit) through the active session's client\n * (published perspective, active locale), so the canvas previews a dynamic grid (a\n * ProductGrid keyed to a category) exactly as delivery renders it. An invalid query\n * (structured, never thrown) or a non-list lookup yields `[]` → the block's empty\n * state. Reuses the same `listDocuments` path as `runCollectionListQuery`.\n */\nexport function resolveCanvasListing(\n query: ListingQuery,\n locale: Locale = previewLocale(),\n perspective: CanvasPerspective = 'published',\n): ResolvedDocument[] {\n const result = clientFor(locale, perspective).listDocuments(query.collection, {\n where: query.where,\n ...(query.sort ? { sort: query.sort } : {}),\n ...(query.limit !== undefined ? { limit: query.limit } : {}),\n })\n return result.ok ? result.documents : []\n}\n\n/**\n * Statically validate a listing block's query against the ACTIVE session schema\n * (EC-460, the never-silent rule): the exact `validateWhere`/`validateSort`/\n * `validateLimit` checks `listDocuments` runs, WITHOUT executing the query — so\n * the canvas can surface a config-invalid listing (a filter/sort field the\n * collection doesn't declare `filterable`, an unknown collection) as a visible\n * notice instead of the block's indistinguishable empty state. With no content\n * session configured (boot instants, fixtures) there is no schema to judge\n * against, so it reports nothing rather than false-flagging every listing.\n */\nexport function validateCanvasListingQuery(query: ListingQuery): ContentQueryError[] {\n if (contentSession === null) return []\n const collection = playgroundCollection(query.collection)\n if (!collection) {\n return [\n queryError(\n 'unknown-collection',\n `Collection \"${query.collection}\" is not defined.`,\n ['collection'],\n undefined,\n { key: 'content.queryError.unknownCollection', vars: { collection: query.collection } },\n ),\n ]\n }\n return [\n ...validateWhere(collection, query.where),\n ...(query.sort ? validateSort(collection, query.sort) : []),\n ...(query.limit !== undefined ? validateLimit(query.limit) : []),\n ]\n}\n\n/**\n * Resolve a rich-text internal link's target document to its URL path for the canvas\n * (EC-291) — the studio analog of the host's baked links map. Derives the URL through\n * the active session's client (published perspective, active locale, config-sourced\n * routes), so the canvas previews a `{type:'reference'}` link's `href` exactly as\n * delivery serves it. `null` when the target is unpublished, missing, or addressed by\n * no route → the rich-text renderer shows the EC-290 `unresolved-ref` issue. Reuses\n * the same `resolveLink` path as the host bake, so both agree on the derived URL.\n */\nexport function resolveCanvasLink(\n ref: DocumentRef,\n locale: Locale = previewLocale(),\n perspective: CanvasPerspective = 'published',\n): string | null {\n return clientFor(locale, perspective).resolveLink(ref)\n}\n\n/** A pickable entry of a collection (the template-page preview switcher). */\nexport interface CollectionEntrySummary {\n id: string\n label: string\n}\n\n/** Published entries of a collection, labeled by the schema's title field. */\nexport function listCollectionEntries(collectionId: string): CollectionEntrySummary[] {\n const collection = playgroundCollection(collectionId)\n const result = runCollectionListQuery(collectionId)\n if (!result.ok) return []\n // EC-242: label via the shared identity resolver (string `titleField` or a\n // function pattern), over the delivery-shape values; falls back to the id.\n return result.documents.map((doc) => ({\n id: doc.id,\n label: collection ? resolveDocumentTitle(collection, doc, doc.id) : doc.id,\n }))\n}\n"]}
|
|
1
|
+
{"version":3,"file":"collection-content.js","sourceRoot":"","sources":["../../../src/lib/data/collection-content.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,GACd,MAAM,yBAAyB,CAAA;AAWhC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,GACf,MAAM,0BAA0B,CAAA;AAWjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAGnE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAwE/E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA6B,EAAE,CAAA;AAYjE,IAAI,cAAc,GAA+B,IAAI,CAAA;AACrD,IAAI,MAAM,GAAkB,YAAY,CAAC,qBAAqB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AACvE,iFAAiF;AACjF,6EAA6E;AAC7E,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;AAEhD,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,sFAAsF;AACtF,6BAA6B;AAC7B,IAAI,YAAY,GAAG,CAAC,CAAA;AACpB,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAc,CAAA;AAE9C,oFAAoF;AACpF,MAAM,UAAU,mBAAmB;IACjC,OAAO,YAAY,CAAA;AACrB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,QA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CAAC,CAAC;QACpC,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;KAC3E,CAAC,CAAC,CAAA;AACL,CAAC","sourcesContent":["import {\n createContentClient,\n createContentContext,\n queryError,\n validateLimit,\n validateSort,\n validateWhere,\n} from '@elytracms/core/content'\nimport type {\n ContentClient,\n ContentDocumentSource,\n ContentLookup,\n ContentQueryError,\n GetDocumentResult,\n ListDocumentsQuery,\n ListDocumentsResult,\n ResolvedDocument,\n} from '@elytracms/core/content'\nimport {\n documentKey,\n localeSchema,\n parseLocaleConfig,\n resolveDocumentTitle,\n valuesInLocale,\n} from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CollectionDef,\n DocumentRef,\n Locale,\n LocaleConfig,\n OrphanedCollection,\n RouteRecord,\n} from '@elytracms/core/cms-core'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport { listingRequestOf } from '@elytracms/core/runtime-renderer'\nimport type { ListingQuery } from '@elytracms/core/runtime-renderer'\nimport type { Clock } from '@elytracms/core/determinism'\nimport { getStudioLocale, getStudioLocaleConfig } from '../locale/locale-store'\n\n/**\n * The studio's content delivery engine for canvas previews (EC-166).\n *\n * Repeating sections and template pages preview *delivery-shaped* documents —\n * the exact shape `@elytracms/core/content` serves in production — so the canvas\n * shows what publishing will show. This module wires the canonical content\n * client (closed AD-3 query vocabulary, published perspective, EC-018 locale\n * fallback, depth-1 population, resolved assets) over a **content session**:\n *\n * - Convex mode: the project-session gate (`components/studio/project-session`)\n * configures the session with the project's HYDRATED schema + documents, so\n * \"Preview with\" lists and section previews show the live content — never\n * fixture titles (EC-177 gap 1).\n * - Playground mode (EC-361): the SAME hydration loader runs over the seeded\n * in-memory adapter (through operations — AD-17), so canvas listing/relation\n * population resolves from the in-memory session documents with identical\n * semantics. With no session configured (tests, boot instants, no persisted\n * content) the engine serves nothing.\n *\n * Nothing here invents query semantics; both modes go through the same\n * canonical client.\n */\n\n/** The schema + documents the preview engine serves (one project session). */\nexport interface ContentSessionState {\n collections: readonly CollectionDef[]\n documents: readonly CmsDocument[]\n /**\n * Published document keys via the version POINTER (EC-224). When present, the\n * preview's published perspective resolves by the pin — never the flat\n * `state` enum — so it matches what delivery serves. Absent (playground\n * fixtures / tests) → the rows' own `state` gates the perspective, unchanged.\n */\n publishedKeys?: readonly string[]\n /**\n * Locale config of the session content — the project's own, composed by\n * `contentSessionOf` from `elytra.config.ts`. Absent (a kit session, tests) →\n * the ambient studio config, then the single locale being asked for; EC-479\n * retired the engine's `sampleLocaleConfig` fallback here.\n */\n localeConfig?: LocaleConfig\n /**\n * The project's config-sourced routes (EC-207). Wired into the content client so\n * the canvas preview's `resolveLink` (EC-291) derives a rich-text link's URL from\n * the SAME routes delivery serves — the studio-live half of the host link bake.\n * Absent (playground/tests) → no routes, so `resolveLink` returns null and a\n * reference link degrades to the visible `unresolved-ref` issue.\n */\n routes?: readonly RouteRecord[]\n /**\n * The project's asset records (assets table). Wired into the lookup so the\n * content client resolves `asset`-typed FIELDS on listing/relation results\n * (e.g. a ProductGrid product's `gallery`) to delivery shape — the same assets\n * the renderer's `resolveAsset` reads for static props (EC-262). Absent\n * (playground/tests) → assets come only from `asset`-collection fixture docs.\n */\n assets?: readonly AssetRecord[]\n /**\n * EC-606 — the stored rows the session does NOT serve: per undeclared collection,\n * how many rows and how many published (`HydratedCms.orphans`, carried here by\n * `contentSessionOf`'s spread). The preview engine never reads it. It rides this\n * session because this is the one hydrated-content channel that reaches the\n * section rail in both modes: the rail renders outside `ProjectSessionProvider`,\n * so it cannot read the project session context, and a second documents query\n * would be a parallel data flow (AD-17). Read via {@link contentSessionOrphans}.\n * Absent (a kit session, tests) → none.\n */\n orphans?: readonly OrphanedCollection[]\n}\n\n/**\n * Default (no-session) collection schema: EMPTY. The studio ships no demo content\n * (Oli, 2026-06-19) — with no backend/content session configured, there is nothing\n * to preview, and the studio says so rather than serving fixtures. A real project's\n * collections + documents arrive via {@link configureContentSession} in BOTH modes\n * (EC-361): Convex hydration, or the playground's seeded in-memory adapter through\n * the same loader.\n */\nexport const playgroundCollections: readonly CollectionDef[] = []\n\n/**\n * The perspective a canvas preview resolves references against (EC-300/AD-16). The\n * canvas is draft-coherent: the editable Draft view resolves references to their\n * `'draft'` targets (so a just-made reusable shows immediately), the read-only\n * Published view resolves `'published'` (an honest preview of what delivery serves;\n * an unpublished hard ref shows the in-canvas placeholder). Delivery stays\n * published-only — this does not weaken `live-is-published-only`.\n */\nexport type CanvasPerspective = 'draft' | 'published'\n\nlet contentSession: ContentSessionState | null = null\nlet lookup: ContentLookup = createLookup(playgroundCollections, [], [])\n// Keyed by locale + perspective (EC-300) + the resolved locale CONFIG (EC-479) —\n// one deterministic client per distinct resolution context. See `clientFor`.\nconst clients = new Map<string, ContentClient>()\n\n// EC-460: a monotonically increasing session epoch + listener set, so a REACT\n// surface (the canvas render context) can re-render when the session is\n// re-pointed at fresher content. The session itself stays a module global (the\n// EC-361 design); this only makes \"it changed\" observable — `configureContentSession`\n// remains the single setter.\nlet sessionEpoch = 0\nconst sessionListeners = new Set<() => void>()\n\n/** The current content-session epoch — bumps on every `configureContentSession`. */\nexport function contentSessionEpoch(): number {\n return sessionEpoch\n}\n\n/**\n * Subscribe to content-session swaps (EC-460). The listener fires after every\n * `configureContentSession`; returns the unsubscribe. Shaped for\n * `useSyncExternalStore(subscribeContentSession, contentSessionEpoch)`.\n */\nexport function subscribeContentSession(listener: () => void): () => void {\n sessionListeners.add(listener)\n return () => sessionListeners.delete(listener)\n}\n\n/**\n * Point the preview engine at a project's hydrated content — Convex hydration\n * or the playground's in-memory persisted state (EC-361), both through the same\n * `loadHydratedCms` loader — or back at the empty no-session default (`null`).\n */\nexport function configureContentSession(next: ContentSessionState | null): void {\n contentSession = next\n lookup = next\n ? createLookup(next.collections, next.documents, next.publishedKeys, next.assets, next.localeConfig)\n : createLookup(playgroundCollections, [], [])\n clients.clear()\n sessionEpoch += 1\n for (const listener of [...sessionListeners]) listener()\n}\n\n/** Whether a hydrated content session is configured (Convex mode). */\nexport function hasContentSession(): boolean {\n return contentSession !== null\n}\n\nconst NO_ORPHANS: readonly OrphanedCollection[] = []\n\n/**\n * The active session's orphaned collections (EC-606), or an empty list with no\n * session. Referentially stable between `configureContentSession` calls (the\n * session's own array, or one shared empty constant), so it is a valid\n * `useSyncExternalStore(subscribeContentSession, contentSessionOrphans, …)`\n * snapshot — the rail foot reads it exactly that way.\n */\nexport function contentSessionOrphans(): readonly OrphanedCollection[] {\n return contentSession?.orphans ?? NO_ORPHANS\n}\n\n/** The server snapshot for {@link contentSessionOrphans}: no session exists during SSR. */\nexport function serverContentSessionOrphans(): readonly OrphanedCollection[] {\n return NO_ORPHANS\n}\n\n/** The collections the preview engine currently serves (session or fixtures). */\nfunction activeCollections(): readonly CollectionDef[] {\n return contentSession?.collections ?? playgroundCollections\n}\n\n/**\n * The sentinel {@link previewLocale} yields when NOTHING has declared a locale —\n * no ambient studio config, no content session. It is not a locale code and\n * matches no stored key, which is the point: with no session the lookup is empty\n * (`playgroundCollections` is `[]`), so every query already resolves to nothing\n * and this only fills `CacheTags.locale`, which no studio surface reads. EC-479:\n * the engine used to answer this question with its `sampleLocaleConfig` fixture's\n * `en` — a locale nobody chose, standing in for the project's own.\n */\nconst NO_LOCALE = ''\n\n/**\n * The locale a canvas preview resolves in, when the caller names none: the\n * ambient studio locale (installed from the PROJECT's config by `CmsProvider`),\n * else the active content session's own declared default (surfaces that render\n * outside a CMS session — the Components view's previews — still resolve in the\n * project's locale), else {@link NO_LOCALE}. Never an engine fixture.\n */\nfunction previewLocale(): Locale {\n return getStudioLocale() ?? contentSession?.localeConfig?.default ?? NO_LOCALE\n}\n\n/**\n * The locale set a preview resolves fallbacks against (EC-018): the session's own\n * declaration, else the ambient studio config (the project's, via `elytra.config.ts`),\n * else the single locale actually being asked for.\n *\n * That last step is a DERIVATION, not an invention — it says \"the only locale we\n * know of is the one you named\", so the default-locale fallback is the requested\n * locale itself (a no-op) and a localized read falls through to `doc.values`.\n * Before EC-479 this line read `?? sampleLocaleConfig`, which silently declared\n * every locale-less studio bilingual `en/de` and resolved fallbacks through an `en`\n * no project had chosen. Only reached with no session AND no installed config, so\n * no stored key is ever written against it.\n */\nfunction activeLocaleConfig(locale: Locale): LocaleConfig {\n return contentSession?.localeConfig ?? getStudioLocaleConfig() ?? requestedLocaleOnly(locale)\n}\n\n/**\n * The single-locale derivation above, through the one constructor (EC-580:\n * `LocaleConfig` is parse-only). {@link NO_LOCALE} — or anything else that is not\n * a locale code — becomes `und`, BCP 47's own \"undetermined\", which likewise\n * matches no stored key.\n */\nfunction requestedLocaleOnly(locale: Locale): LocaleConfig {\n const code = localeSchema.safeParse(locale).success ? locale : 'und'\n return parseLocaleConfig({ default: code, locales: [code] })\n}\n\n/** Resolve a collection in the active content session (fixtures in playground). */\nexport function playgroundCollection(id: string): CollectionDef | undefined {\n return activeCollections().find((collection) => collection.id === id)\n}\n\n/**\n * Overlay the active session's canonical `filterable` declarations onto a\n * schema that doesn't carry any of its own. The inspector hands the Content\n * tab fixture collection defs; the filter/sort pickers must offer exactly the\n * EC-143 declaration set the delivery engine enforces, so both ends agree. A\n * collection that declares its own filterable fields is left untouched.\n */\nexport function withPlaygroundFilterable(\n collections: readonly CollectionDef[],\n): readonly CollectionDef[] {\n return collections.map((collection) => {\n if (collection.fields.some((field) => field.filterable === true)) return collection\n const counterpart = playgroundCollection(collection.id)\n if (counterpart === undefined) return collection\n const flagged = new Set(\n counterpart.fields.filter((field) => field.filterable === true).map((field) => field.name),\n )\n if (flagged.size === 0) return collection\n return {\n ...collection,\n fields: collection.fields.map((field) =>\n flagged.has(field.name) ? { ...field, filterable: true } : field,\n ),\n }\n })\n}\n\n/**\n * Synthesize the persistence-shaped asset record the asset resolver reads. EC-580:\n * the record's single `alt` is the DEFAULT locale's displayed value\n * (`valuesInLocale`, the project's config default) — it used to read\n * `localized.en.alt` whatever the project's locales were (MODE F5b, \"further\n * evidence\"), so a `de`-default project's previews had no alt and a shared `alt`\n * was never read. Without a locale model (no session config) only the shared bag\n * can be read.\n */\nfunction assetRecordOf(\n doc: CmsDocument,\n collection: CollectionDef | undefined,\n locales: LocaleConfig | undefined,\n): AssetRecord {\n const values = doc.values\n const alt =\n collection && locales\n ? valuesInLocale(collection, doc, locales.default, locales).alt\n : values.alt\n return {\n id: doc.id,\n projectId: 'playground',\n filename: typeof values.filename === 'string' ? values.filename : doc.id,\n contentType: 'image/png',\n byteSize: 0,\n alt: typeof alt === 'string' ? alt : undefined,\n storageKey: typeof values.url === 'string' ? values.url : doc.id,\n createdAt: '2026-01-01T00:00:00.000Z',\n updatedAt: '2026-01-01T00:00:00.000Z',\n }\n}\n\nfunction createLookup(\n collectionDefs: readonly CollectionDef[],\n documents: readonly CmsDocument[],\n publishedKeys?: readonly string[],\n assetRecords?: readonly AssetRecord[],\n locales?: LocaleConfig,\n): ContentLookup {\n const collections = new Map(collectionDefs.map((c) => [c.id, c]))\n // EC-224: published-ness is the version POINTER, not the flat `state` enum.\n // A hydrated session hands `publishedKeys` (the pinned set) → wrap each row as\n // a `DocumentHistory` so the published perspective resolves by the pin (the\n // live row is always a draft now) with ZERO dependence on `state`. Without a\n // pointer set (playground fixtures / tests) we keep bare rows, whose own\n // `state` gates the published perspective — byte-identical to before.\n const published = publishedKeys ? new Set(publishedKeys) : null\n const toSource = (doc: CmsDocument): ContentDocumentSource => {\n if (!published) return doc\n return published.has(documentKey({ collection: doc.collection, id: doc.id }))\n ? { draft: doc, published: doc, versions: [] }\n : { draft: doc, published: undefined, versions: [] }\n }\n const byKey = new Map(\n documents.map((doc) => [`${doc.collection}:${doc.id}`, toSource(doc)] as const),\n )\n // Asset resolution source for `asset`-typed FIELDS on resolved documents\n // (listing/relation results, e.g. a product's `gallery`). Two sources, real\n // records last so they win: (1) `asset`-collection fixture documents — how\n // playground/tests model assets; (2) the project's real asset-table records\n // (EC-262) — a Convex session has its assets here, NOT as `asset` documents,\n // so without these the content client resolves no nested image.\n const assets = new Map<string, AssetRecord>()\n for (const doc of documents) {\n if (doc.collection === 'asset') {\n assets.set(doc.id, assetRecordOf(doc, collections.get(doc.collection), locales))\n }\n }\n for (const record of assetRecords ?? []) assets.set(record.id, record)\n return {\n collection: (id) => collections.get(id),\n document: (ref) => byKey.get(`${ref.collection}:${ref.id}`),\n documents: (collectionId) =>\n documents.filter((doc) => doc.collection === collectionId).map(toSource),\n asset: (id) => assets.get(id),\n // Prefer the record's resolved servable `url` — the one the renderer's\n // resolveAsset reads (EC-262). Real asset-table records carry a Convex blob\n // locator in `storageKey` and the servable URL in `url`; fixture/`asset`-document\n // records (assetRecordOf) leave `url` unset and store the servable url in\n // `storageKey`. Falling back keeps both correct.\n assetUrl: (asset) => asset.url ?? asset.storageKey,\n }\n}\n\n/**\n * One deterministic client per (locale, perspective): EC-018 locale fallback,\n * draft-or-published perspective (EC-300/AD-16, default `'published'`). The studio's\n * ambient active locale (EC-176, `lib/locale`) picks the locale at query time, so the\n * canvas previews follow the locale switcher exactly like delivery would; the canvas's\n * Draft/Published view picks the perspective. The cache resets whenever the content\n * session changes.\n */\nfunction clientFor(locale: Locale, perspective: CanvasPerspective = 'published'): ContentClient {\n const locales = activeLocaleConfig(locale)\n // EC-479: the locale CONFIG is part of the client's identity now — it may come\n // from the ambient studio store, which changes independently of the session the\n // cache is cleared on, so keying by locale alone could serve a client built\n // against a superseded locale set.\n const key = `${locale}:${perspective}:${locales.default}|${locales.locales.join(',')}`\n const existing = clients.get(key)\n if (existing) return existing\n const client = createContentClient({\n lookup,\n context: createContentContext({\n locale,\n perspective,\n locales,\n }),\n // EC-291: the routes a rich-text link resolves against (config-sourced) — the\n // studio-live half of the host link bake.\n routes: contentSession?.routes ?? [],\n })\n clients.set(key, client)\n return client\n}\n\n/**\n * Run a closed-vocabulary list query (AD-3: eq/in/lt/lte/gt/gte, AND-only,\n * filterable fields only) and return the delivery-shaped result. Invalid\n * queries come back as structured errors — never thrown, never silently\n * widened. Resolves in the studio's active locale unless one is passed.\n */\nexport function runCollectionListQuery(\n collectionId: string,\n query: ListDocumentsQuery = {},\n locale: Locale = previewLocale(),\n): ListDocumentsResult {\n return clientFor(locale).listDocuments(collectionId, query)\n}\n\n/** Resolve one document (by id or slug) into delivery shape. */\nexport function getCollectionDocument(\n collectionId: string,\n idOrSlug: string,\n locale: Locale = previewLocale(),\n): GetDocumentResult {\n return clientFor(locale).getDocument(collectionId, idOrSlug)\n}\n\n/**\n * Populate a composition-node `relation` prop to delivery shape for the canvas\n * (EC-254) — the studio analog of the host's baked relations map. Resolves the\n * ref through the active session's client (published perspective, active locale),\n * so the canvas previews a block's picked documents (a ProductGrid's products, a\n * Reusable's element) exactly as delivery renders them. `null` when the target is\n * missing or not visible → the block degrades to its own empty state.\n */\nexport function resolveCanvasRelation(\n ref: DocumentRef,\n locale: Locale = previewLocale(),\n perspective: CanvasPerspective = 'published',\n): ResolvedDocument | null {\n return clientFor(locale, perspective).resolveRelation(ref)\n}\n\n/** The real clock — the canvas boundary's default; tests inject a fixed one (EC-581 6a). */\nconst systemClock: Clock = () => new Date().toISOString()\n\n/**\n * A listing query as `listDocuments` input (EC-581 6a): executed through\n * `listingRequestOf` — the phase the delivery host runs too, so canvas and site\n * build the identical request — with `{ now: true }` read from `clock`. The\n * operands are JSON bound from authored props; the cast hands them to the one\n * validator (`validateWhere`/`validateLimit`), which reports anything invalid.\n */\nfunction listDocumentsQueryOf(query: ListingQuery, clock: Clock): ListDocumentsQuery {\n const request = listingRequestOf(query, clock)\n return {\n where: request.where as ListDocumentsQuery['where'],\n ...(request.sort ? { sort: request.sort } : {}),\n ...(request.limit !== undefined ? { limit: request.limit as number } : {}),\n }\n}\n\n/**\n * Resolve a listing block's query to its documents for the canvas (EC-255) — the\n * studio analog of the host's baked listings map. Runs the query (collection +\n * AND-only `where`, optional sort/limit; EC-581 6a: `now` read from `clock`)\n * through the active session's client (published perspective, active locale), so\n * the canvas previews a dynamic grid (a ProductGrid keyed to a category) exactly as\n * delivery renders it. An invalid query (structured, never thrown) or a non-list\n * lookup yields `[]` → the block's empty state, and the canvas notice\n * ({@link validateCanvasListingQuery}) says why. Reuses the same `listDocuments`\n * path as `runCollectionListQuery`.\n */\nexport function resolveCanvasListing(\n query: ListingQuery,\n locale: Locale = previewLocale(),\n perspective: CanvasPerspective = 'published',\n clock: Clock = systemClock,\n): ResolvedDocument[] {\n const result = clientFor(locale, perspective).listDocuments(\n query.collection,\n listDocumentsQueryOf(query, clock),\n )\n return result.ok ? result.documents : []\n}\n\n/**\n * Statically validate a listing block's query against the ACTIVE session schema\n * (EC-460, the never-silent rule): the exact `validateWhere`/`validateSort`/\n * `validateLimit` checks `listDocuments` runs, WITHOUT executing the query — so\n * the canvas can surface a config-invalid listing (a filter/sort field the\n * collection doesn't declare `filterable`, an unknown collection) as a visible\n * notice instead of the block's indistinguishable empty state. With no content\n * session configured (boot instants, fixtures) there is no schema to judge\n * against, so it reports nothing rather than false-flagging every listing.\n */\nexport function validateCanvasListingQuery(\n query: ListingQuery,\n clock: Clock = systemClock,\n): ContentQueryError[] {\n if (contentSession === null) return []\n const collection = playgroundCollection(query.collection)\n if (!collection) {\n return [\n queryError(\n 'unknown-collection',\n `Collection \"${query.collection}\" is not defined.`,\n ['collection'],\n undefined,\n { key: 'content.queryError.unknownCollection', vars: { collection: query.collection } },\n ),\n ]\n }\n // EC-581 6a: judge the request the query EXECUTES as (`now` bound), with the\n // same three validators `listDocuments` runs — notice and execution agree.\n const request = listDocumentsQueryOf(query, clock)\n return [\n ...(request.where ? validateWhere(collection, request.where) : []),\n ...(request.sort ? validateSort(collection, request.sort) : []),\n ...(request.limit !== undefined ? validateLimit(request.limit) : []),\n ]\n}\n\n/**\n * Resolve a rich-text internal link's target document to its URL path for the canvas\n * (EC-291) — the studio analog of the host's baked links map. Derives the URL through\n * the active session's client (published perspective, active locale, config-sourced\n * routes), so the canvas previews a `{type:'reference'}` link's `href` exactly as\n * delivery serves it. `null` when the target is unpublished, missing, or addressed by\n * no route → the rich-text renderer shows the EC-290 `unresolved-ref` issue. Reuses\n * the same `resolveLink` path as the host bake, so both agree on the derived URL.\n */\nexport function resolveCanvasLink(\n ref: DocumentRef,\n locale: Locale = previewLocale(),\n perspective: CanvasPerspective = 'published',\n): string | null {\n return clientFor(locale, perspective).resolveLink(ref)\n}\n\n/** A pickable entry of a collection (the template-page preview switcher). */\nexport interface CollectionEntrySummary {\n id: string\n label: string\n}\n\n/** Published entries of a collection, labeled by the schema's title field. */\nexport function listCollectionEntries(collectionId: string): CollectionEntrySummary[] {\n const collection = playgroundCollection(collectionId)\n const result = runCollectionListQuery(collectionId)\n if (!result.ok) return []\n // EC-242: label via the shared identity resolver (string `titleField` or a\n // function pattern), over the delivery-shape values; falls back to the id.\n return result.documents.map((doc) => ({\n id: doc.id,\n label: collection ? resolveDocumentTitle(collection, doc, doc.id) : doc.id,\n }))\n}\n"]}
|
|
@@ -11,9 +11,6 @@ import type { DeliveryConfigStatus } from '@elytracms/core/persistence';
|
|
|
11
11
|
export type { DeliveryConfigStatus };
|
|
12
12
|
/** The pipeline env vars, in setup order, paired with the status key each maps to. */
|
|
13
13
|
export declare const INSTANT_PUBLISH_VARS: readonly [{
|
|
14
|
-
readonly key: "projectScope";
|
|
15
|
-
readonly env: "CANVAS_PROJECT_SCOPE";
|
|
16
|
-
}, {
|
|
17
14
|
readonly key: "revalidateEndpoint";
|
|
18
15
|
readonly env: "CANVAS_REVALIDATE_ENDPOINT";
|
|
19
16
|
}, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** The pipeline env vars, in setup order, paired with the status key each maps to. */
|
|
2
2
|
export const INSTANT_PUBLISH_VARS = [
|
|
3
|
-
{ key: 'projectScope', env: 'CANVAS_PROJECT_SCOPE' },
|
|
4
3
|
{ key: 'revalidateEndpoint', env: 'CANVAS_REVALIDATE_ENDPOINT' },
|
|
5
4
|
{ key: 'revalidateSecret', env: 'CANVAS_REVALIDATE_SECRET' },
|
|
6
5
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instant-publish.js","sourceRoot":"","sources":["../../../src/lib/delivery/instant-publish.ts"],"names":[],"mappings":"AAYA,sFAAsF;AACtF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"instant-publish.js","sourceRoot":"","sources":["../../../src/lib/delivery/instant-publish.ts"],"names":[],"mappings":"AAYA,sFAAsF;AACtF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,EAAE,GAAG,EAAE,oBAAoB,EAAE,GAAG,EAAE,4BAA4B,EAAE;IAChE,EAAE,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,0BAA0B,EAAE;CACsB,CAAA;AAEpF,qFAAqF;AACrF,MAAM,UAAU,yBAAyB,CAAC,MAA4B;IACpE,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAC7F,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,0BAA0B,CAAC,MAA4B;IACrE,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;AACvD,CAAC","sourcesContent":["/**\n * EC-268: instant-publish (EC-146) configuration health, studio-side. Reads\n * through `operations.delivery.config` (EC-329 — the operations seam, not a\n * raw Convex client) to `PersistenceAdapter.delivery`, reporting whether each\n * delivery env var is set (booleans only — never the values); these helpers\n * turn that into the list the health banner shows. Kept pure + React-free so\n * it is unit-testable and reusable (a future `elytra doctor`, EC-259, can\n * format the same status).\n */\nimport type { DeliveryConfigStatus } from '@elytracms/core/persistence'\nexport type { DeliveryConfigStatus }\n\n/** The pipeline env vars, in setup order, paired with the status key each maps to. */\nexport const INSTANT_PUBLISH_VARS = [\n { key: 'revalidateEndpoint', env: 'CANVAS_REVALIDATE_ENDPOINT' },\n { key: 'revalidateSecret', env: 'CANVAS_REVALIDATE_SECRET' },\n] as const satisfies ReadonlyArray<{ key: keyof DeliveryConfigStatus; env: string }>\n\n/** The env var names that are NOT set, in setup order (empty = fully configured). */\nexport function missingInstantPublishVars(status: DeliveryConfigStatus): string[] {\n return INSTANT_PUBLISH_VARS.filter((entry) => !status[entry.key]).map((entry) => entry.env)\n}\n\n/** True when every instant-publish env var is set. */\nexport function isInstantPublishConfigured(status: DeliveryConfigStatus): boolean {\n return missingInstantPublishVars(status).length === 0\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentNode, GridContainerOptions, InsertTarget } from '@elytracms/core/project-graph';
|
|
1
|
+
import type { ComponentNode, GridContainerOptions, InsertTarget, LayoutContainerIds } from '@elytracms/core/project-graph';
|
|
2
2
|
import type { ComponentManifest } from '@elytracms/core/component-registry';
|
|
3
3
|
/**
|
|
4
4
|
* Drag & drop eligibility rules (EC-160 + EC-162, vision §3.1) — pure
|
|
@@ -11,7 +11,8 @@ import type { ComponentManifest } from '@elytracms/core/component-registry';
|
|
|
11
11
|
* The drop-zone model is position-based: `into` a slot, `before`/`after` a
|
|
12
12
|
* sibling along the parent's flow axis, and the EC-162 gesture positions
|
|
13
13
|
* `left`/`right` — dropping *beside* an element wraps both in a two-column
|
|
14
|
-
* `Grid` container (see `applyWrap`)
|
|
14
|
+
* `Grid` container (see `applyWrap`) — the component that fills the
|
|
15
|
+
* `layout.grid` role (EC-591); with no such component the gesture is off.
|
|
15
16
|
*/
|
|
16
17
|
/**
|
|
17
18
|
* The manifest slice the rules evaluate. Structural (not the full
|
|
@@ -83,7 +84,13 @@ export type DropRejectionCode =
|
|
|
83
84
|
/** The page root cannot be moved, and nothing can drop beside it. */
|
|
84
85
|
| 'root'
|
|
85
86
|
/** Structurally valid but changes nothing (dropping a node onto its own position). */
|
|
86
|
-
| 'no-op'
|
|
87
|
+
| 'no-op'
|
|
88
|
+
/**
|
|
89
|
+
* EC-591: the wrap-beside gesture needs the component that fills the
|
|
90
|
+
* `layout.grid` role, and the project's component list has none — the gesture
|
|
91
|
+
* is off (the canvas's role notice says so), never a hardcoded fallback id.
|
|
92
|
+
*/
|
|
93
|
+
| 'no-grid';
|
|
87
94
|
export interface DropRejection {
|
|
88
95
|
eligible: false;
|
|
89
96
|
code: DropRejectionCode;
|
|
@@ -136,9 +143,9 @@ export declare function slotAllows(slot: SlotRule | undefined, componentId: stri
|
|
|
136
143
|
* composition root, mirroring `validateCompositionValue` — so this returns the
|
|
137
144
|
* field vocabulary when `parentId` IS the root node and `undefined` (no field
|
|
138
145
|
* constraint) anywhere deeper. Keyed on node IDENTITY, never on the component id:
|
|
139
|
-
* the composition editor's synthetic root is
|
|
140
|
-
* nestable block, and a rule keyed on the component id would leash
|
|
141
|
-
* Stack. EC-544: an omitted `allow` is `undefined` here (any registered
|
|
146
|
+
* the composition editor's synthetic root is the `layout.stack` component, which
|
|
147
|
+
* is also a nestable block, and a rule keyed on the component id would leash
|
|
148
|
+
* every nested Stack. EC-544: an omitted `allow` is `undefined` here (any registered
|
|
142
149
|
* component); a declared list is a closed set.
|
|
143
150
|
*/
|
|
144
151
|
export declare function fieldAllowAt(root: ComponentNode, parentId: string, fieldAllow: readonly string[] | undefined): readonly string[] | undefined;
|
|
@@ -165,6 +172,12 @@ export declare function placementRefusal(args: {
|
|
|
165
172
|
export declare function resolveDrop(args: {
|
|
166
173
|
root: ComponentNode;
|
|
167
174
|
getManifest: ManifestLookup;
|
|
175
|
+
/**
|
|
176
|
+
* The components filling the layout roles (EC-591, `ComponentRegistry.layout`) —
|
|
177
|
+
* the wrap gesture builds the `layout.grid` one, and is OFF when nobody fills it.
|
|
178
|
+
* Required so no surface can forget it.
|
|
179
|
+
*/
|
|
180
|
+
layout: LayoutContainerIds;
|
|
168
181
|
/**
|
|
169
182
|
* The composition field's top-level `allow` (EC-554) — `undefined` when the
|
|
170
183
|
* field declares none. Required so no surface can forget to pass it; judged
|
|
@@ -213,6 +226,8 @@ export interface WrapResult {
|
|
|
213
226
|
*/
|
|
214
227
|
export declare function applyWrap(args: {
|
|
215
228
|
root: ComponentNode;
|
|
229
|
+
/** The `layout.grid` component's id (EC-591) — the container the gesture builds. */
|
|
230
|
+
gridComponentId: string;
|
|
216
231
|
referenceId: string;
|
|
217
232
|
side: WrapSide;
|
|
218
233
|
partner: WrapPartner;
|
|
@@ -228,7 +243,7 @@ export type FlowAxis = 'vertical' | 'horizontal';
|
|
|
228
243
|
* horizontally when it actually has ≥ 2 column tracks (an absent/invalid
|
|
229
244
|
* `columns` renders one column). Everything else is block flow (vertical).
|
|
230
245
|
*/
|
|
231
|
-
export declare function containerFlowAxis(node: ComponentNode | undefined): FlowAxis;
|
|
246
|
+
export declare function containerFlowAxis(node: ComponentNode | undefined, layout: LayoutContainerIds): FlowAxis;
|
|
232
247
|
/**
|
|
233
248
|
* Map a 2D pointer offset within a drop target's box onto a `DropPosition`
|
|
234
249
|
* (EC-162). `flow` is the flow axis of the target's *parent* — before/after
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_SLOT,
|
|
1
|
+
import { DEFAULT_SLOT, OUTLET_SLOT, getNode, getParentInfo, gridContainerNode, isDescendantOf, isStaticProp, layoutContainerKind, removeNode, updateNode, } from '@elytracms/core/project-graph';
|
|
2
2
|
import { manifestSlots } from '@elytracms/core/component-registry';
|
|
3
3
|
/**
|
|
4
4
|
* The canonical `ManifestRules` view of a full manifest (EC-386): the declared
|
|
@@ -59,9 +59,9 @@ export function slotAllows(slot, componentId) {
|
|
|
59
59
|
* composition root, mirroring `validateCompositionValue` — so this returns the
|
|
60
60
|
* field vocabulary when `parentId` IS the root node and `undefined` (no field
|
|
61
61
|
* constraint) anywhere deeper. Keyed on node IDENTITY, never on the component id:
|
|
62
|
-
* the composition editor's synthetic root is
|
|
63
|
-
* nestable block, and a rule keyed on the component id would leash
|
|
64
|
-
* Stack. EC-544: an omitted `allow` is `undefined` here (any registered
|
|
62
|
+
* the composition editor's synthetic root is the `layout.stack` component, which
|
|
63
|
+
* is also a nestable block, and a rule keyed on the component id would leash
|
|
64
|
+
* every nested Stack. EC-544: an omitted `allow` is `undefined` here (any registered
|
|
65
65
|
* component); a declared list is a closed set.
|
|
66
66
|
*/
|
|
67
67
|
export function fieldAllowAt(root, parentId, fieldAllow) {
|
|
@@ -91,7 +91,7 @@ export function placementRefusal(args) {
|
|
|
91
91
|
* same answer, on both surfaces.
|
|
92
92
|
*/
|
|
93
93
|
export function resolveDrop(args) {
|
|
94
|
-
const { root, getManifest, fieldAllow, subject, location } = args;
|
|
94
|
+
const { root, getManifest, layout, fieldAllow, subject, location } = args;
|
|
95
95
|
if (subject.kind === 'node' && subject.nodeId === root.id) {
|
|
96
96
|
return rejected('root', 'The page root cannot be moved.');
|
|
97
97
|
}
|
|
@@ -101,7 +101,7 @@ export function resolveDrop(args) {
|
|
|
101
101
|
}
|
|
102
102
|
// EC-162: dropping beside the reference wraps both in a two-column Grid.
|
|
103
103
|
if (location.position === 'left' || location.position === 'right') {
|
|
104
|
-
return resolveWrap({ root, getManifest, fieldAllow, subject, reference, side: location.position });
|
|
104
|
+
return resolveWrap({ root, getManifest, layout, fieldAllow, subject, reference, side: location.position });
|
|
105
105
|
}
|
|
106
106
|
// Resolve the concrete insertion point: parent node, slot, index.
|
|
107
107
|
let parentId;
|
|
@@ -172,7 +172,13 @@ export function resolveDrop(args) {
|
|
|
172
172
|
export const WRAP_GRID_OPTIONS = { columns: 2, gap: '4' };
|
|
173
173
|
/** Eligibility for a `left`/`right` (wrap-beside) drop. */
|
|
174
174
|
function resolveWrap(args) {
|
|
175
|
-
const { root, getManifest, fieldAllow, subject, reference, side } = args;
|
|
175
|
+
const { root, getManifest, layout, fieldAllow, subject, reference, side } = args;
|
|
176
|
+
// EC-591: the gesture builds the `layout.grid` component — a role nobody fills
|
|
177
|
+
// switches it off (the canvas shows the role notice), never a hidden default id.
|
|
178
|
+
const gridId = layout.grid;
|
|
179
|
+
if (gridId === undefined) {
|
|
180
|
+
return rejected('no-grid', 'No component fills the layout.grid role — side-by-side columns are unavailable.');
|
|
181
|
+
}
|
|
176
182
|
// The Grid takes the reference's place in its parent slot — so the
|
|
177
183
|
// reference needs a parent (the root is the page anchor, never wrapped)
|
|
178
184
|
// and that slot's allow-list must accept a Grid. EC-554: beside a direct
|
|
@@ -188,7 +194,7 @@ function resolveWrap(args) {
|
|
|
188
194
|
parentId: info.parent.id,
|
|
189
195
|
slot: parentSlotRule,
|
|
190
196
|
fieldAllow,
|
|
191
|
-
componentId:
|
|
197
|
+
componentId: gridId,
|
|
192
198
|
});
|
|
193
199
|
if (refusal === 'field') {
|
|
194
200
|
return rejected('field-not-allowed', "The field's top-level vocabulary does not allow a Grid container.");
|
|
@@ -197,7 +203,7 @@ function resolveWrap(args) {
|
|
|
197
203
|
return rejected('not-allowed', `Slot "${info.slot}" does not allow a Grid container.`);
|
|
198
204
|
}
|
|
199
205
|
// Both columns land in the Grid's children slot.
|
|
200
|
-
const gridSlot = primaryInsertSlot(getManifest(
|
|
206
|
+
const gridSlot = primaryInsertSlot(getManifest(gridId));
|
|
201
207
|
for (const componentId of [reference.componentId, subject.componentId]) {
|
|
202
208
|
if (!slotAllows(gridSlot, componentId)) {
|
|
203
209
|
return rejected('not-allowed', `A Grid container does not allow "${componentId}".`);
|
|
@@ -230,7 +236,7 @@ function resolveWrap(args) {
|
|
|
230
236
|
* `gridContainerNode` constructor output — identical to manual composition.
|
|
231
237
|
*/
|
|
232
238
|
export function applyWrap(args) {
|
|
233
|
-
const { root, referenceId, side, partner, containerId } = args;
|
|
239
|
+
const { root, gridComponentId, referenceId, side, partner, containerId } = args;
|
|
234
240
|
if (referenceId === root.id || !getNode(root, referenceId))
|
|
235
241
|
return null;
|
|
236
242
|
let working = root;
|
|
@@ -247,7 +253,7 @@ export function applyWrap(args) {
|
|
|
247
253
|
else {
|
|
248
254
|
partnerNode = partner.node;
|
|
249
255
|
}
|
|
250
|
-
const next = updateNode(working, referenceId, (reference) => gridContainerNode(containerId, WRAP_GRID_OPTIONS, side === 'left' ? [partnerNode, reference] : [reference, partnerNode]));
|
|
256
|
+
const next = updateNode(working, referenceId, (reference) => gridContainerNode(gridComponentId, containerId, WRAP_GRID_OPTIONS, side === 'left' ? [partnerNode, reference] : [reference, partnerNode]));
|
|
251
257
|
return { root: next, containerId };
|
|
252
258
|
}
|
|
253
259
|
function staticPropValue(node, name) {
|
|
@@ -262,13 +268,14 @@ function staticPropValue(node, name) {
|
|
|
262
268
|
* horizontally when it actually has ≥ 2 column tracks (an absent/invalid
|
|
263
269
|
* `columns` renders one column). Everything else is block flow (vertical).
|
|
264
270
|
*/
|
|
265
|
-
export function containerFlowAxis(node) {
|
|
271
|
+
export function containerFlowAxis(node, layout) {
|
|
266
272
|
if (!node)
|
|
267
273
|
return 'vertical';
|
|
268
|
-
|
|
274
|
+
const kind = layoutContainerKind(node.componentId, layout);
|
|
275
|
+
if (kind === 'stack') {
|
|
269
276
|
return staticPropValue(node, 'direction') === 'horizontal' ? 'horizontal' : 'vertical';
|
|
270
277
|
}
|
|
271
|
-
if (
|
|
278
|
+
if (kind === 'grid') {
|
|
272
279
|
const columns = staticPropValue(node, 'columns');
|
|
273
280
|
return typeof columns === 'number' && columns >= 2 ? 'horizontal' : 'vertical';
|
|
274
281
|
}
|