@01.software/sdk 0.37.0 → 0.38.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 (48) hide show
  1. package/README.md +75 -53
  2. package/dist/client.cjs +67 -104
  3. package/dist/client.cjs.map +1 -1
  4. package/dist/client.d.cts +6 -6
  5. package/dist/client.d.ts +6 -6
  6. package/dist/client.js +67 -104
  7. package/dist/client.js.map +1 -1
  8. package/dist/{collection-client-zOmnxwdA.d.cts → collection-client-B0J9wMNE.d.cts} +5 -5
  9. package/dist/{collection-client-DyELGUcL.d.ts → collection-client-BroIWHY1.d.ts} +5 -5
  10. package/dist/const-6XHz_jej.d.ts +32 -0
  11. package/dist/const-B5KT72c7.d.cts +32 -0
  12. package/dist/{index-DRJs7QIh.d.cts → index-BOLQxveo.d.cts} +3 -3
  13. package/dist/{index-DTqoUZk_.d.ts → index-CSwR2HSg.d.ts} +3 -3
  14. package/dist/index.cjs +95 -123
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +9 -9
  17. package/dist/index.d.ts +9 -9
  18. package/dist/index.js +95 -123
  19. package/dist/index.js.map +1 -1
  20. package/dist/{payload-types-CREOjFNT.d.cts → payload-types-m3jjhxk9.d.cts} +418 -106
  21. package/dist/{payload-types-CREOjFNT.d.ts → payload-types-m3jjhxk9.d.ts} +418 -106
  22. package/dist/query.cjs +3 -1035
  23. package/dist/query.cjs.map +1 -1
  24. package/dist/query.d.cts +13 -13
  25. package/dist/query.d.ts +13 -13
  26. package/dist/query.js +3 -1035
  27. package/dist/query.js.map +1 -1
  28. package/dist/realtime.d.cts +2 -2
  29. package/dist/realtime.d.ts +2 -2
  30. package/dist/server.cjs +42 -21
  31. package/dist/server.cjs.map +1 -1
  32. package/dist/server.d.cts +7 -7
  33. package/dist/server.d.ts +7 -7
  34. package/dist/server.js +42 -21
  35. package/dist/server.js.map +1 -1
  36. package/dist/{types-DMvVHdb1.d.ts → types-CIGscmus.d.cts} +1455 -1208
  37. package/dist/{types-CxzWHspI.d.ts → types-Cmrd1ezc.d.ts} +1 -15
  38. package/dist/{types-BkZNhuBh.d.cts → types-D0ubzQw0.d.cts} +1 -15
  39. package/dist/{types-BWMUr3Zw.d.cts → types-D2xYdz4P.d.ts} +1455 -1208
  40. package/dist/ui/form.d.cts +1 -1
  41. package/dist/ui/form.d.ts +1 -1
  42. package/dist/ui/video.d.cts +1 -1
  43. package/dist/ui/video.d.ts +1 -1
  44. package/dist/webhook.d.cts +4 -4
  45. package/dist/webhook.d.ts +4 -4
  46. package/package.json +3 -3
  47. package/dist/const-CK_FPaIn.d.cts +0 -32
  48. 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,1471 @@ 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;
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;
986
1030
  };
987
- type ListingGroupsParams = {
988
- productIds: string[];
1031
+ type ProductSelectionOptionValue = {
1032
+ id?: string | number | null;
1033
+ swatch?: NormalizedOptionSwatch<unknown> | null;
989
1034
  };
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 | {
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;
1130
1168
  };
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;
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;
1188
+ };
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 ProductListingCardRepresentativeVariant = ProductListingGroupsItem['groups'][number]['variants'][number];
1198
+ type ProductListingCard = {
1199
+ id: EntityID;
1200
+ href: string;
1201
+ title: string;
1202
+ representativeVariant?: ProductListingCardRepresentativeVariant | null;
1203
+ primaryImage: ProductDetailMedia | null;
1204
+ priceRange: ProductListingCardPriceRange;
1205
+ availableForSale: boolean;
1206
+ swatches: ProductListingSwatch[];
1190
1207
  };
1191
- type ProductDetailCatalogResult = {
1192
- found: true;
1193
- product: ProductDetailCatalog;
1194
- } | {
1195
- found: false;
1196
- reason: ProductDetailUnavailableReason;
1208
+ type ProductSelectionByOptionValue = string | number | null | undefined | {
1209
+ valueId?: string | number | null;
1210
+ valueSlug?: string | null;
1197
1211
  };
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;
1212
+ type ProductSelectionInput = {
1213
+ variantId?: string | number | null;
1214
+ byOptionSlug?: Record<string, ProductSelectionByOptionValue>;
1215
+ byOptionId?: Record<string, ProductSelectionByOptionValue>;
1216
+ valueIds?: Iterable<unknown>;
1217
+ search?: string | URLSearchParams | URL | null;
1209
1218
  };
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;
1219
+ type NormalizedProductSelection = {
1220
+ byOptionSlug: Record<string, string>;
1221
+ byOptionId: Record<string, string>;
1222
+ valueIds: string[];
1223
+ variantId: string | null;
1220
1224
  };
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>;
1225
+ type CompatibilityProductSelectionParamEvent = {
1226
+ optionId: string;
1227
+ optionSlug: string;
1228
+ valueSlug: string;
1229
+ searchParam: string;
1230
+ };
1231
+ type LegacyProductSelectionParamEvent = CompatibilityProductSelectionParamEvent;
1232
+ type ProductSelectionUrlEmit = 'slug-compat' | 'canonical-id';
1233
+ type ProductSelectionCodecOptions = {
1234
+ emit?: ProductSelectionUrlEmit;
1244
1235
  /**
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.
1236
+ * When true, `resolveProductSelection()` fills unselected options to reach a
1237
+ * concrete variant. Does not change codec parse/stringify behavior.
1249
1238
  */
1250
- upsert(params: ProductUpsertParams): Promise<ProductUpsertResponse>;
1251
- }
1252
-
1253
- type DiscountApiOptions = ServerApiOptions;
1254
- type ValidateDiscountParams = {
1239
+ fillDefaults?: boolean;
1240
+ onCompatibilityOptionIdParam?: (event: CompatibilityProductSelectionParamEvent) => void;
1241
+ onLegacyOptionIdParam?: (event: LegacyProductSelectionParamEvent) => void;
1242
+ };
1243
+ type ProductSelectionResolutionContext = {
1244
+ detail?: Pick<ProductDetail, 'images' | 'listing' | 'primaryMediaItemId'>;
1245
+ images?: ProductDetail['images'];
1246
+ listing?: ProductDetail['listing'];
1247
+ primaryMediaItemId?: ProductDetail['primaryMediaItemId'];
1248
+ };
1249
+ type ProductSelectionAvailableSwatch = {
1250
+ color?: string | null;
1251
+ image?: MediaValue | null;
1252
+ };
1253
+ type ProductSelectionAvailableValue = {
1254
+ valueId: string;
1255
+ value: string;
1256
+ label: string;
1257
+ slug: string;
1258
+ selected: boolean;
1259
+ available: boolean;
1260
+ exists: boolean;
1261
+ availableForSale: boolean;
1262
+ isUnlimited: boolean;
1263
+ availableStock: number | null;
1264
+ swatch: ProductOptionValueSwatch;
1265
+ };
1266
+ type ProductSelectionResolution = {
1267
+ normalizedSelection: NormalizedProductSelection;
1268
+ selectedVariant: ProductDetailVariant | null;
1269
+ matchingVariants: ProductDetailVariant[];
1270
+ partialVariants: ProductDetailVariant[];
1271
+ availableValuesByOptionSlug: Record<string, ProductSelectionAvailableValue[]>;
1272
+ availableValuesByOptionId: Record<string, ProductSelectionAvailableValue[]>;
1273
+ allOptionsSelected: boolean;
1274
+ price: {
1275
+ min: number | null;
1276
+ max: number | null;
1277
+ compareAtMin: number | null;
1278
+ compareAtMax: number | null;
1279
+ isRange: boolean;
1280
+ };
1281
+ media: {
1282
+ primaryImage: ProductDetailMedia | null;
1283
+ images: ProductDetailMedia[];
1284
+ source?: ProductMediaResolutionSource;
1285
+ };
1286
+ stock: {
1287
+ availableForSale: boolean;
1288
+ isUnlimited: boolean;
1289
+ stock: number | null;
1290
+ reservedStock: number | null;
1291
+ availableStock: number | null;
1292
+ };
1293
+ };
1294
+ declare class ProductSelectionCodecError extends Error {
1255
1295
  code: string;
1256
- orderAmount: number;
1296
+ constructor(message: string);
1297
+ }
1298
+ declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
1299
+ options: ProductOptionShape[];
1300
+ variants?: TVariant[];
1301
+ }): ProductOptionMatrix<TVariant>;
1302
+ declare function buildProductOptionMatrixFromDetail(detail: ProductDetail): ProductOptionMatrix<ProductDetailVariant>;
1303
+ declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
1304
+ declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
1305
+ declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
1306
+ declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
1307
+ declare function normalizeProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1308
+ declare function normalizeProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1309
+ declare function parseProductSelection(detail: ProductDetail, search: string | URLSearchParams | URL | null | undefined, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1310
+ declare function stringifyProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): string;
1311
+ declare function createProductSelectionCodec(detail: ProductDetail, options?: ProductSelectionCodecOptions): {
1312
+ parse: (search: string | URLSearchParams | URL | null | undefined) => NormalizedProductSelection;
1313
+ stringify: (selection?: ProductSelectionInput) => string;
1257
1314
  };
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;
1315
+ declare function resolveProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions, context?: ProductSelectionResolutionContext): ProductSelectionResolution;
1316
+ declare function resolveProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): ProductSelectionResolution;
1317
+ declare function selectNext(detail: ProductDetail, current: ProductSelectionInput | undefined, optionSlug: string, valueSlug: string, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
1318
+ type ProductDetailImageMedia = Extract<ProductDetailMedia, {
1319
+ id?: string | number | null;
1320
+ url?: string | null;
1321
+ }>;
1322
+ declare function getProductSelectionImages(resolution: Pick<ProductSelectionResolution, 'media'>): ProductDetailImageMedia[];
1323
+ type ProductHrefProduct = ProductDetail | {
1324
+ slug?: string | null;
1325
+ product?: {
1326
+ slug?: string | null;
1327
+ } | null;
1265
1328
  };
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;
1329
+ type ProductHrefGroup = {
1330
+ optionId?: string | number | null;
1331
+ optionSlug?: string | null;
1332
+ optionValueId?: string | number | null;
1333
+ optionValueSlug?: string | null;
1334
+ variantId?: string | number | null;
1335
+ listing?: {
1336
+ selectionHintVariant?: string | number | null;
1337
+ } | null;
1276
1338
  };
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;
1339
+ type ProductHrefOptions = {
1340
+ basePath?: string;
1341
+ detail?: ProductDetail;
1342
+ matrix?: ProductOptionMatrix<ProductDetailVariant>;
1343
+ selection?: ProductSelectionInput;
1344
+ trailingSlash?: boolean;
1345
+ emit?: ProductSelectionUrlEmit;
1346
+ preferCompleteVariantFromHint?: boolean;
1285
1347
  };
1286
- declare class ShippingApi extends BaseApi {
1287
- constructor(options: ShippingApiOptions);
1288
- calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
1289
- }
1348
+ type ProductListingCardOptions = {
1349
+ basePath?: string;
1350
+ trailingSlash?: boolean;
1351
+ emit?: ProductSelectionUrlEmit;
1352
+ preferCompleteVariantFromHint?: boolean;
1353
+ };
1354
+ declare function buildProductHref(product: ProductHrefProduct, group?: ProductHrefGroup | null, options?: ProductHrefOptions): string;
1355
+ declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
1356
+ declare function buildProductListingCard(item: ProductListingGroupsItem, options?: ProductListingCardOptions): ProductListingCard;
1357
+ /** Shopify `priceRangeV2` naming for persisted listing projection fields. */
1358
+ declare function toShopifyPriceRangeV2(listing: {
1359
+ minPrice?: number | null;
1360
+ maxPrice?: number | null;
1361
+ }): {
1362
+ minVariantPrice: {
1363
+ amount: number | null;
1364
+ };
1365
+ maxVariantPrice: {
1366
+ amount: number | null;
1367
+ };
1368
+ };
1369
+ /**
1370
+ * PLP-safe query preset for the `products` collection.
1371
+ *
1372
+ * Payload's top-level `type: 'join'` fields on `products` (`variants`,
1373
+ * `options`) return at most 10 docs by default when queried via the REST API.
1374
+ * Storefront PLPs calling `client.collections.from('products').find()` without
1375
+ * explicit join limits silently receive truncated variant/option join data.
1376
+ * `buildProductListingGroupsByOption()` then drops primary-option values with
1377
+ * no matching variant in the response — a common cause of missing color swatches
1378
+ * even when the product has more variants than the default join cap.
1379
+ *
1380
+ * Spread this constant into your `find()` call to raise both top-level limits:
1381
+ *
1382
+ * ```typescript
1383
+ * const { docs } = await client.collections.from('products').find({
1384
+ * ...PRODUCT_PLP_FIND_OPTIONS,
1385
+ * where: { status: { equals: 'published' } },
1386
+ * limit: 24,
1387
+ * })
1388
+ * ```
1389
+ *
1390
+ * **Limitation:** This preset cures top-level `products.options` and
1391
+ * `products.variants` join truncation. It cannot cure the nested
1392
+ * `options[].values.docs` join — the Payload REST `joins` param is flat and
1393
+ * nested join limits require the listing-groups endpoint. Prefer
1394
+ * `commerce.product.listingGroupsCatalog()` + `buildProductListingCard()` as
1395
+ * the primary PLP path; they apply unlimited join fetches server-side and
1396
+ * return pre-grouped data ready for rendering.
1397
+ */
1398
+ declare const PRODUCT_PLP_FIND_OPTIONS: ApiQueryOptions;
1399
+ /**
1400
+ * Builds product-first listing groups for one primary option.
1401
+ *
1402
+ * The returned groups are intended for product cards with nested swatches or
1403
+ * option-value sections. They do not make a product-paginated API response into
1404
+ * an expanded-card paginator; one product can still emit several groups.
1405
+ */
1406
+ declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
1407
+ product: ProductListingProductShape | null | undefined;
1408
+ options: ProductOptionShape[];
1409
+ variants: TVariant[];
1410
+ primaryOptionId?: string | null;
1411
+ }): ProductListingGroup<TVariant>[];
1290
1412
 
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;
1413
+ type ProductUpsertColorSwatchInput = {
1414
+ type: 'color';
1415
+ color: string;
1416
+ mediaItemId?: null;
1299
1417
  };
1300
- type CustomerSnapshot = {
1301
- name?: string;
1302
- email: string;
1303
- phone?: string;
1418
+ type ProductUpsertMediaSwatchInput = {
1419
+ type: 'media';
1420
+ mediaItemId: string;
1421
+ color?: null;
1304
1422
  };
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;
1423
+ type ProductUpsertSwatchInput = ProductUpsertColorSwatchInput | ProductUpsertMediaSwatchInput;
1424
+ type ProductUpsertOptionValueInput = {
1425
+ id?: string;
1426
+ value: string;
1427
+ slug?: string;
1428
+ swatch?: ProductUpsertSwatchInput | null;
1429
+ metadata?: unknown;
1311
1430
  };
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;
1431
+ type OptionValueInput = ProductUpsertOptionValueInput;
1432
+ type OptionInput = {
1433
+ id?: string;
1434
+ title: string;
1435
+ slug?: string;
1436
+ values: OptionValueInput[];
1328
1437
  };
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;
1438
+ type VariantInput = {
1439
+ id?: string;
1440
+ optionValues?: Record<string, string | {
1441
+ valueSlug?: string;
1442
+ valueId?: string;
1443
+ value?: string;
1444
+ }> | string[];
1445
+ sku?: string | null;
1446
+ title?: string | null;
1447
+ price: number;
1448
+ compareAtPrice?: number | null;
1449
+ stock?: number;
1450
+ isUnlimited?: boolean;
1451
+ weight?: number | null;
1452
+ requiresShipping?: boolean;
1453
+ barcode?: string | null;
1454
+ externalId?: string | null;
1455
+ isActive?: boolean;
1456
+ images?: string[];
1457
+ metadata?: unknown;
1342
1458
  };
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;
1459
+ type ProductFieldsInput = {
1460
+ id?: string;
1461
+ title?: string;
1462
+ subtitle?: string | null;
1463
+ description?: string | null;
1464
+ status?: string;
1465
+ slug?: string;
1466
+ primaryMediaItemId?: string | null;
1467
+ thumbnail?: string | null;
1468
+ images?: string[];
1469
+ vendor?: string | null;
1470
+ productType?: string | null;
1471
+ brand?: string | null;
1472
+ shippingPolicy?: string | null;
1473
+ weight?: number | null;
1474
+ minOrderQuantity?: number | null;
1475
+ maxOrderQuantity?: number | null;
1476
+ isFeatured?: boolean;
1477
+ publishedAt?: string | null;
1478
+ categories?: string[];
1479
+ tags?: string[];
1480
+ metadata?: unknown;
1352
1481
  };
1353
- type CreateOrderParams = WithIdempotencyKey<CreateOrderBodyBase & CreateOrderLineItemsInput>;
1354
- type UpdateOrderParams = {
1355
- orderNumber: string;
1356
- status: 'confirmed';
1482
+ type ProductUpsertGraphFields = {
1483
+ /** Required when updating an existing product graph if the server graph is non-empty. */
1484
+ graphRevision?: string;
1485
+ options?: OptionInput[];
1486
+ variants?: VariantInput[];
1487
+ };
1488
+ /** Create a product document and initial graph. */
1489
+ type ProductUpsertCreateInput = ProductUpsertGraphFields & {
1490
+ productId?: never;
1491
+ product: ProductFieldsInput & {
1492
+ title: string;
1493
+ };
1357
1494
  };
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;
1495
+ /** Graph-only update for an existing product (document fields via Payload save). */
1496
+ type ProductUpsertEditInput = ProductUpsertGraphFields & {
1497
+ productId: string;
1498
+ product?: never;
1366
1499
  };
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;
1500
+ type ProductUpsertInput = ProductUpsertCreateInput | ProductUpsertEditInput;
1501
+
1502
+ type ProductApiOptions = ServerApiOptions;
1503
+ type StockCheckParams = {
1504
+ items: Array<{
1505
+ variantId: string;
1506
+ quantity: number;
1507
+ }>;
1388
1508
  };
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;
1509
+ type StockCheckResult = {
1510
+ variantId: string;
1511
+ status: 'available' | 'not_published' | 'archived' | 'not_found';
1512
+ available: boolean;
1513
+ availableStock: number;
1514
+ isUnlimited: boolean;
1515
+ requestedQuantity: number;
1516
+ error?: string;
1394
1517
  };
1395
- type CancelOrderUnpaidCommittedResponseFields = {
1396
- refundedAmount: 0;
1397
- providerRefunded: false;
1518
+ type StockCheckResponse = {
1519
+ results: StockCheckResult[];
1520
+ allAvailable: boolean;
1398
1521
  };
1399
- type CancelOrderPaidCommittedResponseFields = {
1400
- transactionId: string;
1401
- refundedAmount: 0;
1402
- providerRefunded: false;
1403
- refundPending: true;
1522
+ type ListingGroupsParams = {
1523
+ productIds: string[];
1404
1524
  };
1405
- type CancelOrderLegacyProviderRefundResponseFields = {
1406
- transactionId: string;
1407
- refundedAmount: number;
1408
- refundSeq: number;
1409
- providerRefunded: true;
1525
+ type ProductListingGroupVariant = Pick<ProductVariantShape, 'id' | 'optionValues' | 'price' | 'compareAtPrice' | 'stock' | 'isUnlimited' | 'isActive' | 'thumbnail' | 'images' | '_order'>;
1526
+ type ProductListingGroupSummary = ProductListingGroup<ProductListingGroupVariant>;
1527
+ type ProductListingGroupCatalogVariant = Omit<ProductListingGroupVariant, 'stock'>;
1528
+ type ProductListingGroupCatalogSummary = ProductListingGroup<ProductListingGroupCatalogVariant>;
1529
+ type ProductListingGroupsProductVariants = NonNullable<PublicProduct['variants']>;
1530
+ type ProductListingGroupsProductPrimaryMediaItemId = string | number | {
1531
+ id?: string | number | null;
1532
+ } | null;
1533
+ type ProductListingGroupsProduct = Omit<PublicProduct, 'variants'> & {
1534
+ id: string;
1535
+ slug: string;
1536
+ title: string;
1537
+ primaryMediaItemId?: ProductListingGroupsProductPrimaryMediaItemId;
1538
+ variants?: (Omit<ProductListingGroupsProductVariants, 'docs'> & {
1539
+ docs: ProductListingGroupVariant[];
1540
+ }) | null;
1410
1541
  };
1411
- type CancelOrderAlreadyCanceledResponseFields = {
1412
- refundedAmount: number;
1413
- providerRefunded: false;
1542
+ type ProductListingGroupsCatalogProduct = Omit<ProductListingGroupsProduct, 'variants'> & {
1543
+ variants?: (Omit<NonNullable<ProductListingGroupsProduct['variants']>, 'docs'> & {
1544
+ docs: ProductListingGroupCatalogVariant[];
1545
+ }) | null;
1414
1546
  };
1415
- type CancelOrderAlreadyCanceledRefundPendingResponseFields = {
1416
- transactionId: string;
1417
- refundedAmount: number;
1418
- providerRefunded: false;
1419
- refundPending: true;
1547
+ type ProductListingGroupsItem = {
1548
+ product: ProductListingGroupsProduct;
1549
+ groups: ProductListingGroupSummary[];
1420
1550
  };
1421
- type CancelOrderPaidCommittedResponse = CancelOrderResponseBase & CancelOrderPaidCommittedResponseFields & {
1422
- status: 'canceled';
1423
- cancelCommitted: true;
1551
+ type ProductListingGroupsCatalogItem = {
1552
+ product: ProductListingGroupsCatalogProduct;
1553
+ groups: ProductListingGroupCatalogSummary[];
1424
1554
  };
1425
- type CancelOrderUnpaidCommittedResponse = CancelOrderResponseBase & CancelOrderUnpaidCommittedResponseFields & {
1426
- status: 'canceled';
1427
- cancelCommitted: true;
1555
+ type ProductListingGroupsResponse = {
1556
+ /**
1557
+ * Matching products in the same order as the requested productIds, excluding
1558
+ * ids that were not found, not published, or not accessible for the current
1559
+ * tenant/key.
1560
+ */
1561
+ docs: ProductListingGroupsItem[];
1562
+ /** Requested productIds that could not be returned. */
1563
+ missing: string[];
1428
1564
  };
1429
- type CancelOrderCommittedResponse = CancelOrderPaidCommittedResponse | CancelOrderUnpaidCommittedResponse;
1430
- type CancelOrderAlreadyCanceledResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledResponseFields & {
1431
- status: 'canceled';
1432
- cancelCommitted: false;
1433
- alreadyCanceled: true;
1565
+ type ProductListingGroupsCatalogResponse = Omit<ProductListingGroupsResponse, 'docs'> & {
1566
+ docs: ProductListingGroupsCatalogItem[];
1434
1567
  };
1435
- type CancelOrderAlreadyCanceledRefundPendingResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledRefundPendingResponseFields & {
1436
- status: 'canceled';
1437
- cancelCommitted: false;
1438
- alreadyCanceled: true;
1568
+ type ProductDetailParams = {
1569
+ slug: string;
1570
+ } | {
1571
+ id: string;
1439
1572
  };
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;
1573
+ type ProductDetailPreviewParams = {
1574
+ id: string;
1445
1575
  };
1446
- type CancelOrderResponse = CancelOrderCommittedResponse | CancelOrderAlreadyCanceledResponse | CancelOrderAlreadyCanceledRefundPendingResponse | CancelOrderReconciliationResponse;
1447
- type CancelOrderParams = {
1448
- orderNumber: string;
1449
- reasonCode?: CancelReasonCode;
1450
- reasonDetail?: string;
1451
- idempotencyKey?: string;
1576
+ type ProductDetailPreviewOptions = {
1577
+ previewToken: string;
1452
1578
  };
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;
1579
+ interface ProductDetailVariantOptionValue {
1580
+ optionId: string | number;
1581
+ optionSlug: string;
1582
+ valueId: string | number;
1583
+ valueSlug: string;
1584
+ value?: string | null;
1585
+ }
1586
+ type ProductDetailMedia = string | number | {
1587
+ id?: string | number | null;
1588
+ url?: string | null;
1589
+ alt?: string | null;
1590
+ width?: number | null;
1591
+ height?: number | null;
1461
1592
  };
1462
- type ResolveCancelRefundFailedParams = {
1463
- orderNumber: string;
1464
- idempotencyKey: string;
1465
- outcome: 'failed';
1466
- refundedAmount: 0;
1467
- pgProvider: string;
1468
- pgRefundId?: string;
1593
+ type ProductOptionValueColorSwatch = {
1594
+ type: 'color';
1595
+ color: string;
1596
+ mediaItemId?: null;
1469
1597
  };
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';
1598
+ type ProductOptionValueMediaSwatch<TMedia = ProductDetailMedia> = {
1599
+ type: 'media';
1600
+ mediaItemId: TMedia;
1601
+ color?: null;
1602
+ };
1603
+ type ProductOptionValueSwatch<TMedia = ProductDetailMedia> = ProductOptionValueColorSwatch | ProductOptionValueMediaSwatch<TMedia> | null;
1604
+ type ProductDetailMediaValue = string | number | ProductDetailMedia | null;
1605
+ type ProductDetailSelectionMediaSource = 'variant_media_selected' | 'variant_media_matching' | 'option_swatch' | 'none';
1606
+ interface ProductDetailVariant {
1607
+ id: string | number;
1608
+ optionKey: string;
1609
+ title?: string | null;
1610
+ displayName: string;
1611
+ sku?: string | null;
1612
+ price: number;
1613
+ compareAtPrice?: number | null;
1614
+ stock: number;
1615
+ reservedStock: number;
1616
+ isUnlimited: boolean;
1617
+ isActive: boolean;
1618
+ thumbnail?: ProductDetailMedia | null;
1619
+ images?: ProductDetailMedia[];
1620
+ media?: {
1621
+ primaryImage: ProductDetailMedia | null;
1622
+ images: ProductDetailMedia[];
1623
+ source: ProductDetailSelectionMediaSource;
1624
+ };
1625
+ optionValues: ProductDetailVariantOptionValue[];
1626
+ }
1627
+ interface ProductDetailOptionValue {
1628
+ id: string | number;
1629
+ value: string;
1630
+ slug: string;
1631
+ swatch?: ProductOptionValueSwatch<ProductDetailMedia>;
1632
+ }
1633
+ interface ProductDetailOption {
1634
+ id: string | number;
1635
+ title: string;
1636
+ slug: string;
1637
+ values: ProductDetailOptionValue[];
1638
+ }
1639
+ interface ProductDetailBrand {
1640
+ id: string | number;
1641
+ name: string;
1642
+ slug?: string | null;
1643
+ logo?: unknown | null;
1644
+ }
1645
+ interface ProductDetailCategory {
1646
+ id: string | number;
1647
+ title: string;
1648
+ slug?: string | null;
1649
+ }
1650
+ interface ProductDetailTag {
1651
+ id: string | number;
1652
+ title: string;
1653
+ slug?: string | null;
1654
+ }
1655
+ interface ProductDetailImage {
1656
+ id: string | number;
1657
+ url?: string | null;
1658
+ alt?: string | null;
1659
+ width?: number | null;
1660
+ height?: number | null;
1661
+ }
1662
+ interface ProductDetailVideo {
1663
+ id: string | number;
1664
+ url?: string | null;
1665
+ }
1666
+ interface ProductDetailListing {
1667
+ minPrice?: number | null;
1668
+ maxPrice?: number | null;
1669
+ minCompareAtPrice?: number | null;
1670
+ maxCompareAtPrice?: number | null;
1671
+ isPriceRange?: boolean | null;
1672
+ primaryImage?: ProductDetailMedia | null;
1673
+ availableForSale?: boolean | null;
1674
+ selectionHintVariant?: string | number | null;
1675
+ }
1676
+ type ProductDetailCatalogVariant = Omit<ProductDetailVariant, 'stock' | 'reservedStock'>;
1677
+ type ProductDetailCatalogListing = Omit<ProductDetailListing, 'availableForSale'> & {
1678
+ liveStockRequired: true;
1478
1679
  };
1479
- type ResolveCancelRefundFailedResponse = {
1480
- orderId: string;
1481
- transactionId: string;
1482
- refundTransactionId: string;
1483
- refundedAmount: 0;
1484
- refundStatus: 'failed';
1485
- transactionStatus: 'paid';
1680
+ interface ProductDetailCatalog {
1681
+ product: Omit<ProductDetail['product'], 'totalInventory'>;
1682
+ variants: ProductDetailCatalogVariant[];
1683
+ options: ProductDetail['options'];
1684
+ brand: ProductDetail['brand'];
1685
+ categories: ProductDetail['categories'];
1686
+ tags: ProductDetail['tags'];
1687
+ images: ProductDetail['images'];
1688
+ videos: ProductDetail['videos'];
1689
+ primaryMediaItemId?: ProductDetail['primaryMediaItemId'];
1690
+ listing: ProductDetailCatalogListing;
1691
+ }
1692
+ type StockSnapshotItemStatus = 'available' | 'not_published' | 'archived' | 'not_found';
1693
+ interface StockSnapshotItem {
1694
+ variantId: string;
1695
+ status: StockSnapshotItemStatus;
1696
+ availableStock: number;
1697
+ availableForSale: boolean;
1698
+ isUnlimited: boolean;
1699
+ }
1700
+ interface StockSnapshotResponse {
1701
+ snapshots: StockSnapshotItem[];
1702
+ }
1703
+ type StockSnapshotParams = {
1704
+ variantIds: string[];
1486
1705
  };
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;
1706
+ interface ProductDetail {
1707
+ product: {
1708
+ id: string | number;
1709
+ slug: string;
1710
+ title: string;
1711
+ subtitle?: string | null;
1712
+ description?: string | null;
1713
+ content?: unknown;
1714
+ publishedAt?: string | null;
1715
+ status: string;
1716
+ totalInventory: number | null;
1717
+ totalVariants: number;
1718
+ hasUnlimitedVariant: boolean;
1719
+ hasOnlyDefaultVariant: boolean;
1720
+ };
1721
+ variants: ProductDetailVariant[];
1722
+ options: ProductDetailOption[];
1723
+ brand: ProductDetailBrand | null;
1724
+ categories: ProductDetailCategory[];
1725
+ tags: ProductDetailTag[];
1726
+ images: ProductDetailImage[];
1727
+ videos: ProductDetailVideo[];
1728
+ /** Canonical product primary pointer (pool member). */
1729
+ primaryMediaItemId?: ProductDetailMediaValue;
1730
+ listing: ProductDetailListing;
1731
+ }
1732
+ type ProductDetailUnavailableReason = 'not_found' | 'not_published' | 'feature_disabled';
1733
+ type ProductDetailResult = {
1734
+ found: true;
1735
+ product: ProductDetail;
1736
+ } | {
1737
+ found: false;
1738
+ reason: ProductDetailUnavailableReason;
1494
1739
  };
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;
1740
+ type ProductDetailCatalogResult = {
1741
+ found: true;
1742
+ product: ProductDetailCatalog;
1743
+ } | {
1744
+ found: false;
1745
+ reason: ProductDetailUnavailableReason;
1527
1746
  };
1528
- type PrepareFulfillmentOrderResponse = {
1529
- orderId: string;
1530
- fulfillmentOrders: Array<{
1531
- id: string;
1532
- status: string;
1533
- }>;
1747
+ type ProductUpsertParams = ProductUpsertInput;
1748
+ /** Console `POST /api/products/upsert` field allowlist error reasons. */
1749
+ declare const PRODUCT_UPSERT_UNKNOWN_FIELD_REASON: "unknown_field";
1750
+ declare const PRODUCT_UPSERT_READONLY_FIELD_REASON: "product_field_readonly";
1751
+ type ProductUpsertFieldValidationErrorReason = typeof PRODUCT_UPSERT_UNKNOWN_FIELD_REASON | typeof PRODUCT_UPSERT_READONLY_FIELD_REASON;
1752
+ /** 400 response body when upsert rejects unknown or server-managed product fields. */
1753
+ type ProductUpsertFieldValidationErrorBody = {
1754
+ error: string;
1755
+ reason: ProductUpsertFieldValidationErrorReason;
1756
+ field: string;
1757
+ requestId?: string;
1534
1758
  };
1535
- type UpdateFulfillmentParams = {
1536
- fulfillmentId: string;
1537
- status?: 'shipped' | 'delivered' | 'failed';
1538
- carrier?: string;
1539
- trackingNumber?: string;
1759
+ declare function isProductUpsertFieldValidationErrorBody(value: unknown): value is ProductUpsertFieldValidationErrorBody;
1760
+ type ProductUpsertResponse = {
1761
+ ok: true;
1762
+ product: PublicProduct;
1763
+ listingProjectionStale: boolean;
1764
+ } | {
1765
+ ok: false;
1766
+ failedEntity: 'product' | 'option' | 'option-value' | 'variant';
1767
+ failedIndex?: number;
1768
+ message: string;
1540
1769
  };
1541
- type BulkImportFulfillmentsParams = {
1542
- items: Array<{
1543
- orderNumber: string;
1544
- carrier: string;
1545
- trackingNumber: string;
1546
- }>;
1770
+ declare class ProductApi extends BaseApi {
1771
+ constructor(options: ProductApiOptions);
1772
+ /**
1773
+ * Check point-in-time stock availability for one or more product variants.
1774
+ * Results reflect available stock at the moment of the call and are not guaranteed
1775
+ * to remain available by the time an order is placed.
1776
+ */
1777
+ stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
1778
+ stockSnapshot(params: StockSnapshotParams): Promise<StockSnapshotResponse>;
1779
+ listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
1780
+ listingGroupsCatalog(params: ListingGroupsParams): Promise<ProductListingGroupsCatalogResponse>;
1781
+ /**
1782
+ * Fetch full product detail by slug or id.
1783
+ * Returns a discriminated result so storefronts can distinguish missing,
1784
+ * unpublished, and feature-disabled products.
1785
+ *
1786
+ * Only product-detail 404 responses carrying one of those allowlisted reasons
1787
+ * are mapped to `{ found: false, reason }`. Unknown or uncoded 404s, plus
1788
+ * permission/auth errors such as tenant mismatch, continue to throw typed SDK
1789
+ * errors instead of being collapsed into a storefront absence result.
1790
+ */
1791
+ detail(params: ProductDetailParams): Promise<ProductDetailResult>;
1792
+ detailCatalog(params: ProductDetailParams): Promise<ProductDetailCatalogResult>;
1793
+ /**
1794
+ * Atomically create or update a product together with its options,
1795
+ * option-values, and variants in a single transaction. Mirrors Shopify's
1796
+ * `productSet` shape and is the canonical write path for the MCP
1797
+ * `product-upsert` tool.
1798
+ */
1799
+ upsert(params: ProductUpsertParams): Promise<ProductUpsertResponse>;
1800
+ }
1801
+
1802
+ type DiscountApiOptions = ServerApiOptions;
1803
+ type ValidateDiscountParams = {
1804
+ code: string;
1805
+ orderAmount: number;
1547
1806
  };
1548
- type BulkImportFulfillmentsResponse = {
1549
- succeeded: Array<{
1550
- orderNumber: string;
1551
- fulfillmentId: string;
1552
- }>;
1553
- failed: Array<{
1554
- orderNumber: string;
1555
- error: string;
1556
- }>;
1807
+ type ValidateDiscountResult = {
1808
+ valid: boolean;
1809
+ code: string;
1810
+ type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
1811
+ discountAmount: number;
1812
+ freeShipping?: boolean;
1813
+ reason?: string;
1557
1814
  };
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';
1815
+ declare class DiscountApi extends BaseApi {
1816
+ constructor(options: DiscountApiOptions);
1817
+ validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
1818
+ }
1819
+
1820
+ type ShippingApiOptions = ServerApiOptions;
1821
+ type CalculateShippingParams = {
1822
+ shippingPolicyId?: string;
1823
+ orderAmount: number;
1824
+ postalCode?: string;
1571
1825
  };
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>;
1826
+ type CalculateShippingResult = {
1827
+ shippingAmount: number;
1828
+ baseShippingAmount: number;
1829
+ extraShippingAmount: number;
1830
+ freeShipping: boolean;
1831
+ freeShippingMinAmount: number | null;
1832
+ isJeju: boolean;
1833
+ isRemoteIsland: boolean;
1834
+ };
1835
+ declare class ShippingApi extends BaseApi {
1836
+ constructor(options: ShippingApiOptions);
1837
+ calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
1591
1838
  }
1592
1839
 
1593
1840
  interface CommerceClientOptions {
@@ -1603,30 +1850,30 @@ declare class CommerceClient {
1603
1850
  stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1604
1851
  stockSnapshot: (params: StockSnapshotParams) => Promise<StockSnapshotResponse>;
1605
1852
  listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1606
- listingGroupsCatalog: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1853
+ listingGroupsCatalog: (params: ListingGroupsParams) => Promise<ProductListingGroupsCatalogResponse>;
1607
1854
  detail: (params: ProductDetailParams) => Promise<ProductDetailResult>;
1608
1855
  detailCatalog: (params: ProductDetailParams) => Promise<ProductDetailCatalogResult>;
1609
1856
  };
1610
1857
  readonly cart: {
1611
- get: (cartId: string) => Promise<Cart>;
1612
- addItem: (params: AddItemParams) => Promise<CartItem>;
1613
- updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1858
+ get: (cartId: string) => Promise<PublicCart>;
1859
+ addItem: (params: AddItemParams) => Promise<PublicCartItem>;
1860
+ updateItem: (params: UpdateItemParams) => Promise<PublicCartItem>;
1614
1861
  removeItem: (params: RemoveItemParams) => Promise<{
1615
1862
  success: boolean;
1616
1863
  }>;
1617
- applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1618
- removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1864
+ applyDiscount: (params: ApplyDiscountParams) => Promise<PublicCart>;
1865
+ removeDiscount: (params: RemoveDiscountParams) => Promise<PublicCart>;
1619
1866
  clear: (params: ClearCartParams) => Promise<{
1620
1867
  success: boolean;
1621
1868
  }>;
1622
1869
  };
1623
1870
  readonly orders: {
1624
- checkout: (params: CheckoutParams) => Promise<Order>;
1871
+ checkout: (params: CheckoutParams) => Promise<PublicOrder>;
1625
1872
  listMine: (options?: {
1626
1873
  page?: number;
1627
1874
  limit?: number;
1628
1875
  status?: string;
1629
- }) => Promise<PayloadFindResponse<Order>>;
1876
+ }) => Promise<PayloadFindResponse<PublicOrder>>;
1630
1877
  };
1631
1878
  readonly discounts: {
1632
1879
  validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
@@ -1652,20 +1899,20 @@ declare class ServerCommerceClient {
1652
1899
  upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
1653
1900
  };
1654
1901
  readonly cart: {
1655
- get: (cartId: string) => Promise<Cart>;
1656
- addItem: (params: AddItemParams) => Promise<CartItem>;
1657
- updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1902
+ get: (cartId: string) => Promise<PublicCart>;
1903
+ addItem: (params: AddItemParams) => Promise<PublicCartItem>;
1904
+ updateItem: (params: UpdateItemParams) => Promise<PublicCartItem>;
1658
1905
  removeItem: (params: RemoveItemParams) => Promise<{
1659
1906
  success: boolean;
1660
1907
  }>;
1661
- applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1662
- removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1908
+ applyDiscount: (params: ApplyDiscountParams) => Promise<PublicCart>;
1909
+ removeDiscount: (params: RemoveDiscountParams) => Promise<PublicCart>;
1663
1910
  clear: (params: ClearCartParams) => Promise<{
1664
1911
  success: boolean;
1665
1912
  }>;
1666
1913
  };
1667
1914
  readonly orders: {
1668
- checkout: (params: CheckoutParams) => Promise<Order>;
1915
+ checkout: (params: CheckoutParams) => Promise<PublicOrder>;
1669
1916
  create: (params: CreateOrderParams) => Promise<Order>;
1670
1917
  update: (params: UpdateOrderParams) => Promise<Order>;
1671
1918
  updateTransaction: (params: UpdateTransactionParams) => Promise<Transaction>;
@@ -2162,4 +2409,4 @@ type DeepPartial<T> = {
2162
2409
  };
2163
2410
  type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
2164
2411
 
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 };
2412
+ export { type EventsCalendarItem as $, type AddItemParams as A, BaseApi as B, CommerceClient as C, type DebugConfig as D, EventsClient as E, ServerCommerceClient as F, type BanCustomerParams as G, type CommunityBan as H, type UnbanCustomerParams as I, type ClientServerConfig as J, type RootServerClientWithEvents as K, type CollectionFieldSchema as L, type CollectionSchemaResponse as M, type EventGuestCancelParams as N, type EventGuestRegistration as O, type PayloadFindResponse as P, type EventGuestRegistrationResponse as Q, type RemoveDiscountParams as R, type Sort as S, type TenantIntrospectionClient as T, type UpdateItemParams as U, type EventRegistrationAnswerInput as V, type Where as W, type EventRegistrationAttendeeInput as X, type EventRegistrationPublic as Y, type EventRegistrationRegisterParams as Z, type EventRegistrationRegisterResponse as _, CommunityClient as a, type CommunityPublicAuthorSnapshot as a$, type EventsClientOptions as a0, type EventsDateParam as a1, type EventsExternalSource as a2, type EventsLocation as a3, type EventsOccurrenceLocation as a4, type EventsRangeEvent as a5, type EventsRangeOccurrence as a6, type EventsRangeParams as a7, type EventsRangeResponse as a8, type EventsTaxonomyItem as a9, type ProductDetailCatalog as aA, type StockSnapshotResponse as aB, type ProductSelectionMediaSource as aC, type ProductDisplayMediaSource as aD, type ResolveProductSelectionMediaInput as aE, type ResolveProductSelectionMediaResult as aF, type ProductSelectionMediaPointer as aG, type RootClientWithEvents as aH, type BulkImportFulfillmentsParams as aI, type BulkImportFulfillmentsResponse as aJ, type CalculateShippingParams as aK, type CalculateShippingResult as aL, type CancelOrderParams as aM, type CancelOrderReconciliationStatus as aN, type CancelOrderResponse as aO, type CancelReasonCode as aP, CartApi as aQ, type CartApiOptions as aR, type Comment as aS, type CommerceClientOptions as aT, type CommunityClientOptions as aU, type CommunityComment as aV, type CommunityCommentListSort as aW, type CommunityPost as aX, type CommunityPostCategory as aY, type CommunityPostListSort as aZ, type CommunityPostTag as a_, ModerationApi as aa, type RootServerClient as ab, type TenantFeatureProgressEvidenceValue as ac, type TenantFeatureProgressFeature as ad, type TenantFeatureProgressGroup as ae, type TenantFeatureProgressInput as af, type TenantFeatureProgressItem as ag, type TenantFeatureProgressItemState as ah, type TenantFeatureProgressResponse as ai, type TenantFeatureProgressSeverity as aj, type TenantFeatureProgressStatus as ak, TenantIntrospectionApi as al, type TenantIntrospectionApiOptions as am, CustomerAuth as an, type CustomerProfile as ao, type CustomerAuthResponse as ap, type CustomerLoginData as aq, type CustomerRegisterResponse as ar, type CustomerRegisterData as as, type CustomerRefreshResponse as at, type UpdateProfileData as au, type ProductDetailParams as av, type ProductDetailResult as aw, type ProductListingGroupsItem as ax, type ProductListingGroupsCatalogItem as ay, type ProductDetail as az, CustomerNamespace as b, type ProductMediaResolutionSource as b$, type CommunityPublicMediaAsset as b0, type CommunityPublicReference as b1, type CompatibilityProductSelectionParamEvent as b2, type ConfirmPaymentParams as b3, type ConfirmPaymentResponse as b4, type CreateFulfillmentParams as b5, type CreateOrderItem as b6, type CreateOrderParams as b7, type CreateReturnParams as b8, type CustomerAuthOptions as b9, type ProductDetailMedia as bA, type ProductDetailOption as bB, type ProductDetailOptionValue as bC, type ProductDetailTag as bD, type ProductDetailUnavailableReason as bE, type ProductDetailVariant as bF, type ProductDetailVariantOptionValue as bG, type ProductDetailVideo as bH, type ProductHrefGroup as bI, type ProductHrefOptions as bJ, type ProductHrefProduct as bK, type ProductListingCard as bL, type ProductListingCardOptions as bM, type ProductListingCardPriceRange as bN, type ProductListingCardRepresentativeVariant as bO, type ProductListingGroup as bP, type ProductListingGroupCatalogSummary as bQ, type ProductListingGroupCatalogVariant as bR, type ProductListingGroupSummary as bS, type ProductListingGroupVariant as bT, type ProductListingGroupsCatalogProduct as bU, type ProductListingGroupsCatalogResponse as bV, type ProductListingGroupsProduct as bW, type ProductListingGroupsResponse as bX, type ProductListingProductShape as bY, type ProductListingProjection as bZ, type ProductListingSwatch as b_, type CustomerSnapshot as ba, DiscountApi as bb, type DiscountApiOptions as bc, type LegacyProductSelectionParamEvent as bd, type ListingGroupsParams as be, type ListingPrimaryImageFallbackInput as bf, type MediaValue as bg, type NormalizedOptionSwatch as bh, type NormalizedProductSelection as bi, OrderApi as bj, type OrderApiOptions as bk, PRODUCT_PLP_FIND_OPTIONS as bl, PRODUCT_UPSERT_READONLY_FIELD_REASON as bm, PRODUCT_UPSERT_UNKNOWN_FIELD_REASON as bn, type PrepareFulfillmentOrderParams as bo, type PrepareFulfillmentOrderResponse as bp, ProductApi as bq, type ProductApiOptions as br, type ProductDetailBrand as bs, type ProductDetailCatalogListing as bt, type ProductDetailCatalogResult as bu, type ProductDetailCatalogVariant as bv, type ProductDetailCategory as bw, type ProductDetailImage as bx, type ProductDetailImageMedia as by, type ProductDetailListing as bz, type ClientState as c, resolveListingPrimaryImagePointer as c$, type ProductOptionMatrix as c0, type ProductOptionMatrixOption as c1, type ProductOptionMatrixValue as c2, type ProductOptionMatrixVariant as c3, type ProductOptionShape as c4, type ProductOptionValueShape as c5, type ProductOptionValueSwatch as c6, type ProductOptionValueSwatchInput as c7, type ProductSelectionAvailableSwatch as c8, type ProductSelectionAvailableValue as c9, type StockCheckParams as cA, type StockCheckResponse as cB, type StockCheckResult as cC, type StockSnapshotItem as cD, type StockSnapshotParams as cE, type UpdateFulfillmentParams as cF, type UpdateOrderParams as cG, type UpdateReturnParams as cH, type UpdateTransactionParams as cI, type ValidateDiscountParams as cJ, type ValidateDiscountResult as cK, type WithIdempotencyKey as cL, buildProductHref as cM, buildProductListingCard as cN, buildProductListingGroupsByOption as cO, buildProductListingProjection as cP, buildProductOptionMatrix as cQ, buildProductOptionMatrixFromDetail as cR, createProductSelectionCodec as cS, getAvailableOptionValues as cT, getProductSelectionImages as cU, getSelectedValueByOptionId as cV, isProductUpsertFieldValidationErrorBody as cW, normalizeProductSelection as cX, normalizeProductSelectionFromMatrix as cY, normalizeSelectedValueIds as cZ, parseProductSelection as c_, type ProductSelectionByOptionValue as ca, ProductSelectionCodecError as cb, type ProductSelectionCodecOptions as cc, type ProductSelectionInput as cd, type ProductSelectionOptionValue as ce, type ProductSelectionResolution as cf, type ProductSelectionResolutionContext as cg, type ProductSelectionUrlEmit as ch, type ProductSelectionVariant as ci, type ProductUpsertFieldValidationErrorBody as cj, type ProductUpsertFieldValidationErrorReason as ck, type ProductVariantShape as cl, type RequestOptions as cm, type ResolveCancelRefundFailedResponse as cn, type ResolveCancelRefundOutcome as co, type ResolveCancelRefundParams as cp, type ResolveCancelRefundResponse as cq, type ResolveCancelRefundSucceededResponse as cr, type ResolveProductDisplayMediaInput as cs, type ResolveProductDisplayMediaResult as ct, type ReturnItem as cu, type ReturnReason as cv, type ReturnWithRefundItem as cw, type ReturnWithRefundParams as cx, ShippingApi as cy, type ShippingApiOptions as cz, type ClientConfig as d, resolveProductDisplayMedia as d0, resolveProductSelection as d1, resolveProductSelectionFromMatrix as d2, resolveProductSelectionMedia as d3, resolveVariantForSelection as d4, selectNext as d5, selectedSwatchMediaItemId as d6, stringifyProductSelection as d7, toShopifyPriceRangeV2 as d8, type ApiQueryOptions as e, type ApplyDiscountParams as f, type CheckoutParams as g, type ClearCartParams as h, type ClientMetadata as i, type DeepPartial as j, type ExtractArrayType as k, type PayloadMutationResponse as l, type PublicCart as m, type PublicCartItem as n, type PublicCartReference as o, type PublicMediaAsset as p, type PublicMediaSize as q, type PublicOrder as r, type PublicOrderItem as s, type PublicOrderReference as t, type RemoveItemParams as u, type RetryConfig as v, type RootClient as w, type RootCollectionClient as x, type RootReadOnlyQueryBuilder as y, type ServerApiOptions as z };