@cmssy/next 2.4.0 → 2.6.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.d.cts CHANGED
@@ -1,17 +1,15 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ComponentType, ReactNode } from 'react';
3
- import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig, CmssyProduct, CmssyOrder } from '@cmssy/react';
3
+ import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig } from '@cmssy/react';
4
4
  export { DEFAULT_CMSSY_API_URL, FieldCondition, FieldConditionGroup, FieldConditionLogic, evaluateFieldConditionGroup, resolveApiUrl } from '@cmssy/react';
5
5
  import { EditBridgeConfig } from '@cmssy/react/client';
6
+ import { CmssyAuthConfig, CmssySessionPayload, SessionCookieOptions, CmssySessionUser, FetchProductOptions, CmssyProduct, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, CmssyOrder, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
7
+ export { CmssyAuthConfig, CmssyProductPage, CmssySessionPayload, CmssySessionUser, CmssyStockState, CmssyWebhookEvent, CmssyWebhookOrder, FetchOrderByTokenOptions, FetchProductOptions, FetchProductsOptions, MyOrdersResult, SessionCookieOptions, VerifyCmssyWebhookOptions } from '@cmssy/types';
6
8
  import { MetadataRoute, Metadata } from 'next';
7
9
  import { NextRequest, NextResponse } from 'next/server';
8
10
 
9
11
  declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
10
12
  declare function resolveEditorOrigin(editorOrigin: string | string[] | undefined): string | string[];
11
- interface CmssyAuthConfig {
12
- modelSlug: string;
13
- sessionSecret: string;
14
- }
15
13
  interface CmssyNextConfig {
16
14
  /**
17
15
  * Full GraphQL delivery endpoint. Defaults to the cmssy cloud endpoint
@@ -234,26 +232,9 @@ declare function createCmssyLocaleMiddleware(config: CmssyNextConfig): (request:
234
232
 
235
233
  declare const CMSSY_SESSION_COOKIE = "cmssy_session";
236
234
  declare const SESSION_MAX_AGE_SECONDS: number;
237
- interface CmssySessionUser {
238
- recordId: string;
239
- email: string;
240
- }
241
- interface CmssySessionPayload {
242
- accessToken: string;
243
- refreshToken: string;
244
- accessExpiresAt: number;
245
- user: CmssySessionUser;
246
- }
247
235
  declare function sealSession(payload: CmssySessionPayload, secret: string, audience?: string): Promise<string>;
248
236
  declare function openSession(token: string, secret: string, audience?: string): Promise<CmssySessionPayload | null>;
249
237
  declare function isAccessExpired(payload: CmssySessionPayload, now?: number): boolean;
250
- interface SessionCookieOptions {
251
- httpOnly: true;
252
- secure: boolean;
253
- sameSite: "lax";
254
- path: "/";
255
- maxAge: number;
256
- }
257
238
  declare function sessionCookieOptions(): SessionCookieOptions;
258
239
 
259
240
  interface CmssyAuthRouteHandlers {
@@ -286,38 +267,9 @@ declare function getCmssyAccessToken(config: CmssyNextConfig): Promise<string |
286
267
  type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
287
268
  declare function createCmssyAuthMiddleware(config: CmssyNextConfig): CmssyAuthMiddleware;
288
269
 
289
- type CmssyStockState = "in" | "low" | "out";
290
- interface FetchProductsOptions {
291
- modelSlug: string;
292
- filter?: Record<string, unknown>;
293
- /**
294
- * Availability facet: "in", "low" or "out". Stock is not a data field -
295
- * availability is onHand minus reserved, summed across variants - so it
296
- * cannot go through `filter`. The backend applies the same rule the admin
297
- * catalog uses, so this facet cannot contradict the stock badge.
298
- */
299
- stockState?: CmssyStockState;
300
- limit?: number;
301
- offset?: number;
302
- sort?: string;
303
- }
304
- interface CmssyProductPage {
305
- items: CmssyProduct[];
306
- total: number;
307
- hasMore: boolean;
308
- }
309
270
  declare function fetchProducts(config: CmssyNextConfig, options: FetchProductsOptions): Promise<CmssyProductPage>;
310
- interface FetchProductOptions {
311
- modelSlug: string;
312
- slug: string;
313
- slugField?: string;
314
- }
315
271
  declare function fetchProduct(config: CmssyNextConfig, options: FetchProductOptions): Promise<CmssyProduct | null>;
316
272
 
317
- interface FetchOrderByTokenOptions {
318
- orderId: string;
319
- accessToken: string;
320
- }
321
273
  declare function fetchOrderByToken(config: CmssyNextConfig, options: FetchOrderByTokenOptions): Promise<CmssyOrder>;
322
274
 
323
275
  interface CmssyOrdersRouteHandlers {
@@ -325,12 +277,6 @@ interface CmssyOrdersRouteHandlers {
325
277
  }
326
278
  declare function createCmssyOrdersRoute(config: CmssyNextConfig): CmssyOrdersRouteHandlers;
327
279
 
328
- interface MyOrdersResult {
329
- items: CmssyOrder[];
330
- total: number;
331
- hasMore: boolean;
332
- }
333
-
334
280
  /**
335
281
  * Verify + parse an inbound cmssy webhook (CMS-693 / CMS-694).
336
282
  *
@@ -343,46 +289,6 @@ interface MyOrdersResult {
343
289
  * IMPORTANT: pass the RAW request body string (e.g. `await req.text()`),
344
290
  * never a re-serialized object - the signed bytes must match exactly.
345
291
  */
346
- /** Serialized order carried in an order.* webhook (mirrors the backend). */
347
- interface CmssyWebhookOrder {
348
- id: string;
349
- workspaceId: string;
350
- displayStatus: string;
351
- paymentStatus: string;
352
- fulfillmentStatus: string;
353
- total: number;
354
- currency: string;
355
- customerId: string | null;
356
- customerEmail: string;
357
- paymentProvider: string | null;
358
- paymentReference: string | null;
359
- refundedAmount: number;
360
- createdAt: string;
361
- updatedAt: string;
362
- }
363
- interface CmssyWebhookEvent {
364
- /** Delivery id - also sent in X-Cmssy-Webhook-Id; dedup on it. */
365
- id: string;
366
- /** e.g. "order.paid", "order.refunded". */
367
- event: string;
368
- createdAt: string;
369
- data: {
370
- workspaceId: string;
371
- order: CmssyWebhookOrder;
372
- };
373
- }
374
- interface VerifyCmssyWebhookOptions {
375
- /** Raw request body string (NOT parsed JSON). */
376
- body: string;
377
- /** The `X-Cmssy-Signature` header value, or null if absent. */
378
- signatureHeader: string | null;
379
- /** The endpoint's signing secret. */
380
- secret: string;
381
- /** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
382
- toleranceSeconds?: number;
383
- /** Override the current time (ms) - for tests. */
384
- now?: number;
385
- }
386
292
  declare class CmssyWebhookError extends Error {
387
293
  constructor(message: string);
388
294
  }
@@ -393,4 +299,4 @@ declare class CmssyWebhookError extends Error {
393
299
  */
394
300
  declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
395
301
 
396
- export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyEnvConfig, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssyProductPage, type CmssySessionPayload, type CmssySessionUser, type CmssyStockState, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, type FetchOrderByTokenOptions, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, 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 };
302
+ export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, 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, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, 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
@@ -1,17 +1,15 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ComponentType, ReactNode } from 'react';
3
- import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig, CmssyProduct, CmssyOrder } from '@cmssy/react';
3
+ import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig } from '@cmssy/react';
4
4
  export { DEFAULT_CMSSY_API_URL, FieldCondition, FieldConditionGroup, FieldConditionLogic, evaluateFieldConditionGroup, resolveApiUrl } from '@cmssy/react';
5
5
  import { EditBridgeConfig } from '@cmssy/react/client';
6
+ import { CmssyAuthConfig, CmssySessionPayload, SessionCookieOptions, CmssySessionUser, FetchProductOptions, CmssyProduct, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, CmssyOrder, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
7
+ export { CmssyAuthConfig, CmssyProductPage, CmssySessionPayload, CmssySessionUser, CmssyStockState, CmssyWebhookEvent, CmssyWebhookOrder, FetchOrderByTokenOptions, FetchProductOptions, FetchProductsOptions, MyOrdersResult, SessionCookieOptions, VerifyCmssyWebhookOptions } from '@cmssy/types';
6
8
  import { MetadataRoute, Metadata } from 'next';
7
9
  import { NextRequest, NextResponse } from 'next/server';
8
10
 
9
11
  declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
10
12
  declare function resolveEditorOrigin(editorOrigin: string | string[] | undefined): string | string[];
11
- interface CmssyAuthConfig {
12
- modelSlug: string;
13
- sessionSecret: string;
14
- }
15
13
  interface CmssyNextConfig {
16
14
  /**
17
15
  * Full GraphQL delivery endpoint. Defaults to the cmssy cloud endpoint
@@ -234,26 +232,9 @@ declare function createCmssyLocaleMiddleware(config: CmssyNextConfig): (request:
234
232
 
235
233
  declare const CMSSY_SESSION_COOKIE = "cmssy_session";
236
234
  declare const SESSION_MAX_AGE_SECONDS: number;
237
- interface CmssySessionUser {
238
- recordId: string;
239
- email: string;
240
- }
241
- interface CmssySessionPayload {
242
- accessToken: string;
243
- refreshToken: string;
244
- accessExpiresAt: number;
245
- user: CmssySessionUser;
246
- }
247
235
  declare function sealSession(payload: CmssySessionPayload, secret: string, audience?: string): Promise<string>;
248
236
  declare function openSession(token: string, secret: string, audience?: string): Promise<CmssySessionPayload | null>;
249
237
  declare function isAccessExpired(payload: CmssySessionPayload, now?: number): boolean;
250
- interface SessionCookieOptions {
251
- httpOnly: true;
252
- secure: boolean;
253
- sameSite: "lax";
254
- path: "/";
255
- maxAge: number;
256
- }
257
238
  declare function sessionCookieOptions(): SessionCookieOptions;
258
239
 
259
240
  interface CmssyAuthRouteHandlers {
@@ -286,38 +267,9 @@ declare function getCmssyAccessToken(config: CmssyNextConfig): Promise<string |
286
267
  type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
287
268
  declare function createCmssyAuthMiddleware(config: CmssyNextConfig): CmssyAuthMiddleware;
288
269
 
289
- type CmssyStockState = "in" | "low" | "out";
290
- interface FetchProductsOptions {
291
- modelSlug: string;
292
- filter?: Record<string, unknown>;
293
- /**
294
- * Availability facet: "in", "low" or "out". Stock is not a data field -
295
- * availability is onHand minus reserved, summed across variants - so it
296
- * cannot go through `filter`. The backend applies the same rule the admin
297
- * catalog uses, so this facet cannot contradict the stock badge.
298
- */
299
- stockState?: CmssyStockState;
300
- limit?: number;
301
- offset?: number;
302
- sort?: string;
303
- }
304
- interface CmssyProductPage {
305
- items: CmssyProduct[];
306
- total: number;
307
- hasMore: boolean;
308
- }
309
270
  declare function fetchProducts(config: CmssyNextConfig, options: FetchProductsOptions): Promise<CmssyProductPage>;
310
- interface FetchProductOptions {
311
- modelSlug: string;
312
- slug: string;
313
- slugField?: string;
314
- }
315
271
  declare function fetchProduct(config: CmssyNextConfig, options: FetchProductOptions): Promise<CmssyProduct | null>;
316
272
 
317
- interface FetchOrderByTokenOptions {
318
- orderId: string;
319
- accessToken: string;
320
- }
321
273
  declare function fetchOrderByToken(config: CmssyNextConfig, options: FetchOrderByTokenOptions): Promise<CmssyOrder>;
322
274
 
323
275
  interface CmssyOrdersRouteHandlers {
@@ -325,12 +277,6 @@ interface CmssyOrdersRouteHandlers {
325
277
  }
326
278
  declare function createCmssyOrdersRoute(config: CmssyNextConfig): CmssyOrdersRouteHandlers;
327
279
 
328
- interface MyOrdersResult {
329
- items: CmssyOrder[];
330
- total: number;
331
- hasMore: boolean;
332
- }
333
-
334
280
  /**
335
281
  * Verify + parse an inbound cmssy webhook (CMS-693 / CMS-694).
336
282
  *
@@ -343,46 +289,6 @@ interface MyOrdersResult {
343
289
  * IMPORTANT: pass the RAW request body string (e.g. `await req.text()`),
344
290
  * never a re-serialized object - the signed bytes must match exactly.
345
291
  */
346
- /** Serialized order carried in an order.* webhook (mirrors the backend). */
347
- interface CmssyWebhookOrder {
348
- id: string;
349
- workspaceId: string;
350
- displayStatus: string;
351
- paymentStatus: string;
352
- fulfillmentStatus: string;
353
- total: number;
354
- currency: string;
355
- customerId: string | null;
356
- customerEmail: string;
357
- paymentProvider: string | null;
358
- paymentReference: string | null;
359
- refundedAmount: number;
360
- createdAt: string;
361
- updatedAt: string;
362
- }
363
- interface CmssyWebhookEvent {
364
- /** Delivery id - also sent in X-Cmssy-Webhook-Id; dedup on it. */
365
- id: string;
366
- /** e.g. "order.paid", "order.refunded". */
367
- event: string;
368
- createdAt: string;
369
- data: {
370
- workspaceId: string;
371
- order: CmssyWebhookOrder;
372
- };
373
- }
374
- interface VerifyCmssyWebhookOptions {
375
- /** Raw request body string (NOT parsed JSON). */
376
- body: string;
377
- /** The `X-Cmssy-Signature` header value, or null if absent. */
378
- signatureHeader: string | null;
379
- /** The endpoint's signing secret. */
380
- secret: string;
381
- /** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
382
- toleranceSeconds?: number;
383
- /** Override the current time (ms) - for tests. */
384
- now?: number;
385
- }
386
292
  declare class CmssyWebhookError extends Error {
387
293
  constructor(message: string);
388
294
  }
@@ -393,4 +299,4 @@ declare class CmssyWebhookError extends Error {
393
299
  */
394
300
  declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
395
301
 
396
- export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyEnvConfig, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssyProductPage, type CmssySessionPayload, type CmssySessionUser, type CmssyStockState, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, type FetchOrderByTokenOptions, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, 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 };
302
+ export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, 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, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -55,10 +55,11 @@
55
55
  "tsup": "^8.3.0",
56
56
  "typescript": "^5.6.0",
57
57
  "vitest": "^2.1.0",
58
- "@cmssy/react": "2.4.0"
58
+ "@cmssy/react": "2.6.0"
59
59
  },
60
60
  "dependencies": {
61
- "jose": "^6.2.3"
61
+ "jose": "^6.2.3",
62
+ "@cmssy/types": "0.26.0"
62
63
  },
63
64
  "scripts": {
64
65
  "build": "tsup",