@elytracms/next 0.0.96 → 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 CHANGED
@@ -2014,6 +2014,12 @@ interface DeliverySnapshotPayload {
2014
2014
  */
2015
2015
  redirectIssues?: unknown[];
2016
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[];
2017
2023
  assets: unknown[];
2018
2024
  }
2019
2025
  /**
package/dist/index.js CHANGED
@@ -2,9 +2,11 @@ import { registerComponents, createRenderContext, renderDocumentBodyItems, docum
2
2
  import { isBlockSequenceValueShape } from '@elytracms/core/rich-text';
3
3
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
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, presentationBodyFields } from '@elytracms/core/cms-core';
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
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
@@ -358,6 +359,28 @@ function presentationFor(source, result) {
358
359
  const body = presentationBodyFields(collection);
359
360
  return body.length > 0 ? { body: [...body] } : void 0;
360
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
+ }
361
384
  function populatePageRelations(body, client, registry) {
362
385
  if (!registry) return { relations: {}, docKeys: [] };
363
386
  const refKeys = /* @__PURE__ */ new Set();
@@ -422,18 +445,19 @@ function populatePageLinks(body, client, registry) {
422
445
  async function resolveCanvasPage(source, url, perspective, options = {}) {
423
446
  const { locale, path } = splitLocalePath(url, source.locales);
424
447
  const client = source.client({ perspective, locale });
425
- const result = client.resolvePage(path);
426
- if (result.status === "redirect" && result.redirect) {
448
+ const resolved = client.resolvePage(path);
449
+ if (resolved.status === "redirect" && resolved.redirect) {
427
450
  return {
428
451
  kind: "redirect",
429
- target: result.redirect.target,
430
- permanent: result.redirect.permanent,
431
- tags: result.tags
452
+ target: resolved.redirect.target,
453
+ permanent: resolved.redirect.permanent,
454
+ tags: resolved.tags
432
455
  };
433
456
  }
434
- if (result.status !== "ok") {
435
- return { kind: "not-found", tags: result.tags };
457
+ if (resolved.status !== "ok") {
458
+ return { kind: "not-found", tags: resolved.tags };
436
459
  }
460
+ const result = projectPageProps(resolved, options.registry);
437
461
  const presentation = presentationFor(source, result);
438
462
  const body = pageBodyOf(result, presentation);
439
463
  const allAssets = source.assets?.(locale) ?? [];
@@ -1111,7 +1135,10 @@ async function runConvexQuery(fetchImpl, convexUrl, path, args) {
1111
1135
  }
1112
1136
  function assembleLiveSource(payload, options, perspective) {
1113
1137
  const locales = options.locales;
1114
- const { documents, issues: documentIssues } = parseDeliveredDocuments(payload.documents);
1138
+ const { documents, issues: documentIssues } = parseDeliveredDocuments(
1139
+ payload.documents,
1140
+ payload.documentIssues ?? []
1141
+ );
1115
1142
  const delivered = parseDeliveredRedirects(payload.redirects ?? [], payload.redirectIssues ?? []);
1116
1143
  const sourceIssues = [...documentIssues, ...delivered.issues];
1117
1144
  const routes = [...options.routes];