@01.software/sdk 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,778 +1,18 @@
1
- import { O as Order, a as Cart, b as CartItem, P as Product, c as OrderItem$1, T as Transaction, d as Fulfillment, R as Return } from './payload-types-D7lnu9By.js';
2
- export { A as Article, e as ArticleAuthor, f as ArticleCategory, g as ArticleTag, D as Document, I as Image, h as Post, i as PostCategory, j as ProductVariant, k as Tenant, V as Video } from './payload-types-D7lnu9By.js';
3
- import { Sort, Where } from 'payload';
4
- import * as _tanstack_react_query from '@tanstack/react-query';
5
- import { QueryClient, InfiniteData } from '@tanstack/react-query';
6
- import { Metadata } from 'next';
7
- import { C as CollectionType } from './webhook-C6vne8Ve.js';
8
- export { d as CUSTOMER_PASSWORD_RESET_OPERATION, g as CustomerAuthWebhookEvent, h as CustomerAuthWebhookHandlers, e as CustomerPasswordResetWebhookData, f as CustomerPasswordResetWebhookEvent, a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, k as createCustomerAuthWebhookHandler, m as createTypedWebhookHandler, l as handleWebhook, j as isCustomerPasswordResetWebhookEvent, i as isValidWebhookEvent } from './webhook-C6vne8Ve.js';
9
- import { P as PublicCollection } from './const-BNJRuk3V.js';
10
- export { a as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS } from './const-BNJRuk3V.js';
1
+ import { d as Cart, e as CartItem, O as Order, f as Product } from './payload-types-D8-G1PiT.js';
2
+ export { A as Article, g as ArticleAuthor, h as ArticleCategory, i as ArticleTag, D as Document, I as Image, P as Post, j as PostCategory, k as ProductVariant, T as Tenant, V as Video } from './payload-types-D8-G1PiT.js';
3
+ import { C as CustomerAuth, a as CustomerAuthOptions, S as StockCheckParams, b as StockCheckResponse, L as ListingGroupsParams, P as ProductListingGroupsResponse, A as AddItemParams, U as UpdateItemParams, R as RemoveItemParams, c as ApplyDiscountParams, d as RemoveDiscountParams, e as ClearCartParams, f as CheckoutParams, g as PayloadFindResponse, V as ValidateDiscountParams, h as ValidateDiscountResult, i as CalculateShippingParams, j as CalculateShippingResult, k as ApiQueryOptions, l as ProductListingGroupsQueryOptions, m as ClientConfig, n as CommunityClient, o as ReadOnlyQueryHooks, p as ReadOnlyCollectionClient, q as ClientState } from './server-D7FcHj7J.js';
4
+ export { v as ApiError, z as AuthError, aV as BanCustomerParams, af as BaseApi, ap as BulkImportFulfillmentsParams, aq as BulkImportFulfillmentsResponse, aB as CartApi, aC as CartApiOptions, ac as ClientMetadata, ab as ClientServerConfig, aL as CollectionClient, b3 as CollectionDetailQueryParams, b9 as CollectionHooks, b4 as CollectionInfiniteQueryParams, aI as CollectionQueryBuilder, b2 as CollectionQueryParams, aU as CommunityBan, aQ as CommunityClientOptions, aR as CommunityPost, w as ConfigError, H as ConflictError, au as CreateFulfillmentParams, an as CreateOrderParams, ar as CreateReturnParams, aX as CustomerAuthResponse, ba as CustomerHooks, b0 as CustomerLoginData, a_ as CustomerProfile, aY as CustomerRefreshResponse, a$ as CustomerRegisterData, aZ as CustomerRegisterResponse, ak as CustomerSnapshot, r as DebugConfig, D as DeepPartial, ax as DiscountApi, ay as DiscountApiOptions, E as ExtractArrayType, aN as GenerateMetadataOptions, G as GoneError, b7 as InfiniteQueryOptions, aS as ModerationApi, aT as ModerationApiOptions, N as NetworkError, F as NotFoundError, ai as OrderApi, aj as OrderApiOptions, ad as PaginationMeta, ae as PayloadMutationResponse, B as PermissionError, aD as ProductApi, aE as ProductApiOptions, bl as ProductListingGroup, aF as ProductListingGroupSummary, aG as ProductListingGroupsItem, bf as ProductListingProductShape, bk as ProductListingProjection, bj as ProductOptionMatrix, bh as ProductOptionMatrixOption, bg as ProductOptionMatrixValue, bi as ProductOptionMatrixVariant, bd as ProductOptionShape, bc as ProductOptionValueShape, be as ProductVariantShape, bb as QueryHooks, b5 as QueryOptions, I as RateLimitError, aK as ReadOnlyQueryBuilder, ah as RequestOptions, s as RetryConfig, am as ReturnItem, al as ReturnReason, av as ReturnWithRefundParams, t as SDKError, ag as ServerApiOptions, a9 as ServerClient, a9 as ServerClientType, aM as ServerCollectionClient, aJ as ServerCollectionQueryBuilder, aO as ServerCommerceClient, aP as ServerCommerceClientOptions, x as ServiceUnavailableError, az as ShippingApi, aA as ShippingApiOptions, aH as StockCheckResult, b8 as SuspenseInfiniteQueryOptions, b6 as SuspenseQueryOptions, T as TimeoutError, aW as UnbanCustomerParams, aw as UpdateFulfillmentParams, ao as UpdateOrderParams, b1 as UpdateProfileData, as as UpdateReturnParams, at as UpdateTransactionParams, y as UsageLimitError, u as ValidationError, bs as buildProductListingGroupsByOption, br as buildProductListingProjection, bm as buildProductOptionMatrix, a3 as createAuthError, a6 as createConflictError, a5 as createNotFoundError, a4 as createPermissionError, a7 as createRateLimitError, a8 as createServerClient, bp as getAvailableOptionValues, bn as getSelectedValueByOptionId, O as isApiError, _ as isAuthError, Q as isConfigError, a1 as isConflictError, X as isGoneError, K as isNetworkError, a0 as isNotFoundError, $ as isPermissionError, a2 as isRateLimitError, J as isSDKError, Y as isServiceUnavailableError, W as isTimeoutError, Z as isUsageLimitError, M as isValidationError, bo as normalizeSelectedValueIds, aa as resolveApiUrl, bq as resolveVariantForSelection } from './server-D7FcHj7J.js';
5
+ import { QueryClient } from '@tanstack/react-query';
6
+ export { C as CollectionType } from './types-BQqfXbB2.js';
7
+ import { P as PublicCollection } from './const-CMdmNgEs.js';
8
+ export { b as COLLECTIONS, C as Collection, I as INTERNAL_COLLECTIONS, e as InternalCollection, d as SERVER_COLLECTIONS, c as SERVER_ONLY_COLLECTIONS, S as ServerCollection, a as ServerOnlyCollection } from './const-CMdmNgEs.js';
11
9
  export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.js';
10
+ export { CUSTOMER_PASSWORD_RESET_OPERATION, CustomerAuthWebhookEvent, CustomerAuthWebhookHandlers, CustomerPasswordResetWebhookData, CustomerPasswordResetWebhookEvent, WebhookEvent, WebhookHandler, WebhookOperation, WebhookOptions, createCustomerAuthWebhookHandler, createTypedWebhookHandler, handleWebhook, isCustomerPasswordResetWebhookEvent, isValidWebhookEvent } from './webhook.js';
12
11
  export { b as IMAGE_SIZES, I as ImageData, a as ImagePalette, f as ImagePlaceholderOptions, d as getImageLqip, e as getImagePalette, h as getImagePlaceholderStyle, c as getImageSrcSet, g as getImageUrl } from './image-TT8lTsk5.js';
13
12
  export { e as VideoGifOptions, V as VideoThumbnailOptions, a as getVideoGif, c as getVideoMp4Url, d as getVideoStoryboard, b as getVideoStreamUrl, g as getVideoThumbnail } from './video-DbLL8yuc.js';
14
13
  export { Analytics, AnalyticsConfig, createAnalytics } from './analytics.js';
15
-
16
- declare function resolveApiUrl(): string;
17
- interface ClientConfig {
18
- publishableKey: string;
19
- /**
20
- * Customer authentication options.
21
- * Used to initialize CustomerAuth on Client.
22
- */
23
- customer?: {
24
- /**
25
- * Persist token in localStorage. Defaults to `true`.
26
- * - `true` (default): uses key `'customer-token'`
27
- * - `string`: uses the given string as localStorage key
28
- * - `false`: disables persistence (token/onTokenChange used instead)
29
- *
30
- * Handles SSR safely (no-op on server).
31
- * When enabled, `token` and `onTokenChange` are ignored.
32
- */
33
- persist?: boolean | string;
34
- /** Initial token (e.g. from SSR cookie) */
35
- token?: string;
36
- /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
37
- onTokenChange?: (token: string | null) => void;
38
- };
39
- }
40
- interface ClientServerConfig extends ClientConfig {
41
- secretKey: string;
42
- }
43
- interface ClientMetadata {
44
- userAgent?: string;
45
- timestamp: number;
46
- }
47
- interface ClientState {
48
- metadata: ClientMetadata;
49
- }
50
- interface PaginationMeta {
51
- page: number;
52
- limit: number;
53
- totalDocs: number;
54
- totalPages: number;
55
- hasNextPage: boolean;
56
- hasPrevPage: boolean;
57
- pagingCounter: number;
58
- prevPage: number | null;
59
- nextPage: number | null;
60
- }
61
- /**
62
- * Payload CMS Find (List) Response
63
- * GET /api/{collection}
64
- */
65
- interface PayloadFindResponse<T = unknown> {
66
- docs: T[];
67
- totalDocs: number;
68
- limit: number;
69
- totalPages: number;
70
- page: number;
71
- pagingCounter: number;
72
- hasPrevPage: boolean;
73
- hasNextPage: boolean;
74
- prevPage: number | null;
75
- nextPage: number | null;
76
- }
77
- /**
78
- * Payload CMS Create/Update Response
79
- * POST /api/{collection}
80
- * PATCH /api/{collection}/{id}
81
- */
82
- interface PayloadMutationResponse<T = unknown> {
83
- message: string;
84
- doc: T;
85
- errors?: unknown[];
86
- }
87
- /**
88
- * Do NOT replace with `Pick<FindOptions>` from `payload`. Payload's generic
89
- * types (`JoinQuery<TSlug>`, `PopulateType`) depend on `PayloadTypes` module
90
- * augmentation; external SDK consumers who skip that get degenerate types
91
- * (`never` / `{}`). Only non-generic `Sort`/`Where` are safe to import.
92
- * Excluded vs native: Local-API-only fields, `locale`/`fallbackLocale`.
93
- */
94
- interface ApiQueryOptions {
95
- page?: number;
96
- limit?: number;
97
- sort?: Sort;
98
- where?: Where;
99
- depth?: number;
100
- select?: Record<string, boolean>;
101
- /** Per-collection field selection for populated relationships (keyed by collection slug) */
102
- populate?: Record<string, boolean | Record<string, boolean>>;
103
- /** Join field control: pagination/filter per join, or false to disable */
104
- joins?: Record<string, {
105
- limit?: number;
106
- page?: number;
107
- sort?: string;
108
- where?: Where;
109
- count?: boolean;
110
- } | false> | false;
111
- /** Set to `false` to skip the count query — returns docs without totalDocs/totalPages */
112
- pagination?: boolean;
113
- /** Include draft versions (access control still applies on the server) */
114
- draft?: boolean;
115
- /** Include soft-deleted documents (requires `trash` enabled on the collection) */
116
- trash?: boolean;
117
- }
118
- interface DebugConfig {
119
- logRequests?: boolean;
120
- logResponses?: boolean;
121
- logErrors?: boolean;
122
- }
123
- interface RetryConfig {
124
- maxRetries?: number;
125
- retryableStatuses?: number[];
126
- retryDelay?: (attempt: number) => number;
127
- }
128
- type DeepPartial<T> = {
129
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
130
- };
131
- type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
132
-
133
- interface GenerateMetadataOptions {
134
- siteName?: string;
135
- }
136
-
137
- declare class SDKError extends Error {
138
- readonly code: string;
139
- readonly status?: number;
140
- readonly details?: unknown;
141
- readonly userMessage?: string;
142
- readonly suggestion?: string;
143
- readonly requestId?: string;
144
- constructor(code: string, message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
145
- getUserMessage(): string;
146
- toJSON(): {
147
- requestId?: string | undefined;
148
- name: string;
149
- code: string;
150
- message: string;
151
- status: number | undefined;
152
- details: unknown;
153
- userMessage: string | undefined;
154
- suggestion: string | undefined;
155
- };
156
- }
157
- declare class NetworkError extends SDKError {
158
- constructor(message: string, status?: number, details?: unknown, userMessage?: string, suggestion?: string);
159
- }
160
- declare class ValidationError extends SDKError {
161
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
162
- }
163
- declare class ApiError extends SDKError {
164
- constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
165
- }
166
- declare class ConfigError extends SDKError {
167
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
168
- }
169
- declare class TimeoutError extends SDKError {
170
- constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
171
- }
172
- declare class GoneError extends SDKError {
173
- constructor(message?: string, details?: unknown, userMessage?: string, suggestion?: string);
174
- }
175
- declare class ServiceUnavailableError extends SDKError {
176
- readonly retryAfter?: number;
177
- constructor(message?: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string);
178
- }
179
- declare class UsageLimitError extends SDKError {
180
- readonly usage: {
181
- limit: number;
182
- current: number;
183
- remaining: number;
184
- };
185
- constructor(message: string, usage: {
186
- limit: number;
187
- current: number;
188
- remaining: number;
189
- }, details?: unknown, userMessage?: string, suggestion?: string);
190
- toJSON(): {
191
- usage: {
192
- limit: number;
193
- current: number;
194
- remaining: number;
195
- };
196
- requestId?: string | undefined;
197
- name: string;
198
- code: string;
199
- message: string;
200
- status: number | undefined;
201
- details: unknown;
202
- userMessage: string | undefined;
203
- suggestion: string | undefined;
204
- };
205
- }
206
- declare class AuthError extends SDKError {
207
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
208
- }
209
- declare class PermissionError extends SDKError {
210
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
211
- }
212
- declare class NotFoundError extends SDKError {
213
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
214
- }
215
- declare class ConflictError extends SDKError {
216
- constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
217
- }
218
- declare class RateLimitError extends SDKError {
219
- readonly retryAfter?: number;
220
- constructor(message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
221
- }
222
- declare function isSDKError(error: unknown): error is SDKError;
223
- declare function isNetworkError(error: unknown): error is NetworkError;
224
- declare function isValidationError(error: unknown): error is ValidationError;
225
- declare function isApiError(error: unknown): error is ApiError;
226
- declare function isConfigError(error: unknown): error is ConfigError;
227
- declare function isTimeoutError(error: unknown): error is TimeoutError;
228
- declare function isGoneError(error: unknown): error is GoneError;
229
- declare function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError;
230
- declare function isUsageLimitError(error: unknown): error is UsageLimitError;
231
- declare function isAuthError(error: unknown): error is AuthError;
232
- declare function isPermissionError(error: unknown): error is PermissionError;
233
- declare function isNotFoundError(error: unknown): error is NotFoundError;
234
- declare function isConflictError(error: unknown): error is ConflictError;
235
- declare function isRateLimitError(error: unknown): error is RateLimitError;
236
- declare const createAuthError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => AuthError;
237
- declare const createPermissionError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => PermissionError;
238
- declare const createNotFoundError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => NotFoundError;
239
- declare const createConflictError: (message: string, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => ConflictError;
240
- declare const createRateLimitError: (message: string, retryAfter?: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string) => RateLimitError;
241
-
242
- interface FetchOptions extends RequestInit {
243
- publishableKey?: string;
244
- secretKey?: string;
245
- customerToken?: string;
246
- timeout?: number;
247
- debug?: boolean | DebugConfig;
248
- retry?: RetryConfig;
249
- /** Called on 401 when customerToken is set and reason=token_expired. Return a new token to retry, or null to fail. */
250
- onUnauthorized?: () => Promise<string | null>;
251
- }
252
-
253
- declare class HttpClient {
254
- protected publishableKey: string;
255
- protected secretKey?: string;
256
- private getCustomerToken?;
257
- private onUnauthorized?;
258
- private onRequestId?;
259
- constructor(publishableKey: string, secretKey?: string, getCustomerToken?: () => string | null, onUnauthorized?: () => Promise<string | null>, onRequestId?: (id: string | null) => void);
260
- protected get defaultOptions(): FetchOptions;
261
- protected fetchWithTracking(url: string, opts: FetchOptions): Promise<Response>;
262
- protected buildUrl(endpoint: string, options?: ApiQueryOptions): string;
263
- protected assertJsonResponse(response: Response): void;
264
- /**
265
- * Parse Payload CMS find response (list query)
266
- * Returns native Payload response structure
267
- */
268
- protected parseFindResponse<T>(response: Response): Promise<PayloadFindResponse<T>>;
269
- /**
270
- * Parse Payload CMS mutation response (create/update)
271
- * Returns native Payload response structure
272
- */
273
- protected parseMutationResponse<T>(response: Response): Promise<PayloadMutationResponse<T>>;
274
- /**
275
- * Parse Payload CMS document response (findById/delete)
276
- * Returns document directly without wrapper
277
- */
278
- protected parseDocumentResponse<T>(response: Response): Promise<T>;
279
- }
280
-
281
- declare class CollectionClient extends HttpClient {
282
- from<T extends PublicCollection>(collection: T): CollectionQueryBuilder<T>;
283
- /**
284
- * Find documents (list query)
285
- * GET /api/{collection}
286
- */
287
- requestFind<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<PayloadFindResponse<T>>;
288
- /**
289
- * Find-like response from a custom endpoint
290
- * POST /api/...custom-endpoint
291
- */
292
- requestFindEndpoint<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadFindResponse<T>>;
293
- /**
294
- * Find document by ID
295
- * GET /api/{collection}/{id}
296
- */
297
- requestFindById<T = unknown>(endpoint: string, options?: ApiQueryOptions): Promise<T>;
298
- /**
299
- * Create document
300
- * POST /api/{collection}
301
- */
302
- requestCreate<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadMutationResponse<T>>;
303
- /**
304
- * Update document
305
- * PATCH /api/{collection}/{id}
306
- */
307
- requestUpdate<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadMutationResponse<T>>;
308
- /**
309
- * Count documents
310
- * GET /api/{collection}/count
311
- */
312
- requestCount(endpoint: string, options?: ApiQueryOptions): Promise<{
313
- totalDocs: number;
314
- }>;
315
- /**
316
- * Update multiple documents (bulk update)
317
- * PATCH /api/{collection}
318
- */
319
- requestUpdateMany<T = unknown>(endpoint: string, data: {
320
- where?: unknown;
321
- data: unknown;
322
- }): Promise<PayloadFindResponse<T>>;
323
- /**
324
- * Delete document
325
- * DELETE /api/{collection}/{id}
326
- */
327
- requestDelete<T = unknown>(endpoint: string): Promise<T>;
328
- /**
329
- * Delete multiple documents (bulk delete)
330
- * DELETE /api/{collection}
331
- */
332
- requestDeleteMany<T = unknown>(endpoint: string, data: {
333
- where?: unknown;
334
- }): Promise<PayloadFindResponse<T>>;
335
- /**
336
- * Create document with file upload
337
- * POST /api/{collection} (multipart/form-data)
338
- */
339
- requestCreateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
340
- /**
341
- * Update document with file upload
342
- * PATCH /api/{collection}/{id} (multipart/form-data)
343
- */
344
- requestUpdateWithFile<T = unknown>(endpoint: string, data: unknown, file: File | Blob, filename?: string): Promise<PayloadMutationResponse<T>>;
345
- }
346
-
347
- /**
348
- * Read-only subset of CollectionQueryBuilder.
349
- * Client.from() returns this type to prevent write operations at compile time.
350
- */
351
- type ReadOnlyQueryBuilder<T extends PublicCollection> = Pick<CollectionQueryBuilder<T>, 'find' | 'findById' | 'count' | 'findMetadata' | 'findMetadataById'>;
352
- declare class CollectionQueryBuilder<T extends PublicCollection> {
353
- private api;
354
- private collection;
355
- constructor(api: CollectionClient, collection: T);
356
- /**
357
- * Find documents (list query)
358
- * GET /api/{collection}
359
- * @returns Payload CMS find response with docs array and pagination
360
- */
361
- find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
362
- /**
363
- * Find document by ID
364
- * GET /api/{collection}/{id}
365
- * @returns Document object directly (no wrapper)
366
- */
367
- findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
368
- /**
369
- * Create a new document
370
- * POST /api/{collection}
371
- * @returns Payload CMS mutation response with doc and message
372
- */
373
- create(data: Partial<CollectionType<T>>, options?: {
374
- file?: File | Blob;
375
- filename?: string;
376
- }): Promise<PayloadMutationResponse<CollectionType<T>>>;
377
- /**
378
- * Update a document by ID
379
- * PATCH /api/{collection}/{id}
380
- * @returns Payload CMS mutation response with doc and message
381
- */
382
- update(id: string, data: Partial<CollectionType<T>>, options?: {
383
- file?: File | Blob;
384
- filename?: string;
385
- }): Promise<PayloadMutationResponse<CollectionType<T>>>;
386
- /**
387
- * Count documents
388
- * GET /api/{collection}/count
389
- * @returns Count response with totalDocs
390
- */
391
- count(options?: ApiQueryOptions): Promise<{
392
- totalDocs: number;
393
- }>;
394
- /**
395
- * Find first matching document and return its Next.js Metadata.
396
- * Applies depth: 1 (SEO image populate) and limit: 1 automatically.
397
- * @returns Metadata or null if no document matches
398
- */
399
- findMetadata(options?: ApiQueryOptions, metadataOptions?: GenerateMetadataOptions): Promise<Metadata | null>;
400
- /**
401
- * Find document by ID and return its Next.js Metadata.
402
- * Applies depth: 1 (SEO image populate) automatically.
403
- * @returns Metadata (throws on 404)
404
- */
405
- findMetadataById(id: string, metadataOptions?: GenerateMetadataOptions): Promise<Metadata>;
406
- /**
407
- * Update multiple documents (bulk update)
408
- * PATCH /api/{collection}
409
- * @returns Payload CMS find response with updated docs
410
- */
411
- updateMany(where: ApiQueryOptions['where'], data: Partial<CollectionType<T>>): Promise<PayloadFindResponse<CollectionType<T>>>;
412
- /**
413
- * Delete a document by ID
414
- * DELETE /api/{collection}/{id}
415
- * @returns Deleted document object directly (no wrapper)
416
- */
417
- remove(id: string): Promise<CollectionType<T>>;
418
- /**
419
- * Delete multiple documents (bulk delete)
420
- * DELETE /api/{collection}
421
- * @returns Payload CMS find response with deleted docs
422
- */
423
- removeMany(where: ApiQueryOptions['where']): Promise<PayloadFindResponse<CollectionType<T>>>;
424
- }
425
-
426
- interface CommunityClientOptions {
427
- publishableKey?: string;
428
- secretKey?: string;
429
- customerToken?: string | (() => string | null);
430
- onUnauthorized?: () => Promise<string | null>;
431
- onRequestId?: (id: string | null) => void;
432
- }
433
- interface CommunityPost {
434
- id: string;
435
- title: string;
436
- content: unknown;
437
- categories?: string[];
438
- thumbnail?: string;
439
- viewCount?: number;
440
- createdAt?: string;
441
- updatedAt?: string;
442
- [key: string]: unknown;
443
- }
444
- interface Comment {
445
- id: string;
446
- body: string;
447
- post?: string;
448
- parent?: string;
449
- rootComment?: string;
450
- createdAt?: string;
451
- updatedAt?: string;
452
- [key: string]: unknown;
453
- }
454
- interface Reaction {
455
- id: string;
456
- post?: string;
457
- comment?: string;
458
- type?: string;
459
- createdAt?: string;
460
- [key: string]: unknown;
461
- }
462
- interface ReactionSummary {
463
- counts: Record<string, number>;
464
- total: number;
465
- userReactions: string[];
466
- }
467
- interface Bookmark {
468
- id: string;
469
- post?: string;
470
- createdAt?: string;
471
- [key: string]: unknown;
472
- }
473
- interface ReactionType {
474
- id: string;
475
- title: string;
476
- slug: string;
477
- emoji?: string;
478
- [key: string]: unknown;
479
- }
480
- interface PaginatedResponse<T> {
481
- docs: T[];
482
- totalDocs: number;
483
- limit: number;
484
- totalPages: number;
485
- page: number;
486
- pagingCounter: number;
487
- hasPrevPage: boolean;
488
- hasNextPage: boolean;
489
- prevPage: number | null;
490
- nextPage: number | null;
491
- }
492
- declare class CommunityClient {
493
- private readonly publishableKey;
494
- private readonly secretKey?;
495
- private readonly customerToken?;
496
- private readonly onUnauthorized?;
497
- private readonly onRequestId?;
498
- constructor(options: CommunityClientOptions);
499
- private buildQuery;
500
- private execute;
501
- createPost(params: {
502
- title: string;
503
- content: unknown;
504
- categories?: string[];
505
- thumbnail?: string;
506
- }): Promise<CommunityPost>;
507
- getMyPosts(params?: {
508
- page?: number;
509
- limit?: number;
510
- }): Promise<PaginatedResponse<CommunityPost>>;
511
- getTrending(params?: {
512
- page?: number;
513
- limit?: number;
514
- period?: string;
515
- }): Promise<PaginatedResponse<CommunityPost>>;
516
- incrementView(params: {
517
- postId: string;
518
- }): Promise<{
519
- viewCount: number;
520
- }>;
521
- reportPost(params: {
522
- postId: string;
523
- reason?: string;
524
- reasonDetail?: string;
525
- }): Promise<{
526
- success: boolean;
527
- }>;
528
- createComment(params: {
529
- postId: string;
530
- body: string;
531
- parentId?: string;
532
- }): Promise<Comment>;
533
- listComments(params: {
534
- postId: string;
535
- page?: number;
536
- limit?: number;
537
- rootComment?: string;
538
- }): Promise<PaginatedResponse<Comment>>;
539
- updateComment(params: {
540
- commentId: string;
541
- body: string;
542
- }): Promise<Comment>;
543
- deleteComment(params: {
544
- commentId: string;
545
- }): Promise<{
546
- success: boolean;
547
- }>;
548
- reportComment(params: {
549
- commentId: string;
550
- reason?: string;
551
- reasonDetail?: string;
552
- }): Promise<{
553
- success: boolean;
554
- }>;
555
- addReaction(params: {
556
- postId: string;
557
- type: string;
558
- }): Promise<Reaction>;
559
- removeReaction(params: {
560
- postId: string;
561
- type: string;
562
- }): Promise<{
563
- success: boolean;
564
- }>;
565
- addCommentReaction(params: {
566
- commentId: string;
567
- type: string;
568
- }): Promise<Reaction>;
569
- removeCommentReaction(params: {
570
- commentId: string;
571
- type: string;
572
- }): Promise<{
573
- success: boolean;
574
- }>;
575
- getReactionSummary(params: {
576
- postId: string;
577
- }): Promise<ReactionSummary>;
578
- getReactionTypes(): Promise<PaginatedResponse<ReactionType>>;
579
- addBookmark(params: {
580
- postId: string;
581
- }): Promise<Bookmark>;
582
- removeBookmark(params: {
583
- postId: string;
584
- }): Promise<{
585
- success: boolean;
586
- }>;
587
- getMyBookmarks(params?: {
588
- page?: number;
589
- limit?: number;
590
- }): Promise<PaginatedResponse<Bookmark>>;
591
- }
592
-
593
- interface ServerApiOptions {
594
- publishableKey?: string;
595
- secretKey: string;
596
- onRequestId?: (id: string | null) => void;
597
- }
598
- interface RequestOptions {
599
- method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
600
- headers?: Record<string, string>;
601
- }
602
- declare abstract class BaseApi {
603
- protected readonly publishableKey: string;
604
- protected readonly secretKey: string;
605
- protected readonly onRequestId?: (id: string | null) => void;
606
- constructor(apiName: string, options: ServerApiOptions);
607
- protected request<T>(endpoint: string, body: unknown, options?: RequestOptions): Promise<T>;
608
- }
609
-
610
- type ModerationApiOptions = ServerApiOptions;
611
- interface CommunityBan {
612
- id: string;
613
- customer: string;
614
- isPermanent?: boolean;
615
- bannedUntil?: string;
616
- reason?: string;
617
- createdAt?: string;
618
- updatedAt?: string;
619
- [key: string]: unknown;
620
- }
621
- type BanCustomerParams = {
622
- customerId: string;
623
- isPermanent?: boolean;
624
- bannedUntil?: string;
625
- reason?: string;
626
- };
627
- type UnbanCustomerParams = {
628
- customerId: string;
629
- };
630
- declare class ModerationApi extends BaseApi {
631
- constructor(options: ModerationApiOptions);
632
- banCustomer(params: BanCustomerParams): Promise<CommunityBan>;
633
- unbanCustomer(params: UnbanCustomerParams): Promise<{
634
- success: true;
635
- }>;
636
- }
637
-
638
- interface CustomerAuthResponse {
639
- token: string;
640
- customer: CustomerProfile;
641
- }
642
- interface MarketingConsentChannel {
643
- isConsented?: boolean;
644
- }
645
- interface MarketingConsent {
646
- email?: MarketingConsentChannel;
647
- sms?: MarketingConsentChannel;
648
- push?: MarketingConsentChannel;
649
- consentSource?: string;
650
- }
651
- interface CustomerProfile {
652
- id: string;
653
- name: string;
654
- email?: string | null;
655
- phone?: string | null;
656
- authProvider?: 'local' | 'google' | 'apple' | 'kakao' | 'naver' | null;
657
- isGuest?: boolean | null;
658
- marketingConsent?: MarketingConsent | null;
659
- metadata?: Record<string, unknown> | null;
660
- groups?: string[];
661
- }
662
- interface CustomerRegisterData {
663
- name: string;
664
- email: string;
665
- password: string;
666
- phone?: string;
667
- }
668
- interface CustomerRegisterResponse {
669
- customer: CustomerProfile;
670
- }
671
- interface CustomerLoginData {
672
- email: string;
673
- password: string;
674
- }
675
- interface CustomerRefreshResponse {
676
- token: string;
677
- }
678
- interface UpdateProfileData {
679
- name?: string;
680
- phone?: string;
681
- marketingConsent?: MarketingConsent;
682
- }
683
- interface CustomerAuthOptions {
684
- /**
685
- * Persist token in localStorage. Defaults to `true`.
686
- * - `true` (default): uses key `'customer-token'`
687
- * - `string`: uses the given string as localStorage key
688
- * - `false`: disables persistence (token/onTokenChange used instead)
689
- *
690
- * Handles SSR safely (no-op on server).
691
- * When enabled, `token` and `onTokenChange` are ignored.
692
- */
693
- persist?: boolean | string;
694
- /** Initial token (e.g. from SSR cookie) */
695
- token?: string;
696
- /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
697
- onTokenChange?: (token: string | null) => void;
698
- }
699
-
700
- /**
701
- * Customer authentication client.
702
- *
703
- * Manages customer registration, login, logout, and token lifecycle.
704
- * All requests include X-Publishable-Key for tenant resolution.
705
- */
706
- declare class CustomerAuth {
707
- private publishableKey;
708
- private baseUrl;
709
- private token;
710
- private onTokenChange?;
711
- private refreshPromise;
712
- constructor(publishableKey: string, options?: CustomerAuthOptions);
713
- /**
714
- * Register a new customer account
715
- */
716
- register(data: CustomerRegisterData): Promise<CustomerRegisterResponse>;
717
- /**
718
- * Login with email and password. Stores the token internally.
719
- */
720
- login(data: CustomerLoginData): Promise<CustomerAuthResponse>;
721
- /**
722
- * Refresh the current token. Requires a valid (non-expired) token.
723
- */
724
- refreshToken(): Promise<CustomerRefreshResponse>;
725
- private _doRefreshToken;
726
- /**
727
- * Clear the stored token
728
- */
729
- logout(): void;
730
- /**
731
- * Get the current authenticated customer's profile
732
- */
733
- me(): Promise<CustomerProfile | null>;
734
- /**
735
- * Request a password reset email
736
- */
737
- forgotPassword(email: string): Promise<void>;
738
- /**
739
- * Reset password using a token from the reset email
740
- */
741
- resetPassword(token: string, password: string): Promise<void>;
742
- /**
743
- * Update the authenticated customer's profile (name, phone, marketingConsent)
744
- */
745
- updateProfile(data: UpdateProfileData): Promise<CustomerProfile>;
746
- /**
747
- * Change the password of the currently authenticated customer
748
- */
749
- changePassword(currentPassword: string, newPassword: string): Promise<void>;
750
- /**
751
- * Get the authenticated customer's orders with pagination and optional status filter
752
- */
753
- getMyOrders(options?: {
754
- page?: number;
755
- limit?: number;
756
- status?: string;
757
- }): Promise<PayloadFindResponse<Order>>;
758
- /**
759
- * Get the current token (or null if not authenticated)
760
- */
761
- getToken(): string | null;
762
- /**
763
- * Set the token manually (e.g. from SSR)
764
- */
765
- setToken(token: string | null): void;
766
- /**
767
- * Check if the customer is currently authenticated
768
- */
769
- isAuthenticated(): boolean;
770
- /**
771
- * Internal: make a request with timeout and error handling.
772
- * Auth endpoints don't retry — failures are final.
773
- */
774
- private requestJson;
775
- }
14
+ import 'payload';
15
+ import 'next';
776
16
 
777
17
  /**
778
18
  * Customer namespace. Currently exposes .auth; reserved for future customer-
@@ -783,360 +23,6 @@ declare class CustomerNamespace {
783
23
  constructor(publishableKey: string, options?: CustomerAuthOptions);
784
24
  }
785
25
 
786
- interface CartApiOptions {
787
- publishableKey?: string;
788
- secretKey?: string;
789
- customerToken?: string | (() => string | null);
790
- onUnauthorized?: () => Promise<string | null>;
791
- onRequestId?: (id: string | null) => void;
792
- }
793
- type AddItemParams = {
794
- cartId: string;
795
- product: string;
796
- variant: string;
797
- option: string;
798
- quantity: number;
799
- };
800
- type UpdateItemParams = {
801
- cartItemId: string;
802
- quantity: number;
803
- };
804
- type RemoveItemParams = {
805
- cartItemId: string;
806
- };
807
- type ApplyDiscountParams = {
808
- cartId: string;
809
- discountCode: string;
810
- };
811
- type RemoveDiscountParams = {
812
- cartId: string;
813
- };
814
- type ClearCartParams = {
815
- cartId: string;
816
- };
817
- declare class CartApi {
818
- private readonly publishableKey;
819
- private readonly secretKey?;
820
- private readonly customerToken?;
821
- private readonly onUnauthorized?;
822
- private readonly onRequestId?;
823
- constructor(options: CartApiOptions);
824
- private execute;
825
- getCart(cartId: string): Promise<Cart>;
826
- addItem(params: AddItemParams): Promise<CartItem>;
827
- updateItem(params: UpdateItemParams): Promise<CartItem>;
828
- removeItem(params: RemoveItemParams): Promise<{
829
- success: boolean;
830
- }>;
831
- applyDiscount(params: ApplyDiscountParams): Promise<Cart>;
832
- removeDiscount(params: RemoveDiscountParams): Promise<Cart>;
833
- clearCart(params: ClearCartParams): Promise<{
834
- success: boolean;
835
- }>;
836
- }
837
-
838
- type EntityID = string;
839
- type RelationshipValue = string | number | null | undefined | {
840
- id?: string | number | null;
841
- };
842
- type MediaValue = {
843
- id?: EntityID | null;
844
- } | EntityID | null | undefined;
845
- interface ProductOptionValueShape {
846
- id?: string | number | null;
847
- option?: RelationshipValue;
848
- value?: string | null;
849
- slug?: string | null;
850
- _order?: string | null;
851
- '_product-option-values_values_order'?: string | null;
852
- }
853
- interface ProductOptionShape {
854
- id?: string | number | null;
855
- title?: string | null;
856
- _order?: string | null;
857
- '_product-options_options_order'?: string | null;
858
- values?: {
859
- docs?: unknown[];
860
- } | null;
861
- }
862
- interface ProductVariantShape {
863
- id?: string | number | null;
864
- optionValues?: unknown[] | null;
865
- price?: number | null;
866
- compareAtPrice?: number | null;
867
- stock?: number | null;
868
- isUnlimited?: boolean | null;
869
- isActive?: boolean | null;
870
- thumbnail?: MediaValue;
871
- images?: MediaValue[] | null;
872
- _order?: string | null;
873
- }
874
- interface ProductListingProductShape {
875
- id?: EntityID;
876
- thumbnail?: MediaValue;
877
- images?: MediaValue[] | null;
878
- }
879
- type ProductOptionMatrixValue = {
880
- id: string;
881
- optionId: string;
882
- label: string;
883
- slug: string | null;
884
- order: string;
885
- };
886
- type ProductOptionMatrixOption = {
887
- id: string;
888
- title: string;
889
- order: string;
890
- values: ProductOptionMatrixValue[];
891
- };
892
- type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
893
- id: string;
894
- optionValueIds: string[];
895
- optionValueByOptionId: Map<string, string>;
896
- source: TVariant;
897
- };
898
- type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
899
- options: ProductOptionMatrixOption[];
900
- optionIds: string[];
901
- optionById: Map<string, ProductOptionMatrixOption>;
902
- valueById: Map<string, ProductOptionMatrixValue>;
903
- valueToOptionId: Map<string, string>;
904
- variants: ProductOptionMatrixVariant<TVariant>[];
905
- };
906
- type ProductListingProjection = {
907
- selectionHintVariant: EntityID | null;
908
- primaryImage: EntityID | null;
909
- minPrice: number | null;
910
- maxPrice: number | null;
911
- minCompareAtPrice: number | null;
912
- maxCompareAtPrice: number | null;
913
- isPriceRange: boolean;
914
- availableForSale: boolean;
915
- };
916
- type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
917
- optionId: EntityID;
918
- optionTitle: string;
919
- optionValueId: EntityID;
920
- optionValueLabel: string;
921
- optionValueSlug: string | null;
922
- variantIds: EntityID[];
923
- variantCount: number;
924
- variants: TVariant[];
925
- listing: ProductListingProjection;
926
- };
927
- declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
928
- options: ProductOptionShape[];
929
- variants?: TVariant[];
930
- }): ProductOptionMatrix<TVariant>;
931
- declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
932
- declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
933
- declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
934
- declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
935
- declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
936
- declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
937
- product: ProductListingProductShape | null | undefined;
938
- options: ProductOptionShape[];
939
- variants: TVariant[];
940
- primaryOptionId?: string | null;
941
- }): ProductListingGroup<TVariant>[];
942
-
943
- type ProductApiOptions = ServerApiOptions;
944
- type StockCheckParams = {
945
- items: Array<{
946
- variantId: string;
947
- quantity: number;
948
- }>;
949
- };
950
- type StockCheckResult = {
951
- variantId: string;
952
- available: boolean;
953
- availableStock: number;
954
- requestedQuantity: number;
955
- error?: string;
956
- };
957
- type StockCheckResponse = {
958
- results: StockCheckResult[];
959
- allAvailable: boolean;
960
- };
961
- type ListingGroupsParams = {
962
- productIds: string[];
963
- };
964
- type ProductListingGroupSummary = Omit<ProductListingGroup, 'variants'>;
965
- type ProductListingGroupsItem = {
966
- product: Product;
967
- primaryOptionId: string | null;
968
- groups: ProductListingGroupSummary[];
969
- };
970
- type ProductListingGroupsResponse = {
971
- docs: ProductListingGroupsItem[];
972
- };
973
- declare class ProductApi extends BaseApi {
974
- constructor(options: ProductApiOptions);
975
- /**
976
- * Check point-in-time stock availability for one or more product variants.
977
- * Results reflect available stock at the moment of the call and are not guaranteed
978
- * to remain available by the time an order is placed.
979
- */
980
- stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
981
- listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
982
- }
983
-
984
- type DiscountApiOptions = ServerApiOptions;
985
- type ValidateDiscountParams = {
986
- code: string;
987
- orderAmount: number;
988
- };
989
- type ValidateDiscountResult = {
990
- valid: boolean;
991
- code: string;
992
- type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
993
- discountAmount: number;
994
- freeShipping?: boolean;
995
- reason?: string;
996
- };
997
- declare class DiscountApi extends BaseApi {
998
- constructor(options: DiscountApiOptions);
999
- validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
1000
- }
1001
-
1002
- type ShippingApiOptions = ServerApiOptions;
1003
- type CalculateShippingParams = {
1004
- shippingPolicyId?: string;
1005
- orderAmount: number;
1006
- postalCode?: string;
1007
- };
1008
- type CalculateShippingResult = {
1009
- shippingAmount: number;
1010
- baseShippingAmount: number;
1011
- extraShippingAmount: number;
1012
- freeShipping: boolean;
1013
- freeShippingMinAmount: number | null;
1014
- isJeju: boolean;
1015
- isRemoteIsland: boolean;
1016
- };
1017
- declare class ShippingApi extends BaseApi {
1018
- constructor(options: ShippingApiOptions);
1019
- calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
1020
- }
1021
-
1022
- type OrderApiOptions = ServerApiOptions;
1023
- type CustomerSnapshot = {
1024
- name?: string;
1025
- email: string;
1026
- phone?: string;
1027
- };
1028
- type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
1029
- type ReturnItem = {
1030
- orderItem: string;
1031
- quantity: number;
1032
- };
1033
- type CreateOrderParams = {
1034
- orderNumber: string;
1035
- customer?: string;
1036
- customerSnapshot: CustomerSnapshot;
1037
- shippingAddress: Order['shippingAddress'];
1038
- orderItems: Pick<OrderItem$1, 'product' | 'variant' | 'quantity' | 'unitPrice' | 'totalPrice'>[];
1039
- totalAmount: number;
1040
- shippingAmount?: number;
1041
- pgPaymentId?: string;
1042
- discountCode?: string;
1043
- };
1044
- type UpdateOrderParams = {
1045
- orderNumber: string;
1046
- status: Order['status'];
1047
- };
1048
- type TransactionStatus = 'pending' | 'paid' | 'failed' | 'canceled';
1049
- type UpdateTransactionParams = {
1050
- pgPaymentId: string;
1051
- status: TransactionStatus;
1052
- paymentMethod?: string;
1053
- receiptUrl?: string;
1054
- paymentKey?: string;
1055
- amount?: number;
1056
- };
1057
- type RestockAction = 'return_to_stock' | 'discard';
1058
- type ReturnWithRefundItem = {
1059
- orderItem: string | number;
1060
- quantity: number;
1061
- restockAction?: RestockAction;
1062
- };
1063
- type ReturnWithRefundParams = {
1064
- orderNumber: string;
1065
- reason?: ReturnReason;
1066
- reasonDetail?: string;
1067
- returnItems: ReturnWithRefundItem[];
1068
- refundAmount: number;
1069
- pgPaymentId: string;
1070
- paymentKey?: string;
1071
- refundReceiptUrl?: string;
1072
- };
1073
- type CheckoutParams = {
1074
- cartId: string;
1075
- orderNumber: string;
1076
- customerSnapshot: CustomerSnapshot;
1077
- pgPaymentId?: string;
1078
- discountCode?: string;
1079
- };
1080
- type CreateFulfillmentParams = {
1081
- orderNumber: string;
1082
- carrier?: string;
1083
- trackingNumber?: string;
1084
- items: Array<{
1085
- orderItem: string;
1086
- quantity: number;
1087
- }>;
1088
- };
1089
- type UpdateFulfillmentParams = {
1090
- fulfillmentId: string;
1091
- status: 'packed' | 'shipped' | 'delivered' | 'failed';
1092
- carrier?: string;
1093
- trackingNumber?: string;
1094
- };
1095
- type BulkImportFulfillmentsParams = {
1096
- items: Array<{
1097
- orderNumber: string;
1098
- carrier?: string;
1099
- trackingNumber?: string;
1100
- }>;
1101
- };
1102
- type BulkImportFulfillmentsResponse = {
1103
- succeeded: Array<{
1104
- orderNumber: string;
1105
- fulfillmentId: string;
1106
- }>;
1107
- failed: Array<{
1108
- orderNumber: string;
1109
- error: string;
1110
- }>;
1111
- };
1112
- type CreateReturnParams = {
1113
- orderNumber: string;
1114
- reason?: ReturnReason;
1115
- reasonDetail?: string;
1116
- returnItems: ReturnItem[];
1117
- refundAmount: number;
1118
- };
1119
- type UpdateReturnParams = {
1120
- returnId: string;
1121
- status: 'processing' | 'approved' | 'rejected' | 'completed';
1122
- };
1123
- declare class OrderApi extends BaseApi {
1124
- constructor(options: OrderApiOptions);
1125
- createOrder(params: CreateOrderParams): Promise<Order>;
1126
- updateOrder(params: UpdateOrderParams): Promise<Order>;
1127
- updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
1128
- checkout(params: CheckoutParams): Promise<Order>;
1129
- createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
1130
- updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
1131
- bulkImportFulfillments(params: BulkImportFulfillmentsParams): Promise<BulkImportFulfillmentsResponse>;
1132
- returnWithRefund(params: ReturnWithRefundParams): Promise<{
1133
- return: Return;
1134
- transaction: Transaction | null;
1135
- }>;
1136
- createReturn(params: CreateReturnParams): Promise<Return>;
1137
- updateReturn(params: UpdateReturnParams): Promise<Return>;
1138
- }
1139
-
1140
26
  interface CommerceClientOptions {
1141
27
  publishableKey: string;
1142
28
  customerToken: () => string | null;
@@ -1179,183 +65,6 @@ declare class CommerceClient {
1179
65
  constructor(options: CommerceClientOptions);
1180
66
  }
1181
67
 
1182
- interface ServerCommerceClientOptions {
1183
- publishableKey?: string;
1184
- secretKey: string;
1185
- onRequestId?: (id: string | null) => void;
1186
- }
1187
- declare class ServerCommerceClient {
1188
- readonly product: {
1189
- stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1190
- listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1191
- };
1192
- readonly cart: {
1193
- get: (cartId: string) => Promise<Cart>;
1194
- addItem: (params: AddItemParams) => Promise<CartItem>;
1195
- updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1196
- removeItem: (params: RemoveItemParams) => Promise<{
1197
- success: boolean;
1198
- }>;
1199
- applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1200
- removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1201
- clear: (params: ClearCartParams) => Promise<{
1202
- success: boolean;
1203
- }>;
1204
- };
1205
- readonly orders: {
1206
- checkout: (params: CheckoutParams) => Promise<Order>;
1207
- create: (params: CreateOrderParams) => Promise<Order>;
1208
- update: (params: UpdateOrderParams) => Promise<Order>;
1209
- updateTransaction: (params: UpdateTransactionParams) => Promise<Transaction>;
1210
- createFulfillment: (params: CreateFulfillmentParams) => Promise<Fulfillment>;
1211
- updateFulfillment: (params: UpdateFulfillmentParams) => Promise<Fulfillment>;
1212
- bulkImportFulfillments: (params: BulkImportFulfillmentsParams) => Promise<BulkImportFulfillmentsResponse>;
1213
- createReturn: (params: CreateReturnParams) => Promise<Return>;
1214
- updateReturn: (params: UpdateReturnParams) => Promise<Return>;
1215
- returnWithRefund: (params: ReturnWithRefundParams) => Promise<{
1216
- return: Return;
1217
- transaction: Transaction | null;
1218
- }>;
1219
- };
1220
- readonly discounts: {
1221
- validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
1222
- };
1223
- readonly shipping: {
1224
- calculate: (params: CalculateShippingParams) => Promise<CalculateShippingResult>;
1225
- };
1226
- constructor(options: ServerCommerceClientOptions);
1227
- }
1228
-
1229
- interface CollectionQueryParams<T extends PublicCollection> {
1230
- collection: T;
1231
- options?: ApiQueryOptions;
1232
- }
1233
- interface CollectionDetailQueryParams<T extends PublicCollection> {
1234
- collection: T;
1235
- id: string;
1236
- options?: ApiQueryOptions;
1237
- }
1238
- interface CollectionInfiniteQueryParams<T extends PublicCollection> {
1239
- collection: T;
1240
- options?: Omit<ApiQueryOptions, 'page'>;
1241
- pageSize?: number;
1242
- }
1243
- interface QueryOptions<TQueryFnData = unknown, TData = TQueryFnData> {
1244
- enabled?: boolean;
1245
- staleTime?: number;
1246
- gcTime?: number;
1247
- refetchOnWindowFocus?: boolean;
1248
- refetchOnMount?: boolean | 'always';
1249
- refetchInterval?: number | false;
1250
- retry?: boolean | number;
1251
- select?: (data: TQueryFnData) => TData;
1252
- placeholderData?: TQueryFnData | ((previousData: TData | undefined) => TQueryFnData | undefined);
1253
- initialData?: TQueryFnData | (() => TQueryFnData);
1254
- initialDataUpdatedAt?: number | (() => number | undefined);
1255
- }
1256
- type SuspenseQueryOptions<TQueryFnData = unknown, TData = TQueryFnData> = Omit<QueryOptions<TQueryFnData, TData>, 'enabled' | 'placeholderData'>;
1257
- interface InfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> {
1258
- enabled?: boolean;
1259
- staleTime?: number;
1260
- gcTime?: number;
1261
- refetchOnWindowFocus?: boolean;
1262
- refetchOnMount?: boolean | 'always';
1263
- refetchInterval?: number | false;
1264
- retry?: boolean | number;
1265
- select?: (data: InfiniteData<TQueryFnData>) => TData;
1266
- }
1267
- type SuspenseInfiniteQueryOptions<TQueryFnData = unknown, TData = InfiniteData<TQueryFnData>> = Omit<InfiniteQueryOptions<TQueryFnData, TData>, 'enabled'>;
1268
- interface MutationCallbacks$1<TData> {
1269
- onSuccess?: (data: TData) => void;
1270
- onError?: (error: SDKError) => void;
1271
- onSettled?: () => void;
1272
- }
1273
- declare class CollectionHooks {
1274
- protected queryClient: QueryClient;
1275
- protected collectionClient: CollectionClient;
1276
- constructor(queryClient: QueryClient, collectionClient: CollectionClient);
1277
- 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>;
1278
- useSuspenseQuery<T extends PublicCollection, TData = PayloadFindResponse<CollectionType<T>>>(params: CollectionQueryParams<T>, options?: SuspenseQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1279
- 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>;
1280
- useSuspenseQueryById<T extends PublicCollection, TData = CollectionType<T>>(params: CollectionDetailQueryParams<T>, options?: SuspenseQueryOptions<CollectionType<T>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1281
- useInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: InfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
1282
- useSuspenseInfiniteQuery<T extends PublicCollection, TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>>(params: CollectionInfiniteQueryParams<T>, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<CollectionType<T>>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
1283
- prefetchQuery<T extends PublicCollection>(params: CollectionQueryParams<T>, options?: {
1284
- staleTime?: number;
1285
- }): Promise<void>;
1286
- prefetchQueryById<T extends PublicCollection>(params: CollectionDetailQueryParams<T>, options?: {
1287
- staleTime?: number;
1288
- }): Promise<void>;
1289
- prefetchInfiniteQuery<T extends PublicCollection>(params: CollectionInfiniteQueryParams<T>, options?: {
1290
- pages?: number;
1291
- staleTime?: number;
1292
- }): Promise<void>;
1293
- useCreate<T extends PublicCollection>(params: {
1294
- collection: T;
1295
- }, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
1296
- data: Partial<CollectionType<T>>;
1297
- file?: File | Blob;
1298
- filename?: string;
1299
- }, unknown>;
1300
- useUpdate<T extends PublicCollection>(params: {
1301
- collection: T;
1302
- }, options?: MutationCallbacks$1<PayloadMutationResponse<CollectionType<T>>>): _tanstack_react_query.UseMutationResult<PayloadMutationResponse<CollectionType<T>>, SDKError, {
1303
- id: string;
1304
- data: Partial<CollectionType<T>>;
1305
- file?: File | Blob;
1306
- filename?: string;
1307
- }, unknown>;
1308
- useRemove<T extends PublicCollection>(params: {
1309
- collection: T;
1310
- }, options?: MutationCallbacks$1<CollectionType<T>>): _tanstack_react_query.UseMutationResult<CollectionType<T>, SDKError, string, unknown>;
1311
- invalidateQueries<T extends PublicCollection>(collection: T, type?: 'list' | 'detail' | 'infinite'): Promise<void>;
1312
- getQueryData<T extends PublicCollection>(collection: T, type: 'list', options?: ApiQueryOptions): PayloadFindResponse<CollectionType<T>> | undefined;
1313
- getQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, options?: ApiQueryOptions): CollectionType<T> | null | undefined;
1314
- setQueryData<T extends PublicCollection>(collection: T, type: 'list', data: PayloadFindResponse<CollectionType<T>>, options?: ApiQueryOptions): void;
1315
- setQueryData<T extends PublicCollection>(collection: T, type: 'detail', id: string, data: CollectionType<T> | null, options?: ApiQueryOptions): void;
1316
- }
1317
-
1318
- interface MutationCallbacks<TData> {
1319
- onSuccess?: (data: TData) => void;
1320
- onError?: (error: SDKError) => void;
1321
- onSettled?: () => void;
1322
- }
1323
- declare class CustomerHooks {
1324
- private queryClient;
1325
- private customerAuth?;
1326
- constructor(queryClient: QueryClient, customerAuth?: CustomerAuth);
1327
- private ensureCustomerAuth;
1328
- private invalidateMe;
1329
- useCustomerMe(options?: {
1330
- enabled?: boolean;
1331
- staleTime?: number;
1332
- gcTime?: number;
1333
- refetchOnWindowFocus?: boolean;
1334
- refetchOnMount?: boolean | 'always';
1335
- refetchInterval?: number | false;
1336
- retry?: boolean | number;
1337
- }): _tanstack_react_query.UseQueryResult<CustomerProfile | null, Error>;
1338
- useCustomerLogin(options?: MutationCallbacks<CustomerAuthResponse>): _tanstack_react_query.UseMutationResult<CustomerAuthResponse, SDKError, CustomerLoginData, unknown>;
1339
- useCustomerRegister(options?: MutationCallbacks<{
1340
- customer: CustomerProfile;
1341
- }>): _tanstack_react_query.UseMutationResult<CustomerRegisterResponse, SDKError, CustomerRegisterData, unknown>;
1342
- useCustomerLogout(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, void, unknown>;
1343
- useCustomerForgotPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, string, unknown>;
1344
- useCustomerResetPassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
1345
- token: string;
1346
- password: string;
1347
- }, unknown>;
1348
- useCustomerRefreshToken(options?: MutationCallbacks<CustomerRefreshResponse>): _tanstack_react_query.UseMutationResult<CustomerRefreshResponse, SDKError, unknown, unknown>;
1349
- useCustomerUpdateProfile(options?: MutationCallbacks<CustomerProfile>): _tanstack_react_query.UseMutationResult<CustomerProfile, SDKError, UpdateProfileData, unknown>;
1350
- useCustomerChangePassword(options?: MutationCallbacks<void>): _tanstack_react_query.UseMutationResult<void, SDKError, {
1351
- currentPassword: string;
1352
- newPassword: string;
1353
- }, unknown>;
1354
- invalidateCustomerQueries(): Promise<void>;
1355
- getCustomerData(): CustomerProfile | null | undefined;
1356
- setCustomerData(data: CustomerProfile | null): void;
1357
- }
1358
-
1359
68
  declare function collectionKeys<T extends PublicCollection>(collection: T): {
1360
69
  all: readonly [T];
1361
70
  lists: () => readonly [T, "list"];
@@ -1374,61 +83,12 @@ declare const productKeys: {
1374
83
  listingGroupsInfinite: (options?: Omit<ProductListingGroupsQueryOptions, "page" | "limit">) => readonly ["products", "listing-groups", "infinite", Omit<ProductListingGroupsQueryOptions, "limit" | "page"> | undefined];
1375
84
  };
1376
85
 
1377
- type ProductListingGroupsQueryOptions = Pick<ApiQueryOptions, 'page' | 'limit' | 'sort' | 'where'>;
1378
- type ReadOnlyQueryHooks = Omit<QueryHooks, 'useCreate' | 'useUpdate' | 'useRemove'>;
1379
- /**
1380
- * Composes CollectionHooks + CustomerHooks into a single API surface.
1381
- * All methods are delegated; no logic lives here.
1382
- */
1383
- declare class QueryHooks extends CollectionHooks {
1384
- private _customer;
1385
- constructor(queryClient: QueryClient, collectionClient: CollectionClient, customerAuth?: CustomerAuth);
1386
- useCustomerMe: CustomerHooks['useCustomerMe'];
1387
- useCustomerLogin: CustomerHooks['useCustomerLogin'];
1388
- useCustomerRegister: CustomerHooks['useCustomerRegister'];
1389
- useCustomerLogout: CustomerHooks['useCustomerLogout'];
1390
- useCustomerForgotPassword: CustomerHooks['useCustomerForgotPassword'];
1391
- useCustomerResetPassword: CustomerHooks['useCustomerResetPassword'];
1392
- useCustomerRefreshToken: CustomerHooks['useCustomerRefreshToken'];
1393
- useCustomerUpdateProfile: CustomerHooks['useCustomerUpdateProfile'];
1394
- useCustomerChangePassword: CustomerHooks['useCustomerChangePassword'];
1395
- invalidateCustomerQueries: CustomerHooks['invalidateCustomerQueries'];
1396
- getCustomerData: CustomerHooks['getCustomerData'];
1397
- setCustomerData: CustomerHooks['setCustomerData'];
1398
- useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
1399
- options?: ProductListingGroupsQueryOptions;
1400
- }, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseQueryResult<_tanstack_react_query.NoInfer<TData>, Error>;
1401
- useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
1402
- options?: ProductListingGroupsQueryOptions;
1403
- }, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseQueryResult<TData, Error>;
1404
- useInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
1405
- options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1406
- pageSize?: number;
1407
- }, options?: InfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseInfiniteQueryResult<TData, Error>;
1408
- useSuspenseInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
1409
- options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1410
- pageSize?: number;
1411
- }, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): _tanstack_react_query.UseSuspenseInfiniteQueryResult<TData, Error>;
1412
- prefetchProductListingGroupsQuery(params: {
1413
- options?: ProductListingGroupsQueryOptions;
1414
- }, options?: {
1415
- staleTime?: number;
1416
- }): Promise<void>;
1417
- prefetchInfiniteProductListingGroupsQuery(params: {
1418
- options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
1419
- pageSize?: number;
1420
- }, options?: {
1421
- pages?: number;
1422
- staleTime?: number;
1423
- }): Promise<void>;
1424
- }
1425
-
1426
86
  declare class Client {
1427
87
  commerce: CommerceClient;
1428
88
  community: CommunityClient;
1429
89
  customer: CustomerNamespace;
1430
90
  query: ReadOnlyQueryHooks;
1431
- collections: CollectionClient;
91
+ collections: ReadOnlyCollectionClient;
1432
92
  queryClient: QueryClient;
1433
93
  lastRequestId: string | null;
1434
94
  protected state: ClientState;
@@ -1444,32 +104,6 @@ declare class Client {
1444
104
  */
1445
105
  declare function createClient(options: ClientConfig): Client;
1446
106
 
1447
- declare class ServerClient {
1448
- commerce: ServerCommerceClient;
1449
- community: CommunityClient & {
1450
- moderation: {
1451
- banCustomer: (p: BanCustomerParams) => Promise<CommunityBan>;
1452
- unbanCustomer: (p: UnbanCustomerParams) => Promise<{
1453
- success: true;
1454
- }>;
1455
- };
1456
- };
1457
- query: QueryHooks;
1458
- collections: CollectionClient;
1459
- queryClient: QueryClient;
1460
- lastRequestId: string | null;
1461
- protected state: ClientState;
1462
- protected config: ClientServerConfig;
1463
- constructor(options: ClientServerConfig);
1464
- getState(): ClientState;
1465
- getConfig(): Omit<ClientServerConfig, 'secretKey'>;
1466
- }
1467
- /**
1468
- * Create a server-only client with full read/write access. Requires secretKey.
1469
- * For read-only usage, prefer `createClient()` (no secretKey needed).
1470
- */
1471
- declare function createServerClient(options: ClientServerConfig): ServerClient;
1472
-
1473
107
  declare function getQueryClient(): QueryClient;
1474
108
 
1475
109
  declare const generateOrderNumber: () => string;
@@ -1490,4 +124,4 @@ declare const formatOrderName: (items: OrderItem[]) => string;
1490
124
  */
1491
125
  declare const resolveRelation: <T>(ref: T | string | number | null | undefined) => T | null;
1492
126
 
1493
- export { type AddItemParams, ApiError, type ApiQueryOptions, type ApplyDiscountParams, AuthError, type BanCustomerParams, BaseApi, type BulkImportFulfillmentsParams, type BulkImportFulfillmentsResponse, type CalculateShippingParams, type CalculateShippingResult, Cart, CartApi, type CartApiOptions, CartItem, type CheckoutParams, type ClearCartParams, Client, type ClientConfig, type ClientMetadata, type ClientServerConfig, type ClientState, Client as ClientType, CollectionClient, type CollectionDetailQueryParams, CollectionHooks, type CollectionInfiniteQueryParams, CollectionQueryBuilder, type CollectionQueryParams, CollectionType, CommerceClient, type CommerceClientOptions, type CommunityBan, CommunityClient, type CommunityClientOptions, type CommunityPost, ConfigError, ConflictError, type CreateFulfillmentParams, type CreateOrderParams, type CreateReturnParams, CustomerAuth, type CustomerAuthOptions, type CustomerAuthResponse, CustomerHooks, type CustomerLoginData, CustomerNamespace, type CustomerProfile, type CustomerRefreshResponse, type CustomerRegisterData, type CustomerRegisterResponse, type CustomerSnapshot, type DebugConfig, type DeepPartial, DiscountApi, type DiscountApiOptions, type ExtractArrayType, type GenerateMetadataOptions, GoneError, type InfiniteQueryOptions, type ListingGroupsParams, ModerationApi, type ModerationApiOptions, NetworkError, NotFoundError, Order, OrderApi, type OrderApiOptions, type PaginationMeta, type PayloadFindResponse, type PayloadMutationResponse, PermissionError, Product, ProductApi, type ProductApiOptions, type ProductListingGroup, type ProductListingGroupSummary, type ProductListingGroupsItem, type ProductListingGroupsQueryOptions, type ProductListingGroupsResponse, type ProductListingProductShape, type ProductListingProjection, type ProductOptionMatrix, type ProductOptionMatrixOption, type ProductOptionMatrixValue, type ProductOptionMatrixVariant, type ProductOptionShape, type ProductOptionValueShape, type ProductVariantShape, PublicCollection, QueryHooks, type QueryOptions, RateLimitError, type ReadOnlyQueryBuilder, type ReadOnlyQueryHooks, type RemoveDiscountParams, type RemoveItemParams, type RequestOptions, type RetryConfig, type ReturnItem, type ReturnReason, type ReturnWithRefundParams, SDKError, type ServerApiOptions, ServerClient, ServerClient as ServerClientType, ServerCommerceClient, type ServerCommerceClientOptions, ServiceUnavailableError, ShippingApi, type ShippingApiOptions, type StockCheckParams, type StockCheckResponse, type StockCheckResult, type SuspenseInfiniteQueryOptions, type SuspenseQueryOptions, TimeoutError, type UnbanCustomerParams, type UpdateFulfillmentParams, type UpdateItemParams, type UpdateOrderParams, type UpdateProfileData, type UpdateReturnParams, type UpdateTransactionParams, UsageLimitError, type ValidateDiscountParams, type ValidateDiscountResult, ValidationError, buildProductListingGroupsByOption, buildProductListingProjection, buildProductOptionMatrix, collectionKeys, createAuthError, createClient, createConflictError, createNotFoundError, createPermissionError, createRateLimitError, createServerClient, customerKeys, formatOrderName, generateOrderNumber, getAvailableOptionValues, getQueryClient, getSelectedValueByOptionId, isApiError, isAuthError, isConfigError, isConflictError, isGoneError, isNetworkError, isNotFoundError, isPermissionError, isRateLimitError, isSDKError, isServiceUnavailableError, isTimeoutError, isUsageLimitError, isValidationError, normalizeSelectedValueIds, productKeys, resolveApiUrl, resolveRelation, resolveVariantForSelection };
127
+ export { AddItemParams, ApiQueryOptions, ApplyDiscountParams, CalculateShippingParams, CalculateShippingResult, Cart, CartItem, CheckoutParams, ClearCartParams, Client, ClientConfig, ClientState, Client as ClientType, CommerceClient, type CommerceClientOptions, CommunityClient, CustomerAuth, CustomerAuthOptions, CustomerNamespace, ListingGroupsParams, Order, PayloadFindResponse, Product, ProductListingGroupsQueryOptions, ProductListingGroupsResponse, PublicCollection, ReadOnlyCollectionClient, ReadOnlyQueryHooks, RemoveDiscountParams, RemoveItemParams, StockCheckParams, StockCheckResponse, UpdateItemParams, ValidateDiscountParams, ValidateDiscountResult, collectionKeys, createClient, customerKeys, formatOrderName, generateOrderNumber, getQueryClient, productKeys, resolveRelation };