@01.software/sdk 0.29.0 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +273 -73
  2. package/dist/analytics/react.cjs +4 -1
  3. package/dist/analytics/react.cjs.map +1 -1
  4. package/dist/analytics/react.js +4 -1
  5. package/dist/analytics/react.js.map +1 -1
  6. package/dist/analytics.cjs +4 -1
  7. package/dist/analytics.cjs.map +1 -1
  8. package/dist/analytics.js +4 -1
  9. package/dist/analytics.js.map +1 -1
  10. package/dist/client.cjs +1476 -0
  11. package/dist/client.cjs.map +1 -0
  12. package/dist/client.d.cts +28 -0
  13. package/dist/client.d.ts +28 -0
  14. package/dist/client.js +1453 -0
  15. package/dist/client.js.map +1 -0
  16. package/dist/collection-client-B9d9kr1d.d.ts +218 -0
  17. package/dist/collection-client-QPbwimkU.d.cts +218 -0
  18. package/dist/{const-DAjQYNuM.d.ts → const-B75IFDRi.d.ts} +2 -4
  19. package/dist/{const-Dsixdi6z.d.cts → const-VZuk2tWc.d.cts} +2 -4
  20. package/dist/index-B2WbhEgT.d.cts +106 -0
  21. package/dist/index-B2WbhEgT.d.ts +106 -0
  22. package/dist/index.cjs +784 -1530
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +11 -115
  25. package/dist/index.d.ts +11 -115
  26. package/dist/index.js +784 -1548
  27. package/dist/index.js.map +1 -1
  28. package/dist/metadata.cjs +91 -0
  29. package/dist/metadata.cjs.map +1 -0
  30. package/dist/metadata.d.cts +58 -0
  31. package/dist/metadata.d.ts +58 -0
  32. package/dist/metadata.js +68 -0
  33. package/dist/metadata.js.map +1 -0
  34. package/dist/{payload-types-Ci-ZA7aM.d.cts → payload-types-DPjO_IbQ.d.cts} +9 -3
  35. package/dist/{payload-types-Ci-ZA7aM.d.ts → payload-types-DPjO_IbQ.d.ts} +9 -3
  36. package/dist/query.cjs +1791 -0
  37. package/dist/query.cjs.map +1 -0
  38. package/dist/query.d.cts +244 -0
  39. package/dist/query.d.ts +244 -0
  40. package/dist/query.js +1786 -0
  41. package/dist/query.js.map +1 -0
  42. package/dist/realtime.cjs +4 -1
  43. package/dist/realtime.cjs.map +1 -1
  44. package/dist/realtime.d.cts +2 -2
  45. package/dist/realtime.d.ts +2 -2
  46. package/dist/realtime.js +4 -1
  47. package/dist/realtime.js.map +1 -1
  48. package/dist/{server-BINWywT8.d.cts → server-CrsPyqEc.d.cts} +14 -31
  49. package/dist/{server-BINWywT8.d.ts → server-CrsPyqEc.d.ts} +14 -31
  50. package/dist/server.cjs +299 -840
  51. package/dist/server.cjs.map +1 -1
  52. package/dist/server.d.cts +112 -7
  53. package/dist/server.d.ts +112 -7
  54. package/dist/server.js +299 -858
  55. package/dist/server.js.map +1 -1
  56. package/dist/{types-BWq_WlbB.d.ts → types-1fBLrYU7.d.ts} +1 -1
  57. package/dist/{types-zKjATmDK.d.cts → types-BwT0eeaz.d.cts} +1 -1
  58. package/dist/{server-Cv0Q4dPQ.d.ts → types-Dlb2mwpX.d.cts} +228 -741
  59. package/dist/{server-C0C8dtms.d.cts → types-DuSKPiY5.d.ts} +228 -741
  60. package/dist/ui/canvas/server.cjs +7 -6
  61. package/dist/ui/canvas/server.cjs.map +1 -1
  62. package/dist/ui/canvas/server.d.cts +1 -3
  63. package/dist/ui/canvas/server.d.ts +1 -3
  64. package/dist/ui/canvas/server.js +7 -6
  65. package/dist/ui/canvas/server.js.map +1 -1
  66. package/dist/ui/canvas.cjs +11 -10
  67. package/dist/ui/canvas.cjs.map +1 -1
  68. package/dist/ui/canvas.d.cts +29 -6
  69. package/dist/ui/canvas.d.ts +29 -6
  70. package/dist/ui/canvas.js +11 -10
  71. package/dist/ui/canvas.js.map +1 -1
  72. package/dist/ui/form.d.cts +1 -1
  73. package/dist/ui/form.d.ts +1 -1
  74. package/dist/ui/video.d.cts +1 -1
  75. package/dist/ui/video.d.ts +1 -1
  76. package/dist/webhook.d.cts +3 -3
  77. package/dist/webhook.d.ts +3 -3
  78. package/package.json +84 -15
@@ -1,489 +1,11 @@
1
- import * as _tanstack_react_query from '@tanstack/react-query';
2
- import { QueryClient, InfiniteData, UseQueryResult } from '@tanstack/react-query';
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-Ci-ZA7aM.js';
4
- import { Sort, Where } from 'payload';
5
- import { Metadata } from 'next';
6
- import { C as CollectionType } from './types-BWq_WlbB.js';
7
- import { P as PublicCollection, d as ServerCollection } from './const-DAjQYNuM.js';
8
-
9
- declare function resolveApiUrl(): string;
10
- interface ClientConfig {
11
- publishableKey: string;
12
- /**
13
- * Customer authentication options.
14
- * Used to initialize CustomerAuth on Client.
15
- */
16
- customer?: {
17
- /**
18
- * Persist token in localStorage. Defaults to `true`.
19
- * - `true` (default): uses key `'customer-token'`
20
- * - `string`: uses the given string as localStorage key
21
- * - `false`: disables persistence (token/onTokenChange used instead)
22
- *
23
- * Handles SSR safely (no-op on server).
24
- * When enabled, `token` and `onTokenChange` are ignored.
25
- */
26
- persist?: boolean | string;
27
- /** Initial token (e.g. from SSR cookie) */
28
- token?: string;
29
- /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
30
- onTokenChange?: (token: string | null) => void;
31
- };
32
- }
33
- interface ClientServerConfig extends ClientConfig {
34
- secretKey: string;
35
- }
36
- interface ClientMetadata {
37
- userAgent?: string;
38
- timestamp: number;
39
- }
40
- interface ClientState {
41
- metadata: ClientMetadata;
42
- }
43
- interface PaginationMeta {
44
- page: number;
45
- limit: number;
46
- totalDocs: number;
47
- totalPages: number;
48
- hasNextPage: boolean;
49
- hasPrevPage: boolean;
50
- pagingCounter: number;
51
- prevPage: number | null;
52
- nextPage: number | null;
53
- }
54
- /**
55
- * Payload CMS Find (List) Response
56
- * GET /api/{collection}
57
- */
58
- interface PayloadFindResponse<T = unknown> {
59
- docs: T[];
60
- totalDocs: number;
61
- limit: number;
62
- totalPages: number;
63
- page: number;
64
- pagingCounter: number;
65
- hasPrevPage: boolean;
66
- hasNextPage: boolean;
67
- prevPage: number | null;
68
- nextPage: number | null;
69
- }
70
- /**
71
- * Payload CMS Create/Update Response
72
- * POST /api/{collection}
73
- * PATCH /api/{collection}/{id}
74
- */
75
- interface PayloadMutationResponse<T = unknown> {
76
- message: string;
77
- doc: T;
78
- errors?: unknown[];
79
- }
80
- /**
81
- * Do NOT replace with `Pick<FindOptions>` from `payload`. Payload's generic
82
- * types (`JoinQuery<TSlug>`, `PopulateType`) depend on `PayloadTypes` module
83
- * augmentation; external SDK consumers who skip that get degenerate types
84
- * (`never` / `{}`). Only non-generic `Sort`/`Where` are safe to import.
85
- * Excluded vs native: Local-API-only fields, `locale`/`fallbackLocale`.
86
- */
87
- interface ApiQueryOptions {
88
- page?: number;
89
- limit?: number;
90
- sort?: Sort;
91
- /**
92
- * Filter documents. Id-based relation filters (`where: { product: { equals: id } }`) are the
93
- * most reliable pattern. Dotted-path relation filters (`where: { 'product.slug': { equals } }`)
94
- * are Payload-native but may silently return empty when access control restricts the related
95
- * document or when the relation is polymorphic. String shorthand (`where: { slug: 'x' }`)
96
- * silently matches nothing — always use `{ slug: { equals: 'x' } }`.
97
- */
98
- where?: Where;
99
- /**
100
- * Controls how deeply relationship fields are populated. This is the primary control for
101
- * populating relationships like `category`, `images`, `brand`. The configured Payload default
102
- * applies when unset.
103
- */
104
- depth?: number;
105
- select?: Record<string, boolean>;
106
- /**
107
- * Controls which fields are returned for already-populated relationships, keyed by collection
108
- * slug. Does NOT control which relationships to populate — that is `depth`.
109
- *
110
- * @example
111
- * // depth: 2 populates category; populate trims which fields come back
112
- * populate: { categories: { title: true, slug: true } }
113
- */
114
- populate?: Record<string, boolean | Record<string, boolean>>;
115
- /**
116
- * Controls Payload `type: 'join'` virtual reverse-relation fields only (pagination, sort,
117
- * filter, count per join field, or `false` to disable all join-field population).
118
- *
119
- * Does NOT populate normal relationship fields like `category`, `images`, or `brand`.
120
- * For normal relationship population use `depth` (and optionally `populate` for field
121
- * selection).
122
- *
123
- * Pass `joins: false` to disable all join-field population — useful for lightweight list
124
- * queries where join fields are not needed.
125
- *
126
- * @example
127
- * // `article-authors` has a `type: 'join'` field `articles` (reverse-relation)
128
- * joins: { articles: { limit: 10, sort: '-publishedAt' } }
129
- *
130
- * // depth: 2 populates product.category — joins has no effect on this
131
- * depth: 2
132
- *
133
- * // Disable all join-field population
134
- * joins: false
135
- */
136
- joins?: Record<string, {
137
- limit?: number;
138
- page?: number;
139
- sort?: string;
140
- where?: Where;
141
- count?: boolean;
142
- } | false> | false;
143
- /** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */
144
- pagination?: boolean;
145
- /** Include draft versions (access control still applies on the server) */
146
- draft?: boolean;
147
- /** Include soft-deleted documents (requires `trash` enabled on the collection) */
148
- trash?: boolean;
149
- }
150
- interface DebugConfig {
151
- logRequests?: boolean;
152
- logResponses?: boolean;
153
- logErrors?: boolean;
154
- }
155
- interface RetryConfig {
156
- maxRetries?: number;
157
- retryableStatuses?: number[];
158
- retryDelay?: (attempt: number) => number;
159
- }
160
- type DeepPartial<T> = {
161
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
162
- };
163
- type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
164
-
165
- interface GenerateMetadataOptions {
166
- siteName?: string;
167
- }
168
-
169
- declare class SDKError extends Error {
170
- readonly code: string;
171
- readonly status?: number;
172
- readonly details?: unknown;
173
- readonly userMessage?: string;
174
- readonly suggestion?: string;
175
- readonly requestId?: string;
176
- constructor(code: string, message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
177
- getUserMessage(): string;
178
- toJSON(): {
179
- requestId?: string | undefined;
180
- name: string;
181
- code: string;
182
- message: string;
183
- status: number | undefined;
184
- details: unknown;
185
- userMessage: string | undefined;
186
- suggestion: string | undefined;
187
- };
188
- }
189
- declare class NetworkError extends SDKError {
190
- constructor(message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
191
- }
192
- declare class ValidationError extends SDKError {
193
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, status?: number);
194
- }
195
- declare class ApiError extends SDKError {
196
- constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
197
- }
198
- declare class ConfigError extends SDKError {
199
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
200
- }
201
- declare class TimeoutError extends SDKError {
202
- constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
203
- }
204
- declare class GoneError extends SDKError {
205
- constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
206
- }
207
- declare class ServiceUnavailableError extends SDKError {
208
- readonly retryAfter?: number;
209
- constructor(message?: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string);
210
- }
211
- declare class UsageLimitError extends SDKError {
212
- readonly usage: {
213
- limit: number;
214
- current: number;
215
- remaining: number;
216
- };
217
- constructor(message: string, usage: {
218
- limit: number;
219
- current: number;
220
- remaining: number;
221
- }, details?: unknown, userMessage?: string, suggestion?: string);
222
- toJSON(): {
223
- usage: {
224
- limit: number;
225
- current: number;
226
- remaining: number;
227
- };
228
- requestId?: string | undefined;
229
- name: string;
230
- code: string;
231
- message: string;
232
- status: number | undefined;
233
- details: unknown;
234
- userMessage: string | undefined;
235
- suggestion: string | undefined;
236
- };
237
- }
238
- declare class AuthError extends SDKError {
239
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
240
- }
241
- declare class PermissionError extends SDKError {
242
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
243
- }
244
- declare class NotFoundError extends SDKError {
245
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
246
- }
247
- declare class ConflictError extends SDKError {
248
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
249
- }
250
- declare class RateLimitError extends SDKError {
251
- readonly retryAfter?: number;
252
- constructor(message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
253
- }
254
- declare function isSDKError(error: unknown): error is SDKError;
255
- declare function isNetworkError(error: unknown): error is NetworkError;
256
- declare function isValidationError(error: unknown): error is ValidationError;
257
- declare function isApiError(error: unknown): error is ApiError;
258
- declare function isConfigError(error: unknown): error is ConfigError;
259
- declare function isTimeoutError(error: unknown): error is TimeoutError;
260
- declare function isGoneError(error: unknown): error is GoneError;
261
- declare function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError;
262
- declare function isUsageLimitError(error: unknown): error is UsageLimitError;
263
- declare function isAuthError(error: unknown): error is AuthError;
264
- declare function isPermissionError(error: unknown): error is PermissionError;
265
- declare function isNotFoundError(error: unknown): error is NotFoundError;
266
- declare function isConflictError(error: unknown): error is ConflictError;
267
- declare function isRateLimitError(error: unknown): error is RateLimitError;
268
- declare const createAuthError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => AuthError;
269
- declare const createPermissionError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => PermissionError;
270
- declare const createNotFoundError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => NotFoundError;
271
- declare const createConflictError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => ConflictError;
272
- declare const createRateLimitError: (message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => RateLimitError;
273
-
274
- interface FetchOptions extends RequestInit {
275
- publishableKey?: string;
276
- secretKey?: string;
277
- customerToken?: string;
278
- timeout?: number;
279
- debug?: boolean | DebugConfig;
280
- retry?: RetryConfig;
281
- /** Called on 401 when customerToken is set and reason=token_expired. Return a new token to retry, or null to fail. */
282
- onUnauthorized?: () => Promise<string | null>;
283
- }
284
-
285
- declare class HttpClient {
286
- protected publishableKey: string;
287
- protected secretKey?: string;
288
- private getCustomerToken?;
289
- private onUnauthorized?;
290
- private onRequestId?;
291
- constructor(publishableKey: string, secretKey?: string, getCustomerToken?: () => string | null, onUnauthorized?: () => Promise<string | null>, onRequestId?: (id: string | null) => void);
292
- protected get defaultOptions(): FetchOptions;
293
- protected fetchWithTracking(url: string, opts: FetchOptions): Promise<Response>;
294
- protected buildUrl(endpoint: string, options?: ApiQueryOptions): string;
295
- protected assertJsonResponse(response: Response): void;
296
- /**
297
- * Parse Payload CMS find response (list query)
298
- * Returns native Payload response structure
299
- */
300
- protected parseFindResponse<T>(response: Response): Promise<PayloadFindResponse<T>>;
301
- /**
302
- * Parse Payload CMS mutation response (create/update)
303
- * Returns native Payload response structure
304
- */
305
- protected parseMutationResponse<T>(response: Response): Promise<PayloadMutationResponse<T>>;
306
- /**
307
- * Parse Payload CMS document response (findById/delete)
308
- * Returns document directly without wrapper
309
- */
310
- protected parseDocumentResponse<T>(response: Response): Promise<T>;
311
- }
312
-
313
- declare class CollectionClient<TCollection extends string = PublicCollection> extends HttpClient {
314
- from<T extends TCollection>(collection: T): CollectionQueryBuilder<T>;
315
- /**
316
- * Find documents (list query)
317
- * GET /api/{collection}
318
- */
319
- requestFind<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<PayloadFindResponse<T>>;
320
- /**
321
- * Find-like response from a custom endpoint
322
- * POST /api/...custom-endpoint
323
- */
324
- requestFindEndpoint<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadFindResponse<T>>;
325
- /**
326
- * Find document by ID
327
- * GET /api/{collection}/{id}
328
- */
329
- requestFindById<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<T>;
330
- /**
331
- * Create document
332
- * POST /api/{collection}
333
- */
334
- requestCreate<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadMutationResponse<T>>;
335
- /**
336
- * Update document
337
- * PATCH /api/{collection}/{id}
338
- */
339
- requestUpdate<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadMutationResponse<T>>;
340
- /**
341
- * Count documents
342
- * GET /api/{collection}/count
343
- */
344
- requestCount(endpoint: string, options?: ApiQueryOptions): Promise<{
345
- totalDocs: number;
346
- }>;
347
- /**
348
- * Update multiple documents (bulk update)
349
- * PATCH /api/{collection}
350
- */
351
- requestUpdateMany<T = unknown>(endpoint: string, data: {
352
- where?: unknown;
353
- data: unknown;
354
- }): Promise<PayloadFindResponse<T>>;
355
- /**
356
- * Delete document
357
- * DELETE /api/{collection}/{id}
358
- */
359
- requestDelete<T = unknown>(endpoint: string): Promise<T>;
360
- /**
361
- * Delete multiple documents (bulk delete)
362
- * DELETE /api/{collection}
363
- */
364
- requestDeleteMany<T = unknown>(endpoint: string, data: {
365
- where?: unknown;
366
- }): Promise<PayloadFindResponse<T>>;
367
- /**
368
- * Create document with file upload
369
- * POST /api/{collection} (multipart/form-data)
370
- */
371
- requestCreateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
372
- /**
373
- * Update document with file upload
374
- * PATCH /api/{collection}/{id} (multipart/form-data)
375
- */
376
- requestUpdateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
377
- }
378
- declare class ServerCollectionClient extends CollectionClient<ServerCollection> {
379
- from<T extends ServerCollection>(collection: T): ServerCollectionQueryBuilder<T>;
380
- }
381
- declare class ReadOnlyCollectionClient extends HttpClient {
382
- from<T extends PublicCollection>(collection: T): ReadOnlyQueryBuilder<T>;
383
- requestFind<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<PayloadFindResponse<T>>;
384
- requestFindById<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<T>;
385
- requestCount(endpoint: string, options?: ApiQueryOptions): Promise<{
386
- totalDocs: number;
387
- }>;
388
- }
389
-
390
- type ReadOnlyCollectionApi = Pick<CollectionClient, 'requestFind' | 'requestFindById' | 'requestCount'>;
391
- /**
392
- * Read-only subset of CollectionQueryBuilder.
393
- * Client.from() returns this type to prevent write operations at compile time.
394
- */
395
- type ReadOnlyQueryBuilder<T extends PublicCollection> = ReadOnlyCollectionQueryBuilder<T>;
396
- declare class ReadOnlyCollectionQueryBuilder<T extends PublicCollection> {
397
- private api;
398
- private collection;
399
- constructor(api: ReadOnlyCollectionApi, collection: T);
400
- find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
401
- findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
402
- count(options?: ApiQueryOptions): Promise<{
403
- totalDocs: number;
404
- }>;
405
- findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
406
- findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
407
- }
408
- declare class CollectionQueryBuilder<T extends string> {
409
- private api;
410
- private collection;
411
- constructor(api: CollectionClient, collection: T);
412
- /**
413
- * Find documents (list query)
414
- * GET /api/{collection}
415
- * @returns Payload CMS find response with docs array and pagination
416
- */
417
- find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
418
- /**
419
- * Find document by ID
420
- * GET /api/{collection}/{id}
421
- * @returns Document object directly (no wrapper)
422
- */
423
- findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
424
- /**
425
- * Create a new document
426
- * POST /api/{collection}
427
- * @returns Payload CMS mutation response with doc and message
428
- */
429
- create(data: Partial<CollectionType<T>>, options?: {
430
- file?: File | Blob;
431
- filename?: string;
432
- }): Promise<PayloadMutationResponse<CollectionType<T>>>;
433
- /**
434
- * Update a document by ID
435
- * PATCH /api/{collection}/{id}
436
- * @returns Payload CMS mutation response with doc and message
437
- */
438
- update(id: string, data: Partial<CollectionType<T>>, options?: {
439
- file?: File | Blob;
440
- filename?: string;
441
- }): Promise<PayloadMutationResponse<CollectionType<T>>>;
442
- /**
443
- * Count documents
444
- * GET /api/{collection}/count
445
- * @returns Count response with totalDocs
446
- */
447
- count(options?: ApiQueryOptions): Promise<{
448
- totalDocs: number;
449
- }>;
450
- /**
451
- * Find first matching document and return its Next.js Metadata.
452
- * Applies depth: 1 (SEO image populate) and limit: 1 automatically.
453
- * @returns Metadata or null if no document matches
454
- */
455
- findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
456
- /**
457
- * Find document by ID and return its Next.js Metadata.
458
- * Applies depth: 1 (SEO image populate) automatically.
459
- * @returns Metadata (throws on 404)
460
- */
461
- findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
462
- /**
463
- * Update multiple documents (bulk update)
464
- * PATCH /api/{collection}
465
- * @returns Payload CMS find response with updated docs
466
- */
467
- updateMany(where: ApiQueryOptions['where'], data: Partial<CollectionType<T>>): Promise<PayloadFindResponse<CollectionType<T>>>;
468
- /**
469
- * Delete a document by ID
470
- * DELETE /api/{collection}/{id}
471
- * @returns Deleted document object directly (no wrapper)
472
- */
473
- remove(id: string): Promise<CollectionType<T>>;
474
- /**
475
- * Delete multiple documents (bulk delete)
476
- * DELETE /api/{collection}
477
- * @returns Payload CMS find response with deleted docs
478
- */
479
- removeMany(where: ApiQueryOptions['where']): Promise<PayloadFindResponse<CollectionType<T>>>;
480
- }
481
- declare class ServerCollectionQueryBuilder<T extends ServerCollection> extends CollectionQueryBuilder<T> {
482
- }
1
+ import { P as PublicCollection } from './const-VZuk2tWc.cjs';
2
+ import { C as CollectionType } from './types-BwT0eeaz.cjs';
3
+ import { O as Order, h as Cart, i as CartItem, d as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-DPjO_IbQ.cjs';
483
4
 
484
5
  interface CommunityClientOptions {
485
6
  publishableKey?: string;
486
7
  secretKey?: string;
8
+ apiUrl?: string;
487
9
  customerToken?: string | (() => string | null);
488
10
  onUnauthorized?: () => Promise<string | null>;
489
11
  onRequestId?: (id: string | null) => void;
@@ -551,6 +73,7 @@ interface PaginatedResponse<T> {
551
73
  declare class CommunityClient {
552
74
  private readonly publishableKey;
553
75
  private readonly secretKey?;
76
+ private readonly apiUrl?;
554
77
  private readonly customerToken?;
555
78
  private readonly onUnauthorized?;
556
79
  private readonly onRequestId?;
@@ -652,6 +175,7 @@ declare class CommunityClient {
652
175
  interface ServerApiOptions {
653
176
  publishableKey?: string;
654
177
  secretKey: string;
178
+ apiUrl?: string;
655
179
  onRequestId?: (id: string | null) => void;
656
180
  }
657
181
  interface RequestOptions {
@@ -661,39 +185,12 @@ interface RequestOptions {
661
185
  declare abstract class BaseApi {
662
186
  protected readonly publishableKey: string;
663
187
  protected readonly secretKey: string;
188
+ protected readonly apiUrl?: string;
664
189
  protected readonly onRequestId?: (id: string | null) => void;
665
190
  constructor(apiName: string, options: ServerApiOptions);
666
191
  protected request<T>(endpoint: string, body: unknown, options?: RequestOptions): Promise<T>;
667
192
  }
668
193
 
669
- type ModerationApiOptions = ServerApiOptions;
670
- interface CommunityBan {
671
- id: string;
672
- customer: string;
673
- isPermanent?: boolean;
674
- bannedUntil?: string;
675
- reason?: string;
676
- createdAt?: string;
677
- updatedAt?: string;
678
- [key: string]: unknown;
679
- }
680
- type BanCustomerParams = {
681
- customerId: string;
682
- isPermanent?: boolean;
683
- bannedUntil?: string;
684
- reason?: string;
685
- };
686
- type UnbanCustomerParams = {
687
- customerId: string;
688
- };
689
- declare class ModerationApi extends BaseApi {
690
- constructor(options: ModerationApiOptions);
691
- banCustomer(params: BanCustomerParams): Promise<CommunityBan>;
692
- unbanCustomer(params: UnbanCustomerParams): Promise<{
693
- success: true;
694
- }>;
695
- }
696
-
697
194
  interface CustomerAuthResponse {
698
195
  token: string;
699
196
  customer: CustomerProfile;
@@ -768,7 +265,7 @@ declare class CustomerAuth {
768
265
  private token;
769
266
  private onTokenChange?;
770
267
  private refreshPromise;
771
- constructor(publishableKey: string, options?: CustomerAuthOptions);
268
+ constructor(publishableKey: string, options?: CustomerAuthOptions, apiUrl?: string);
772
269
  /**
773
270
  * Register a new customer account
774
271
  */
@@ -836,6 +333,7 @@ declare class CustomerAuth {
836
333
  interface CartApiOptions {
837
334
  publishableKey?: string;
838
335
  secretKey?: string;
336
+ apiUrl?: string;
839
337
  customerToken?: string | (() => string | null);
840
338
  onUnauthorized?: () => Promise<string | null>;
841
339
  onRequestId?: (id: string | null) => void;
@@ -867,6 +365,7 @@ type ClearCartParams = {
867
365
  declare class CartApi {
868
366
  private readonly publishableKey;
869
367
  private readonly secretKey?;
368
+ private readonly apiUrl?;
870
369
  private readonly customerToken?;
871
370
  private readonly onUnauthorized?;
872
371
  private readonly onRequestId?;
@@ -1006,21 +505,31 @@ type NormalizedProductSelection = {
1006
505
  valueIds: string[];
1007
506
  variantId: string | null;
1008
507
  };
1009
- type LegacyProductSelectionParamEvent = {
508
+ type CompatibilityProductSelectionParamEvent = {
1010
509
  optionId: string;
1011
510
  optionSlug: string;
1012
511
  valueSlug: string;
1013
512
  searchParam: string;
1014
513
  };
514
+ type LegacyProductSelectionParamEvent = CompatibilityProductSelectionParamEvent;
1015
515
  type ProductSelectionCodecOptions = {
516
+ onCompatibilityOptionIdParam?: (event: CompatibilityProductSelectionParamEvent) => void;
1016
517
  onLegacyOptionIdParam?: (event: LegacyProductSelectionParamEvent) => void;
1017
518
  };
519
+ type ProductSelectionResolutionContext = {
520
+ detail?: Pick<ProductDetail, 'images' | 'listing'>;
521
+ images?: ProductDetail['images'];
522
+ listing?: ProductDetail['listing'];
523
+ };
1018
524
  type ProductSelectionAvailableValue = {
1019
525
  valueId: string;
1020
526
  value: string;
1021
527
  slug: string;
1022
528
  selected: boolean;
1023
529
  available: boolean;
530
+ availableForSale: boolean;
531
+ isUnlimited: boolean;
532
+ availableStock: number | null;
1024
533
  swatchColor?: string | null;
1025
534
  thumbnail?: MediaValue;
1026
535
  images?: MediaValue[] | null;
@@ -1066,13 +575,44 @@ declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape
1066
575
  declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
1067
576
  declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
1068
577
  declare function normalizeProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
578
+ declare function normalizeProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1069
579
  declare function parseProductSelection(detail: ProductDetail, search: string | URLSearchParams | URL | null | undefined, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1070
580
  declare function stringifyProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): string;
1071
581
  declare function createProductSelectionCodec(detail: ProductDetail, options?: ProductSelectionCodecOptions): {
1072
582
  parse: (search: string | URLSearchParams | URL | null | undefined) => NormalizedProductSelection;
1073
583
  stringify: (selection?: ProductSelectionInput) => string;
1074
584
  };
585
+ declare function resolveProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions, context?: ProductSelectionResolutionContext): ProductSelectionResolution;
1075
586
  declare function resolveProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): ProductSelectionResolution;
587
+ type ProductDetailImageMedia = Extract<ProductDetailMedia, {
588
+ id?: string | number | null;
589
+ url?: string | null;
590
+ }>;
591
+ declare function getProductSelectionImages(resolution: Pick<ProductSelectionResolution, 'media'>): ProductDetailImageMedia[];
592
+ type ProductHrefProduct = ProductDetail | {
593
+ slug?: string | null;
594
+ product?: {
595
+ slug?: string | null;
596
+ } | null;
597
+ };
598
+ type ProductHrefGroup = {
599
+ optionId?: string | number | null;
600
+ optionSlug?: string | null;
601
+ optionValueId?: string | number | null;
602
+ optionValueSlug?: string | null;
603
+ variantId?: string | number | null;
604
+ listing?: {
605
+ selectionHintVariant?: string | number | null;
606
+ } | null;
607
+ };
608
+ type ProductHrefOptions = {
609
+ basePath?: string;
610
+ detail?: ProductDetail;
611
+ matrix?: ProductOptionMatrix<ProductDetailVariant>;
612
+ selection?: ProductSelectionInput;
613
+ trailingSlash?: boolean;
614
+ };
615
+ declare function buildProductHref(product: ProductHrefProduct, group?: ProductHrefGroup | null, options?: ProductHrefOptions): string;
1076
616
  declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
1077
617
  /**
1078
618
  * Builds product-first listing groups for one primary option.
@@ -1485,17 +1025,19 @@ declare class OrderApi extends BaseApi {
1485
1025
  updateReturn(params: UpdateReturnParams): Promise<Return>;
1486
1026
  }
1487
1027
 
1488
- interface ServerCommerceClientOptions {
1489
- publishableKey?: string;
1490
- secretKey: string;
1028
+ interface CommerceClientOptions {
1029
+ publishableKey: string;
1030
+ apiUrl?: string;
1031
+ customerToken: () => string | null;
1032
+ onUnauthorized?: () => Promise<string | null>;
1491
1033
  onRequestId?: (id: string | null) => void;
1034
+ customerAuth: CustomerAuth;
1492
1035
  }
1493
- declare class ServerCommerceClient {
1036
+ declare class CommerceClient {
1494
1037
  readonly product: {
1495
1038
  stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1496
1039
  listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1497
1040
  detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
1498
- upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
1499
1041
  };
1500
1042
  readonly cart: {
1501
1043
  get: (cartId: string) => Promise<Cart>;
@@ -1512,19 +1054,11 @@ declare class ServerCommerceClient {
1512
1054
  };
1513
1055
  readonly orders: {
1514
1056
  checkout: (params: CheckoutParams) => Promise<Order>;
1515
- create: (params: CreateOrderParams) => Promise<Order>;
1516
- update: (params: UpdateOrderParams) => Promise<Order>;
1517
- updateTransaction: (params: UpdateTransactionParams) => Promise<Transaction>;
1518
- confirmPayment: (params: ConfirmPaymentParams) => Promise<ConfirmPaymentResponse>;
1519
- createFulfillment: (params: CreateFulfillmentParams) => Promise<Fulfillment>;
1520
- updateFulfillment: (params: UpdateFulfillmentParams) => Promise<Fulfillment>;
1521
- bulkImportFulfillments: (params: BulkImportFulfillmentsParams) => Promise<BulkImportFulfillmentsResponse>;
1522
- createReturn: (params: CreateReturnParams) => Promise<Return>;
1523
- updateReturn: (params: UpdateReturnParams) => Promise<Return>;
1524
- returnWithRefund: (params: ReturnWithRefundParams) => Promise<{
1525
- return: Return;
1526
- transaction: Transaction | null;
1527
- }>;
1057
+ listMine: (options?: {
1058
+ page?: number;
1059
+ limit?: number;
1060
+ status?: string;
1061
+ }) => Promise<PayloadFindResponse<Order>>;
1528
1062
  };
1529
1063
  readonly discounts: {
1530
1064
  validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
@@ -1532,231 +1066,184 @@ declare class ServerCommerceClient {
1532
1066
  readonly shipping: {
1533
1067
  calculate: (params: CalculateShippingParams) => Promise<CalculateShippingResult>;
1534
1068
  };
1535
- constructor(options: ServerCommerceClientOptions);
1069
+ constructor(options: CommerceClientOptions);
1536
1070
  }
1537
1071
 
1538
- interface CollectionQueryParams<T extends PublicCollection> {
1539
- collection: T;
1540
- options?: ApiQueryOptions;
1541
- }
1542
- interface CollectionDetailQueryParams<T extends PublicCollection> {
1543
- collection: T;
1544
- id: string;
1545
- options?: ApiQueryOptions;
1546
- }
1547
- interface CollectionInfiniteQueryParams<T extends PublicCollection> {
1548
- collection: T;
1549
- options?: Omit<ApiQueryOptions, 'page'>;
1550
- pageSize?: number;
1072
+ /**
1073
+ * Customer namespace. Currently exposes .auth; reserved for future customer-
1074
+ * scoped capabilities (addresses, preferences, etc.).
1075
+ */
1076
+ declare class CustomerNamespace {
1077
+ readonly auth: CustomerAuth;
1078
+ constructor(publishableKey: string, options?: CustomerAuthOptions, apiUrl?: string);
1551
1079
  }
1552
- interface QueryOptions<TQueryFnData = unknown, TData = TQueryFnData> {
1553
- enabled?: boolean;
1554
- staleTime?: number;
1555
- gcTime?: number;
1556
- refetchOnWindowFocus?: boolean;
1557
- refetchOnMount?: boolean | 'always';
1558
- refetchInterval?: number | false;
1559
- retry?: boolean | number;
1560
- select?: (data: TQueryFnData) => TData;
1561
- placeholderData?: TQueryFnData | ((previousData: TData | undefined) => TQueryFnData | undefined);
1562
- initialData?: TQueryFnData | (() => TQueryFnData);
1563
- initialDataUpdatedAt?: number | (() => number | undefined);
1080
+
1081
+ interface ClientConfig {
1082
+ publishableKey: string;
1083
+ /** API base URL for staging, self-hosted, preview, or proxy deployments. */
1084
+ apiUrl?: string;
1085
+ /**
1086
+ * Customer authentication options.
1087
+ * Used to initialize CustomerAuth on Client.
1088
+ */
1089
+ customer?: {
1090
+ /**
1091
+ * Persist token in localStorage. Defaults to `true`.
1092
+ * - `true` (default): uses key `'customer-token'`
1093
+ * - `string`: uses the given string as localStorage key
1094
+ * - `false`: disables persistence (token/onTokenChange used instead)
1095
+ *
1096
+ * Handles SSR safely (no-op on server).
1097
+ * When enabled, `token` and `onTokenChange` are ignored.
1098
+ */
1099
+ persist?: boolean | string;
1100
+ /** Initial token (e.g. from SSR cookie) */
1101
+ token?: string;
1102
+ /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
1103
+ onTokenChange?: (token: string | null) => void;
1104
+ };
1564
1105
  }
1565
- type SuspenseQueryOptions<TQueryFnData = unknown, TData = TQueryFnData> = Omit<QueryOptions<TQueryFnData, TData>, 'enabled' | 'placeholderData'>;
1566
- interface InfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> {
1567
- enabled?: boolean;
1568
- staleTime?: number;
1569
- gcTime?: number;
1570
- refetchOnWindowFocus?: boolean;
1571
- refetchOnMount?: boolean | 'always';
1572
- refetchInterval?: number | false;
1573
- retry?: boolean | number;
1574
- select?: (data: InfiniteData<TQueryFnData>) => TData;
1106
+ interface ClientServerConfig extends ClientConfig {
1107
+ secretKey: string;
1575
1108
  }
1576
- type SuspenseInfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> = Omit<InfiniteQueryOptions<TQueryFnData, TData>, 'enabled'>;
1577
- interface MutationCallbacks$1<TData> {
1578
- onSuccess?: (data: TData) => void;
1579
- onError?: (error: SDKError) => void;
1580
- onSettled?: () => void;
1109
+ interface ClientMetadata {
1110
+ userAgent?: string;
1111
+ timestamp: number;
1581
1112
  }
1582
- declare class CollectionHooks {
1583
- protected queryClient: QueryClient;
1584
- protected collectionClient: CollectionClient;
1585
- constructor(queryClient: QueryClient, collectionClient: CollectionClient);
1586
- useQuery<T extends PublicCollection, TData = PayloadFindResponse<CollectionType<T>>>(params: CollectionQueryParams<T>, options?: QueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
1587
- useSuspenseQuery<T extends PublicCollection, TData = PayloadFindResponse<CollectionType<T>>>(params: CollectionQueryParams<T>, options?: SuspenseQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1588
- useQueryById<T extends PublicCollection, TData = CollectionType<T>>(params: CollectionDetailQueryParams<T>, options?: QueryOptions<CollectionType<T>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
1589
- useSuspenseQueryById<T extends PublicCollection, TData = CollectionType<T>>(params: CollectionDetailQueryParams<T>, options?: SuspenseQueryOptions<CollectionType<T>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1590
- useInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: InfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
1591
- useSuspenseInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
1592
- prefetchQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
1593
- staleTime?: number;
1594
- }): Promise<void>;
1595
- prefetchQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
1596
- staleTime?: number;
1597
- }): Promise<void>;
1598
- prefetchInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
1599
- pages?: number;
1600
- staleTime?: number;
1601
- }): Promise<void>;
1602
- useCreate<T extends PublicCollection>(params: {
1603
- collection: T;
1604
- }, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
1605
- data: Partial<CollectionType<T>>;
1606
- file?: File | Blob;
1607
- filename?: string;
1608
- }, unknown>;
1609
- useUpdate<T extends PublicCollection>(params: {
1610
- collection: T;
1611
- }, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
1612
- id: string;
1613
- data: Partial<CollectionType<T>>;
1614
- file?: File | Blob;
1615
- filename?: string;
1616
- }, unknown>;
1617
- useRemove<T extends PublicCollection>(params: {
1618
- collection: T;
1619
- }, options?: MutationCallbacks$1<CollectionType<T>>): _tanstack_react_query.UseMutationResult<CollectionType<T>, SDKError, string, unknown>;
1620
- invalidateQueries<T extends PublicCollection>(collection: T, type?: 'list' | 'detail' | 'infinite'): Promise<void>;
1621
- getQueryData<T extends PublicCollection>(collection: T, type: 'list', options?: ApiQueryOptions): PayloadFindResponse<CollectionType<T>> | undefined;
1622
- getQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, options?: ApiQueryOptions): CollectionType<T> | null | undefined;
1623
- setQueryData<T extends PublicCollection>(collection: T, type: 'list', data: PayloadFindResponse<CollectionType<T>>, options?: ApiQueryOptions): void;
1624
- setQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
1113
+ interface ClientState {
1114
+ metadata: ClientMetadata;
1625
1115
  }
1626
-
1627
- interface MutationCallbacks<TData> {
1628
- onSuccess?: (data: TData) => void;
1629
- onError?: (error: SDKError) => void;
1630
- onSettled?: () => void;
1116
+ /**
1117
+ * Payload CMS Find (List) Response
1118
+ * GET /api/{collection}
1119
+ */
1120
+ interface PayloadFindResponse<T = unknown> {
1121
+ docs: T[];
1122
+ totalDocs: number;
1123
+ limit: number;
1124
+ totalPages: number;
1125
+ page: number;
1126
+ pagingCounter: number;
1127
+ hasPrevPage: boolean;
1128
+ hasNextPage: boolean;
1129
+ prevPage: number | null;
1130
+ nextPage: number | null;
1631
1131
  }
1632
- declare class CustomerHooks {
1633
- private queryClient;
1634
- private customerAuth?;
1635
- constructor(queryClient: QueryClient, customerAuth?: CustomerAuth);
1636
- private ensureCustomerAuth;
1637
- private invalidateMe;
1638
- useCustomerMe(options?: {
1639
- enabled?: boolean;
1640
- staleTime?: number;
1641
- gcTime?: number;
1642
- refetchOnWindowFocus?: boolean;
1643
- refetchOnMount?: boolean | 'always';
1644
- refetchInterval?: number | false;
1645
- retry?: boolean | number;
1646
- }): _tanstack_react_query.UseQueryResult<CustomerProfile | null, Error>;
1647
- useCustomerLogin(options?: MutationCallbacks<CustomerAuthResponse>): _tanstack_react_query.UseMutationResult<CustomerAuthResponse, SDKError, CustomerLoginData, unknown>;
1648
- useCustomerRegister(options?: MutationCallbacks<{
1649
- customer: CustomerProfile;
1650
- }>): _tanstack_react_query.UseMutationResult<CustomerRegisterResponse, SDKError, CustomerRegisterData, unknown>;
1651
- useCustomerLogout(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, void, unknown>;
1652
- useCustomerForgotPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, string, unknown>;
1653
- useCustomerResetPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
1654
- token: string;
1655
- password: string;
1656
- }, unknown>;
1657
- useCustomerRefreshToken(options?: MutationCallbacks<CustomerRefreshResponse>): _tanstack_react_query.UseMutationResult<CustomerRefreshResponse, SDKError, unknown, unknown>;
1658
- useCustomerUpdateProfile(options?: MutationCallbacks<CustomerProfile>): _tanstack_react_query.UseMutationResult<CustomerProfile, SDKError, UpdateProfileData, unknown>;
1659
- useCustomerChangePassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
1660
- currentPassword: string;
1661
- newPassword: string;
1662
- }, unknown>;
1663
- invalidateCustomerQueries(): Promise<void>;
1664
- getCustomerData(): CustomerProfile | null | undefined;
1665
- setCustomerData(data: CustomerProfile | null): void;
1132
+ /**
1133
+ * Payload CMS Create/Update Response
1134
+ * POST /api/{collection}
1135
+ * PATCH /api/{collection}/{id}
1136
+ */
1137
+ interface PayloadMutationResponse<T = unknown> {
1138
+ message: string;
1139
+ doc: T;
1140
+ errors?: unknown[];
1666
1141
  }
1667
-
1668
- type ProductListingGroupsQueryOptions = Pick<ApiQueryOptions, 'page' | 'limit' | 'sort' | 'where'>;
1669
- type ReadOnlyQueryHooks = Omit<QueryHooks, 'useCreate' | 'useUpdate' | 'useRemove'>;
1142
+ type Sort = string | string[];
1143
+ type Where = Record<string, unknown>;
1670
1144
  /**
1671
- * Composes CollectionHooks + CustomerHooks into a single API surface.
1672
- * All methods are delegated; no logic lives here.
1145
+ * Do NOT replace with `Pick<FindOptions>` from `payload` or import Payload
1146
+ * types here. Payload's generic query types depend on `PayloadTypes` module
1147
+ * augmentation; external SDK consumers who only use `createClient` should not
1148
+ * install Payload just to type REST query objects. Excluded vs native:
1149
+ * Local-API-only fields, `locale`/`fallbackLocale`.
1673
1150
  */
1674
- interface ProductDetailCallable {
1675
- product: {
1676
- detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
1677
- };
1151
+ interface ApiQueryOptions {
1152
+ page?: number;
1153
+ limit?: number;
1154
+ sort?: Sort;
1155
+ /**
1156
+ * Filter documents. Id-based relation filters (`where: { product: { equals: id } }`) are the
1157
+ * most reliable pattern. Dotted-path relation filters (`where: { 'product.slug': { equals } }`)
1158
+ * are Payload-native but may silently return empty when access control restricts the related
1159
+ * document or when the relation is polymorphic. String shorthand (`where: { slug: 'x' }`)
1160
+ * silently matches nothing — always use `{ slug: { equals: 'x' } }`.
1161
+ */
1162
+ where?: Where;
1163
+ /**
1164
+ * Controls how deeply relationship fields are populated. This is the primary control for
1165
+ * populating relationships like `category`, `images`, `brand`. The configured Payload default
1166
+ * applies when unset.
1167
+ */
1168
+ depth?: number;
1169
+ select?: Record<string, boolean>;
1170
+ /**
1171
+ * Controls which fields are returned for already-populated relationships, keyed by collection
1172
+ * slug. Does NOT control which relationships to populate — that is `depth`.
1173
+ *
1174
+ * @example
1175
+ * // depth: 2 populates category; populate trims which fields come back
1176
+ * populate: { categories: { title: true, slug: true } }
1177
+ */
1178
+ populate?: Record<string, boolean | Record<string, boolean>>;
1179
+ /**
1180
+ * Controls Payload `type: 'join'` virtual reverse-relation fields only (pagination, sort,
1181
+ * filter, count per join field, or `false` to disable all join-field population).
1182
+ *
1183
+ * Does NOT populate normal relationship fields like `category`, `images`, or `brand`.
1184
+ * For normal relationship population use `depth` (and optionally `populate` for field
1185
+ * selection).
1186
+ *
1187
+ * Pass `joins: false` to disable all join-field population — useful for lightweight list
1188
+ * queries where join fields are not needed.
1189
+ *
1190
+ * @example
1191
+ * // `article-authors` has a `type: 'join'` field `articles` (reverse-relation)
1192
+ * joins: { articles: { limit: 10, sort: '-publishedAt' } }
1193
+ *
1194
+ * // depth: 2 populates product.category — joins has no effect on this
1195
+ * depth: 2
1196
+ *
1197
+ * // Disable all join-field population
1198
+ * joins: false
1199
+ */
1200
+ joins?: Record<string, {
1201
+ limit?: number;
1202
+ page?: number;
1203
+ sort?: string;
1204
+ where?: Where;
1205
+ count?: boolean;
1206
+ } | false> | false;
1207
+ /** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */
1208
+ pagination?: boolean;
1209
+ /** Include draft versions (access control still applies on the server) */
1210
+ draft?: boolean;
1211
+ /** Include soft-deleted documents (requires `trash` enabled on the collection) */
1212
+ trash?: boolean;
1678
1213
  }
1679
- declare class QueryHooks extends CollectionHooks {
1680
- private _customer;
1681
- private _commerce?;
1682
- constructor(queryClient: QueryClient, collectionClient: CollectionClient, customerAuth?: CustomerAuth, commerceClient?: ProductDetailCallable);
1683
- useCustomerMe: CustomerHooks['useCustomerMe'];
1684
- useCustomerLogin: CustomerHooks['useCustomerLogin'];
1685
- useCustomerRegister: CustomerHooks['useCustomerRegister'];
1686
- useCustomerLogout: CustomerHooks['useCustomerLogout'];
1687
- useCustomerForgotPassword: CustomerHooks['useCustomerForgotPassword'];
1688
- useCustomerResetPassword: CustomerHooks['useCustomerResetPassword'];
1689
- useCustomerRefreshToken: CustomerHooks['useCustomerRefreshToken'];
1690
- useCustomerUpdateProfile: CustomerHooks['useCustomerUpdateProfile'];
1691
- useCustomerChangePassword: CustomerHooks['useCustomerChangePassword'];
1692
- invalidateCustomerQueries: CustomerHooks['invalidateCustomerQueries'];
1693
- getCustomerData: CustomerHooks['getCustomerData'];
1694
- setCustomerData: CustomerHooks['setCustomerData'];
1695
- useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
1696
- options?: ProductListingGroupsQueryOptions;
1697
- }, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
1698
- useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
1699
- options?: ProductListingGroupsQueryOptions;
1700
- }, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1701
- useInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
1702
- options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1703
- pageSize?: number;
1704
- }, options?: InfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
1705
- useSuspenseInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
1706
- options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1707
- pageSize?: number;
1708
- }, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
1709
- prefetchProductListingGroupsQuery(params: {
1710
- options?: ProductListingGroupsQueryOptions;
1711
- }, options?: {
1712
- staleTime?: number;
1713
- }): Promise<void>;
1714
- prefetchInfiniteProductListingGroupsQuery(params: {
1715
- options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1716
- pageSize?: number;
1717
- }, options?: {
1718
- pages?: number;
1719
- staleTime?: number;
1720
- }): Promise<void>;
1721
- useProductDetail(params: {
1722
- slug: string;
1723
- } | {
1724
- id: string;
1725
- }, options?: {
1726
- enabled?: boolean;
1727
- }): UseQueryResult<ProductDetail | null>;
1728
- useProductDetailBySlug(slug: string, options?: {
1729
- enabled?: boolean;
1730
- }): UseQueryResult<ProductDetail | null>;
1731
- useProductDetailById(id: string, options?: {
1732
- enabled?: boolean;
1733
- }): UseQueryResult<ProductDetail | null>;
1214
+ interface DebugConfig {
1215
+ logRequests?: boolean;
1216
+ logResponses?: boolean;
1217
+ logErrors?: boolean;
1734
1218
  }
1735
-
1736
- declare class ServerClient {
1737
- commerce: ServerCommerceClient;
1738
- community: CommunityClient & {
1739
- moderation: {
1740
- banCustomer: (p: BanCustomerParams) => Promise<CommunityBan>;
1741
- unbanCustomer: (p: UnbanCustomerParams) => Promise<{
1742
- success: true;
1743
- }>;
1744
- };
1745
- };
1746
- query: QueryHooks;
1747
- collections: ServerCollectionClient;
1748
- queryClient: QueryClient;
1219
+ interface RetryConfig {
1220
+ maxRetries?: number;
1221
+ retryableStatuses?: number[];
1222
+ retryDelay?: (attempt: number) => number;
1223
+ }
1224
+ interface RootQueryLookup<T extends string> {
1225
+ find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
1226
+ findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
1227
+ count(options?: ApiQueryOptions): Promise<{
1228
+ totalDocs: number;
1229
+ }>;
1230
+ }
1231
+ type RootReadOnlyQueryBuilder<T extends PublicCollection> = RootQueryLookup<T>;
1232
+ interface RootCollectionClient {
1233
+ from<T extends PublicCollection>(collection: T): RootReadOnlyQueryBuilder<T>;
1234
+ }
1235
+ interface RootClient {
1236
+ commerce: CommerceClient;
1237
+ community: CommunityClient;
1238
+ customer: CustomerNamespace;
1239
+ collections: RootCollectionClient;
1749
1240
  lastRequestId: string | null;
1750
- protected state: ClientState;
1751
- protected config: ClientServerConfig;
1752
- constructor(options: ClientServerConfig);
1753
1241
  getState(): ClientState;
1754
- getConfig(): Omit<ClientServerConfig, 'secretKey'>;
1242
+ getConfig(): ClientConfig;
1755
1243
  }
1756
- /**
1757
- * Create a server-only client with full read/write access. Requires secretKey.
1758
- * For read-only usage, prefer `createClient()` (no secretKey needed).
1759
- */
1760
- declare function createServerClient(options: ClientServerConfig): ServerClient;
1244
+ type DeepPartial<T> = {
1245
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
1246
+ };
1247
+ type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
1761
1248
 
1762
- export { type CustomerAuthResponse as $, type AddItemParams as A, type BanCustomerParams as B, CustomerAuth as C, type ClientMetadata as D, type ClientServerConfig as E, CollectionClient as F, type CollectionDetailQueryParams as G, CollectionHooks as H, type CollectionInfiniteQueryParams as I, CollectionQueryBuilder as J, type CollectionQueryParams as K, type ListingGroupsParams as L, type CommunityBan as M, type CommunityClientOptions as N, type CommunityPost as O, type ProductListingGroupsResponse as P, ConfigError as Q, type RemoveItemParams as R, type StockCheckParams as S, type ConfirmPaymentParams as T, type UpdateItemParams as U, type ValidateDiscountParams as V, type ConfirmPaymentResponse as W, ConflictError as X, type CreateFulfillmentParams as Y, type CreateOrderParams as Z, type CreateReturnParams as _, type CustomerAuthOptions as a, type ReturnItem as a$, CustomerHooks as a0, type CustomerLoginData as a1, type CustomerProfile as a2, type CustomerRefreshResponse as a3, type CustomerRegisterData as a4, type CustomerRegisterResponse as a5, type CustomerSnapshot as a6, type DebugConfig as a7, type DeepPartial as a8, DiscountApi as a9, type ProductDetailVariant as aA, type ProductDetailVariantOptionValue as aB, type ProductDetailVideo as aC, type ProductListingGroup as aD, type ProductListingGroupSummary as aE, type ProductListingGroupsItem as aF, type ProductListingProductShape as aG, type ProductListingProjection as aH, type ProductOptionMatrix as aI, type ProductOptionMatrixOption as aJ, type ProductOptionMatrixValue as aK, type ProductOptionMatrixVariant as aL, type ProductOptionShape as aM, type ProductOptionValueShape as aN, type ProductSelectionAvailableValue as aO, type ProductSelectionByOptionValue as aP, ProductSelectionCodecError as aQ, type ProductSelectionCodecOptions as aR, type ProductSelectionInput as aS, type ProductSelectionResolution as aT, type ProductVariantShape as aU, QueryHooks as aV, type QueryOptions as aW, RateLimitError as aX, type ReadOnlyQueryBuilder as aY, type RequestOptions as aZ, type RetryConfig as a_, type DiscountApiOptions as aa, type ExtractArrayType as ab, type GenerateMetadataOptions as ac, GoneError as ad, type InfiniteQueryOptions as ae, type LegacyProductSelectionParamEvent as af, ModerationApi as ag, type ModerationApiOptions as ah, NetworkError as ai, type NormalizedProductSelection as aj, NotFoundError as ak, OrderApi as al, type OrderApiOptions as am, type PaginationMeta as an, type PayloadMutationResponse as ao, PermissionError as ap, ProductApi as aq, type ProductApiOptions as ar, type ProductDetailBrand as as, type ProductDetailCategory as at, type ProductDetailImage as au, type ProductDetailListing as av, type ProductDetailMedia as aw, type ProductDetailOption as ax, type ProductDetailOptionValue as ay, type ProductDetailTag as az, type StockCheckResponse as b, type ReturnReason as b0, type ReturnWithRefundParams as b1, SDKError as b2, type ServerApiOptions as b3, ServerClient as b4, ServerCollectionClient as b5, ServerCollectionQueryBuilder as b6, ServerCommerceClient as b7, type ServerCommerceClientOptions as b8, ServiceUnavailableError as b9, getSelectedValueByOptionId as bA, isApiError as bB, isAuthError as bC, isConfigError as bD, isConflictError as bE, isGoneError as bF, isNetworkError as bG, isNotFoundError as bH, isPermissionError as bI, isRateLimitError as bJ, isSDKError as bK, isServiceUnavailableError as bL, isTimeoutError as bM, isUsageLimitError as bN, isValidationError as bO, normalizeProductSelection as bP, normalizeSelectedValueIds as bQ, parseProductSelection as bR, resolveApiUrl as bS, resolveProductSelection as bT, resolveVariantForSelection as bU, stringifyProductSelection as bV, ShippingApi as ba, type ShippingApiOptions as bb, type StockCheckResult as bc, type SuspenseInfiniteQueryOptions as bd, type SuspenseQueryOptions as be, TimeoutError as bf, type UnbanCustomerParams as bg, type UpdateFulfillmentParams as bh, type UpdateOrderParams as bi, type UpdateProfileData as bj, type UpdateReturnParams as bk, type UpdateTransactionParams as bl, UsageLimitError as bm, ValidationError as bn, buildProductListingGroupsByOption as bo, buildProductListingProjection as bp, buildProductOptionMatrix as bq, buildProductOptionMatrixFromDetail as br, createAuthError as bs, createConflictError as bt, createNotFoundError as bu, createPermissionError as bv, createProductSelectionCodec as bw, createRateLimitError as bx, createServerClient as by, getAvailableOptionValues as bz, type ProductDetailParams as c, type ProductDetail as d, type ApplyDiscountParams as e, type RemoveDiscountParams as f, type ClearCartParams as g, type CheckoutParams as h, type PayloadFindResponse as i, type ValidateDiscountResult as j, type CalculateShippingParams as k, type CalculateShippingResult as l, type ApiQueryOptions as m, type ProductListingGroupsQueryOptions as n, CommunityClient as o, type ReadOnlyQueryHooks as p, ReadOnlyCollectionClient as q, type ClientState as r, type ClientConfig as s, ApiError as t, AuthError as u, BaseApi as v, type BulkImportFulfillmentsParams as w, type BulkImportFulfillmentsResponse as x, CartApi as y, type CartApiOptions as z };
1249
+ export { type OrderApiOptions as $, type ApiQueryOptions as A, BaseApi as B, CommerceClient as C, type DebugConfig as D, type ExtractArrayType as E, type CreateFulfillmentParams as F, type CreateOrderParams as G, type CreateReturnParams as H, CustomerAuth as I, type CustomerAuthOptions as J, type CustomerAuthResponse as K, type CustomerLoginData as L, type CustomerProfile as M, type CustomerRefreshResponse as N, type CustomerRegisterData as O, type PayloadFindResponse as P, type CustomerRegisterResponse as Q, type RetryConfig as R, type Sort as S, type CustomerSnapshot as T, DiscountApi as U, type DiscountApiOptions as V, type Where as W, type LegacyProductSelectionParamEvent as X, type ListingGroupsParams as Y, type NormalizedProductSelection as Z, OrderApi as _, CommunityClient as a, buildProductOptionMatrixFromDetail as a$, ProductApi as a0, type ProductApiOptions as a1, type ProductDetail as a2, type ProductDetailBrand as a3, type ProductDetailCategory as a4, type ProductDetailImage as a5, type ProductDetailImageMedia as a6, type ProductDetailListing as a7, type ProductDetailMedia as a8, type ProductDetailOption as a9, type ProductSelectionResolution as aA, type ProductSelectionResolutionContext as aB, type ProductVariantShape as aC, type RemoveDiscountParams as aD, type RemoveItemParams as aE, type RequestOptions as aF, type ReturnItem as aG, type ReturnReason as aH, type ReturnWithRefundParams as aI, type ServerApiOptions as aJ, ShippingApi as aK, type ShippingApiOptions as aL, type StockCheckParams as aM, type StockCheckResponse as aN, type StockCheckResult as aO, type UpdateFulfillmentParams as aP, type UpdateItemParams as aQ, type UpdateOrderParams as aR, type UpdateProfileData as aS, type UpdateReturnParams as aT, type UpdateTransactionParams as aU, type ValidateDiscountParams as aV, type ValidateDiscountResult as aW, buildProductHref as aX, buildProductListingGroupsByOption as aY, buildProductListingProjection as aZ, buildProductOptionMatrix as a_, type ProductDetailOptionValue as aa, type ProductDetailParams as ab, type ProductDetailTag as ac, type ProductDetailVariant as ad, type ProductDetailVariantOptionValue as ae, type ProductDetailVideo as af, type ProductHrefGroup as ag, type ProductHrefOptions as ah, type ProductHrefProduct as ai, type ProductListingGroup as aj, type ProductListingGroupSummary as ak, type ProductListingGroupsItem as al, type ProductListingGroupsResponse as am, type ProductListingProductShape as an, type ProductListingProjection as ao, type ProductOptionMatrix as ap, type ProductOptionMatrixOption as aq, type ProductOptionMatrixValue as ar, type ProductOptionMatrixVariant as as, type ProductOptionShape as at, type ProductOptionValueShape as au, type ProductSelectionAvailableValue as av, type ProductSelectionByOptionValue as aw, ProductSelectionCodecError as ax, type ProductSelectionCodecOptions as ay, type ProductSelectionInput as az, CustomerNamespace as b, createProductSelectionCodec as b0, getAvailableOptionValues as b1, getProductSelectionImages as b2, getSelectedValueByOptionId as b3, normalizeProductSelection as b4, normalizeProductSelectionFromMatrix as b5, normalizeSelectedValueIds as b6, parseProductSelection as b7, resolveProductSelection as b8, resolveProductSelectionFromMatrix as b9, resolveVariantForSelection as ba, stringifyProductSelection as bb, type ProductUpsertParams as bc, type ProductUpsertResponse as bd, type ClientServerConfig as be, type ClientState as c, type ClientConfig as d, type ClientMetadata as e, type DeepPartial as f, type PayloadMutationResponse as g, type RootClient as h, type RootCollectionClient as i, type RootReadOnlyQueryBuilder as j, type AddItemParams as k, type ApplyDiscountParams as l, type BulkImportFulfillmentsParams as m, type BulkImportFulfillmentsResponse as n, type CalculateShippingParams as o, type CalculateShippingResult as p, CartApi as q, type CartApiOptions as r, type CheckoutParams as s, type ClearCartParams as t, type CommerceClientOptions as u, type CommunityClientOptions as v, type CommunityPost as w, type CompatibilityProductSelectionParamEvent as x, type ConfirmPaymentParams as y, type ConfirmPaymentResponse as z };