@cmssy/next 16.5.0 → 16.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.cjs +23 -0
- package/dist/server.d.cts +9 -2
- package/dist/server.d.ts +9 -2
- package/dist/server.js +24 -2
- package/package.json +4 -4
package/dist/server.cjs
CHANGED
|
@@ -379,11 +379,34 @@ async function CmssyLayoutSlot({
|
|
|
379
379
|
const { groups, settings, page: routed, element } = layout;
|
|
380
380
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children({ groups, settings, page: routed, element }) });
|
|
381
381
|
}
|
|
382
|
+
function createCmssyBlockDataRoute(config, blocks, options = {}) {
|
|
383
|
+
return async function POST(request) {
|
|
384
|
+
if (!await isCmssyEditMode()) {
|
|
385
|
+
return new Response(
|
|
386
|
+
"cmssy: block data is only resolved for a verified editor request",
|
|
387
|
+
{ status: 403 }
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
let body;
|
|
391
|
+
try {
|
|
392
|
+
body = await request.json();
|
|
393
|
+
} catch {
|
|
394
|
+
return Response.json(
|
|
395
|
+
{ message: "cmssy: body is not JSON" },
|
|
396
|
+
{
|
|
397
|
+
status: 400
|
|
398
|
+
}
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
return react.handleBlockDataRequest(body, { blocks, config, ...options });
|
|
402
|
+
};
|
|
403
|
+
}
|
|
382
404
|
|
|
383
405
|
exports.CMSSY_CONTENT_TAG = CMSSY_CONTENT_TAG;
|
|
384
406
|
exports.CmssyLayoutSlot = CmssyLayoutSlot;
|
|
385
407
|
exports.NEXT_BUILD_PHASE = NEXT_BUILD_PHASE;
|
|
386
408
|
exports.cmssyCachedFetch = cmssyCachedFetch;
|
|
409
|
+
exports.createCmssyBlockDataRoute = createCmssyBlockDataRoute;
|
|
387
410
|
exports.createCmssyEditPage = createCmssyEditPage;
|
|
388
411
|
exports.createCmssyPage = createCmssyPage;
|
|
389
412
|
exports.createCmssyRevalidateRoute = createCmssyRevalidateRoute;
|
package/dist/server.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 } from '@cmssy/core';
|
|
3
|
+
import { CmssyConfig, CmssyRegionOf, RetryOption, CmssyFormDefinition, 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';
|
|
@@ -51,4 +51,11 @@ 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
|
-
|
|
54
|
+
interface CmssyBlockDataRouteConfig {
|
|
55
|
+
forms?: Record<string, CmssyFormDefinition>;
|
|
56
|
+
appContext?: Record<string, unknown>;
|
|
57
|
+
workspaceId?: string;
|
|
58
|
+
}
|
|
59
|
+
declare function createCmssyBlockDataRoute(config: CmssyClientConfig, blocks: BlockDefinition[], options?: CmssyBlockDataRouteConfig): (request: Request) => Promise<Response>;
|
|
60
|
+
|
|
61
|
+
export { type CmssyBlockDataRouteConfig, CmssyDataCacheOptions, type CmssyDraftRouteConfig, CmssyLayoutSlot, type CmssyLayoutSlotProps, type CmssyLayoutSlotRenderProps, type CmssyRevalidateRouteConfig, type ResolveCmssyLayoutOptions, createCmssyBlockDataRoute, createCmssyRevalidateRoute, createDraftRoute, isCmssyEditMode, resolveCmssyLayout };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 } from '@cmssy/core';
|
|
3
|
+
import { CmssyConfig, CmssyRegionOf, RetryOption, CmssyFormDefinition, 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';
|
|
@@ -51,4 +51,11 @@ 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
|
-
|
|
54
|
+
interface CmssyBlockDataRouteConfig {
|
|
55
|
+
forms?: Record<string, CmssyFormDefinition>;
|
|
56
|
+
appContext?: Record<string, unknown>;
|
|
57
|
+
workspaceId?: string;
|
|
58
|
+
}
|
|
59
|
+
declare function createCmssyBlockDataRoute(config: CmssyClientConfig, blocks: BlockDefinition[], options?: CmssyBlockDataRouteConfig): (request: Request) => Promise<Response>;
|
|
60
|
+
|
|
61
|
+
export { type CmssyBlockDataRouteConfig, CmssyDataCacheOptions, type CmssyDraftRouteConfig, CmssyLayoutSlot, type CmssyLayoutSlotProps, type CmssyLayoutSlotRenderProps, type CmssyRevalidateRouteConfig, type ResolveCmssyLayoutOptions, createCmssyBlockDataRoute, createCmssyRevalidateRoute, createDraftRoute, isCmssyEditMode, resolveCmssyLayout };
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 } from '@cmssy/react';
|
|
4
|
+
import { createCmssyClient, CmssyServerPage, resolveCmssyLayout as resolveCmssyLayout$1, handleBlockDataRequest } from '@cmssy/react';
|
|
5
5
|
import { CmssyLocaleProvider } from '@cmssy/react/internal';
|
|
6
6
|
import { blocksToSchemas, resolveEditorBlockData } from '@cmssy/react/internal-server';
|
|
7
7
|
import { isDevelopment, resolveSiteLocales, splitLocaleFromPath, fetchPage, resolveForms, toCspOrigin, cmssySecretsMatch } from '@cmssy/core/internal';
|
|
@@ -377,5 +377,27 @@ async function CmssyLayoutSlot({
|
|
|
377
377
|
const { groups, settings, page: routed, element } = layout;
|
|
378
378
|
return /* @__PURE__ */ jsx(Fragment, { children: children({ groups, settings, page: routed, element }) });
|
|
379
379
|
}
|
|
380
|
+
function createCmssyBlockDataRoute(config, blocks, options = {}) {
|
|
381
|
+
return async function POST(request) {
|
|
382
|
+
if (!await isCmssyEditMode()) {
|
|
383
|
+
return new Response(
|
|
384
|
+
"cmssy: block data is only resolved for a verified editor request",
|
|
385
|
+
{ status: 403 }
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
let body;
|
|
389
|
+
try {
|
|
390
|
+
body = await request.json();
|
|
391
|
+
} catch {
|
|
392
|
+
return Response.json(
|
|
393
|
+
{ message: "cmssy: body is not JSON" },
|
|
394
|
+
{
|
|
395
|
+
status: 400
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
return handleBlockDataRequest(body, { blocks, config, ...options });
|
|
400
|
+
};
|
|
401
|
+
}
|
|
380
402
|
|
|
381
|
-
export { CMSSY_CONTENT_TAG, CmssyLayoutSlot, NEXT_BUILD_PHASE, cmssyCachedFetch, createCmssyEditPage, createCmssyPage, createCmssyRevalidateRoute, createDraftRoute, isCmssyEditMode, nextRetryMode, resolveCmssyLayout };
|
|
403
|
+
export { CMSSY_CONTENT_TAG, CmssyLayoutSlot, NEXT_BUILD_PHASE, cmssyCachedFetch, createCmssyBlockDataRoute, createCmssyEditPage, createCmssyPage, createCmssyRevalidateRoute, createDraftRoute, isCmssyEditMode, nextRetryMode, resolveCmssyLayout };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/next",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.7.0",
|
|
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.
|
|
74
|
+
"@cmssy/react": "^16.7.0",
|
|
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.
|
|
88
|
+
"@cmssy/react": "16.7.0"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@cmssy/types": "0.49.0",
|
|
92
92
|
"server-only": "^0.0.1",
|
|
93
|
-
"@cmssy/core": "16.
|
|
93
|
+
"@cmssy/core": "16.7.0"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build": "tsup",
|