@elytracms/next 0.0.95 → 0.0.97
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/dist/index.d.ts +13 -0
- package/dist/index.js +47 -15
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -301,6 +301,13 @@ interface StaticContentData {
|
|
|
301
301
|
routes?: readonly RouteRecord[];
|
|
302
302
|
/** Redirect records served by `resolvePage` (EC-019/020). */
|
|
303
303
|
redirects?: readonly RedirectRecord[];
|
|
304
|
+
/**
|
|
305
|
+
* The project's collection definitions (every host path hands the resolved config's). They
|
|
306
|
+
* are also the asset metadata's lens (EC-659): the asset collection's `localized` fields
|
|
307
|
+
* are the only ones a stored per-locale value is read for. ABSENT means no schema — no
|
|
308
|
+
* field is localized, so every stored translation is drift: never applied (the shared
|
|
309
|
+
* value is served), each one named on `sourceIssues`.
|
|
310
|
+
*/
|
|
304
311
|
collections?: readonly CollectionDef[];
|
|
305
312
|
/**
|
|
306
313
|
* Stored document sources. Either a bare `CmsDocument` (gated by its own
|
|
@@ -2007,6 +2014,12 @@ interface DeliverySnapshotPayload {
|
|
|
2007
2014
|
*/
|
|
2008
2015
|
redirectIssues?: unknown[];
|
|
2009
2016
|
documents: unknown[];
|
|
2017
|
+
/**
|
|
2018
|
+
* EC-670 — the stored documents the deployment withheld because it could not unfold them
|
|
2019
|
+
* (`invalid-stored-document` issues: a folded value whose payload does not parse). Absent
|
|
2020
|
+
* from a deployment older than EC-670, whose snapshot rejected altogether instead.
|
|
2021
|
+
*/
|
|
2022
|
+
documentIssues?: unknown[];
|
|
2010
2023
|
assets: unknown[];
|
|
2011
2024
|
}
|
|
2012
2025
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { registerComponents, createRenderContext, renderDocumentBodyItems, documentBodyItems, serializeListingQuery, documentBodyRichTextValues, documentBodyCompositionNodes, richTextEmbedsInValue, collectReferencedAssetIds, collectRichTextRefsInValue, collectReferencedRelations, collectReferencedListings, collectReferencedRichTextLinks, listingRequestOf } from '@elytracms/core/runtime-renderer';
|
|
2
2
|
import { isBlockSequenceValueShape } from '@elytracms/core/rich-text';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
import { cacheTags, isDocumentHistory, assetWithoutUrlIssue, resolvedAsset, parseDeliveredDocuments, parseDeliveredRedirects, createContentClient, createContentContext } from '@elytracms/core/content';
|
|
5
|
-
import { DEFAULT_SEO_FIELD, parseLocaleConfig, documentKey, readLiveRedirects, SEO_SUBFIELDS, splitLocalePath, DRAFT_PERSPECTIVE, splitPath, localeUrlPath, variantOf, DRAFT_VARIANT, createRouter, presentationBodyFields } from '@elytracms/core/cms-core';
|
|
4
|
+
import { cacheTags, isDocumentHistory, assetWithoutUrlIssue, assetMetaDriftIssue, resolvedAsset, parseDeliveredDocuments, parseDeliveredRedirects, createContentClient, createContentContext } from '@elytracms/core/content';
|
|
5
|
+
import { DEFAULT_SEO_FIELD, parseLocaleConfig, documentKey, readLiveRedirects, SEO_SUBFIELDS, splitLocalePath, DRAFT_PERSPECTIVE, splitPath, localeUrlPath, variantOf, DRAFT_VARIANT, createRouter, deliverCompositionProps, presentationBodyFields } from '@elytracms/core/cms-core';
|
|
6
6
|
export { DRAFT_PERSPECTIVE, documentSchema, localeConfigSchema, localeUrlPath, parseLocaleConfig, redirectRecordSchema, resolveLocale, routeRecordSchema, splitLocalePath, textDirection, variantOf } from '@elytracms/core/cms-core';
|
|
7
|
-
import { assetReadLocale, redirectRecordKind } from '@elytracms/core/persistence';
|
|
7
|
+
import { assetMetaLens, assetMetaDrift, assetReadLocale, redirectRecordKind } from '@elytracms/core/persistence';
|
|
8
|
+
import { propFieldLookupOf } from '@elytracms/core/component-registry';
|
|
9
|
+
export { defineComponent } from '@elytracms/core/component-registry';
|
|
8
10
|
import { revalidateTag, cacheTag } from 'next/cache';
|
|
9
11
|
import { draftMode } from 'next/headers';
|
|
10
12
|
import { redirect, notFound, permanentRedirect } from 'next/navigation';
|
|
@@ -15,7 +17,6 @@ import { INGEST_MAX_BODY_BYTES, readIngestPayload, INGEST_RECEIVER_PATH, signedI
|
|
|
15
17
|
import NextImage from 'next/image';
|
|
16
18
|
import { normalizeImageSource } from '@elytracms/components';
|
|
17
19
|
import { projectFrontendUrl, resolveProject } from '@elytracms/core/studio-core';
|
|
18
|
-
export { defineComponent } from '@elytracms/core/component-registry';
|
|
19
20
|
export { z } from 'zod';
|
|
20
21
|
|
|
21
22
|
// src/components.ts
|
|
@@ -136,9 +137,13 @@ function createStaticContentSource(data) {
|
|
|
136
137
|
}
|
|
137
138
|
const assets = /* @__PURE__ */ new Map();
|
|
138
139
|
for (const record2 of data.assets ?? []) assets.set(record2.id, record2);
|
|
140
|
+
const metaLens = assetMetaLens(data.collections ?? []);
|
|
139
141
|
const sourceIssues = [
|
|
140
142
|
...data.sourceIssues ?? [],
|
|
141
|
-
...[...assets.values()].filter((record2) => !assetUrl(record2)).map((record2) => assetWithoutUrlIssue(record2.id))
|
|
143
|
+
...[...assets.values()].filter((record2) => !assetUrl(record2)).map((record2) => assetWithoutUrlIssue(record2.id)),
|
|
144
|
+
...[...assets.values()].flatMap(
|
|
145
|
+
(record2) => assetMetaDrift(record2, metaLens).map((drift) => assetMetaDriftIssue(record2.id, drift))
|
|
146
|
+
)
|
|
142
147
|
];
|
|
143
148
|
const lookupFor = (_perspective) => ({
|
|
144
149
|
collection: (id) => collections.get(id),
|
|
@@ -152,7 +157,8 @@ function createStaticContentSource(data) {
|
|
|
152
157
|
context: createContentContext({
|
|
153
158
|
locale: init.locale ?? locales.default,
|
|
154
159
|
perspective: init.perspective,
|
|
155
|
-
locales
|
|
160
|
+
locales,
|
|
161
|
+
assetMetaLens: metaLens
|
|
156
162
|
}),
|
|
157
163
|
routes,
|
|
158
164
|
redirects,
|
|
@@ -172,7 +178,7 @@ function createStaticContentSource(data) {
|
|
|
172
178
|
// EC-633: a record with no URL is no resolved asset — not baked, so the page renders
|
|
173
179
|
// the empty state the canvas renders for it (and `sourceIssues` names it).
|
|
174
180
|
assets: (locale) => [...assets.values()].flatMap((record2) => {
|
|
175
|
-
const asset = resolvedAsset(record2, assetUrl(record2), assetReadLocale(locales, locale));
|
|
181
|
+
const asset = resolvedAsset(record2, assetUrl(record2), assetReadLocale(locales, metaLens, locale));
|
|
176
182
|
return asset ? [asset] : [];
|
|
177
183
|
}),
|
|
178
184
|
// EC-499: the schema the route helper reads a collection's declared
|
|
@@ -353,6 +359,28 @@ function presentationFor(source, result) {
|
|
|
353
359
|
const body = presentationBodyFields(collection);
|
|
354
360
|
return body.length > 0 ? { body: [...body] } : void 0;
|
|
355
361
|
}
|
|
362
|
+
function projectPageProps(result, registry) {
|
|
363
|
+
const document = result.document;
|
|
364
|
+
if (!document) return result;
|
|
365
|
+
const lookupManifest = registry ? propFieldLookupOf((id) => registry.getManifest(id)) : void 0;
|
|
366
|
+
const issues = [];
|
|
367
|
+
let projected;
|
|
368
|
+
for (const [name, value] of Object.entries(document)) {
|
|
369
|
+
const delivered = deliverCompositionProps(
|
|
370
|
+
value,
|
|
371
|
+
{ path: [name], collectionId: document.collection, documentId: document.id },
|
|
372
|
+
issues,
|
|
373
|
+
lookupManifest
|
|
374
|
+
);
|
|
375
|
+
if (delivered !== value) (projected ??= { ...document })[name] = delivered;
|
|
376
|
+
}
|
|
377
|
+
if (!projected && issues.length === 0) return result;
|
|
378
|
+
return {
|
|
379
|
+
...result,
|
|
380
|
+
...projected ? { document: projected } : {},
|
|
381
|
+
issues: [...result.issues, ...issues]
|
|
382
|
+
};
|
|
383
|
+
}
|
|
356
384
|
function populatePageRelations(body, client, registry) {
|
|
357
385
|
if (!registry) return { relations: {}, docKeys: [] };
|
|
358
386
|
const refKeys = /* @__PURE__ */ new Set();
|
|
@@ -417,18 +445,19 @@ function populatePageLinks(body, client, registry) {
|
|
|
417
445
|
async function resolveCanvasPage(source, url, perspective, options = {}) {
|
|
418
446
|
const { locale, path } = splitLocalePath(url, source.locales);
|
|
419
447
|
const client = source.client({ perspective, locale });
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
448
|
+
const resolved = client.resolvePage(path);
|
|
449
|
+
if (resolved.status === "redirect" && resolved.redirect) {
|
|
422
450
|
return {
|
|
423
451
|
kind: "redirect",
|
|
424
|
-
target:
|
|
425
|
-
permanent:
|
|
426
|
-
tags:
|
|
452
|
+
target: resolved.redirect.target,
|
|
453
|
+
permanent: resolved.redirect.permanent,
|
|
454
|
+
tags: resolved.tags
|
|
427
455
|
};
|
|
428
456
|
}
|
|
429
|
-
if (
|
|
430
|
-
return { kind: "not-found", tags:
|
|
457
|
+
if (resolved.status !== "ok") {
|
|
458
|
+
return { kind: "not-found", tags: resolved.tags };
|
|
431
459
|
}
|
|
460
|
+
const result = projectPageProps(resolved, options.registry);
|
|
432
461
|
const presentation = presentationFor(source, result);
|
|
433
462
|
const body = pageBodyOf(result, presentation);
|
|
434
463
|
const allAssets = source.assets?.(locale) ?? [];
|
|
@@ -1106,7 +1135,10 @@ async function runConvexQuery(fetchImpl, convexUrl, path, args) {
|
|
|
1106
1135
|
}
|
|
1107
1136
|
function assembleLiveSource(payload, options, perspective) {
|
|
1108
1137
|
const locales = options.locales;
|
|
1109
|
-
const { documents, issues: documentIssues } = parseDeliveredDocuments(
|
|
1138
|
+
const { documents, issues: documentIssues } = parseDeliveredDocuments(
|
|
1139
|
+
payload.documents,
|
|
1140
|
+
payload.documentIssues ?? []
|
|
1141
|
+
);
|
|
1110
1142
|
const delivered = parseDeliveredRedirects(payload.redirects ?? [], payload.redirectIssues ?? []);
|
|
1111
1143
|
const sourceIssues = [...documentIssues, ...delivered.issues];
|
|
1112
1144
|
const routes = [...options.routes];
|