@cmssy/next 2.1.0 → 2.2.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, $limit: Int, $offset: Int, $sort: String) {
1590
+ var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $limit: Int, $offset: Int, $sort: String) {
1591
1591
  public {
1592
1592
  model {
1593
- records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, limit: $limit, offset: $offset, sort: $sort) {
1593
+ records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, limit: $limit, offset: $offset, sort: $sort) {
1594
1594
  total
1595
1595
  hasMore
1596
1596
  items {
@@ -1612,6 +1612,7 @@ async function fetchProducts(config, options) {
1612
1612
  workspaceId,
1613
1613
  modelSlug: options.modelSlug,
1614
1614
  filter: options.filter ?? {},
1615
+ stockState: options.stockState ?? null,
1615
1616
  limit: options.limit ?? 50,
1616
1617
  offset: options.offset ?? 0,
1617
1618
  sort: options.sort ?? null
package/dist/index.d.cts CHANGED
@@ -286,9 +286,17 @@ declare function getCmssyAccessToken(config: CmssyNextConfig): Promise<string |
286
286
  type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
287
287
  declare function createCmssyAuthMiddleware(config: CmssyNextConfig): CmssyAuthMiddleware;
288
288
 
289
+ type CmssyStockState = "in" | "low" | "out";
289
290
  interface FetchProductsOptions {
290
291
  modelSlug: string;
291
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;
292
300
  limit?: number;
293
301
  offset?: number;
294
302
  sort?: string;
@@ -385,4 +393,4 @@ declare class CmssyWebhookError extends Error {
385
393
  */
386
394
  declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
387
395
 
388
- 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, 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -286,9 +286,17 @@ declare function getCmssyAccessToken(config: CmssyNextConfig): Promise<string |
286
286
  type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
287
287
  declare function createCmssyAuthMiddleware(config: CmssyNextConfig): CmssyAuthMiddleware;
288
288
 
289
+ type CmssyStockState = "in" | "low" | "out";
289
290
  interface FetchProductsOptions {
290
291
  modelSlug: string;
291
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;
292
300
  limit?: number;
293
301
  offset?: number;
294
302
  sort?: string;
@@ -385,4 +393,4 @@ declare class CmssyWebhookError extends Error {
385
393
  */
386
394
  declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
387
395
 
388
- 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, 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 };
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 };
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, $limit: Int, $offset: Int, $sort: String) {
1589
+ var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $limit: Int, $offset: Int, $sort: String) {
1590
1590
  public {
1591
1591
  model {
1592
- records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, limit: $limit, offset: $offset, sort: $sort) {
1592
+ records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, limit: $limit, offset: $offset, sort: $sort) {
1593
1593
  total
1594
1594
  hasMore
1595
1595
  items {
@@ -1611,6 +1611,7 @@ async function fetchProducts(config, options) {
1611
1611
  workspaceId,
1612
1612
  modelSlug: options.modelSlug,
1613
1613
  filter: options.filter ?? {},
1614
+ stockState: options.stockState ?? null,
1614
1615
  limit: options.limit ?? 50,
1615
1616
  offset: options.offset ?? 0,
1616
1617
  sort: options.sort ?? null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -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": "2.1.0"
58
+ "@cmssy/react": "2.2.0"
59
59
  },
60
60
  "dependencies": {
61
61
  "jose": "^6.2.3"