@cmssy/next 4.7.2 → 5.0.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.d.cts CHANGED
@@ -1,330 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ComponentType, ReactNode } from 'react';
3
- import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig } from '@cmssy/react';
4
- export { DEFAULT_CMSSY_API_URL, FieldCondition, FieldConditionGroup, FieldConditionLogic, evaluateFieldConditionGroup, resolveApiUrl } from '@cmssy/react';
5
- import { EditBridgeConfig } from '@cmssy/react/client';
6
- import { C as CmssyNextConfig } from './config-DNaPqq1f.cjs';
7
- export { a as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, b as assertAuthConfig, d as defineCmssyConfig, r as resolveEditorOrigin } from './config-DNaPqq1f.cjs';
8
- import { NextRequest, NextResponse } from 'next/server';
9
- import { MetadataRoute, Metadata } from 'next';
10
- import { CmssySessionPayload, SessionCookieOptions, CmssySessionUser, FetchProductOptions, CmssyProduct, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, CmssyOrder, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
11
- export { CmssyAuthConfig, CmssyProductPage, CmssySessionPayload, CmssySessionUser, CmssyStockState, CmssyWebhookEvent, CmssyWebhookOrder, FetchOrderByTokenOptions, FetchProductOptions, FetchProductsOptions, MyOrdersResult, SessionCookieOptions, VerifyCmssyWebhookOptions } from '@cmssy/types';
12
-
13
- interface CmssyEditorProps {
14
- page: CmssyPageData;
15
- locale: string;
16
- defaultLocale: string;
17
- enabledLocales?: string[];
18
- edit: EditBridgeConfig;
19
- forms?: Record<string, CmssyFormDefinition>;
20
- }
21
- interface CreateCmssyPageOptions {
22
- editor?: ComponentType<CmssyEditorProps>;
23
- path?: string;
24
- }
25
- interface CatchAllParams {
26
- path?: string[];
27
- }
28
- type SearchParams = Record<string, string | string[] | undefined>;
29
- interface CatchAllProps {
30
- params?: Promise<CatchAllParams>;
31
- searchParams?: Promise<SearchParams>;
32
- }
33
- /**
34
- * Public catch-all page. Statically renderable: it never reads
35
- * `searchParams` or `headers()` - awaiting either forces every route
36
- * dynamic and kills ISR (CMS-952). Draft-mode preview (the authenticated
37
- * /api/draft cookie) still works per-request via `draftMode()`, which is
38
- * static-safe, and renders draft CONTENT without the editor (CMS-948).
39
- * The editor-iframe flow (`?cmssyEdit=1&cmssySecret=...`) is served by
40
- * the middleware rewrite (`cmssyEditRewrite`) onto the dynamic edit route
41
- * mounted with `createCmssyEditPage`.
42
- */
43
- declare function createCmssyPage(config: CmssyNextConfig, blocks: BlockDefinition[], options?: CreateCmssyPageOptions): ({ params, searchParams, }: CatchAllProps) => Promise<react_jsx_runtime.JSX.Element>;
44
- /**
45
- * Editor page for the middleware-rewritten edit route
46
- * (`app/cmssy-edit/[[...path]]/page.tsx`, `dynamic = "force-dynamic"`).
47
- * Re-verifies the `cmssyEdit` + `cmssySecret` pair itself, so a direct hit
48
- * on the route path (bypassing the middleware) cannot mount the editor.
49
- */
50
- declare function createCmssyEditPage(config: CmssyNextConfig, blocks: BlockDefinition[], options?: CreateCmssyPageOptions): ({ params, searchParams, }: CatchAllProps) => Promise<react_jsx_runtime.JSX.Element>;
51
-
52
- /**
53
- * Where the middleware rewrites editor-preview traffic. Mount the matching
54
- * dynamic route in the consumer app:
55
- *
56
- * app/cmssy-edit/[[...path]]/page.tsx
57
- * export const dynamic = "force-dynamic";
58
- * export default createCmssyEditPage(cmssy, blocks, { editor: Editor });
59
- */
60
- declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
61
- /**
62
- * Rewrite VERIFIED editor requests (`cmssyEdit=1` + a `cmssySecret` matching
63
- * the site's draft secret, CMS-948) onto the dedicated dynamic edit route, so
64
- * the public catch-all can stay fully static. A static page never sees its
65
- * query string - this rewrite is what makes the editor iframe work at all
66
- * once ISR is on. Draft-mode preview (the authenticated /api/draft cookie) is
67
- * NOT rewritten: it renders draft content on the public route via
68
- * `draftMode()`, without the editor. Returns null for normal traffic so it
69
- * composes with other middleware.
70
- */
71
- declare function cmssyEditRewrite(request: NextRequest, config: {
72
- draftSecret: string;
73
- }, options?: {
74
- /**
75
- * Headers to forward to the edit route, for a site whose middleware tells
76
- * the app something the path alone does not - a resolved locale, say.
77
- * Without them the editor preview renders in the default language while the
78
- * public page renders in the visitor's.
79
- */
80
- requestHeaders?: Headers;
81
- }): Promise<NextResponse | null>;
82
- /** Standalone middleware when the consumer has no other middleware to compose. */
83
- declare function createCmssyEditMiddleware(config: {
84
- draftSecret: string;
85
- }): (request: NextRequest) => Promise<NextResponse>;
86
-
87
- interface CreateCmssyNotFoundOptions {
88
- /**
89
- * Rendered when no 404 page is configured in Settings, or the configured
90
- * page has no published content. Defaults to a minimal built-in message.
91
- */
92
- fallback?: ReactNode;
93
- }
94
- /**
95
- * Renders the workspace's configured 404 page (Settings → 404 page) as the
96
- * body of Next's `app/not-found.tsx`, preserving the HTTP 404 status. Drop the
97
- * returned component in as the default export of `app/not-found.tsx`:
98
- *
99
- * export default createCmssyNotFound(cmssy, blocks);
100
- */
101
- declare function createCmssyNotFound(config: CmssyNextConfig, blocks: BlockDefinition[], options?: CreateCmssyNotFoundOptions): () => Promise<string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode> | null | undefined>;
102
-
103
- interface SeoBaseUrlOption {
104
- /**
105
- * Override for the canonical origin. A string (e.g. https://cmssy.com) or a
106
- * resolver. Falls back to `config.siteUrl`, then the request `host` header.
107
- */
108
- baseUrl?: string | (() => string | Promise<string>);
109
- }
110
-
111
- interface CreateCmssyRobotsOptions extends SeoBaseUrlOption {
112
- /** Path prefixes to disallow. Defaults to `["/api/"]`. */
113
- disallow?: string[];
114
- /** Override the generated rules entirely. */
115
- rules?: MetadataRoute.Robots["rules"];
116
- /** Reference `${baseUrl}/sitemap.xml`. Defaults to true. */
117
- sitemap?: boolean;
118
- /**
119
- * Emit the non-standard `Host:` directive (a Yandex extension). Google
120
- * ignores it and reports a warning in Search Console, so it is off by
121
- * default. Enable only when targeting Yandex.
122
- */
123
- host?: boolean;
124
- }
125
- /**
126
- * Builds the default export for Next's `app/robots.ts`. Allows crawling and
127
- * points to the sitemap. Drop in as:
128
- *
129
- * export default createCmssyRobots(cmssy);
130
- */
131
- declare function createCmssyRobots(config: CmssyNextConfig, options?: CreateCmssyRobotsOptions): () => Promise<MetadataRoute.Robots>;
132
-
133
- /** What an `extra` resolver needs to build URLs that agree with the page ones. */
134
- interface CmssySitemapContext {
135
- baseUrl: string;
136
- defaultLocale: string;
137
- locales: string[];
138
- }
139
- interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
140
- /**
141
- * Entries appended to the generated page list - the URLs a workspace's PAGES
142
- * cannot express, like a product or a category rendered from model records.
143
- * Pass a resolver to build them at request time; it gets the same baseUrl and
144
- * locales the page entries use, so the two cannot disagree.
145
- */
146
- extra?: MetadataRoute.Sitemap | ((context: CmssySitemapContext) => MetadataRoute.Sitemap | Promise<MetadataRoute.Sitemap>);
147
- /**
148
- * Additional page slugs to omit. The workspace's configured 404 page
149
- * (Settings → 404 page) is excluded automatically via its id, so this is
150
- * only for extra slugs you never want indexed.
151
- */
152
- excludeSlugs?: string[];
153
- }
154
- /**
155
- * Builds the default export for Next's `app/sitemap.ts` from the workspace's
156
- * published pages. Emits one entry per page with per-locale `alternates` when
157
- * the config enables multiple locales. Drop in as:
158
- *
159
- * export default createCmssySitemap(cmssy);
160
- */
161
- declare function createCmssySitemap(config: CmssyNextConfig, options?: CreateCmssySitemapOptions): () => Promise<MetadataRoute.Sitemap>;
162
-
163
- interface BuildCmssyMetadataOptions extends SeoBaseUrlOption {
164
- /** Override the Open Graph / Twitter image (defaults to workspace branding). */
165
- image?: string;
166
- /** Open Graph type. Defaults to "website". */
167
- ogType?: string;
168
- /** Twitter card. Defaults to "summary_large_image" when an image exists. */
169
- twitterCard?: "summary" | "summary_large_image";
170
- /**
171
- * The language to render metadata in. Only needed when the language does not
172
- * live in the URL (a per-domain or cookie strategy); with a locale prefix the
173
- * path already says it.
174
- */
175
- locale?: string;
176
- }
177
- /**
178
- * Builds complete Next.js `Metadata` for a cmssy page from its SEO fields and
179
- * the workspace branding: title/description/keywords, canonical + per-locale
180
- * `hreflang` alternates, and Open Graph / Twitter cards (with the branding OG
181
- * image). Use in a route's `generateMetadata`:
182
- *
183
- * export const generateMetadata = async ({ params }) =>
184
- * buildCmssyMetadata(cmssy, (await params).path);
185
- *
186
- * Pass the catch-all segments **as routed**, locale prefix and all: the prefix
187
- * is what says which language this page is. Stripping it first (and leaving the
188
- * language to `config.resolveLocale`) is how every localized page ends up with
189
- * the default language's title - and a canonical pointing at the default
190
- * language's URL, which tells Google the translation is a duplicate.
191
- */
192
- declare function buildCmssyMetadata(config: CmssyNextConfig, path?: string | string[], options?: BuildCmssyMetadataOptions): Promise<Metadata>;
193
-
194
- type CmssyDraftRouteConfig = Pick<CmssyNextConfig, "draftSecret"> & {
195
- defaultRedirect?: string;
196
- };
197
- declare function createDraftRoute(config: CmssyDraftRouteConfig): (request: Request) => Promise<Response>;
198
-
199
- interface CmssyCspOptions {
200
- /** Defaults to the cmssy cloud admin origin when unset. */
201
- editorOrigin?: string | string[];
202
- }
203
- interface MutableHeaders {
204
- headers: {
205
- get: (name: string) => string | null;
206
- set: (name: string, value: string) => void;
207
- delete: (name: string) => void;
208
- };
209
- }
210
- declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
211
- declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
212
-
213
- declare const CMSSY_EDIT_HEADER = "x-cmssy-edit";
214
- declare const CMSSY_EDIT_QUERY_PARAM = "cmssyEdit";
215
- declare const CMSSY_SECRET_QUERY_PARAM = "cmssySecret";
216
- interface EditRequestLike {
217
- cookies: {
218
- has: (name: string) => boolean;
219
- };
220
- nextUrl: {
221
- searchParams: {
222
- getAll: (name: string) => string[];
223
- get: (name: string) => string | null;
224
- };
225
- };
226
- }
227
- declare function isCmssyEditRequest(request: EditRequestLike, config: {
228
- draftSecret: string;
229
- }): Promise<boolean>;
230
- declare function isCmssyEditMode(): Promise<boolean>;
231
-
232
- declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
233
- declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
234
- declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
235
- locale: string;
236
- path: string[] | undefined;
237
- }>;
238
- /**
239
- * Resolve the active locale. Pass `options.path` (route params) wherever
240
- * possible - that path is static-safe. The no-argument form falls back to the
241
- * `x-cmssy-locale` request header, which reads `headers()` and forces the
242
- * calling route into dynamic rendering.
243
- */
244
- declare function getCmssyLocale(config: CmssyClientConfig, options?: {
245
- path?: string | string[];
246
- }): Promise<string>;
247
-
248
- /**
249
- * Resolves the active locale from a pathname's leading segment. Uses the
250
- * config's static `defaultLocale` + `enabledLocales` when both are set (no
251
- * network); otherwise fetches the workspace locales (cached).
252
- */
253
- declare function resolveLocaleFromPathname(config: CmssyNextConfig, pathname: string): Promise<string>;
254
- /**
255
- * Middleware that derives the locale from the URL path prefix and forwards it as
256
- * the `x-cmssy-locale` request header, so server components that can't read the
257
- * path (root layout) resolve the right locale via `getCmssyLocale`.
258
- */
259
- declare function createCmssyLocaleMiddleware(config: CmssyNextConfig): (request: NextRequest) => Promise<NextResponse>;
260
-
261
- declare const CMSSY_SESSION_COOKIE = "cmssy_session";
262
- declare const SESSION_MAX_AGE_SECONDS: number;
263
- declare function sealSession(payload: CmssySessionPayload, secret: string, audience?: string): Promise<string>;
264
- declare function openSession(token: string, secret: string, audience?: string): Promise<CmssySessionPayload | null>;
265
- declare function isAccessExpired(payload: CmssySessionPayload, now?: number): boolean;
266
- declare function sessionCookieOptions(): SessionCookieOptions;
267
-
268
- interface CmssyAuthRouteHandlers {
269
- POST(request: Request, context: {
270
- params: Promise<{
271
- action: string;
272
- }>;
273
- }): Promise<Response>;
274
- GET(request: Request, context: {
275
- params: Promise<{
276
- action: string;
277
- }>;
278
- }): Promise<Response>;
279
- }
280
- declare function createCmssyAuthRoute(config: CmssyNextConfig): CmssyAuthRouteHandlers;
281
-
282
- declare const CMSSY_CART_COOKIE = "cmssy_cart";
283
- interface CmssyCartRouteHandlers {
284
- POST(request: Request, context: {
285
- params: Promise<{
286
- action: string;
287
- }>;
288
- }): Promise<Response>;
289
- }
290
- declare function createCmssyCartRoute(config: CmssyNextConfig): CmssyCartRouteHandlers;
291
-
292
- declare function getCmssyUser(config: CmssyNextConfig): Promise<CmssySessionUser | null>;
293
- declare function getCmssyAccessToken(config: CmssyNextConfig): Promise<string | null>;
294
-
295
- type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
296
- declare function createCmssyAuthMiddleware(config: CmssyNextConfig): CmssyAuthMiddleware;
297
-
298
- declare function fetchProducts(config: CmssyNextConfig, options: FetchProductsOptions): Promise<CmssyProductPage>;
299
- declare function fetchProduct(config: CmssyNextConfig, options: FetchProductOptions): Promise<CmssyProduct | null>;
300
-
301
- declare function fetchOrderByToken(config: CmssyNextConfig, options: FetchOrderByTokenOptions): Promise<CmssyOrder>;
302
-
303
- interface CmssyOrdersRouteHandlers {
304
- GET(request: Request): Promise<Response>;
305
- }
306
- declare function createCmssyOrdersRoute(config: CmssyNextConfig): CmssyOrdersRouteHandlers;
307
-
308
- /**
309
- * Verify + parse an inbound cmssy webhook (CMS-693 / CMS-694).
310
- *
311
- * cmssy signs each delivery with HMAC-SHA256 over `${timestamp}.${body}`
312
- * and sends the result in the `X-Cmssy-Signature: t=<ms>,v1=<hex>`
313
- * header, plus a unique `X-Cmssy-Webhook-Id`. This helper recomputes the
314
- * signature (timing-safe compare), rejects stale timestamps to bound
315
- * replay, and returns the typed event.
316
- *
317
- * IMPORTANT: pass the RAW request body string (e.g. `await req.text()`),
318
- * never a re-serialized object - the signed bytes must match exactly.
319
- */
320
- declare class CmssyWebhookError extends Error {
321
- constructor(message: string);
322
- }
323
- /**
324
- * Verify the signature + freshness and return the parsed event. Throws
325
- * `CmssyWebhookError` on any failure (missing/malformed header, bad
326
- * signature, stale timestamp, invalid JSON) - catch it and respond 400.
327
- */
328
- declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
329
-
330
- 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, CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySitemapContext, CmssyWebhookError, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, buildCmssyMetadata, cmssyCspHeaders, cmssyEditRewrite, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyEditMiddleware, createCmssyEditPage, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchOrderByToken, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
1
+ export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, CmssyAuthConfig, CmssyConfig, CmssyEnvConfig, CmssyPageData, CmssyPageMeta, CmssyPageSummary, DEFAULT_CMSSY_EDITOR_ORIGINS, assertAuthConfig, defineCmssyConfig, resolveEditorOrigin } from '@cmssy/core';
2
+ export { C as CmssyEditorProps, a as CreateCmssyPageOptions } from './index-D-mfavEO.cjs';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
5
+ import '@cmssy/react';
6
+ import '@cmssy/react/client';
package/dist/index.d.ts CHANGED
@@ -1,330 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ComponentType, ReactNode } from 'react';
3
- import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig } from '@cmssy/react';
4
- export { DEFAULT_CMSSY_API_URL, FieldCondition, FieldConditionGroup, FieldConditionLogic, evaluateFieldConditionGroup, resolveApiUrl } from '@cmssy/react';
5
- import { EditBridgeConfig } from '@cmssy/react/client';
6
- import { C as CmssyNextConfig } from './config-DNaPqq1f.js';
7
- export { a as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, b as assertAuthConfig, d as defineCmssyConfig, r as resolveEditorOrigin } from './config-DNaPqq1f.js';
8
- import { NextRequest, NextResponse } from 'next/server';
9
- import { MetadataRoute, Metadata } from 'next';
10
- import { CmssySessionPayload, SessionCookieOptions, CmssySessionUser, FetchProductOptions, CmssyProduct, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, CmssyOrder, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
11
- export { CmssyAuthConfig, CmssyProductPage, CmssySessionPayload, CmssySessionUser, CmssyStockState, CmssyWebhookEvent, CmssyWebhookOrder, FetchOrderByTokenOptions, FetchProductOptions, FetchProductsOptions, MyOrdersResult, SessionCookieOptions, VerifyCmssyWebhookOptions } from '@cmssy/types';
12
-
13
- interface CmssyEditorProps {
14
- page: CmssyPageData;
15
- locale: string;
16
- defaultLocale: string;
17
- enabledLocales?: string[];
18
- edit: EditBridgeConfig;
19
- forms?: Record<string, CmssyFormDefinition>;
20
- }
21
- interface CreateCmssyPageOptions {
22
- editor?: ComponentType<CmssyEditorProps>;
23
- path?: string;
24
- }
25
- interface CatchAllParams {
26
- path?: string[];
27
- }
28
- type SearchParams = Record<string, string | string[] | undefined>;
29
- interface CatchAllProps {
30
- params?: Promise<CatchAllParams>;
31
- searchParams?: Promise<SearchParams>;
32
- }
33
- /**
34
- * Public catch-all page. Statically renderable: it never reads
35
- * `searchParams` or `headers()` - awaiting either forces every route
36
- * dynamic and kills ISR (CMS-952). Draft-mode preview (the authenticated
37
- * /api/draft cookie) still works per-request via `draftMode()`, which is
38
- * static-safe, and renders draft CONTENT without the editor (CMS-948).
39
- * The editor-iframe flow (`?cmssyEdit=1&cmssySecret=...`) is served by
40
- * the middleware rewrite (`cmssyEditRewrite`) onto the dynamic edit route
41
- * mounted with `createCmssyEditPage`.
42
- */
43
- declare function createCmssyPage(config: CmssyNextConfig, blocks: BlockDefinition[], options?: CreateCmssyPageOptions): ({ params, searchParams, }: CatchAllProps) => Promise<react_jsx_runtime.JSX.Element>;
44
- /**
45
- * Editor page for the middleware-rewritten edit route
46
- * (`app/cmssy-edit/[[...path]]/page.tsx`, `dynamic = "force-dynamic"`).
47
- * Re-verifies the `cmssyEdit` + `cmssySecret` pair itself, so a direct hit
48
- * on the route path (bypassing the middleware) cannot mount the editor.
49
- */
50
- declare function createCmssyEditPage(config: CmssyNextConfig, blocks: BlockDefinition[], options?: CreateCmssyPageOptions): ({ params, searchParams, }: CatchAllProps) => Promise<react_jsx_runtime.JSX.Element>;
51
-
52
- /**
53
- * Where the middleware rewrites editor-preview traffic. Mount the matching
54
- * dynamic route in the consumer app:
55
- *
56
- * app/cmssy-edit/[[...path]]/page.tsx
57
- * export const dynamic = "force-dynamic";
58
- * export default createCmssyEditPage(cmssy, blocks, { editor: Editor });
59
- */
60
- declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
61
- /**
62
- * Rewrite VERIFIED editor requests (`cmssyEdit=1` + a `cmssySecret` matching
63
- * the site's draft secret, CMS-948) onto the dedicated dynamic edit route, so
64
- * the public catch-all can stay fully static. A static page never sees its
65
- * query string - this rewrite is what makes the editor iframe work at all
66
- * once ISR is on. Draft-mode preview (the authenticated /api/draft cookie) is
67
- * NOT rewritten: it renders draft content on the public route via
68
- * `draftMode()`, without the editor. Returns null for normal traffic so it
69
- * composes with other middleware.
70
- */
71
- declare function cmssyEditRewrite(request: NextRequest, config: {
72
- draftSecret: string;
73
- }, options?: {
74
- /**
75
- * Headers to forward to the edit route, for a site whose middleware tells
76
- * the app something the path alone does not - a resolved locale, say.
77
- * Without them the editor preview renders in the default language while the
78
- * public page renders in the visitor's.
79
- */
80
- requestHeaders?: Headers;
81
- }): Promise<NextResponse | null>;
82
- /** Standalone middleware when the consumer has no other middleware to compose. */
83
- declare function createCmssyEditMiddleware(config: {
84
- draftSecret: string;
85
- }): (request: NextRequest) => Promise<NextResponse>;
86
-
87
- interface CreateCmssyNotFoundOptions {
88
- /**
89
- * Rendered when no 404 page is configured in Settings, or the configured
90
- * page has no published content. Defaults to a minimal built-in message.
91
- */
92
- fallback?: ReactNode;
93
- }
94
- /**
95
- * Renders the workspace's configured 404 page (Settings → 404 page) as the
96
- * body of Next's `app/not-found.tsx`, preserving the HTTP 404 status. Drop the
97
- * returned component in as the default export of `app/not-found.tsx`:
98
- *
99
- * export default createCmssyNotFound(cmssy, blocks);
100
- */
101
- declare function createCmssyNotFound(config: CmssyNextConfig, blocks: BlockDefinition[], options?: CreateCmssyNotFoundOptions): () => Promise<string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode> | null | undefined>;
102
-
103
- interface SeoBaseUrlOption {
104
- /**
105
- * Override for the canonical origin. A string (e.g. https://cmssy.com) or a
106
- * resolver. Falls back to `config.siteUrl`, then the request `host` header.
107
- */
108
- baseUrl?: string | (() => string | Promise<string>);
109
- }
110
-
111
- interface CreateCmssyRobotsOptions extends SeoBaseUrlOption {
112
- /** Path prefixes to disallow. Defaults to `["/api/"]`. */
113
- disallow?: string[];
114
- /** Override the generated rules entirely. */
115
- rules?: MetadataRoute.Robots["rules"];
116
- /** Reference `${baseUrl}/sitemap.xml`. Defaults to true. */
117
- sitemap?: boolean;
118
- /**
119
- * Emit the non-standard `Host:` directive (a Yandex extension). Google
120
- * ignores it and reports a warning in Search Console, so it is off by
121
- * default. Enable only when targeting Yandex.
122
- */
123
- host?: boolean;
124
- }
125
- /**
126
- * Builds the default export for Next's `app/robots.ts`. Allows crawling and
127
- * points to the sitemap. Drop in as:
128
- *
129
- * export default createCmssyRobots(cmssy);
130
- */
131
- declare function createCmssyRobots(config: CmssyNextConfig, options?: CreateCmssyRobotsOptions): () => Promise<MetadataRoute.Robots>;
132
-
133
- /** What an `extra` resolver needs to build URLs that agree with the page ones. */
134
- interface CmssySitemapContext {
135
- baseUrl: string;
136
- defaultLocale: string;
137
- locales: string[];
138
- }
139
- interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
140
- /**
141
- * Entries appended to the generated page list - the URLs a workspace's PAGES
142
- * cannot express, like a product or a category rendered from model records.
143
- * Pass a resolver to build them at request time; it gets the same baseUrl and
144
- * locales the page entries use, so the two cannot disagree.
145
- */
146
- extra?: MetadataRoute.Sitemap | ((context: CmssySitemapContext) => MetadataRoute.Sitemap | Promise<MetadataRoute.Sitemap>);
147
- /**
148
- * Additional page slugs to omit. The workspace's configured 404 page
149
- * (Settings → 404 page) is excluded automatically via its id, so this is
150
- * only for extra slugs you never want indexed.
151
- */
152
- excludeSlugs?: string[];
153
- }
154
- /**
155
- * Builds the default export for Next's `app/sitemap.ts` from the workspace's
156
- * published pages. Emits one entry per page with per-locale `alternates` when
157
- * the config enables multiple locales. Drop in as:
158
- *
159
- * export default createCmssySitemap(cmssy);
160
- */
161
- declare function createCmssySitemap(config: CmssyNextConfig, options?: CreateCmssySitemapOptions): () => Promise<MetadataRoute.Sitemap>;
162
-
163
- interface BuildCmssyMetadataOptions extends SeoBaseUrlOption {
164
- /** Override the Open Graph / Twitter image (defaults to workspace branding). */
165
- image?: string;
166
- /** Open Graph type. Defaults to "website". */
167
- ogType?: string;
168
- /** Twitter card. Defaults to "summary_large_image" when an image exists. */
169
- twitterCard?: "summary" | "summary_large_image";
170
- /**
171
- * The language to render metadata in. Only needed when the language does not
172
- * live in the URL (a per-domain or cookie strategy); with a locale prefix the
173
- * path already says it.
174
- */
175
- locale?: string;
176
- }
177
- /**
178
- * Builds complete Next.js `Metadata` for a cmssy page from its SEO fields and
179
- * the workspace branding: title/description/keywords, canonical + per-locale
180
- * `hreflang` alternates, and Open Graph / Twitter cards (with the branding OG
181
- * image). Use in a route's `generateMetadata`:
182
- *
183
- * export const generateMetadata = async ({ params }) =>
184
- * buildCmssyMetadata(cmssy, (await params).path);
185
- *
186
- * Pass the catch-all segments **as routed**, locale prefix and all: the prefix
187
- * is what says which language this page is. Stripping it first (and leaving the
188
- * language to `config.resolveLocale`) is how every localized page ends up with
189
- * the default language's title - and a canonical pointing at the default
190
- * language's URL, which tells Google the translation is a duplicate.
191
- */
192
- declare function buildCmssyMetadata(config: CmssyNextConfig, path?: string | string[], options?: BuildCmssyMetadataOptions): Promise<Metadata>;
193
-
194
- type CmssyDraftRouteConfig = Pick<CmssyNextConfig, "draftSecret"> & {
195
- defaultRedirect?: string;
196
- };
197
- declare function createDraftRoute(config: CmssyDraftRouteConfig): (request: Request) => Promise<Response>;
198
-
199
- interface CmssyCspOptions {
200
- /** Defaults to the cmssy cloud admin origin when unset. */
201
- editorOrigin?: string | string[];
202
- }
203
- interface MutableHeaders {
204
- headers: {
205
- get: (name: string) => string | null;
206
- set: (name: string, value: string) => void;
207
- delete: (name: string) => void;
208
- };
209
- }
210
- declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
211
- declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
212
-
213
- declare const CMSSY_EDIT_HEADER = "x-cmssy-edit";
214
- declare const CMSSY_EDIT_QUERY_PARAM = "cmssyEdit";
215
- declare const CMSSY_SECRET_QUERY_PARAM = "cmssySecret";
216
- interface EditRequestLike {
217
- cookies: {
218
- has: (name: string) => boolean;
219
- };
220
- nextUrl: {
221
- searchParams: {
222
- getAll: (name: string) => string[];
223
- get: (name: string) => string | null;
224
- };
225
- };
226
- }
227
- declare function isCmssyEditRequest(request: EditRequestLike, config: {
228
- draftSecret: string;
229
- }): Promise<boolean>;
230
- declare function isCmssyEditMode(): Promise<boolean>;
231
-
232
- declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
233
- declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
234
- declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
235
- locale: string;
236
- path: string[] | undefined;
237
- }>;
238
- /**
239
- * Resolve the active locale. Pass `options.path` (route params) wherever
240
- * possible - that path is static-safe. The no-argument form falls back to the
241
- * `x-cmssy-locale` request header, which reads `headers()` and forces the
242
- * calling route into dynamic rendering.
243
- */
244
- declare function getCmssyLocale(config: CmssyClientConfig, options?: {
245
- path?: string | string[];
246
- }): Promise<string>;
247
-
248
- /**
249
- * Resolves the active locale from a pathname's leading segment. Uses the
250
- * config's static `defaultLocale` + `enabledLocales` when both are set (no
251
- * network); otherwise fetches the workspace locales (cached).
252
- */
253
- declare function resolveLocaleFromPathname(config: CmssyNextConfig, pathname: string): Promise<string>;
254
- /**
255
- * Middleware that derives the locale from the URL path prefix and forwards it as
256
- * the `x-cmssy-locale` request header, so server components that can't read the
257
- * path (root layout) resolve the right locale via `getCmssyLocale`.
258
- */
259
- declare function createCmssyLocaleMiddleware(config: CmssyNextConfig): (request: NextRequest) => Promise<NextResponse>;
260
-
261
- declare const CMSSY_SESSION_COOKIE = "cmssy_session";
262
- declare const SESSION_MAX_AGE_SECONDS: number;
263
- declare function sealSession(payload: CmssySessionPayload, secret: string, audience?: string): Promise<string>;
264
- declare function openSession(token: string, secret: string, audience?: string): Promise<CmssySessionPayload | null>;
265
- declare function isAccessExpired(payload: CmssySessionPayload, now?: number): boolean;
266
- declare function sessionCookieOptions(): SessionCookieOptions;
267
-
268
- interface CmssyAuthRouteHandlers {
269
- POST(request: Request, context: {
270
- params: Promise<{
271
- action: string;
272
- }>;
273
- }): Promise<Response>;
274
- GET(request: Request, context: {
275
- params: Promise<{
276
- action: string;
277
- }>;
278
- }): Promise<Response>;
279
- }
280
- declare function createCmssyAuthRoute(config: CmssyNextConfig): CmssyAuthRouteHandlers;
281
-
282
- declare const CMSSY_CART_COOKIE = "cmssy_cart";
283
- interface CmssyCartRouteHandlers {
284
- POST(request: Request, context: {
285
- params: Promise<{
286
- action: string;
287
- }>;
288
- }): Promise<Response>;
289
- }
290
- declare function createCmssyCartRoute(config: CmssyNextConfig): CmssyCartRouteHandlers;
291
-
292
- declare function getCmssyUser(config: CmssyNextConfig): Promise<CmssySessionUser | null>;
293
- declare function getCmssyAccessToken(config: CmssyNextConfig): Promise<string | null>;
294
-
295
- type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
296
- declare function createCmssyAuthMiddleware(config: CmssyNextConfig): CmssyAuthMiddleware;
297
-
298
- declare function fetchProducts(config: CmssyNextConfig, options: FetchProductsOptions): Promise<CmssyProductPage>;
299
- declare function fetchProduct(config: CmssyNextConfig, options: FetchProductOptions): Promise<CmssyProduct | null>;
300
-
301
- declare function fetchOrderByToken(config: CmssyNextConfig, options: FetchOrderByTokenOptions): Promise<CmssyOrder>;
302
-
303
- interface CmssyOrdersRouteHandlers {
304
- GET(request: Request): Promise<Response>;
305
- }
306
- declare function createCmssyOrdersRoute(config: CmssyNextConfig): CmssyOrdersRouteHandlers;
307
-
308
- /**
309
- * Verify + parse an inbound cmssy webhook (CMS-693 / CMS-694).
310
- *
311
- * cmssy signs each delivery with HMAC-SHA256 over `${timestamp}.${body}`
312
- * and sends the result in the `X-Cmssy-Signature: t=<ms>,v1=<hex>`
313
- * header, plus a unique `X-Cmssy-Webhook-Id`. This helper recomputes the
314
- * signature (timing-safe compare), rejects stale timestamps to bound
315
- * replay, and returns the typed event.
316
- *
317
- * IMPORTANT: pass the RAW request body string (e.g. `await req.text()`),
318
- * never a re-serialized object - the signed bytes must match exactly.
319
- */
320
- declare class CmssyWebhookError extends Error {
321
- constructor(message: string);
322
- }
323
- /**
324
- * Verify the signature + freshness and return the parsed event. Throws
325
- * `CmssyWebhookError` on any failure (missing/malformed header, bad
326
- * signature, stale timestamp, invalid JSON) - catch it and respond 400.
327
- */
328
- declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
329
-
330
- 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, CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySitemapContext, CmssyWebhookError, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, buildCmssyMetadata, cmssyCspHeaders, cmssyEditRewrite, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyEditMiddleware, createCmssyEditPage, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchOrderByToken, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
1
+ export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, CmssyAuthConfig, CmssyConfig, CmssyEnvConfig, CmssyPageData, CmssyPageMeta, CmssyPageSummary, DEFAULT_CMSSY_EDITOR_ORIGINS, assertAuthConfig, defineCmssyConfig, resolveEditorOrigin } from '@cmssy/core';
2
+ export { C as CmssyEditorProps, a as CreateCmssyPageOptions } from './index-D-mfavEO.js';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
5
+ import '@cmssy/react';
6
+ import '@cmssy/react/client';