@cmssy/next 4.1.0 → 4.3.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/index.cjs +8 -3
- package/dist/index.d.cts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +8 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -399,7 +399,7 @@ function resolveBridgeOrigin(editorOrigin) {
|
|
|
399
399
|
return origins.length === 1 ? origins[0] : origins;
|
|
400
400
|
}
|
|
401
401
|
var CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
|
|
402
|
-
async function cmssyEditRewrite(request2, config) {
|
|
402
|
+
async function cmssyEditRewrite(request2, config, options = {}) {
|
|
403
403
|
const { pathname, searchParams } = request2.nextUrl;
|
|
404
404
|
if (pathname.startsWith(CMSSY_EDIT_PATH_PREFIX)) return null;
|
|
405
405
|
if (!searchParams.getAll(CMSSY_EDIT_QUERY_PARAM).includes("1")) return null;
|
|
@@ -408,7 +408,10 @@ async function cmssyEditRewrite(request2, config) {
|
|
|
408
408
|
if (!await cmssySecretsMatch(provided, config.draftSecret)) return null;
|
|
409
409
|
const url = request2.nextUrl.clone();
|
|
410
410
|
url.pathname = `${CMSSY_EDIT_PATH_PREFIX}${pathname === "/" ? "" : pathname}`;
|
|
411
|
-
return server.NextResponse.rewrite(
|
|
411
|
+
return server.NextResponse.rewrite(
|
|
412
|
+
url,
|
|
413
|
+
options.requestHeaders ? { request: { headers: options.requestHeaders } } : void 0
|
|
414
|
+
);
|
|
412
415
|
}
|
|
413
416
|
function createCmssyEditMiddleware(config) {
|
|
414
417
|
return async function cmssyEditMiddleware(request2) {
|
|
@@ -606,7 +609,9 @@ function createCmssySitemap(config, options = {}) {
|
|
|
606
609
|
...alternates ? { alternates } : {}
|
|
607
610
|
}));
|
|
608
611
|
});
|
|
609
|
-
|
|
612
|
+
if (!options.extra) return entries;
|
|
613
|
+
const extra = typeof options.extra === "function" ? await options.extra({ baseUrl, defaultLocale, locales }) : options.extra;
|
|
614
|
+
return [...entries, ...extra];
|
|
610
615
|
};
|
|
611
616
|
}
|
|
612
617
|
function pick(value, locale, defaultLocale) {
|
package/dist/index.d.cts
CHANGED
|
@@ -128,6 +128,14 @@ declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
|
|
|
128
128
|
*/
|
|
129
129
|
declare function cmssyEditRewrite(request: NextRequest, config: {
|
|
130
130
|
draftSecret: string;
|
|
131
|
+
}, options?: {
|
|
132
|
+
/**
|
|
133
|
+
* Headers to forward to the edit route, for a site whose middleware tells
|
|
134
|
+
* the app something the path alone does not - a resolved locale, say.
|
|
135
|
+
* Without them the editor preview renders in the default language while the
|
|
136
|
+
* public page renders in the visitor's.
|
|
137
|
+
*/
|
|
138
|
+
requestHeaders?: Headers;
|
|
131
139
|
}): Promise<NextResponse | null>;
|
|
132
140
|
/** Standalone middleware when the consumer has no other middleware to compose. */
|
|
133
141
|
declare function createCmssyEditMiddleware(config: {
|
|
@@ -180,9 +188,20 @@ interface CreateCmssyRobotsOptions extends SeoBaseUrlOption {
|
|
|
180
188
|
*/
|
|
181
189
|
declare function createCmssyRobots(config: CmssyNextConfig, options?: CreateCmssyRobotsOptions): () => Promise<MetadataRoute.Robots>;
|
|
182
190
|
|
|
191
|
+
/** What an `extra` resolver needs to build URLs that agree with the page ones. */
|
|
192
|
+
interface CmssySitemapContext {
|
|
193
|
+
baseUrl: string;
|
|
194
|
+
defaultLocale: string;
|
|
195
|
+
locales: string[];
|
|
196
|
+
}
|
|
183
197
|
interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
|
|
184
|
-
/**
|
|
185
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Entries appended to the generated page list - the URLs a workspace's PAGES
|
|
200
|
+
* cannot express, like a product or a category rendered from model records.
|
|
201
|
+
* Pass a resolver to build them at request time; it gets the same baseUrl and
|
|
202
|
+
* locales the page entries use, so the two cannot disagree.
|
|
203
|
+
*/
|
|
204
|
+
extra?: MetadataRoute.Sitemap | ((context: CmssySitemapContext) => MetadataRoute.Sitemap | Promise<MetadataRoute.Sitemap>);
|
|
186
205
|
/**
|
|
187
206
|
* Additional page slugs to omit. The workspace's configured 404 page
|
|
188
207
|
* (Settings → 404 page) is excluded automatically via its id, so this is
|
|
@@ -366,4 +385,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
366
385
|
*/
|
|
367
386
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
|
|
368
387
|
|
|
369
|
-
export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_EDIT_PATH_PREFIX, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyEnvConfig, type CmssyNextConfig, type CmssyOrdersRouteHandlers, CmssyWebhookError, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, cmssyEditRewrite, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyEditMiddleware, createCmssyEditPage, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, defineCmssyConfig, fetchOrderByToken, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
|
|
388
|
+
export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_EDIT_PATH_PREFIX, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyEnvConfig, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySitemapContext, CmssyWebhookError, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, cmssyEditRewrite, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyEditMiddleware, createCmssyEditPage, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, defineCmssyConfig, fetchOrderByToken, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -128,6 +128,14 @@ declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
|
|
|
128
128
|
*/
|
|
129
129
|
declare function cmssyEditRewrite(request: NextRequest, config: {
|
|
130
130
|
draftSecret: string;
|
|
131
|
+
}, options?: {
|
|
132
|
+
/**
|
|
133
|
+
* Headers to forward to the edit route, for a site whose middleware tells
|
|
134
|
+
* the app something the path alone does not - a resolved locale, say.
|
|
135
|
+
* Without them the editor preview renders in the default language while the
|
|
136
|
+
* public page renders in the visitor's.
|
|
137
|
+
*/
|
|
138
|
+
requestHeaders?: Headers;
|
|
131
139
|
}): Promise<NextResponse | null>;
|
|
132
140
|
/** Standalone middleware when the consumer has no other middleware to compose. */
|
|
133
141
|
declare function createCmssyEditMiddleware(config: {
|
|
@@ -180,9 +188,20 @@ interface CreateCmssyRobotsOptions extends SeoBaseUrlOption {
|
|
|
180
188
|
*/
|
|
181
189
|
declare function createCmssyRobots(config: CmssyNextConfig, options?: CreateCmssyRobotsOptions): () => Promise<MetadataRoute.Robots>;
|
|
182
190
|
|
|
191
|
+
/** What an `extra` resolver needs to build URLs that agree with the page ones. */
|
|
192
|
+
interface CmssySitemapContext {
|
|
193
|
+
baseUrl: string;
|
|
194
|
+
defaultLocale: string;
|
|
195
|
+
locales: string[];
|
|
196
|
+
}
|
|
183
197
|
interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
|
|
184
|
-
/**
|
|
185
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Entries appended to the generated page list - the URLs a workspace's PAGES
|
|
200
|
+
* cannot express, like a product or a category rendered from model records.
|
|
201
|
+
* Pass a resolver to build them at request time; it gets the same baseUrl and
|
|
202
|
+
* locales the page entries use, so the two cannot disagree.
|
|
203
|
+
*/
|
|
204
|
+
extra?: MetadataRoute.Sitemap | ((context: CmssySitemapContext) => MetadataRoute.Sitemap | Promise<MetadataRoute.Sitemap>);
|
|
186
205
|
/**
|
|
187
206
|
* Additional page slugs to omit. The workspace's configured 404 page
|
|
188
207
|
* (Settings → 404 page) is excluded automatically via its id, so this is
|
|
@@ -366,4 +385,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
366
385
|
*/
|
|
367
386
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
|
|
368
387
|
|
|
369
|
-
export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_EDIT_PATH_PREFIX, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyEnvConfig, type CmssyNextConfig, type CmssyOrdersRouteHandlers, CmssyWebhookError, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, cmssyEditRewrite, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyEditMiddleware, createCmssyEditPage, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, defineCmssyConfig, fetchOrderByToken, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
|
|
388
|
+
export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_EDIT_PATH_PREFIX, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyEnvConfig, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySitemapContext, CmssyWebhookError, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, cmssyEditRewrite, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyEditMiddleware, createCmssyEditPage, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, defineCmssyConfig, fetchOrderByToken, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -398,7 +398,7 @@ function resolveBridgeOrigin(editorOrigin) {
|
|
|
398
398
|
return origins.length === 1 ? origins[0] : origins;
|
|
399
399
|
}
|
|
400
400
|
var CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
|
|
401
|
-
async function cmssyEditRewrite(request2, config) {
|
|
401
|
+
async function cmssyEditRewrite(request2, config, options = {}) {
|
|
402
402
|
const { pathname, searchParams } = request2.nextUrl;
|
|
403
403
|
if (pathname.startsWith(CMSSY_EDIT_PATH_PREFIX)) return null;
|
|
404
404
|
if (!searchParams.getAll(CMSSY_EDIT_QUERY_PARAM).includes("1")) return null;
|
|
@@ -407,7 +407,10 @@ async function cmssyEditRewrite(request2, config) {
|
|
|
407
407
|
if (!await cmssySecretsMatch(provided, config.draftSecret)) return null;
|
|
408
408
|
const url = request2.nextUrl.clone();
|
|
409
409
|
url.pathname = `${CMSSY_EDIT_PATH_PREFIX}${pathname === "/" ? "" : pathname}`;
|
|
410
|
-
return NextResponse.rewrite(
|
|
410
|
+
return NextResponse.rewrite(
|
|
411
|
+
url,
|
|
412
|
+
options.requestHeaders ? { request: { headers: options.requestHeaders } } : void 0
|
|
413
|
+
);
|
|
411
414
|
}
|
|
412
415
|
function createCmssyEditMiddleware(config) {
|
|
413
416
|
return async function cmssyEditMiddleware(request2) {
|
|
@@ -605,7 +608,9 @@ function createCmssySitemap(config, options = {}) {
|
|
|
605
608
|
...alternates ? { alternates } : {}
|
|
606
609
|
}));
|
|
607
610
|
});
|
|
608
|
-
|
|
611
|
+
if (!options.extra) return entries;
|
|
612
|
+
const extra = typeof options.extra === "function" ? await options.extra({ baseUrl, defaultLocale, locales }) : options.extra;
|
|
613
|
+
return [...entries, ...extra];
|
|
609
614
|
};
|
|
610
615
|
}
|
|
611
616
|
function pick(value, locale, defaultLocale) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/next",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@cmssy/react": "^4.
|
|
44
|
+
"@cmssy/react": "^4.3.0",
|
|
45
45
|
"next": ">=15",
|
|
46
46
|
"react": "^18.2.0 || ^19.0.0",
|
|
47
47
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"tsup": "^8.3.0",
|
|
56
56
|
"typescript": "^5.6.0",
|
|
57
57
|
"vitest": "^2.1.0",
|
|
58
|
-
"@cmssy/react": "4.
|
|
58
|
+
"@cmssy/react": "4.3.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"jose": "^6.2.3",
|