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