@01.software/sdk 0.22.0 → 0.24.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.
Files changed (44) hide show
  1. package/README.md +101 -71
  2. package/dist/analytics.cjs.map +1 -1
  3. package/dist/analytics.js.map +1 -1
  4. package/dist/const-CMdmNgEs.d.ts +34 -0
  5. package/dist/const-Cgd4op4V.d.cts +34 -0
  6. package/dist/index.cjs +50 -8
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +7 -7
  9. package/dist/index.d.ts +7 -7
  10. package/dist/index.js +50 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/{payload-types-DeLBmtzd.d.cts → payload-types-D8-G1PiT.d.cts} +129 -8
  13. package/dist/{payload-types-DeLBmtzd.d.ts → payload-types-D8-G1PiT.d.ts} +129 -8
  14. package/dist/realtime.cjs.map +1 -1
  15. package/dist/realtime.d.cts +2 -2
  16. package/dist/realtime.d.ts +2 -2
  17. package/dist/realtime.js.map +1 -1
  18. package/dist/{server-BARh_6zH.d.ts → server-D7FcHj7J.d.ts} +35 -12
  19. package/dist/{server-BcQr-nGn.d.cts → server-DJcDyOmM.d.cts} +35 -12
  20. package/dist/server.cjs +9 -1
  21. package/dist/server.cjs.map +1 -1
  22. package/dist/server.d.cts +4 -4
  23. package/dist/server.d.ts +4 -4
  24. package/dist/server.js +9 -1
  25. package/dist/server.js.map +1 -1
  26. package/dist/{types-D7iFEsPc.d.cts → types-BQqfXbB2.d.ts} +18 -2
  27. package/dist/{types-KkuKwsli.d.ts → types-C_kwEIvY.d.cts} +18 -2
  28. package/dist/ui/code-block.cjs.map +1 -1
  29. package/dist/ui/code-block.js.map +1 -1
  30. package/dist/ui/form.d.cts +1 -1
  31. package/dist/ui/form.d.ts +1 -1
  32. package/dist/ui/rich-text.cjs +170 -10
  33. package/dist/ui/rich-text.cjs.map +1 -1
  34. package/dist/ui/rich-text.d.cts +22 -3
  35. package/dist/ui/rich-text.d.ts +22 -3
  36. package/dist/ui/rich-text.js +165 -5
  37. package/dist/ui/rich-text.js.map +1 -1
  38. package/dist/ui/video.d.cts +1 -1
  39. package/dist/ui/video.d.ts +1 -1
  40. package/dist/webhook.d.cts +3 -3
  41. package/dist/webhook.d.ts +3 -3
  42. package/package.json +5 -4
  43. package/dist/const-CfcjPbOu.d.ts +0 -24
  44. package/dist/const-DraU44bA.d.cts +0 -24
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/query/realtime-hooks.ts","../src/core/query/realtime.ts","../src/core/client/types.ts","../src/core/query/query-keys.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { RealtimeConnection, type RealtimeEvent } from './realtime'\nimport { resolveApiUrl, type PublicCollection } from '../client/types'\nimport { collectionKeys } from './query-keys'\n\nexport type { RealtimeEvent }\n\nexport interface UseRealtimeQueryOptions {\n /** Filter events to specific collections. Empty/undefined = all collections. */\n collections?: PublicCollection[]\n /** Enable/disable the SSE connection. Default: true. */\n enabled?: boolean\n}\n\nexport interface UseRealtimeQueryResult {\n /** Whether the SSE connection is currently active. */\n connected: boolean\n /** The last received event, or null. */\n lastEvent: RealtimeEvent | null\n}\n\n/**\n * React hook that subscribes to real-time collection change events via SSE.\n * Automatically invalidates React Query cache when changes are detected.\n *\n * @example\n * ```tsx\n * const { connected } = useRealtimeQuery({\n * publishableKey: 'your-key',\n * getToken: () => client.customer.getToken(),\n * collections: ['products', 'orders'],\n * })\n * ```\n */\nexport function useRealtimeQuery(options: {\n publishableKey: string\n getToken: () => string | null\n collections?: PublicCollection[]\n enabled?: boolean\n}): UseRealtimeQueryResult {\n const { getToken, collections, enabled = true } = options\n const publishableKey = options.publishableKey\n const queryClient = useQueryClient()\n const [connected, setConnected] = useState(false)\n const [lastEvent, setLastEvent] = useState<RealtimeEvent | null>(null)\n const connectionRef = useRef<RealtimeConnection | null>(null)\n\n useEffect(() => {\n if (!enabled || !publishableKey) return\n\n const baseUrl = resolveApiUrl()\n const conn = new RealtimeConnection(\n baseUrl,\n publishableKey,\n getToken,\n collections,\n )\n connectionRef.current = conn\n\n // Listen for events and invalidate queries\n const removeListener = conn.addListener((event) => {\n setLastEvent(event)\n\n // Invalidate all queries for the changed collection\n const keys = collectionKeys(event.collection as PublicCollection)\n queryClient.invalidateQueries({ queryKey: keys.all })\n })\n\n // Track connection state\n const pollInterval = setInterval(() => {\n setConnected(conn.connected)\n }, 1000)\n\n conn.connect()\n\n return () => {\n conn.disconnect()\n removeListener()\n clearInterval(pollInterval)\n connectionRef.current = null\n setConnected(false)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [publishableKey, enabled, collections?.join(',')])\n\n return { connected, lastEvent }\n}\n","/**\n * Fetch-based SSE connection manager for real-time collection change events.\n * Uses fetch + ReadableStream to support custom auth headers (unlike native EventSource).\n */\n\nexport interface RealtimeEvent {\n collection: string\n operation: string\n id: string | null\n timestamp: string\n}\n\nexport type RealtimeListener = (event: RealtimeEvent) => void\n\nconst INITIAL_RECONNECT_DELAY = 1_000\nconst MAX_RECONNECT_DELAY = 30_000\nconst RECONNECT_BACKOFF_FACTOR = 2\nconst MAX_NO_TOKEN_RETRIES = 5\n\nexport class RealtimeConnection {\n private abortController: AbortController | null = null\n private reconnectAttempt = 0\n private noTokenAttempts = 0\n private reconnectTimer: ReturnType<typeof setTimeout> | null = null\n private listeners = new Set<RealtimeListener>()\n private _connected = false\n\n constructor(\n private baseUrl: string,\n private publishableKey: string,\n private getToken: () => string | null,\n private collections?: string[],\n ) {}\n\n get connected(): boolean {\n return this._connected\n }\n\n addListener(fn: RealtimeListener): () => void {\n this.listeners.add(fn)\n return () => this.listeners.delete(fn)\n }\n\n connect(): void {\n if (this.abortController) return // Already connecting/connected\n\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }\n\n disconnect(): void {\n this._connected = false\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer)\n this.reconnectTimer = null\n }\n if (this.abortController) {\n this.abortController.abort()\n this.abortController = null\n }\n this.reconnectAttempt = 0\n this.noTokenAttempts = 0\n }\n\n private async startStream(signal: AbortSignal): Promise<void> {\n const token = this.getToken()\n if (!token) {\n this.noTokenAttempts++\n if (this.noTokenAttempts >= MAX_NO_TOKEN_RETRIES) {\n // Stop reconnecting — no token available after multiple attempts\n this._connected = false\n this.abortController = null\n return\n }\n this.scheduleReconnect()\n return\n }\n this.noTokenAttempts = 0\n\n const params = this.collections?.length\n ? `?collections=${this.collections.join(',')}`\n : ''\n const url = `${this.baseUrl}/api/events/stream${params}`\n\n try {\n const response = await fetch(url, {\n headers: {\n 'X-Publishable-Key': this.publishableKey,\n Authorization: `Bearer ${token}`,\n },\n signal,\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n // Token expired — try reconnecting (will get fresh token)\n this.scheduleReconnect()\n return\n }\n throw new Error(`SSE connection failed: ${response.status}`)\n }\n\n if (!response.body) {\n throw new Error('SSE response has no body')\n }\n\n this._connected = true\n this.reconnectAttempt = 0\n\n await this.readStream(response.body, signal)\n } catch {\n if (signal.aborted) return // Intentional disconnect\n this._connected = false\n this.scheduleReconnect()\n }\n }\n\n private async readStream(\n body: ReadableStream<Uint8Array>,\n signal: AbortSignal,\n ): Promise<void> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let currentEvent = ''\n let currentData = ''\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done || signal.aborted) break\n\n buffer += decoder.decode(value, { stream: true })\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? '' // Keep incomplete last line in buffer\n\n for (const line of lines) {\n if (line.startsWith('event: ')) {\n currentEvent = line.slice(7)\n } else if (line.startsWith('data: ')) {\n currentData += (currentData ? '\\n' : '') + line.slice(6)\n } else if (line === '') {\n // Empty line = end of event\n if (currentEvent === 'collection:change' && currentData) {\n try {\n const event: RealtimeEvent = JSON.parse(currentData)\n for (const listener of this.listeners) {\n try {\n listener(event)\n } catch {\n // Listener error — ignore\n }\n }\n } catch {\n // Malformed JSON — ignore\n }\n }\n currentEvent = ''\n currentData = ''\n }\n // Ignore comment lines (: heartbeat)\n }\n }\n } catch {\n // Stream read error\n } finally {\n reader.releaseLock()\n this._connected = false\n if (!signal.aborted) {\n this.scheduleReconnect()\n }\n }\n }\n\n private scheduleReconnect(): void {\n if (this.reconnectTimer) return\n\n const delay = Math.min(\n INITIAL_RECONNECT_DELAY *\n Math.pow(RECONNECT_BACKOFF_FACTOR, this.reconnectAttempt),\n MAX_RECONNECT_DELAY,\n )\n this.reconnectAttempt++\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }, delay)\n }\n}\n","import type { Sort, Where } from 'payload'\n\nimport type { Collection, PublicCollection } from '../collection/const'\n\nexport type { Collection, PublicCollection }\n\n// ============================================================================\n// API URL Configuration\n// ============================================================================\n\ndeclare const __DEFAULT_API_URL__: string\n\nexport function resolveApiUrl(): string {\n if (typeof process !== 'undefined' && process.env) {\n const envUrl =\n process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL\n if (envUrl) {\n return envUrl.replace(/\\/$/, '')\n }\n }\n return __DEFAULT_API_URL__\n}\n\n// ============================================================================\n// Client Configuration\n// ============================================================================\n\nexport interface ClientConfig {\n publishableKey: string\n /**\n * Customer authentication options.\n * Used to initialize CustomerAuth on Client.\n */\n customer?: {\n /**\n * Persist token in localStorage. Defaults to `true`.\n * - `true` (default): uses key `'customer-token'`\n * - `string`: uses the given string as localStorage key\n * - `false`: disables persistence (token/onTokenChange used instead)\n *\n * Handles SSR safely (no-op on server).\n * When enabled, `token` and `onTokenChange` are ignored.\n */\n persist?: boolean | string\n /** Initial token (e.g. from SSR cookie) */\n token?: string\n /** Called when token changes (login/logout) — use to persist in localStorage/cookie */\n onTokenChange?: (token: string | null) => void\n }\n}\n\n// Server client: requires both publishableKey (for CDN routing + rate limit +\n// monthly quota enforcement via the edge proxy) and secretKey (sk01_ opaque\n// bearer token, the authentication credential).\n// The proxy keys its tenant lookup off `X-Publishable-Key`, so omitting\n// publishableKey would silently bypass rate limiting and plan-based quota\n// enforcement.\nexport interface ClientServerConfig extends ClientConfig {\n secretKey: string\n}\n\n\nexport interface ClientMetadata {\n userAgent?: string\n timestamp: number\n}\n\nexport interface ClientState {\n metadata: ClientMetadata\n}\n\nexport interface PaginationMeta {\n page: number\n limit: number\n totalDocs: number\n totalPages: number\n hasNextPage: boolean\n hasPrevPage: boolean\n pagingCounter: number\n prevPage: number | null\n nextPage: number | null\n}\n\n// ============================================================================\n// Payload CMS Native Response Types\n// ============================================================================\n\n/**\n * Payload CMS Find (List) Response\n * GET /api/{collection}\n */\nexport interface PayloadFindResponse<T = unknown> {\n docs: T[]\n totalDocs: number\n limit: number\n totalPages: number\n page: number\n pagingCounter: number\n hasPrevPage: boolean\n hasNextPage: boolean\n prevPage: number | null\n nextPage: number | null\n}\n\n/**\n * Payload CMS Create/Update Response\n * POST /api/{collection}\n * PATCH /api/{collection}/{id}\n */\nexport interface PayloadMutationResponse<T = unknown> {\n message: string\n doc: T\n errors?: unknown[]\n}\n\n// ============================================================================\n// Query Options\n// ============================================================================\n\n/**\n * Do NOT replace with `Pick<FindOptions>` from `payload`. Payload's generic\n * types (`JoinQuery<TSlug>`, `PopulateType`) depend on `PayloadTypes` module\n * augmentation; external SDK consumers who skip that get degenerate types\n * (`never` / `{}`). Only non-generic `Sort`/`Where` are safe to import.\n * Excluded vs native: Local-API-only fields, `locale`/`fallbackLocale`.\n */\nexport interface ApiQueryOptions {\n page?: number\n limit?: number\n sort?: Sort\n where?: Where\n depth?: number\n select?: Record<string, boolean>\n /** Per-collection field selection for populated relationships (keyed by collection slug) */\n populate?: Record<string, boolean | Record<string, boolean>>\n /** Join field control: pagination/filter per join, or false to disable */\n joins?:\n | Record<\n string,\n | {\n limit?: number\n page?: number\n sort?: string\n where?: Where\n count?: boolean\n }\n | false\n >\n | false\n /** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */\n pagination?: boolean\n /** Include draft versions (access control still applies on the server) */\n draft?: boolean\n /** Include soft-deleted documents (requires `trash` enabled on the collection) */\n trash?: boolean\n}\n\n// ============================================================================\n// Debug & Retry Configuration\n// ============================================================================\n\nexport interface DebugConfig {\n logRequests?: boolean\n logResponses?: boolean\n logErrors?: boolean\n}\n\nexport interface RetryConfig {\n maxRetries?: number\n retryableStatuses?: number[]\n retryDelay?: (attempt: number) => number\n}\n\n\n// ============================================================================\n// Type Utilities\n// ============================================================================\n\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]\n}\n\nexport type ExtractArrayType<T> = T extends (infer U)[] ? U : never\n","import type { PublicCollection, ApiQueryOptions } from '../client/types'\nimport type { ProductListingGroupsQueryOptions } from './query-hooks'\n\nexport function collectionKeys<T extends PublicCollection>(collection: T) {\n return {\n all: [collection] as const,\n lists: () => [collection, 'list'] as const,\n list: (options?: ApiQueryOptions) => [collection, 'list', options] as const,\n details: () => [collection, 'detail'] as const,\n detail: (id: string, options?: ApiQueryOptions) =>\n [collection, 'detail', id, options] as const,\n infinites: () => [collection, 'infinite'] as const,\n infinite: (options?: Omit<ApiQueryOptions, 'page'>) =>\n [collection, 'infinite', options] as const,\n }\n}\n\nexport const customerKeys = {\n all: ['customer'] as const,\n me: () => ['customer', 'me'] as const,\n}\n\nexport const productKeys = {\n listingGroups: (options?: ProductListingGroupsQueryOptions) =>\n ['products', 'listing-groups', 'list', options] as const,\n listingGroupsInfinite: (\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>,\n ) =>\n ['products', 'listing-groups', 'infinite', options] as const,\n}\n"],"mappings":";AAAA,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,sBAAsB;;;ACa/B,IAAM,0BAA0B;AAChC,IAAM,sBAAsB;AAC5B,IAAM,2BAA2B;AACjC,IAAM,uBAAuB;AAEtB,IAAM,qBAAN,MAAyB;AA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AY,YAAY,OAAO;AAAA,EACpC;AACF;;;AHoBO,SAAS,iBAAiB,SAKN;AACzB,QAAM,EAAE,UAAU,aAAa,UAAU,KAAK,IAAI;AAClD,QAAM,iBAAiB,QAAQ;AAC/B,QAAM,cAAc,eAAe;AACnC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,WAAW,YAAY,IAAI,SAA+B,IAAI;AACrE,QAAM,gBAAgB,OAAkC,IAAI;AAE5D,YAAU,MAAM;AACd,QAAI,CAAC,WAAW,CAAC,eAAgB;AAEjC,UAAM,UAAU,cAAc;AAC9B,UAAM,OAAO,IAAI;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,kBAAc,UAAU;AAGxB,UAAM,iBAAiB,KAAK,YAAY,CAAC,UAAU;AACjD,mBAAa,KAAK;AAGlB,YAAM,OAAO,eAAe,MAAM,UAA8B;AAChE,kBAAY,kBAAkB,EAAE,UAAU,KAAK,IAAI,CAAC;AAAA,IACtD,CAAC;AAGD,UAAM,eAAe,YAAY,MAAM;AACrC,mBAAa,KAAK,SAAS;AAAA,IAC7B,GAAG,GAAI;AAEP,SAAK,QAAQ;AAEb,WAAO,MAAM;AACX,WAAK,WAAW;AAChB,qBAAe;AACf,oBAAc,YAAY;AAC1B,oBAAc,UAAU;AACxB,mBAAa,KAAK;AAAA,IACpB;AAAA,EAEF,GAAG,CAAC,gBAAgB,SAAS,aAAa,KAAK,GAAG,CAAC,CAAC;AAEpD,SAAO,EAAE,WAAW,UAAU;AAChC;","names":[]}
1
+ {"version":3,"sources":["../src/core/query/realtime-hooks.ts","../src/core/query/realtime.ts","../src/core/client/types.ts","../src/core/query/query-keys.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { RealtimeConnection, type RealtimeEvent } from './realtime'\nimport { resolveApiUrl, type PublicCollection } from '../client/types'\nimport { collectionKeys } from './query-keys'\n\nexport type { RealtimeEvent }\n\nexport interface UseRealtimeQueryOptions {\n /** Filter events to specific collections. Empty/undefined = all collections. */\n collections?: PublicCollection[]\n /** Enable/disable the SSE connection. Default: true. */\n enabled?: boolean\n}\n\nexport interface UseRealtimeQueryResult {\n /** Whether the SSE connection is currently active. */\n connected: boolean\n /** The last received event, or null. */\n lastEvent: RealtimeEvent | null\n}\n\n/**\n * React hook that subscribes to real-time collection change events via SSE.\n * Automatically invalidates React Query cache when changes are detected.\n *\n * @example\n * ```tsx\n * const { connected } = useRealtimeQuery({\n * publishableKey: 'your-key',\n * getToken: () => client.customer.getToken(),\n * collections: ['products', 'orders'],\n * })\n * ```\n */\nexport function useRealtimeQuery(options: {\n publishableKey: string\n getToken: () => string | null\n collections?: PublicCollection[]\n enabled?: boolean\n}): UseRealtimeQueryResult {\n const { getToken, collections, enabled = true } = options\n const publishableKey = options.publishableKey\n const queryClient = useQueryClient()\n const [connected, setConnected] = useState(false)\n const [lastEvent, setLastEvent] = useState<RealtimeEvent | null>(null)\n const connectionRef = useRef<RealtimeConnection | null>(null)\n\n useEffect(() => {\n if (!enabled || !publishableKey) return\n\n const baseUrl = resolveApiUrl()\n const conn = new RealtimeConnection(\n baseUrl,\n publishableKey,\n getToken,\n collections,\n )\n connectionRef.current = conn\n\n // Listen for events and invalidate queries\n const removeListener = conn.addListener((event) => {\n setLastEvent(event)\n\n // Invalidate all queries for the changed collection\n const keys = collectionKeys(event.collection as PublicCollection)\n queryClient.invalidateQueries({ queryKey: keys.all })\n })\n\n // Track connection state\n const pollInterval = setInterval(() => {\n setConnected(conn.connected)\n }, 1000)\n\n conn.connect()\n\n return () => {\n conn.disconnect()\n removeListener()\n clearInterval(pollInterval)\n connectionRef.current = null\n setConnected(false)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [publishableKey, enabled, collections?.join(',')])\n\n return { connected, lastEvent }\n}\n","/**\n * Fetch-based SSE connection manager for real-time collection change events.\n * Uses fetch + ReadableStream to support custom auth headers (unlike native EventSource).\n */\n\nexport interface RealtimeEvent {\n collection: string\n operation: string\n id: string | null\n timestamp: string\n}\n\nexport type RealtimeListener = (event: RealtimeEvent) => void\n\nconst INITIAL_RECONNECT_DELAY = 1_000\nconst MAX_RECONNECT_DELAY = 30_000\nconst RECONNECT_BACKOFF_FACTOR = 2\nconst MAX_NO_TOKEN_RETRIES = 5\n\nexport class RealtimeConnection {\n private abortController: AbortController | null = null\n private reconnectAttempt = 0\n private noTokenAttempts = 0\n private reconnectTimer: ReturnType<typeof setTimeout> | null = null\n private listeners = new Set<RealtimeListener>()\n private _connected = false\n\n constructor(\n private baseUrl: string,\n private publishableKey: string,\n private getToken: () => string | null,\n private collections?: string[],\n ) {}\n\n get connected(): boolean {\n return this._connected\n }\n\n addListener(fn: RealtimeListener): () => void {\n this.listeners.add(fn)\n return () => this.listeners.delete(fn)\n }\n\n connect(): void {\n if (this.abortController) return // Already connecting/connected\n\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }\n\n disconnect(): void {\n this._connected = false\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer)\n this.reconnectTimer = null\n }\n if (this.abortController) {\n this.abortController.abort()\n this.abortController = null\n }\n this.reconnectAttempt = 0\n this.noTokenAttempts = 0\n }\n\n private async startStream(signal: AbortSignal): Promise<void> {\n const token = this.getToken()\n if (!token) {\n this.noTokenAttempts++\n if (this.noTokenAttempts >= MAX_NO_TOKEN_RETRIES) {\n // Stop reconnecting — no token available after multiple attempts\n this._connected = false\n this.abortController = null\n return\n }\n this.scheduleReconnect()\n return\n }\n this.noTokenAttempts = 0\n\n const params = this.collections?.length\n ? `?collections=${this.collections.join(',')}`\n : ''\n const url = `${this.baseUrl}/api/events/stream${params}`\n\n try {\n const response = await fetch(url, {\n headers: {\n 'X-Publishable-Key': this.publishableKey,\n Authorization: `Bearer ${token}`,\n },\n signal,\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n // Token expired — try reconnecting (will get fresh token)\n this.scheduleReconnect()\n return\n }\n throw new Error(`SSE connection failed: ${response.status}`)\n }\n\n if (!response.body) {\n throw new Error('SSE response has no body')\n }\n\n this._connected = true\n this.reconnectAttempt = 0\n\n await this.readStream(response.body, signal)\n } catch {\n if (signal.aborted) return // Intentional disconnect\n this._connected = false\n this.scheduleReconnect()\n }\n }\n\n private async readStream(\n body: ReadableStream<Uint8Array>,\n signal: AbortSignal,\n ): Promise<void> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let currentEvent = ''\n let currentData = ''\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done || signal.aborted) break\n\n buffer += decoder.decode(value, { stream: true })\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? '' // Keep incomplete last line in buffer\n\n for (const line of lines) {\n if (line.startsWith('event: ')) {\n currentEvent = line.slice(7)\n } else if (line.startsWith('data: ')) {\n currentData += (currentData ? '\\n' : '') + line.slice(6)\n } else if (line === '') {\n // Empty line = end of event\n if (currentEvent === 'collection:change' && currentData) {\n try {\n const event: RealtimeEvent = JSON.parse(currentData)\n for (const listener of this.listeners) {\n try {\n listener(event)\n } catch {\n // Listener error — ignore\n }\n }\n } catch {\n // Malformed JSON — ignore\n }\n }\n currentEvent = ''\n currentData = ''\n }\n // Ignore comment lines (: heartbeat)\n }\n }\n } catch {\n // Stream read error\n } finally {\n reader.releaseLock()\n this._connected = false\n if (!signal.aborted) {\n this.scheduleReconnect()\n }\n }\n }\n\n private scheduleReconnect(): void {\n if (this.reconnectTimer) return\n\n const delay = Math.min(\n INITIAL_RECONNECT_DELAY *\n Math.pow(RECONNECT_BACKOFF_FACTOR, this.reconnectAttempt),\n MAX_RECONNECT_DELAY,\n )\n this.reconnectAttempt++\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }, delay)\n }\n}\n","import type { Sort, Where } from 'payload'\n\nimport type {\n Collection,\n PublicCollection,\n ServerCollection,\n ServerOnlyCollection,\n} from '../collection/const'\n\nexport type {\n Collection,\n PublicCollection,\n ServerCollection,\n ServerOnlyCollection,\n}\n\n// ============================================================================\n// API URL Configuration\n// ============================================================================\n\ndeclare const __DEFAULT_API_URL__: string\n\nexport function resolveApiUrl(): string {\n if (typeof process !== 'undefined' && process.env) {\n const envUrl =\n process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL\n if (envUrl) {\n return envUrl.replace(/\\/$/, '')\n }\n }\n return __DEFAULT_API_URL__\n}\n\n// ============================================================================\n// Client Configuration\n// ============================================================================\n\nexport interface ClientConfig {\n publishableKey: string\n /**\n * Customer authentication options.\n * Used to initialize CustomerAuth on Client.\n */\n customer?: {\n /**\n * Persist token in localStorage. Defaults to `true`.\n * - `true` (default): uses key `'customer-token'`\n * - `string`: uses the given string as localStorage key\n * - `false`: disables persistence (token/onTokenChange used instead)\n *\n * Handles SSR safely (no-op on server).\n * When enabled, `token` and `onTokenChange` are ignored.\n */\n persist?: boolean | string\n /** Initial token (e.g. from SSR cookie) */\n token?: string\n /** Called when token changes (login/logout) — use to persist in localStorage/cookie */\n onTokenChange?: (token: string | null) => void\n }\n}\n\n// Server client: requires both publishableKey (for CDN routing + rate limit +\n// monthly quota enforcement via the edge proxy) and secretKey (sk01_ opaque\n// bearer token, the authentication credential).\n// The proxy keys its tenant lookup off `X-Publishable-Key`, so omitting\n// publishableKey would silently bypass rate limiting and plan-based quota\n// enforcement.\nexport interface ClientServerConfig extends ClientConfig {\n secretKey: string\n}\n\nexport interface ClientMetadata {\n userAgent?: string\n timestamp: number\n}\n\nexport interface ClientState {\n metadata: ClientMetadata\n}\n\nexport interface PaginationMeta {\n page: number\n limit: number\n totalDocs: number\n totalPages: number\n hasNextPage: boolean\n hasPrevPage: boolean\n pagingCounter: number\n prevPage: number | null\n nextPage: number | null\n}\n\n// ============================================================================\n// Payload CMS Native Response Types\n// ============================================================================\n\n/**\n * Payload CMS Find (List) Response\n * GET /api/{collection}\n */\nexport interface PayloadFindResponse<T = unknown> {\n docs: T[]\n totalDocs: number\n limit: number\n totalPages: number\n page: number\n pagingCounter: number\n hasPrevPage: boolean\n hasNextPage: boolean\n prevPage: number | null\n nextPage: number | null\n}\n\n/**\n * Payload CMS Create/Update Response\n * POST /api/{collection}\n * PATCH /api/{collection}/{id}\n */\nexport interface PayloadMutationResponse<T = unknown> {\n message: string\n doc: T\n errors?: unknown[]\n}\n\n// ============================================================================\n// Query Options\n// ============================================================================\n\n/**\n * Do NOT replace with `Pick<FindOptions>` from `payload`. Payload's generic\n * types (`JoinQuery<TSlug>`, `PopulateType`) depend on `PayloadTypes` module\n * augmentation; external SDK consumers who skip that get degenerate types\n * (`never` / `{}`). Only non-generic `Sort`/`Where` are safe to import.\n * Excluded vs native: Local-API-only fields, `locale`/`fallbackLocale`.\n */\nexport interface ApiQueryOptions {\n page?: number\n limit?: number\n sort?: Sort\n where?: Where\n depth?: number\n select?: Record<string, boolean>\n /** Per-collection field selection for populated relationships (keyed by collection slug) */\n populate?: Record<string, boolean | Record<string, boolean>>\n /** Join field control: pagination/filter per join, or false to disable */\n joins?:\n | Record<\n string,\n | {\n limit?: number\n page?: number\n sort?: string\n where?: Where\n count?: boolean\n }\n | false\n >\n | false\n /** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */\n pagination?: boolean\n /** Include draft versions (access control still applies on the server) */\n draft?: boolean\n /** Include soft-deleted documents (requires `trash` enabled on the collection) */\n trash?: boolean\n}\n\n// ============================================================================\n// Debug & Retry Configuration\n// ============================================================================\n\nexport interface DebugConfig {\n logRequests?: boolean\n logResponses?: boolean\n logErrors?: boolean\n}\n\nexport interface RetryConfig {\n maxRetries?: number\n retryableStatuses?: number[]\n retryDelay?: (attempt: number) => number\n}\n\n// ============================================================================\n// Type Utilities\n// ============================================================================\n\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]\n}\n\nexport type ExtractArrayType<T> = T extends (infer U)[] ? U : never\n","import type { PublicCollection, ApiQueryOptions } from '../client/types'\nimport type { ProductListingGroupsQueryOptions } from './query-hooks'\n\nexport function collectionKeys<T extends PublicCollection>(collection: T) {\n return {\n all: [collection] as const,\n lists: () => [collection, 'list'] as const,\n list: (options?: ApiQueryOptions) => [collection, 'list', options] as const,\n details: () => [collection, 'detail'] as const,\n detail: (id: string, options?: ApiQueryOptions) =>\n [collection, 'detail', id, options] as const,\n infinites: () => [collection, 'infinite'] as const,\n infinite: (options?: Omit<ApiQueryOptions, 'page'>) =>\n [collection, 'infinite', options] as const,\n }\n}\n\nexport const customerKeys = {\n all: ['customer'] as const,\n me: () => ['customer', 'me'] as const,\n}\n\nexport const productKeys = {\n listingGroups: (options?: ProductListingGroupsQueryOptions) =>\n ['products', 'listing-groups', 'list', options] as const,\n listingGroupsInfinite: (\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>,\n ) =>\n ['products', 'listing-groups', 'infinite', options] as const,\n}\n"],"mappings":";AAAA,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,sBAAsB;;;ACa/B,IAAM,0BAA0B;AAChC,IAAM,sBAAsB;AAC5B,IAAM,2BAA2B;AACjC,IAAM,uBAAuB;AAEtB,IAAM,qBAAN,MAAyB;AAAA,EAQ9B,YACU,SACA,gBACA,UACA,aACR;AAJQ;AACA;AACA;AACA;AAXV,SAAQ,kBAA0C;AAClD,SAAQ,mBAAmB;AAC3B,SAAQ,kBAAkB;AAC1B,SAAQ,iBAAuD;AAC/D,SAAQ,YAAY,oBAAI,IAAsB;AAC9C,SAAQ,aAAa;AAAA,EAOlB;AAAA,EAEH,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,IAAkC;AAC5C,SAAK,UAAU,IAAI,EAAE;AACrB,WAAO,MAAM,KAAK,UAAU,OAAO,EAAE;AAAA,EACvC;AAAA,EAEA,UAAgB;AACd,QAAI,KAAK,gBAAiB;AAE1B,SAAK,kBAAkB,IAAI,gBAAgB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,kBAAc,UAAU;AAGxB,UAAM,iBAAiB,KAAK,YAAY,CAAC,UAAU;AACjD,mBAAa,KAAK;AAGlB,YAAM,OAAO,eAAe,MAAM,UAA8B;AAChE,kBAAY,kBAAkB,EAAE,UAAU,KAAK,IAAI,CAAC;AAAA,IACtD,CAAC;AAGD,UAAM,eAAe,YAAY,MAAM;AACrC,mBAAa,KAAK,SAAS;AAAA,IAC7B,GAAG,GAAI;AAEP,SAAK,QAAQ;AAEb,WAAO,MAAM;AACX,WAAK,WAAW;AAChB,qBAAe;AACf,oBAAc,YAAY;AAC1B,oBAAc,UAAU;AACxB,mBAAa,KAAK;AAAA,IACpB;AAAA,EAEF,GAAG,CAAC,gBAAgB,SAAS,aAAa,KAAK,GAAG,CAAC,CAAC;AAEpD,SAAO,EAAE,WAAW,UAAU;AAChC;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient, InfiniteData } from '@tanstack/react-query';
3
- import { O as Order, c as Cart, d as CartItem, e as Product, k as OrderItem, l as Transaction, m as Fulfillment, n as Return } from './payload-types-DeLBmtzd.js';
3
+ import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-D8-G1PiT.js';
4
4
  import { Sort, Where } from 'payload';
5
5
  import { Metadata } from 'next';
6
- import { C as CollectionType } from './types-KkuKwsli.js';
7
- import { P as PublicCollection } from './const-CfcjPbOu.js';
6
+ import { C as CollectionType } from './types-BQqfXbB2.js';
7
+ import { P as PublicCollection, S as ServerCollection } from './const-CMdmNgEs.js';
8
8
 
9
9
  declare function resolveApiUrl(): string;
10
10
  interface ClientConfig {
@@ -271,8 +271,8 @@ declare class HttpClient {
271
271
  protected parseDocumentResponse<T>(response: Response): Promise<T>;
272
272
  }
273
273
 
274
- declare class CollectionClient extends HttpClient {
275
- from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
274
+ declare class CollectionClient<TCollection extends string = PublicCollection> extends HttpClient {
275
+ from<T extends TCollection>(collection: T): CollectionQueryBuilder<T>;
276
276
  /**
277
277
  * Find documents (list query)
278
278
  * GET /api/{collection}
@@ -336,6 +336,9 @@ declare class CollectionClient extends HttpClient {
336
336
  */
337
337
  requestUpdateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
338
338
  }
339
+ declare class ServerCollectionClient extends CollectionClient<ServerCollection> {
340
+ from<T extends ServerCollection>(collection: T): ServerCollectionQueryBuilder<T>;
341
+ }
339
342
  declare class ReadOnlyCollectionClient extends HttpClient {
340
343
  from<T extends PublicCollection>(collection: T): ReadOnlyQueryBuilder<T>;
341
344
  requestFind<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<PayloadFindResponse<T>>;
@@ -363,7 +366,7 @@ declare class ReadOnlyCollectionQueryBuilder<T extends PublicCollection> {
363
366
  findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
364
367
  findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
365
368
  }
366
- declare class CollectionQueryBuilder<T extends PublicCollection> {
369
+ declare class CollectionQueryBuilder<T extends string> {
367
370
  private api;
368
371
  private collection;
369
372
  constructor(api: CollectionClient, collection: T);
@@ -436,6 +439,8 @@ declare class CollectionQueryBuilder<T extends PublicCollection> {
436
439
  */
437
440
  removeMany(where: ApiQueryOptions['where']): Promise<PayloadFindResponse<CollectionType<T>>>;
438
441
  }
442
+ declare class ServerCollectionQueryBuilder<T extends ServerCollection> extends CollectionQueryBuilder<T> {
443
+ }
439
444
 
440
445
  interface CommunityClientOptions {
441
446
  publishableKey?: string;
@@ -446,8 +451,9 @@ interface CommunityClientOptions {
446
451
  }
447
452
  interface CommunityPost {
448
453
  id: string;
449
- title: string;
450
- content: unknown;
454
+ title?: string | null;
455
+ displayTitle?: string | null;
456
+ content?: unknown;
451
457
  categories?: string[];
452
458
  thumbnail?: string;
453
459
  viewCount?: number;
@@ -513,8 +519,8 @@ declare class CommunityClient {
513
519
  private buildQuery;
514
520
  private execute;
515
521
  createPost(params: {
516
- title: string;
517
- content: unknown;
522
+ title?: string | null;
523
+ content?: unknown;
518
524
  categories?: string[];
519
525
  thumbnail?: string;
520
526
  }): Promise<CommunityPost>;
@@ -852,6 +858,9 @@ interface ProductOptionValueShape {
852
858
  option?: RelationshipValue;
853
859
  value?: string | null;
854
860
  slug?: string | null;
861
+ swatchColor?: string | null;
862
+ thumbnail?: MediaValue;
863
+ images?: MediaValue[] | null;
855
864
  _order?: string | null;
856
865
  '_product-option-values_values_order'?: string | null;
857
866
  }
@@ -870,6 +879,7 @@ interface ProductVariantShape {
870
879
  price?: number | null;
871
880
  compareAtPrice?: number | null;
872
881
  stock?: number | null;
882
+ reservedStock?: number | null;
873
883
  isUnlimited?: boolean | null;
874
884
  isActive?: boolean | null;
875
885
  thumbnail?: MediaValue;
@@ -886,6 +896,9 @@ type ProductOptionMatrixValue = {
886
896
  optionId: string;
887
897
  label: string;
888
898
  slug: string | null;
899
+ swatchColor?: string | null;
900
+ thumbnail?: MediaValue;
901
+ images?: MediaValue[] | null;
889
902
  order: string;
890
903
  };
891
904
  type ProductOptionMatrixOption = {
@@ -924,6 +937,9 @@ type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantSh
924
937
  optionValueId: EntityID;
925
938
  optionValueLabel: string;
926
939
  optionValueSlug: string | null;
940
+ optionValueSwatchColor?: string | null;
941
+ optionValueThumbnail?: MediaValue;
942
+ optionValueImages?: MediaValue[] | null;
927
943
  variantIds: EntityID[];
928
944
  variantCount: number;
929
945
  variants: TVariant[];
@@ -938,6 +954,13 @@ declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape
938
954
  declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
939
955
  declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
940
956
  declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
957
+ /**
958
+ * Builds product-first listing groups for one primary option.
959
+ *
960
+ * The returned groups are intended for product cards with nested swatches or
961
+ * option-value sections. They do not make a product-paginated API response into
962
+ * an expanded-card paginator; one product can still emit several groups.
963
+ */
941
964
  declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
942
965
  product: ProductListingProductShape | null | undefined;
943
966
  options: ProductOptionShape[];
@@ -1379,7 +1402,7 @@ declare class ServerClient {
1379
1402
  };
1380
1403
  };
1381
1404
  query: QueryHooks;
1382
- collections: CollectionClient;
1405
+ collections: ServerCollectionClient;
1383
1406
  queryClient: QueryClient;
1384
1407
  lastRequestId: string | null;
1385
1408
  protected state: ClientState;
@@ -1394,4 +1417,4 @@ declare class ServerClient {
1394
1417
  */
1395
1418
  declare function createServerClient(options: ClientServerConfig): ServerClient;
1396
1419
 
1397
- export { isPermissionError as $, type AddItemParams as A, PermissionError as B, CustomerAuth as C, type DeepPartial as D, type ExtractArrayType as E, NotFoundError as F, GoneError as G, ConflictError as H, RateLimitError as I, isSDKError as J, isNetworkError as K, type ListingGroupsParams as L, isValidationError as M, NetworkError as N, isApiError as O, type ProductListingGroupsResponse as P, isConfigError as Q, type RemoveItemParams as R, type StockCheckParams as S, TimeoutError as T, type UpdateItemParams as U, type ValidateDiscountParams as V, isTimeoutError as W, isGoneError as X, isServiceUnavailableError as Y, isUsageLimitError as Z, isAuthError as _, type CustomerAuthOptions as a, type UpdateProfileData as a$, isNotFoundError as a0, isConflictError as a1, isRateLimitError as a2, createAuthError as a3, createPermissionError as a4, createNotFoundError as a5, createConflictError as a6, createRateLimitError as a7, createServerClient as a8, ServerClient as a9, type ShippingApiOptions as aA, CartApi as aB, type CartApiOptions as aC, ProductApi as aD, type ProductApiOptions as aE, type ProductListingGroupSummary as aF, type ProductListingGroupsItem as aG, type StockCheckResult as aH, CollectionQueryBuilder as aI, type ReadOnlyQueryBuilder as aJ, CollectionClient as aK, type GenerateMetadataOptions as aL, ServerCommerceClient as aM, type ServerCommerceClientOptions as aN, type CommunityClientOptions as aO, type CommunityPost as aP, ModerationApi as aQ, type ModerationApiOptions as aR, type CommunityBan as aS, type BanCustomerParams as aT, type UnbanCustomerParams as aU, type CustomerAuthResponse as aV, type CustomerRefreshResponse as aW, type CustomerRegisterResponse as aX, type CustomerProfile as aY, type CustomerRegisterData as aZ, type CustomerLoginData as a_, resolveApiUrl as aa, type ClientServerConfig as ab, type ClientMetadata as ac, type PaginationMeta as ad, type PayloadMutationResponse as ae, BaseApi as af, type ServerApiOptions as ag, type RequestOptions as ah, OrderApi as ai, type OrderApiOptions as aj, type CustomerSnapshot as ak, type ReturnReason as al, type ReturnItem as am, type CreateOrderParams as an, type UpdateOrderParams as ao, type BulkImportFulfillmentsParams as ap, type BulkImportFulfillmentsResponse as aq, type CreateReturnParams as ar, type UpdateReturnParams as as, type UpdateTransactionParams as at, type CreateFulfillmentParams as au, type ReturnWithRefundParams as av, type UpdateFulfillmentParams as aw, DiscountApi as ax, type DiscountApiOptions as ay, ShippingApi as az, type StockCheckResponse as b, type CollectionQueryParams as b0, type CollectionDetailQueryParams as b1, type CollectionInfiniteQueryParams as b2, type QueryOptions as b3, type SuspenseQueryOptions as b4, type InfiniteQueryOptions as b5, type SuspenseInfiniteQueryOptions as b6, CollectionHooks as b7, CustomerHooks as b8, QueryHooks as b9, type ProductOptionValueShape as ba, type ProductOptionShape as bb, type ProductVariantShape as bc, type ProductListingProductShape as bd, type ProductOptionMatrixValue as be, type ProductOptionMatrixOption as bf, type ProductOptionMatrixVariant as bg, type ProductOptionMatrix as bh, type ProductListingProjection as bi, type ProductListingGroup as bj, buildProductOptionMatrix as bk, getSelectedValueByOptionId as bl, normalizeSelectedValueIds as bm, getAvailableOptionValues as bn, resolveVariantForSelection as bo, buildProductListingProjection as bp, buildProductListingGroupsByOption as bq, type ApplyDiscountParams as c, type RemoveDiscountParams as d, type ClearCartParams as e, type CheckoutParams as f, type PayloadFindResponse as g, type ValidateDiscountResult as h, type CalculateShippingParams as i, type CalculateShippingResult as j, type ApiQueryOptions as k, type ProductListingGroupsQueryOptions as l, type ClientConfig as m, CommunityClient as n, type ReadOnlyQueryHooks as o, ReadOnlyCollectionClient as p, type ClientState as q, type DebugConfig as r, type RetryConfig as s, SDKError as t, ValidationError as u, ApiError as v, ConfigError as w, ServiceUnavailableError as x, UsageLimitError as y, AuthError as z };
1420
+ export { isPermissionError as $, type AddItemParams as A, PermissionError as B, CustomerAuth as C, type DeepPartial as D, type ExtractArrayType as E, NotFoundError as F, GoneError as G, ConflictError as H, RateLimitError as I, isSDKError as J, isNetworkError as K, type ListingGroupsParams as L, isValidationError as M, NetworkError as N, isApiError as O, type ProductListingGroupsResponse as P, isConfigError as Q, type RemoveItemParams as R, type StockCheckParams as S, TimeoutError as T, type UpdateItemParams as U, type ValidateDiscountParams as V, isTimeoutError as W, isGoneError as X, isServiceUnavailableError as Y, isUsageLimitError as Z, isAuthError as _, type CustomerAuthOptions as a, type CustomerRegisterData as a$, isNotFoundError as a0, isConflictError as a1, isRateLimitError as a2, createAuthError as a3, createPermissionError as a4, createNotFoundError as a5, createConflictError as a6, createRateLimitError as a7, createServerClient as a8, ServerClient as a9, type ShippingApiOptions as aA, CartApi as aB, type CartApiOptions as aC, ProductApi as aD, type ProductApiOptions as aE, type ProductListingGroupSummary as aF, type ProductListingGroupsItem as aG, type StockCheckResult as aH, CollectionQueryBuilder as aI, ServerCollectionQueryBuilder as aJ, type ReadOnlyQueryBuilder as aK, CollectionClient as aL, ServerCollectionClient as aM, type GenerateMetadataOptions as aN, ServerCommerceClient as aO, type ServerCommerceClientOptions as aP, type CommunityClientOptions as aQ, type CommunityPost as aR, ModerationApi as aS, type ModerationApiOptions as aT, type CommunityBan as aU, type BanCustomerParams as aV, type UnbanCustomerParams as aW, type CustomerAuthResponse as aX, type CustomerRefreshResponse as aY, type CustomerRegisterResponse as aZ, type CustomerProfile as a_, resolveApiUrl as aa, type ClientServerConfig as ab, type ClientMetadata as ac, type PaginationMeta as ad, type PayloadMutationResponse as ae, BaseApi as af, type ServerApiOptions as ag, type RequestOptions as ah, OrderApi as ai, type OrderApiOptions as aj, type CustomerSnapshot as ak, type ReturnReason as al, type ReturnItem as am, type CreateOrderParams as an, type UpdateOrderParams as ao, type BulkImportFulfillmentsParams as ap, type BulkImportFulfillmentsResponse as aq, type CreateReturnParams as ar, type UpdateReturnParams as as, type UpdateTransactionParams as at, type CreateFulfillmentParams as au, type ReturnWithRefundParams as av, type UpdateFulfillmentParams as aw, DiscountApi as ax, type DiscountApiOptions as ay, ShippingApi as az, type StockCheckResponse as b, type CustomerLoginData as b0, type UpdateProfileData as b1, type CollectionQueryParams as b2, type CollectionDetailQueryParams as b3, type CollectionInfiniteQueryParams as b4, type QueryOptions as b5, type SuspenseQueryOptions as b6, type InfiniteQueryOptions as b7, type SuspenseInfiniteQueryOptions as b8, CollectionHooks as b9, CustomerHooks as ba, QueryHooks as bb, type ProductOptionValueShape as bc, type ProductOptionShape as bd, type ProductVariantShape as be, type ProductListingProductShape as bf, type ProductOptionMatrixValue as bg, type ProductOptionMatrixOption as bh, type ProductOptionMatrixVariant as bi, type ProductOptionMatrix as bj, type ProductListingProjection as bk, type ProductListingGroup as bl, buildProductOptionMatrix as bm, getSelectedValueByOptionId as bn, normalizeSelectedValueIds as bo, getAvailableOptionValues as bp, resolveVariantForSelection as bq, buildProductListingProjection as br, buildProductListingGroupsByOption as bs, type ApplyDiscountParams as c, type RemoveDiscountParams as d, type ClearCartParams as e, type CheckoutParams as f, type PayloadFindResponse as g, type ValidateDiscountResult as h, type CalculateShippingParams as i, type CalculateShippingResult as j, type ApiQueryOptions as k, type ProductListingGroupsQueryOptions as l, type ClientConfig as m, CommunityClient as n, type ReadOnlyQueryHooks as o, ReadOnlyCollectionClient as p, type ClientState as q, type DebugConfig as r, type RetryConfig as s, SDKError as t, ValidationError as u, ApiError as v, ConfigError as w, ServiceUnavailableError as x, UsageLimitError as y, AuthError as z };
@@ -1,10 +1,10 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient, InfiniteData } from '@tanstack/react-query';
3
- import { O as Order, c as Cart, d as CartItem, e as Product, k as OrderItem, l as Transaction, m as Fulfillment, n as Return } from './payload-types-DeLBmtzd.cjs';
3
+ import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-D8-G1PiT.cjs';
4
4
  import { Sort, Where } from 'payload';
5
5
  import { Metadata } from 'next';
6
- import { C as CollectionType } from './types-D7iFEsPc.cjs';
7
- import { P as PublicCollection } from './const-DraU44bA.cjs';
6
+ import { C as CollectionType } from './types-C_kwEIvY.cjs';
7
+ import { P as PublicCollection, S as ServerCollection } from './const-Cgd4op4V.cjs';
8
8
 
9
9
  declare function resolveApiUrl(): string;
10
10
  interface ClientConfig {
@@ -271,8 +271,8 @@ declare class HttpClient {
271
271
  protected parseDocumentResponse<T>(response: Response): Promise<T>;
272
272
  }
273
273
 
274
- declare class CollectionClient extends HttpClient {
275
- from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
274
+ declare class CollectionClient<TCollection extends string = PublicCollection> extends HttpClient {
275
+ from<T extends TCollection>(collection: T): CollectionQueryBuilder<T>;
276
276
  /**
277
277
  * Find documents (list query)
278
278
  * GET /api/{collection}
@@ -336,6 +336,9 @@ declare class CollectionClient extends HttpClient {
336
336
  */
337
337
  requestUpdateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
338
338
  }
339
+ declare class ServerCollectionClient extends CollectionClient<ServerCollection> {
340
+ from<T extends ServerCollection>(collection: T): ServerCollectionQueryBuilder<T>;
341
+ }
339
342
  declare class ReadOnlyCollectionClient extends HttpClient {
340
343
  from<T extends PublicCollection>(collection: T): ReadOnlyQueryBuilder<T>;
341
344
  requestFind<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<PayloadFindResponse<T>>;
@@ -363,7 +366,7 @@ declare class ReadOnlyCollectionQueryBuilder<T extends PublicCollection> {
363
366
  findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
364
367
  findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
365
368
  }
366
- declare class CollectionQueryBuilder<T extends PublicCollection> {
369
+ declare class CollectionQueryBuilder<T extends string> {
367
370
  private api;
368
371
  private collection;
369
372
  constructor(api: CollectionClient, collection: T);
@@ -436,6 +439,8 @@ declare class CollectionQueryBuilder<T extends PublicCollection> {
436
439
  */
437
440
  removeMany(where: ApiQueryOptions['where']): Promise<PayloadFindResponse<CollectionType<T>>>;
438
441
  }
442
+ declare class ServerCollectionQueryBuilder<T extends ServerCollection> extends CollectionQueryBuilder<T> {
443
+ }
439
444
 
440
445
  interface CommunityClientOptions {
441
446
  publishableKey?: string;
@@ -446,8 +451,9 @@ interface CommunityClientOptions {
446
451
  }
447
452
  interface CommunityPost {
448
453
  id: string;
449
- title: string;
450
- content: unknown;
454
+ title?: string | null;
455
+ displayTitle?: string | null;
456
+ content?: unknown;
451
457
  categories?: string[];
452
458
  thumbnail?: string;
453
459
  viewCount?: number;
@@ -513,8 +519,8 @@ declare class CommunityClient {
513
519
  private buildQuery;
514
520
  private execute;
515
521
  createPost(params: {
516
- title: string;
517
- content: unknown;
522
+ title?: string | null;
523
+ content?: unknown;
518
524
  categories?: string[];
519
525
  thumbnail?: string;
520
526
  }): Promise<CommunityPost>;
@@ -852,6 +858,9 @@ interface ProductOptionValueShape {
852
858
  option?: RelationshipValue;
853
859
  value?: string | null;
854
860
  slug?: string | null;
861
+ swatchColor?: string | null;
862
+ thumbnail?: MediaValue;
863
+ images?: MediaValue[] | null;
855
864
  _order?: string | null;
856
865
  '_product-option-values_values_order'?: string | null;
857
866
  }
@@ -870,6 +879,7 @@ interface ProductVariantShape {
870
879
  price?: number | null;
871
880
  compareAtPrice?: number | null;
872
881
  stock?: number | null;
882
+ reservedStock?: number | null;
873
883
  isUnlimited?: boolean | null;
874
884
  isActive?: boolean | null;
875
885
  thumbnail?: MediaValue;
@@ -886,6 +896,9 @@ type ProductOptionMatrixValue = {
886
896
  optionId: string;
887
897
  label: string;
888
898
  slug: string | null;
899
+ swatchColor?: string | null;
900
+ thumbnail?: MediaValue;
901
+ images?: MediaValue[] | null;
889
902
  order: string;
890
903
  };
891
904
  type ProductOptionMatrixOption = {
@@ -924,6 +937,9 @@ type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantSh
924
937
  optionValueId: EntityID;
925
938
  optionValueLabel: string;
926
939
  optionValueSlug: string | null;
940
+ optionValueSwatchColor?: string | null;
941
+ optionValueThumbnail?: MediaValue;
942
+ optionValueImages?: MediaValue[] | null;
927
943
  variantIds: EntityID[];
928
944
  variantCount: number;
929
945
  variants: TVariant[];
@@ -938,6 +954,13 @@ declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape
938
954
  declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
939
955
  declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
940
956
  declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
957
+ /**
958
+ * Builds product-first listing groups for one primary option.
959
+ *
960
+ * The returned groups are intended for product cards with nested swatches or
961
+ * option-value sections. They do not make a product-paginated API response into
962
+ * an expanded-card paginator; one product can still emit several groups.
963
+ */
941
964
  declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
942
965
  product: ProductListingProductShape | null | undefined;
943
966
  options: ProductOptionShape[];
@@ -1379,7 +1402,7 @@ declare class ServerClient {
1379
1402
  };
1380
1403
  };
1381
1404
  query: QueryHooks;
1382
- collections: CollectionClient;
1405
+ collections: ServerCollectionClient;
1383
1406
  queryClient: QueryClient;
1384
1407
  lastRequestId: string | null;
1385
1408
  protected state: ClientState;
@@ -1394,4 +1417,4 @@ declare class ServerClient {
1394
1417
  */
1395
1418
  declare function createServerClient(options: ClientServerConfig): ServerClient;
1396
1419
 
1397
- export { isPermissionError as $, type AddItemParams as A, PermissionError as B, CustomerAuth as C, type DeepPartial as D, type ExtractArrayType as E, NotFoundError as F, GoneError as G, ConflictError as H, RateLimitError as I, isSDKError as J, isNetworkError as K, type ListingGroupsParams as L, isValidationError as M, NetworkError as N, isApiError as O, type ProductListingGroupsResponse as P, isConfigError as Q, type RemoveItemParams as R, type StockCheckParams as S, TimeoutError as T, type UpdateItemParams as U, type ValidateDiscountParams as V, isTimeoutError as W, isGoneError as X, isServiceUnavailableError as Y, isUsageLimitError as Z, isAuthError as _, type CustomerAuthOptions as a, type UpdateProfileData as a$, isNotFoundError as a0, isConflictError as a1, isRateLimitError as a2, createAuthError as a3, createPermissionError as a4, createNotFoundError as a5, createConflictError as a6, createRateLimitError as a7, createServerClient as a8, ServerClient as a9, type ShippingApiOptions as aA, CartApi as aB, type CartApiOptions as aC, ProductApi as aD, type ProductApiOptions as aE, type ProductListingGroupSummary as aF, type ProductListingGroupsItem as aG, type StockCheckResult as aH, CollectionQueryBuilder as aI, type ReadOnlyQueryBuilder as aJ, CollectionClient as aK, type GenerateMetadataOptions as aL, ServerCommerceClient as aM, type ServerCommerceClientOptions as aN, type CommunityClientOptions as aO, type CommunityPost as aP, ModerationApi as aQ, type ModerationApiOptions as aR, type CommunityBan as aS, type BanCustomerParams as aT, type UnbanCustomerParams as aU, type CustomerAuthResponse as aV, type CustomerRefreshResponse as aW, type CustomerRegisterResponse as aX, type CustomerProfile as aY, type CustomerRegisterData as aZ, type CustomerLoginData as a_, resolveApiUrl as aa, type ClientServerConfig as ab, type ClientMetadata as ac, type PaginationMeta as ad, type PayloadMutationResponse as ae, BaseApi as af, type ServerApiOptions as ag, type RequestOptions as ah, OrderApi as ai, type OrderApiOptions as aj, type CustomerSnapshot as ak, type ReturnReason as al, type ReturnItem as am, type CreateOrderParams as an, type UpdateOrderParams as ao, type BulkImportFulfillmentsParams as ap, type BulkImportFulfillmentsResponse as aq, type CreateReturnParams as ar, type UpdateReturnParams as as, type UpdateTransactionParams as at, type CreateFulfillmentParams as au, type ReturnWithRefundParams as av, type UpdateFulfillmentParams as aw, DiscountApi as ax, type DiscountApiOptions as ay, ShippingApi as az, type StockCheckResponse as b, type CollectionQueryParams as b0, type CollectionDetailQueryParams as b1, type CollectionInfiniteQueryParams as b2, type QueryOptions as b3, type SuspenseQueryOptions as b4, type InfiniteQueryOptions as b5, type SuspenseInfiniteQueryOptions as b6, CollectionHooks as b7, CustomerHooks as b8, QueryHooks as b9, type ProductOptionValueShape as ba, type ProductOptionShape as bb, type ProductVariantShape as bc, type ProductListingProductShape as bd, type ProductOptionMatrixValue as be, type ProductOptionMatrixOption as bf, type ProductOptionMatrixVariant as bg, type ProductOptionMatrix as bh, type ProductListingProjection as bi, type ProductListingGroup as bj, buildProductOptionMatrix as bk, getSelectedValueByOptionId as bl, normalizeSelectedValueIds as bm, getAvailableOptionValues as bn, resolveVariantForSelection as bo, buildProductListingProjection as bp, buildProductListingGroupsByOption as bq, type ApplyDiscountParams as c, type RemoveDiscountParams as d, type ClearCartParams as e, type CheckoutParams as f, type PayloadFindResponse as g, type ValidateDiscountResult as h, type CalculateShippingParams as i, type CalculateShippingResult as j, type ApiQueryOptions as k, type ProductListingGroupsQueryOptions as l, type ClientConfig as m, CommunityClient as n, type ReadOnlyQueryHooks as o, ReadOnlyCollectionClient as p, type ClientState as q, type DebugConfig as r, type RetryConfig as s, SDKError as t, ValidationError as u, ApiError as v, ConfigError as w, ServiceUnavailableError as x, UsageLimitError as y, AuthError as z };
1420
+ export { isPermissionError as $, type AddItemParams as A, PermissionError as B, CustomerAuth as C, type DeepPartial as D, type ExtractArrayType as E, NotFoundError as F, GoneError as G, ConflictError as H, RateLimitError as I, isSDKError as J, isNetworkError as K, type ListingGroupsParams as L, isValidationError as M, NetworkError as N, isApiError as O, type ProductListingGroupsResponse as P, isConfigError as Q, type RemoveItemParams as R, type StockCheckParams as S, TimeoutError as T, type UpdateItemParams as U, type ValidateDiscountParams as V, isTimeoutError as W, isGoneError as X, isServiceUnavailableError as Y, isUsageLimitError as Z, isAuthError as _, type CustomerAuthOptions as a, type CustomerRegisterData as a$, isNotFoundError as a0, isConflictError as a1, isRateLimitError as a2, createAuthError as a3, createPermissionError as a4, createNotFoundError as a5, createConflictError as a6, createRateLimitError as a7, createServerClient as a8, ServerClient as a9, type ShippingApiOptions as aA, CartApi as aB, type CartApiOptions as aC, ProductApi as aD, type ProductApiOptions as aE, type ProductListingGroupSummary as aF, type ProductListingGroupsItem as aG, type StockCheckResult as aH, CollectionQueryBuilder as aI, ServerCollectionQueryBuilder as aJ, type ReadOnlyQueryBuilder as aK, CollectionClient as aL, ServerCollectionClient as aM, type GenerateMetadataOptions as aN, ServerCommerceClient as aO, type ServerCommerceClientOptions as aP, type CommunityClientOptions as aQ, type CommunityPost as aR, ModerationApi as aS, type ModerationApiOptions as aT, type CommunityBan as aU, type BanCustomerParams as aV, type UnbanCustomerParams as aW, type CustomerAuthResponse as aX, type CustomerRefreshResponse as aY, type CustomerRegisterResponse as aZ, type CustomerProfile as a_, resolveApiUrl as aa, type ClientServerConfig as ab, type ClientMetadata as ac, type PaginationMeta as ad, type PayloadMutationResponse as ae, BaseApi as af, type ServerApiOptions as ag, type RequestOptions as ah, OrderApi as ai, type OrderApiOptions as aj, type CustomerSnapshot as ak, type ReturnReason as al, type ReturnItem as am, type CreateOrderParams as an, type UpdateOrderParams as ao, type BulkImportFulfillmentsParams as ap, type BulkImportFulfillmentsResponse as aq, type CreateReturnParams as ar, type UpdateReturnParams as as, type UpdateTransactionParams as at, type CreateFulfillmentParams as au, type ReturnWithRefundParams as av, type UpdateFulfillmentParams as aw, DiscountApi as ax, type DiscountApiOptions as ay, ShippingApi as az, type StockCheckResponse as b, type CustomerLoginData as b0, type UpdateProfileData as b1, type CollectionQueryParams as b2, type CollectionDetailQueryParams as b3, type CollectionInfiniteQueryParams as b4, type QueryOptions as b5, type SuspenseQueryOptions as b6, type InfiniteQueryOptions as b7, type SuspenseInfiniteQueryOptions as b8, CollectionHooks as b9, CustomerHooks as ba, QueryHooks as bb, type ProductOptionValueShape as bc, type ProductOptionShape as bd, type ProductVariantShape as be, type ProductListingProductShape as bf, type ProductOptionMatrixValue as bg, type ProductOptionMatrixOption as bh, type ProductOptionMatrixVariant as bi, type ProductOptionMatrix as bj, type ProductListingProjection as bk, type ProductListingGroup as bl, buildProductOptionMatrix as bm, getSelectedValueByOptionId as bn, normalizeSelectedValueIds as bo, getAvailableOptionValues as bp, resolveVariantForSelection as bq, buildProductListingProjection as br, buildProductListingGroupsByOption as bs, type ApplyDiscountParams as c, type RemoveDiscountParams as d, type ClearCartParams as e, type CheckoutParams as f, type PayloadFindResponse as g, type ValidateDiscountResult as h, type CalculateShippingParams as i, type CalculateShippingResult as j, type ApiQueryOptions as k, type ProductListingGroupsQueryOptions as l, type ClientConfig as m, CommunityClient as n, type ReadOnlyQueryHooks as o, ReadOnlyCollectionClient as p, type ClientState as q, type DebugConfig as r, type RetryConfig as s, SDKError as t, ValidationError as u, ApiError as v, ConfigError as w, ServiceUnavailableError as x, UsageLimitError as y, AuthError as z };
package/dist/server.cjs CHANGED
@@ -24,6 +24,7 @@ __export(server_exports, {
24
24
  CommunityClient: () => CommunityClient,
25
25
  ModerationApi: () => ModerationApi,
26
26
  ServerClient: () => ServerClient,
27
+ ServerCollectionClient: () => ServerCollectionClient,
27
28
  ServerCommerceClient: () => ServerCommerceClient,
28
29
  createServerClient: () => createServerClient
29
30
  });
@@ -225,6 +226,8 @@ var CollectionQueryBuilder = class {
225
226
  );
226
227
  }
227
228
  };
229
+ var ServerCollectionQueryBuilder = class extends CollectionQueryBuilder {
230
+ };
228
231
 
229
232
  // src/core/collection/http-client.ts
230
233
  var import_qs_esm = require("qs-esm");
@@ -1001,6 +1004,11 @@ var CollectionClient = class extends HttpClient {
1001
1004
  return this.parseMutationResponse(response);
1002
1005
  }
1003
1006
  };
1007
+ var ServerCollectionClient = class extends CollectionClient {
1008
+ from(collection) {
1009
+ return new ServerCollectionQueryBuilder(this, collection);
1010
+ }
1011
+ };
1004
1012
 
1005
1013
  // src/core/api/parse-response.ts
1006
1014
  async function parseApiResponse(response, endpoint) {
@@ -2025,7 +2033,7 @@ var ServerClient = class {
2025
2033
  unbanCustomer: moderationApi.unbanCustomer.bind(moderationApi)
2026
2034
  }
2027
2035
  });
2028
- this.collections = new CollectionClient(
2036
+ this.collections = new ServerCollectionClient(
2029
2037
  this.config.publishableKey,
2030
2038
  this.config.secretKey,
2031
2039
  void 0,