@cmssy/astro 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/dist/index.cjs +24 -0
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +15 -4
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -135,16 +135,31 @@ async function loadCmssyPage(config, request, url, options = {}) {
|
|
|
135
135
|
defaultLocale: slot.defaultLocale,
|
|
136
136
|
enabledLocales: slot.enabledLocales,
|
|
137
137
|
isEdit,
|
|
138
|
+
...isEdit && config.draftSecret ? {
|
|
139
|
+
blockDataToken: await core.mintCmssyEditToken(config.draftSecret, {
|
|
140
|
+
page: slot.page.slug
|
|
141
|
+
})
|
|
142
|
+
} : {},
|
|
138
143
|
editorData,
|
|
139
144
|
editorOrigin: slot.editorOrigin,
|
|
140
145
|
...config.layout ? { layoutRegions: config.layout.regions } : {}
|
|
141
146
|
};
|
|
142
147
|
}
|
|
148
|
+
function createCmssyBlockDataEndpoint(config, blocks, options = {}) {
|
|
149
|
+
const handle = react.createBlockDataHandler(config, blocks, options);
|
|
150
|
+
return async function POST(context) {
|
|
151
|
+
return handle(context.request);
|
|
152
|
+
};
|
|
153
|
+
}
|
|
143
154
|
|
|
144
155
|
Object.defineProperty(exports, "CMSSY_EDIT_HEADER", {
|
|
145
156
|
enumerable: true,
|
|
146
157
|
get: function () { return core.CMSSY_EDIT_HEADER; }
|
|
147
158
|
});
|
|
159
|
+
Object.defineProperty(exports, "CMSSY_EDIT_TOKEN_HEADER", {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function () { return core.CMSSY_EDIT_TOKEN_HEADER; }
|
|
162
|
+
});
|
|
148
163
|
Object.defineProperty(exports, "CMSSY_LOCALE_HEADER", {
|
|
149
164
|
enumerable: true,
|
|
150
165
|
get: function () { return core.CMSSY_LOCALE_HEADER; }
|
|
@@ -169,10 +184,18 @@ Object.defineProperty(exports, "localizeHref", {
|
|
|
169
184
|
enumerable: true,
|
|
170
185
|
get: function () { return core.localizeHref; }
|
|
171
186
|
});
|
|
187
|
+
Object.defineProperty(exports, "mintCmssyEditToken", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function () { return core.mintCmssyEditToken; }
|
|
190
|
+
});
|
|
172
191
|
Object.defineProperty(exports, "resolveEditorOrigin", {
|
|
173
192
|
enumerable: true,
|
|
174
193
|
get: function () { return core.resolveEditorOrigin; }
|
|
175
194
|
});
|
|
195
|
+
Object.defineProperty(exports, "verifyCmssyEditToken", {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
get: function () { return core.verifyCmssyEditToken; }
|
|
198
|
+
});
|
|
176
199
|
Object.defineProperty(exports, "verifyCmssyWebhook", {
|
|
177
200
|
enumerable: true,
|
|
178
201
|
get: function () { return core.verifyCmssyWebhook; }
|
|
@@ -183,4 +206,5 @@ Object.defineProperty(exports, "resolveCmssyLayout", {
|
|
|
183
206
|
});
|
|
184
207
|
exports.CMSSY_EDIT_PATH_PREFIX = CMSSY_EDIT_PATH_PREFIX;
|
|
185
208
|
exports.cmssyMiddleware = cmssyMiddleware;
|
|
209
|
+
exports.createCmssyBlockDataEndpoint = createCmssyBlockDataEndpoint;
|
|
186
210
|
exports.loadCmssyPage = loadCmssyPage;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, LayoutRegion, RetryOption } from '@cmssy/core';
|
|
2
|
-
export { CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CmssyBlockContext, CmssyBlockPage, CmssyConfig, CmssyEnvConfig, CmssyLayout, CmssyLayoutGroup, CmssyPageData, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRetryMode, CmssyWebhookError, CmssyWebhookEvent, LayoutRegion, RetryOption, RetryPolicy, VerifyCmssyWebhookOptions, createCmssyClient, defineCmssyConfig, defineCmssyLayout, localizeHref, resolveEditorOrigin, verifyCmssyWebhook } from '@cmssy/core';
|
|
3
|
-
import { BlockDefinition } from '@cmssy/react';
|
|
1
|
+
import { CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, LayoutRegion, RetryOption, CmssyClientConfig } from '@cmssy/core';
|
|
2
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_TOKEN_HEADER, CMSSY_LOCALE_HEADER, CmssyBlockContext, CmssyBlockPage, CmssyConfig, CmssyEnvConfig, CmssyLayout, CmssyLayoutGroup, CmssyPageData, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRetryMode, CmssyWebhookError, CmssyWebhookEvent, LayoutRegion, RetryOption, RetryPolicy, VerifyCmssyWebhookOptions, createCmssyClient, defineCmssyConfig, defineCmssyLayout, localizeHref, mintCmssyEditToken, resolveEditorOrigin, verifyCmssyEditToken, verifyCmssyWebhook } from '@cmssy/core';
|
|
3
|
+
import { BlockDefinition, CmssyBlockDataHandlerOptions } from '@cmssy/react';
|
|
4
4
|
export { CmssyLayoutEditableProps, CmssyLayoutResolution, ResolveCmssyLayoutOptions, resolveCmssyLayout } from '@cmssy/react';
|
|
5
5
|
|
|
6
6
|
declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
|
|
@@ -22,6 +22,7 @@ interface CmssyPageResult {
|
|
|
22
22
|
defaultLocale: string;
|
|
23
23
|
enabledLocales: string[];
|
|
24
24
|
isEdit: boolean;
|
|
25
|
+
blockDataToken?: string;
|
|
25
26
|
editorData?: Record<string, CmssyLayoutEditorData>;
|
|
26
27
|
editorOrigin?: string | string[];
|
|
27
28
|
layoutRegions?: readonly LayoutRegion[];
|
|
@@ -39,4 +40,11 @@ interface LoadCmssyPageOptions {
|
|
|
39
40
|
}
|
|
40
41
|
declare function loadCmssyPage(config: CmssyConfig, request: Request, url: URL, options?: LoadCmssyPageOptions): Promise<CmssyPageResult>;
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
type CmssyBlockDataEndpointConfig = CmssyBlockDataHandlerOptions;
|
|
44
|
+
declare function createCmssyBlockDataEndpoint(config: CmssyClientConfig & {
|
|
45
|
+
draftSecret?: string;
|
|
46
|
+
}, blocks: BlockDefinition[], options?: CmssyBlockDataEndpointConfig): (context: {
|
|
47
|
+
request: Request;
|
|
48
|
+
}) => Promise<Response>;
|
|
49
|
+
|
|
50
|
+
export { CMSSY_EDIT_PATH_PREFIX, type CmssyBlockDataEndpointConfig, type CmssyMiddlewareOptions, type CmssyPageResult, type LoadCmssyPageOptions, cmssyMiddleware, createCmssyBlockDataEndpoint, loadCmssyPage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, LayoutRegion, RetryOption } from '@cmssy/core';
|
|
2
|
-
export { CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CmssyBlockContext, CmssyBlockPage, CmssyConfig, CmssyEnvConfig, CmssyLayout, CmssyLayoutGroup, CmssyPageData, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRetryMode, CmssyWebhookError, CmssyWebhookEvent, LayoutRegion, RetryOption, RetryPolicy, VerifyCmssyWebhookOptions, createCmssyClient, defineCmssyConfig, defineCmssyLayout, localizeHref, resolveEditorOrigin, verifyCmssyWebhook } from '@cmssy/core';
|
|
3
|
-
import { BlockDefinition } from '@cmssy/react';
|
|
1
|
+
import { CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, LayoutRegion, RetryOption, CmssyClientConfig } from '@cmssy/core';
|
|
2
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_TOKEN_HEADER, CMSSY_LOCALE_HEADER, CmssyBlockContext, CmssyBlockPage, CmssyConfig, CmssyEnvConfig, CmssyLayout, CmssyLayoutGroup, CmssyPageData, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRetryMode, CmssyWebhookError, CmssyWebhookEvent, LayoutRegion, RetryOption, RetryPolicy, VerifyCmssyWebhookOptions, createCmssyClient, defineCmssyConfig, defineCmssyLayout, localizeHref, mintCmssyEditToken, resolveEditorOrigin, verifyCmssyEditToken, verifyCmssyWebhook } from '@cmssy/core';
|
|
3
|
+
import { BlockDefinition, CmssyBlockDataHandlerOptions } from '@cmssy/react';
|
|
4
4
|
export { CmssyLayoutEditableProps, CmssyLayoutResolution, ResolveCmssyLayoutOptions, resolveCmssyLayout } from '@cmssy/react';
|
|
5
5
|
|
|
6
6
|
declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
|
|
@@ -22,6 +22,7 @@ interface CmssyPageResult {
|
|
|
22
22
|
defaultLocale: string;
|
|
23
23
|
enabledLocales: string[];
|
|
24
24
|
isEdit: boolean;
|
|
25
|
+
blockDataToken?: string;
|
|
25
26
|
editorData?: Record<string, CmssyLayoutEditorData>;
|
|
26
27
|
editorOrigin?: string | string[];
|
|
27
28
|
layoutRegions?: readonly LayoutRegion[];
|
|
@@ -39,4 +40,11 @@ interface LoadCmssyPageOptions {
|
|
|
39
40
|
}
|
|
40
41
|
declare function loadCmssyPage(config: CmssyConfig, request: Request, url: URL, options?: LoadCmssyPageOptions): Promise<CmssyPageResult>;
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
type CmssyBlockDataEndpointConfig = CmssyBlockDataHandlerOptions;
|
|
44
|
+
declare function createCmssyBlockDataEndpoint(config: CmssyClientConfig & {
|
|
45
|
+
draftSecret?: string;
|
|
46
|
+
}, blocks: BlockDefinition[], options?: CmssyBlockDataEndpointConfig): (context: {
|
|
47
|
+
request: Request;
|
|
48
|
+
}) => Promise<Response>;
|
|
49
|
+
|
|
50
|
+
export { CMSSY_EDIT_PATH_PREFIX, type CmssyBlockDataEndpointConfig, type CmssyMiddlewareOptions, type CmssyPageResult, type LoadCmssyPageOptions, cmssyMiddleware, createCmssyBlockDataEndpoint, loadCmssyPage };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, isVerifiedEditUrl, applyCmssyCsp, CMSSY_SECRET_QUERY_PARAM } from '@cmssy/core';
|
|
2
|
-
export { CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CmssyWebhookError, createCmssyClient, defineCmssyConfig, defineCmssyLayout, localizeHref, resolveEditorOrigin, verifyCmssyWebhook } from '@cmssy/core';
|
|
1
|
+
import { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, isVerifiedEditUrl, applyCmssyCsp, CMSSY_SECRET_QUERY_PARAM, mintCmssyEditToken } from '@cmssy/core';
|
|
2
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_TOKEN_HEADER, CMSSY_LOCALE_HEADER, CmssyWebhookError, createCmssyClient, defineCmssyConfig, defineCmssyLayout, localizeHref, mintCmssyEditToken, resolveEditorOrigin, verifyCmssyEditToken, verifyCmssyWebhook } from '@cmssy/core';
|
|
3
3
|
import { CMSSY_LOCALE_HEADER, localeForPathname, isDevelopment, resolveSiteLocales, layoutRegionIds, fetchPage } from '@cmssy/core/internal';
|
|
4
|
-
import { resolveCmssyLayoutSlot } from '@cmssy/react';
|
|
4
|
+
import { resolveCmssyLayoutSlot, createBlockDataHandler } from '@cmssy/react';
|
|
5
5
|
export { resolveCmssyLayout } from '@cmssy/react';
|
|
6
6
|
|
|
7
7
|
// src/middleware.ts
|
|
@@ -135,10 +135,21 @@ async function loadCmssyPage(config, request, url, options = {}) {
|
|
|
135
135
|
defaultLocale: slot.defaultLocale,
|
|
136
136
|
enabledLocales: slot.enabledLocales,
|
|
137
137
|
isEdit,
|
|
138
|
+
...isEdit && config.draftSecret ? {
|
|
139
|
+
blockDataToken: await mintCmssyEditToken(config.draftSecret, {
|
|
140
|
+
page: slot.page.slug
|
|
141
|
+
})
|
|
142
|
+
} : {},
|
|
138
143
|
editorData,
|
|
139
144
|
editorOrigin: slot.editorOrigin,
|
|
140
145
|
...config.layout ? { layoutRegions: config.layout.regions } : {}
|
|
141
146
|
};
|
|
142
147
|
}
|
|
148
|
+
function createCmssyBlockDataEndpoint(config, blocks, options = {}) {
|
|
149
|
+
const handle = createBlockDataHandler(config, blocks, options);
|
|
150
|
+
return async function POST(context) {
|
|
151
|
+
return handle(context.request);
|
|
152
|
+
};
|
|
153
|
+
}
|
|
143
154
|
|
|
144
|
-
export { CMSSY_EDIT_PATH_PREFIX, cmssyMiddleware, loadCmssyPage };
|
|
155
|
+
export { CMSSY_EDIT_PATH_PREFIX, cmssyMiddleware, createCmssyBlockDataEndpoint, loadCmssyPage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/astro",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.9.1",
|
|
4
4
|
"description": "Astro bindings for cmssy headless sites: middleware, page loader, sitemap and robots.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -50,17 +50,17 @@
|
|
|
50
50
|
],
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"astro": ">=4.16",
|
|
53
|
-
"@cmssy/react": "^16.
|
|
53
|
+
"@cmssy/react": "^16.9.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^20.0.0",
|
|
57
57
|
"tsup": "^8.3.0",
|
|
58
58
|
"typescript": "^5.6.0",
|
|
59
59
|
"vitest": "^2.1.0",
|
|
60
|
-
"@cmssy/react": "16.
|
|
60
|
+
"@cmssy/react": "16.9.1"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@cmssy/core": "16.
|
|
63
|
+
"@cmssy/core": "16.9.1"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "tsup",
|