@cmssy/next 16.8.0 → 16.9.1

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/README.md CHANGED
@@ -121,6 +121,21 @@ Root: `defineCmssyConfig`, `localizeHref`, `nextRetryMode`, `cmssyCachedFetch`,
121
121
  `CMSSY_CONTENT_TAG` and the types. The full list, with signatures, is in
122
122
  [docs/reference/sdk-api.md](../../docs/reference/sdk-api.md).
123
123
 
124
+ ## Versioning: this package, not the API
125
+
126
+ **Pinning this package does not pin the API it talks to.** The package version
127
+ covers this client - its exports and their behaviour, normal semver. The cmssy
128
+ delivery API is a hosted service whose GraphQL schema can change on any deploy,
129
+ without a release here.
130
+
131
+ There is no dated API version to pin; the delivery endpoint has no version
132
+ segment. What protects you today is that a breaking schema change cannot merge
133
+ silently - it is caught by a gate that validates the SDK's own operations, and
134
+ shipping one anyway takes a recorded approval - and that fields we intend to
135
+ remove are marked `@deprecated` first. There is no guaranteed deprecation window
136
+ and no minimum notice period. Details in
137
+ [`@cmssy/core`](https://www.npmjs.com/package/@cmssy/core).
138
+
124
139
  ## License
125
140
 
126
141
  MIT
package/dist/server.cjs CHANGED
@@ -386,42 +386,10 @@ async function CmssyLayoutSlot({
386
386
  const { groups, settings, page: routed, element } = layout;
387
387
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children({ groups, settings, page: routed, element }) });
388
388
  }
389
- function pageOf(body) {
390
- if (typeof body !== "object" || body === null) return "";
391
- const page = body.page;
392
- if (typeof page !== "object" || page === null) return "";
393
- const slug = page.slug;
394
- return typeof slug === "string" ? slug : "";
395
- }
396
389
  function createCmssyBlockDataRoute(config, blocks, options = {}) {
390
+ const handle = react.createBlockDataHandler(config, blocks, options);
397
391
  return async function POST(request) {
398
- if (!config.draftSecret) {
399
- return new Response(
400
- "cmssy: createCmssyBlockDataRoute needs config.draftSecret to verify the editor",
401
- { status: 500 }
402
- );
403
- }
404
- let body;
405
- try {
406
- body = await request.json();
407
- } catch {
408
- return Response.json(
409
- { message: "cmssy: body is not JSON" },
410
- { status: 400 }
411
- );
412
- }
413
- const authorized = await core.verifyCmssyEditToken(
414
- request.headers.get(core.CMSSY_EDIT_TOKEN_HEADER),
415
- config.draftSecret,
416
- { page: pageOf(body) }
417
- );
418
- if (!authorized) {
419
- return new Response(
420
- "cmssy: block data needs the edit token the editor page was rendered with",
421
- { status: 403 }
422
- );
423
- }
424
- return react.handleBlockDataRequest(body, { blocks, config, ...options });
392
+ return handle(request);
425
393
  };
426
394
  }
427
395
 
package/dist/server.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { C as CmssyDataCacheOptions } from './index-D6hhjPH3.cjs';
2
2
  export { a as CMSSY_CONTENT_TAG, b as CmssyAppContext, c as CmssyEditorProps, d as CreateCmssyPageOptions, N as NEXT_BUILD_PHASE, e as cmssyCachedFetch, f as createCmssyEditPage, g as createCmssyPage, n as nextRetryMode } from './index-D6hhjPH3.cjs';
3
- import { CmssyConfig, CmssyRegionOf, RetryOption, CmssyFormDefinition, CmssyClientConfig } from '@cmssy/core';
3
+ import { CmssyConfig, CmssyRegionOf, RetryOption, CmssyClientConfig } from '@cmssy/core';
4
4
  export { CmssyRetryMode, RetryOption, RetryPolicy } from '@cmssy/core';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { ComponentType, ReactNode } from 'react';
7
- import { BlockDefinition, CmssyLayoutEditableProps, CmssyLayoutResolution, ResolveCmssyLayoutOptions as ResolveCmssyLayoutOptions$1 } from '@cmssy/react';
7
+ import { BlockDefinition, CmssyLayoutEditableProps, CmssyLayoutResolution, ResolveCmssyLayoutOptions as ResolveCmssyLayoutOptions$1, CmssyBlockDataHandlerOptions } from '@cmssy/react';
8
8
  export { CmssyLayoutEditableProps, CmssyLayoutResolution } from '@cmssy/react';
9
9
  import '@cmssy/react/client';
10
10
 
@@ -51,11 +51,7 @@ type ResolveCmssyLayoutOptions<C extends CmssyConfig, P extends CmssyRegionOf<C>
51
51
  };
52
52
  declare function resolveCmssyLayout<C extends CmssyConfig, P extends CmssyRegionOf<C>>(config: C, options: ResolveCmssyLayoutOptions<C, P>): Promise<CmssyLayoutResolution<C, P>>;
53
53
 
54
- interface CmssyBlockDataRouteConfig {
55
- forms?: Record<string, CmssyFormDefinition>;
56
- appContext?: Record<string, unknown>;
57
- workspaceId?: string;
58
- }
54
+ type CmssyBlockDataRouteConfig = CmssyBlockDataHandlerOptions;
59
55
  declare function createCmssyBlockDataRoute(config: CmssyClientConfig & {
60
56
  draftSecret?: string;
61
57
  }, blocks: BlockDefinition[], options?: CmssyBlockDataRouteConfig): (request: Request) => Promise<Response>;
package/dist/server.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { C as CmssyDataCacheOptions } from './index-D6hhjPH3.js';
2
2
  export { a as CMSSY_CONTENT_TAG, b as CmssyAppContext, c as CmssyEditorProps, d as CreateCmssyPageOptions, N as NEXT_BUILD_PHASE, e as cmssyCachedFetch, f as createCmssyEditPage, g as createCmssyPage, n as nextRetryMode } from './index-D6hhjPH3.js';
3
- import { CmssyConfig, CmssyRegionOf, RetryOption, CmssyFormDefinition, CmssyClientConfig } from '@cmssy/core';
3
+ import { CmssyConfig, CmssyRegionOf, RetryOption, CmssyClientConfig } from '@cmssy/core';
4
4
  export { CmssyRetryMode, RetryOption, RetryPolicy } from '@cmssy/core';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { ComponentType, ReactNode } from 'react';
7
- import { BlockDefinition, CmssyLayoutEditableProps, CmssyLayoutResolution, ResolveCmssyLayoutOptions as ResolveCmssyLayoutOptions$1 } from '@cmssy/react';
7
+ import { BlockDefinition, CmssyLayoutEditableProps, CmssyLayoutResolution, ResolveCmssyLayoutOptions as ResolveCmssyLayoutOptions$1, CmssyBlockDataHandlerOptions } from '@cmssy/react';
8
8
  export { CmssyLayoutEditableProps, CmssyLayoutResolution } from '@cmssy/react';
9
9
  import '@cmssy/react/client';
10
10
 
@@ -51,11 +51,7 @@ type ResolveCmssyLayoutOptions<C extends CmssyConfig, P extends CmssyRegionOf<C>
51
51
  };
52
52
  declare function resolveCmssyLayout<C extends CmssyConfig, P extends CmssyRegionOf<C>>(config: C, options: ResolveCmssyLayoutOptions<C, P>): Promise<CmssyLayoutResolution<C, P>>;
53
53
 
54
- interface CmssyBlockDataRouteConfig {
55
- forms?: Record<string, CmssyFormDefinition>;
56
- appContext?: Record<string, unknown>;
57
- workspaceId?: string;
58
- }
54
+ type CmssyBlockDataRouteConfig = CmssyBlockDataHandlerOptions;
59
55
  declare function createCmssyBlockDataRoute(config: CmssyClientConfig & {
60
56
  draftSecret?: string;
61
57
  }, blocks: BlockDefinition[], options?: CmssyBlockDataRouteConfig): (request: Request) => Promise<Response>;
package/dist/server.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import 'server-only';
2
2
  import { draftMode, headers } from 'next/headers';
3
3
  import { notFound, redirect } from 'next/navigation';
4
- import { createCmssyClient, CmssyServerPage, resolveCmssyLayout as resolveCmssyLayout$1, handleBlockDataRequest } from '@cmssy/react';
5
- import { mintCmssyEditToken, CMSSY_SECRET_QUERY_PARAM, resolveEditorOrigin, verifyCmssyWebhook, CmssyWebhookError, CMSSY_EDIT_HEADER, verifyCmssyEditToken, CMSSY_EDIT_TOKEN_HEADER, CMSSY_EDIT_QUERY_PARAM } from '@cmssy/core';
4
+ import { createCmssyClient, CmssyServerPage, resolveCmssyLayout as resolveCmssyLayout$1, createBlockDataHandler } from '@cmssy/react';
5
+ import { mintCmssyEditToken, CMSSY_SECRET_QUERY_PARAM, resolveEditorOrigin, verifyCmssyWebhook, CmssyWebhookError, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM } from '@cmssy/core';
6
6
  import { CmssyLocaleProvider } from '@cmssy/react/internal';
7
7
  import { blocksToSchemas, resolveEditorBlockData } from '@cmssy/react/internal-server';
8
8
  import { isDevelopment, resolveSiteLocales, splitLocaleFromPath, fetchPage, resolveForms, toCspOrigin, cmssySecretsMatch } from '@cmssy/core/internal';
@@ -384,42 +384,10 @@ async function CmssyLayoutSlot({
384
384
  const { groups, settings, page: routed, element } = layout;
385
385
  return /* @__PURE__ */ jsx(Fragment, { children: children({ groups, settings, page: routed, element }) });
386
386
  }
387
- function pageOf(body) {
388
- if (typeof body !== "object" || body === null) return "";
389
- const page = body.page;
390
- if (typeof page !== "object" || page === null) return "";
391
- const slug = page.slug;
392
- return typeof slug === "string" ? slug : "";
393
- }
394
387
  function createCmssyBlockDataRoute(config, blocks, options = {}) {
388
+ const handle = createBlockDataHandler(config, blocks, options);
395
389
  return async function POST(request) {
396
- if (!config.draftSecret) {
397
- return new Response(
398
- "cmssy: createCmssyBlockDataRoute needs config.draftSecret to verify the editor",
399
- { status: 500 }
400
- );
401
- }
402
- let body;
403
- try {
404
- body = await request.json();
405
- } catch {
406
- return Response.json(
407
- { message: "cmssy: body is not JSON" },
408
- { status: 400 }
409
- );
410
- }
411
- const authorized = await verifyCmssyEditToken(
412
- request.headers.get(CMSSY_EDIT_TOKEN_HEADER),
413
- config.draftSecret,
414
- { page: pageOf(body) }
415
- );
416
- if (!authorized) {
417
- return new Response(
418
- "cmssy: block data needs the edit token the editor page was rendered with",
419
- { status: 403 }
420
- );
421
- }
422
- return handleBlockDataRequest(body, { blocks, config, ...options });
390
+ return handle(request);
423
391
  };
424
392
  }
425
393
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "16.8.0",
3
+ "version": "16.9.1",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -71,7 +71,7 @@
71
71
  "dist"
72
72
  ],
73
73
  "peerDependencies": {
74
- "@cmssy/react": "^16.8.0",
74
+ "@cmssy/react": "^16.9.1",
75
75
  "next": ">=15",
76
76
  "react": "^18.2.0 || ^19.0.0",
77
77
  "react-dom": "^18.2.0 || ^19.0.0"
@@ -85,12 +85,12 @@
85
85
  "tsup": "^8.3.0",
86
86
  "typescript": "^5.6.0",
87
87
  "vitest": "^2.1.0",
88
- "@cmssy/react": "16.8.0"
88
+ "@cmssy/react": "16.9.1"
89
89
  },
90
90
  "dependencies": {
91
91
  "@cmssy/types": "0.49.0",
92
92
  "server-only": "^0.0.1",
93
- "@cmssy/core": "16.8.0"
93
+ "@cmssy/core": "16.9.1"
94
94
  },
95
95
  "scripts": {
96
96
  "build": "tsup",