@cmssy/next 2.5.0 → 2.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/index.cjs CHANGED
@@ -1587,10 +1587,10 @@ function createCmssyAuthMiddleware(config) {
1587
1587
  return refreshed;
1588
1588
  };
1589
1589
  }
1590
- var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $limit: Int, $offset: Int, $sort: String) {
1590
+ var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $locale: String, $limit: Int, $offset: Int, $sort: String) {
1591
1591
  public {
1592
1592
  model {
1593
- records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, limit: $limit, offset: $offset, sort: $sort) {
1593
+ records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, locale: $locale, limit: $limit, offset: $offset, sort: $sort) {
1594
1594
  total
1595
1595
  hasMore
1596
1596
  items {
@@ -1603,8 +1603,16 @@ var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!,
1603
1603
  }
1604
1604
  }
1605
1605
  }`;
1606
+ async function requestLocale(config) {
1607
+ try {
1608
+ return await getCmssyLocale(config);
1609
+ } catch {
1610
+ return null;
1611
+ }
1612
+ }
1606
1613
  async function fetchProducts(config, options) {
1607
1614
  const workspaceId = await react.resolveWorkspaceId(config);
1615
+ const locale = options.locale ?? await requestLocale(config);
1608
1616
  const data = await react.graphqlRequest(
1609
1617
  config,
1610
1618
  PRODUCTS_QUERY,
@@ -1613,6 +1621,7 @@ async function fetchProducts(config, options) {
1613
1621
  modelSlug: options.modelSlug,
1614
1622
  filter: options.filter ?? {},
1615
1623
  stockState: options.stockState ?? null,
1624
+ locale,
1616
1625
  limit: options.limit ?? 50,
1617
1626
  offset: options.offset ?? 0,
1618
1627
  sort: options.sort ?? null
@@ -1626,6 +1635,7 @@ async function fetchProduct(config, options) {
1626
1635
  const page = await fetchProducts(config, {
1627
1636
  modelSlug: options.modelSlug,
1628
1637
  filter: { [options.slugField ?? "slug"]: options.slug },
1638
+ locale: options.locale,
1629
1639
  limit: 1
1630
1640
  });
1631
1641
  return page.items[0] ?? null;
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/dist/index.js CHANGED
@@ -1586,10 +1586,10 @@ function createCmssyAuthMiddleware(config) {
1586
1586
  return refreshed;
1587
1587
  };
1588
1588
  }
1589
- var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $limit: Int, $offset: Int, $sort: String) {
1589
+ var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $locale: String, $limit: Int, $offset: Int, $sort: String) {
1590
1590
  public {
1591
1591
  model {
1592
- records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, limit: $limit, offset: $offset, sort: $sort) {
1592
+ records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, locale: $locale, limit: $limit, offset: $offset, sort: $sort) {
1593
1593
  total
1594
1594
  hasMore
1595
1595
  items {
@@ -1602,8 +1602,16 @@ var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!,
1602
1602
  }
1603
1603
  }
1604
1604
  }`;
1605
+ async function requestLocale(config) {
1606
+ try {
1607
+ return await getCmssyLocale(config);
1608
+ } catch {
1609
+ return null;
1610
+ }
1611
+ }
1605
1612
  async function fetchProducts(config, options) {
1606
1613
  const workspaceId = await resolveWorkspaceId(config);
1614
+ const locale = options.locale ?? await requestLocale(config);
1607
1615
  const data = await graphqlRequest(
1608
1616
  config,
1609
1617
  PRODUCTS_QUERY,
@@ -1612,6 +1620,7 @@ async function fetchProducts(config, options) {
1612
1620
  modelSlug: options.modelSlug,
1613
1621
  filter: options.filter ?? {},
1614
1622
  stockState: options.stockState ?? null,
1623
+ locale,
1615
1624
  limit: options.limit ?? 50,
1616
1625
  offset: options.offset ?? 0,
1617
1626
  sort: options.sort ?? null
@@ -1625,6 +1634,7 @@ async function fetchProduct(config, options) {
1625
1634
  const page = await fetchProducts(config, {
1626
1635
  modelSlug: options.modelSlug,
1627
1636
  filter: { [options.slugField ?? "slug"]: options.slug },
1637
+ locale: options.locale,
1628
1638
  limit: 1
1629
1639
  });
1630
1640
  return page.items[0] ?? null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "2.5.0",
3
+ "version": "2.7.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.5.0"
58
+ "@cmssy/react": "2.7.0"
59
59
  },
60
60
  "dependencies": {
61
- "jose": "^6.2.3"
61
+ "jose": "^6.2.3",
62
+ "@cmssy/types": "0.27.0"
62
63
  },
63
64
  "scripts": {
64
65
  "build": "tsup",