@01.software/sdk 0.37.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +189 -84
  2. package/dist/analytics/react.cjs.map +1 -1
  3. package/dist/analytics/react.js.map +1 -1
  4. package/dist/analytics.cjs.map +1 -1
  5. package/dist/analytics.js.map +1 -1
  6. package/dist/client.cjs +1286 -109
  7. package/dist/client.cjs.map +1 -1
  8. package/dist/client.d.cts +8 -7
  9. package/dist/client.d.ts +8 -7
  10. package/dist/client.js +1286 -109
  11. package/dist/client.js.map +1 -1
  12. package/dist/{collection-client-DyELGUcL.d.ts → collection-client-CaMgs5KE.d.ts} +18 -12
  13. package/dist/{collection-client-zOmnxwdA.d.cts → collection-client-DVfB0Em1.d.cts} +18 -12
  14. package/dist/const-6XHz_jej.d.ts +32 -0
  15. package/dist/const-B5KT72c7.d.cts +32 -0
  16. package/dist/errors.cjs +4 -1
  17. package/dist/errors.cjs.map +1 -1
  18. package/dist/errors.js +4 -1
  19. package/dist/errors.js.map +1 -1
  20. package/dist/{index-DRJs7QIh.d.cts → index-BOLQxveo.d.cts} +3 -3
  21. package/dist/{index-DTqoUZk_.d.ts → index-CSwR2HSg.d.ts} +3 -3
  22. package/dist/index.cjs +2861 -2714
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +9 -9
  25. package/dist/index.d.ts +9 -9
  26. package/dist/index.js +2861 -2714
  27. package/dist/index.js.map +1 -1
  28. package/dist/{payload-types-CREOjFNT.d.cts → payload-types-m3jjhxk9.d.cts} +418 -106
  29. package/dist/{payload-types-CREOjFNT.d.ts → payload-types-m3jjhxk9.d.ts} +418 -106
  30. package/dist/query.cjs +244 -1093
  31. package/dist/query.cjs.map +1 -1
  32. package/dist/query.d.cts +159 -34
  33. package/dist/query.d.ts +159 -34
  34. package/dist/query.js +244 -1093
  35. package/dist/query.js.map +1 -1
  36. package/dist/realtime.cjs +5 -1
  37. package/dist/realtime.cjs.map +1 -1
  38. package/dist/realtime.d.cts +2 -2
  39. package/dist/realtime.d.ts +2 -2
  40. package/dist/realtime.js +5 -1
  41. package/dist/realtime.js.map +1 -1
  42. package/dist/server.cjs +1191 -22
  43. package/dist/server.cjs.map +1 -1
  44. package/dist/server.d.cts +7 -7
  45. package/dist/server.d.ts +7 -7
  46. package/dist/server.js +1191 -22
  47. package/dist/server.js.map +1 -1
  48. package/dist/storefront-cache.cjs +144 -0
  49. package/dist/storefront-cache.cjs.map +1 -0
  50. package/dist/storefront-cache.d.cts +24 -0
  51. package/dist/storefront-cache.d.ts +24 -0
  52. package/dist/storefront-cache.js +121 -0
  53. package/dist/storefront-cache.js.map +1 -0
  54. package/dist/{types-DMvVHdb1.d.ts → types-BQo7UdI9.d.cts} +1608 -1215
  55. package/dist/{types-BWMUr3Zw.d.cts → types-CVf8sCZ-.d.ts} +1608 -1215
  56. package/dist/{types-CxzWHspI.d.ts → types-Cmrd1ezc.d.ts} +1 -15
  57. package/dist/{types-BkZNhuBh.d.cts → types-D0ubzQw0.d.cts} +1 -15
  58. package/dist/ui/canvas/server.cjs +5 -1
  59. package/dist/ui/canvas/server.cjs.map +1 -1
  60. package/dist/ui/canvas/server.js +5 -1
  61. package/dist/ui/canvas/server.js.map +1 -1
  62. package/dist/ui/canvas.cjs +5 -1
  63. package/dist/ui/canvas.cjs.map +1 -1
  64. package/dist/ui/canvas.js +5 -1
  65. package/dist/ui/canvas.js.map +1 -1
  66. package/dist/ui/form.d.cts +1 -1
  67. package/dist/ui/form.d.ts +1 -1
  68. package/dist/ui/video.d.cts +1 -1
  69. package/dist/ui/video.d.ts +1 -1
  70. package/dist/webhook.d.cts +4 -4
  71. package/dist/webhook.d.ts +4 -4
  72. package/package.json +11 -1
  73. package/dist/const-CK_FPaIn.d.cts +0 -32
  74. package/dist/const-Dqz05oaG.d.ts +0 -32
@@ -1,6 +1,6 @@
1
- import { P as PublicCollection, S as ServerCollection } from './const-Dqz05oaG.js';
2
- import { C as CollectionType, P as PublicProduct } from './types-CxzWHspI.js';
3
- import { O as Order, i as Cart, j as CartItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-CREOjFNT.js';
1
+ import { P as PublicCollection, S as ServerCollection } from './const-B5KT72c7.cjs';
2
+ import { C as CollectionType, P as PublicProduct } from './types-D0ubzQw0.cjs';
3
+ import { O as Order, l as Transaction, m as Fulfillment, R as Return } from './payload-types-m3jjhxk9.cjs';
4
4
 
5
5
  interface CustomerScopedApiOptions {
6
6
  publishableKey?: string;
@@ -27,6 +27,10 @@ declare class CustomerScopedApi {
27
27
  protected request<T>(endpoint: string, options: CustomerScopedRequestOptions): Promise<T>;
28
28
  }
29
29
 
30
+ type RawCommunityPost = CollectionType<'posts'>;
31
+ type RawCommunityComment = CollectionType<'comments'>;
32
+ type RawCommunityReaction = CollectionType<'reactions'>;
33
+ type RawCommunityBookmark = CollectionType<'bookmarks'>;
30
34
  interface CommunityClientOptions {
31
35
  publishableKey?: string;
32
36
  secretKey?: string;
@@ -35,10 +39,82 @@ interface CommunityClientOptions {
35
39
  onUnauthorized?: () => Promise<string | null>;
36
40
  onRequestId?: (id: string | null) => void;
37
41
  }
38
- /** Public read shape for `posts` (tenant-scoped author profiles). */
39
- type CommunityPost = CollectionType<'posts'>;
40
- /** Public read shape for `comments`. */
41
- type CommunityComment = CollectionType<'comments'>;
42
+ type CommunityPublicMediaAsset = string | {
43
+ id?: string | number | null;
44
+ alt?: string | null;
45
+ width?: number | null;
46
+ height?: number | null;
47
+ mimeType?: string | null;
48
+ filename?: string | null;
49
+ url?: string | null;
50
+ sizes?: Record<string, {
51
+ width?: number | null;
52
+ height?: number | null;
53
+ mimeType?: string | null;
54
+ filename?: string | null;
55
+ url?: string | null;
56
+ }> | null;
57
+ };
58
+ type CommunityPublicReference = string | {
59
+ id?: string | number | null;
60
+ title?: string | null;
61
+ name?: string | null;
62
+ slug?: string | null;
63
+ displayName?: string | null;
64
+ handle?: string | null;
65
+ color?: string | null;
66
+ image?: CommunityPublicMediaAsset | null;
67
+ thumbnail?: CommunityPublicMediaAsset | null;
68
+ avatar?: CommunityPublicMediaAsset | null;
69
+ };
70
+ interface CommunityPublicAuthorSnapshot {
71
+ displayName?: string | null;
72
+ handle?: string | null;
73
+ avatarUrl?: string | null;
74
+ avatar?: CommunityPublicMediaAsset | null;
75
+ }
76
+ /** Public read shape for projected community post endpoints. */
77
+ interface CommunityPost {
78
+ id: RawCommunityPost['id'];
79
+ title?: RawCommunityPost['title'];
80
+ slug?: RawCommunityPost['slug'];
81
+ content?: RawCommunityPost['content'];
82
+ status?: RawCommunityPost['status'];
83
+ thumbnail?: CommunityPublicMediaAsset | null;
84
+ categories?: CommunityPublicReference[] | null;
85
+ tags?: CommunityPublicReference[] | null;
86
+ authorProfile?: CommunityPublicReference | null;
87
+ authorSnapshot?: CommunityPublicAuthorSnapshot | null;
88
+ viewCount?: RawCommunityPost['viewCount'];
89
+ commentCount?: RawCommunityPost['commentCount'];
90
+ reactionCount?: RawCommunityPost['reactionCount'];
91
+ isPinned?: RawCommunityPost['isPinned'];
92
+ allowsComments?: RawCommunityPost['allowsComments'];
93
+ isEdited?: RawCommunityPost['isEdited'];
94
+ editedAt?: RawCommunityPost['editedAt'];
95
+ lastActivityAt?: RawCommunityPost['lastActivityAt'];
96
+ publishedAt?: RawCommunityPost['publishedAt'];
97
+ createdAt: RawCommunityPost['createdAt'];
98
+ updatedAt: RawCommunityPost['updatedAt'];
99
+ }
100
+ /** Public read shape for projected community comment endpoints. */
101
+ interface CommunityComment {
102
+ id: RawCommunityComment['id'];
103
+ body?: RawCommunityComment['body'];
104
+ post?: CommunityPublicReference | null;
105
+ parent?: CommunityPublicReference | null;
106
+ rootComment?: CommunityPublicReference | null;
107
+ authorProfile?: CommunityPublicReference | null;
108
+ authorSnapshot?: CommunityPublicAuthorSnapshot | null;
109
+ depth?: RawCommunityComment['depth'];
110
+ status?: RawCommunityComment['status'];
111
+ reactionCount?: RawCommunityComment['reactionCount'];
112
+ replyCount?: RawCommunityComment['replyCount'];
113
+ isEdited?: RawCommunityComment['isEdited'];
114
+ editedAt?: RawCommunityComment['editedAt'];
115
+ createdAt: RawCommunityComment['createdAt'];
116
+ updatedAt: RawCommunityComment['updatedAt'];
117
+ }
42
118
  /** @deprecated Use {@link CommunityComment}. */
43
119
  type Comment = CommunityComment;
44
120
  /** Public read shape for `post-categories`. */
@@ -49,10 +125,11 @@ type CommunityPostListSort = 'createdAt' | '-createdAt' | 'lastActivityAt' | '-l
49
125
  type CommunityCommentListSort = 'createdAt' | '-createdAt';
50
126
  interface Reaction {
51
127
  id: string;
52
- post?: string;
53
- comment?: string;
54
- type?: string;
128
+ post?: CommunityPublicReference | null;
129
+ comment?: CommunityPublicReference | null;
130
+ type?: CommunityPublicReference | null;
55
131
  createdAt?: string;
132
+ updatedAt?: string;
56
133
  [key: string]: unknown;
57
134
  }
58
135
  interface ReactionSummary {
@@ -62,8 +139,9 @@ interface ReactionSummary {
62
139
  }
63
140
  interface Bookmark {
64
141
  id: string;
65
- post?: string;
142
+ post?: string | CommunityPost | null;
66
143
  createdAt?: string;
144
+ updatedAt?: string;
67
145
  [key: string]: unknown;
68
146
  }
69
147
  interface ReactionType {
@@ -85,6 +163,10 @@ interface PaginatedResponse<T> {
85
163
  prevPage: number | null;
86
164
  nextPage: number | null;
87
165
  }
166
+ type CommunityPostMutationResponse = CommunityPost | RawCommunityPost;
167
+ type CommunityCommentMutationResponse = CommunityComment | RawCommunityComment;
168
+ type CommunityReactionMutationResponse = Reaction | RawCommunityReaction;
169
+ type CommunityBookmarkMutationResponse = Bookmark | RawCommunityBookmark;
88
170
  declare class CommunityClient extends CustomerScopedApi {
89
171
  constructor(options: CommunityClientOptions);
90
172
  private buildQuery;
@@ -97,7 +179,7 @@ declare class CommunityClient extends CustomerScopedApi {
97
179
  content?: unknown;
98
180
  categories?: string[];
99
181
  thumbnail?: string;
100
- }): Promise<CommunityPost>;
182
+ }): Promise<CommunityPostMutationResponse>;
101
183
  /**
102
184
  * Public post feed. Server applies the same visibility contract as
103
185
  * `communityPostRead` (published + visible + moderation-safe).
@@ -143,7 +225,7 @@ declare class CommunityClient extends CustomerScopedApi {
143
225
  postId: string;
144
226
  body: string;
145
227
  parentId?: string;
146
- }): Promise<CommunityComment>;
228
+ }): Promise<CommunityCommentMutationResponse>;
147
229
  /**
148
230
  * List comments for a post.
149
231
  *
@@ -169,12 +251,10 @@ declare class CommunityClient extends CustomerScopedApi {
169
251
  updateComment(params: {
170
252
  commentId: string;
171
253
  body: string;
172
- }): Promise<CommunityComment>;
254
+ }): Promise<CommunityCommentMutationResponse>;
173
255
  deleteComment(params: {
174
256
  commentId: string;
175
- }): Promise<{
176
- success: boolean;
177
- }>;
257
+ }): Promise<CommunityCommentMutationResponse>;
178
258
  reportComment(params: {
179
259
  commentId: string;
180
260
  reason?: string;
@@ -187,7 +267,7 @@ declare class CommunityClient extends CustomerScopedApi {
187
267
  typeSlug?: string;
188
268
  /** @deprecated Use `typeSlug`. */
189
269
  type?: string;
190
- }): Promise<Reaction>;
270
+ }): Promise<CommunityReactionMutationResponse>;
191
271
  removeReaction(params: {
192
272
  postId: string;
193
273
  type: string;
@@ -199,7 +279,7 @@ declare class CommunityClient extends CustomerScopedApi {
199
279
  typeSlug?: string;
200
280
  /** @deprecated Use `typeSlug`. */
201
281
  type?: string;
202
- }): Promise<Reaction>;
282
+ }): Promise<CommunityReactionMutationResponse>;
203
283
  removeCommentReaction(params: {
204
284
  commentId: string;
205
285
  type: string;
@@ -215,7 +295,7 @@ declare class CommunityClient extends CustomerScopedApi {
215
295
  getReactionTypes(): Promise<PaginatedResponse<ReactionType>>;
216
296
  addBookmark(params: {
217
297
  postId: string;
218
- }): Promise<Bookmark>;
298
+ }): Promise<CommunityBookmarkMutationResponse>;
219
299
  removeBookmark(params: {
220
300
  postId: string;
221
301
  }): Promise<{
@@ -290,1304 +370,1515 @@ declare class ModerationApi extends BaseApi {
290
370
  }>;
291
371
  }
292
372
 
293
- interface CustomerAuthResponse {
294
- token: string;
295
- customer: CustomerProfile;
296
- }
297
- interface MarketingConsentChannel {
298
- isConsented?: boolean;
299
- }
300
- interface MarketingConsent {
301
- email?: MarketingConsentChannel;
302
- sms?: MarketingConsentChannel;
303
- push?: MarketingConsentChannel;
304
- consentSource?: string;
305
- }
306
- interface CustomerProfile {
307
- id: string;
308
- name: string;
309
- email?: string | null;
310
- phone?: string | null;
311
- authProvider?: 'local' | 'google' | 'apple' | 'kakao' | 'naver' | null;
312
- isGuest?: boolean | null;
313
- marketingConsent?: MarketingConsent | null;
314
- metadata?: Record<string, unknown> | null;
315
- groups?: string[];
316
- }
317
- interface CustomerRegisterData {
318
- name: string;
319
- email: string;
320
- password: string;
321
- phone?: string;
322
- }
323
- interface CustomerRegisterResponse {
324
- customer: CustomerProfile;
325
- }
326
- interface CustomerLoginData {
327
- email: string;
328
- password: string;
329
- }
330
- interface CustomerRefreshResponse {
331
- token: string;
332
- }
333
- interface UpdateProfileData {
334
- name?: string;
335
- phone?: string;
336
- marketingConsent?: MarketingConsent;
337
- }
338
- interface CustomerAuthOptions {
339
- /**
340
- * Persist token in localStorage. Defaults to `true`.
341
- * - `true` (default): uses key `'customer-token'`
342
- * - `string`: uses the given string as localStorage key
343
- * - `false`: disables persistence (token/onTokenChange used instead)
344
- *
345
- * Handles SSR safely (no-op on server).
346
- * When enabled, `token` and `onTokenChange` are ignored.
347
- */
348
- persist?: boolean | string;
349
- /** Initial token (e.g. from SSR cookie) */
350
- token?: string;
351
- /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
352
- onTokenChange?: (token: string | null) => void;
353
- }
373
+ type PublicMediaSize = {
374
+ width?: number | null;
375
+ height?: number | null;
376
+ mimeType?: string | null;
377
+ filename?: string | null;
378
+ url?: string | null;
379
+ };
380
+ type PublicMediaAsset = string | {
381
+ id?: string | number | null;
382
+ alt?: string | null;
383
+ width?: number | null;
384
+ height?: number | null;
385
+ mimeType?: string | null;
386
+ filename?: string | null;
387
+ url?: string | null;
388
+ sizes?: Record<string, PublicMediaSize>;
389
+ };
354
390
 
355
- /**
356
- * Customer authentication client.
357
- *
358
- * Manages customer registration, login, logout, and token lifecycle.
359
- * All requests include X-Publishable-Key for tenant resolution.
360
- */
361
- declare class CustomerAuth {
362
- private publishableKey;
363
- private baseUrl;
364
- private token;
365
- private onTokenChange?;
366
- private refreshPromise;
367
- constructor(publishableKey: string, options?: CustomerAuthOptions, apiUrl?: string);
368
- /**
369
- * Register a new customer account
370
- */
371
- register(data: CustomerRegisterData): Promise<CustomerRegisterResponse>;
372
- /**
373
- * Login with email and password. Stores the token internally.
374
- */
375
- login(data: CustomerLoginData): Promise<CustomerAuthResponse>;
376
- /**
377
- * Refresh the current token. Requires a valid (non-expired) token.
378
- */
379
- refreshToken(): Promise<CustomerRefreshResponse>;
380
- private _doRefreshToken;
381
- /**
382
- * Clear the stored token
383
- */
384
- logout(): void;
385
- /**
386
- * Get the current authenticated customer's profile
387
- */
388
- me(): Promise<CustomerProfile | null>;
389
- /**
390
- * Request a password reset email
391
- */
392
- forgotPassword(email: string): Promise<void>;
393
- /**
394
- * Reset password using a token from the reset email
395
- */
396
- resetPassword(token: string, password: string): Promise<void>;
391
+ type OrderApiOptions = ServerApiOptions;
392
+ /** Header-only; never sent in the JSON body. */
393
+ type WithIdempotencyKey<T> = T & {
397
394
  /**
398
- * Update the authenticated customer's profile (name, phone, marketingConsent)
395
+ * Client-generated key for safe retries. Sent as `X-Idempotency-Key` when the
396
+ * server endpoint supports HTTP idempotency.
399
397
  */
400
- updateProfile(data: UpdateProfileData): Promise<CustomerProfile>;
398
+ idempotencyKey?: string;
399
+ };
400
+ type CustomerSnapshot = {
401
+ name?: string;
402
+ email: string;
403
+ phone?: string;
404
+ };
405
+ type PublicOrderReference = string | {
406
+ id?: string | number | null;
407
+ title?: string | null;
408
+ name?: string | null;
409
+ slug?: string | null;
410
+ displayName?: string | null;
411
+ handle?: string | null;
412
+ color?: string | null;
413
+ image?: PublicMediaAsset | null;
414
+ thumbnail?: PublicMediaAsset | null;
415
+ avatar?: PublicMediaAsset | null;
416
+ };
417
+ type PublicOrderItem = {
418
+ id?: string | number;
419
+ product?: PublicOrderReference;
420
+ variant?: PublicOrderReference;
421
+ productTitle?: string | null;
422
+ variantTitle?: string | null;
423
+ sku?: string | null;
424
+ quantity?: number | null;
425
+ unitPrice?: number | null;
426
+ discountedUnitPrice?: number | null;
427
+ totalPrice?: number | null;
428
+ options?: unknown;
429
+ createdAt?: string | null;
430
+ updatedAt?: string | null;
431
+ image?: PublicMediaAsset | null;
432
+ };
433
+ type PublicOrder = {
434
+ id?: string | number;
435
+ orderNumber?: string | null;
436
+ status?: string | null;
437
+ displayStatus?: string | null;
438
+ primaryDisplayStatus?: string | null;
439
+ displayFinancialStatus?: string | null;
440
+ displayFulfillmentStatus?: string | null;
441
+ returnDisplayStatus?: string | null;
442
+ totalAmount?: number | null;
443
+ subtotalAmount?: number | null;
444
+ shippingAmount?: number | null;
445
+ discountAmount?: number | null;
446
+ taxAmount?: number | null;
447
+ refundedAmount?: number | null;
448
+ currency?: string | null;
449
+ customerNote?: string | null;
450
+ createdAt?: string | null;
451
+ updatedAt?: string | null;
452
+ customerSnapshot?: {
453
+ name?: string | null;
454
+ email?: string | null;
455
+ phone?: string | null;
456
+ };
457
+ shippingAddress?: {
458
+ recipientName?: string | null;
459
+ phone?: string | null;
460
+ postalCode?: string | null;
461
+ address1?: string | null;
462
+ address2?: string | null;
463
+ jibunAddress?: string | null;
464
+ administrativeArea?: string | null;
465
+ city?: string | null;
466
+ province?: string | null;
467
+ country?: string | null;
468
+ deliveryMemo?: string | null;
469
+ address?: string | null;
470
+ detailAddress?: string | null;
471
+ deliveryMessage?: string | null;
472
+ };
473
+ items?: PublicOrderItem[];
474
+ };
475
+ type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
476
+ type ReturnItem = {
477
+ orderItem: string | number;
478
+ quantity: number;
479
+ restockAction?: RestockAction;
480
+ restockingFee?: number;
481
+ };
482
+ type OrderCreateEntityID = string | number;
483
+ type CreateOrderItem = {
401
484
  /**
402
- * Change the password of the currently authenticated customer
485
+ * Compatibility input: the create-order endpoint derives the line's product
486
+ * from the variant's parent server-side; storefront items may omit this.
403
487
  */
404
- changePassword(currentPassword: string, newPassword: string): Promise<void>;
488
+ product?: OrderCreateEntityID;
489
+ variant: OrderCreateEntityID;
405
490
  /**
406
- * Get the authenticated customer's orders with pagination and optional status filter
491
+ * Compatibility input: accepted but unused by the create-order endpoint;
492
+ * option selection is snapshotted server-side from the variant.
407
493
  */
408
- getMyOrders(options?: {
409
- page?: number;
410
- limit?: number;
411
- status?: string;
412
- }): Promise<PayloadFindResponse<Order>>;
494
+ option?: OrderCreateEntityID;
495
+ quantity: number;
413
496
  /**
414
- * Get the current token (or null if not authenticated)
497
+ * Compatibility input: the create-order endpoint accepts this, but the server
498
+ * derives authoritative line pricing from the product variant.
415
499
  */
416
- getToken(): string | null;
500
+ unitPrice?: number;
417
501
  /**
418
- * Set the token manually (e.g. from SSR)
502
+ * Compatibility input: the create-order endpoint accepts this, but the server
503
+ * derives authoritative line totals from the product variant.
419
504
  */
420
- setToken(token: string | null): void;
505
+ totalPrice?: number;
506
+ };
507
+ type CreateOrderLineItemsInput = {
508
+ orderItems: CreateOrderItem[];
509
+ items?: never;
510
+ } | {
421
511
  /**
422
- * Check if the customer is currently authenticated
512
+ * Storefront-facing alias for orderItems. The SDK serializes this to
513
+ * orderItems for the existing create-order endpoint.
423
514
  */
424
- isAuthenticated(): boolean;
515
+ items: CreateOrderItem[];
425
516
  /**
426
- * Internal: make a request with timeout and error handling.
427
- * Auth endpoints don't retry — failures are final.
517
+ * @deprecated Use items for storefront-facing create-order inputs.
428
518
  */
429
- private requestJson;
430
- }
431
-
432
- interface CartApiOptions {
433
- publishableKey?: string;
434
- secretKey?: string;
435
- apiUrl?: string;
436
- customerToken?: string | (() => string | null);
437
- onUnauthorized?: () => Promise<string | null>;
438
- onRequestId?: (id: string | null) => void;
439
- }
440
- type AddItemParams = {
441
- cartId: string;
442
- product: string;
443
- variant: string;
444
- option: string;
445
- quantity: number;
446
- };
447
- type UpdateItemParams = {
448
- cartItemId: string;
449
- quantity: number;
450
- };
451
- type RemoveItemParams = {
452
- cartItemId: string;
519
+ orderItems?: never;
453
520
  };
454
- type ApplyDiscountParams = {
455
- cartId: string;
456
- discountCode: string;
521
+ type CreateOrderBodyBase = {
522
+ orderNumber: string;
523
+ customer?: string;
524
+ customerSnapshot: CustomerSnapshot;
525
+ shippingAddress: Order['shippingAddress'];
526
+ totalAmount: number;
527
+ shippingAmount?: number;
528
+ pgPaymentId?: string;
529
+ discountCode?: string;
457
530
  };
458
- type RemoveDiscountParams = {
459
- cartId: string;
531
+ type CreateOrderParams = WithIdempotencyKey<CreateOrderBodyBase & CreateOrderLineItemsInput>;
532
+ type UpdateOrderParams = {
533
+ orderNumber: string;
534
+ status: 'confirmed';
460
535
  };
461
- type ClearCartParams = {
462
- cartId: string;
536
+ type TransactionStatus = 'pending' | 'paid' | 'failed' | 'canceled';
537
+ type UpdateTransactionParams = {
538
+ pgPaymentId: string;
539
+ status: TransactionStatus;
540
+ paymentMethod?: string;
541
+ receiptUrl?: string;
542
+ paymentKey?: string;
543
+ amount?: number;
463
544
  };
464
- declare class CartApi extends CustomerScopedApi {
465
- constructor(options: CartApiOptions);
466
- private execute;
467
- getCart(cartId: string): Promise<Cart>;
468
- addItem(params: AddItemParams): Promise<CartItem>;
469
- updateItem(params: UpdateItemParams): Promise<CartItem>;
470
- removeItem(params: RemoveItemParams): Promise<{
471
- success: boolean;
472
- }>;
473
- applyDiscount(params: ApplyDiscountParams): Promise<Cart>;
474
- removeDiscount(params: RemoveDiscountParams): Promise<Cart>;
475
- clearCart(params: ClearCartParams): Promise<{
476
- success: boolean;
477
- }>;
478
- }
479
-
480
- type NormalizedOptionSwatch<TMedia = unknown> = {
481
- type: 'color' | 'media' | null;
482
- color?: string | null;
483
- mediaItemId?: string | number | null;
484
- /** Inlined swatch media when the API populated mediaItemId before pool indexing. */
485
- inlineMedia?: TMedia | null;
545
+ type ConfirmPaymentParams = WithIdempotencyKey<{
546
+ orderNumber?: string;
547
+ pgPaymentId: string;
548
+ pgProvider: string;
549
+ pgOrderId?: string;
550
+ amount: number;
551
+ currency?: string;
552
+ paymentMethod?: string;
553
+ receiptUrl?: string;
554
+ approvedAt?: string;
555
+ providerStatus?: string;
556
+ /** Provider event id; also used as idempotency key when `idempotencyKey` is omitted. */
557
+ providerEventId?: string;
558
+ paymentKey?: string;
559
+ confirmationSource?: 'provider_webhook' | 'provider_lookup' | 'provider_api_confirm' | 'manual_server';
560
+ metadata?: Record<string, unknown>;
561
+ }>;
562
+ type ConfirmPaymentResponse = {
563
+ orderId: string;
564
+ transactionId: string;
565
+ status: 'paid';
566
+ alreadyConfirmed?: boolean;
486
567
  };
487
- declare function selectedSwatchMediaItemId(swatch: NormalizedOptionSwatch | null | undefined): string | null;
488
- type ProductSelectionMediaSource = 'variant_media_selected' | 'variant_media_matching' | 'option_swatch' | 'none';
489
- type ProductDisplayMediaSource = 'listing_primary' | 'product_primary' | 'product_pool' | 'none';
490
- /** @deprecated Use {@link ProductSelectionMediaSource} or {@link ProductDisplayMediaSource}. */
491
- type ProductMediaResolutionSource = ProductSelectionMediaSource | ProductDisplayMediaSource;
492
- type ProductSelectionVariant<TMedia> = {
493
- id?: string | number | null;
494
- images?: Array<TMedia | string | number | null | undefined> | null;
568
+ type CancelReasonCode = 'customer' | 'inventory' | 'fraud' | 'declined' | 'staff' | 'other';
569
+ type CancelOrderStatus = 'pending' | 'paid' | 'canceled' | 'refunded' | 'preparing' | 'shipped' | 'delivered' | 'confirmed' | 'return_requested' | 'return_processing' | 'returned';
570
+ type CancelOrderReconciliationStatus = Exclude<CancelOrderStatus, 'pending' | 'canceled'>;
571
+ type CancelOrderResponseBase = {
572
+ orderId: string;
495
573
  };
496
- type ProductSelectionOptionValue = {
497
- id?: string | number | null;
498
- swatch?: NormalizedOptionSwatch<unknown> | null;
574
+ type CancelOrderUnpaidCommittedResponseFields = {
575
+ refundedAmount: 0;
576
+ providerRefunded: false;
499
577
  };
500
- type ProductSelectionMediaPointer = string | number | {
501
- id?: string | number | null;
502
- } | null;
503
- type ResolveProductSelectionMediaInput<TMedia> = {
504
- productMediaPool?: TMedia[] | null;
505
- productPrimaryMediaItemId?: ProductSelectionMediaPointer;
506
- selectedVariant?: ProductSelectionVariant<TMedia> | null;
507
- matchingVariants?: Array<ProductSelectionVariant<TMedia> | null | undefined> | null;
508
- selectedOptionValues?: Array<ProductSelectionOptionValue | null | undefined> | null;
578
+ type CancelOrderPaidCommittedResponseFields = {
579
+ transactionId: string;
580
+ refundedAmount: 0;
581
+ providerRefunded: false;
582
+ refundPending: true;
509
583
  };
510
- type ResolveProductSelectionMediaResult<TMedia> = {
511
- primaryImage: TMedia | null;
512
- images: TMedia[];
513
- source: ProductSelectionMediaSource;
584
+ type CancelOrderLegacyProviderRefundResponseFields = {
585
+ transactionId: string;
586
+ refundedAmount: number;
587
+ refundSeq: number;
588
+ providerRefunded: true;
514
589
  };
515
- type ResolveProductDisplayMediaInput<TMedia> = {
516
- productMediaPool?: TMedia[] | null;
517
- productPrimaryMediaItemId?: ProductSelectionMediaPointer;
518
- listingPrimaryImage?: ProductSelectionMediaPointer;
590
+ type CancelOrderAlreadyCanceledResponseFields = {
591
+ refundedAmount: number;
592
+ providerRefunded: false;
519
593
  };
520
- type ResolveProductDisplayMediaResult<TMedia> = {
521
- primaryImage: TMedia | null;
522
- images: TMedia[];
523
- source: ProductDisplayMediaSource;
594
+ type CancelOrderAlreadyCanceledRefundPendingResponseFields = {
595
+ transactionId: string;
596
+ refundedAmount: number;
597
+ providerRefunded: false;
598
+ refundPending: true;
524
599
  };
525
- declare function resolveProductSelectionMedia<TMedia>(input: ResolveProductSelectionMediaInput<TMedia>): ResolveProductSelectionMediaResult<TMedia>;
526
- declare function resolveProductDisplayMedia<TMedia>(input: ResolveProductDisplayMediaInput<TMedia>): ResolveProductDisplayMediaResult<TMedia>;
527
- type ListingPrimaryImageFallbackInput<TMedia> = {
528
- productMediaPool?: TMedia[] | null;
529
- productPrimaryMediaItemId?: ProductSelectionMediaPointer;
530
- productThumbnail?: TMedia | string | number | null;
531
- listingPrimaryImage?: TMedia | string | number | null;
532
- resolvedPrimary?: TMedia | null;
533
- resolvedSource?: ProductMediaResolutionSource;
600
+ type CancelOrderPaidCommittedResponse = CancelOrderResponseBase & CancelOrderPaidCommittedResponseFields & {
601
+ status: 'canceled';
602
+ cancelCommitted: true;
534
603
  };
535
- declare function resolveListingPrimaryImagePointer<TMedia>(input: ListingPrimaryImageFallbackInput<TMedia>): string | null;
536
-
537
- type EntityID = string;
538
- type RelationshipValue = string | number | null | undefined | {
539
- id?: string | number | null;
604
+ type CancelOrderUnpaidCommittedResponse = CancelOrderResponseBase & CancelOrderUnpaidCommittedResponseFields & {
605
+ status: 'canceled';
606
+ cancelCommitted: true;
540
607
  };
541
- type MediaValue = ProductDetailMedia | null | undefined;
542
-
543
- /** Raw Payload / REST swatch before strict public normalization. */
544
- type ProductOptionValueSwatchInput = {
545
- type?: 'color' | 'media' | null;
546
- color?: string | null;
547
- mediaItemId?: RelationshipValue;
608
+ type CancelOrderCommittedResponse = CancelOrderPaidCommittedResponse | CancelOrderUnpaidCommittedResponse;
609
+ type CancelOrderAlreadyCanceledResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledResponseFields & {
610
+ status: 'canceled';
611
+ cancelCommitted: false;
612
+ alreadyCanceled: true;
548
613
  };
549
- interface ProductOptionValueShape {
550
- id?: string | number | null;
551
- option?: RelationshipValue;
552
- value?: string | null;
553
- slug?: string | null;
554
- swatch?: ProductOptionValueSwatch | ProductOptionValueSwatchInput | null;
555
- _order?: string | null;
556
- '_product-option-values_values_order'?: string | null;
557
- }
558
- interface ProductOptionShape {
559
- id?: string | number | null;
560
- title?: string | null;
561
- slug?: string | null;
562
- _order?: string | null;
563
- '_product-options_options_order'?: string | null;
564
- values?: {
565
- docs?: unknown[];
566
- } | null;
567
- }
568
- interface ProductVariantShape {
569
- id?: string | number | null;
570
- optionValues?: unknown[] | null;
571
- price?: number | null;
572
- compareAtPrice?: number | null;
573
- stock?: number | null;
574
- reservedStock?: number | null;
575
- isUnlimited?: boolean | null;
576
- isActive?: boolean | null;
577
- thumbnail?: MediaValue;
578
- images?: MediaValue[] | null;
579
- _order?: string | null;
580
- }
581
- interface ProductListingProductShape {
582
- id?: EntityID;
583
- thumbnail?: MediaValue;
584
- primaryMediaItemId?: MediaValue;
585
- images?: MediaValue[] | null;
586
- listing?: {
587
- primaryImage?: MediaValue;
588
- } | null;
589
- }
590
- type ProductOptionMatrixValue = {
591
- id: string;
592
- optionId: string;
593
- optionSlug: string;
594
- label: string;
595
- slug: string | null;
596
- swatch: ProductOptionValueSwatch;
597
- order: string;
614
+ type CancelOrderAlreadyCanceledRefundPendingResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledRefundPendingResponseFields & {
615
+ status: 'canceled';
616
+ cancelCommitted: false;
617
+ alreadyCanceled: true;
598
618
  };
599
- type ProductOptionMatrixOption = {
600
- id: string;
601
- title: string;
602
- slug: string;
603
- order: string;
604
- values: ProductOptionMatrixValue[];
619
+ /** @deprecated Inline PG cancel reconciliation; retained for legacy API consumers. */
620
+ type CancelOrderReconciliationResponse = CancelOrderResponseBase & CancelOrderLegacyProviderRefundResponseFields & {
621
+ status: CancelOrderReconciliationStatus;
622
+ cancelCommitted: false;
623
+ reconciliationRequired: true;
605
624
  };
606
- type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
607
- id: string;
608
- optionValueIds: string[];
609
- optionValueByOptionId: Map<string, string>;
610
- optionValueByOptionSlug: Map<string, string>;
611
- source: TVariant;
625
+ type CancelOrderResponse = CancelOrderCommittedResponse | CancelOrderAlreadyCanceledResponse | CancelOrderAlreadyCanceledRefundPendingResponse | CancelOrderReconciliationResponse;
626
+ type CancelOrderParams = {
627
+ orderNumber: string;
628
+ reasonCode?: CancelReasonCode;
629
+ reasonDetail?: string;
630
+ idempotencyKey?: string;
612
631
  };
613
- type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
614
- options: ProductOptionMatrixOption[];
615
- optionIds: string[];
616
- optionSlugs: string[];
617
- optionById: Map<string, ProductOptionMatrixOption>;
618
- optionBySlug: Map<string, ProductOptionMatrixOption>;
619
- valueById: Map<string, ProductOptionMatrixValue>;
620
- valueToOptionId: Map<string, string>;
621
- valueToOptionSlug: Map<string, string>;
622
- variants: ProductOptionMatrixVariant<TVariant>[];
632
+ type ResolveCancelRefundOutcome = 'succeeded' | 'failed';
633
+ type ResolveCancelRefundSucceededParams = {
634
+ orderNumber: string;
635
+ idempotencyKey: string;
636
+ outcome: 'succeeded';
637
+ refundedAmount: number;
638
+ pgProvider: string;
639
+ pgRefundId: string;
623
640
  };
624
- type ProductListingProjection = {
625
- selectionHintVariant: EntityID | null;
626
- primaryImage: EntityID | null;
627
- minPrice: number | null;
628
- maxPrice: number | null;
629
- minCompareAtPrice: number | null;
630
- maxCompareAtPrice: number | null;
631
- isPriceRange: boolean;
632
- availableForSale: boolean;
641
+ type ResolveCancelRefundFailedParams = {
642
+ orderNumber: string;
643
+ idempotencyKey: string;
644
+ outcome: 'failed';
645
+ refundedAmount: 0;
646
+ pgProvider: string;
647
+ pgRefundId?: string;
633
648
  };
634
- type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
635
- optionId: EntityID;
636
- optionTitle: string;
637
- optionSlug: string;
638
- optionValueId: EntityID;
639
- optionValueLabel: string;
640
- optionValueSlug: string | null;
641
- optionValueSwatch: ProductOptionValueSwatch;
642
- variantIds: EntityID[];
643
- variantCount: number;
644
- variants: TVariant[];
645
- listing: ProductListingProjection;
649
+ type ResolveCancelRefundParams = ResolveCancelRefundSucceededParams | ResolveCancelRefundFailedParams;
650
+ type ResolveCancelRefundSucceededResponse = {
651
+ orderId: string;
652
+ transactionId: string;
653
+ refundTransactionId: string;
654
+ refundedAmount: number;
655
+ refundStatus: 'succeeded';
656
+ transactionStatus: 'refunded';
646
657
  };
647
- type ProductListingCardPriceRange = {
648
- minPrice: number | null;
649
- maxPrice: number | null;
650
- minCompareAtPrice: number | null;
651
- maxCompareAtPrice: number | null;
652
- isPriceRange: boolean;
653
- };
654
- type ProductListingSwatch = {
655
- optionId: EntityID;
656
- optionValueId: EntityID;
657
- label: string;
658
- swatch: ProductOptionValueSwatch<ProductDetailMedia>;
659
- href: string;
660
- availableForSale: boolean;
661
- };
662
- type ProductListingCardRepresentativeVariant = ProductListingGroupsItem['groups'][number]['variants'][number];
663
- type ProductListingCard = {
664
- id: EntityID;
665
- href: string;
666
- title: string;
667
- representativeVariant?: ProductListingCardRepresentativeVariant | null;
668
- primaryImage: ProductDetailMedia | null;
669
- priceRange: ProductListingCardPriceRange;
670
- availableForSale: boolean;
671
- swatches: ProductListingSwatch[];
672
- };
673
- type ProductSelectionByOptionValue = string | number | null | undefined | {
674
- valueId?: string | number | null;
675
- valueSlug?: string | null;
676
- };
677
- type ProductSelectionInput = {
678
- variantId?: string | number | null;
679
- byOptionSlug?: Record<string, ProductSelectionByOptionValue>;
680
- byOptionId?: Record<string, ProductSelectionByOptionValue>;
681
- valueIds?: Iterable<unknown>;
682
- search?: string | URLSearchParams | URL | null;
683
- };
684
- type NormalizedProductSelection = {
685
- byOptionSlug: Record<string, string>;
686
- byOptionId: Record<string, string>;
687
- valueIds: string[];
688
- variantId: string | null;
689
- };
690
- type CompatibilityProductSelectionParamEvent = {
691
- optionId: string;
692
- optionSlug: string;
693
- valueSlug: string;
694
- searchParam: string;
658
+ type ResolveCancelRefundFailedResponse = {
659
+ orderId: string;
660
+ transactionId: string;
661
+ refundTransactionId: string;
662
+ refundedAmount: 0;
663
+ refundStatus: 'failed';
664
+ transactionStatus: 'paid';
695
665
  };
696
- type LegacyProductSelectionParamEvent = CompatibilityProductSelectionParamEvent;
697
- type ProductSelectionUrlEmit = 'slug-compat' | 'canonical-id';
698
- type ProductSelectionCodecOptions = {
699
- emit?: ProductSelectionUrlEmit;
700
- /**
701
- * When true, `resolveProductSelection()` fills unselected options to reach a
702
- * concrete variant. Does not change codec parse/stringify behavior.
703
- */
704
- fillDefaults?: boolean;
705
- onCompatibilityOptionIdParam?: (event: CompatibilityProductSelectionParamEvent) => void;
706
- onLegacyOptionIdParam?: (event: LegacyProductSelectionParamEvent) => void;
666
+ type ResolveCancelRefundResponse = ResolveCancelRefundSucceededResponse | ResolveCancelRefundFailedResponse;
667
+ type RestockAction = 'return_to_stock' | 'discard';
668
+ type ReturnWithRefundItem = {
669
+ orderItem: string | number;
670
+ quantity: number;
671
+ restockAction?: RestockAction;
672
+ restockingFee?: number;
707
673
  };
708
- type ProductSelectionResolutionContext = {
709
- detail?: Pick<ProductDetail, 'images' | 'listing' | 'primaryMediaItemId'>;
710
- images?: ProductDetail['images'];
711
- listing?: ProductDetail['listing'];
712
- primaryMediaItemId?: ProductDetail['primaryMediaItemId'];
674
+ type ReturnWithRefundParams = WithIdempotencyKey<{
675
+ orderNumber: string;
676
+ reason?: ReturnReason;
677
+ reasonDetail?: string;
678
+ returnItems: ReturnWithRefundItem[];
679
+ refundAmount: number;
680
+ returnShippingFee?: number;
681
+ initialShippingRefundAmount?: number;
682
+ initialShippingRefundOverrideNote?: string;
683
+ pgPaymentId: string;
684
+ paymentKey?: string;
685
+ refundReceiptUrl?: string;
686
+ }>;
687
+ type CheckoutParams = WithIdempotencyKey<{
688
+ cartId: string;
689
+ orderNumber: string;
690
+ customerSnapshot: CustomerSnapshot;
691
+ pgPaymentId?: string;
692
+ discountCode?: string;
693
+ }>;
694
+ type CreateFulfillmentParams = WithIdempotencyKey<{
695
+ orderNumber: string;
696
+ fulfillmentOrderId?: string | number;
697
+ carrier?: string;
698
+ trackingNumber?: string;
699
+ items?: Array<{
700
+ orderItem: string;
701
+ quantity: number;
702
+ }>;
703
+ }>;
704
+ type PrepareFulfillmentOrderParams = {
705
+ orderNumber: string;
713
706
  };
714
- type ProductSelectionAvailableSwatch = {
715
- color?: string | null;
716
- image?: MediaValue | null;
707
+ type PrepareFulfillmentOrderResponse = {
708
+ orderId: string;
709
+ fulfillmentOrders: Array<{
710
+ id: string;
711
+ status: string;
712
+ }>;
717
713
  };
718
- type ProductSelectionAvailableValue = {
719
- valueId: string;
720
- value: string;
721
- label: string;
722
- slug: string;
723
- selected: boolean;
724
- available: boolean;
725
- exists: boolean;
726
- availableForSale: boolean;
727
- isUnlimited: boolean;
728
- availableStock: number | null;
729
- swatch: ProductOptionValueSwatch;
714
+ type UpdateFulfillmentParams = {
715
+ fulfillmentId: string;
716
+ status?: 'shipped' | 'delivered' | 'failed';
717
+ carrier?: string;
718
+ trackingNumber?: string;
730
719
  };
731
- type ProductSelectionResolution = {
732
- normalizedSelection: NormalizedProductSelection;
733
- selectedVariant: ProductDetailVariant | null;
734
- matchingVariants: ProductDetailVariant[];
735
- partialVariants: ProductDetailVariant[];
736
- availableValuesByOptionSlug: Record<string, ProductSelectionAvailableValue[]>;
737
- availableValuesByOptionId: Record<string, ProductSelectionAvailableValue[]>;
738
- allOptionsSelected: boolean;
739
- price: {
740
- min: number | null;
741
- max: number | null;
742
- compareAtMin: number | null;
743
- compareAtMax: number | null;
744
- isRange: boolean;
745
- };
746
- media: {
747
- primaryImage: ProductDetailMedia | null;
748
- images: ProductDetailMedia[];
749
- source?: ProductMediaResolutionSource;
750
- };
751
- stock: {
752
- availableForSale: boolean;
753
- isUnlimited: boolean;
754
- stock: number | null;
755
- reservedStock: number | null;
756
- availableStock: number | null;
757
- };
720
+ type BulkImportFulfillmentsParams = {
721
+ items: Array<{
722
+ orderNumber: string;
723
+ carrier: string;
724
+ trackingNumber: string;
725
+ }>;
758
726
  };
759
- declare class ProductSelectionCodecError extends Error {
760
- code: string;
761
- constructor(message: string);
762
- }
763
- declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
764
- options: ProductOptionShape[];
765
- variants?: TVariant[];
766
- }): ProductOptionMatrix<TVariant>;
767
- declare function buildProductOptionMatrixFromDetail(detail: ProductDetail): ProductOptionMatrix<ProductDetailVariant>;
768
- declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
769
- declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
770
- declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
771
- declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
772
- declare function normalizeProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
773
- declare function normalizeProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
774
- declare function parseProductSelection(detail: ProductDetail, search: string | URLSearchParams | URL | null | undefined, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
775
- declare function stringifyProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): string;
776
- declare function createProductSelectionCodec(detail: ProductDetail, options?: ProductSelectionCodecOptions): {
777
- parse: (search: string | URLSearchParams | URL | null | undefined) => NormalizedProductSelection;
778
- stringify: (selection?: ProductSelectionInput) => string;
727
+ type BulkImportFulfillmentsResponse = {
728
+ succeeded: Array<{
729
+ orderNumber: string;
730
+ fulfillmentId: string;
731
+ }>;
732
+ failed: Array<{
733
+ orderNumber: string;
734
+ error: string;
735
+ }>;
779
736
  };
780
- declare function resolveProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions, context?: ProductSelectionResolutionContext): ProductSelectionResolution;
781
- declare function resolveProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): ProductSelectionResolution;
782
- declare function selectNext(detail: ProductDetail, current: ProductSelectionInput | undefined, optionSlug: string, valueSlug: string, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
783
- type ProductDetailImageMedia = Extract<ProductDetailMedia, {
784
- id?: string | number | null;
785
- url?: string | null;
737
+ type CreateReturnParams = WithIdempotencyKey<{
738
+ orderNumber: string;
739
+ reason?: ReturnReason;
740
+ reasonDetail?: string;
741
+ returnItems: ReturnItem[];
742
+ refundAmount: number;
743
+ returnShippingFee?: number;
744
+ initialShippingRefundAmount?: number;
745
+ initialShippingRefundOverrideNote?: string;
786
746
  }>;
787
- declare function getProductSelectionImages(resolution: Pick<ProductSelectionResolution, 'media'>): ProductDetailImageMedia[];
788
- type ProductHrefProduct = ProductDetail | {
789
- slug?: string | null;
790
- product?: {
791
- slug?: string | null;
792
- } | null;
793
- };
794
- type ProductHrefGroup = {
795
- optionId?: string | number | null;
796
- optionSlug?: string | null;
797
- optionValueId?: string | number | null;
798
- optionValueSlug?: string | null;
799
- variantId?: string | number | null;
800
- listing?: {
801
- selectionHintVariant?: string | number | null;
802
- } | null;
803
- };
804
- type ProductHrefOptions = {
805
- basePath?: string;
806
- detail?: ProductDetail;
807
- matrix?: ProductOptionMatrix<ProductDetailVariant>;
808
- selection?: ProductSelectionInput;
809
- trailingSlash?: boolean;
810
- emit?: ProductSelectionUrlEmit;
811
- preferCompleteVariantFromHint?: boolean;
812
- };
813
- type ProductListingCardOptions = {
814
- basePath?: string;
815
- trailingSlash?: boolean;
816
- emit?: ProductSelectionUrlEmit;
817
- preferCompleteVariantFromHint?: boolean;
818
- };
819
- declare function buildProductHref(product: ProductHrefProduct, group?: ProductHrefGroup | null, options?: ProductHrefOptions): string;
820
- declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
821
- declare function buildProductListingCard(item: ProductListingGroupsItem, options?: ProductListingCardOptions): ProductListingCard;
822
- /** Shopify `priceRangeV2` naming for persisted listing projection fields. */
823
- declare function toShopifyPriceRangeV2(listing: {
824
- minPrice?: number | null;
825
- maxPrice?: number | null;
826
- }): {
827
- minVariantPrice: {
828
- amount: number | null;
829
- };
830
- maxVariantPrice: {
831
- amount: number | null;
832
- };
747
+ type UpdateReturnParams = {
748
+ returnId: string;
749
+ status: 'processing' | 'approved' | 'rejected' | 'completed';
833
750
  };
751
+ declare class OrderApi extends BaseApi {
752
+ constructor(options: OrderApiOptions);
753
+ createOrder(params: CreateOrderParams): Promise<Order>;
754
+ updateOrder(params: UpdateOrderParams): Promise<Order>;
755
+ updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
756
+ confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse>;
757
+ cancelOrder(params: CancelOrderParams): Promise<CancelOrderResponse>;
758
+ resolveCancelRefund(params: ResolveCancelRefundParams): Promise<ResolveCancelRefundResponse>;
759
+ checkout(params: CheckoutParams): Promise<PublicOrder>;
760
+ createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
761
+ prepareFulfillmentOrder(params: PrepareFulfillmentOrderParams): Promise<PrepareFulfillmentOrderResponse>;
762
+ updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
763
+ bulkImportFulfillments(params: BulkImportFulfillmentsParams): Promise<BulkImportFulfillmentsResponse>;
764
+ returnWithRefund(params: ReturnWithRefundParams): Promise<{
765
+ return: Return;
766
+ transaction: Transaction | null;
767
+ }>;
768
+ createReturn(params: CreateReturnParams): Promise<Return>;
769
+ updateReturn(params: UpdateReturnParams): Promise<Return>;
770
+ }
771
+
772
+ interface CustomerAuthResponse {
773
+ token: string;
774
+ customer: CustomerProfile;
775
+ }
776
+ interface MarketingConsentChannel {
777
+ isConsented?: boolean;
778
+ }
779
+ interface MarketingConsent {
780
+ email?: MarketingConsentChannel;
781
+ sms?: MarketingConsentChannel;
782
+ push?: MarketingConsentChannel;
783
+ consentSource?: string;
784
+ }
785
+ interface CustomerProfile {
786
+ id: string;
787
+ name: string;
788
+ email?: string | null;
789
+ phone?: string | null;
790
+ authProvider?: 'local' | 'google' | 'apple' | 'kakao' | 'naver' | null;
791
+ isGuest?: boolean | null;
792
+ marketingConsent?: MarketingConsent | null;
793
+ metadata?: Record<string, unknown> | null;
794
+ groups?: string[];
795
+ }
796
+ interface CustomerRegisterData {
797
+ name: string;
798
+ email: string;
799
+ password: string;
800
+ phone?: string;
801
+ }
802
+ interface CustomerRegisterResponse {
803
+ customer: CustomerProfile;
804
+ }
805
+ interface CustomerLoginData {
806
+ email: string;
807
+ password: string;
808
+ }
809
+ interface CustomerRefreshResponse {
810
+ token: string;
811
+ }
812
+ interface UpdateProfileData {
813
+ name?: string;
814
+ phone?: string;
815
+ marketingConsent?: MarketingConsent;
816
+ }
817
+ interface CustomerAuthOptions {
818
+ /**
819
+ * Persist token in localStorage. Defaults to `true`.
820
+ * - `true` (default): uses key `'customer-token'`
821
+ * - `string`: uses the given string as localStorage key
822
+ * - `false`: disables persistence (token/onTokenChange used instead)
823
+ *
824
+ * Handles SSR safely (no-op on server).
825
+ * When enabled, `token` and `onTokenChange` are ignored.
826
+ */
827
+ persist?: boolean | string;
828
+ /** Initial token (e.g. from SSR cookie) */
829
+ token?: string;
830
+ /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
831
+ onTokenChange?: (token: string | null) => void;
832
+ }
833
+
834
834
  /**
835
- * PLP-safe query preset for the `products` collection.
836
- *
837
- * Payload's top-level `type: 'join'` fields on `products` (`variants`,
838
- * `options`) return at most 10 docs by default when queried via the REST API.
839
- * Storefront PLPs calling `client.collections.from('products').find()` without
840
- * explicit join limits silently receive truncated variant/option join data.
841
- * `buildProductListingGroupsByOption()` then drops primary-option values with
842
- * no matching variant in the response — a common cause of missing color swatches
843
- * even when the product has more variants than the default join cap.
844
- *
845
- * Spread this constant into your `find()` call to raise both top-level limits:
846
- *
847
- * ```typescript
848
- * const { docs } = await client.collections.from('products').find({
849
- * ...PRODUCT_PLP_FIND_OPTIONS,
850
- * where: { status: { equals: 'published' } },
851
- * limit: 24,
852
- * })
853
- * ```
854
- *
855
- * **Limitation:** This preset cures top-level `products.options` and
856
- * `products.variants` join truncation. It cannot cure the nested
857
- * `options[].values.docs` join — the Payload REST `joins` param is flat and
858
- * nested join limits require the listing-groups endpoint. Prefer
859
- * `commerce.product.listingGroupsCatalog()` + `buildProductListingCard()` as
860
- * the primary PLP path; they apply unlimited join fetches server-side and
861
- * return pre-grouped data ready for rendering.
862
- */
863
- declare const PRODUCT_PLP_FIND_OPTIONS: ApiQueryOptions;
864
- /**
865
- * Builds product-first listing groups for one primary option.
835
+ * Customer authentication client.
866
836
  *
867
- * The returned groups are intended for product cards with nested swatches or
868
- * option-value sections. They do not make a product-paginated API response into
869
- * an expanded-card paginator; one product can still emit several groups.
837
+ * Manages customer registration, login, logout, and token lifecycle.
838
+ * All requests include X-Publishable-Key for tenant resolution.
870
839
  */
871
- declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
872
- product: ProductListingProductShape | null | undefined;
873
- options: ProductOptionShape[];
874
- variants: TVariant[];
875
- primaryOptionId?: string | null;
876
- }): ProductListingGroup<TVariant>[];
840
+ declare class CustomerAuth {
841
+ private publishableKey;
842
+ private baseUrl;
843
+ private token;
844
+ private onTokenChange?;
845
+ private refreshPromise;
846
+ constructor(publishableKey: string, options?: CustomerAuthOptions, apiUrl?: string);
847
+ /**
848
+ * Register a new customer account
849
+ */
850
+ register(data: CustomerRegisterData): Promise<CustomerRegisterResponse>;
851
+ /**
852
+ * Login with email and password. Stores the token internally.
853
+ */
854
+ login(data: CustomerLoginData): Promise<CustomerAuthResponse>;
855
+ /**
856
+ * Refresh the current token. Requires a valid (non-expired) token.
857
+ */
858
+ refreshToken(): Promise<CustomerRefreshResponse>;
859
+ private _doRefreshToken;
860
+ /**
861
+ * Clear the stored token
862
+ */
863
+ logout(): void;
864
+ /**
865
+ * Get the current authenticated customer's profile
866
+ */
867
+ me(): Promise<CustomerProfile | null>;
868
+ /**
869
+ * Request a password reset email
870
+ */
871
+ forgotPassword(email: string): Promise<void>;
872
+ /**
873
+ * Reset password using a token from the reset email
874
+ */
875
+ resetPassword(token: string, password: string): Promise<void>;
876
+ /**
877
+ * Update the authenticated customer's profile (name, phone, marketingConsent)
878
+ */
879
+ updateProfile(data: UpdateProfileData): Promise<CustomerProfile>;
880
+ /**
881
+ * Change the password of the currently authenticated customer
882
+ */
883
+ changePassword(currentPassword: string, newPassword: string): Promise<void>;
884
+ /**
885
+ * Get the authenticated customer's orders with pagination and optional status filter
886
+ */
887
+ getMyOrders(options?: {
888
+ page?: number;
889
+ limit?: number;
890
+ status?: string;
891
+ }): Promise<PayloadFindResponse<PublicOrder>>;
892
+ /**
893
+ * Get the current token (or null if not authenticated)
894
+ */
895
+ getToken(): string | null;
896
+ /**
897
+ * Set the token manually (e.g. from SSR)
898
+ */
899
+ setToken(token: string | null): void;
900
+ /**
901
+ * Check if the customer is currently authenticated
902
+ */
903
+ isAuthenticated(): boolean;
904
+ /**
905
+ * Internal: make a request with timeout and error handling.
906
+ * Auth endpoints don't retry — failures are final.
907
+ */
908
+ private requestJson;
909
+ }
877
910
 
878
- type ProductUpsertColorSwatchInput = {
879
- type: 'color';
880
- color: string;
881
- mediaItemId?: null;
911
+ interface CartApiOptions {
912
+ publishableKey?: string;
913
+ secretKey?: string;
914
+ apiUrl?: string;
915
+ customerToken?: string | (() => string | null);
916
+ onUnauthorized?: () => Promise<string | null>;
917
+ onRequestId?: (id: string | null) => void;
918
+ }
919
+ type AddItemParams = {
920
+ cartId: string;
921
+ product: string;
922
+ variant: string;
923
+ option: string;
924
+ quantity: number;
882
925
  };
883
- type ProductUpsertMediaSwatchInput = {
884
- type: 'media';
885
- mediaItemId: string;
886
- color?: null;
926
+ type UpdateItemParams = {
927
+ cartItemId: string;
928
+ quantity: number;
887
929
  };
888
- type ProductUpsertSwatchInput = ProductUpsertColorSwatchInput | ProductUpsertMediaSwatchInput;
889
- type ProductUpsertOptionValueInput = {
890
- id?: string;
891
- value: string;
892
- slug?: string;
893
- swatch?: ProductUpsertSwatchInput | null;
894
- metadata?: unknown;
930
+ type RemoveItemParams = {
931
+ cartItemId: string;
895
932
  };
896
- type OptionValueInput = ProductUpsertOptionValueInput;
897
- type OptionInput = {
898
- id?: string;
899
- title: string;
900
- slug?: string;
901
- values: OptionValueInput[];
933
+ type ApplyDiscountParams = {
934
+ cartId: string;
935
+ discountCode: string;
902
936
  };
903
- type VariantInput = {
904
- id?: string;
905
- optionValues?: Record<string, string | {
906
- valueSlug?: string;
907
- valueId?: string;
908
- value?: string;
909
- }> | string[];
910
- sku?: string | null;
911
- title?: string | null;
912
- price: number;
913
- compareAtPrice?: number | null;
914
- stock?: number;
915
- isUnlimited?: boolean;
916
- weight?: number | null;
917
- requiresShipping?: boolean;
918
- barcode?: string | null;
919
- externalId?: string | null;
920
- isActive?: boolean;
921
- images?: string[];
922
- metadata?: unknown;
937
+ type RemoveDiscountParams = {
938
+ cartId: string;
923
939
  };
924
- type ProductFieldsInput = {
925
- id?: string;
926
- title?: string;
927
- subtitle?: string | null;
928
- description?: string | null;
929
- status?: string;
930
- slug?: string;
931
- primaryMediaItemId?: string | null;
932
- thumbnail?: string | null;
933
- images?: string[];
934
- vendor?: string | null;
935
- productType?: string | null;
936
- brand?: string | null;
937
- shippingPolicy?: string | null;
938
- weight?: number | null;
939
- minOrderQuantity?: number | null;
940
- maxOrderQuantity?: number | null;
941
- isFeatured?: boolean;
942
- publishedAt?: string | null;
943
- categories?: string[];
944
- tags?: string[];
945
- metadata?: unknown;
940
+ type ClearCartParams = {
941
+ cartId: string;
946
942
  };
947
- type ProductUpsertGraphFields = {
948
- /** Required when updating an existing product graph if the server graph is non-empty. */
949
- graphRevision?: string;
950
- options?: OptionInput[];
951
- variants?: VariantInput[];
943
+ type PublicCartReference = string | {
944
+ id?: string | number | null;
945
+ title?: string | null;
946
+ name?: string | null;
947
+ slug?: string | null;
948
+ displayName?: string | null;
949
+ handle?: string | null;
950
+ color?: string | null;
951
+ image?: PublicMediaAsset | null;
952
+ thumbnail?: PublicMediaAsset | null;
953
+ avatar?: PublicMediaAsset | null;
952
954
  };
953
- /** Create a product document and initial graph. */
954
- type ProductUpsertCreateInput = ProductUpsertGraphFields & {
955
- productId?: never;
956
- product: ProductFieldsInput & {
957
- title: string;
955
+ type PublicCartItem = {
956
+ id?: string | number;
957
+ product?: PublicCartReference;
958
+ variant?: PublicCartReference;
959
+ quantity?: number | null;
960
+ unitPrice?: number | null;
961
+ discountAllocation?: number | null;
962
+ discountedUnitPrice?: number | null;
963
+ discountedTotalPrice?: number | null;
964
+ createdAt?: string | null;
965
+ updatedAt?: string | null;
966
+ };
967
+ type PublicCart = {
968
+ id?: string | number;
969
+ status?: string | null;
970
+ currency?: string | null;
971
+ subtotalAmount?: number | null;
972
+ shippingAmount?: number | null;
973
+ discountAmount?: number | null;
974
+ totalAmount?: number | null;
975
+ discountCode?: string | null;
976
+ customerNote?: string | null;
977
+ lastActivityAt?: string | null;
978
+ expiresAt?: string | null;
979
+ createdAt?: string | null;
980
+ updatedAt?: string | null;
981
+ shippingAddress?: {
982
+ recipientName?: string | null;
983
+ phone?: string | null;
984
+ postalCode?: string | null;
985
+ address?: string | null;
986
+ detailAddress?: string | null;
987
+ deliveryMessage?: string | null;
988
+ address1?: string | null;
989
+ address2?: string | null;
990
+ jibunAddress?: string | null;
991
+ administrativeArea?: string | null;
992
+ city?: string | null;
993
+ province?: string | null;
994
+ country?: string | null;
995
+ deliveryMemo?: string | null;
958
996
  };
997
+ items?: PublicCartItem[];
959
998
  };
960
- /** Graph-only update for an existing product (document fields via Payload save). */
961
- type ProductUpsertEditInput = ProductUpsertGraphFields & {
962
- productId: string;
963
- product?: never;
964
- };
965
- type ProductUpsertInput = ProductUpsertCreateInput | ProductUpsertEditInput;
966
-
967
- type ProductApiOptions = ServerApiOptions;
968
- type StockCheckParams = {
969
- items: Array<{
970
- variantId: string;
971
- quantity: number;
999
+ declare class CartApi extends CustomerScopedApi {
1000
+ constructor(options: CartApiOptions);
1001
+ private execute;
1002
+ getCart(cartId: string): Promise<PublicCart>;
1003
+ addItem(params: AddItemParams): Promise<PublicCartItem>;
1004
+ updateItem(params: UpdateItemParams): Promise<PublicCartItem>;
1005
+ removeItem(params: RemoveItemParams): Promise<{
1006
+ success: boolean;
972
1007
  }>;
1008
+ applyDiscount(params: ApplyDiscountParams): Promise<PublicCart>;
1009
+ removeDiscount(params: RemoveDiscountParams): Promise<PublicCart>;
1010
+ clearCart(params: ClearCartParams): Promise<{
1011
+ success: boolean;
1012
+ }>;
1013
+ }
1014
+
1015
+ type NormalizedOptionSwatch<TMedia = unknown> = {
1016
+ type: 'color' | 'media' | null;
1017
+ color?: string | null;
1018
+ mediaItemId?: string | number | null;
1019
+ /** Inlined swatch media when the API populated mediaItemId before pool indexing. */
1020
+ inlineMedia?: TMedia | null;
973
1021
  };
974
- type StockCheckResult = {
975
- variantId: string;
976
- status: 'available' | 'not_published' | 'archived' | 'not_found';
977
- available: boolean;
978
- availableStock: number;
979
- isUnlimited: boolean;
980
- requestedQuantity: number;
981
- error?: string;
982
- };
983
- type StockCheckResponse = {
984
- results: StockCheckResult[];
985
- allAvailable: boolean;
986
- };
987
- type ListingGroupsParams = {
988
- productIds: string[];
1022
+ declare function selectedSwatchMediaItemId(swatch: NormalizedOptionSwatch | null | undefined): string | null;
1023
+ type ProductSelectionMediaSource = 'variant_media_selected' | 'variant_media_matching' | 'option_swatch' | 'none';
1024
+ type ProductDisplayMediaSource = 'listing_primary' | 'product_primary' | 'product_pool' | 'none';
1025
+ /** @deprecated Use {@link ProductSelectionMediaSource} or {@link ProductDisplayMediaSource}. */
1026
+ type ProductMediaResolutionSource = ProductSelectionMediaSource | ProductDisplayMediaSource;
1027
+ type ProductSelectionVariant<TMedia> = {
1028
+ id?: string | number | null;
1029
+ images?: Array<TMedia | string | number | null | undefined> | null;
989
1030
  };
990
- type ProductListingGroupVariant = Pick<ProductVariantShape, 'id' | 'optionValues' | 'price' | 'compareAtPrice' | 'stock' | 'isUnlimited' | 'isActive' | 'thumbnail' | 'images' | '_order'>;
991
- type ProductListingGroupSummary = ProductListingGroup<ProductListingGroupVariant>;
992
- type ProductListingGroupsProductVariants = NonNullable<PublicProduct['variants']>;
993
- type ProductListingGroupsProductPrimaryMediaItemId = string | number | {
1031
+ type ProductSelectionOptionValue = {
1032
+ id?: string | number | null;
1033
+ swatch?: NormalizedOptionSwatch<unknown> | null;
1034
+ };
1035
+ type ProductSelectionMediaPointer = string | number | {
994
1036
  id?: string | number | null;
995
1037
  } | null;
996
- type ProductListingGroupsProduct = Omit<PublicProduct, 'variants'> & {
997
- id: string;
998
- slug: string;
999
- title: string;
1000
- primaryMediaItemId?: ProductListingGroupsProductPrimaryMediaItemId;
1001
- variants?: (Omit<ProductListingGroupsProductVariants, 'docs'> & {
1002
- docs: ProductListingGroupVariant[];
1003
- }) | null;
1038
+ type ResolveProductSelectionMediaInput<TMedia> = {
1039
+ productMediaPool?: TMedia[] | null;
1040
+ productPrimaryMediaItemId?: ProductSelectionMediaPointer;
1041
+ selectedVariant?: ProductSelectionVariant<TMedia> | null;
1042
+ matchingVariants?: Array<ProductSelectionVariant<TMedia> | null | undefined> | null;
1043
+ selectedOptionValues?: Array<ProductSelectionOptionValue | null | undefined> | null;
1004
1044
  };
1005
- type ProductListingGroupsItem = {
1006
- product: ProductListingGroupsProduct;
1007
- groups: ProductListingGroupSummary[];
1045
+ type ResolveProductSelectionMediaResult<TMedia> = {
1046
+ primaryImage: TMedia | null;
1047
+ images: TMedia[];
1048
+ source: ProductSelectionMediaSource;
1008
1049
  };
1009
- type ProductListingGroupsResponse = {
1010
- /**
1011
- * Matching products in the same order as the requested productIds, excluding
1012
- * ids that were not found, not published, or not accessible for the current
1013
- * tenant/key.
1014
- */
1015
- docs: ProductListingGroupsItem[];
1016
- /** Requested productIds that could not be returned. */
1017
- missing: string[];
1050
+ type ResolveProductDisplayMediaInput<TMedia> = {
1051
+ productMediaPool?: TMedia[] | null;
1052
+ productPrimaryMediaItemId?: ProductSelectionMediaPointer;
1053
+ listingPrimaryImage?: ProductSelectionMediaPointer;
1018
1054
  };
1019
- type ProductDetailParams = {
1020
- slug: string;
1021
- } | {
1022
- id: string;
1055
+ type ResolveProductDisplayMediaResult<TMedia> = {
1056
+ primaryImage: TMedia | null;
1057
+ images: TMedia[];
1058
+ source: ProductDisplayMediaSource;
1023
1059
  };
1024
- type ProductDetailPreviewParams = {
1025
- id: string;
1060
+ declare function resolveProductSelectionMedia<TMedia>(input: ResolveProductSelectionMediaInput<TMedia>): ResolveProductSelectionMediaResult<TMedia>;
1061
+ declare function resolveProductDisplayMedia<TMedia>(input: ResolveProductDisplayMediaInput<TMedia>): ResolveProductDisplayMediaResult<TMedia>;
1062
+ type ListingPrimaryImageFallbackInput<TMedia> = {
1063
+ productMediaPool?: TMedia[] | null;
1064
+ productPrimaryMediaItemId?: ProductSelectionMediaPointer;
1065
+ productThumbnail?: TMedia | string | number | null;
1066
+ listingPrimaryImage?: TMedia | string | number | null;
1067
+ resolvedPrimary?: TMedia | null;
1068
+ resolvedSource?: ProductMediaResolutionSource;
1026
1069
  };
1027
- type ProductDetailPreviewOptions = {
1028
- previewToken: string;
1070
+ declare function resolveListingPrimaryImagePointer<TMedia>(input: ListingPrimaryImageFallbackInput<TMedia>): string | null;
1071
+
1072
+ type EntityID = string;
1073
+ type RelationshipValue = string | number | null | undefined | {
1074
+ id?: string | number | null;
1029
1075
  };
1030
- interface ProductDetailVariantOptionValue {
1031
- optionId: string | number;
1032
- optionSlug: string;
1033
- valueId: string | number;
1034
- valueSlug: string;
1076
+ type MediaValue = ProductDetailMedia | null | undefined;
1077
+
1078
+ /** Raw Payload / REST swatch before strict public normalization. */
1079
+ type ProductOptionValueSwatchInput = {
1080
+ type?: 'color' | 'media' | null;
1081
+ color?: string | null;
1082
+ mediaItemId?: RelationshipValue;
1083
+ };
1084
+ interface ProductOptionValueShape {
1085
+ id?: string | number | null;
1086
+ option?: RelationshipValue;
1035
1087
  value?: string | null;
1088
+ slug?: string | null;
1089
+ swatch?: ProductOptionValueSwatch | ProductOptionValueSwatchInput | null;
1090
+ _order?: string | null;
1091
+ '_product-option-values_values_order'?: string | null;
1036
1092
  }
1037
- type ProductDetailMedia = string | number | {
1093
+ interface ProductOptionShape {
1038
1094
  id?: string | number | null;
1039
- url?: string | null;
1040
- alt?: string | null;
1041
- width?: number | null;
1042
- height?: number | null;
1043
- };
1044
- type ProductOptionValueColorSwatch = {
1045
- type: 'color';
1046
- color: string;
1047
- mediaItemId?: null;
1048
- };
1049
- type ProductOptionValueMediaSwatch<TMedia = ProductDetailMedia> = {
1050
- type: 'media';
1051
- mediaItemId: TMedia;
1052
- color?: null;
1053
- };
1054
- type ProductOptionValueSwatch<TMedia = ProductDetailMedia> = ProductOptionValueColorSwatch | ProductOptionValueMediaSwatch<TMedia> | null;
1055
- type ProductDetailMediaValue = string | number | ProductDetailMedia | null;
1056
- type ProductDetailSelectionMediaSource = 'variant_media_selected' | 'variant_media_matching' | 'option_swatch' | 'none';
1057
- interface ProductDetailVariant {
1058
- id: string | number;
1059
- optionKey: string;
1060
1095
  title?: string | null;
1061
- displayName: string;
1062
- sku?: string | null;
1063
- price: number;
1096
+ slug?: string | null;
1097
+ _order?: string | null;
1098
+ '_product-options_options_order'?: string | null;
1099
+ values?: {
1100
+ docs?: unknown[];
1101
+ } | null;
1102
+ }
1103
+ interface ProductVariantShape {
1104
+ id?: string | number | null;
1105
+ optionValues?: unknown[] | null;
1106
+ price?: number | null;
1064
1107
  compareAtPrice?: number | null;
1065
- stock: number;
1066
- reservedStock: number;
1067
- isUnlimited: boolean;
1068
- isActive: boolean;
1069
- thumbnail?: ProductDetailMedia | null;
1070
- images?: ProductDetailMedia[];
1071
- media?: {
1072
- primaryImage: ProductDetailMedia | null;
1073
- images: ProductDetailMedia[];
1074
- source: ProductDetailSelectionMediaSource;
1075
- };
1076
- optionValues: ProductDetailVariantOptionValue[];
1108
+ stock?: number | null;
1109
+ reservedStock?: number | null;
1110
+ isUnlimited?: boolean | null;
1111
+ isActive?: boolean | null;
1112
+ thumbnail?: MediaValue;
1113
+ images?: MediaValue[] | null;
1114
+ _order?: string | null;
1077
1115
  }
1078
- interface ProductDetailOptionValue {
1079
- id: string | number;
1080
- value: string;
1081
- slug: string;
1082
- swatch?: ProductOptionValueSwatch<ProductDetailMedia>;
1116
+ interface ProductListingProductShape {
1117
+ id?: EntityID;
1118
+ thumbnail?: MediaValue;
1119
+ primaryMediaItemId?: MediaValue;
1120
+ images?: MediaValue[] | null;
1121
+ listing?: {
1122
+ primaryImage?: MediaValue;
1123
+ } | null;
1083
1124
  }
1084
- interface ProductDetailOption {
1085
- id: string | number;
1125
+ type ProductOptionMatrixValue = {
1126
+ id: string;
1127
+ optionId: string;
1128
+ optionSlug: string;
1129
+ label: string;
1130
+ slug: string | null;
1131
+ swatch: ProductOptionValueSwatch;
1132
+ order: string;
1133
+ };
1134
+ type ProductOptionMatrixOption = {
1135
+ id: string;
1086
1136
  title: string;
1087
1137
  slug: string;
1088
- values: ProductDetailOptionValue[];
1089
- }
1090
- interface ProductDetailBrand {
1091
- id: string | number;
1092
- name: string;
1093
- slug?: string | null;
1094
- logo?: unknown | null;
1095
- }
1096
- interface ProductDetailCategory {
1097
- id: string | number;
1098
- title: string;
1099
- slug?: string | null;
1100
- }
1101
- interface ProductDetailTag {
1102
- id: string | number;
1103
- title: string;
1104
- slug?: string | null;
1105
- }
1106
- interface ProductDetailImage {
1107
- id: string | number;
1108
- url?: string | null;
1109
- alt?: string | null;
1110
- width?: number | null;
1111
- height?: number | null;
1112
- }
1113
- interface ProductDetailVideo {
1114
- id: string | number;
1115
- url?: string | null;
1116
- }
1117
- interface ProductDetailListing {
1118
- minPrice?: number | null;
1119
- maxPrice?: number | null;
1120
- minCompareAtPrice?: number | null;
1121
- maxCompareAtPrice?: number | null;
1122
- isPriceRange?: boolean | null;
1123
- primaryImage?: ProductDetailMedia | null;
1124
- availableForSale?: boolean | null;
1125
- selectionHintVariant?: string | number | null;
1126
- }
1127
- type ProductDetailCatalogVariant = Omit<ProductDetailVariant, 'stock' | 'reservedStock'>;
1128
- type ProductDetailCatalogListing = Omit<ProductDetailListing, 'availableForSale'> & {
1129
- liveStockRequired: true;
1138
+ order: string;
1139
+ values: ProductOptionMatrixValue[];
1140
+ };
1141
+ type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
1142
+ id: string;
1143
+ optionValueIds: string[];
1144
+ optionValueByOptionId: Map<string, string>;
1145
+ optionValueByOptionSlug: Map<string, string>;
1146
+ source: TVariant;
1147
+ };
1148
+ type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
1149
+ options: ProductOptionMatrixOption[];
1150
+ optionIds: string[];
1151
+ optionSlugs: string[];
1152
+ optionById: Map<string, ProductOptionMatrixOption>;
1153
+ optionBySlug: Map<string, ProductOptionMatrixOption>;
1154
+ valueById: Map<string, ProductOptionMatrixValue>;
1155
+ valueToOptionId: Map<string, string>;
1156
+ valueToOptionSlug: Map<string, string>;
1157
+ variants: ProductOptionMatrixVariant<TVariant>[];
1158
+ };
1159
+ type ProductListingProjection = {
1160
+ selectionHintVariant: EntityID | null;
1161
+ primaryImage: EntityID | null;
1162
+ minPrice: number | null;
1163
+ maxPrice: number | null;
1164
+ minCompareAtPrice: number | null;
1165
+ maxCompareAtPrice: number | null;
1166
+ isPriceRange: boolean;
1167
+ availableForSale: boolean;
1168
+ };
1169
+ type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
1170
+ optionId: EntityID;
1171
+ optionTitle: string;
1172
+ optionSlug: string;
1173
+ optionValueId: EntityID;
1174
+ optionValueLabel: string;
1175
+ optionValueSlug: string | null;
1176
+ optionValueSwatch: ProductOptionValueSwatch;
1177
+ variantIds: EntityID[];
1178
+ variantCount: number;
1179
+ variants: TVariant[];
1180
+ listing: ProductListingProjection;
1181
+ };
1182
+ type ProductListingCardPriceRange = {
1183
+ minPrice: number | null;
1184
+ maxPrice: number | null;
1185
+ minCompareAtPrice: number | null;
1186
+ maxCompareAtPrice: number | null;
1187
+ isPriceRange: boolean;
1130
1188
  };
1131
- interface ProductDetailCatalog {
1132
- product: Omit<ProductDetail['product'], 'totalInventory'>;
1133
- variants: ProductDetailCatalogVariant[];
1134
- options: ProductDetail['options'];
1135
- brand: ProductDetail['brand'];
1136
- categories: ProductDetail['categories'];
1137
- tags: ProductDetail['tags'];
1138
- images: ProductDetail['images'];
1139
- videos: ProductDetail['videos'];
1140
- primaryMediaItemId?: ProductDetail['primaryMediaItemId'];
1141
- listing: ProductDetailCatalogListing;
1142
- }
1143
- type StockSnapshotItemStatus = 'available' | 'not_published' | 'archived' | 'not_found';
1144
- interface StockSnapshotItem {
1145
- variantId: string;
1146
- status: StockSnapshotItemStatus;
1147
- availableStock: number;
1189
+ type ProductListingSwatch = {
1190
+ optionId: EntityID;
1191
+ optionValueId: EntityID;
1192
+ label: string;
1193
+ swatch: ProductOptionValueSwatch<ProductDetailMedia>;
1194
+ href: string;
1148
1195
  availableForSale: boolean;
1149
- isUnlimited: boolean;
1150
- }
1151
- interface StockSnapshotResponse {
1152
- snapshots: StockSnapshotItem[];
1153
- }
1154
- type StockSnapshotParams = {
1155
- variantIds: string[];
1156
1196
  };
1157
- interface ProductDetail {
1158
- product: {
1159
- id: string | number;
1160
- slug: string;
1161
- title: string;
1162
- subtitle?: string | null;
1163
- description?: string | null;
1164
- content?: unknown;
1165
- publishedAt?: string | null;
1166
- status: string;
1167
- totalInventory: number | null;
1168
- totalVariants: number;
1169
- hasUnlimitedVariant: boolean;
1170
- hasOnlyDefaultVariant: boolean;
1171
- };
1172
- variants: ProductDetailVariant[];
1173
- options: ProductDetailOption[];
1174
- brand: ProductDetailBrand | null;
1175
- categories: ProductDetailCategory[];
1176
- tags: ProductDetailTag[];
1177
- images: ProductDetailImage[];
1178
- videos: ProductDetailVideo[];
1179
- /** Canonical product primary pointer (pool member). */
1180
- primaryMediaItemId?: ProductDetailMediaValue;
1181
- listing: ProductDetailListing;
1182
- }
1183
- type ProductDetailUnavailableReason = 'not_found' | 'not_published' | 'feature_disabled';
1184
- type ProductDetailResult = {
1185
- found: true;
1186
- product: ProductDetail;
1187
- } | {
1188
- found: false;
1189
- reason: ProductDetailUnavailableReason;
1197
+ type ProductListingCardSourceItem = ProductListingGroupsCatalogItem | ProductListingGroupsItem;
1198
+ type ProductListingCardRepresentativeVariant = ProductListingCardSourceItem['groups'][number]['variants'][number];
1199
+ type ProductListingCard = {
1200
+ id: EntityID;
1201
+ href: string;
1202
+ title: string;
1203
+ representativeVariant?: ProductListingCardRepresentativeVariant | null;
1204
+ primaryImage: ProductDetailMedia | null;
1205
+ priceRange: ProductListingCardPriceRange;
1206
+ availableForSale: boolean;
1207
+ swatches: ProductListingSwatch[];
1190
1208
  };
1191
- type ProductDetailCatalogResult = {
1192
- found: true;
1193
- product: ProductDetailCatalog;
1194
- } | {
1195
- found: false;
1196
- reason: ProductDetailUnavailableReason;
1209
+ type ProductSelectionByOptionValue = string | number | null | undefined | {
1210
+ valueId?: string | number | null;
1211
+ valueSlug?: string | null;
1197
1212
  };
1198
- type ProductUpsertParams = ProductUpsertInput;
1199
- /** Console `POST /api/products/upsert` field allowlist error reasons. */
1200
- declare const PRODUCT_UPSERT_UNKNOWN_FIELD_REASON: "unknown_field";
1201
- declare const PRODUCT_UPSERT_READONLY_FIELD_REASON: "product_field_readonly";
1202
- type ProductUpsertFieldValidationErrorReason = typeof PRODUCT_UPSERT_UNKNOWN_FIELD_REASON | typeof PRODUCT_UPSERT_READONLY_FIELD_REASON;
1203
- /** 400 response body when upsert rejects unknown or server-managed product fields. */
1204
- type ProductUpsertFieldValidationErrorBody = {
1205
- error: string;
1206
- reason: ProductUpsertFieldValidationErrorReason;
1207
- field: string;
1208
- requestId?: string;
1213
+ type ProductSelectionInput = {
1214
+ variantId?: string | number | null;
1215
+ byOptionSlug?: Record<string, ProductSelectionByOptionValue>;
1216
+ byOptionId?: Record<string, ProductSelectionByOptionValue>;
1217
+ valueIds?: Iterable<unknown>;
1218
+ search?: string | URLSearchParams | URL | null;
1209
1219
  };
1210
- declare function isProductUpsertFieldValidationErrorBody(value: unknown): value is ProductUpsertFieldValidationErrorBody;
1211
- type ProductUpsertResponse = {
1212
- ok: true;
1213
- product: PublicProduct;
1214
- listingProjectionStale: boolean;
1215
- } | {
1216
- ok: false;
1217
- failedEntity: 'product' | 'option' | 'option-value' | 'variant';
1218
- failedIndex?: number;
1219
- message: string;
1220
+ type NormalizedProductSelection = {
1221
+ byOptionSlug: Record<string, string>;
1222
+ byOptionId: Record<string, string>;
1223
+ valueIds: string[];
1224
+ variantId: string | null;
1220
1225
  };
1221
- declare class ProductApi extends BaseApi {
1222
- constructor(options: ProductApiOptions);
1223
- /**
1224
- * Check point-in-time stock availability for one or more product variants.
1225
- * Results reflect available stock at the moment of the call and are not guaranteed
1226
- * to remain available by the time an order is placed.
1227
- */
1228
- stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
1229
- stockSnapshot(params: StockSnapshotParams): Promise<StockSnapshotResponse>;
1230
- listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
1231
- listingGroupsCatalog(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
1232
- /**
1233
- * Fetch full product detail by slug or id.
1234
- * Returns a discriminated result so storefronts can distinguish missing,
1235
- * unpublished, and feature-disabled products.
1236
- *
1237
- * Only product-detail 404 responses carrying one of those allowlisted reasons
1238
- * are mapped to `{ found: false, reason }`. Unknown or uncoded 404s, plus
1239
- * permission/auth errors such as tenant mismatch, continue to throw typed SDK
1240
- * errors instead of being collapsed into a storefront absence result.
1241
- */
1242
- detail(params: ProductDetailParams): Promise<ProductDetailResult>;
1243
- detailCatalog(params: ProductDetailParams): Promise<ProductDetailCatalogResult>;
1226
+ type CompatibilityProductSelectionParamEvent = {
1227
+ optionId: string;
1228
+ optionSlug: string;
1229
+ valueSlug: string;
1230
+ searchParam: string;
1231
+ };
1232
+ type LegacyProductSelectionParamEvent = CompatibilityProductSelectionParamEvent;
1233
+ type ProductSelectionUrlEmit = 'slug-compat' | 'canonical-id';
1234
+ type ProductSelectionCodecOptions = {
1235
+ emit?: ProductSelectionUrlEmit;
1244
1236
  /**
1245
- * Atomically create or update a product together with its options,
1246
- * option-values, and variants in a single transaction. Mirrors Shopify's
1247
- * `productSet` shape and is the canonical write path for the MCP
1248
- * `product-upsert` tool.
1237
+ * When true, `resolveProductSelection()` fills unselected options to reach a
1238
+ * concrete variant. Does not change codec parse/stringify behavior.
1249
1239
  */
1250
- upsert(params: ProductUpsertParams): Promise<ProductUpsertResponse>;
1251
- }
1252
-
1253
- type DiscountApiOptions = ServerApiOptions;
1254
- type ValidateDiscountParams = {
1240
+ fillDefaults?: boolean;
1241
+ onCompatibilityOptionIdParam?: (event: CompatibilityProductSelectionParamEvent) => void;
1242
+ onLegacyOptionIdParam?: (event: LegacyProductSelectionParamEvent) => void;
1243
+ };
1244
+ type ProductSelectionResolutionContext = {
1245
+ detail?: Pick<ProductDetail, 'images' | 'listing' | 'primaryMediaItemId'>;
1246
+ images?: ProductDetail['images'];
1247
+ listing?: ProductDetail['listing'];
1248
+ primaryMediaItemId?: ProductDetail['primaryMediaItemId'];
1249
+ };
1250
+ type ProductSelectionAvailableSwatch = {
1251
+ color?: string | null;
1252
+ image?: MediaValue | null;
1253
+ };
1254
+ type ProductSelectionAvailableValue = {
1255
+ valueId: string;
1256
+ value: string;
1257
+ label: string;
1258
+ slug: string;
1259
+ selected: boolean;
1260
+ available: boolean;
1261
+ exists: boolean;
1262
+ availableForSale: boolean;
1263
+ isUnlimited: boolean;
1264
+ availableStock: number | null;
1265
+ swatch: ProductOptionValueSwatch;
1266
+ };
1267
+ type ProductSelectionResolution = {
1268
+ normalizedSelection: NormalizedProductSelection;
1269
+ selectedVariant: ProductDetailVariant | null;
1270
+ matchingVariants: ProductDetailVariant[];
1271
+ partialVariants: ProductDetailVariant[];
1272
+ availableValuesByOptionSlug: Record<string, ProductSelectionAvailableValue[]>;
1273
+ availableValuesByOptionId: Record<string, ProductSelectionAvailableValue[]>;
1274
+ allOptionsSelected: boolean;
1275
+ price: {
1276
+ min: number | null;
1277
+ max: number | null;
1278
+ compareAtMin: number | null;
1279
+ compareAtMax: number | null;
1280
+ isRange: boolean;
1281
+ };
1282
+ media: {
1283
+ primaryImage: ProductDetailMedia | null;
1284
+ images: ProductDetailMedia[];
1285
+ source?: ProductMediaResolutionSource;
1286
+ };
1287
+ stock: {
1288
+ availableForSale: boolean;
1289
+ isUnlimited: boolean;
1290
+ stock: number | null;
1291
+ reservedStock: number | null;
1292
+ availableStock: number | null;
1293
+ };
1294
+ };
1295
+ declare class ProductSelectionCodecError extends Error {
1255
1296
  code: string;
1256
- orderAmount: number;
1297
+ constructor(message: string);
1298
+ }
1299
+ declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
1300
+ options: ProductOptionShape[];
1301
+ variants?: TVariant[];
1302
+ }): ProductOptionMatrix<TVariant>;
1303
+ declare function buildProductOptionMatrixFromDetail(detail: ProductDetail): ProductOptionMatrix<ProductDetailVariant>;
1304
+ declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
1305
+ declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
1306
+ declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
1307
+ declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
1308
+ declare function normalizeProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1309
+ declare function normalizeProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1310
+ declare function parseProductSelection(detail: ProductDetail, search: string | URLSearchParams | URL | null | undefined, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1311
+ declare function stringifyProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): string;
1312
+ declare function createProductSelectionCodec(detail: ProductDetail, options?: ProductSelectionCodecOptions): {
1313
+ parse: (search: string | URLSearchParams | URL | null | undefined) => NormalizedProductSelection;
1314
+ stringify: (selection?: ProductSelectionInput) => string;
1315
+ };
1316
+ declare function resolveProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions, context?: ProductSelectionResolutionContext): ProductSelectionResolution;
1317
+ declare function resolveProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): ProductSelectionResolution;
1318
+ declare function selectNext(detail: ProductDetail, current: ProductSelectionInput | undefined, optionSlug: string, valueSlug: string, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1319
+ type ProductDetailImageMedia = Extract<ProductDetailMedia, {
1320
+ id?: string | number | null;
1321
+ url?: string | null;
1322
+ }>;
1323
+ declare function getProductSelectionImages(resolution: Pick<ProductSelectionResolution, 'media'>): ProductDetailImageMedia[];
1324
+ type ProductHrefProduct = ProductDetail | {
1325
+ slug?: string | null;
1326
+ product?: {
1327
+ slug?: string | null;
1328
+ } | null;
1329
+ };
1330
+ type ProductHrefGroup = {
1331
+ optionId?: string | number | null;
1332
+ optionSlug?: string | null;
1333
+ optionValueId?: string | number | null;
1334
+ optionValueSlug?: string | null;
1335
+ variantId?: string | number | null;
1336
+ listing?: {
1337
+ selectionHintVariant?: string | number | null;
1338
+ } | null;
1257
1339
  };
1258
- type ValidateDiscountResult = {
1259
- valid: boolean;
1260
- code: string;
1261
- type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
1262
- discountAmount: number;
1263
- freeShipping?: boolean;
1264
- reason?: string;
1340
+ type ProductHrefOptions = {
1341
+ basePath?: string;
1342
+ detail?: ProductDetail;
1343
+ matrix?: ProductOptionMatrix<ProductDetailVariant>;
1344
+ selection?: ProductSelectionInput;
1345
+ trailingSlash?: boolean;
1346
+ emit?: ProductSelectionUrlEmit;
1347
+ preferCompleteVariantFromHint?: boolean;
1265
1348
  };
1266
- declare class DiscountApi extends BaseApi {
1267
- constructor(options: DiscountApiOptions);
1268
- validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
1269
- }
1270
-
1271
- type ShippingApiOptions = ServerApiOptions;
1272
- type CalculateShippingParams = {
1273
- shippingPolicyId?: string;
1274
- orderAmount: number;
1275
- postalCode?: string;
1349
+ type ProductListingCardOptions = {
1350
+ basePath?: string;
1351
+ trailingSlash?: boolean;
1352
+ emit?: ProductSelectionUrlEmit;
1353
+ preferCompleteVariantFromHint?: boolean;
1276
1354
  };
1277
- type CalculateShippingResult = {
1278
- shippingAmount: number;
1279
- baseShippingAmount: number;
1280
- extraShippingAmount: number;
1281
- freeShipping: boolean;
1282
- freeShippingMinAmount: number | null;
1283
- isJeju: boolean;
1284
- isRemoteIsland: boolean;
1355
+ declare function buildProductHref(product: ProductHrefProduct, group?: ProductHrefGroup | null, options?: ProductHrefOptions): string;
1356
+ declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
1357
+ declare function buildProductListingCard(item: ProductListingCardSourceItem, options?: ProductListingCardOptions): ProductListingCard;
1358
+ /** Shopify `priceRangeV2` naming for persisted listing projection fields. */
1359
+ declare function toShopifyPriceRangeV2(listing: {
1360
+ minPrice?: number | null;
1361
+ maxPrice?: number | null;
1362
+ }): {
1363
+ minVariantPrice: {
1364
+ amount: number | null;
1365
+ };
1366
+ maxVariantPrice: {
1367
+ amount: number | null;
1368
+ };
1285
1369
  };
1286
- declare class ShippingApi extends BaseApi {
1287
- constructor(options: ShippingApiOptions);
1288
- calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
1289
- }
1370
+ /**
1371
+ * Server-side PLP query preset for raw `products` collection reads.
1372
+ *
1373
+ * Greenfield storefronts should prefer
1374
+ * `client.commerce.product.listingPage()` because it calls the shaped catalog
1375
+ * endpoint, preserves pagination metadata, returns card-ready `cards`, and
1376
+ * avoids exposing inventory quantities.
1377
+ *
1378
+ * This preset remains only for server-auth raw product query code
1379
+ * that deliberately understands Payload join behavior. It raises top-level
1380
+ * `products.options` and `products.variants` join limits, but it cannot fix
1381
+ * nested `options[].values.docs` joins because the Payload REST `joins` param
1382
+ * is flat.
1383
+ *
1384
+ * It is not accepted by publishable
1385
+ * `createClient().collections.from('products').find()` because browser-public
1386
+ * raw reads are constrained to `depth: 0`, `joins: false`, and no `populate`.
1387
+ */
1388
+ declare const PRODUCT_PLP_FIND_OPTIONS: ApiQueryOptions;
1389
+ /**
1390
+ * Builds product-first listing groups for one primary option.
1391
+ *
1392
+ * The returned groups are intended for product cards with nested swatches or
1393
+ * option-value sections. They do not make a product-paginated API response into
1394
+ * an expanded-card paginator; one product can still emit several groups.
1395
+ */
1396
+ declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
1397
+ product: ProductListingProductShape | null | undefined;
1398
+ options: ProductOptionShape[];
1399
+ variants: TVariant[];
1400
+ primaryOptionId?: string | null;
1401
+ }): ProductListingGroup<TVariant>[];
1290
1402
 
1291
- type OrderApiOptions = ServerApiOptions;
1292
- /** Header-only; never sent in the JSON body. */
1293
- type WithIdempotencyKey<T> = T & {
1294
- /**
1295
- * Client-generated key for safe retries. Sent as `X-Idempotency-Key` when the
1296
- * server endpoint supports HTTP idempotency.
1297
- */
1298
- idempotencyKey?: string;
1403
+ type ProductUpsertColorSwatchInput = {
1404
+ type: 'color';
1405
+ color: string;
1406
+ mediaItemId?: null;
1299
1407
  };
1300
- type CustomerSnapshot = {
1301
- name?: string;
1302
- email: string;
1303
- phone?: string;
1408
+ type ProductUpsertMediaSwatchInput = {
1409
+ type: 'media';
1410
+ mediaItemId: string;
1411
+ color?: null;
1304
1412
  };
1305
- type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
1306
- type ReturnItem = {
1307
- orderItem: string | number;
1308
- quantity: number;
1309
- restockAction?: RestockAction;
1310
- restockingFee?: number;
1413
+ type ProductUpsertSwatchInput = ProductUpsertColorSwatchInput | ProductUpsertMediaSwatchInput;
1414
+ type ProductUpsertOptionValueInput = {
1415
+ id?: string;
1416
+ value: string;
1417
+ slug?: string;
1418
+ swatch?: ProductUpsertSwatchInput | null;
1419
+ metadata?: unknown;
1311
1420
  };
1312
- type OrderCreateEntityID = string | number;
1313
- type CreateOrderItem = {
1314
- product: OrderCreateEntityID;
1315
- variant: OrderCreateEntityID;
1316
- option: OrderCreateEntityID;
1317
- quantity: number;
1318
- /**
1319
- * Compatibility input: the create-order endpoint accepts this, but the server
1320
- * derives authoritative line pricing from the product variant.
1321
- */
1322
- unitPrice?: number;
1323
- /**
1324
- * Compatibility input: the create-order endpoint accepts this, but the server
1325
- * derives authoritative line totals from the product variant.
1326
- */
1327
- totalPrice?: number;
1421
+ type OptionValueInput = ProductUpsertOptionValueInput;
1422
+ type OptionInput = {
1423
+ id?: string;
1424
+ title: string;
1425
+ slug?: string;
1426
+ values: OptionValueInput[];
1328
1427
  };
1329
- type CreateOrderLineItemsInput = {
1330
- orderItems: CreateOrderItem[];
1331
- items?: never;
1332
- } | {
1333
- /**
1334
- * Storefront-facing alias for orderItems. The SDK serializes this to
1335
- * orderItems for the existing create-order endpoint.
1336
- */
1337
- items: CreateOrderItem[];
1338
- /**
1339
- * @deprecated Use items for storefront-facing create-order inputs.
1340
- */
1341
- orderItems?: never;
1428
+ type VariantInput = {
1429
+ id?: string;
1430
+ optionValues?: Record<string, string | {
1431
+ valueSlug?: string;
1432
+ valueId?: string;
1433
+ value?: string;
1434
+ }> | string[];
1435
+ sku?: string | null;
1436
+ title?: string | null;
1437
+ price: number;
1438
+ compareAtPrice?: number | null;
1439
+ stock?: number;
1440
+ isUnlimited?: boolean;
1441
+ weight?: number | null;
1442
+ requiresShipping?: boolean;
1443
+ barcode?: string | null;
1444
+ externalId?: string | null;
1445
+ isActive?: boolean;
1446
+ images?: string[];
1447
+ metadata?: unknown;
1342
1448
  };
1343
- type CreateOrderBodyBase = {
1344
- orderNumber: string;
1345
- customer?: string;
1346
- customerSnapshot: CustomerSnapshot;
1347
- shippingAddress: Order['shippingAddress'];
1348
- totalAmount: number;
1349
- shippingAmount?: number;
1350
- pgPaymentId?: string;
1351
- discountCode?: string;
1449
+ type ProductFieldsInput = {
1450
+ id?: string;
1451
+ title?: string;
1452
+ subtitle?: string | null;
1453
+ description?: string | null;
1454
+ status?: string;
1455
+ slug?: string;
1456
+ primaryMediaItemId?: string | null;
1457
+ thumbnail?: string | null;
1458
+ images?: string[];
1459
+ vendor?: string | null;
1460
+ productType?: string | null;
1461
+ brand?: string | null;
1462
+ shippingPolicy?: string | null;
1463
+ weight?: number | null;
1464
+ minOrderQuantity?: number | null;
1465
+ maxOrderQuantity?: number | null;
1466
+ isFeatured?: boolean;
1467
+ publishedAt?: string | null;
1468
+ categories?: string[];
1469
+ tags?: string[];
1470
+ metadata?: unknown;
1352
1471
  };
1353
- type CreateOrderParams = WithIdempotencyKey<CreateOrderBodyBase & CreateOrderLineItemsInput>;
1354
- type UpdateOrderParams = {
1355
- orderNumber: string;
1356
- status: 'confirmed';
1472
+ type ProductUpsertGraphFields = {
1473
+ /** Required when updating an existing product graph if the server graph is non-empty. */
1474
+ graphRevision?: string;
1475
+ options?: OptionInput[];
1476
+ variants?: VariantInput[];
1357
1477
  };
1358
- type TransactionStatus = 'pending' | 'paid' | 'failed' | 'canceled';
1359
- type UpdateTransactionParams = {
1360
- pgPaymentId: string;
1361
- status: TransactionStatus;
1362
- paymentMethod?: string;
1363
- receiptUrl?: string;
1364
- paymentKey?: string;
1365
- amount?: number;
1478
+ /** Create a product document and initial graph. */
1479
+ type ProductUpsertCreateInput = ProductUpsertGraphFields & {
1480
+ productId?: never;
1481
+ product: ProductFieldsInput & {
1482
+ title: string;
1483
+ };
1366
1484
  };
1367
- type ConfirmPaymentParams = WithIdempotencyKey<{
1368
- orderNumber?: string;
1369
- pgPaymentId: string;
1370
- pgProvider: string;
1371
- pgOrderId?: string;
1372
- amount: number;
1373
- currency?: string;
1374
- paymentMethod?: string;
1375
- receiptUrl?: string;
1376
- approvedAt?: string;
1377
- providerStatus?: string;
1378
- /** Provider event id; also used as idempotency key when `idempotencyKey` is omitted. */
1379
- providerEventId?: string;
1380
- confirmationSource?: 'provider_webhook' | 'provider_lookup' | 'provider_api_confirm' | 'manual_server';
1381
- metadata?: Record<string, unknown>;
1382
- }>;
1383
- type ConfirmPaymentResponse = {
1384
- orderId: string;
1385
- transactionId: string;
1386
- status: 'paid';
1387
- alreadyConfirmed?: boolean;
1485
+ /** Graph-only update for an existing product (document fields via Payload save). */
1486
+ type ProductUpsertEditInput = ProductUpsertGraphFields & {
1487
+ productId: string;
1488
+ product?: never;
1489
+ };
1490
+ type ProductUpsertInput = ProductUpsertCreateInput | ProductUpsertEditInput;
1491
+
1492
+ type ProductApiOptions = ServerApiOptions;
1493
+ type StockCheckParams = {
1494
+ items: Array<{
1495
+ variantId: string;
1496
+ quantity: number;
1497
+ }>;
1498
+ };
1499
+ type StockCheckResult = {
1500
+ variantId: string;
1501
+ status: 'available' | 'not_published' | 'archived' | 'not_found';
1502
+ available: boolean;
1503
+ availableStock: number;
1504
+ isUnlimited: boolean;
1505
+ requestedQuantity: number;
1506
+ error?: string;
1388
1507
  };
1389
- type CancelReasonCode = 'customer' | 'inventory' | 'fraud' | 'declined' | 'staff' | 'other';
1390
- type CancelOrderStatus = 'pending' | 'paid' | 'failed' | 'canceled' | 'refunded' | 'preparing' | 'shipped' | 'delivered' | 'confirmed' | 'return_requested' | 'return_processing' | 'returned';
1391
- type CancelOrderReconciliationStatus = Exclude<CancelOrderStatus, 'pending' | 'failed' | 'canceled'>;
1392
- type CancelOrderResponseBase = {
1393
- orderId: string;
1508
+ type StockCheckResponse = {
1509
+ results: StockCheckResult[];
1510
+ allAvailable: boolean;
1394
1511
  };
1395
- type CancelOrderUnpaidCommittedResponseFields = {
1396
- refundedAmount: 0;
1397
- providerRefunded: false;
1512
+ type ListingGroupsParams = {
1513
+ productIds: string[];
1398
1514
  };
1399
- type CancelOrderPaidCommittedResponseFields = {
1400
- transactionId: string;
1401
- refundedAmount: 0;
1402
- providerRefunded: false;
1403
- refundPending: true;
1515
+ type ProductListingGroupVariant = Pick<ProductVariantShape, 'id' | 'optionValues' | 'price' | 'compareAtPrice' | 'stock' | 'isUnlimited' | 'isActive' | 'thumbnail' | 'images' | '_order'>;
1516
+ type ProductListingGroupSummary = ProductListingGroup<ProductListingGroupVariant>;
1517
+ type ProductListingGroupCatalogVariant = Omit<ProductListingGroupVariant, 'stock'>;
1518
+ type ProductListingGroupCatalogSummary = ProductListingGroup<ProductListingGroupCatalogVariant>;
1519
+ type ProductListingGroupsProductVariants = NonNullable<PublicProduct['variants']>;
1520
+ type ProductListingGroupsProductPrimaryMediaItemId = string | number | {
1521
+ id?: string | number | null;
1522
+ } | null;
1523
+ type ProductListingGroupsProduct = Omit<PublicProduct, 'createdAt' | 'primaryMediaItemId' | 'updatedAt' | 'variants'> & {
1524
+ id: string;
1525
+ slug: string;
1526
+ title: string;
1527
+ createdAt?: PublicProduct['createdAt'];
1528
+ updatedAt?: PublicProduct['updatedAt'];
1529
+ primaryMediaItemId?: ProductListingGroupsProductPrimaryMediaItemId;
1530
+ variants?: (Omit<ProductListingGroupsProductVariants, 'docs'> & {
1531
+ docs: ProductListingGroupVariant[];
1532
+ }) | null;
1404
1533
  };
1405
- type CancelOrderLegacyProviderRefundResponseFields = {
1406
- transactionId: string;
1407
- refundedAmount: number;
1408
- refundSeq: number;
1409
- providerRefunded: true;
1534
+ type ProductListingGroupsCatalogListing = {
1535
+ minPrice?: NonNullable<ProductListingGroupsProduct['listing']>['minPrice'];
1536
+ maxPrice?: NonNullable<ProductListingGroupsProduct['listing']>['maxPrice'];
1537
+ minCompareAtPrice?: NonNullable<ProductListingGroupsProduct['listing']>['minCompareAtPrice'];
1538
+ maxCompareAtPrice?: NonNullable<ProductListingGroupsProduct['listing']>['maxCompareAtPrice'];
1539
+ isPriceRange?: NonNullable<ProductListingGroupsProduct['listing']>['isPriceRange'];
1540
+ primaryImage?: NonNullable<ProductListingGroupsProduct['listing']>['primaryImage'];
1541
+ availableForSale?: NonNullable<ProductListingGroupsProduct['listing']>['availableForSale'];
1542
+ selectionHintVariant?: NonNullable<ProductListingGroupsProduct['listing']>['selectionHintVariant'];
1543
+ };
1544
+ type ProductListingGroupsCatalogProduct = {
1545
+ id: string;
1546
+ slug: string;
1547
+ handle?: string | null;
1548
+ title: string;
1549
+ subtitle?: ProductListingGroupsProduct['subtitle'];
1550
+ primaryMediaItemId?: ProductListingGroupsProductPrimaryMediaItemId;
1551
+ thumbnail?: ProductListingGroupsProduct['thumbnail'];
1552
+ images?: ProductListingGroupsProduct['images'];
1553
+ listing?: ProductListingGroupsCatalogListing | null;
1554
+ variants?: (Omit<NonNullable<ProductListingGroupsProduct['variants']>, 'docs'> & {
1555
+ docs: ProductListingGroupCatalogVariant[];
1556
+ }) | null;
1410
1557
  };
1411
- type CancelOrderAlreadyCanceledResponseFields = {
1412
- refundedAmount: number;
1413
- providerRefunded: false;
1558
+ type ProductListingGroupsItem = {
1559
+ product: ProductListingGroupsProduct;
1560
+ groups: ProductListingGroupSummary[];
1414
1561
  };
1415
- type CancelOrderAlreadyCanceledRefundPendingResponseFields = {
1416
- transactionId: string;
1417
- refundedAmount: number;
1418
- providerRefunded: false;
1419
- refundPending: true;
1562
+ type ProductListingGroupsCatalogItem = {
1563
+ product: ProductListingGroupsCatalogProduct;
1564
+ groups: ProductListingGroupCatalogSummary[];
1420
1565
  };
1421
- type CancelOrderPaidCommittedResponse = CancelOrderResponseBase & CancelOrderPaidCommittedResponseFields & {
1422
- status: 'canceled';
1423
- cancelCommitted: true;
1566
+ type ProductListingGroupsResponse = {
1567
+ /**
1568
+ * Matching products in the same order as the requested productIds, excluding
1569
+ * ids that were not found, not published, or not accessible for the current
1570
+ * tenant/key.
1571
+ */
1572
+ docs: ProductListingGroupsItem[];
1573
+ /** Requested productIds that could not be returned. */
1574
+ missing: string[];
1424
1575
  };
1425
- type CancelOrderUnpaidCommittedResponse = CancelOrderResponseBase & CancelOrderUnpaidCommittedResponseFields & {
1426
- status: 'canceled';
1427
- cancelCommitted: true;
1576
+ type ProductListingGroupsCatalogResponse = Omit<ProductListingGroupsResponse, 'docs'> & {
1577
+ docs: ProductListingGroupsCatalogItem[];
1578
+ };
1579
+ type ProductListingPageSort = 'id' | '-id' | 'slug' | '-slug' | 'handle' | '-handle' | 'createdAt' | '-createdAt' | 'updatedAt' | '-updatedAt' | 'title' | '-title' | 'listing.minPrice' | '-listing.minPrice' | 'listing.maxPrice' | '-listing.maxPrice' | 'listing.availableForSale' | '-listing.availableForSale';
1580
+ type ProductListingPageFilters = {
1581
+ ids?: string[];
1582
+ slugs?: string[];
1583
+ handles?: string[];
1584
+ categoryIds?: string[];
1585
+ tagIds?: string[];
1586
+ price?: {
1587
+ min?: number;
1588
+ max?: number;
1589
+ };
1590
+ availableForSale?: boolean;
1428
1591
  };
1429
- type CancelOrderCommittedResponse = CancelOrderPaidCommittedResponse | CancelOrderUnpaidCommittedResponse;
1430
- type CancelOrderAlreadyCanceledResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledResponseFields & {
1431
- status: 'canceled';
1432
- cancelCommitted: false;
1433
- alreadyCanceled: true;
1592
+ type ProductListingPageBaseParams = {
1593
+ page?: number;
1594
+ limit?: number;
1595
+ search?: string;
1596
+ sort?: ProductListingPageSort | ProductListingPageSort[];
1597
+ filters?: ProductListingPageFilters;
1598
+ } & ProductListingCardOptions;
1599
+ type ProductListingPageCatalogParams = ProductListingPageBaseParams & {
1600
+ mode?: 'catalog';
1434
1601
  };
1435
- type CancelOrderAlreadyCanceledRefundPendingResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledRefundPendingResponseFields & {
1436
- status: 'canceled';
1437
- cancelCommitted: false;
1438
- alreadyCanceled: true;
1602
+ type ProductListingPageFullParams = ProductListingPageBaseParams & {
1603
+ mode: 'full';
1439
1604
  };
1440
- /** @deprecated Inline PG cancel reconciliation; retained for legacy API consumers. */
1441
- type CancelOrderReconciliationResponse = CancelOrderResponseBase & CancelOrderLegacyProviderRefundResponseFields & {
1442
- status: CancelOrderReconciliationStatus;
1443
- cancelCommitted: false;
1444
- reconciliationRequired: true;
1605
+ type ProductListingPageParams = ProductListingPageCatalogParams | ProductListingPageFullParams;
1606
+ type ProductListingPageResult<TItem> = PayloadFindResponse<TItem> & {
1607
+ cards: ProductListingCard[];
1445
1608
  };
1446
- type CancelOrderResponse = CancelOrderCommittedResponse | CancelOrderAlreadyCanceledResponse | CancelOrderAlreadyCanceledRefundPendingResponse | CancelOrderReconciliationResponse;
1447
- type CancelOrderParams = {
1448
- orderNumber: string;
1449
- reasonCode?: CancelReasonCode;
1450
- reasonDetail?: string;
1451
- idempotencyKey?: string;
1609
+ type ProductDetailParams = {
1610
+ slug: string;
1611
+ } | {
1612
+ id: string;
1452
1613
  };
1453
- type ResolveCancelRefundOutcome = 'succeeded' | 'failed';
1454
- type ResolveCancelRefundSucceededParams = {
1455
- orderNumber: string;
1456
- idempotencyKey: string;
1457
- outcome: 'succeeded';
1458
- refundedAmount: number;
1459
- pgProvider: string;
1460
- pgRefundId: string;
1614
+ type ProductDetailPreviewParams = {
1615
+ id: string;
1461
1616
  };
1462
- type ResolveCancelRefundFailedParams = {
1463
- orderNumber: string;
1464
- idempotencyKey: string;
1465
- outcome: 'failed';
1466
- refundedAmount: 0;
1467
- pgProvider: string;
1468
- pgRefundId?: string;
1617
+ type ProductDetailPreviewOptions = {
1618
+ previewToken: string;
1469
1619
  };
1470
- type ResolveCancelRefundParams = ResolveCancelRefundSucceededParams | ResolveCancelRefundFailedParams;
1471
- type ResolveCancelRefundSucceededResponse = {
1472
- orderId: string;
1473
- transactionId: string;
1474
- refundTransactionId: string;
1475
- refundedAmount: number;
1476
- refundStatus: 'succeeded';
1477
- transactionStatus: 'refunded';
1620
+ interface ProductDetailVariantOptionValue {
1621
+ optionId: string | number;
1622
+ optionSlug: string;
1623
+ valueId: string | number;
1624
+ valueSlug: string;
1625
+ value?: string | null;
1626
+ }
1627
+ type ProductDetailMedia = string | number | {
1628
+ id?: string | number | null;
1629
+ url?: string | null;
1630
+ alt?: string | null;
1631
+ width?: number | null;
1632
+ height?: number | null;
1478
1633
  };
1479
- type ResolveCancelRefundFailedResponse = {
1480
- orderId: string;
1481
- transactionId: string;
1482
- refundTransactionId: string;
1483
- refundedAmount: 0;
1484
- refundStatus: 'failed';
1485
- transactionStatus: 'paid';
1634
+ type ProductOptionValueColorSwatch = {
1635
+ type: 'color';
1636
+ color: string;
1637
+ mediaItemId?: null;
1638
+ };
1639
+ type ProductOptionValueMediaSwatch<TMedia = ProductDetailMedia> = {
1640
+ type: 'media';
1641
+ mediaItemId: TMedia;
1642
+ color?: null;
1643
+ };
1644
+ type ProductOptionValueSwatch<TMedia = ProductDetailMedia> = ProductOptionValueColorSwatch | ProductOptionValueMediaSwatch<TMedia> | null;
1645
+ type ProductDetailMediaValue = string | number | ProductDetailMedia | null;
1646
+ type ProductDetailSelectionMediaSource = 'variant_media_selected' | 'variant_media_matching' | 'option_swatch' | 'none';
1647
+ interface ProductDetailVariant {
1648
+ id: string | number;
1649
+ optionKey: string;
1650
+ title?: string | null;
1651
+ displayName: string;
1652
+ sku?: string | null;
1653
+ price: number;
1654
+ compareAtPrice?: number | null;
1655
+ stock: number;
1656
+ reservedStock: number;
1657
+ isUnlimited: boolean;
1658
+ isActive: boolean;
1659
+ thumbnail?: ProductDetailMedia | null;
1660
+ images?: ProductDetailMedia[];
1661
+ media?: {
1662
+ primaryImage: ProductDetailMedia | null;
1663
+ images: ProductDetailMedia[];
1664
+ source: ProductDetailSelectionMediaSource;
1665
+ };
1666
+ optionValues: ProductDetailVariantOptionValue[];
1667
+ }
1668
+ interface ProductDetailOptionValue {
1669
+ id: string | number;
1670
+ value: string;
1671
+ slug: string;
1672
+ swatch?: ProductOptionValueSwatch<ProductDetailMedia>;
1673
+ }
1674
+ interface ProductDetailOption {
1675
+ id: string | number;
1676
+ title: string;
1677
+ slug: string;
1678
+ values: ProductDetailOptionValue[];
1679
+ }
1680
+ interface ProductDetailBrand {
1681
+ id: string | number;
1682
+ name: string;
1683
+ slug?: string | null;
1684
+ logo?: unknown | null;
1685
+ }
1686
+ interface ProductDetailCategory {
1687
+ id: string | number;
1688
+ title: string;
1689
+ slug?: string | null;
1690
+ }
1691
+ interface ProductDetailTag {
1692
+ id: string | number;
1693
+ title: string;
1694
+ slug?: string | null;
1695
+ }
1696
+ interface ProductDetailImage {
1697
+ id: string | number;
1698
+ url?: string | null;
1699
+ alt?: string | null;
1700
+ width?: number | null;
1701
+ height?: number | null;
1702
+ }
1703
+ interface ProductDetailVideo {
1704
+ id: string | number;
1705
+ url?: string | null;
1706
+ }
1707
+ interface ProductDetailListing {
1708
+ minPrice?: number | null;
1709
+ maxPrice?: number | null;
1710
+ minCompareAtPrice?: number | null;
1711
+ maxCompareAtPrice?: number | null;
1712
+ isPriceRange?: boolean | null;
1713
+ primaryImage?: ProductDetailMedia | null;
1714
+ availableForSale?: boolean | null;
1715
+ selectionHintVariant?: string | number | null;
1716
+ }
1717
+ type ProductDetailCatalogVariant = Omit<ProductDetailVariant, 'stock' | 'reservedStock'>;
1718
+ type ProductDetailCatalogListing = Omit<ProductDetailListing, 'availableForSale'> & {
1719
+ liveStockRequired: true;
1720
+ };
1721
+ interface ProductDetailCatalog {
1722
+ product: Omit<ProductDetail['product'], 'totalInventory'>;
1723
+ variants: ProductDetailCatalogVariant[];
1724
+ options: ProductDetail['options'];
1725
+ brand: ProductDetail['brand'];
1726
+ categories: ProductDetail['categories'];
1727
+ tags: ProductDetail['tags'];
1728
+ images: ProductDetail['images'];
1729
+ videos: ProductDetail['videos'];
1730
+ primaryMediaItemId?: ProductDetail['primaryMediaItemId'];
1731
+ listing: ProductDetailCatalogListing;
1732
+ }
1733
+ type StockSnapshotItemStatus = 'available' | 'not_published' | 'archived' | 'not_found';
1734
+ interface StockSnapshotItem {
1735
+ variantId: string;
1736
+ status: StockSnapshotItemStatus;
1737
+ availableStock: number;
1738
+ availableForSale: boolean;
1739
+ isUnlimited: boolean;
1740
+ }
1741
+ interface StockSnapshotResponse {
1742
+ snapshots: StockSnapshotItem[];
1743
+ }
1744
+ type StockSnapshotParams = {
1745
+ variantIds: string[];
1486
1746
  };
1487
- type ResolveCancelRefundResponse = ResolveCancelRefundSucceededResponse | ResolveCancelRefundFailedResponse;
1488
- type RestockAction = 'return_to_stock' | 'discard';
1489
- type ReturnWithRefundItem = {
1490
- orderItem: string | number;
1491
- quantity: number;
1492
- restockAction?: RestockAction;
1493
- restockingFee?: number;
1747
+ interface ProductDetail {
1748
+ product: {
1749
+ id: string | number;
1750
+ slug: string;
1751
+ title: string;
1752
+ subtitle?: string | null;
1753
+ description?: string | null;
1754
+ content?: unknown;
1755
+ publishedAt?: string | null;
1756
+ status: string;
1757
+ totalInventory: number | null;
1758
+ totalVariants: number;
1759
+ hasUnlimitedVariant: boolean;
1760
+ hasOnlyDefaultVariant: boolean;
1761
+ };
1762
+ variants: ProductDetailVariant[];
1763
+ options: ProductDetailOption[];
1764
+ brand: ProductDetailBrand | null;
1765
+ categories: ProductDetailCategory[];
1766
+ tags: ProductDetailTag[];
1767
+ images: ProductDetailImage[];
1768
+ videos: ProductDetailVideo[];
1769
+ /** Canonical product primary pointer (pool member). */
1770
+ primaryMediaItemId?: ProductDetailMediaValue;
1771
+ listing: ProductDetailListing;
1772
+ }
1773
+ type ProductDetailUnavailableReason = 'not_found' | 'not_published' | 'feature_disabled';
1774
+ type ProductDetailResult = {
1775
+ found: true;
1776
+ product: ProductDetail;
1777
+ } | {
1778
+ found: false;
1779
+ reason: ProductDetailUnavailableReason;
1494
1780
  };
1495
- type ReturnWithRefundParams = WithIdempotencyKey<{
1496
- orderNumber: string;
1497
- reason?: ReturnReason;
1498
- reasonDetail?: string;
1499
- returnItems: ReturnWithRefundItem[];
1500
- refundAmount: number;
1501
- returnShippingFee?: number;
1502
- initialShippingRefundAmount?: number;
1503
- initialShippingRefundOverrideNote?: string;
1504
- pgPaymentId: string;
1505
- paymentKey?: string;
1506
- refundReceiptUrl?: string;
1507
- }>;
1508
- type CheckoutParams = WithIdempotencyKey<{
1509
- cartId: string;
1510
- orderNumber: string;
1511
- customerSnapshot: CustomerSnapshot;
1512
- pgPaymentId?: string;
1513
- discountCode?: string;
1514
- }>;
1515
- type CreateFulfillmentParams = WithIdempotencyKey<{
1516
- orderNumber: string;
1517
- fulfillmentOrderId?: string | number;
1518
- carrier?: string;
1519
- trackingNumber?: string;
1520
- items?: Array<{
1521
- orderItem: string;
1522
- quantity: number;
1523
- }>;
1524
- }>;
1525
- type PrepareFulfillmentOrderParams = {
1526
- orderNumber: string;
1781
+ type ProductDetailCatalogResult = {
1782
+ found: true;
1783
+ product: ProductDetailCatalog;
1784
+ } | {
1785
+ found: false;
1786
+ reason: ProductDetailUnavailableReason;
1527
1787
  };
1528
- type PrepareFulfillmentOrderResponse = {
1529
- orderId: string;
1530
- fulfillmentOrders: Array<{
1531
- id: string;
1532
- status: string;
1533
- }>;
1788
+ type ProductUpsertParams = ProductUpsertInput;
1789
+ /** Console `POST /api/products/upsert` field allowlist error reasons. */
1790
+ declare const PRODUCT_UPSERT_UNKNOWN_FIELD_REASON: "unknown_field";
1791
+ declare const PRODUCT_UPSERT_READONLY_FIELD_REASON: "product_field_readonly";
1792
+ type ProductUpsertFieldValidationErrorReason = typeof PRODUCT_UPSERT_UNKNOWN_FIELD_REASON | typeof PRODUCT_UPSERT_READONLY_FIELD_REASON;
1793
+ /** 400 response body when upsert rejects unknown or server-managed product fields. */
1794
+ type ProductUpsertFieldValidationErrorBody = {
1795
+ error: string;
1796
+ reason: ProductUpsertFieldValidationErrorReason;
1797
+ field: string;
1798
+ requestId?: string;
1534
1799
  };
1535
- type UpdateFulfillmentParams = {
1536
- fulfillmentId: string;
1537
- status?: 'shipped' | 'delivered' | 'failed';
1538
- carrier?: string;
1539
- trackingNumber?: string;
1800
+ declare function isProductUpsertFieldValidationErrorBody(value: unknown): value is ProductUpsertFieldValidationErrorBody;
1801
+ type ProductUpsertResponse = {
1802
+ ok: true;
1803
+ product: PublicProduct;
1804
+ listingProjectionStale: boolean;
1805
+ } | {
1806
+ ok: false;
1807
+ failedEntity: 'product' | 'option' | 'option-value' | 'variant';
1808
+ failedIndex?: number;
1809
+ message: string;
1540
1810
  };
1541
- type BulkImportFulfillmentsParams = {
1542
- items: Array<{
1543
- orderNumber: string;
1544
- carrier: string;
1545
- trackingNumber: string;
1546
- }>;
1811
+ declare class ProductApi extends BaseApi {
1812
+ constructor(options: ProductApiOptions);
1813
+ /**
1814
+ * Check point-in-time stock availability for one or more product variants.
1815
+ * Results reflect available stock at the moment of the call and are not guaranteed
1816
+ * to remain available by the time an order is placed.
1817
+ */
1818
+ stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
1819
+ stockSnapshot(params: StockSnapshotParams): Promise<StockSnapshotResponse>;
1820
+ listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
1821
+ listingGroupsCatalog(params: ListingGroupsParams): Promise<ProductListingGroupsCatalogResponse>;
1822
+ listingPage(params?: ProductListingPageCatalogParams): Promise<ProductListingPageResult<ProductListingGroupsCatalogItem>>;
1823
+ listingPage(params: ProductListingPageFullParams): Promise<ProductListingPageResult<ProductListingGroupsItem>>;
1824
+ listingPage(params: ProductListingPageParams): Promise<ProductListingPageResult<ProductListingGroupsCatalogItem> | ProductListingPageResult<ProductListingGroupsItem>>;
1825
+ /**
1826
+ * Fetch full product detail by slug or id.
1827
+ * Returns a discriminated result so storefronts can distinguish missing,
1828
+ * unpublished, and feature-disabled products.
1829
+ *
1830
+ * Only product-detail 404 responses carrying one of those allowlisted reasons
1831
+ * are mapped to `{ found: false, reason }`. Unknown or uncoded 404s, plus
1832
+ * permission/auth errors such as tenant mismatch, continue to throw typed SDK
1833
+ * errors instead of being collapsed into a storefront absence result.
1834
+ */
1835
+ detail(params: ProductDetailParams): Promise<ProductDetailResult>;
1836
+ detailCatalog(params: ProductDetailParams): Promise<ProductDetailCatalogResult>;
1837
+ /**
1838
+ * Atomically create or update a product together with its options,
1839
+ * option-values, and variants in a single transaction. Mirrors Shopify's
1840
+ * `productSet` shape and is the canonical write path for the MCP
1841
+ * `product-upsert` tool.
1842
+ */
1843
+ upsert(params: ProductUpsertParams): Promise<ProductUpsertResponse>;
1844
+ }
1845
+
1846
+ type DiscountApiOptions = ServerApiOptions;
1847
+ type ValidateDiscountParams = {
1848
+ code: string;
1849
+ orderAmount: number;
1547
1850
  };
1548
- type BulkImportFulfillmentsResponse = {
1549
- succeeded: Array<{
1550
- orderNumber: string;
1551
- fulfillmentId: string;
1552
- }>;
1553
- failed: Array<{
1554
- orderNumber: string;
1555
- error: string;
1556
- }>;
1851
+ type ValidateDiscountResult = {
1852
+ valid: boolean;
1853
+ code: string;
1854
+ type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
1855
+ discountAmount: number;
1856
+ freeShipping?: boolean;
1857
+ reason?: string;
1557
1858
  };
1558
- type CreateReturnParams = WithIdempotencyKey<{
1559
- orderNumber: string;
1560
- reason?: ReturnReason;
1561
- reasonDetail?: string;
1562
- returnItems: ReturnItem[];
1563
- refundAmount: number;
1564
- returnShippingFee?: number;
1565
- initialShippingRefundAmount?: number;
1566
- initialShippingRefundOverrideNote?: string;
1567
- }>;
1568
- type UpdateReturnParams = {
1569
- returnId: string;
1570
- status: 'processing' | 'approved' | 'rejected' | 'completed';
1859
+ declare class DiscountApi extends BaseApi {
1860
+ constructor(options: DiscountApiOptions);
1861
+ validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
1862
+ }
1863
+
1864
+ type ShippingApiOptions = ServerApiOptions;
1865
+ type CalculateShippingParams = {
1866
+ shippingPolicyId?: string;
1867
+ orderAmount: number;
1868
+ postalCode?: string;
1571
1869
  };
1572
- declare class OrderApi extends BaseApi {
1573
- constructor(options: OrderApiOptions);
1574
- createOrder(params: CreateOrderParams): Promise<Order>;
1575
- updateOrder(params: UpdateOrderParams): Promise<Order>;
1576
- updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
1577
- confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse>;
1578
- cancelOrder(params: CancelOrderParams): Promise<CancelOrderResponse>;
1579
- resolveCancelRefund(params: ResolveCancelRefundParams): Promise<ResolveCancelRefundResponse>;
1580
- checkout(params: CheckoutParams): Promise<Order>;
1581
- createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
1582
- prepareFulfillmentOrder(params: PrepareFulfillmentOrderParams): Promise<PrepareFulfillmentOrderResponse>;
1583
- updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
1584
- bulkImportFulfillments(params: BulkImportFulfillmentsParams): Promise<BulkImportFulfillmentsResponse>;
1585
- returnWithRefund(params: ReturnWithRefundParams): Promise<{
1586
- return: Return;
1587
- transaction: Transaction | null;
1588
- }>;
1589
- createReturn(params: CreateReturnParams): Promise<Return>;
1590
- updateReturn(params: UpdateReturnParams): Promise<Return>;
1870
+ type CalculateShippingResult = {
1871
+ shippingAmount: number;
1872
+ baseShippingAmount: number;
1873
+ extraShippingAmount: number;
1874
+ freeShipping: boolean;
1875
+ freeShippingMinAmount: number | null;
1876
+ isJeju: boolean;
1877
+ isRemoteIsland: boolean;
1878
+ };
1879
+ declare class ShippingApi extends BaseApi {
1880
+ constructor(options: ShippingApiOptions);
1881
+ calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
1591
1882
  }
1592
1883
 
1593
1884
  interface CommerceClientOptions {
@@ -1602,31 +1893,34 @@ declare class CommerceClient {
1602
1893
  readonly product: {
1603
1894
  stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1604
1895
  stockSnapshot: (params: StockSnapshotParams) => Promise<StockSnapshotResponse>;
1605
- listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1606
- listingGroupsCatalog: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1896
+ listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsCatalogResponse>;
1897
+ listingGroupsCatalog: (params: ListingGroupsParams) => Promise<ProductListingGroupsCatalogResponse>;
1898
+ listingPage: {
1899
+ (params?: ProductListingPageCatalogParams): Promise<ProductListingPageResult<ProductListingGroupsCatalogItem>>;
1900
+ };
1607
1901
  detail: (params: ProductDetailParams) => Promise<ProductDetailResult>;
1608
1902
  detailCatalog: (params: ProductDetailParams) => Promise<ProductDetailCatalogResult>;
1609
1903
  };
1610
1904
  readonly cart: {
1611
- get: (cartId: string) => Promise<Cart>;
1612
- addItem: (params: AddItemParams) => Promise<CartItem>;
1613
- updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1905
+ get: (cartId: string) => Promise<PublicCart>;
1906
+ addItem: (params: AddItemParams) => Promise<PublicCartItem>;
1907
+ updateItem: (params: UpdateItemParams) => Promise<PublicCartItem>;
1614
1908
  removeItem: (params: RemoveItemParams) => Promise<{
1615
1909
  success: boolean;
1616
1910
  }>;
1617
- applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1618
- removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1911
+ applyDiscount: (params: ApplyDiscountParams) => Promise<PublicCart>;
1912
+ removeDiscount: (params: RemoveDiscountParams) => Promise<PublicCart>;
1619
1913
  clear: (params: ClearCartParams) => Promise<{
1620
1914
  success: boolean;
1621
1915
  }>;
1622
1916
  };
1623
1917
  readonly orders: {
1624
- checkout: (params: CheckoutParams) => Promise<Order>;
1918
+ checkout: (params: CheckoutParams) => Promise<PublicOrder>;
1625
1919
  listMine: (options?: {
1626
1920
  page?: number;
1627
1921
  limit?: number;
1628
1922
  status?: string;
1629
- }) => Promise<PayloadFindResponse<Order>>;
1923
+ }) => Promise<PayloadFindResponse<PublicOrder>>;
1630
1924
  };
1631
1925
  readonly discounts: {
1632
1926
  validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
@@ -1637,6 +1931,85 @@ declare class CommerceClient {
1637
1931
  constructor(options: CommerceClientOptions);
1638
1932
  }
1639
1933
 
1934
+ type StorefrontContentReference = {
1935
+ id?: string | number | null;
1936
+ title?: string | null;
1937
+ name?: string | null;
1938
+ slug?: string | null;
1939
+ displayName?: string | null;
1940
+ handle?: string | null;
1941
+ color?: string | null;
1942
+ image?: PublicMediaAsset | null;
1943
+ thumbnail?: PublicMediaAsset | null;
1944
+ avatar?: PublicMediaAsset | null;
1945
+ };
1946
+ type StorefrontLink = {
1947
+ id?: string | number | null;
1948
+ title?: string | null;
1949
+ subtitle?: string | null;
1950
+ url?: string | null;
1951
+ description?: string | null;
1952
+ slug?: string | null;
1953
+ type?: 'external' | 'social' | 'internal' | string | null;
1954
+ platform?: string | null;
1955
+ opensInNewTab?: boolean | null;
1956
+ noFollow?: boolean | null;
1957
+ expiresAt?: string | null;
1958
+ isFeatured?: boolean | null;
1959
+ publishedAt?: string | null;
1960
+ createdAt?: string | null;
1961
+ updatedAt?: string | null;
1962
+ categories?: StorefrontContentReference[] | StorefrontContentReference | null;
1963
+ tags?: StorefrontContentReference[] | StorefrontContentReference | null;
1964
+ thumbnail?: PublicMediaAsset | null;
1965
+ icon?: PublicMediaAsset | null;
1966
+ };
1967
+ type StorefrontGalleryItem = {
1968
+ id?: string | number | null;
1969
+ title?: string | null;
1970
+ description?: string | null;
1971
+ content?: unknown;
1972
+ createdAt?: string | null;
1973
+ updatedAt?: string | null;
1974
+ gallery?: StorefrontContentReference | string | null;
1975
+ image?: PublicMediaAsset | null;
1976
+ };
1977
+ type StorefrontLinksSort = 'createdAt' | '-createdAt' | 'updatedAt' | '-updatedAt' | 'publishedAt' | '-publishedAt' | 'title' | '-title' | 'isFeatured' | '-isFeatured';
1978
+ type StorefrontGalleryItemsSort = 'manual' | 'createdAt' | '-createdAt' | 'updatedAt' | '-updatedAt' | 'title' | '-title';
1979
+ type StorefrontContentListOptions<TSort extends string = string> = {
1980
+ page?: number;
1981
+ limit?: number;
1982
+ sort?: TSort;
1983
+ };
1984
+ type StorefrontLinksListOptions = StorefrontContentListOptions<StorefrontLinksSort> & {
1985
+ categoryId?: string;
1986
+ categorySlug?: string;
1987
+ tagId?: string;
1988
+ tagSlug?: string;
1989
+ featured?: boolean;
1990
+ };
1991
+ type StorefrontGalleryItemsListOptions = StorefrontContentListOptions<StorefrontGalleryItemsSort> & ({
1992
+ galleryId: string;
1993
+ gallerySlug?: string;
1994
+ } | {
1995
+ galleryId?: string;
1996
+ gallerySlug: string;
1997
+ });
1998
+ type ContentClientOptions = {
1999
+ publishableKey: string;
2000
+ apiUrl?: string;
2001
+ onRequestId?: (id: string | null) => void;
2002
+ };
2003
+ declare class ContentClient {
2004
+ readonly links: {
2005
+ list: (options?: StorefrontLinksListOptions) => Promise<PayloadFindResponse<StorefrontLink>>;
2006
+ };
2007
+ readonly galleryItems: {
2008
+ list: (options: StorefrontGalleryItemsListOptions) => Promise<PayloadFindResponse<StorefrontGalleryItem>>;
2009
+ };
2010
+ constructor(options: ContentClientOptions);
2011
+ }
2012
+
1640
2013
  interface ServerCommerceClientOptions {
1641
2014
  publishableKey?: string;
1642
2015
  secretKey: string;
@@ -1647,25 +2020,30 @@ declare class ServerCommerceClient {
1647
2020
  readonly product: {
1648
2021
  stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1649
2022
  listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
2023
+ listingPage: {
2024
+ (params?: ProductListingPageCatalogParams): Promise<ProductListingPageResult<ProductListingGroupsCatalogItem>>;
2025
+ (params: ProductListingPageFullParams): Promise<ProductListingPageResult<ProductListingGroupsItem>>;
2026
+ (params: ProductListingPageParams): Promise<ProductListingPageResult<ProductListingGroupsCatalogItem> | ProductListingPageResult<ProductListingGroupsItem>>;
2027
+ };
1650
2028
  detail: (params: ProductDetailParams) => Promise<ProductDetailResult>;
1651
2029
  previewDetail: (params: ProductDetailPreviewParams, options: ProductDetailPreviewOptions) => Promise<ProductDetail | null>;
1652
2030
  upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
1653
2031
  };
1654
2032
  readonly cart: {
1655
- get: (cartId: string) => Promise<Cart>;
1656
- addItem: (params: AddItemParams) => Promise<CartItem>;
1657
- updateItem: (params: UpdateItemParams) => Promise<CartItem>;
2033
+ get: (cartId: string) => Promise<PublicCart>;
2034
+ addItem: (params: AddItemParams) => Promise<PublicCartItem>;
2035
+ updateItem: (params: UpdateItemParams) => Promise<PublicCartItem>;
1658
2036
  removeItem: (params: RemoveItemParams) => Promise<{
1659
2037
  success: boolean;
1660
2038
  }>;
1661
- applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1662
- removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
2039
+ applyDiscount: (params: ApplyDiscountParams) => Promise<PublicCart>;
2040
+ removeDiscount: (params: RemoveDiscountParams) => Promise<PublicCart>;
1663
2041
  clear: (params: ClearCartParams) => Promise<{
1664
2042
  success: boolean;
1665
2043
  }>;
1666
2044
  };
1667
2045
  readonly orders: {
1668
- checkout: (params: CheckoutParams) => Promise<Order>;
2046
+ checkout: (params: CheckoutParams) => Promise<PublicOrder>;
1669
2047
  create: (params: CreateOrderParams) => Promise<Order>;
1670
2048
  update: (params: UpdateOrderParams) => Promise<Order>;
1671
2049
  updateTransaction: (params: UpdateTransactionParams) => Promise<Transaction>;
@@ -2085,6 +2463,20 @@ interface ApiQueryOptions {
2085
2463
  /** Include soft-deleted documents (requires `trash` enabled on the collection) */
2086
2464
  trash?: boolean;
2087
2465
  }
2466
+ type PublicReadQueryOptions = Omit<ApiQueryOptions, 'depth' | 'joins' | 'populate'> & {
2467
+ /**
2468
+ * Publishable collection reads stay unpopulated. Use shaped commerce/community
2469
+ * endpoints or a server client when populated relations are required.
2470
+ */
2471
+ depth?: 0;
2472
+ /**
2473
+ * Publishable collection reads disable Payload join fields to avoid accidental
2474
+ * exposure and expensive generic list responses.
2475
+ */
2476
+ joins?: false;
2477
+ /** Publishable collection reads do not support relationship populate maps. */
2478
+ populate?: never;
2479
+ };
2088
2480
  interface DebugConfig {
2089
2481
  logRequests?: boolean;
2090
2482
  logResponses?: boolean;
@@ -2095,14 +2487,14 @@ interface RetryConfig {
2095
2487
  retryableStatuses?: number[];
2096
2488
  retryDelay?: (attempt: number) => number;
2097
2489
  }
2098
- interface RootQueryLookup<T extends string> {
2099
- find(options?: ApiQueryOptions): Promise<PayloadFindResponse<CollectionType<T>>>;
2100
- findById(id: string | number, options?: ApiQueryOptions): Promise<CollectionType<T>>;
2101
- count(options?: ApiQueryOptions): Promise<{
2490
+ interface RootQueryLookup<T extends string, Options extends ApiQueryOptions = ApiQueryOptions> {
2491
+ find(options?: Options): Promise<PayloadFindResponse<CollectionType<T>>>;
2492
+ findById(id: string | number, options?: Options): Promise<CollectionType<T>>;
2493
+ count(options?: Options): Promise<{
2102
2494
  totalDocs: number;
2103
2495
  }>;
2104
2496
  }
2105
- type RootReadOnlyQueryBuilder<T extends PublicCollection> = RootQueryLookup<T>;
2497
+ type RootReadOnlyQueryBuilder<T extends PublicCollection> = RootQueryLookup<T, PublicReadQueryOptions>;
2106
2498
  interface RootServerQueryBuilder<T extends ServerCollection> extends RootQueryLookup<T> {
2107
2499
  create(data: Partial<CollectionType<T>>, options?: {
2108
2500
  file?: File | Blob;
@@ -2125,6 +2517,7 @@ interface RootServerCollectionClient {
2125
2517
  interface RootClient {
2126
2518
  commerce: CommerceClient;
2127
2519
  community: CommunityClient;
2520
+ content: ContentClient;
2128
2521
  /** Set on {@link createClient} return values; optional for structural mocks. */
2129
2522
  events?: EventsClient;
2130
2523
  customer: CustomerNamespace;
@@ -2162,4 +2555,4 @@ type DeepPartial<T> = {
2162
2555
  };
2163
2556
  type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
2164
2557
 
2165
- export { type TenantFeatureProgressGroup as $, type ApiQueryOptions as A, BaseApi as B, CommerceClient as C, type DebugConfig as D, EventsClient as E, type EventRegistrationRegisterResponse as F, type EventsCalendarItem as G, type EventsClientOptions as H, type EventsDateParam as I, type EventsExternalSource as J, type EventsLocation as K, type EventsOccurrenceLocation as L, type EventsRangeEvent as M, type EventsRangeOccurrence as N, type EventsRangeParams as O, type PayloadFindResponse as P, type EventsRangeResponse as Q, type RetryConfig as R, type Sort as S, type TenantIntrospectionClient as T, type UnbanCustomerParams as U, type EventsTaxonomyItem as V, type Where as W, ModerationApi as X, type RootServerClient as Y, type TenantFeatureProgressEvidenceValue as Z, type TenantFeatureProgressFeature as _, CommunityClient as a, type ListingGroupsParams as a$, type TenantFeatureProgressInput as a0, type TenantFeatureProgressItem as a1, type TenantFeatureProgressItemState as a2, type TenantFeatureProgressResponse as a3, type TenantFeatureProgressSeverity as a4, type TenantFeatureProgressStatus as a5, TenantIntrospectionApi as a6, type TenantIntrospectionApiOptions as a7, CustomerAuth as a8, type CustomerProfile as a9, type CancelOrderResponse as aA, type CancelReasonCode as aB, CartApi as aC, type CartApiOptions as aD, type CheckoutParams as aE, type ClearCartParams as aF, type Comment as aG, type CommerceClientOptions as aH, type CommunityClientOptions as aI, type CommunityComment as aJ, type CommunityCommentListSort as aK, type CommunityPost as aL, type CommunityPostCategory as aM, type CommunityPostListSort as aN, type CommunityPostTag as aO, type CompatibilityProductSelectionParamEvent as aP, type ConfirmPaymentParams as aQ, type ConfirmPaymentResponse as aR, type CreateFulfillmentParams as aS, type CreateOrderItem as aT, type CreateOrderParams as aU, type CreateReturnParams as aV, type CustomerAuthOptions as aW, type CustomerSnapshot as aX, DiscountApi as aY, type DiscountApiOptions as aZ, type LegacyProductSelectionParamEvent as a_, type CustomerAuthResponse as aa, type CustomerLoginData as ab, type CustomerRegisterResponse as ac, type CustomerRegisterData as ad, type CustomerRefreshResponse as ae, type UpdateProfileData as af, type ProductDetailParams as ag, type ProductDetailResult as ah, type ProductListingGroupsItem as ai, type ProductDetail as aj, type ProductDetailCatalog as ak, type StockSnapshotResponse as al, type ProductSelectionMediaSource as am, type ProductDisplayMediaSource as an, type ResolveProductSelectionMediaInput as ao, type ResolveProductSelectionMediaResult as ap, type ProductSelectionMediaPointer as aq, type RootClientWithEvents as ar, type AddItemParams as as, type ApplyDiscountParams as at, type BulkImportFulfillmentsParams as au, type BulkImportFulfillmentsResponse as av, type CalculateShippingParams as aw, type CalculateShippingResult as ax, type CancelOrderParams as ay, type CancelOrderReconciliationStatus as az, CustomerNamespace as b, type ProductSelectionVariant as b$, type ListingPrimaryImageFallbackInput as b0, type MediaValue as b1, type NormalizedOptionSwatch as b2, type NormalizedProductSelection as b3, OrderApi as b4, type OrderApiOptions as b5, PRODUCT_PLP_FIND_OPTIONS as b6, PRODUCT_UPSERT_READONLY_FIELD_REASON as b7, PRODUCT_UPSERT_UNKNOWN_FIELD_REASON as b8, type PrepareFulfillmentOrderParams as b9, type ProductListingGroup as bA, type ProductListingGroupSummary as bB, type ProductListingGroupVariant as bC, type ProductListingGroupsProduct as bD, type ProductListingGroupsResponse as bE, type ProductListingProductShape as bF, type ProductListingProjection as bG, type ProductListingSwatch as bH, type ProductMediaResolutionSource as bI, type ProductOptionMatrix as bJ, type ProductOptionMatrixOption as bK, type ProductOptionMatrixValue as bL, type ProductOptionMatrixVariant as bM, type ProductOptionShape as bN, type ProductOptionValueShape as bO, type ProductOptionValueSwatch as bP, type ProductOptionValueSwatchInput as bQ, type ProductSelectionAvailableSwatch as bR, type ProductSelectionAvailableValue as bS, type ProductSelectionByOptionValue as bT, ProductSelectionCodecError as bU, type ProductSelectionCodecOptions as bV, type ProductSelectionInput as bW, type ProductSelectionOptionValue as bX, type ProductSelectionResolution as bY, type ProductSelectionResolutionContext as bZ, type ProductSelectionUrlEmit as b_, type PrepareFulfillmentOrderResponse as ba, ProductApi as bb, type ProductApiOptions as bc, type ProductDetailBrand as bd, type ProductDetailCatalogListing as be, type ProductDetailCatalogResult as bf, type ProductDetailCatalogVariant as bg, type ProductDetailCategory as bh, type ProductDetailImage as bi, type ProductDetailImageMedia as bj, type ProductDetailListing as bk, type ProductDetailMedia as bl, type ProductDetailOption as bm, type ProductDetailOptionValue as bn, type ProductDetailTag as bo, type ProductDetailUnavailableReason as bp, type ProductDetailVariant as bq, type ProductDetailVariantOptionValue as br, type ProductDetailVideo as bs, type ProductHrefGroup as bt, type ProductHrefOptions as bu, type ProductHrefProduct as bv, type ProductListingCard as bw, type ProductListingCardOptions as bx, type ProductListingCardPriceRange as by, type ProductListingCardRepresentativeVariant as bz, type ClientState as c, type ProductUpsertFieldValidationErrorBody as c0, type ProductUpsertFieldValidationErrorReason as c1, type ProductVariantShape as c2, type RemoveDiscountParams as c3, type RemoveItemParams as c4, type RequestOptions as c5, type ResolveCancelRefundFailedResponse as c6, type ResolveCancelRefundOutcome as c7, type ResolveCancelRefundParams as c8, type ResolveCancelRefundResponse as c9, buildProductOptionMatrix as cA, buildProductOptionMatrixFromDetail as cB, createProductSelectionCodec as cC, getAvailableOptionValues as cD, getProductSelectionImages as cE, getSelectedValueByOptionId as cF, isProductUpsertFieldValidationErrorBody as cG, normalizeProductSelection as cH, normalizeProductSelectionFromMatrix as cI, normalizeSelectedValueIds as cJ, parseProductSelection as cK, resolveListingPrimaryImagePointer as cL, resolveProductDisplayMedia as cM, resolveProductSelection as cN, resolveProductSelectionFromMatrix as cO, resolveProductSelectionMedia as cP, resolveVariantForSelection as cQ, selectNext as cR, selectedSwatchMediaItemId as cS, stringifyProductSelection as cT, toShopifyPriceRangeV2 as cU, type ResolveCancelRefundSucceededResponse as ca, type ResolveProductDisplayMediaInput as cb, type ResolveProductDisplayMediaResult as cc, type ReturnItem as cd, type ReturnReason as ce, type ReturnWithRefundItem as cf, type ReturnWithRefundParams as cg, ShippingApi as ch, type ShippingApiOptions as ci, type StockCheckParams as cj, type StockCheckResponse as ck, type StockCheckResult as cl, type StockSnapshotItem as cm, type StockSnapshotParams as cn, type UpdateFulfillmentParams as co, type UpdateItemParams as cp, type UpdateOrderParams as cq, type UpdateReturnParams as cr, type UpdateTransactionParams as cs, type ValidateDiscountParams as ct, type ValidateDiscountResult as cu, type WithIdempotencyKey as cv, buildProductHref as cw, buildProductListingCard as cx, buildProductListingGroupsByOption as cy, buildProductListingProjection as cz, type ClientConfig as d, type ClientMetadata as e, type DeepPartial as f, type ExtractArrayType as g, type PayloadMutationResponse as h, type RootClient as i, type RootCollectionClient as j, type RootReadOnlyQueryBuilder as k, type ServerApiOptions as l, ServerCommerceClient as m, type BanCustomerParams as n, type CommunityBan as o, type ClientServerConfig as p, type RootServerClientWithEvents as q, type CollectionFieldSchema as r, type CollectionSchemaResponse as s, type EventGuestCancelParams as t, type EventGuestRegistration as u, type EventGuestRegistrationResponse as v, type EventRegistrationAnswerInput as w, type EventRegistrationAttendeeInput as x, type EventRegistrationPublic as y, type EventRegistrationRegisterParams as z };
2558
+ export { type CollectionFieldSchema as $, type AddItemParams as A, type RootReadOnlyQueryBuilder as B, CommerceClient as C, type DebugConfig as D, EventsClient as E, type StorefrontContentListOptions as F, type StorefrontContentReference as G, type StorefrontGalleryItem as H, type StorefrontGalleryItemsListOptions as I, type StorefrontGalleryItemsSort as J, type StorefrontLink as K, type StorefrontLinksListOptions as L, type StorefrontLinksSort as M, BaseApi as N, type ServerApiOptions as O, type PayloadFindResponse as P, ServerCommerceClient as Q, type RemoveDiscountParams as R, type Sort as S, type TenantIntrospectionClient as T, type UpdateItemParams as U, type BanCustomerParams as V, type Where as W, type CommunityBan as X, type UnbanCustomerParams as Y, type ClientServerConfig as Z, type RootServerClientWithEvents as _, CommunityClient as a, type CalculateShippingResult as a$, type CollectionSchemaResponse as a0, type EventGuestCancelParams as a1, type EventGuestRegistration as a2, type EventGuestRegistrationResponse as a3, type EventRegistrationAnswerInput as a4, type EventRegistrationAttendeeInput as a5, type EventRegistrationPublic as a6, type EventRegistrationRegisterParams as a7, type EventRegistrationRegisterResponse as a8, type EventsCalendarItem as a9, type CustomerAuthResponse as aA, type CustomerLoginData as aB, type CustomerRegisterResponse as aC, type CustomerRegisterData as aD, type CustomerRefreshResponse as aE, type UpdateProfileData as aF, type ProductListingPageBaseParams as aG, type ProductListingPageParams as aH, type ProductDetailParams as aI, type ProductDetailResult as aJ, type ProductListingPageCatalogParams as aK, type ProductListingPageResult as aL, type ProductListingGroupsCatalogItem as aM, type ProductListingPageFullParams as aN, type ProductListingGroupsItem as aO, type ProductDetail as aP, type ProductDetailCatalog as aQ, type StockSnapshotResponse as aR, type ProductSelectionMediaSource as aS, type ProductDisplayMediaSource as aT, type ResolveProductSelectionMediaInput as aU, type ResolveProductSelectionMediaResult as aV, type ProductSelectionMediaPointer as aW, type RootClientWithEvents as aX, type BulkImportFulfillmentsParams as aY, type BulkImportFulfillmentsResponse as aZ, type CalculateShippingParams as a_, type EventsClientOptions as aa, type EventsDateParam as ab, type EventsExternalSource as ac, type EventsLocation as ad, type EventsOccurrenceLocation as ae, type EventsRangeEvent as af, type EventsRangeOccurrence as ag, type EventsRangeParams as ah, type EventsRangeResponse as ai, type EventsTaxonomyItem as aj, ModerationApi as ak, type RootServerClient as al, type TenantFeatureProgressEvidenceValue as am, type TenantFeatureProgressFeature as an, type TenantFeatureProgressGroup as ao, type TenantFeatureProgressInput as ap, type TenantFeatureProgressItem as aq, type TenantFeatureProgressItemState as ar, type TenantFeatureProgressResponse as as, type TenantFeatureProgressSeverity as at, type TenantFeatureProgressStatus as au, TenantIntrospectionApi as av, type TenantIntrospectionApiOptions as aw, type PublicReadQueryOptions as ax, CustomerAuth as ay, type CustomerProfile as az, ContentClient as b, type ProductListingCard as b$, type CancelOrderParams as b0, type CancelOrderReconciliationStatus as b1, type CancelOrderResponse as b2, type CancelReasonCode as b3, CartApi as b4, type CartApiOptions as b5, type Comment as b6, type CommerceClientOptions as b7, type CommunityClientOptions as b8, type CommunityComment as b9, type OrderApiOptions as bA, PRODUCT_PLP_FIND_OPTIONS as bB, PRODUCT_UPSERT_READONLY_FIELD_REASON as bC, PRODUCT_UPSERT_UNKNOWN_FIELD_REASON as bD, type PrepareFulfillmentOrderParams as bE, type PrepareFulfillmentOrderResponse as bF, ProductApi as bG, type ProductApiOptions as bH, type ProductDetailBrand as bI, type ProductDetailCatalogListing as bJ, type ProductDetailCatalogResult as bK, type ProductDetailCatalogVariant as bL, type ProductDetailCategory as bM, type ProductDetailImage as bN, type ProductDetailImageMedia as bO, type ProductDetailListing as bP, type ProductDetailMedia as bQ, type ProductDetailOption as bR, type ProductDetailOptionValue as bS, type ProductDetailTag as bT, type ProductDetailUnavailableReason as bU, type ProductDetailVariant as bV, type ProductDetailVariantOptionValue as bW, type ProductDetailVideo as bX, type ProductHrefGroup as bY, type ProductHrefOptions as bZ, type ProductHrefProduct as b_, type CommunityCommentListSort as ba, type CommunityPost as bb, type CommunityPostCategory as bc, type CommunityPostListSort as bd, type CommunityPostTag as be, type CommunityPublicAuthorSnapshot as bf, type CommunityPublicMediaAsset as bg, type CommunityPublicReference as bh, type CompatibilityProductSelectionParamEvent as bi, type ConfirmPaymentParams as bj, type ConfirmPaymentResponse as bk, type CreateFulfillmentParams as bl, type CreateOrderItem as bm, type CreateOrderParams as bn, type CreateReturnParams as bo, type CustomerAuthOptions as bp, type CustomerSnapshot as bq, DiscountApi as br, type DiscountApiOptions as bs, type LegacyProductSelectionParamEvent as bt, type ListingGroupsParams as bu, type ListingPrimaryImageFallbackInput as bv, type MediaValue as bw, type NormalizedOptionSwatch as bx, type NormalizedProductSelection as by, OrderApi as bz, CustomerNamespace as c, type UpdateTransactionParams as c$, type ProductListingCardOptions as c0, type ProductListingCardPriceRange as c1, type ProductListingCardRepresentativeVariant as c2, type ProductListingGroup as c3, type ProductListingGroupCatalogSummary as c4, type ProductListingGroupCatalogVariant as c5, type ProductListingGroupSummary as c6, type ProductListingGroupVariant as c7, type ProductListingGroupsCatalogListing as c8, type ProductListingGroupsCatalogProduct as c9, type ProductSelectionUrlEmit as cA, type ProductSelectionVariant as cB, type ProductUpsertFieldValidationErrorBody as cC, type ProductUpsertFieldValidationErrorReason as cD, type ProductVariantShape as cE, type RequestOptions as cF, type ResolveCancelRefundFailedResponse as cG, type ResolveCancelRefundOutcome as cH, type ResolveCancelRefundParams as cI, type ResolveCancelRefundResponse as cJ, type ResolveCancelRefundSucceededResponse as cK, type ResolveProductDisplayMediaInput as cL, type ResolveProductDisplayMediaResult as cM, type ReturnItem as cN, type ReturnReason as cO, type ReturnWithRefundItem as cP, type ReturnWithRefundParams as cQ, ShippingApi as cR, type ShippingApiOptions as cS, type StockCheckParams as cT, type StockCheckResponse as cU, type StockCheckResult as cV, type StockSnapshotItem as cW, type StockSnapshotParams as cX, type UpdateFulfillmentParams as cY, type UpdateOrderParams as cZ, type UpdateReturnParams as c_, type ProductListingGroupsCatalogResponse as ca, type ProductListingGroupsProduct as cb, type ProductListingGroupsResponse as cc, type ProductListingPageFilters as cd, type ProductListingPageSort as ce, type ProductListingProductShape as cf, type ProductListingProjection as cg, type ProductListingSwatch as ch, type ProductMediaResolutionSource as ci, type ProductOptionMatrix as cj, type ProductOptionMatrixOption as ck, type ProductOptionMatrixValue as cl, type ProductOptionMatrixVariant as cm, type ProductOptionShape as cn, type ProductOptionValueShape as co, type ProductOptionValueSwatch as cp, type ProductOptionValueSwatchInput as cq, type ProductSelectionAvailableSwatch as cr, type ProductSelectionAvailableValue as cs, type ProductSelectionByOptionValue as ct, ProductSelectionCodecError as cu, type ProductSelectionCodecOptions as cv, type ProductSelectionInput as cw, type ProductSelectionOptionValue as cx, type ProductSelectionResolution as cy, type ProductSelectionResolutionContext as cz, type ClientState as d, type ValidateDiscountParams as d0, type ValidateDiscountResult as d1, type WithIdempotencyKey as d2, buildProductHref as d3, buildProductListingCard as d4, buildProductListingGroupsByOption as d5, buildProductListingProjection as d6, buildProductOptionMatrix as d7, buildProductOptionMatrixFromDetail as d8, createProductSelectionCodec as d9, getAvailableOptionValues as da, getProductSelectionImages as db, getSelectedValueByOptionId as dc, isProductUpsertFieldValidationErrorBody as dd, normalizeProductSelection as de, normalizeProductSelectionFromMatrix as df, normalizeSelectedValueIds as dg, parseProductSelection as dh, resolveListingPrimaryImagePointer as di, resolveProductDisplayMedia as dj, resolveProductSelection as dk, resolveProductSelectionFromMatrix as dl, resolveProductSelectionMedia as dm, resolveVariantForSelection as dn, selectNext as dp, selectedSwatchMediaItemId as dq, stringifyProductSelection as dr, toShopifyPriceRangeV2 as ds, type ClientConfig as e, type ApiQueryOptions as f, type ApplyDiscountParams as g, type CheckoutParams as h, type ClearCartParams as i, type ClientMetadata as j, type ContentClientOptions as k, type DeepPartial as l, type ExtractArrayType as m, type PayloadMutationResponse as n, type PublicCart as o, type PublicCartItem as p, type PublicCartReference as q, type PublicMediaAsset as r, type PublicMediaSize as s, type PublicOrder as t, type PublicOrderItem as u, type PublicOrderReference as v, type RemoveItemParams as w, type RetryConfig as x, type RootClient as y, type RootCollectionClient as z };