@01.software/sdk 0.28.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 (80) 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-mdQQtIOz.d.ts → const-B75IFDRi.d.ts} +2 -4
  19. package/dist/{const-Cz9Ki_I7.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 +1291 -1501
  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 +1292 -1520
  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-BrSYb-sh.d.cts → payload-types-DPjO_IbQ.d.cts} +17 -6
  35. package/dist/{payload-types-BrSYb-sh.d.ts → payload-types-DPjO_IbQ.d.ts} +17 -6
  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 +300 -844
  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 +300 -862
  55. package/dist/server.js.map +1 -1
  56. package/dist/{types-BLUb4cYq.d.ts → types-1fBLrYU7.d.ts} +1 -1
  57. package/dist/{types-CW4PaIL7.d.cts → types-BwT0eeaz.d.cts} +1 -1
  58. package/dist/types-Dlb2mwpX.d.cts +1249 -0
  59. package/dist/types-DuSKPiY5.d.ts +1249 -0
  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 +82 -13
  79. package/dist/server-C2Q9R-Lu.d.ts +0 -1662
  80. package/dist/server-D369bCVJ.d.cts +0 -1662
@@ -0,0 +1,1249 @@
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';
4
+
5
+ interface CommunityClientOptions {
6
+ publishableKey?: string;
7
+ secretKey?: string;
8
+ apiUrl?: string;
9
+ customerToken?: string | (() => string | null);
10
+ onUnauthorized?: () => Promise<string | null>;
11
+ onRequestId?: (id: string | null) => void;
12
+ }
13
+ interface CommunityPost {
14
+ id: string;
15
+ title?: string | null;
16
+ displayTitle?: string | null;
17
+ content?: unknown;
18
+ categories?: string[];
19
+ thumbnail?: string;
20
+ viewCount?: number;
21
+ createdAt?: string;
22
+ updatedAt?: string;
23
+ [key: string]: unknown;
24
+ }
25
+ interface Comment {
26
+ id: string;
27
+ body: string;
28
+ post?: string;
29
+ parent?: string;
30
+ rootComment?: string;
31
+ createdAt?: string;
32
+ updatedAt?: string;
33
+ [key: string]: unknown;
34
+ }
35
+ interface Reaction {
36
+ id: string;
37
+ post?: string;
38
+ comment?: string;
39
+ type?: string;
40
+ createdAt?: string;
41
+ [key: string]: unknown;
42
+ }
43
+ interface ReactionSummary {
44
+ counts: Record<string, number>;
45
+ total: number;
46
+ userReactions: string[];
47
+ }
48
+ interface Bookmark {
49
+ id: string;
50
+ post?: string;
51
+ createdAt?: string;
52
+ [key: string]: unknown;
53
+ }
54
+ interface ReactionType {
55
+ id: string;
56
+ title: string;
57
+ slug: string;
58
+ emoji?: string;
59
+ [key: string]: unknown;
60
+ }
61
+ interface PaginatedResponse<T> {
62
+ docs: T[];
63
+ totalDocs: number;
64
+ limit: number;
65
+ totalPages: number;
66
+ page: number;
67
+ pagingCounter: number;
68
+ hasPrevPage: boolean;
69
+ hasNextPage: boolean;
70
+ prevPage: number | null;
71
+ nextPage: number | null;
72
+ }
73
+ declare class CommunityClient {
74
+ private readonly publishableKey;
75
+ private readonly secretKey?;
76
+ private readonly apiUrl?;
77
+ private readonly customerToken?;
78
+ private readonly onUnauthorized?;
79
+ private readonly onRequestId?;
80
+ constructor(options: CommunityClientOptions);
81
+ private buildQuery;
82
+ private execute;
83
+ createPost(params: {
84
+ title?: string | null;
85
+ content?: unknown;
86
+ categories?: string[];
87
+ thumbnail?: string;
88
+ }): Promise<CommunityPost>;
89
+ getMyPosts(params?: {
90
+ page?: number;
91
+ limit?: number;
92
+ }): Promise<PaginatedResponse<CommunityPost>>;
93
+ getTrending(params?: {
94
+ page?: number;
95
+ limit?: number;
96
+ period?: string;
97
+ }): Promise<PaginatedResponse<CommunityPost>>;
98
+ incrementView(params: {
99
+ postId: string;
100
+ }): Promise<{
101
+ viewCount: number;
102
+ }>;
103
+ reportPost(params: {
104
+ postId: string;
105
+ reason?: string;
106
+ reasonDetail?: string;
107
+ }): Promise<{
108
+ success: boolean;
109
+ }>;
110
+ createComment(params: {
111
+ postId: string;
112
+ body: string;
113
+ parentId?: string;
114
+ }): Promise<Comment>;
115
+ listComments(params: {
116
+ postId: string;
117
+ page?: number;
118
+ limit?: number;
119
+ rootComment?: string;
120
+ }): Promise<PaginatedResponse<Comment>>;
121
+ updateComment(params: {
122
+ commentId: string;
123
+ body: string;
124
+ }): Promise<Comment>;
125
+ deleteComment(params: {
126
+ commentId: string;
127
+ }): Promise<{
128
+ success: boolean;
129
+ }>;
130
+ reportComment(params: {
131
+ commentId: string;
132
+ reason?: string;
133
+ reasonDetail?: string;
134
+ }): Promise<{
135
+ success: boolean;
136
+ }>;
137
+ addReaction(params: {
138
+ postId: string;
139
+ type: string;
140
+ }): Promise<Reaction>;
141
+ removeReaction(params: {
142
+ postId: string;
143
+ type: string;
144
+ }): Promise<{
145
+ success: boolean;
146
+ }>;
147
+ addCommentReaction(params: {
148
+ commentId: string;
149
+ type: string;
150
+ }): Promise<Reaction>;
151
+ removeCommentReaction(params: {
152
+ commentId: string;
153
+ type: string;
154
+ }): Promise<{
155
+ success: boolean;
156
+ }>;
157
+ getReactionSummary(params: {
158
+ postId: string;
159
+ }): Promise<ReactionSummary>;
160
+ getReactionTypes(): Promise<PaginatedResponse<ReactionType>>;
161
+ addBookmark(params: {
162
+ postId: string;
163
+ }): Promise<Bookmark>;
164
+ removeBookmark(params: {
165
+ postId: string;
166
+ }): Promise<{
167
+ success: boolean;
168
+ }>;
169
+ getMyBookmarks(params?: {
170
+ page?: number;
171
+ limit?: number;
172
+ }): Promise<PaginatedResponse<Bookmark>>;
173
+ }
174
+
175
+ interface ServerApiOptions {
176
+ publishableKey?: string;
177
+ secretKey: string;
178
+ apiUrl?: string;
179
+ onRequestId?: (id: string | null) => void;
180
+ }
181
+ interface RequestOptions {
182
+ method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
183
+ headers?: Record<string, string>;
184
+ }
185
+ declare abstract class BaseApi {
186
+ protected readonly publishableKey: string;
187
+ protected readonly secretKey: string;
188
+ protected readonly apiUrl?: string;
189
+ protected readonly onRequestId?: (id: string | null) => void;
190
+ constructor(apiName: string, options: ServerApiOptions);
191
+ protected request<T>(endpoint: string, body: unknown, options?: RequestOptions): Promise<T>;
192
+ }
193
+
194
+ interface CustomerAuthResponse {
195
+ token: string;
196
+ customer: CustomerProfile;
197
+ }
198
+ interface MarketingConsentChannel {
199
+ isConsented?: boolean;
200
+ }
201
+ interface MarketingConsent {
202
+ email?: MarketingConsentChannel;
203
+ sms?: MarketingConsentChannel;
204
+ push?: MarketingConsentChannel;
205
+ consentSource?: string;
206
+ }
207
+ interface CustomerProfile {
208
+ id: string;
209
+ name: string;
210
+ email?: string | null;
211
+ phone?: string | null;
212
+ authProvider?: 'local' | 'google' | 'apple' | 'kakao' | 'naver' | null;
213
+ isGuest?: boolean | null;
214
+ marketingConsent?: MarketingConsent | null;
215
+ metadata?: Record<string, unknown> | null;
216
+ groups?: string[];
217
+ }
218
+ interface CustomerRegisterData {
219
+ name: string;
220
+ email: string;
221
+ password: string;
222
+ phone?: string;
223
+ }
224
+ interface CustomerRegisterResponse {
225
+ customer: CustomerProfile;
226
+ }
227
+ interface CustomerLoginData {
228
+ email: string;
229
+ password: string;
230
+ }
231
+ interface CustomerRefreshResponse {
232
+ token: string;
233
+ }
234
+ interface UpdateProfileData {
235
+ name?: string;
236
+ phone?: string;
237
+ marketingConsent?: MarketingConsent;
238
+ }
239
+ interface CustomerAuthOptions {
240
+ /**
241
+ * Persist token in localStorage. Defaults to `true`.
242
+ * - `true` (default): uses key `'customer-token'`
243
+ * - `string`: uses the given string as localStorage key
244
+ * - `false`: disables persistence (token/onTokenChange used instead)
245
+ *
246
+ * Handles SSR safely (no-op on server).
247
+ * When enabled, `token` and `onTokenChange` are ignored.
248
+ */
249
+ persist?: boolean | string;
250
+ /** Initial token (e.g. from SSR cookie) */
251
+ token?: string;
252
+ /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
253
+ onTokenChange?: (token: string | null) => void;
254
+ }
255
+
256
+ /**
257
+ * Customer authentication client.
258
+ *
259
+ * Manages customer registration, login, logout, and token lifecycle.
260
+ * All requests include X-Publishable-Key for tenant resolution.
261
+ */
262
+ declare class CustomerAuth {
263
+ private publishableKey;
264
+ private baseUrl;
265
+ private token;
266
+ private onTokenChange?;
267
+ private refreshPromise;
268
+ constructor(publishableKey: string, options?: CustomerAuthOptions, apiUrl?: string);
269
+ /**
270
+ * Register a new customer account
271
+ */
272
+ register(data: CustomerRegisterData): Promise<CustomerRegisterResponse>;
273
+ /**
274
+ * Login with email and password. Stores the token internally.
275
+ */
276
+ login(data: CustomerLoginData): Promise<CustomerAuthResponse>;
277
+ /**
278
+ * Refresh the current token. Requires a valid (non-expired) token.
279
+ */
280
+ refreshToken(): Promise<CustomerRefreshResponse>;
281
+ private _doRefreshToken;
282
+ /**
283
+ * Clear the stored token
284
+ */
285
+ logout(): void;
286
+ /**
287
+ * Get the current authenticated customer's profile
288
+ */
289
+ me(): Promise<CustomerProfile | null>;
290
+ /**
291
+ * Request a password reset email
292
+ */
293
+ forgotPassword(email: string): Promise<void>;
294
+ /**
295
+ * Reset password using a token from the reset email
296
+ */
297
+ resetPassword(token: string, password: string): Promise<void>;
298
+ /**
299
+ * Update the authenticated customer's profile (name, phone, marketingConsent)
300
+ */
301
+ updateProfile(data: UpdateProfileData): Promise<CustomerProfile>;
302
+ /**
303
+ * Change the password of the currently authenticated customer
304
+ */
305
+ changePassword(currentPassword: string, newPassword: string): Promise<void>;
306
+ /**
307
+ * Get the authenticated customer's orders with pagination and optional status filter
308
+ */
309
+ getMyOrders(options?: {
310
+ page?: number;
311
+ limit?: number;
312
+ status?: string;
313
+ }): Promise<PayloadFindResponse<Order>>;
314
+ /**
315
+ * Get the current token (or null if not authenticated)
316
+ */
317
+ getToken(): string | null;
318
+ /**
319
+ * Set the token manually (e.g. from SSR)
320
+ */
321
+ setToken(token: string | null): void;
322
+ /**
323
+ * Check if the customer is currently authenticated
324
+ */
325
+ isAuthenticated(): boolean;
326
+ /**
327
+ * Internal: make a request with timeout and error handling.
328
+ * Auth endpoints don't retry — failures are final.
329
+ */
330
+ private requestJson;
331
+ }
332
+
333
+ interface CartApiOptions {
334
+ publishableKey?: string;
335
+ secretKey?: string;
336
+ apiUrl?: string;
337
+ customerToken?: string | (() => string | null);
338
+ onUnauthorized?: () => Promise<string | null>;
339
+ onRequestId?: (id: string | null) => void;
340
+ }
341
+ type AddItemParams = {
342
+ cartId: string;
343
+ product: string;
344
+ variant: string;
345
+ option: string;
346
+ quantity: number;
347
+ };
348
+ type UpdateItemParams = {
349
+ cartItemId: string;
350
+ quantity: number;
351
+ };
352
+ type RemoveItemParams = {
353
+ cartItemId: string;
354
+ };
355
+ type ApplyDiscountParams = {
356
+ cartId: string;
357
+ discountCode: string;
358
+ };
359
+ type RemoveDiscountParams = {
360
+ cartId: string;
361
+ };
362
+ type ClearCartParams = {
363
+ cartId: string;
364
+ };
365
+ declare class CartApi {
366
+ private readonly publishableKey;
367
+ private readonly secretKey?;
368
+ private readonly apiUrl?;
369
+ private readonly customerToken?;
370
+ private readonly onUnauthorized?;
371
+ private readonly onRequestId?;
372
+ constructor(options: CartApiOptions);
373
+ private execute;
374
+ getCart(cartId: string): Promise<Cart>;
375
+ addItem(params: AddItemParams): Promise<CartItem>;
376
+ updateItem(params: UpdateItemParams): Promise<CartItem>;
377
+ removeItem(params: RemoveItemParams): Promise<{
378
+ success: boolean;
379
+ }>;
380
+ applyDiscount(params: ApplyDiscountParams): Promise<Cart>;
381
+ removeDiscount(params: RemoveDiscountParams): Promise<Cart>;
382
+ clearCart(params: ClearCartParams): Promise<{
383
+ success: boolean;
384
+ }>;
385
+ }
386
+
387
+ type EntityID = string;
388
+ type RelationshipValue = string | number | null | undefined | {
389
+ id?: string | number | null;
390
+ };
391
+ type MediaValue = ProductDetailMedia | null | undefined;
392
+ interface ProductOptionValueShape {
393
+ id?: string | number | null;
394
+ option?: RelationshipValue;
395
+ value?: string | null;
396
+ slug?: string | null;
397
+ swatchColor?: string | null;
398
+ thumbnail?: MediaValue;
399
+ images?: MediaValue[] | null;
400
+ _order?: string | null;
401
+ '_product-option-values_values_order'?: string | null;
402
+ }
403
+ interface ProductOptionShape {
404
+ id?: string | number | null;
405
+ title?: string | null;
406
+ slug?: string | null;
407
+ _order?: string | null;
408
+ '_product-options_options_order'?: string | null;
409
+ values?: {
410
+ docs?: unknown[];
411
+ } | null;
412
+ }
413
+ interface ProductVariantShape {
414
+ id?: string | number | null;
415
+ optionValues?: unknown[] | null;
416
+ price?: number | null;
417
+ compareAtPrice?: number | null;
418
+ stock?: number | null;
419
+ reservedStock?: number | null;
420
+ isUnlimited?: boolean | null;
421
+ isActive?: boolean | null;
422
+ thumbnail?: MediaValue;
423
+ images?: MediaValue[] | null;
424
+ _order?: string | null;
425
+ }
426
+ interface ProductListingProductShape {
427
+ id?: EntityID;
428
+ thumbnail?: MediaValue;
429
+ images?: MediaValue[] | null;
430
+ }
431
+ type ProductOptionMatrixValue = {
432
+ id: string;
433
+ optionId: string;
434
+ optionSlug: string;
435
+ label: string;
436
+ slug: string | null;
437
+ swatchColor?: string | null;
438
+ thumbnail?: MediaValue;
439
+ images?: MediaValue[] | null;
440
+ order: string;
441
+ };
442
+ type ProductOptionMatrixOption = {
443
+ id: string;
444
+ title: string;
445
+ slug: string;
446
+ order: string;
447
+ values: ProductOptionMatrixValue[];
448
+ };
449
+ type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
450
+ id: string;
451
+ optionValueIds: string[];
452
+ optionValueByOptionId: Map<string, string>;
453
+ optionValueByOptionSlug: Map<string, string>;
454
+ source: TVariant;
455
+ };
456
+ type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
457
+ options: ProductOptionMatrixOption[];
458
+ optionIds: string[];
459
+ optionSlugs: string[];
460
+ optionById: Map<string, ProductOptionMatrixOption>;
461
+ optionBySlug: Map<string, ProductOptionMatrixOption>;
462
+ valueById: Map<string, ProductOptionMatrixValue>;
463
+ valueToOptionId: Map<string, string>;
464
+ valueToOptionSlug: Map<string, string>;
465
+ variants: ProductOptionMatrixVariant<TVariant>[];
466
+ };
467
+ type ProductListingProjection = {
468
+ selectionHintVariant: EntityID | null;
469
+ primaryImage: EntityID | null;
470
+ minPrice: number | null;
471
+ maxPrice: number | null;
472
+ minCompareAtPrice: number | null;
473
+ maxCompareAtPrice: number | null;
474
+ isPriceRange: boolean;
475
+ availableForSale: boolean;
476
+ };
477
+ type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
478
+ optionId: EntityID;
479
+ optionTitle: string;
480
+ optionValueId: EntityID;
481
+ optionValueLabel: string;
482
+ optionValueSlug: string | null;
483
+ optionValueSwatchColor?: string | null;
484
+ optionValueThumbnail?: MediaValue;
485
+ optionValueImages?: MediaValue[] | null;
486
+ variantIds: EntityID[];
487
+ variantCount: number;
488
+ variants: TVariant[];
489
+ listing: ProductListingProjection;
490
+ };
491
+ type ProductSelectionByOptionValue = string | number | null | undefined | {
492
+ valueId?: string | number | null;
493
+ valueSlug?: string | null;
494
+ };
495
+ type ProductSelectionInput = {
496
+ variantId?: string | number | null;
497
+ byOptionSlug?: Record<string, ProductSelectionByOptionValue>;
498
+ byOptionId?: Record<string, ProductSelectionByOptionValue>;
499
+ valueIds?: Iterable<unknown>;
500
+ search?: string | URLSearchParams | URL | null;
501
+ };
502
+ type NormalizedProductSelection = {
503
+ byOptionSlug: Record<string, string>;
504
+ byOptionId: Record<string, string>;
505
+ valueIds: string[];
506
+ variantId: string | null;
507
+ };
508
+ type CompatibilityProductSelectionParamEvent = {
509
+ optionId: string;
510
+ optionSlug: string;
511
+ valueSlug: string;
512
+ searchParam: string;
513
+ };
514
+ type LegacyProductSelectionParamEvent = CompatibilityProductSelectionParamEvent;
515
+ type ProductSelectionCodecOptions = {
516
+ onCompatibilityOptionIdParam?: (event: CompatibilityProductSelectionParamEvent) => void;
517
+ onLegacyOptionIdParam?: (event: LegacyProductSelectionParamEvent) => void;
518
+ };
519
+ type ProductSelectionResolutionContext = {
520
+ detail?: Pick<ProductDetail, 'images' | 'listing'>;
521
+ images?: ProductDetail['images'];
522
+ listing?: ProductDetail['listing'];
523
+ };
524
+ type ProductSelectionAvailableValue = {
525
+ valueId: string;
526
+ value: string;
527
+ slug: string;
528
+ selected: boolean;
529
+ available: boolean;
530
+ availableForSale: boolean;
531
+ isUnlimited: boolean;
532
+ availableStock: number | null;
533
+ swatchColor?: string | null;
534
+ thumbnail?: MediaValue;
535
+ images?: MediaValue[] | null;
536
+ };
537
+ type ProductSelectionResolution = {
538
+ normalizedSelection: NormalizedProductSelection;
539
+ selectedVariant: ProductDetailVariant | null;
540
+ matchingVariants: ProductDetailVariant[];
541
+ partialVariants: ProductDetailVariant[];
542
+ availableValuesByOptionSlug: Record<string, ProductSelectionAvailableValue[]>;
543
+ availableValuesByOptionId: Record<string, ProductSelectionAvailableValue[]>;
544
+ allOptionsSelected: boolean;
545
+ price: {
546
+ min: number | null;
547
+ max: number | null;
548
+ compareAtMin: number | null;
549
+ compareAtMax: number | null;
550
+ isRange: boolean;
551
+ };
552
+ media: {
553
+ primaryImage: ProductDetailMedia | null;
554
+ images: ProductDetailMedia[];
555
+ };
556
+ stock: {
557
+ availableForSale: boolean;
558
+ isUnlimited: boolean;
559
+ stock: number | null;
560
+ reservedStock: number | null;
561
+ availableStock: number | null;
562
+ };
563
+ };
564
+ declare class ProductSelectionCodecError extends Error {
565
+ code: string;
566
+ constructor(message: string);
567
+ }
568
+ declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
569
+ options: ProductOptionShape[];
570
+ variants?: TVariant[];
571
+ }): ProductOptionMatrix<TVariant>;
572
+ declare function buildProductOptionMatrixFromDetail(detail: ProductDetail): ProductOptionMatrix<ProductDetailVariant>;
573
+ declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
574
+ declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
575
+ declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
576
+ declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
577
+ declare function normalizeProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
578
+ declare function normalizeProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
579
+ declare function parseProductSelection(detail: ProductDetail, search: string | URLSearchParams | URL | null | undefined, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
580
+ declare function stringifyProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): string;
581
+ declare function createProductSelectionCodec(detail: ProductDetail, options?: ProductSelectionCodecOptions): {
582
+ parse: (search: string | URLSearchParams | URL | null | undefined) => NormalizedProductSelection;
583
+ stringify: (selection?: ProductSelectionInput) => string;
584
+ };
585
+ declare function resolveProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions, context?: ProductSelectionResolutionContext): ProductSelectionResolution;
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;
616
+ declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
617
+ /**
618
+ * Builds product-first listing groups for one primary option.
619
+ *
620
+ * The returned groups are intended for product cards with nested swatches or
621
+ * option-value sections. They do not make a product-paginated API response into
622
+ * an expanded-card paginator; one product can still emit several groups.
623
+ */
624
+ declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
625
+ product: ProductListingProductShape | null | undefined;
626
+ options: ProductOptionShape[];
627
+ variants: TVariant[];
628
+ primaryOptionId?: string | null;
629
+ }): ProductListingGroup<TVariant>[];
630
+
631
+ type ProductApiOptions = ServerApiOptions;
632
+ type StockCheckParams = {
633
+ items: Array<{
634
+ variantId: string;
635
+ quantity: number;
636
+ }>;
637
+ };
638
+ type StockCheckResult = {
639
+ variantId: string;
640
+ available: boolean;
641
+ availableStock: number;
642
+ requestedQuantity: number;
643
+ error?: string;
644
+ };
645
+ type StockCheckResponse = {
646
+ results: StockCheckResult[];
647
+ allAvailable: boolean;
648
+ };
649
+ type ListingGroupsParams = {
650
+ productIds: string[];
651
+ };
652
+ type ProductListingGroupSummary = Omit<ProductListingGroup, 'variants'>;
653
+ type ProductListingGroupsItem = {
654
+ product: Product;
655
+ primaryOptionId: string | null;
656
+ groups: ProductListingGroupSummary[];
657
+ };
658
+ type ProductListingGroupsResponse = {
659
+ docs: ProductListingGroupsItem[];
660
+ };
661
+ type ProductDetailParams = {
662
+ slug: string;
663
+ } | {
664
+ id: string;
665
+ };
666
+ interface ProductDetailVariantOptionValue {
667
+ optionId: string | number;
668
+ optionSlug: string;
669
+ valueId: string | number;
670
+ valueSlug: string;
671
+ value?: string | null;
672
+ }
673
+ type ProductDetailMedia = string | number | {
674
+ id?: string | number | null;
675
+ url?: string | null;
676
+ alt?: string | null;
677
+ width?: number | null;
678
+ height?: number | null;
679
+ };
680
+ interface ProductDetailVariant {
681
+ id: string | number;
682
+ optionKey: string;
683
+ title?: string | null;
684
+ displayName: string;
685
+ sku?: string | null;
686
+ price: number;
687
+ compareAtPrice?: number | null;
688
+ stock: number;
689
+ reservedStock: number;
690
+ isUnlimited: boolean;
691
+ isActive: boolean;
692
+ thumbnail?: ProductDetailMedia | null;
693
+ images?: ProductDetailMedia[];
694
+ optionValues: ProductDetailVariantOptionValue[];
695
+ }
696
+ interface ProductDetailOptionValue {
697
+ id: string | number;
698
+ value: string;
699
+ slug: string;
700
+ swatchColor?: string | null;
701
+ thumbnail?: ProductDetailMedia | null;
702
+ images?: ProductDetailMedia[] | null;
703
+ }
704
+ interface ProductDetailOption {
705
+ id: string | number;
706
+ title: string;
707
+ slug: string;
708
+ values: ProductDetailOptionValue[];
709
+ }
710
+ interface ProductDetailBrand {
711
+ id: string | number;
712
+ name: string;
713
+ slug?: string | null;
714
+ logo?: unknown | null;
715
+ }
716
+ interface ProductDetailCategory {
717
+ id: string | number;
718
+ title: string;
719
+ slug?: string | null;
720
+ }
721
+ interface ProductDetailTag {
722
+ id: string | number;
723
+ title: string;
724
+ slug?: string | null;
725
+ }
726
+ interface ProductDetailImage {
727
+ id: string | number;
728
+ url?: string | null;
729
+ alt?: string | null;
730
+ width?: number | null;
731
+ height?: number | null;
732
+ }
733
+ interface ProductDetailVideo {
734
+ id: string | number;
735
+ url?: string | null;
736
+ }
737
+ interface ProductDetailListing {
738
+ minPrice?: number | null;
739
+ maxPrice?: number | null;
740
+ minCompareAtPrice?: number | null;
741
+ maxCompareAtPrice?: number | null;
742
+ isPriceRange?: boolean | null;
743
+ primaryImage?: ProductDetailMedia | null;
744
+ availableForSale?: boolean | null;
745
+ selectionHintVariant?: string | number | null;
746
+ }
747
+ interface ProductDetail {
748
+ product: {
749
+ id: string | number;
750
+ slug: string;
751
+ title: string;
752
+ subtitle?: string | null;
753
+ description?: string | null;
754
+ content?: unknown;
755
+ publishedAt?: string | null;
756
+ status: string;
757
+ totalInventory: number;
758
+ totalVariants: number;
759
+ hasOnlyDefaultVariant: boolean;
760
+ };
761
+ variants: ProductDetailVariant[];
762
+ options: ProductDetailOption[];
763
+ brand: ProductDetailBrand | null;
764
+ categories: ProductDetailCategory[];
765
+ tags: ProductDetailTag[];
766
+ images: ProductDetailImage[];
767
+ videos: ProductDetailVideo[];
768
+ listing: ProductDetailListing;
769
+ }
770
+ type ProductUpsertOptionValueInput = {
771
+ id?: string;
772
+ value: string;
773
+ slug?: string;
774
+ swatchColor?: string | null;
775
+ thumbnail?: string | null;
776
+ images?: string[];
777
+ metadata?: unknown;
778
+ };
779
+ type ProductUpsertOptionInput = {
780
+ id?: string;
781
+ title: string;
782
+ slug?: string;
783
+ values: ProductUpsertOptionValueInput[];
784
+ };
785
+ type ProductUpsertVariantOptionValue = string | {
786
+ valueSlug?: string;
787
+ valueId?: string;
788
+ value?: string;
789
+ };
790
+ type ProductUpsertVariantInput = {
791
+ id?: string;
792
+ optionValues?: Record<string, ProductUpsertVariantOptionValue> | string[];
793
+ sku?: string | null;
794
+ title?: string | null;
795
+ price: number;
796
+ compareAtPrice?: number | null;
797
+ stock?: number;
798
+ isUnlimited?: boolean;
799
+ weight?: number | null;
800
+ requiresShipping?: boolean;
801
+ barcode?: string | null;
802
+ externalId?: string | null;
803
+ isActive?: boolean;
804
+ thumbnail?: string | null;
805
+ images?: string[];
806
+ metadata?: unknown;
807
+ };
808
+ type ProductUpsertParams = {
809
+ product: Record<string, unknown> & {
810
+ id?: string;
811
+ title?: string;
812
+ };
813
+ options?: ProductUpsertOptionInput[];
814
+ variants?: ProductUpsertVariantInput[];
815
+ };
816
+ type ProductUpsertResponse = {
817
+ ok: true;
818
+ product: Product;
819
+ } | {
820
+ ok: false;
821
+ failedEntity: 'product' | 'option' | 'option-value' | 'variant';
822
+ failedIndex?: number;
823
+ message: string;
824
+ };
825
+ declare class ProductApi extends BaseApi {
826
+ constructor(options: ProductApiOptions);
827
+ /**
828
+ * Check point-in-time stock availability for one or more product variants.
829
+ * Results reflect available stock at the moment of the call and are not guaranteed
830
+ * to remain available by the time an order is placed.
831
+ */
832
+ stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
833
+ listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
834
+ /**
835
+ * Fetch full product detail by slug or id.
836
+ * Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
837
+ * `tenant_mismatch` / `feature_disabled`). For the reason behind a null,
838
+ * inspect `client.lastRequestId` against backend logs.
839
+ */
840
+ detail(params: ProductDetailParams): Promise<ProductDetail | null>;
841
+ /**
842
+ * Atomically create or update a product together with its options,
843
+ * option-values, and variants in a single transaction. Mirrors Shopify's
844
+ * `productSet` shape and is the canonical write path for the MCP
845
+ * `product-upsert` tool.
846
+ */
847
+ upsert(params: ProductUpsertParams): Promise<ProductUpsertResponse>;
848
+ }
849
+
850
+ type DiscountApiOptions = ServerApiOptions;
851
+ type ValidateDiscountParams = {
852
+ code: string;
853
+ orderAmount: number;
854
+ };
855
+ type ValidateDiscountResult = {
856
+ valid: boolean;
857
+ code: string;
858
+ type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
859
+ discountAmount: number;
860
+ freeShipping?: boolean;
861
+ reason?: string;
862
+ };
863
+ declare class DiscountApi extends BaseApi {
864
+ constructor(options: DiscountApiOptions);
865
+ validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
866
+ }
867
+
868
+ type ShippingApiOptions = ServerApiOptions;
869
+ type CalculateShippingParams = {
870
+ shippingPolicyId?: string;
871
+ orderAmount: number;
872
+ postalCode?: string;
873
+ };
874
+ type CalculateShippingResult = {
875
+ shippingAmount: number;
876
+ baseShippingAmount: number;
877
+ extraShippingAmount: number;
878
+ freeShipping: boolean;
879
+ freeShippingMinAmount: number | null;
880
+ isJeju: boolean;
881
+ isRemoteIsland: boolean;
882
+ };
883
+ declare class ShippingApi extends BaseApi {
884
+ constructor(options: ShippingApiOptions);
885
+ calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
886
+ }
887
+
888
+ type OrderApiOptions = ServerApiOptions;
889
+ type CustomerSnapshot = {
890
+ name?: string;
891
+ email: string;
892
+ phone?: string;
893
+ };
894
+ type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
895
+ type ReturnItem = {
896
+ orderItem: string;
897
+ quantity: number;
898
+ };
899
+ type CreateOrderParams = {
900
+ orderNumber: string;
901
+ customer?: string;
902
+ customerSnapshot: CustomerSnapshot;
903
+ shippingAddress: Order['shippingAddress'];
904
+ orderItems: Pick<OrderItem, 'product' | 'variant' | 'quantity' | 'unitPrice' | 'totalPrice'>[];
905
+ totalAmount: number;
906
+ shippingAmount?: number;
907
+ pgPaymentId?: string;
908
+ discountCode?: string;
909
+ };
910
+ type UpdateOrderParams = {
911
+ orderNumber: string;
912
+ status: Order['status'];
913
+ };
914
+ type TransactionStatus = 'pending' | 'paid' | 'failed' | 'canceled';
915
+ type UpdateTransactionParams = {
916
+ pgPaymentId: string;
917
+ status: TransactionStatus;
918
+ paymentMethod?: string;
919
+ receiptUrl?: string;
920
+ paymentKey?: string;
921
+ amount?: number;
922
+ };
923
+ type ConfirmPaymentParams = {
924
+ orderNumber?: string;
925
+ pgPaymentId: string;
926
+ pgProvider: string;
927
+ pgOrderId?: string;
928
+ amount: number;
929
+ currency?: string;
930
+ paymentMethod?: string;
931
+ receiptUrl?: string;
932
+ approvedAt?: string;
933
+ providerStatus?: string;
934
+ providerEventId?: string;
935
+ confirmationSource?: 'provider_webhook' | 'provider_lookup' | 'provider_api_confirm' | 'manual_server';
936
+ metadata?: Record<string, unknown>;
937
+ };
938
+ type ConfirmPaymentResponse = {
939
+ orderId: string;
940
+ transactionId: string;
941
+ status: 'paid';
942
+ alreadyConfirmed?: boolean;
943
+ };
944
+ type RestockAction = 'return_to_stock' | 'discard';
945
+ type ReturnWithRefundItem = {
946
+ orderItem: string | number;
947
+ quantity: number;
948
+ restockAction?: RestockAction;
949
+ };
950
+ type ReturnWithRefundParams = {
951
+ orderNumber: string;
952
+ reason?: ReturnReason;
953
+ reasonDetail?: string;
954
+ returnItems: ReturnWithRefundItem[];
955
+ refundAmount: number;
956
+ pgPaymentId: string;
957
+ paymentKey?: string;
958
+ refundReceiptUrl?: string;
959
+ };
960
+ type CheckoutParams = {
961
+ cartId: string;
962
+ orderNumber: string;
963
+ customerSnapshot: CustomerSnapshot;
964
+ pgPaymentId?: string;
965
+ discountCode?: string;
966
+ };
967
+ type CreateFulfillmentParams = {
968
+ orderNumber: string;
969
+ carrier?: string;
970
+ trackingNumber?: string;
971
+ items: Array<{
972
+ orderItem: string;
973
+ quantity: number;
974
+ }>;
975
+ };
976
+ type UpdateFulfillmentParams = {
977
+ fulfillmentId: string;
978
+ status: 'packed' | 'shipped' | 'delivered' | 'failed';
979
+ carrier?: string;
980
+ trackingNumber?: string;
981
+ };
982
+ type BulkImportFulfillmentsParams = {
983
+ items: Array<{
984
+ orderNumber: string;
985
+ carrier?: string;
986
+ trackingNumber?: string;
987
+ }>;
988
+ };
989
+ type BulkImportFulfillmentsResponse = {
990
+ succeeded: Array<{
991
+ orderNumber: string;
992
+ fulfillmentId: string;
993
+ }>;
994
+ failed: Array<{
995
+ orderNumber: string;
996
+ error: string;
997
+ }>;
998
+ };
999
+ type CreateReturnParams = {
1000
+ orderNumber: string;
1001
+ reason?: ReturnReason;
1002
+ reasonDetail?: string;
1003
+ returnItems: ReturnItem[];
1004
+ refundAmount: number;
1005
+ };
1006
+ type UpdateReturnParams = {
1007
+ returnId: string;
1008
+ status: 'processing' | 'approved' | 'rejected' | 'completed';
1009
+ };
1010
+ declare class OrderApi extends BaseApi {
1011
+ constructor(options: OrderApiOptions);
1012
+ createOrder(params: CreateOrderParams): Promise<Order>;
1013
+ updateOrder(params: UpdateOrderParams): Promise<Order>;
1014
+ updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
1015
+ confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse>;
1016
+ checkout(params: CheckoutParams): Promise<Order>;
1017
+ createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
1018
+ updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
1019
+ bulkImportFulfillments(params: BulkImportFulfillmentsParams): Promise<BulkImportFulfillmentsResponse>;
1020
+ returnWithRefund(params: ReturnWithRefundParams): Promise<{
1021
+ return: Return;
1022
+ transaction: Transaction | null;
1023
+ }>;
1024
+ createReturn(params: CreateReturnParams): Promise<Return>;
1025
+ updateReturn(params: UpdateReturnParams): Promise<Return>;
1026
+ }
1027
+
1028
+ interface CommerceClientOptions {
1029
+ publishableKey: string;
1030
+ apiUrl?: string;
1031
+ customerToken: () => string | null;
1032
+ onUnauthorized?: () => Promise<string | null>;
1033
+ onRequestId?: (id: string | null) => void;
1034
+ customerAuth: CustomerAuth;
1035
+ }
1036
+ declare class CommerceClient {
1037
+ readonly product: {
1038
+ stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1039
+ listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1040
+ detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
1041
+ };
1042
+ readonly cart: {
1043
+ get: (cartId: string) => Promise<Cart>;
1044
+ addItem: (params: AddItemParams) => Promise<CartItem>;
1045
+ updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1046
+ removeItem: (params: RemoveItemParams) => Promise<{
1047
+ success: boolean;
1048
+ }>;
1049
+ applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1050
+ removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1051
+ clear: (params: ClearCartParams) => Promise<{
1052
+ success: boolean;
1053
+ }>;
1054
+ };
1055
+ readonly orders: {
1056
+ checkout: (params: CheckoutParams) => Promise<Order>;
1057
+ listMine: (options?: {
1058
+ page?: number;
1059
+ limit?: number;
1060
+ status?: string;
1061
+ }) => Promise<PayloadFindResponse<Order>>;
1062
+ };
1063
+ readonly discounts: {
1064
+ validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
1065
+ };
1066
+ readonly shipping: {
1067
+ calculate: (params: CalculateShippingParams) => Promise<CalculateShippingResult>;
1068
+ };
1069
+ constructor(options: CommerceClientOptions);
1070
+ }
1071
+
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);
1079
+ }
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
+ };
1105
+ }
1106
+ interface ClientServerConfig extends ClientConfig {
1107
+ secretKey: string;
1108
+ }
1109
+ interface ClientMetadata {
1110
+ userAgent?: string;
1111
+ timestamp: number;
1112
+ }
1113
+ interface ClientState {
1114
+ metadata: ClientMetadata;
1115
+ }
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;
1131
+ }
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[];
1141
+ }
1142
+ type Sort = string | string[];
1143
+ type Where = Record<string, unknown>;
1144
+ /**
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`.
1150
+ */
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;
1213
+ }
1214
+ interface DebugConfig {
1215
+ logRequests?: boolean;
1216
+ logResponses?: boolean;
1217
+ logErrors?: boolean;
1218
+ }
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;
1240
+ lastRequestId: string | null;
1241
+ getState(): ClientState;
1242
+ getConfig(): ClientConfig;
1243
+ }
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;
1248
+
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 };