@01.software/sdk 0.36.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 (82) hide show
  1. package/README.md +142 -55
  2. package/dist/analytics/react.cjs +33 -9
  3. package/dist/analytics/react.cjs.map +1 -1
  4. package/dist/analytics/react.d.cts +1 -1
  5. package/dist/analytics/react.d.ts +1 -1
  6. package/dist/analytics/react.js +33 -9
  7. package/dist/analytics/react.js.map +1 -1
  8. package/dist/analytics.cjs +30 -8
  9. package/dist/analytics.cjs.map +1 -1
  10. package/dist/analytics.d.cts +6 -0
  11. package/dist/analytics.d.ts +6 -0
  12. package/dist/analytics.js +30 -8
  13. package/dist/analytics.js.map +1 -1
  14. package/dist/client.cjs +150 -207
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.d.cts +6 -6
  17. package/dist/client.d.ts +6 -6
  18. package/dist/client.js +150 -207
  19. package/dist/client.js.map +1 -1
  20. package/dist/{collection-client-Cv0D2w1Q.d.cts → collection-client-B0J9wMNE.d.cts} +5 -5
  21. package/dist/{collection-client-Bq5Zd7p7.d.ts → collection-client-BroIWHY1.d.ts} +5 -5
  22. package/dist/const-6XHz_jej.d.ts +32 -0
  23. package/dist/const-B5KT72c7.d.cts +32 -0
  24. package/dist/{image-BDz2-AaO.d.cts → image-BDjHp03R.d.cts} +13 -9
  25. package/dist/{image-BDz2-AaO.d.ts → image-BDjHp03R.d.ts} +13 -9
  26. package/dist/{index-DTSXUYkr.d.ts → index-BOLQxveo.d.cts} +9 -6
  27. package/dist/{index-BHDKJ6B3.d.cts → index-CSwR2HSg.d.ts} +9 -6
  28. package/dist/index.cjs +256 -244
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +12 -11
  31. package/dist/index.d.ts +12 -11
  32. package/dist/index.js +256 -244
  33. package/dist/index.js.map +1 -1
  34. package/dist/metadata.cjs +5 -3
  35. package/dist/metadata.cjs.map +1 -1
  36. package/dist/metadata.js +5 -3
  37. package/dist/metadata.js.map +1 -1
  38. package/dist/{payload-types-BCui2Oml.d.cts → payload-types-m3jjhxk9.d.cts} +669 -184
  39. package/dist/{payload-types-BCui2Oml.d.ts → payload-types-m3jjhxk9.d.ts} +669 -184
  40. package/dist/query.cjs +3 -1033
  41. package/dist/query.cjs.map +1 -1
  42. package/dist/query.d.cts +13 -13
  43. package/dist/query.d.ts +13 -13
  44. package/dist/query.js +3 -1033
  45. package/dist/query.js.map +1 -1
  46. package/dist/realtime.d.cts +2 -2
  47. package/dist/realtime.d.ts +2 -2
  48. package/dist/server.cjs +121 -85
  49. package/dist/server.cjs.map +1 -1
  50. package/dist/server.d.cts +7 -7
  51. package/dist/server.d.ts +7 -7
  52. package/dist/server.js +121 -85
  53. package/dist/server.js.map +1 -1
  54. package/dist/{types-Dib-zdK6.d.cts → types-CIGscmus.d.cts} +1471 -1100
  55. package/dist/{types-3qV6sY7T.d.ts → types-Cmrd1ezc.d.ts} +1 -15
  56. package/dist/{types-CEzLf3PX.d.cts → types-D0ubzQw0.d.cts} +1 -15
  57. package/dist/{types-DK9EnLwJ.d.ts → types-D2xYdz4P.d.ts} +1471 -1100
  58. package/dist/ui/canvas.cjs +15 -5
  59. package/dist/ui/canvas.cjs.map +1 -1
  60. package/dist/ui/canvas.d.cts +1 -1
  61. package/dist/ui/canvas.d.ts +1 -1
  62. package/dist/ui/canvas.js +15 -5
  63. package/dist/ui/canvas.js.map +1 -1
  64. package/dist/ui/form.d.cts +1 -1
  65. package/dist/ui/form.d.ts +1 -1
  66. package/dist/ui/image.cjs +15 -5
  67. package/dist/ui/image.cjs.map +1 -1
  68. package/dist/ui/image.d.cts +1 -1
  69. package/dist/ui/image.d.ts +1 -1
  70. package/dist/ui/image.js +15 -5
  71. package/dist/ui/image.js.map +1 -1
  72. package/dist/ui/video.d.cts +1 -1
  73. package/dist/ui/video.d.ts +1 -1
  74. package/dist/webhook.cjs +5 -1
  75. package/dist/webhook.cjs.map +1 -1
  76. package/dist/webhook.d.cts +4 -4
  77. package/dist/webhook.d.ts +4 -4
  78. package/dist/webhook.js +5 -1
  79. package/dist/webhook.js.map +1 -1
  80. package/package.json +3 -3
  81. package/dist/const-BDUKFP9w.d.ts +0 -32
  82. package/dist/const-DVcM7Ac_.d.cts +0 -32
@@ -1,7 +1,36 @@
1
- import { P as PublicCollection, S as ServerCollection } from './const-BDUKFP9w.js';
2
- import { C as CollectionType, P as PublicProduct } from './types-3qV6sY7T.js';
3
- import { O as Order, i as Cart, j as CartItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-BCui2Oml.js';
1
+ import { P as PublicCollection, S as ServerCollection } from './const-6XHz_jej.js';
2
+ import { C as CollectionType, P as PublicProduct } from './types-Cmrd1ezc.js';
3
+ import { O as Order, l as Transaction, m as Fulfillment, R as Return } from './payload-types-m3jjhxk9.js';
4
4
 
5
+ interface CustomerScopedApiOptions {
6
+ publishableKey?: string;
7
+ secretKey?: string;
8
+ apiUrl?: string;
9
+ customerToken?: string | (() => string | null);
10
+ onUnauthorized?: () => Promise<string | null>;
11
+ onRequestId?: (id: string | null) => void;
12
+ requiresCredential?: boolean;
13
+ }
14
+ interface CustomerScopedRequestOptions {
15
+ method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
16
+ body?: unknown;
17
+ headers?: Record<string, string>;
18
+ }
19
+ declare class CustomerScopedApi {
20
+ private readonly publishableKey;
21
+ private readonly secretKey?;
22
+ private readonly apiUrl?;
23
+ private readonly customerToken?;
24
+ private readonly onUnauthorized?;
25
+ private readonly onRequestId?;
26
+ constructor(apiName: string, options: CustomerScopedApiOptions);
27
+ protected request<T>(endpoint: string, options: CustomerScopedRequestOptions): Promise<T>;
28
+ }
29
+
30
+ type RawCommunityPost = CollectionType<'posts'>;
31
+ type RawCommunityComment = CollectionType<'comments'>;
32
+ type RawCommunityReaction = CollectionType<'reactions'>;
33
+ type RawCommunityBookmark = CollectionType<'bookmarks'>;
5
34
  interface CommunityClientOptions {
6
35
  publishableKey?: string;
7
36
  secretKey?: string;
@@ -10,10 +39,82 @@ interface CommunityClientOptions {
10
39
  onUnauthorized?: () => Promise<string | null>;
11
40
  onRequestId?: (id: string | null) => void;
12
41
  }
13
- /** Public read shape for `posts` (tenant-scoped author profiles). */
14
- type CommunityPost = CollectionType<'posts'>;
15
- /** Public read shape for `comments`. */
16
- 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
+ }
17
118
  /** @deprecated Use {@link CommunityComment}. */
18
119
  type Comment = CommunityComment;
19
120
  /** Public read shape for `post-categories`. */
@@ -24,10 +125,11 @@ type CommunityPostListSort = 'createdAt' | '-createdAt' | 'lastActivityAt' | '-l
24
125
  type CommunityCommentListSort = 'createdAt' | '-createdAt';
25
126
  interface Reaction {
26
127
  id: string;
27
- post?: string;
28
- comment?: string;
29
- type?: string;
128
+ post?: CommunityPublicReference | null;
129
+ comment?: CommunityPublicReference | null;
130
+ type?: CommunityPublicReference | null;
30
131
  createdAt?: string;
132
+ updatedAt?: string;
31
133
  [key: string]: unknown;
32
134
  }
33
135
  interface ReactionSummary {
@@ -37,8 +139,9 @@ interface ReactionSummary {
37
139
  }
38
140
  interface Bookmark {
39
141
  id: string;
40
- post?: string;
142
+ post?: string | CommunityPost | null;
41
143
  createdAt?: string;
144
+ updatedAt?: string;
42
145
  [key: string]: unknown;
43
146
  }
44
147
  interface ReactionType {
@@ -60,24 +163,23 @@ interface PaginatedResponse<T> {
60
163
  prevPage: number | null;
61
164
  nextPage: number | null;
62
165
  }
63
- declare class CommunityClient {
64
- private readonly publishableKey;
65
- private readonly secretKey?;
66
- private readonly apiUrl?;
67
- private readonly customerToken?;
68
- private readonly onUnauthorized?;
69
- private readonly onRequestId?;
166
+ type CommunityPostMutationResponse = CommunityPost | RawCommunityPost;
167
+ type CommunityCommentMutationResponse = CommunityComment | RawCommunityComment;
168
+ type CommunityReactionMutationResponse = Reaction | RawCommunityReaction;
169
+ type CommunityBookmarkMutationResponse = Bookmark | RawCommunityBookmark;
170
+ declare class CommunityClient extends CustomerScopedApi {
70
171
  constructor(options: CommunityClientOptions);
71
172
  private buildQuery;
72
173
  private buildPostsListQuery;
73
174
  private buildCommentsListQuery;
74
175
  private execute;
176
+ private executeDoc;
75
177
  createPost(params: {
76
178
  title?: string | null;
77
179
  content?: unknown;
78
180
  categories?: string[];
79
181
  thumbnail?: string;
80
- }): Promise<CommunityPost>;
182
+ }): Promise<CommunityPostMutationResponse>;
81
183
  /**
82
184
  * Public post feed. Server applies the same visibility contract as
83
185
  * `communityPostRead` (published + visible + moderation-safe).
@@ -123,7 +225,7 @@ declare class CommunityClient {
123
225
  postId: string;
124
226
  body: string;
125
227
  parentId?: string;
126
- }): Promise<CommunityComment>;
228
+ }): Promise<CommunityCommentMutationResponse>;
127
229
  /**
128
230
  * List comments for a post.
129
231
  *
@@ -149,12 +251,10 @@ declare class CommunityClient {
149
251
  updateComment(params: {
150
252
  commentId: string;
151
253
  body: string;
152
- }): Promise<CommunityComment>;
254
+ }): Promise<CommunityCommentMutationResponse>;
153
255
  deleteComment(params: {
154
256
  commentId: string;
155
- }): Promise<{
156
- success: boolean;
157
- }>;
257
+ }): Promise<CommunityCommentMutationResponse>;
158
258
  reportComment(params: {
159
259
  commentId: string;
160
260
  reason?: string;
@@ -167,7 +267,7 @@ declare class CommunityClient {
167
267
  typeSlug?: string;
168
268
  /** @deprecated Use `typeSlug`. */
169
269
  type?: string;
170
- }): Promise<Reaction>;
270
+ }): Promise<CommunityReactionMutationResponse>;
171
271
  removeReaction(params: {
172
272
  postId: string;
173
273
  type: string;
@@ -179,7 +279,7 @@ declare class CommunityClient {
179
279
  typeSlug?: string;
180
280
  /** @deprecated Use `typeSlug`. */
181
281
  type?: string;
182
- }): Promise<Reaction>;
282
+ }): Promise<CommunityReactionMutationResponse>;
183
283
  removeCommentReaction(params: {
184
284
  commentId: string;
185
285
  type: string;
@@ -195,7 +295,7 @@ declare class CommunityClient {
195
295
  getReactionTypes(): Promise<PaginatedResponse<ReactionType>>;
196
296
  addBookmark(params: {
197
297
  postId: string;
198
- }): Promise<Bookmark>;
298
+ }): Promise<CommunityBookmarkMutationResponse>;
199
299
  removeBookmark(params: {
200
300
  postId: string;
201
301
  }): Promise<{
@@ -270,799 +370,1057 @@ declare class ModerationApi extends BaseApi {
270
370
  }>;
271
371
  }
272
372
 
273
- interface CustomerAuthResponse {
274
- token: string;
275
- customer: CustomerProfile;
276
- }
277
- interface MarketingConsentChannel {
278
- isConsented?: boolean;
279
- }
280
- interface MarketingConsent {
281
- email?: MarketingConsentChannel;
282
- sms?: MarketingConsentChannel;
283
- push?: MarketingConsentChannel;
284
- consentSource?: string;
285
- }
286
- interface CustomerProfile {
287
- id: string;
288
- name: string;
289
- email?: string | null;
290
- phone?: string | null;
291
- authProvider?: 'local' | 'google' | 'apple' | 'kakao' | 'naver' | null;
292
- isGuest?: boolean | null;
293
- marketingConsent?: MarketingConsent | null;
294
- metadata?: Record<string, unknown> | null;
295
- groups?: string[];
296
- }
297
- interface CustomerRegisterData {
298
- name: string;
299
- email: string;
300
- password: string;
301
- phone?: string;
302
- }
303
- interface CustomerRegisterResponse {
304
- customer: CustomerProfile;
305
- }
306
- interface CustomerLoginData {
307
- email: string;
308
- password: string;
309
- }
310
- interface CustomerRefreshResponse {
311
- token: string;
312
- }
313
- interface UpdateProfileData {
314
- name?: string;
315
- phone?: string;
316
- marketingConsent?: MarketingConsent;
317
- }
318
- interface CustomerAuthOptions {
319
- /**
320
- * Persist token in localStorage. Defaults to `true`.
321
- * - `true` (default): uses key `'customer-token'`
322
- * - `string`: uses the given string as localStorage key
323
- * - `false`: disables persistence (token/onTokenChange used instead)
324
- *
325
- * Handles SSR safely (no-op on server).
326
- * When enabled, `token` and `onTokenChange` are ignored.
327
- */
328
- persist?: boolean | string;
329
- /** Initial token (e.g. from SSR cookie) */
330
- token?: string;
331
- /** Called when token changes (login/logout) — use to persist in localStorage/cookie */
332
- onTokenChange?: (token: string | null) => void;
333
- }
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
+ };
334
390
 
335
- /**
336
- * Customer authentication client.
337
- *
338
- * Manages customer registration, login, logout, and token lifecycle.
339
- * All requests include X-Publishable-Key for tenant resolution.
340
- */
341
- declare class CustomerAuth {
342
- private publishableKey;
343
- private baseUrl;
344
- private token;
345
- private onTokenChange?;
346
- private refreshPromise;
347
- constructor(publishableKey: string, options?: CustomerAuthOptions, apiUrl?: string);
348
- /**
349
- * Register a new customer account
350
- */
351
- register(data: CustomerRegisterData): Promise<CustomerRegisterResponse>;
352
- /**
353
- * Login with email and password. Stores the token internally.
354
- */
355
- login(data: CustomerLoginData): Promise<CustomerAuthResponse>;
356
- /**
357
- * Refresh the current token. Requires a valid (non-expired) token.
358
- */
359
- refreshToken(): Promise<CustomerRefreshResponse>;
360
- private _doRefreshToken;
361
- /**
362
- * Clear the stored token
363
- */
364
- logout(): void;
365
- /**
366
- * Get the current authenticated customer's profile
367
- */
368
- me(): Promise<CustomerProfile | null>;
369
- /**
370
- * Request a password reset email
371
- */
372
- forgotPassword(email: string): Promise<void>;
373
- /**
374
- * Reset password using a token from the reset email
375
- */
376
- 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 & {
377
394
  /**
378
- * 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.
379
397
  */
380
- 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 = {
381
484
  /**
382
- * 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.
383
487
  */
384
- changePassword(currentPassword: string, newPassword: string): Promise<void>;
488
+ product?: OrderCreateEntityID;
489
+ variant: OrderCreateEntityID;
385
490
  /**
386
- * 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.
387
493
  */
388
- getMyOrders(options?: {
389
- page?: number;
390
- limit?: number;
391
- status?: string;
392
- }): Promise<PayloadFindResponse<Order>>;
494
+ option?: OrderCreateEntityID;
495
+ quantity: number;
393
496
  /**
394
- * 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.
395
499
  */
396
- getToken(): string | null;
500
+ unitPrice?: number;
397
501
  /**
398
- * 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.
399
504
  */
400
- setToken(token: string | null): void;
505
+ totalPrice?: number;
506
+ };
507
+ type CreateOrderLineItemsInput = {
508
+ orderItems: CreateOrderItem[];
509
+ items?: never;
510
+ } | {
401
511
  /**
402
- * 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.
403
514
  */
404
- isAuthenticated(): boolean;
515
+ items: CreateOrderItem[];
405
516
  /**
406
- * Internal: make a request with timeout and error handling.
407
- * Auth endpoints don't retry — failures are final.
517
+ * @deprecated Use items for storefront-facing create-order inputs.
408
518
  */
409
- private requestJson;
410
- }
411
-
412
- interface CartApiOptions {
413
- publishableKey?: string;
414
- secretKey?: string;
415
- apiUrl?: string;
416
- customerToken?: string | (() => string | null);
417
- onUnauthorized?: () => Promise<string | null>;
418
- onRequestId?: (id: string | null) => void;
419
- }
420
- type AddItemParams = {
421
- cartId: string;
422
- product: string;
423
- variant: string;
424
- option: string;
425
- quantity: number;
519
+ orderItems?: never;
426
520
  };
427
- type UpdateItemParams = {
428
- cartItemId: string;
429
- quantity: number;
430
- };
431
- type RemoveItemParams = {
432
- cartItemId: string;
433
- };
434
- type ApplyDiscountParams = {
435
- cartId: string;
436
- 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;
437
530
  };
438
- type RemoveDiscountParams = {
439
- cartId: string;
531
+ type CreateOrderParams = WithIdempotencyKey<CreateOrderBodyBase & CreateOrderLineItemsInput>;
532
+ type UpdateOrderParams = {
533
+ orderNumber: string;
534
+ status: 'confirmed';
440
535
  };
441
- type ClearCartParams = {
442
- 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;
443
544
  };
444
- declare class CartApi {
445
- private readonly publishableKey;
446
- private readonly secretKey?;
447
- private readonly apiUrl?;
448
- private readonly customerToken?;
449
- private readonly onUnauthorized?;
450
- private readonly onRequestId?;
451
- constructor(options: CartApiOptions);
452
- private execute;
453
- getCart(cartId: string): Promise<Cart>;
454
- addItem(params: AddItemParams): Promise<CartItem>;
455
- updateItem(params: UpdateItemParams): Promise<CartItem>;
456
- removeItem(params: RemoveItemParams): Promise<{
457
- success: boolean;
458
- }>;
459
- applyDiscount(params: ApplyDiscountParams): Promise<Cart>;
460
- removeDiscount(params: RemoveDiscountParams): Promise<Cart>;
461
- clearCart(params: ClearCartParams): Promise<{
462
- success: boolean;
463
- }>;
464
- }
465
-
466
- type NormalizedOptionSwatch<TMedia = unknown> = {
467
- type: 'color' | 'media' | null;
468
- color?: string | null;
469
- mediaItemId?: string | number | null;
470
- /** Inlined swatch media when the API populated mediaItemId before pool indexing. */
471
- 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;
472
567
  };
473
- declare function selectedSwatchMediaItemId(swatch: NormalizedOptionSwatch | null | undefined): string | null;
474
- type ProductSelectionMediaSource = 'variant_media_selected' | 'variant_media_matching' | 'option_swatch' | 'none';
475
- type ProductDisplayMediaSource = 'listing_primary' | 'product_primary' | 'product_pool' | 'none';
476
- /** @deprecated Use {@link ProductSelectionMediaSource} or {@link ProductDisplayMediaSource}. */
477
- type ProductMediaResolutionSource = ProductSelectionMediaSource | ProductDisplayMediaSource;
478
- type ProductSelectionVariant<TMedia> = {
479
- id?: string | number | null;
480
- 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;
481
573
  };
482
- type ProductSelectionOptionValue = {
483
- id?: string | number | null;
484
- swatch?: NormalizedOptionSwatch<unknown> | null;
574
+ type CancelOrderUnpaidCommittedResponseFields = {
575
+ refundedAmount: 0;
576
+ providerRefunded: false;
485
577
  };
486
- type ProductSelectionMediaPointer = string | number | {
487
- id?: string | number | null;
488
- } | null;
489
- type ResolveProductSelectionMediaInput<TMedia> = {
490
- productMediaPool?: TMedia[] | null;
491
- productPrimaryMediaItemId?: ProductSelectionMediaPointer;
492
- selectedVariant?: ProductSelectionVariant<TMedia> | null;
493
- matchingVariants?: Array<ProductSelectionVariant<TMedia> | null | undefined> | null;
494
- selectedOptionValues?: Array<ProductSelectionOptionValue | null | undefined> | null;
578
+ type CancelOrderPaidCommittedResponseFields = {
579
+ transactionId: string;
580
+ refundedAmount: 0;
581
+ providerRefunded: false;
582
+ refundPending: true;
495
583
  };
496
- type ResolveProductSelectionMediaResult<TMedia> = {
497
- primaryImage: TMedia | null;
498
- images: TMedia[];
499
- source: ProductSelectionMediaSource;
584
+ type CancelOrderLegacyProviderRefundResponseFields = {
585
+ transactionId: string;
586
+ refundedAmount: number;
587
+ refundSeq: number;
588
+ providerRefunded: true;
500
589
  };
501
- type ResolveProductDisplayMediaInput<TMedia> = {
502
- productMediaPool?: TMedia[] | null;
503
- productPrimaryMediaItemId?: ProductSelectionMediaPointer;
504
- listingPrimaryImage?: ProductSelectionMediaPointer;
590
+ type CancelOrderAlreadyCanceledResponseFields = {
591
+ refundedAmount: number;
592
+ providerRefunded: false;
505
593
  };
506
- type ResolveProductDisplayMediaResult<TMedia> = {
507
- primaryImage: TMedia | null;
508
- images: TMedia[];
509
- source: ProductDisplayMediaSource;
594
+ type CancelOrderAlreadyCanceledRefundPendingResponseFields = {
595
+ transactionId: string;
596
+ refundedAmount: number;
597
+ providerRefunded: false;
598
+ refundPending: true;
510
599
  };
511
- declare function resolveProductSelectionMedia<TMedia>(input: ResolveProductSelectionMediaInput<TMedia>): ResolveProductSelectionMediaResult<TMedia>;
512
- declare function resolveProductDisplayMedia<TMedia>(input: ResolveProductDisplayMediaInput<TMedia>): ResolveProductDisplayMediaResult<TMedia>;
513
- type ListingPrimaryImageFallbackInput<TMedia> = {
514
- productMediaPool?: TMedia[] | null;
515
- productPrimaryMediaItemId?: ProductSelectionMediaPointer;
516
- productThumbnail?: TMedia | string | number | null;
517
- listingPrimaryImage?: TMedia | string | number | null;
518
- resolvedPrimary?: TMedia | null;
519
- resolvedSource?: ProductMediaResolutionSource;
600
+ type CancelOrderPaidCommittedResponse = CancelOrderResponseBase & CancelOrderPaidCommittedResponseFields & {
601
+ status: 'canceled';
602
+ cancelCommitted: true;
520
603
  };
521
- declare function resolveListingPrimaryImagePointer<TMedia>(input: ListingPrimaryImageFallbackInput<TMedia>): string | null;
522
-
523
- type EntityID = string;
524
- type RelationshipValue = string | number | null | undefined | {
525
- id?: string | number | null;
604
+ type CancelOrderUnpaidCommittedResponse = CancelOrderResponseBase & CancelOrderUnpaidCommittedResponseFields & {
605
+ status: 'canceled';
606
+ cancelCommitted: true;
526
607
  };
527
- type MediaValue = ProductDetailMedia | null | undefined;
528
-
529
- /** Raw Payload / REST swatch before strict public normalization. */
530
- type ProductOptionValueSwatchInput = {
531
- type?: 'color' | 'media' | null;
532
- color?: string | null;
533
- mediaItemId?: RelationshipValue;
608
+ type CancelOrderCommittedResponse = CancelOrderPaidCommittedResponse | CancelOrderUnpaidCommittedResponse;
609
+ type CancelOrderAlreadyCanceledResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledResponseFields & {
610
+ status: 'canceled';
611
+ cancelCommitted: false;
612
+ alreadyCanceled: true;
534
613
  };
535
- interface ProductOptionValueShape {
536
- id?: string | number | null;
537
- option?: RelationshipValue;
538
- value?: string | null;
539
- slug?: string | null;
540
- swatch?: ProductOptionValueSwatch | ProductOptionValueSwatchInput | null;
541
- _order?: string | null;
542
- '_product-option-values_values_order'?: string | null;
543
- }
544
- interface ProductOptionShape {
545
- id?: string | number | null;
546
- title?: string | null;
547
- slug?: string | null;
548
- _order?: string | null;
549
- '_product-options_options_order'?: string | null;
550
- values?: {
551
- docs?: unknown[];
552
- } | null;
553
- }
554
- interface ProductVariantShape {
555
- id?: string | number | null;
556
- optionValues?: unknown[] | null;
557
- price?: number | null;
558
- compareAtPrice?: number | null;
559
- stock?: number | null;
560
- reservedStock?: number | null;
561
- isUnlimited?: boolean | null;
562
- isActive?: boolean | null;
563
- thumbnail?: MediaValue;
564
- images?: MediaValue[] | null;
565
- _order?: string | null;
566
- }
567
- interface ProductListingProductShape {
568
- id?: EntityID;
569
- thumbnail?: MediaValue;
570
- primaryMediaItemId?: MediaValue;
571
- images?: MediaValue[] | null;
572
- listing?: {
573
- primaryImage?: MediaValue;
574
- } | null;
575
- }
576
- type ProductOptionMatrixValue = {
577
- id: string;
578
- optionId: string;
579
- optionSlug: string;
580
- label: string;
581
- slug: string | null;
582
- swatch: ProductOptionValueSwatch;
583
- order: string;
614
+ type CancelOrderAlreadyCanceledRefundPendingResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledRefundPendingResponseFields & {
615
+ status: 'canceled';
616
+ cancelCommitted: false;
617
+ alreadyCanceled: true;
584
618
  };
585
- type ProductOptionMatrixOption = {
586
- id: string;
587
- title: string;
588
- slug: string;
589
- order: string;
590
- 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;
591
624
  };
592
- type ProductOptionMatrixVariant<TVariant extends ProductVariantShape = ProductVariantShape> = {
593
- id: string;
594
- optionValueIds: string[];
595
- optionValueByOptionId: Map<string, string>;
596
- optionValueByOptionSlug: Map<string, string>;
597
- source: TVariant;
625
+ type CancelOrderResponse = CancelOrderCommittedResponse | CancelOrderAlreadyCanceledResponse | CancelOrderAlreadyCanceledRefundPendingResponse | CancelOrderReconciliationResponse;
626
+ type CancelOrderParams = {
627
+ orderNumber: string;
628
+ reasonCode?: CancelReasonCode;
629
+ reasonDetail?: string;
630
+ idempotencyKey?: string;
598
631
  };
599
- type ProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape> = {
600
- options: ProductOptionMatrixOption[];
601
- optionIds: string[];
602
- optionSlugs: string[];
603
- optionById: Map<string, ProductOptionMatrixOption>;
604
- optionBySlug: Map<string, ProductOptionMatrixOption>;
605
- valueById: Map<string, ProductOptionMatrixValue>;
606
- valueToOptionId: Map<string, string>;
607
- valueToOptionSlug: Map<string, string>;
608
- 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;
609
640
  };
610
- type ProductListingProjection = {
611
- selectionHintVariant: EntityID | null;
612
- primaryImage: EntityID | null;
613
- minPrice: number | null;
614
- maxPrice: number | null;
615
- minCompareAtPrice: number | null;
616
- maxCompareAtPrice: number | null;
617
- isPriceRange: boolean;
618
- availableForSale: boolean;
641
+ type ResolveCancelRefundFailedParams = {
642
+ orderNumber: string;
643
+ idempotencyKey: string;
644
+ outcome: 'failed';
645
+ refundedAmount: 0;
646
+ pgProvider: string;
647
+ pgRefundId?: string;
619
648
  };
620
- type ProductListingGroup<TVariant extends ProductVariantShape = ProductVariantShape> = {
621
- optionId: EntityID;
622
- optionTitle: string;
623
- optionSlug: string;
624
- optionValueId: EntityID;
625
- optionValueLabel: string;
626
- optionValueSlug: string | null;
627
- optionValueSwatch: ProductOptionValueSwatch;
628
- variantIds: EntityID[];
629
- variantCount: number;
630
- variants: TVariant[];
631
- 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';
632
657
  };
633
- type ProductListingCardPriceRange = {
634
- minPrice: number | null;
635
- maxPrice: number | null;
636
- minCompareAtPrice: number | null;
637
- maxCompareAtPrice: number | null;
638
- isPriceRange: boolean;
658
+ type ResolveCancelRefundFailedResponse = {
659
+ orderId: string;
660
+ transactionId: string;
661
+ refundTransactionId: string;
662
+ refundedAmount: 0;
663
+ refundStatus: 'failed';
664
+ transactionStatus: 'paid';
639
665
  };
640
- type ProductListingSwatch = {
641
- optionId: EntityID;
642
- optionValueId: EntityID;
643
- label: string;
644
- swatch: ProductOptionValueSwatch<ProductDetailMedia>;
645
- href: string;
646
- availableForSale: boolean;
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;
647
673
  };
648
- type ProductListingCardRepresentativeVariant = ProductListingGroupsItem['groups'][number]['variants'][number];
649
- type ProductListingCard = {
650
- id: EntityID;
651
- href: string;
652
- title: string;
653
- representativeVariant?: ProductListingCardRepresentativeVariant | null;
654
- primaryImage: ProductDetailMedia | null;
655
- priceRange: ProductListingCardPriceRange;
656
- availableForSale: boolean;
657
- swatches: ProductListingSwatch[];
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;
658
706
  };
659
- type ProductSelectionByOptionValue = string | number | null | undefined | {
660
- valueId?: string | number | null;
661
- valueSlug?: string | null;
707
+ type PrepareFulfillmentOrderResponse = {
708
+ orderId: string;
709
+ fulfillmentOrders: Array<{
710
+ id: string;
711
+ status: string;
712
+ }>;
662
713
  };
663
- type ProductSelectionInput = {
664
- variantId?: string | number | null;
665
- byOptionSlug?: Record<string, ProductSelectionByOptionValue>;
666
- byOptionId?: Record<string, ProductSelectionByOptionValue>;
667
- valueIds?: Iterable<unknown>;
668
- search?: string | URLSearchParams | URL | null;
714
+ type UpdateFulfillmentParams = {
715
+ fulfillmentId: string;
716
+ status?: 'shipped' | 'delivered' | 'failed';
717
+ carrier?: string;
718
+ trackingNumber?: string;
669
719
  };
670
- type NormalizedProductSelection = {
671
- byOptionSlug: Record<string, string>;
672
- byOptionId: Record<string, string>;
673
- valueIds: string[];
674
- variantId: string | null;
720
+ type BulkImportFulfillmentsParams = {
721
+ items: Array<{
722
+ orderNumber: string;
723
+ carrier: string;
724
+ trackingNumber: string;
725
+ }>;
675
726
  };
676
- type CompatibilityProductSelectionParamEvent = {
677
- optionId: string;
678
- optionSlug: string;
679
- valueSlug: string;
680
- searchParam: string;
727
+ type BulkImportFulfillmentsResponse = {
728
+ succeeded: Array<{
729
+ orderNumber: string;
730
+ fulfillmentId: string;
731
+ }>;
732
+ failed: Array<{
733
+ orderNumber: string;
734
+ error: string;
735
+ }>;
681
736
  };
682
- type LegacyProductSelectionParamEvent = CompatibilityProductSelectionParamEvent;
683
- type ProductSelectionUrlEmit = 'slug-compat' | 'canonical-id';
684
- type ProductSelectionCodecOptions = {
685
- emit?: ProductSelectionUrlEmit;
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;
746
+ }>;
747
+ type UpdateReturnParams = {
748
+ returnId: string;
749
+ status: 'processing' | 'approved' | 'rejected' | 'completed';
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 {
686
818
  /**
687
- * When true, `resolveProductSelection()` fills unselected options to reach a
688
- * concrete variant. Does not change codec parse/stringify behavior.
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.
689
826
  */
690
- fillDefaults?: boolean;
691
- onCompatibilityOptionIdParam?: (event: CompatibilityProductSelectionParamEvent) => void;
692
- onLegacyOptionIdParam?: (event: LegacyProductSelectionParamEvent) => void;
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
+ /**
835
+ * Customer authentication client.
836
+ *
837
+ * Manages customer registration, login, logout, and token lifecycle.
838
+ * All requests include X-Publishable-Key for tenant resolution.
839
+ */
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
+ }
910
+
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;
925
+ };
926
+ type UpdateItemParams = {
927
+ cartItemId: string;
928
+ quantity: number;
929
+ };
930
+ type RemoveItemParams = {
931
+ cartItemId: string;
932
+ };
933
+ type ApplyDiscountParams = {
934
+ cartId: string;
935
+ discountCode: string;
936
+ };
937
+ type RemoveDiscountParams = {
938
+ cartId: string;
939
+ };
940
+ type ClearCartParams = {
941
+ cartId: string;
942
+ };
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;
954
+ };
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;
996
+ };
997
+ items?: PublicCartItem[];
998
+ };
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;
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;
1021
+ };
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;
1030
+ };
1031
+ type ProductSelectionOptionValue = {
1032
+ id?: string | number | null;
1033
+ swatch?: NormalizedOptionSwatch<unknown> | null;
1034
+ };
1035
+ type ProductSelectionMediaPointer = string | number | {
1036
+ id?: string | number | null;
1037
+ } | 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;
693
1044
  };
694
- type ProductSelectionResolutionContext = {
695
- detail?: Pick<ProductDetail, 'images' | 'listing' | 'primaryMediaItemId'>;
696
- images?: ProductDetail['images'];
697
- listing?: ProductDetail['listing'];
698
- primaryMediaItemId?: ProductDetail['primaryMediaItemId'];
1045
+ type ResolveProductSelectionMediaResult<TMedia> = {
1046
+ primaryImage: TMedia | null;
1047
+ images: TMedia[];
1048
+ source: ProductSelectionMediaSource;
699
1049
  };
700
- type ProductSelectionAvailableSwatch = {
701
- color?: string | null;
702
- image?: MediaValue | null;
1050
+ type ResolveProductDisplayMediaInput<TMedia> = {
1051
+ productMediaPool?: TMedia[] | null;
1052
+ productPrimaryMediaItemId?: ProductSelectionMediaPointer;
1053
+ listingPrimaryImage?: ProductSelectionMediaPointer;
703
1054
  };
704
- type ProductSelectionAvailableValue = {
705
- valueId: string;
706
- value: string;
707
- label: string;
708
- slug: string;
709
- selected: boolean;
710
- available: boolean;
711
- exists: boolean;
712
- availableForSale: boolean;
713
- isUnlimited: boolean;
714
- availableStock: number | null;
715
- swatch: ProductOptionValueSwatch;
1055
+ type ResolveProductDisplayMediaResult<TMedia> = {
1056
+ primaryImage: TMedia | null;
1057
+ images: TMedia[];
1058
+ source: ProductDisplayMediaSource;
716
1059
  };
717
- type ProductSelectionResolution = {
718
- normalizedSelection: NormalizedProductSelection;
719
- selectedVariant: ProductDetailVariant | null;
720
- matchingVariants: ProductDetailVariant[];
721
- partialVariants: ProductDetailVariant[];
722
- availableValuesByOptionSlug: Record<string, ProductSelectionAvailableValue[]>;
723
- availableValuesByOptionId: Record<string, ProductSelectionAvailableValue[]>;
724
- allOptionsSelected: boolean;
725
- price: {
726
- min: number | null;
727
- max: number | null;
728
- compareAtMin: number | null;
729
- compareAtMax: number | null;
730
- isRange: boolean;
731
- };
732
- media: {
733
- primaryImage: ProductDetailMedia | null;
734
- images: ProductDetailMedia[];
735
- source?: ProductMediaResolutionSource;
736
- };
737
- stock: {
738
- availableForSale: boolean;
739
- isUnlimited: boolean;
740
- stock: number | null;
741
- reservedStock: number | null;
742
- availableStock: number | null;
743
- };
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;
744
1069
  };
745
- declare class ProductSelectionCodecError extends Error {
746
- code: string;
747
- constructor(message: string);
748
- }
749
- declare function buildProductOptionMatrix<TVariant extends ProductVariantShape = ProductVariantShape>({ options, variants, }: {
750
- options: ProductOptionShape[];
751
- variants?: TVariant[];
752
- }): ProductOptionMatrix<TVariant>;
753
- declare function buildProductOptionMatrixFromDetail(detail: ProductDetail): ProductOptionMatrix<ProductDetailVariant>;
754
- declare function getSelectedValueByOptionId<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): Map<string, string>;
755
- declare function normalizeSelectedValueIds<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): string[];
756
- declare function getAvailableOptionValues<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, optionId: string, selectedValueIds: Iterable<unknown>): ProductOptionMatrixValue[];
757
- declare function resolveVariantForSelection<TVariant extends ProductVariantShape = ProductVariantShape>(matrix: ProductOptionMatrix<TVariant>, selectedValueIds: Iterable<unknown>): ProductOptionMatrixVariant<TVariant> | undefined;
758
- declare function normalizeProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
759
- declare function normalizeProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
760
- declare function parseProductSelection(detail: ProductDetail, search: string | URLSearchParams | URL | null | undefined, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
761
- declare function stringifyProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): string;
762
- declare function createProductSelectionCodec(detail: ProductDetail, options?: ProductSelectionCodecOptions): {
763
- parse: (search: string | URLSearchParams | URL | null | undefined) => NormalizedProductSelection;
764
- stringify: (selection?: ProductSelectionInput) => 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;
765
1075
  };
766
- declare function resolveProductSelectionFromMatrix(matrix: ProductOptionMatrix<ProductDetailVariant>, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions, context?: ProductSelectionResolutionContext): ProductSelectionResolution;
767
- declare function resolveProductSelection(detail: ProductDetail, selection?: ProductSelectionInput, options?: ProductSelectionCodecOptions): ProductSelectionResolution;
768
- declare function selectNext(detail: ProductDetail, current: ProductSelectionInput | undefined, optionSlug: string, valueSlug: string, options?: ProductSelectionCodecOptions): NormalizedProductSelection;
769
- type ProductDetailImageMedia = Extract<ProductDetailMedia, {
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 {
770
1085
  id?: string | number | null;
771
- url?: string | null;
772
- }>;
773
- declare function getProductSelectionImages(resolution: Pick<ProductSelectionResolution, 'media'>): ProductDetailImageMedia[];
774
- type ProductHrefProduct = ProductDetail | {
1086
+ option?: RelationshipValue;
1087
+ value?: string | null;
775
1088
  slug?: string | null;
776
- product?: {
777
- slug?: string | null;
1089
+ swatch?: ProductOptionValueSwatch | ProductOptionValueSwatchInput | null;
1090
+ _order?: string | null;
1091
+ '_product-option-values_values_order'?: string | null;
1092
+ }
1093
+ interface ProductOptionShape {
1094
+ id?: string | number | null;
1095
+ title?: string | null;
1096
+ slug?: string | null;
1097
+ _order?: string | null;
1098
+ '_product-options_options_order'?: string | null;
1099
+ values?: {
1100
+ docs?: unknown[];
778
1101
  } | null;
779
- };
780
- type ProductHrefGroup = {
781
- optionId?: string | number | null;
782
- optionSlug?: string | null;
783
- optionValueId?: string | number | null;
784
- optionValueSlug?: string | null;
785
- variantId?: string | number | null;
1102
+ }
1103
+ interface ProductVariantShape {
1104
+ id?: string | number | null;
1105
+ optionValues?: unknown[] | null;
1106
+ price?: number | null;
1107
+ compareAtPrice?: number | null;
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;
1115
+ }
1116
+ interface ProductListingProductShape {
1117
+ id?: EntityID;
1118
+ thumbnail?: MediaValue;
1119
+ primaryMediaItemId?: MediaValue;
1120
+ images?: MediaValue[] | null;
786
1121
  listing?: {
787
- selectionHintVariant?: string | number | null;
1122
+ primaryImage?: MediaValue;
788
1123
  } | null;
1124
+ }
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;
789
1133
  };
790
- type ProductHrefOptions = {
791
- basePath?: string;
792
- detail?: ProductDetail;
793
- matrix?: ProductOptionMatrix<ProductDetailVariant>;
794
- selection?: ProductSelectionInput;
795
- trailingSlash?: boolean;
796
- emit?: ProductSelectionUrlEmit;
797
- preferCompleteVariantFromHint?: boolean;
798
- };
799
- type ProductListingCardOptions = {
800
- basePath?: string;
801
- trailingSlash?: boolean;
802
- emit?: ProductSelectionUrlEmit;
803
- preferCompleteVariantFromHint?: boolean;
804
- };
805
- declare function buildProductHref(product: ProductHrefProduct, group?: ProductHrefGroup | null, options?: ProductHrefOptions): string;
806
- declare function buildProductListingProjection(product: ProductListingProductShape | null | undefined, variants: ProductVariantShape[]): ProductListingProjection;
807
- declare function buildProductListingCard(item: ProductListingGroupsItem, options?: ProductListingCardOptions): ProductListingCard;
808
- /** Shopify `priceRangeV2` naming for persisted listing projection fields. */
809
- declare function toShopifyPriceRangeV2(listing: {
810
- minPrice?: number | null;
811
- maxPrice?: number | null;
812
- }): {
813
- minVariantPrice: {
814
- amount: number | null;
815
- };
816
- maxVariantPrice: {
817
- amount: number | null;
818
- };
1134
+ type ProductOptionMatrixOption = {
1135
+ id: string;
1136
+ title: string;
1137
+ slug: string;
1138
+ order: string;
1139
+ values: ProductOptionMatrixValue[];
819
1140
  };
820
- /**
821
- * Builds product-first listing groups for one primary option.
822
- *
823
- * The returned groups are intended for product cards with nested swatches or
824
- * option-value sections. They do not make a product-paginated API response into
825
- * an expanded-card paginator; one product can still emit several groups.
826
- */
827
- declare function buildProductListingGroupsByOption<TVariant extends ProductVariantShape = ProductVariantShape>(args: {
828
- product: ProductListingProductShape | null | undefined;
829
- options: ProductOptionShape[];
830
- variants: TVariant[];
831
- primaryOptionId?: string | null;
832
- }): ProductListingGroup<TVariant>[];
833
-
834
- type ProductApiOptions = ServerApiOptions;
835
- type StockCheckParams = {
836
- items: Array<{
837
- variantId: string;
838
- quantity: number;
839
- }>;
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;
840
1147
  };
841
- type StockCheckResult = {
842
- variantId: string;
843
- status: 'available' | 'not_published' | 'archived' | 'not_found';
844
- available: boolean;
845
- availableStock: number;
846
- isUnlimited: boolean;
847
- requestedQuantity: number;
848
- error?: string;
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>[];
849
1158
  };
850
- type StockCheckResponse = {
851
- results: StockCheckResult[];
852
- allAvailable: boolean;
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;
853
1168
  };
854
- type ListingGroupsParams = {
855
- productIds: string[];
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;
856
1181
  };
857
- type ProductListingGroupVariant = Pick<ProductVariantShape, 'id' | 'optionValues' | 'price' | 'compareAtPrice' | 'stock' | 'isUnlimited' | 'isActive' | 'thumbnail' | 'images' | '_order'>;
858
- type ProductListingGroupSummary = ProductListingGroup<ProductListingGroupVariant>;
859
- type ProductListingGroupsProductVariants = NonNullable<PublicProduct['variants']>;
860
- type ProductListingGroupsProductPrimaryMediaItemId = string | number | {
861
- id?: string | number | null;
862
- } | null;
863
- type ProductListingGroupsProduct = Omit<PublicProduct, 'variants'> & {
864
- id: string;
865
- slug: string;
866
- title: string;
867
- primaryMediaItemId?: ProductListingGroupsProductPrimaryMediaItemId;
868
- variants?: (Omit<ProductListingGroupsProductVariants, 'docs'> & {
869
- docs: ProductListingGroupVariant[];
870
- }) | null;
1182
+ type ProductListingCardPriceRange = {
1183
+ minPrice: number | null;
1184
+ maxPrice: number | null;
1185
+ minCompareAtPrice: number | null;
1186
+ maxCompareAtPrice: number | null;
1187
+ isPriceRange: boolean;
871
1188
  };
872
- type ProductListingGroupsItem = {
873
- product: ProductListingGroupsProduct;
874
- groups: ProductListingGroupSummary[];
1189
+ type ProductListingSwatch = {
1190
+ optionId: EntityID;
1191
+ optionValueId: EntityID;
1192
+ label: string;
1193
+ swatch: ProductOptionValueSwatch<ProductDetailMedia>;
1194
+ href: string;
1195
+ availableForSale: boolean;
875
1196
  };
876
- type ProductListingGroupsResponse = {
877
- /**
878
- * Matching products in the same order as the requested productIds, excluding
879
- * ids that were not found, not published, or not accessible for the current
880
- * tenant/key.
881
- */
882
- docs: ProductListingGroupsItem[];
883
- /** Requested productIds that could not be returned. */
884
- missing: string[];
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[];
885
1207
  };
886
- type ProductDetailParams = {
887
- slug: string;
888
- } | {
889
- id: string;
1208
+ type ProductSelectionByOptionValue = string | number | null | undefined | {
1209
+ valueId?: string | number | null;
1210
+ valueSlug?: string | null;
890
1211
  };
891
- type ProductDetailPreviewParams = {
892
- id: 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;
893
1218
  };
894
- type ProductDetailPreviewOptions = {
895
- previewToken: string;
1219
+ type NormalizedProductSelection = {
1220
+ byOptionSlug: Record<string, string>;
1221
+ byOptionId: Record<string, string>;
1222
+ valueIds: string[];
1223
+ variantId: string | null;
896
1224
  };
897
- interface ProductDetailVariantOptionValue {
898
- optionId: string | number;
1225
+ type CompatibilityProductSelectionParamEvent = {
1226
+ optionId: string;
899
1227
  optionSlug: string;
900
- valueId: string | number;
901
1228
  valueSlug: string;
902
- value?: string | null;
903
- }
904
- type ProductDetailMedia = string | number | {
905
- id?: string | number | null;
906
- url?: string | null;
907
- alt?: string | null;
908
- width?: number | null;
909
- height?: number | null;
1229
+ searchParam: string;
910
1230
  };
911
- type ProductOptionValueColorSwatch = {
912
- type: 'color';
913
- color: string;
914
- mediaItemId?: null;
1231
+ type LegacyProductSelectionParamEvent = CompatibilityProductSelectionParamEvent;
1232
+ type ProductSelectionUrlEmit = 'slug-compat' | 'canonical-id';
1233
+ type ProductSelectionCodecOptions = {
1234
+ emit?: ProductSelectionUrlEmit;
1235
+ /**
1236
+ * When true, `resolveProductSelection()` fills unselected options to reach a
1237
+ * concrete variant. Does not change codec parse/stringify behavior.
1238
+ */
1239
+ fillDefaults?: boolean;
1240
+ onCompatibilityOptionIdParam?: (event: CompatibilityProductSelectionParamEvent) => void;
1241
+ onLegacyOptionIdParam?: (event: LegacyProductSelectionParamEvent) => void;
915
1242
  };
916
- type ProductOptionValueMediaSwatch<TMedia = ProductDetailMedia> = {
917
- type: 'media';
918
- mediaItemId: TMedia;
919
- color?: null;
1243
+ type ProductSelectionResolutionContext = {
1244
+ detail?: Pick<ProductDetail, 'images' | 'listing' | 'primaryMediaItemId'>;
1245
+ images?: ProductDetail['images'];
1246
+ listing?: ProductDetail['listing'];
1247
+ primaryMediaItemId?: ProductDetail['primaryMediaItemId'];
920
1248
  };
921
- type ProductOptionValueSwatch<TMedia = ProductDetailMedia> = ProductOptionValueColorSwatch | ProductOptionValueMediaSwatch<TMedia> | null;
922
- type ProductUpsertSwatchInput = ProductOptionValueColorSwatch | ProductOptionValueMediaSwatch<string>;
923
- type ProductDetailMediaValue = string | number | ProductDetailMedia | null;
924
- type ProductDetailSelectionMediaSource = 'variant_media_selected' | 'variant_media_matching' | 'option_swatch' | 'none';
925
- interface ProductDetailVariant {
926
- id: string | number;
927
- optionKey: string;
928
- title?: string | null;
929
- displayName: string;
930
- sku?: string | null;
931
- price: number;
932
- compareAtPrice?: number | null;
933
- stock: number;
934
- reservedStock: number;
935
- isUnlimited: boolean;
936
- isActive: boolean;
937
- thumbnail?: ProductDetailMedia | null;
938
- images?: ProductDetailMedia[];
939
- media?: {
940
- primaryImage: ProductDetailMedia | null;
941
- images: ProductDetailMedia[];
942
- source: ProductDetailSelectionMediaSource;
943
- };
944
- optionValues: ProductDetailVariantOptionValue[];
945
- }
946
- interface ProductDetailOptionValue {
947
- id: string | number;
1249
+ type ProductSelectionAvailableSwatch = {
1250
+ color?: string | null;
1251
+ image?: MediaValue | null;
1252
+ };
1253
+ type ProductSelectionAvailableValue = {
1254
+ valueId: string;
948
1255
  value: string;
1256
+ label: string;
949
1257
  slug: string;
950
- swatch?: ProductOptionValueSwatch<ProductDetailMedia>;
951
- }
952
- interface ProductDetailOption {
953
- id: string | number;
954
- title: string;
955
- slug: string;
956
- values: ProductDetailOptionValue[];
957
- }
958
- interface ProductDetailBrand {
959
- id: string | number;
960
- name: string;
961
- slug?: string | null;
962
- logo?: unknown | null;
963
- }
964
- interface ProductDetailCategory {
965
- id: string | number;
966
- title: string;
967
- slug?: string | null;
968
- }
969
- interface ProductDetailTag {
970
- id: string | number;
971
- title: string;
972
- slug?: string | null;
973
- }
974
- interface ProductDetailImage {
975
- id: string | number;
976
- url?: string | null;
977
- alt?: string | null;
978
- width?: number | null;
979
- height?: number | null;
980
- }
981
- interface ProductDetailVideo {
982
- id: string | number;
983
- url?: string | null;
984
- }
985
- interface ProductDetailListing {
986
- minPrice?: number | null;
987
- maxPrice?: number | null;
988
- minCompareAtPrice?: number | null;
989
- maxCompareAtPrice?: number | null;
990
- isPriceRange?: boolean | null;
991
- primaryImage?: ProductDetailMedia | null;
992
- availableForSale?: boolean | null;
993
- selectionHintVariant?: string | number | null;
994
- }
995
- type ProductDetailCatalogVariant = Omit<ProductDetailVariant, 'stock' | 'reservedStock'>;
996
- type ProductDetailCatalogListing = Omit<ProductDetailListing, 'availableForSale'> & {
997
- liveStockRequired: true;
998
- };
999
- interface ProductDetailCatalog {
1000
- product: Omit<ProductDetail['product'], 'totalInventory'>;
1001
- variants: ProductDetailCatalogVariant[];
1002
- options: ProductDetail['options'];
1003
- brand: ProductDetail['brand'];
1004
- categories: ProductDetail['categories'];
1005
- tags: ProductDetail['tags'];
1006
- images: ProductDetail['images'];
1007
- videos: ProductDetail['videos'];
1008
- primaryMediaItemId?: ProductDetail['primaryMediaItemId'];
1009
- listing: ProductDetailCatalogListing;
1010
- }
1011
- type StockSnapshotItemStatus = 'available' | 'not_published' | 'archived' | 'not_found';
1012
- interface StockSnapshotItem {
1013
- variantId: string;
1014
- status: StockSnapshotItemStatus;
1015
- availableStock: number;
1258
+ selected: boolean;
1259
+ available: boolean;
1260
+ exists: boolean;
1016
1261
  availableForSale: boolean;
1017
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 {
1295
+ code: string;
1296
+ constructor(message: string);
1018
1297
  }
1019
- interface StockSnapshotResponse {
1020
- snapshots: StockSnapshotItem[];
1021
- }
1022
- type StockSnapshotParams = {
1023
- variantIds: string[];
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;
1024
1314
  };
1025
- interface ProductDetail {
1026
- product: {
1027
- id: string | number;
1028
- slug: string;
1029
- title: string;
1030
- subtitle?: string | null;
1031
- description?: string | null;
1032
- content?: unknown;
1033
- publishedAt?: string | null;
1034
- status: string;
1035
- totalInventory: number | null;
1036
- totalVariants: number;
1037
- hasUnlimitedVariant: boolean;
1038
- hasOnlyDefaultVariant: boolean;
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;
1328
+ };
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;
1338
+ };
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;
1347
+ };
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;
1039
1367
  };
1040
- variants: ProductDetailVariant[];
1041
- options: ProductDetailOption[];
1042
- brand: ProductDetailBrand | null;
1043
- categories: ProductDetailCategory[];
1044
- tags: ProductDetailTag[];
1045
- images: ProductDetailImage[];
1046
- videos: ProductDetailVideo[];
1047
- /** Canonical product primary pointer (pool member). */
1048
- primaryMediaItemId?: ProductDetailMediaValue;
1049
- listing: ProductDetailListing;
1050
- }
1051
- type ProductDetailUnavailableReason = 'not_found' | 'not_published' | 'feature_disabled';
1052
- type ProductDetailResult = {
1053
- found: true;
1054
- product: ProductDetail;
1055
- } | {
1056
- found: false;
1057
- reason: ProductDetailUnavailableReason;
1058
1368
  };
1059
- type ProductDetailCatalogResult = {
1060
- found: true;
1061
- product: ProductDetailCatalog;
1062
- } | {
1063
- found: false;
1064
- reason: ProductDetailUnavailableReason;
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>[];
1412
+
1413
+ type ProductUpsertColorSwatchInput = {
1414
+ type: 'color';
1415
+ color: string;
1416
+ mediaItemId?: null;
1417
+ };
1418
+ type ProductUpsertMediaSwatchInput = {
1419
+ type: 'media';
1420
+ mediaItemId: string;
1421
+ color?: null;
1065
1422
  };
1423
+ type ProductUpsertSwatchInput = ProductUpsertColorSwatchInput | ProductUpsertMediaSwatchInput;
1066
1424
  type ProductUpsertOptionValueInput = {
1067
1425
  id?: string;
1068
1426
  value: string;
@@ -1070,20 +1428,20 @@ type ProductUpsertOptionValueInput = {
1070
1428
  swatch?: ProductUpsertSwatchInput | null;
1071
1429
  metadata?: unknown;
1072
1430
  };
1073
- type ProductUpsertOptionInput = {
1431
+ type OptionValueInput = ProductUpsertOptionValueInput;
1432
+ type OptionInput = {
1074
1433
  id?: string;
1075
1434
  title: string;
1076
1435
  slug?: string;
1077
- values: ProductUpsertOptionValueInput[];
1078
- };
1079
- type ProductUpsertVariantOptionValue = string | {
1080
- valueSlug?: string;
1081
- valueId?: string;
1082
- value?: string;
1436
+ values: OptionValueInput[];
1083
1437
  };
1084
- type ProductUpsertVariantInput = {
1438
+ type VariantInput = {
1085
1439
  id?: string;
1086
- optionValues?: Record<string, ProductUpsertVariantOptionValue> | string[];
1440
+ optionValues?: Record<string, string | {
1441
+ valueSlug?: string;
1442
+ valueId?: string;
1443
+ value?: string;
1444
+ }> | string[];
1087
1445
  sku?: string | null;
1088
1446
  title?: string | null;
1089
1447
  price: number;
@@ -1098,373 +1456,385 @@ type ProductUpsertVariantInput = {
1098
1456
  images?: string[];
1099
1457
  metadata?: unknown;
1100
1458
  };
1101
- type ProductUpsertParams = {
1102
- product: Record<string, unknown> & {
1103
- id?: string;
1104
- title?: string;
1105
- };
1106
- options?: ProductUpsertOptionInput[];
1107
- variants?: ProductUpsertVariantInput[];
1108
- };
1109
- /** Console `POST /api/products/upsert` field allowlist error reasons. */
1110
- declare const PRODUCT_UPSERT_UNKNOWN_FIELD_REASON: "unknown_field";
1111
- declare const PRODUCT_UPSERT_READONLY_FIELD_REASON: "product_field_readonly";
1112
- type ProductUpsertFieldValidationErrorReason = typeof PRODUCT_UPSERT_UNKNOWN_FIELD_REASON | typeof PRODUCT_UPSERT_READONLY_FIELD_REASON;
1113
- /** 400 response body when upsert rejects unknown or server-managed product fields. */
1114
- type ProductUpsertFieldValidationErrorBody = {
1115
- error: string;
1116
- reason: ProductUpsertFieldValidationErrorReason;
1117
- field: string;
1118
- requestId?: string;
1119
- };
1120
- declare function isProductUpsertFieldValidationErrorBody(value: unknown): value is ProductUpsertFieldValidationErrorBody;
1121
- type ProductUpsertResponse = {
1122
- ok: true;
1123
- product: PublicProduct;
1124
- listingProjectionStale: boolean;
1125
- } | {
1126
- ok: false;
1127
- failedEntity: 'product' | 'option' | 'option-value' | 'variant';
1128
- failedIndex?: number;
1129
- message: string;
1130
- };
1131
- declare class ProductApi extends BaseApi {
1132
- constructor(options: ProductApiOptions);
1133
- /**
1134
- * Check point-in-time stock availability for one or more product variants.
1135
- * Results reflect available stock at the moment of the call and are not guaranteed
1136
- * to remain available by the time an order is placed.
1137
- */
1138
- stockCheck(params: StockCheckParams): Promise<StockCheckResponse>;
1139
- stockSnapshot(params: StockSnapshotParams): Promise<StockSnapshotResponse>;
1140
- listingGroups(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
1141
- listingGroupsCatalog(params: ListingGroupsParams): Promise<ProductListingGroupsResponse>;
1142
- /**
1143
- * Fetch full product detail by slug or id.
1144
- * Returns a discriminated result so storefronts can distinguish missing,
1145
- * unpublished, and feature-disabled products.
1146
- *
1147
- * Only product-detail 404 responses carrying one of those allowlisted reasons
1148
- * are mapped to `{ found: false, reason }`. Unknown or uncoded 404s, plus
1149
- * permission/auth errors such as tenant mismatch, continue to throw typed SDK
1150
- * errors instead of being collapsed into a storefront absence result.
1151
- */
1152
- detail(params: ProductDetailParams): Promise<ProductDetailResult>;
1153
- detailCatalog(params: ProductDetailParams): Promise<ProductDetailCatalogResult>;
1154
- /**
1155
- * Atomically create or update a product together with its options,
1156
- * option-values, and variants in a single transaction. Mirrors Shopify's
1157
- * `productSet` shape and is the canonical write path for the MCP
1158
- * `product-upsert` tool.
1159
- */
1160
- upsert(params: ProductUpsertParams): Promise<ProductUpsertResponse>;
1161
- }
1162
-
1163
- type DiscountApiOptions = ServerApiOptions;
1164
- type ValidateDiscountParams = {
1165
- code: string;
1166
- orderAmount: number;
1167
- };
1168
- type ValidateDiscountResult = {
1169
- valid: boolean;
1170
- code: string;
1171
- type?: 'percentage' | 'fixed_amount' | 'free_shipping' | 'tiered';
1172
- discountAmount: number;
1173
- freeShipping?: boolean;
1174
- reason?: string;
1175
- };
1176
- declare class DiscountApi extends BaseApi {
1177
- constructor(options: DiscountApiOptions);
1178
- validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
1179
- }
1180
-
1181
- type ShippingApiOptions = ServerApiOptions;
1182
- type CalculateShippingParams = {
1183
- shippingPolicyId?: string;
1184
- orderAmount: number;
1185
- postalCode?: 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;
1186
1481
  };
1187
- type CalculateShippingResult = {
1188
- shippingAmount: number;
1189
- baseShippingAmount: number;
1190
- extraShippingAmount: number;
1191
- freeShipping: boolean;
1192
- freeShippingMinAmount: number | null;
1193
- isJeju: boolean;
1194
- isRemoteIsland: boolean;
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[];
1195
1487
  };
1196
- declare class ShippingApi extends BaseApi {
1197
- constructor(options: ShippingApiOptions);
1198
- calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
1199
- }
1200
-
1201
- type OrderApiOptions = ServerApiOptions;
1202
- /** Header-only; never sent in the JSON body. */
1203
- type WithIdempotencyKey<T> = T & {
1204
- /**
1205
- * Client-generated key for safe retries. Sent as `X-Idempotency-Key` when the
1206
- * server endpoint supports HTTP idempotency.
1207
- */
1208
- idempotencyKey?: string;
1488
+ /** Create a product document and initial graph. */
1489
+ type ProductUpsertCreateInput = ProductUpsertGraphFields & {
1490
+ productId?: never;
1491
+ product: ProductFieldsInput & {
1492
+ title: string;
1493
+ };
1209
1494
  };
1210
- type CustomerSnapshot = {
1211
- name?: string;
1212
- email: string;
1213
- phone?: string;
1495
+ /** Graph-only update for an existing product (document fields via Payload save). */
1496
+ type ProductUpsertEditInput = ProductUpsertGraphFields & {
1497
+ productId: string;
1498
+ product?: never;
1214
1499
  };
1215
- type ReturnReason = 'change_of_mind' | 'defective' | 'wrong_delivery' | 'damaged' | 'other';
1216
- type ReturnItem = {
1217
- orderItem: string;
1218
- quantity: number;
1500
+ type ProductUpsertInput = ProductUpsertCreateInput | ProductUpsertEditInput;
1501
+
1502
+ type ProductApiOptions = ServerApiOptions;
1503
+ type StockCheckParams = {
1504
+ items: Array<{
1505
+ variantId: string;
1506
+ quantity: number;
1507
+ }>;
1219
1508
  };
1220
- type OrderCreateEntityID = string | number;
1221
- type CreateOrderItem = {
1222
- product: OrderCreateEntityID;
1223
- variant: OrderCreateEntityID;
1224
- option: OrderCreateEntityID;
1225
- quantity: number;
1226
- /**
1227
- * Compatibility input: the create-order endpoint accepts this, but the server
1228
- * derives authoritative line pricing from the product variant.
1229
- */
1230
- unitPrice?: number;
1231
- /**
1232
- * Compatibility input: the create-order endpoint accepts this, but the server
1233
- * derives authoritative line totals from the product variant.
1234
- */
1235
- totalPrice?: number;
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;
1236
1517
  };
1237
- type CreateOrderParams = WithIdempotencyKey<{
1238
- orderNumber: string;
1239
- customer?: string;
1240
- customerSnapshot: CustomerSnapshot;
1241
- shippingAddress: Order['shippingAddress'];
1242
- orderItems: CreateOrderItem[];
1243
- totalAmount: number;
1244
- shippingAmount?: number;
1245
- pgPaymentId?: string;
1246
- discountCode?: string;
1247
- }>;
1248
- type UpdateOrderParams = {
1249
- orderNumber: string;
1250
- status: Order['status'];
1518
+ type StockCheckResponse = {
1519
+ results: StockCheckResult[];
1520
+ allAvailable: boolean;
1251
1521
  };
1252
- type TransactionStatus = 'pending' | 'paid' | 'failed' | 'canceled';
1253
- type UpdateTransactionParams = {
1254
- pgPaymentId: string;
1255
- status: TransactionStatus;
1256
- paymentMethod?: string;
1257
- receiptUrl?: string;
1258
- paymentKey?: string;
1259
- amount?: number;
1522
+ type ListingGroupsParams = {
1523
+ productIds: string[];
1260
1524
  };
1261
- type ConfirmPaymentParams = WithIdempotencyKey<{
1262
- orderNumber?: string;
1263
- pgPaymentId: string;
1264
- pgProvider: string;
1265
- pgOrderId?: string;
1266
- amount: number;
1267
- currency?: string;
1268
- paymentMethod?: string;
1269
- receiptUrl?: string;
1270
- approvedAt?: string;
1271
- providerStatus?: string;
1272
- /** Provider event id; also used as idempotency key when `idempotencyKey` is omitted. */
1273
- providerEventId?: string;
1274
- confirmationSource?: 'provider_webhook' | 'provider_lookup' | 'provider_api_confirm' | 'manual_server';
1275
- metadata?: Record<string, unknown>;
1276
- }>;
1277
- type ConfirmPaymentResponse = {
1278
- orderId: string;
1279
- transactionId: string;
1280
- status: 'paid';
1281
- alreadyConfirmed?: boolean;
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;
1282
1541
  };
1283
- type CancelReasonCode = 'customer' | 'inventory' | 'fraud' | 'declined' | 'staff' | 'other';
1284
- type CancelOrderStatus = 'pending' | 'paid' | 'failed' | 'canceled' | 'refunded' | 'preparing' | 'shipped' | 'delivered' | 'confirmed' | 'return_requested' | 'return_processing' | 'returned';
1285
- type CancelOrderReconciliationStatus = Exclude<CancelOrderStatus, 'pending' | 'failed' | 'canceled'>;
1286
- type CancelOrderResponseBase = {
1287
- orderId: string;
1542
+ type ProductListingGroupsCatalogProduct = Omit<ProductListingGroupsProduct, 'variants'> & {
1543
+ variants?: (Omit<NonNullable<ProductListingGroupsProduct['variants']>, 'docs'> & {
1544
+ docs: ProductListingGroupCatalogVariant[];
1545
+ }) | null;
1288
1546
  };
1289
- type CancelOrderUnpaidCommittedResponseFields = {
1290
- refundedAmount: 0;
1291
- providerRefunded: false;
1547
+ type ProductListingGroupsItem = {
1548
+ product: ProductListingGroupsProduct;
1549
+ groups: ProductListingGroupSummary[];
1292
1550
  };
1293
- type CancelOrderPaidCommittedResponseFields = {
1294
- transactionId: string;
1295
- refundedAmount: 0;
1296
- providerRefunded: false;
1297
- refundPending: true;
1551
+ type ProductListingGroupsCatalogItem = {
1552
+ product: ProductListingGroupsCatalogProduct;
1553
+ groups: ProductListingGroupCatalogSummary[];
1298
1554
  };
1299
- type CancelOrderLegacyProviderRefundResponseFields = {
1300
- transactionId: string;
1301
- refundedAmount: number;
1302
- refundSeq: number;
1303
- providerRefunded: 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[];
1304
1564
  };
1305
- type CancelOrderAlreadyCanceledResponseFields = {
1306
- refundedAmount: number;
1307
- providerRefunded: false;
1565
+ type ProductListingGroupsCatalogResponse = Omit<ProductListingGroupsResponse, 'docs'> & {
1566
+ docs: ProductListingGroupsCatalogItem[];
1308
1567
  };
1309
- type CancelOrderAlreadyCanceledRefundPendingResponseFields = {
1310
- transactionId: string;
1311
- refundedAmount: number;
1312
- providerRefunded: false;
1313
- refundPending: true;
1568
+ type ProductDetailParams = {
1569
+ slug: string;
1570
+ } | {
1571
+ id: string;
1314
1572
  };
1315
- type CancelOrderPaidCommittedResponse = CancelOrderResponseBase & CancelOrderPaidCommittedResponseFields & {
1316
- status: 'canceled';
1317
- cancelCommitted: true;
1573
+ type ProductDetailPreviewParams = {
1574
+ id: string;
1318
1575
  };
1319
- type CancelOrderUnpaidCommittedResponse = CancelOrderResponseBase & CancelOrderUnpaidCommittedResponseFields & {
1320
- status: 'canceled';
1321
- cancelCommitted: true;
1576
+ type ProductDetailPreviewOptions = {
1577
+ previewToken: string;
1322
1578
  };
1323
- type CancelOrderCommittedResponse = CancelOrderPaidCommittedResponse | CancelOrderUnpaidCommittedResponse;
1324
- type CancelOrderAlreadyCanceledResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledResponseFields & {
1325
- status: 'canceled';
1326
- cancelCommitted: false;
1327
- alreadyCanceled: true;
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;
1328
1592
  };
1329
- type CancelOrderAlreadyCanceledRefundPendingResponse = CancelOrderResponseBase & CancelOrderAlreadyCanceledRefundPendingResponseFields & {
1330
- status: 'canceled';
1331
- cancelCommitted: false;
1332
- alreadyCanceled: true;
1593
+ type ProductOptionValueColorSwatch = {
1594
+ type: 'color';
1595
+ color: string;
1596
+ mediaItemId?: null;
1333
1597
  };
1334
- /** @deprecated Inline PG cancel reconciliation; retained for legacy API consumers. */
1335
- type CancelOrderReconciliationResponse = CancelOrderResponseBase & CancelOrderLegacyProviderRefundResponseFields & {
1336
- status: CancelOrderReconciliationStatus;
1337
- cancelCommitted: false;
1338
- reconciliationRequired: true;
1598
+ type ProductOptionValueMediaSwatch<TMedia = ProductDetailMedia> = {
1599
+ type: 'media';
1600
+ mediaItemId: TMedia;
1601
+ color?: null;
1339
1602
  };
1340
- type CancelOrderResponse = CancelOrderCommittedResponse | CancelOrderAlreadyCanceledResponse | CancelOrderAlreadyCanceledRefundPendingResponse | CancelOrderReconciliationResponse;
1341
- type CancelOrderParams = {
1342
- orderNumber: string;
1343
- reasonCode?: CancelReasonCode;
1344
- reasonDetail?: string;
1345
- idempotencyKey?: string;
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;
1346
1679
  };
1347
- type ResolveCancelRefundOutcome = 'succeeded' | 'failed';
1348
- type ResolveCancelRefundSucceededParams = {
1349
- orderNumber: string;
1350
- idempotencyKey: string;
1351
- outcome: 'succeeded';
1352
- refundedAmount: number;
1353
- pgProvider: string;
1354
- pgRefundId: string;
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[];
1355
1705
  };
1356
- type ResolveCancelRefundFailedParams = {
1357
- orderNumber: string;
1358
- idempotencyKey: string;
1359
- outcome: 'failed';
1360
- refundedAmount: 0;
1361
- pgProvider: string;
1362
- pgRefundId?: string;
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;
1363
1739
  };
1364
- type ResolveCancelRefundParams = ResolveCancelRefundSucceededParams | ResolveCancelRefundFailedParams;
1365
- type ResolveCancelRefundSucceededResponse = {
1366
- orderId: string;
1367
- transactionId: string;
1368
- refundTransactionId: string;
1369
- refundedAmount: number;
1370
- refundStatus: 'succeeded';
1371
- transactionStatus: 'refunded';
1740
+ type ProductDetailCatalogResult = {
1741
+ found: true;
1742
+ product: ProductDetailCatalog;
1743
+ } | {
1744
+ found: false;
1745
+ reason: ProductDetailUnavailableReason;
1372
1746
  };
1373
- type ResolveCancelRefundFailedResponse = {
1374
- orderId: string;
1375
- transactionId: string;
1376
- refundTransactionId: string;
1377
- refundedAmount: 0;
1378
- refundStatus: 'failed';
1379
- transactionStatus: 'paid';
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;
1380
1758
  };
1381
- type ResolveCancelRefundResponse = ResolveCancelRefundSucceededResponse | ResolveCancelRefundFailedResponse;
1382
- type RestockAction = 'return_to_stock' | 'discard';
1383
- type ReturnWithRefundItem = {
1384
- orderItem: string | number;
1385
- quantity: number;
1386
- restockAction?: RestockAction;
1387
- restockingFee?: number;
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;
1388
1769
  };
1389
- type ReturnWithRefundParams = WithIdempotencyKey<{
1390
- orderNumber: string;
1391
- reason?: ReturnReason;
1392
- reasonDetail?: string;
1393
- returnItems: ReturnWithRefundItem[];
1394
- refundAmount: number;
1395
- returnShippingFee?: number;
1396
- pgPaymentId: string;
1397
- paymentKey?: string;
1398
- refundReceiptUrl?: string;
1399
- }>;
1400
- type CheckoutParams = WithIdempotencyKey<{
1401
- cartId: string;
1402
- orderNumber: string;
1403
- customerSnapshot: CustomerSnapshot;
1404
- pgPaymentId?: string;
1405
- discountCode?: string;
1406
- }>;
1407
- type CreateFulfillmentParams = WithIdempotencyKey<{
1408
- orderNumber: string;
1409
- carrier?: string;
1410
- trackingNumber?: string;
1411
- items: Array<{
1412
- orderItem: string;
1413
- quantity: number;
1414
- }>;
1415
- }>;
1416
- type UpdateFulfillmentParams = {
1417
- fulfillmentId: string;
1418
- status: 'packed' | 'shipped' | 'delivered' | 'failed';
1419
- carrier?: string;
1420
- trackingNumber?: string;
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;
1421
1806
  };
1422
- type BulkImportFulfillmentsParams = {
1423
- items: Array<{
1424
- orderNumber: string;
1425
- carrier?: string;
1426
- trackingNumber?: string;
1427
- }>;
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;
1428
1814
  };
1429
- type BulkImportFulfillmentsResponse = {
1430
- succeeded: Array<{
1431
- orderNumber: string;
1432
- fulfillmentId: string;
1433
- }>;
1434
- failed: Array<{
1435
- orderNumber: string;
1436
- error: string;
1437
- }>;
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;
1438
1825
  };
1439
- type CreateReturnParams = WithIdempotencyKey<{
1440
- orderNumber: string;
1441
- reason?: ReturnReason;
1442
- reasonDetail?: string;
1443
- returnItems: ReturnItem[];
1444
- refundAmount: number;
1445
- }>;
1446
- type UpdateReturnParams = {
1447
- returnId: string;
1448
- status: 'processing' | 'approved' | 'rejected' | 'completed';
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;
1449
1834
  };
1450
- declare class OrderApi extends BaseApi {
1451
- constructor(options: OrderApiOptions);
1452
- createOrder(params: CreateOrderParams): Promise<Order>;
1453
- updateOrder(params: UpdateOrderParams): Promise<Order>;
1454
- updateTransaction(params: UpdateTransactionParams): Promise<Transaction>;
1455
- confirmPayment(params: ConfirmPaymentParams): Promise<ConfirmPaymentResponse>;
1456
- cancelOrder(params: CancelOrderParams): Promise<CancelOrderResponse>;
1457
- resolveCancelRefund(params: ResolveCancelRefundParams): Promise<ResolveCancelRefundResponse>;
1458
- checkout(params: CheckoutParams): Promise<Order>;
1459
- createFulfillment(params: CreateFulfillmentParams): Promise<Fulfillment>;
1460
- updateFulfillment(params: UpdateFulfillmentParams): Promise<Fulfillment>;
1461
- bulkImportFulfillments(params: BulkImportFulfillmentsParams): Promise<BulkImportFulfillmentsResponse>;
1462
- returnWithRefund(params: ReturnWithRefundParams): Promise<{
1463
- return: Return;
1464
- transaction: Transaction | null;
1465
- }>;
1466
- createReturn(params: CreateReturnParams): Promise<Return>;
1467
- updateReturn(params: UpdateReturnParams): Promise<Return>;
1835
+ declare class ShippingApi extends BaseApi {
1836
+ constructor(options: ShippingApiOptions);
1837
+ calculate(params: CalculateShippingParams): Promise<CalculateShippingResult>;
1468
1838
  }
1469
1839
 
1470
1840
  interface CommerceClientOptions {
@@ -1480,30 +1850,30 @@ declare class CommerceClient {
1480
1850
  stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
1481
1851
  stockSnapshot: (params: StockSnapshotParams) => Promise<StockSnapshotResponse>;
1482
1852
  listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1483
- listingGroupsCatalog: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
1853
+ listingGroupsCatalog: (params: ListingGroupsParams) => Promise<ProductListingGroupsCatalogResponse>;
1484
1854
  detail: (params: ProductDetailParams) => Promise<ProductDetailResult>;
1485
1855
  detailCatalog: (params: ProductDetailParams) => Promise<ProductDetailCatalogResult>;
1486
1856
  };
1487
1857
  readonly cart: {
1488
- get: (cartId: string) => Promise<Cart>;
1489
- addItem: (params: AddItemParams) => Promise<CartItem>;
1490
- updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1858
+ get: (cartId: string) => Promise<PublicCart>;
1859
+ addItem: (params: AddItemParams) => Promise<PublicCartItem>;
1860
+ updateItem: (params: UpdateItemParams) => Promise<PublicCartItem>;
1491
1861
  removeItem: (params: RemoveItemParams) => Promise<{
1492
1862
  success: boolean;
1493
1863
  }>;
1494
- applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1495
- removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1864
+ applyDiscount: (params: ApplyDiscountParams) => Promise<PublicCart>;
1865
+ removeDiscount: (params: RemoveDiscountParams) => Promise<PublicCart>;
1496
1866
  clear: (params: ClearCartParams) => Promise<{
1497
1867
  success: boolean;
1498
1868
  }>;
1499
1869
  };
1500
1870
  readonly orders: {
1501
- checkout: (params: CheckoutParams) => Promise<Order>;
1871
+ checkout: (params: CheckoutParams) => Promise<PublicOrder>;
1502
1872
  listMine: (options?: {
1503
1873
  page?: number;
1504
1874
  limit?: number;
1505
1875
  status?: string;
1506
- }) => Promise<PayloadFindResponse<Order>>;
1876
+ }) => Promise<PayloadFindResponse<PublicOrder>>;
1507
1877
  };
1508
1878
  readonly discounts: {
1509
1879
  validate: (params: ValidateDiscountParams) => Promise<ValidateDiscountResult>;
@@ -1529,20 +1899,20 @@ declare class ServerCommerceClient {
1529
1899
  upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
1530
1900
  };
1531
1901
  readonly cart: {
1532
- get: (cartId: string) => Promise<Cart>;
1533
- addItem: (params: AddItemParams) => Promise<CartItem>;
1534
- updateItem: (params: UpdateItemParams) => Promise<CartItem>;
1902
+ get: (cartId: string) => Promise<PublicCart>;
1903
+ addItem: (params: AddItemParams) => Promise<PublicCartItem>;
1904
+ updateItem: (params: UpdateItemParams) => Promise<PublicCartItem>;
1535
1905
  removeItem: (params: RemoveItemParams) => Promise<{
1536
1906
  success: boolean;
1537
1907
  }>;
1538
- applyDiscount: (params: ApplyDiscountParams) => Promise<Cart>;
1539
- removeDiscount: (params: RemoveDiscountParams) => Promise<Cart>;
1908
+ applyDiscount: (params: ApplyDiscountParams) => Promise<PublicCart>;
1909
+ removeDiscount: (params: RemoveDiscountParams) => Promise<PublicCart>;
1540
1910
  clear: (params: ClearCartParams) => Promise<{
1541
1911
  success: boolean;
1542
1912
  }>;
1543
1913
  };
1544
1914
  readonly orders: {
1545
- checkout: (params: CheckoutParams) => Promise<Order>;
1915
+ checkout: (params: CheckoutParams) => Promise<PublicOrder>;
1546
1916
  create: (params: CreateOrderParams) => Promise<Order>;
1547
1917
  update: (params: UpdateOrderParams) => Promise<Order>;
1548
1918
  updateTransaction: (params: UpdateTransactionParams) => Promise<Transaction>;
@@ -1550,6 +1920,7 @@ declare class ServerCommerceClient {
1550
1920
  cancelOrder: (params: CancelOrderParams) => Promise<CancelOrderResponse>;
1551
1921
  resolveCancelRefund: (params: ResolveCancelRefundParams) => Promise<ResolveCancelRefundResponse>;
1552
1922
  createFulfillment: (params: CreateFulfillmentParams) => Promise<Fulfillment>;
1923
+ prepareFulfillmentOrder: (params: PrepareFulfillmentOrderParams) => Promise<PrepareFulfillmentOrderResponse>;
1553
1924
  updateFulfillment: (params: UpdateFulfillmentParams) => Promise<Fulfillment>;
1554
1925
  bulkImportFulfillments: (params: BulkImportFulfillmentsParams) => Promise<BulkImportFulfillmentsResponse>;
1555
1926
  createReturn: (params: CreateReturnParams) => Promise<Return>;
@@ -2038,4 +2409,4 @@ type DeepPartial<T> = {
2038
2409
  };
2039
2410
  type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
2040
2411
 
2041
- 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 ProductVariantShape 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_UPSERT_READONLY_FIELD_REASON as b6, PRODUCT_UPSERT_UNKNOWN_FIELD_REASON as b7, ProductApi as b8, type ProductApiOptions as b9, type ProductListingGroupsProduct as bA, type ProductListingGroupsResponse as bB, type ProductListingProductShape as bC, type ProductListingProjection as bD, type ProductListingSwatch as bE, type ProductMediaResolutionSource as bF, type ProductOptionMatrix as bG, type ProductOptionMatrixOption as bH, type ProductOptionMatrixValue as bI, type ProductOptionMatrixVariant as bJ, type ProductOptionShape as bK, type ProductOptionValueShape as bL, type ProductOptionValueSwatch as bM, type ProductOptionValueSwatchInput as bN, type ProductSelectionAvailableSwatch as bO, type ProductSelectionAvailableValue as bP, type ProductSelectionByOptionValue as bQ, ProductSelectionCodecError as bR, type ProductSelectionCodecOptions as bS, type ProductSelectionInput as bT, type ProductSelectionOptionValue as bU, type ProductSelectionResolution as bV, type ProductSelectionResolutionContext as bW, type ProductSelectionUrlEmit as bX, type ProductSelectionVariant as bY, type ProductUpsertFieldValidationErrorBody as bZ, type ProductUpsertFieldValidationErrorReason as b_, type ProductDetailBrand as ba, type ProductDetailCatalogListing as bb, type ProductDetailCatalogResult as bc, type ProductDetailCatalogVariant as bd, type ProductDetailCategory as be, type ProductDetailImage as bf, type ProductDetailImageMedia as bg, type ProductDetailListing as bh, type ProductDetailMedia as bi, type ProductDetailOption as bj, type ProductDetailOptionValue as bk, type ProductDetailTag as bl, type ProductDetailUnavailableReason as bm, type ProductDetailVariant as bn, type ProductDetailVariantOptionValue as bo, type ProductDetailVideo as bp, type ProductHrefGroup as bq, type ProductHrefOptions as br, type ProductHrefProduct as bs, type ProductListingCard as bt, type ProductListingCardOptions as bu, type ProductListingCardPriceRange as bv, type ProductListingCardRepresentativeVariant as bw, type ProductListingGroup as bx, type ProductListingGroupSummary as by, type ProductListingGroupVariant as bz, type ClientState as c, type RemoveDiscountParams as c0, type RemoveItemParams as c1, type RequestOptions as c2, type ResolveCancelRefundFailedResponse as c3, type ResolveCancelRefundOutcome as c4, type ResolveCancelRefundParams as c5, type ResolveCancelRefundResponse as c6, type ResolveCancelRefundSucceededResponse as c7, type ResolveProductDisplayMediaInput as c8, type ResolveProductDisplayMediaResult as c9, getAvailableOptionValues as cA, getProductSelectionImages as cB, getSelectedValueByOptionId as cC, isProductUpsertFieldValidationErrorBody as cD, normalizeProductSelection as cE, normalizeProductSelectionFromMatrix as cF, normalizeSelectedValueIds as cG, parseProductSelection as cH, resolveListingPrimaryImagePointer as cI, resolveProductDisplayMedia as cJ, resolveProductSelection as cK, resolveProductSelectionFromMatrix as cL, resolveProductSelectionMedia as cM, resolveVariantForSelection as cN, selectNext as cO, selectedSwatchMediaItemId as cP, stringifyProductSelection as cQ, toShopifyPriceRangeV2 as cR, type ReturnItem as ca, type ReturnReason as cb, type ReturnWithRefundItem as cc, type ReturnWithRefundParams as cd, ShippingApi as ce, type ShippingApiOptions as cf, type StockCheckParams as cg, type StockCheckResponse as ch, type StockCheckResult as ci, type StockSnapshotItem as cj, type StockSnapshotParams as ck, type UpdateFulfillmentParams as cl, type UpdateItemParams as cm, type UpdateOrderParams as cn, type UpdateReturnParams as co, type UpdateTransactionParams as cp, type ValidateDiscountParams as cq, type ValidateDiscountResult as cr, type WithIdempotencyKey as cs, buildProductHref as ct, buildProductListingCard as cu, buildProductListingGroupsByOption as cv, buildProductListingProjection as cw, buildProductOptionMatrix as cx, buildProductOptionMatrixFromDetail as cy, createProductSelectionCodec 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 };