arky-sdk 0.9.13 → 0.9.16
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 +16 -12
- package/dist/admin-C-ZTxvz3.d.ts +1544 -0
- package/dist/admin-Dm2WRN6q.d.cts +1544 -0
- package/dist/admin.cjs +982 -425
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.d.cts +3 -3
- package/dist/admin.d.ts +3 -3
- package/dist/admin.js +982 -425
- package/dist/admin.js.map +1 -1
- package/dist/{api-DvsFdOaF.d.cts → api-D37IpMSq.d.cts} +1417 -665
- package/dist/{api-DvsFdOaF.d.ts → api-D37IpMSq.d.ts} +1417 -665
- package/dist/index.cjs +1317 -539
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1317 -539
- package/dist/index.js.map +1 -1
- package/dist/{index-CQd9b_7n.d.ts → inventory-DdN96PX3.d.cts} +6 -4
- package/dist/{index-BC06yiuv.d.cts → inventory-Dh1RevEb.d.ts} +6 -4
- package/dist/storefront.cjs +1210 -658
- package/dist/storefront.cjs.map +1 -1
- package/dist/storefront.d.cts +88 -285
- package/dist/storefront.d.ts +88 -285
- package/dist/storefront.js +1207 -659
- package/dist/storefront.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs +198 -16
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +18 -2
- package/dist/utils.d.ts +18 -2
- package/dist/utils.js +191 -17
- package/dist/utils.js.map +1 -1
- package/package.json +4 -5
- package/dist/admin-Q9MBFwCb.d.cts +0 -1496
- package/dist/admin-ZLXD4_en.d.ts +0 -1496
- package/scripts/contract-admin.mjs +0 -120
- package/scripts/contract-storefront.mjs +0 -296
package/dist/index.js
CHANGED
|
@@ -6,32 +6,25 @@ var PaymentMethodType = /* @__PURE__ */ ((PaymentMethodType2) => {
|
|
|
6
6
|
})(PaymentMethodType || {});
|
|
7
7
|
|
|
8
8
|
// src/utils/orderItems.ts
|
|
9
|
-
function
|
|
9
|
+
function sanitizePublicCheckoutItems(items) {
|
|
10
10
|
return items.map((item) => {
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
function normalizeOrderCheckoutItems(items) {
|
|
21
|
-
return items.map((item) => {
|
|
22
|
-
if ("type" in item) {
|
|
23
|
-
return item;
|
|
24
|
-
}
|
|
25
|
-
if ("product_id" in item) {
|
|
26
|
-
return { type: "product", ...item };
|
|
11
|
+
if (item.type === "product") {
|
|
12
|
+
return {
|
|
13
|
+
type: "product",
|
|
14
|
+
...item.id ? { id: item.id } : {},
|
|
15
|
+
product_id: item.product_id,
|
|
16
|
+
variant_id: item.variant_id,
|
|
17
|
+
quantity: item.quantity
|
|
18
|
+
};
|
|
27
19
|
}
|
|
28
|
-
return {
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
return {
|
|
21
|
+
type: "service",
|
|
22
|
+
...item.id ? { id: item.id } : {},
|
|
23
|
+
service_id: item.service_id,
|
|
24
|
+
provider_id: item.provider_id,
|
|
25
|
+
slots: item.slots,
|
|
26
|
+
...item.forms ? { forms: item.forms } : {}
|
|
27
|
+
};
|
|
35
28
|
});
|
|
36
29
|
}
|
|
37
30
|
|
|
@@ -56,10 +49,9 @@ var createActionApi = (apiConfig) => ({
|
|
|
56
49
|
COMMON_ACTION_KEYS,
|
|
57
50
|
async track(params) {
|
|
58
51
|
try {
|
|
59
|
-
const key = "key" in params && params.key ? params.key : params.type;
|
|
60
52
|
await apiConfig.httpClient.post(
|
|
61
53
|
`/v1/storefront/${apiConfig.storeId}/actions/track`,
|
|
62
|
-
{ key, payload: params.payload }
|
|
54
|
+
{ key: params.key, payload: params.payload }
|
|
63
55
|
);
|
|
64
56
|
} catch {
|
|
65
57
|
}
|
|
@@ -67,6 +59,47 @@ var createActionApi = (apiConfig) => ({
|
|
|
67
59
|
});
|
|
68
60
|
var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
69
61
|
const base = (storeId = apiConfig.storeId) => `/v1/storefront/${storeId}`;
|
|
62
|
+
const pendingVerifications = /* @__PURE__ */ new Map();
|
|
63
|
+
function persistIdentification(result) {
|
|
64
|
+
const issued = result.token;
|
|
65
|
+
if (issued?.token) {
|
|
66
|
+
updateContactSession(() => ({
|
|
67
|
+
access_token: issued.token,
|
|
68
|
+
contact: result.contact,
|
|
69
|
+
store: result.store,
|
|
70
|
+
market: result.market
|
|
71
|
+
}));
|
|
72
|
+
} else {
|
|
73
|
+
if (result.verification_challenge) {
|
|
74
|
+
pendingVerifications.set(result.verification_challenge.challenge_id, {
|
|
75
|
+
store: result.store,
|
|
76
|
+
market: result.market
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
updateContactSession(
|
|
80
|
+
(current) => current ? {
|
|
81
|
+
...current,
|
|
82
|
+
contact: result.contact,
|
|
83
|
+
store: result.store,
|
|
84
|
+
market: result.market
|
|
85
|
+
} : null
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
async function submitIdentification(path, params, options) {
|
|
91
|
+
const store_id = apiConfig.storeId;
|
|
92
|
+
const result = await apiConfig.httpClient.post(
|
|
93
|
+
`${base(store_id)}/account/${path}`,
|
|
94
|
+
{
|
|
95
|
+
store_id,
|
|
96
|
+
market: params?.market || apiConfig.market || null,
|
|
97
|
+
email: params?.email
|
|
98
|
+
},
|
|
99
|
+
options
|
|
100
|
+
);
|
|
101
|
+
return persistIdentification(result);
|
|
102
|
+
}
|
|
70
103
|
return {
|
|
71
104
|
store: {
|
|
72
105
|
getStore(options) {
|
|
@@ -74,7 +107,10 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
74
107
|
},
|
|
75
108
|
location: {
|
|
76
109
|
getCountries(options) {
|
|
77
|
-
return apiConfig.httpClient.get(
|
|
110
|
+
return apiConfig.httpClient.get(
|
|
111
|
+
`/v1/platform/countries`,
|
|
112
|
+
options
|
|
113
|
+
);
|
|
78
114
|
},
|
|
79
115
|
getCountry(countryCode, options) {
|
|
80
116
|
return apiConfig.httpClient.get(
|
|
@@ -83,18 +119,30 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
83
119
|
);
|
|
84
120
|
},
|
|
85
121
|
list(options) {
|
|
86
|
-
return apiConfig.httpClient.get(
|
|
122
|
+
return apiConfig.httpClient.get(
|
|
123
|
+
`${base()}/locations`,
|
|
124
|
+
options
|
|
125
|
+
);
|
|
87
126
|
},
|
|
88
127
|
get(id, options) {
|
|
89
|
-
return apiConfig.httpClient.get(
|
|
128
|
+
return apiConfig.httpClient.get(
|
|
129
|
+
`${base()}/locations/${id}`,
|
|
130
|
+
options
|
|
131
|
+
);
|
|
90
132
|
}
|
|
91
133
|
},
|
|
92
134
|
market: {
|
|
93
135
|
list(options) {
|
|
94
|
-
return apiConfig.httpClient.get(
|
|
136
|
+
return apiConfig.httpClient.get(
|
|
137
|
+
`${base()}/markets`,
|
|
138
|
+
options
|
|
139
|
+
);
|
|
95
140
|
},
|
|
96
141
|
get(id, options) {
|
|
97
|
-
return apiConfig.httpClient.get(
|
|
142
|
+
return apiConfig.httpClient.get(
|
|
143
|
+
`${base()}/markets/${id}`,
|
|
144
|
+
options
|
|
145
|
+
);
|
|
98
146
|
}
|
|
99
147
|
}
|
|
100
148
|
},
|
|
@@ -102,11 +150,9 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
102
150
|
collection: {
|
|
103
151
|
get(params, options) {
|
|
104
152
|
const store_id = params.store_id || apiConfig.storeId;
|
|
105
|
-
|
|
106
|
-
throw new Error("GetCollectionParams requires id");
|
|
107
|
-
}
|
|
153
|
+
const identifier = params.id !== void 0 ? params.id : `${store_id}:${params.key}`;
|
|
108
154
|
return apiConfig.httpClient.get(
|
|
109
|
-
`${base(store_id)}/collections/${
|
|
155
|
+
`${base(store_id)}/collections/${identifier}`,
|
|
110
156
|
options
|
|
111
157
|
);
|
|
112
158
|
}
|
|
@@ -124,10 +170,13 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
124
170
|
},
|
|
125
171
|
find(params, options) {
|
|
126
172
|
const { store_id, ...queryParams } = params;
|
|
127
|
-
return apiConfig.httpClient.get(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
173
|
+
return apiConfig.httpClient.get(
|
|
174
|
+
`${base(store_id)}/entries`,
|
|
175
|
+
{
|
|
176
|
+
...options,
|
|
177
|
+
params: queryParams
|
|
178
|
+
}
|
|
179
|
+
);
|
|
131
180
|
}
|
|
132
181
|
},
|
|
133
182
|
form: {
|
|
@@ -203,10 +252,13 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
203
252
|
},
|
|
204
253
|
find(params, options) {
|
|
205
254
|
const { store_id, ...queryParams } = params;
|
|
206
|
-
return apiConfig.httpClient.get(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
255
|
+
return apiConfig.httpClient.get(
|
|
256
|
+
`${base(store_id)}/products`,
|
|
257
|
+
{
|
|
258
|
+
...options,
|
|
259
|
+
params: queryParams
|
|
260
|
+
}
|
|
261
|
+
);
|
|
210
262
|
}
|
|
211
263
|
},
|
|
212
264
|
cart: {
|
|
@@ -215,16 +267,23 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
215
267
|
const { store_id: _store_id, ...payload } = params;
|
|
216
268
|
return apiConfig.httpClient.post(
|
|
217
269
|
`${base(store_id)}/carts/current`,
|
|
218
|
-
{
|
|
270
|
+
{
|
|
271
|
+
...payload,
|
|
272
|
+
store_id,
|
|
273
|
+
market: payload.market || apiConfig.market
|
|
274
|
+
},
|
|
219
275
|
options
|
|
220
276
|
);
|
|
221
277
|
},
|
|
222
278
|
get(params, options) {
|
|
223
279
|
const store_id = params.store_id || apiConfig.storeId;
|
|
224
|
-
return apiConfig.httpClient.get(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
280
|
+
return apiConfig.httpClient.get(
|
|
281
|
+
`${base(store_id)}/carts/${params.id}`,
|
|
282
|
+
{
|
|
283
|
+
...options,
|
|
284
|
+
params: params.token ? { token: params.token } : options?.params
|
|
285
|
+
}
|
|
286
|
+
);
|
|
228
287
|
},
|
|
229
288
|
update(params, options) {
|
|
230
289
|
const { store_id, items, ...payload } = params;
|
|
@@ -234,7 +293,7 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
234
293
|
{
|
|
235
294
|
...payload,
|
|
236
295
|
store_id: target,
|
|
237
|
-
...items ? { items:
|
|
296
|
+
...items ? { items: sanitizePublicCheckoutItems(items) } : {}
|
|
238
297
|
},
|
|
239
298
|
options
|
|
240
299
|
);
|
|
@@ -247,7 +306,7 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
247
306
|
{
|
|
248
307
|
...payload,
|
|
249
308
|
store_id: target,
|
|
250
|
-
item:
|
|
309
|
+
item: sanitizePublicCheckoutItems([item])[0]
|
|
251
310
|
},
|
|
252
311
|
options
|
|
253
312
|
);
|
|
@@ -302,18 +361,35 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
302
361
|
},
|
|
303
362
|
find(params, options) {
|
|
304
363
|
const { store_id, ...queryParams } = params;
|
|
305
|
-
return apiConfig.httpClient.get(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
364
|
+
return apiConfig.httpClient.get(
|
|
365
|
+
`${base(store_id)}/orders`,
|
|
366
|
+
{
|
|
367
|
+
...options,
|
|
368
|
+
params: queryParams
|
|
369
|
+
}
|
|
370
|
+
);
|
|
309
371
|
},
|
|
310
372
|
downloadDigitalAccess(params, options) {
|
|
311
373
|
const store_id = params.store_id || apiConfig.storeId;
|
|
312
374
|
return apiConfig.httpClient.post(
|
|
313
|
-
`${base(store_id)}/orders/${params.
|
|
375
|
+
`${base(store_id)}/orders/${params.order_id}/digital-access/${params.grant_id}/download`,
|
|
314
376
|
{},
|
|
315
377
|
options
|
|
316
378
|
);
|
|
379
|
+
},
|
|
380
|
+
findDigitalAccess(params, options) {
|
|
381
|
+
const { order_id, store_id, ...queryParams } = params;
|
|
382
|
+
return apiConfig.httpClient.get(
|
|
383
|
+
`${base(store_id)}/orders/${order_id}/digital-access`,
|
|
384
|
+
{ ...options, params: queryParams }
|
|
385
|
+
);
|
|
386
|
+
},
|
|
387
|
+
getDigitalAccess(params, options) {
|
|
388
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
389
|
+
return apiConfig.httpClient.get(
|
|
390
|
+
`${base(store_id)}/orders/${params.order_id}/digital-access/${params.grant_id}`,
|
|
391
|
+
options
|
|
392
|
+
);
|
|
317
393
|
}
|
|
318
394
|
},
|
|
319
395
|
service: {
|
|
@@ -334,17 +410,23 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
334
410
|
},
|
|
335
411
|
find(params, options) {
|
|
336
412
|
const { store_id, ...queryParams } = params;
|
|
337
|
-
return apiConfig.httpClient.get(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
413
|
+
return apiConfig.httpClient.get(
|
|
414
|
+
`${base(store_id)}/services`,
|
|
415
|
+
{
|
|
416
|
+
...options,
|
|
417
|
+
params: queryParams
|
|
418
|
+
}
|
|
419
|
+
);
|
|
341
420
|
},
|
|
342
421
|
findProviders(params, options) {
|
|
343
422
|
const { store_id, ...queryParams } = params;
|
|
344
|
-
return apiConfig.httpClient.get(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
423
|
+
return apiConfig.httpClient.get(
|
|
424
|
+
`${base(store_id)}/service-providers`,
|
|
425
|
+
{
|
|
426
|
+
...options,
|
|
427
|
+
params: queryParams
|
|
428
|
+
}
|
|
429
|
+
);
|
|
348
430
|
},
|
|
349
431
|
getAvailability(params, options) {
|
|
350
432
|
const { store_id, ...queryParams } = params;
|
|
@@ -373,48 +455,47 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
373
455
|
},
|
|
374
456
|
find(params, options) {
|
|
375
457
|
const { store_id, ...queryParams } = params;
|
|
376
|
-
return apiConfig.httpClient.get(
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
458
|
+
return apiConfig.httpClient.get(
|
|
459
|
+
`${base(store_id)}/providers`,
|
|
460
|
+
{
|
|
461
|
+
...options,
|
|
462
|
+
params: queryParams
|
|
463
|
+
}
|
|
464
|
+
);
|
|
380
465
|
}
|
|
381
466
|
}
|
|
382
467
|
},
|
|
383
468
|
crm: {
|
|
384
469
|
contact: {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
store_id,
|
|
391
|
-
market: params?.market || apiConfig.market || null,
|
|
392
|
-
email: params?.email,
|
|
393
|
-
verify: params?.verify ?? false
|
|
394
|
-
},
|
|
395
|
-
options
|
|
396
|
-
);
|
|
397
|
-
if (result?.token?.token) {
|
|
398
|
-
updateContactSession(() => ({
|
|
399
|
-
access_token: result.token.token,
|
|
400
|
-
contact: result.contact,
|
|
401
|
-
store: result.store,
|
|
402
|
-
market: result.market
|
|
403
|
-
}));
|
|
404
|
-
}
|
|
405
|
-
return result;
|
|
470
|
+
identify(params, options) {
|
|
471
|
+
return submitIdentification("identify", params, options);
|
|
472
|
+
},
|
|
473
|
+
requestCode(params, options) {
|
|
474
|
+
return submitIdentification("code", params, options);
|
|
406
475
|
},
|
|
407
476
|
async verify(params, options) {
|
|
408
477
|
const store_id = apiConfig.storeId;
|
|
409
478
|
const result = await apiConfig.httpClient.post(
|
|
410
479
|
`${base(store_id)}/account/verify`,
|
|
411
|
-
{ store_id, code: params.code },
|
|
480
|
+
{ store_id, challenge_id: params.challenge_id, code: params.code },
|
|
412
481
|
options
|
|
413
482
|
);
|
|
414
|
-
if (result?.token) {
|
|
483
|
+
if (result?.token?.token) {
|
|
484
|
+
const pending = pendingVerifications.get(params.challenge_id);
|
|
485
|
+
const identifiedStore = pending?.store || await apiConfig.httpClient.get(base(store_id), options);
|
|
415
486
|
updateContactSession(
|
|
416
|
-
(prev) => prev ? {
|
|
487
|
+
(prev) => prev ? {
|
|
488
|
+
...prev,
|
|
489
|
+
access_token: result.token.token,
|
|
490
|
+
contact: result.contact
|
|
491
|
+
} : {
|
|
492
|
+
access_token: result.token.token,
|
|
493
|
+
contact: result.contact,
|
|
494
|
+
store: identifiedStore,
|
|
495
|
+
market: pending?.market || null
|
|
496
|
+
}
|
|
417
497
|
);
|
|
498
|
+
pendingVerifications.delete(params.challenge_id);
|
|
418
499
|
}
|
|
419
500
|
return result;
|
|
420
501
|
},
|
|
@@ -431,7 +512,10 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
431
512
|
}
|
|
432
513
|
},
|
|
433
514
|
getMe(options) {
|
|
434
|
-
return apiConfig.httpClient.get(
|
|
515
|
+
return apiConfig.httpClient.get(
|
|
516
|
+
`${base()}/account/me`,
|
|
517
|
+
options
|
|
518
|
+
);
|
|
435
519
|
}
|
|
436
520
|
},
|
|
437
521
|
contactList: {
|
|
@@ -444,10 +528,31 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
444
528
|
},
|
|
445
529
|
find(params, options) {
|
|
446
530
|
const { store_id, ...queryParams } = params || {};
|
|
447
|
-
return apiConfig.httpClient.get(
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
531
|
+
return apiConfig.httpClient.get(
|
|
532
|
+
`${base(store_id)}/contact-lists`,
|
|
533
|
+
{
|
|
534
|
+
...options,
|
|
535
|
+
params: queryParams
|
|
536
|
+
}
|
|
537
|
+
);
|
|
538
|
+
},
|
|
539
|
+
plans: {
|
|
540
|
+
find(params, options) {
|
|
541
|
+
const { store_id, contact_list_id, ...queryParams } = params;
|
|
542
|
+
return apiConfig.httpClient.get(
|
|
543
|
+
`${base(store_id)}/contact-lists/${contact_list_id}/plans`,
|
|
544
|
+
{ ...options, params: queryParams }
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
memberships: {
|
|
549
|
+
find(params, options) {
|
|
550
|
+
const { store_id, ...queryParams } = params || {};
|
|
551
|
+
return apiConfig.httpClient.get(`${base(store_id)}/contact-lists/memberships`, {
|
|
552
|
+
...options,
|
|
553
|
+
params: queryParams
|
|
554
|
+
});
|
|
555
|
+
}
|
|
451
556
|
},
|
|
452
557
|
subscribe(params, options) {
|
|
453
558
|
const { store_id, id, ...payload } = params;
|
|
@@ -472,13 +577,31 @@ var createStorefrontApi = (apiConfig, updateContactSession) => {
|
|
|
472
577
|
options
|
|
473
578
|
);
|
|
474
579
|
},
|
|
475
|
-
|
|
580
|
+
manage(token, options) {
|
|
476
581
|
return apiConfig.httpClient.post(
|
|
477
|
-
`${base()}/contact-lists/
|
|
582
|
+
`${base()}/contact-lists/manage`,
|
|
478
583
|
{ token },
|
|
479
584
|
options
|
|
480
585
|
);
|
|
481
586
|
},
|
|
587
|
+
unsubscribe(token, options) {
|
|
588
|
+
const headers = { ...options?.headers };
|
|
589
|
+
for (const name of Object.keys(headers)) {
|
|
590
|
+
if (name.toLowerCase() === "content-type") delete headers[name];
|
|
591
|
+
}
|
|
592
|
+
return apiConfig.httpClient.post(
|
|
593
|
+
`${base()}/contact-lists/unsubscribe`,
|
|
594
|
+
new URLSearchParams({ "List-Unsubscribe": "One-Click" }),
|
|
595
|
+
{
|
|
596
|
+
...options,
|
|
597
|
+
params: { ...options?.params || {}, token },
|
|
598
|
+
headers: {
|
|
599
|
+
...headers,
|
|
600
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
);
|
|
604
|
+
},
|
|
482
605
|
confirm(token, options) {
|
|
483
606
|
return apiConfig.httpClient.post(
|
|
484
607
|
`${base()}/contact-lists/confirm`,
|
|
@@ -643,27 +766,47 @@ var convertServerErrorToRequestError = (serverError, renameRules) => {
|
|
|
643
766
|
|
|
644
767
|
// src/utils/queryParams.ts
|
|
645
768
|
function buildQueryString(params) {
|
|
646
|
-
const queryParts =
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
const jsonString = JSON.stringify(value);
|
|
660
|
-
queryParts.push(`${key}=${encodeURIComponent(jsonString)}`);
|
|
769
|
+
const queryParts = Object.entries(params).flatMap(
|
|
770
|
+
([key, value]) => {
|
|
771
|
+
if (value === null || value === void 0) return [];
|
|
772
|
+
if (typeof value === "string") {
|
|
773
|
+
return [`${key}=${encodeURIComponent(value)}`];
|
|
774
|
+
}
|
|
775
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
776
|
+
return [`${key}=${value}`];
|
|
777
|
+
}
|
|
778
|
+
if (Array.isArray(value) || typeof value === "object") {
|
|
779
|
+
return [`${key}=${encodeURIComponent(JSON.stringify(value))}`];
|
|
780
|
+
}
|
|
781
|
+
return [];
|
|
661
782
|
}
|
|
662
|
-
|
|
783
|
+
);
|
|
663
784
|
return queryParts.length > 0 ? `?${queryParts.join("&")}` : "";
|
|
664
785
|
}
|
|
665
786
|
|
|
666
787
|
// src/services/createHttpClient.ts
|
|
788
|
+
function requestError(name, message, details = {}) {
|
|
789
|
+
return Object.assign(new Error(message), { name }, details);
|
|
790
|
+
}
|
|
791
|
+
function isRecord(value) {
|
|
792
|
+
return typeof value === "object" && value !== null;
|
|
793
|
+
}
|
|
794
|
+
function isTokenSet(value) {
|
|
795
|
+
return isRecord(value) && typeof value.access_token === "string" && (value.refresh_token === void 0 || typeof value.refresh_token === "string") && (value.access_expires_at === void 0 || typeof value.access_expires_at === "number");
|
|
796
|
+
}
|
|
797
|
+
function isValidationError(value) {
|
|
798
|
+
return isRecord(value) && typeof value.field === "string" && typeof value.error === "string";
|
|
799
|
+
}
|
|
800
|
+
function toServerError(value, statusCode) {
|
|
801
|
+
const payload = isRecord(value) ? value : {};
|
|
802
|
+
const validationErrors = Array.isArray(payload.validationErrors) ? payload.validationErrors.filter(isValidationError) : [];
|
|
803
|
+
return {
|
|
804
|
+
message: typeof payload.message === "string" ? payload.message : "Request failed",
|
|
805
|
+
error: typeof payload.error === "string" ? payload.error : "REQUEST_FAILED",
|
|
806
|
+
statusCode: typeof payload.statusCode === "number" ? payload.statusCode : statusCode,
|
|
807
|
+
validationErrors
|
|
808
|
+
};
|
|
809
|
+
}
|
|
667
810
|
function createHttpClient(cfg) {
|
|
668
811
|
const { authStorage } = cfg;
|
|
669
812
|
let refreshPromise = null;
|
|
@@ -680,32 +823,41 @@ function createHttpClient(cfg) {
|
|
|
680
823
|
const refresh_token = tokens?.refresh_token;
|
|
681
824
|
if (!refresh_token) {
|
|
682
825
|
authStorage.onForcedLogout();
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
throw err;
|
|
826
|
+
throw requestError("ApiError", "No refresh token available", {
|
|
827
|
+
statusCode: 401
|
|
828
|
+
});
|
|
687
829
|
}
|
|
688
830
|
const refRes = await fetch(getRefreshEndpoint(), {
|
|
689
831
|
method: "POST",
|
|
690
|
-
headers: {
|
|
832
|
+
headers: {
|
|
833
|
+
Accept: "application/json",
|
|
834
|
+
"Content-Type": "application/json"
|
|
835
|
+
},
|
|
691
836
|
body: JSON.stringify({ refresh_token })
|
|
692
837
|
});
|
|
693
838
|
if (!refRes.ok) {
|
|
694
839
|
authStorage.onForcedLogout();
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
throw err;
|
|
840
|
+
throw requestError("ApiError", "Token refresh failed", {
|
|
841
|
+
statusCode: 401
|
|
842
|
+
});
|
|
699
843
|
}
|
|
700
844
|
const data = await refRes.json();
|
|
845
|
+
if (!isTokenSet(data)) {
|
|
846
|
+
authStorage.onForcedLogout();
|
|
847
|
+
throw requestError(
|
|
848
|
+
"ParseError",
|
|
849
|
+
"Token refresh returned an invalid response",
|
|
850
|
+
{ statusCode: refRes.status }
|
|
851
|
+
);
|
|
852
|
+
}
|
|
701
853
|
authStorage.onTokensRefreshed(data);
|
|
702
854
|
})().finally(() => {
|
|
703
855
|
refreshPromise = null;
|
|
704
856
|
});
|
|
705
857
|
return refreshPromise;
|
|
706
858
|
}
|
|
707
|
-
async function request(method, path, body, options) {
|
|
708
|
-
if (options?.transformRequest) {
|
|
859
|
+
async function request(method, path, body, options, retried = false) {
|
|
860
|
+
if (!retried && options?.transformRequest) {
|
|
709
861
|
body = options.transformRequest(body);
|
|
710
862
|
}
|
|
711
863
|
const headers = {
|
|
@@ -723,23 +875,27 @@ function createHttpClient(cfg) {
|
|
|
723
875
|
headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
724
876
|
}
|
|
725
877
|
const finalPath = options?.params ? path + buildQueryString(options.params) : path;
|
|
726
|
-
const
|
|
878
|
+
const fetchOptions = {
|
|
879
|
+
method,
|
|
880
|
+
headers,
|
|
881
|
+
signal: options?.signal
|
|
882
|
+
};
|
|
727
883
|
if (!["GET", "DELETE"].includes(method) && body !== void 0) {
|
|
728
|
-
|
|
884
|
+
fetchOptions.body = body instanceof URLSearchParams ? body.toString() : JSON.stringify(body);
|
|
729
885
|
}
|
|
730
886
|
const fullUrl = `${cfg.baseUrl}${finalPath}`;
|
|
731
887
|
let res;
|
|
732
888
|
let data;
|
|
733
889
|
const startedAt = Date.now();
|
|
734
890
|
try {
|
|
735
|
-
res = await fetch(fullUrl,
|
|
891
|
+
res = await fetch(fullUrl, fetchOptions);
|
|
736
892
|
} catch (error) {
|
|
737
893
|
const aborted = options?.signal?.aborted || error instanceof Error && error.name === "AbortError";
|
|
738
|
-
const err =
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
894
|
+
const err = requestError(
|
|
895
|
+
aborted ? "AbortError" : "NetworkError",
|
|
896
|
+
error instanceof Error ? error.message : "Network request failed",
|
|
897
|
+
{ method, url: fullUrl, aborted }
|
|
898
|
+
);
|
|
743
899
|
if (options?.onError && method !== "GET") {
|
|
744
900
|
Promise.resolve(
|
|
745
901
|
options.onError({ error: err, method, url: fullUrl, aborted })
|
|
@@ -748,18 +904,9 @@ function createHttpClient(cfg) {
|
|
|
748
904
|
}
|
|
749
905
|
throw err;
|
|
750
906
|
}
|
|
751
|
-
if (res.status === 401 && !
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
const refreshed = authStorage.getTokens();
|
|
755
|
-
if (refreshed?.access_token) {
|
|
756
|
-
headers["Authorization"] = `Bearer ${refreshed.access_token}`;
|
|
757
|
-
fetchOpts.headers = headers;
|
|
758
|
-
}
|
|
759
|
-
return request(method, path, body, { ...options, _retried: true });
|
|
760
|
-
} catch (refreshError) {
|
|
761
|
-
throw refreshError;
|
|
762
|
-
}
|
|
907
|
+
if (res.status === 401 && !retried) {
|
|
908
|
+
await ensureFreshToken();
|
|
909
|
+
return request(method, path, body, options, true);
|
|
763
910
|
}
|
|
764
911
|
try {
|
|
765
912
|
const contentLength = res.headers.get("content-length");
|
|
@@ -770,30 +917,35 @@ function createHttpClient(cfg) {
|
|
|
770
917
|
data = await res.json();
|
|
771
918
|
}
|
|
772
919
|
} catch (error) {
|
|
773
|
-
const err =
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
920
|
+
const err = requestError("ParseError", "Failed to parse response", {
|
|
921
|
+
method,
|
|
922
|
+
url: fullUrl,
|
|
923
|
+
statusCode: res.status
|
|
924
|
+
});
|
|
778
925
|
if (options?.onError && method !== "GET") {
|
|
779
926
|
Promise.resolve(
|
|
780
|
-
options.onError({
|
|
927
|
+
options.onError({
|
|
928
|
+
error: err,
|
|
929
|
+
method,
|
|
930
|
+
url: fullUrl,
|
|
931
|
+
status: res.status
|
|
932
|
+
})
|
|
781
933
|
).catch(() => {
|
|
782
934
|
});
|
|
783
935
|
}
|
|
784
936
|
throw err;
|
|
785
937
|
}
|
|
786
938
|
if (!res.ok) {
|
|
787
|
-
const serverErr = data;
|
|
939
|
+
const serverErr = toServerError(data, res.status);
|
|
788
940
|
const reqErr = convertServerErrorToRequestError(serverErr);
|
|
789
|
-
const err = new Error(serverErr.message || "Request failed");
|
|
790
|
-
err.name = "ApiError";
|
|
791
|
-
err.statusCode = serverErr.statusCode || res.status;
|
|
792
|
-
err.validationErrors = reqErr.validationErrors;
|
|
793
|
-
err.method = method;
|
|
794
|
-
err.url = fullUrl;
|
|
795
941
|
const requestId = res.headers.get("x-request-id") || res.headers.get("request-id");
|
|
796
|
-
|
|
942
|
+
const err = requestError("ApiError", serverErr.message, {
|
|
943
|
+
statusCode: serverErr.statusCode,
|
|
944
|
+
validationErrors: reqErr.validationErrors,
|
|
945
|
+
method,
|
|
946
|
+
url: fullUrl,
|
|
947
|
+
requestId: requestId || void 0
|
|
948
|
+
});
|
|
797
949
|
if (options?.onError && method !== "GET") {
|
|
798
950
|
Promise.resolve(
|
|
799
951
|
options.onError({
|
|
@@ -836,35 +988,73 @@ function createHttpClient(cfg) {
|
|
|
836
988
|
}
|
|
837
989
|
|
|
838
990
|
// src/api/account.ts
|
|
839
|
-
var createAccountApi = (apiConfig) => {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
991
|
+
var createAccountApi = (apiConfig) => ({
|
|
992
|
+
async updateAccount(_params, options) {
|
|
993
|
+
return apiConfig.httpClient.put(
|
|
994
|
+
"/v1/accounts",
|
|
995
|
+
{},
|
|
996
|
+
options
|
|
997
|
+
);
|
|
998
|
+
},
|
|
999
|
+
async deleteAccount(_params, options) {
|
|
1000
|
+
return apiConfig.httpClient.delete(
|
|
1001
|
+
"/v1/accounts",
|
|
1002
|
+
options
|
|
1003
|
+
);
|
|
1004
|
+
},
|
|
1005
|
+
async getMe(_params, options) {
|
|
1006
|
+
return apiConfig.httpClient.get("/v1/accounts/me", options);
|
|
1007
|
+
},
|
|
1008
|
+
async searchAccounts(params, options) {
|
|
1009
|
+
return apiConfig.httpClient.get(
|
|
1010
|
+
"/v1/accounts/search",
|
|
1011
|
+
{ ...options, params }
|
|
1012
|
+
);
|
|
1013
|
+
},
|
|
1014
|
+
async listApiTokens(options) {
|
|
1015
|
+
return apiConfig.httpClient.get(
|
|
1016
|
+
"/v1/accounts/me/api-tokens",
|
|
1017
|
+
options
|
|
1018
|
+
);
|
|
1019
|
+
},
|
|
1020
|
+
async createApiToken(params, options) {
|
|
1021
|
+
return apiConfig.httpClient.post(
|
|
1022
|
+
"/v1/accounts/me/api-tokens",
|
|
1023
|
+
params,
|
|
1024
|
+
options
|
|
1025
|
+
);
|
|
1026
|
+
},
|
|
1027
|
+
async updateApiToken(params, options) {
|
|
1028
|
+
const { id, ...payload } = params;
|
|
1029
|
+
return apiConfig.httpClient.put(
|
|
1030
|
+
`/v1/accounts/me/api-tokens/${id}`,
|
|
1031
|
+
payload,
|
|
1032
|
+
options
|
|
1033
|
+
);
|
|
1034
|
+
},
|
|
1035
|
+
async revokeApiToken(id, options) {
|
|
1036
|
+
return apiConfig.httpClient.delete(
|
|
1037
|
+
`/v1/accounts/me/api-tokens/${id}`,
|
|
1038
|
+
options
|
|
1039
|
+
);
|
|
1040
|
+
},
|
|
1041
|
+
async listSessions(options) {
|
|
1042
|
+
return apiConfig.httpClient.get(
|
|
1043
|
+
"/v1/accounts/me/sessions",
|
|
1044
|
+
options
|
|
1045
|
+
);
|
|
1046
|
+
},
|
|
1047
|
+
async revokeSession(id, options) {
|
|
1048
|
+
return apiConfig.httpClient.delete(
|
|
1049
|
+
`/v1/accounts/me/sessions/${id}`,
|
|
1050
|
+
options
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
865
1054
|
|
|
866
1055
|
// src/api/auth.ts
|
|
867
1056
|
var createAuthApi = (apiConfig, updateSession) => {
|
|
1057
|
+
const pendingEmails = /* @__PURE__ */ new Map();
|
|
868
1058
|
function applyAuthToken(result, email) {
|
|
869
1059
|
const next = {
|
|
870
1060
|
access_token: result.access_token,
|
|
@@ -876,7 +1066,9 @@ var createAuthApi = (apiConfig, updateSession) => {
|
|
|
876
1066
|
}
|
|
877
1067
|
return {
|
|
878
1068
|
async code(params, options) {
|
|
879
|
-
|
|
1069
|
+
const result = await apiConfig.httpClient.post("/v1/auth/code", params, options);
|
|
1070
|
+
pendingEmails.set(result.challenge_id, params.email);
|
|
1071
|
+
return result;
|
|
880
1072
|
},
|
|
881
1073
|
async verify(params, options) {
|
|
882
1074
|
const result = await apiConfig.httpClient.post(
|
|
@@ -885,7 +1077,8 @@ var createAuthApi = (apiConfig, updateSession) => {
|
|
|
885
1077
|
options
|
|
886
1078
|
);
|
|
887
1079
|
if (result?.access_token) {
|
|
888
|
-
applyAuthToken(result, params.
|
|
1080
|
+
applyAuthToken(result, pendingEmails.get(params.challenge_id));
|
|
1081
|
+
pendingEmails.delete(params.challenge_id);
|
|
889
1082
|
}
|
|
890
1083
|
return result;
|
|
891
1084
|
},
|
|
@@ -893,7 +1086,9 @@ var createAuthApi = (apiConfig, updateSession) => {
|
|
|
893
1086
|
return apiConfig.httpClient.post("/v1/auth/refresh", params, options);
|
|
894
1087
|
},
|
|
895
1088
|
async storeCode(storeId, params, options) {
|
|
896
|
-
|
|
1089
|
+
const result = await apiConfig.httpClient.post(`/v1/stores/${storeId}/auth/code`, params, options);
|
|
1090
|
+
pendingEmails.set(result.challenge_id, params.email);
|
|
1091
|
+
return result;
|
|
897
1092
|
},
|
|
898
1093
|
async storeVerify(storeId, params, options) {
|
|
899
1094
|
const result = await apiConfig.httpClient.post(
|
|
@@ -902,7 +1097,8 @@ var createAuthApi = (apiConfig, updateSession) => {
|
|
|
902
1097
|
options
|
|
903
1098
|
);
|
|
904
1099
|
if (result?.access_token) {
|
|
905
|
-
applyAuthToken(result, params.
|
|
1100
|
+
applyAuthToken(result, pendingEmails.get(params.challenge_id));
|
|
1101
|
+
pendingEmails.delete(params.challenge_id);
|
|
906
1102
|
}
|
|
907
1103
|
return result;
|
|
908
1104
|
}
|
|
@@ -916,23 +1112,10 @@ var createStoreApi = (apiConfig, _updateSession) => {
|
|
|
916
1112
|
return apiConfig.httpClient.post(`/v1/stores`, params, options);
|
|
917
1113
|
},
|
|
918
1114
|
async updateStore(params, options) {
|
|
919
|
-
return apiConfig.httpClient.put(
|
|
920
|
-
`/v1/stores/${params.id}`,
|
|
921
|
-
params,
|
|
922
|
-
options
|
|
923
|
-
);
|
|
924
|
-
},
|
|
925
|
-
async deleteStore(params, options) {
|
|
926
|
-
return apiConfig.httpClient.delete(
|
|
927
|
-
`/v1/stores/${params.id}`,
|
|
928
|
-
options
|
|
929
|
-
);
|
|
1115
|
+
return apiConfig.httpClient.put(`/v1/stores/${params.id}`, params, options);
|
|
930
1116
|
},
|
|
931
1117
|
async getStore(_params, options) {
|
|
932
|
-
return apiConfig.httpClient.get(
|
|
933
|
-
`/v1/stores/${apiConfig.storeId}`,
|
|
934
|
-
options
|
|
935
|
-
);
|
|
1118
|
+
return apiConfig.httpClient.get(`/v1/stores/${apiConfig.storeId}`, options);
|
|
936
1119
|
},
|
|
937
1120
|
async getStores(params, options) {
|
|
938
1121
|
return apiConfig.httpClient.get(`/v1/stores`, {
|
|
@@ -941,20 +1124,58 @@ var createStoreApi = (apiConfig, _updateSession) => {
|
|
|
941
1124
|
});
|
|
942
1125
|
},
|
|
943
1126
|
async getSubscriptionPlans(_params, options) {
|
|
944
|
-
return apiConfig.httpClient.get(
|
|
945
|
-
|
|
1127
|
+
return apiConfig.httpClient.get("/v1/stores/plans", options);
|
|
1128
|
+
},
|
|
1129
|
+
async createSubscriptionAction(params, options) {
|
|
1130
|
+
const { store_id, ...payload } = params;
|
|
1131
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1132
|
+
const response = await apiConfig.httpClient.post(
|
|
1133
|
+
`/v1/stores/${target_store_id}/subscription/actions`,
|
|
1134
|
+
payload,
|
|
946
1135
|
options
|
|
947
1136
|
);
|
|
1137
|
+
if (response.id !== params.action_id) {
|
|
1138
|
+
throw new Error("Subscription response did not match the requested action_id");
|
|
1139
|
+
}
|
|
1140
|
+
return response;
|
|
948
1141
|
},
|
|
949
|
-
async
|
|
950
|
-
const
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1142
|
+
async getSubscription(params = {}, options) {
|
|
1143
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1144
|
+
return apiConfig.httpClient.get(`/v1/stores/${store_id}/subscription`, options);
|
|
1145
|
+
},
|
|
1146
|
+
async retrySubscriptionAction(params, options) {
|
|
1147
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1148
|
+
return apiConfig.httpClient.post(
|
|
1149
|
+
`/v1/stores/${store_id}/subscription/actions/${params.action_id}/retry`,
|
|
1150
|
+
{},
|
|
1151
|
+
options
|
|
1152
|
+
);
|
|
1153
|
+
},
|
|
1154
|
+
async getSubscriptionAction(params, options) {
|
|
1155
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1156
|
+
return apiConfig.httpClient.get(`/v1/stores/${store_id}/subscription/actions/${params.action_id}`, options);
|
|
1157
|
+
},
|
|
1158
|
+
async findSubscriptionActionEffects(params, options) {
|
|
1159
|
+
const { store_id, action_id, ...query } = params;
|
|
1160
|
+
return apiConfig.httpClient.get(
|
|
1161
|
+
`/v1/stores/${store_id || apiConfig.storeId}/subscription/actions/${action_id}/effects`,
|
|
1162
|
+
{ ...options, params: query }
|
|
1163
|
+
);
|
|
1164
|
+
},
|
|
1165
|
+
async getSubscriptionActionEffect(params, options) {
|
|
1166
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
1167
|
+
return apiConfig.httpClient.get(
|
|
1168
|
+
`/v1/stores/${store_id}/subscription/actions/${params.action_id}/effects/${params.effect_id}`,
|
|
955
1169
|
options
|
|
956
1170
|
);
|
|
957
1171
|
},
|
|
1172
|
+
async findSubscriptionActions(params = {}, options) {
|
|
1173
|
+
const { store_id, ...query } = params;
|
|
1174
|
+
return apiConfig.httpClient.get(
|
|
1175
|
+
`/v1/stores/${store_id || apiConfig.storeId}/subscription/actions`,
|
|
1176
|
+
{ ...options, params: query }
|
|
1177
|
+
);
|
|
1178
|
+
},
|
|
958
1179
|
async createPortalSession(params, options) {
|
|
959
1180
|
const store_id = params.store_id || apiConfig.storeId;
|
|
960
1181
|
return apiConfig.httpClient.post(
|
|
@@ -965,114 +1186,61 @@ var createStoreApi = (apiConfig, _updateSession) => {
|
|
|
965
1186
|
},
|
|
966
1187
|
async addMember(params, options) {
|
|
967
1188
|
const { store_id, ...payload } = params;
|
|
968
|
-
return apiConfig.httpClient.post(
|
|
969
|
-
`/v1/stores/${store_id || apiConfig.storeId}/members`,
|
|
970
|
-
payload,
|
|
971
|
-
options
|
|
972
|
-
);
|
|
1189
|
+
return apiConfig.httpClient.post(`/v1/stores/${store_id || apiConfig.storeId}/members`, payload, options);
|
|
973
1190
|
},
|
|
974
1191
|
async inviteUser(params, options) {
|
|
975
1192
|
const { store_id, ...payload } = params;
|
|
976
|
-
return apiConfig.httpClient.post(
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1193
|
+
return apiConfig.httpClient.post(`/v1/stores/${store_id || apiConfig.storeId}/invitation`, payload, options);
|
|
1194
|
+
},
|
|
1195
|
+
async findMembers(params = {}, options) {
|
|
1196
|
+
const { store_id, ...query } = params;
|
|
1197
|
+
return apiConfig.httpClient.get(`/v1/stores/${store_id || apiConfig.storeId}/members`, {
|
|
1198
|
+
...options,
|
|
1199
|
+
params: query
|
|
1200
|
+
});
|
|
1201
|
+
},
|
|
1202
|
+
async findOwnMemberships(options) {
|
|
1203
|
+
return apiConfig.httpClient.get("/v1/stores/memberships", options);
|
|
981
1204
|
},
|
|
982
1205
|
async removeMember(params, options) {
|
|
983
1206
|
return apiConfig.httpClient.delete(
|
|
984
|
-
`/v1/stores/${apiConfig.storeId}/members/${params.account_id}`,
|
|
1207
|
+
`/v1/stores/${params.store_id || apiConfig.storeId}/members/${params.account_id}`,
|
|
985
1208
|
options
|
|
986
1209
|
);
|
|
987
1210
|
},
|
|
988
1211
|
async testWebhook(params, options) {
|
|
989
|
-
return apiConfig.httpClient.post(
|
|
990
|
-
`/v1/stores/${apiConfig.storeId}/webhooks/test`,
|
|
991
|
-
params,
|
|
992
|
-
options
|
|
993
|
-
);
|
|
994
|
-
},
|
|
995
|
-
async getStoreMedia(params, options) {
|
|
996
|
-
const queryParams = {
|
|
997
|
-
limit: params.limit
|
|
998
|
-
};
|
|
999
|
-
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1000
|
-
if (params.ids && params.ids.length > 0)
|
|
1001
|
-
queryParams.ids = JSON.stringify(params.ids);
|
|
1002
|
-
if (params.query) queryParams.query = params.query;
|
|
1003
|
-
if (params.mime_type) queryParams.mime_type = params.mime_type;
|
|
1004
|
-
if (params.sort_field) queryParams.sort_field = params.sort_field;
|
|
1005
|
-
if (params.sort_direction)
|
|
1006
|
-
queryParams.sort_direction = params.sort_direction;
|
|
1007
|
-
return apiConfig.httpClient.get(
|
|
1008
|
-
`/v1/stores/${params.id}/media`,
|
|
1009
|
-
{
|
|
1010
|
-
...options,
|
|
1011
|
-
params: queryParams
|
|
1012
|
-
}
|
|
1013
|
-
);
|
|
1212
|
+
return apiConfig.httpClient.post(`/v1/stores/${apiConfig.storeId}/webhooks/test`, params, options);
|
|
1014
1213
|
},
|
|
1015
1214
|
async listBuildHooks(params, options) {
|
|
1016
|
-
return apiConfig.httpClient.get(
|
|
1017
|
-
`/v1/stores/${params.store_id}/build-hooks`,
|
|
1018
|
-
options
|
|
1019
|
-
);
|
|
1215
|
+
return apiConfig.httpClient.get(`/v1/stores/${params.store_id}/build-hooks`, options);
|
|
1020
1216
|
},
|
|
1021
1217
|
async createBuildHook(params, options) {
|
|
1022
1218
|
const { store_id, ...payload } = params;
|
|
1023
|
-
return apiConfig.httpClient.post(
|
|
1024
|
-
`/v1/stores/${store_id}/build-hooks`,
|
|
1025
|
-
payload,
|
|
1026
|
-
options
|
|
1027
|
-
);
|
|
1219
|
+
return apiConfig.httpClient.post(`/v1/stores/${store_id}/build-hooks`, payload, options);
|
|
1028
1220
|
},
|
|
1029
1221
|
async updateBuildHook(params, options) {
|
|
1030
1222
|
const { store_id, id, ...payload } = params;
|
|
1031
|
-
return apiConfig.httpClient.put(
|
|
1032
|
-
`/v1/stores/${store_id}/build-hooks/${id}`,
|
|
1033
|
-
payload,
|
|
1034
|
-
options
|
|
1035
|
-
);
|
|
1223
|
+
return apiConfig.httpClient.put(`/v1/stores/${store_id}/build-hooks/${id}`, payload, options);
|
|
1036
1224
|
},
|
|
1037
1225
|
async deleteBuildHook(params, options) {
|
|
1038
|
-
return apiConfig.httpClient.delete(
|
|
1039
|
-
`/v1/stores/${params.store_id}/build-hooks/${params.id}`,
|
|
1040
|
-
options
|
|
1041
|
-
);
|
|
1226
|
+
return apiConfig.httpClient.delete(`/v1/stores/${params.store_id}/build-hooks/${params.id}`, options);
|
|
1042
1227
|
},
|
|
1043
|
-
async
|
|
1044
|
-
return apiConfig.httpClient.get(
|
|
1045
|
-
`/v1/stores/${params.store_id}/config/${params.type}`,
|
|
1046
|
-
options
|
|
1047
|
-
);
|
|
1228
|
+
async getPaymentConfig(params, options) {
|
|
1229
|
+
return apiConfig.httpClient.get(`/v1/stores/${params.store_id}/config/payment`, options);
|
|
1048
1230
|
},
|
|
1049
1231
|
async listWebhooks(params, options) {
|
|
1050
|
-
return apiConfig.httpClient.get(
|
|
1051
|
-
`/v1/stores/${params.store_id}/webhooks`,
|
|
1052
|
-
options
|
|
1053
|
-
);
|
|
1232
|
+
return apiConfig.httpClient.get(`/v1/stores/${params.store_id}/webhooks`, options);
|
|
1054
1233
|
},
|
|
1055
1234
|
async createWebhook(params, options) {
|
|
1056
1235
|
const { store_id, ...payload } = params;
|
|
1057
|
-
return apiConfig.httpClient.post(
|
|
1058
|
-
`/v1/stores/${store_id}/webhooks`,
|
|
1059
|
-
payload,
|
|
1060
|
-
options
|
|
1061
|
-
);
|
|
1236
|
+
return apiConfig.httpClient.post(`/v1/stores/${store_id}/webhooks`, payload, options);
|
|
1062
1237
|
},
|
|
1063
1238
|
async updateWebhook(params, options) {
|
|
1064
1239
|
const { store_id, id, ...payload } = params;
|
|
1065
|
-
return apiConfig.httpClient.put(
|
|
1066
|
-
`/v1/stores/${store_id}/webhooks/${id}`,
|
|
1067
|
-
payload,
|
|
1068
|
-
options
|
|
1069
|
-
);
|
|
1240
|
+
return apiConfig.httpClient.put(`/v1/stores/${store_id}/webhooks/${id}`, payload, options);
|
|
1070
1241
|
},
|
|
1071
1242
|
async deleteWebhook(params, options) {
|
|
1072
|
-
return apiConfig.httpClient.delete(
|
|
1073
|
-
`/v1/stores/${params.store_id}/webhooks/${params.id}`,
|
|
1074
|
-
options
|
|
1075
|
-
);
|
|
1243
|
+
return apiConfig.httpClient.delete(`/v1/stores/${params.store_id}/webhooks/${params.id}`, options);
|
|
1076
1244
|
}
|
|
1077
1245
|
};
|
|
1078
1246
|
};
|
|
@@ -1109,9 +1277,10 @@ var createMediaApi = (apiConfig) => {
|
|
|
1109
1277
|
return await response.json();
|
|
1110
1278
|
},
|
|
1111
1279
|
async deleteStoreMedia(params, options) {
|
|
1112
|
-
const {
|
|
1280
|
+
const { store_id, media_id } = params;
|
|
1281
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1113
1282
|
return apiConfig.httpClient.delete(
|
|
1114
|
-
`/v1/stores/${
|
|
1283
|
+
`/v1/stores/${target_store_id}/media/${media_id}`,
|
|
1115
1284
|
options
|
|
1116
1285
|
);
|
|
1117
1286
|
},
|
|
@@ -1155,16 +1324,23 @@ var createMediaApi = (apiConfig) => {
|
|
|
1155
1324
|
// src/api/notification.ts
|
|
1156
1325
|
var createNotificationApi = (apiConfig) => {
|
|
1157
1326
|
return {
|
|
1158
|
-
async
|
|
1327
|
+
async sendEmail(request, options) {
|
|
1328
|
+
return apiConfig.httpClient.post(
|
|
1329
|
+
"/v1/notifications/email",
|
|
1330
|
+
request,
|
|
1331
|
+
options
|
|
1332
|
+
);
|
|
1333
|
+
},
|
|
1334
|
+
async getEmailDelivery(params, options) {
|
|
1159
1335
|
return apiConfig.httpClient.get(
|
|
1160
|
-
`/v1/notifications/
|
|
1336
|
+
`/v1/notifications/email-deliveries/${params.delivery_id}`,
|
|
1161
1337
|
options
|
|
1162
1338
|
);
|
|
1163
1339
|
},
|
|
1164
|
-
async
|
|
1340
|
+
async retryEmailDelivery(params, options) {
|
|
1165
1341
|
return apiConfig.httpClient.post(
|
|
1166
|
-
|
|
1167
|
-
params,
|
|
1342
|
+
`/v1/notifications/email-deliveries/${params.delivery_id}/retry`,
|
|
1343
|
+
{ revision: params.revision },
|
|
1168
1344
|
options
|
|
1169
1345
|
);
|
|
1170
1346
|
}
|
|
@@ -1247,14 +1423,7 @@ var createCmsApi = (apiConfig) => {
|
|
|
1247
1423
|
},
|
|
1248
1424
|
async getCollection(params, options) {
|
|
1249
1425
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1250
|
-
|
|
1251
|
-
if (params.id) {
|
|
1252
|
-
identifier = params.id;
|
|
1253
|
-
} else if (params.key) {
|
|
1254
|
-
identifier = `${target_store_id}:${params.key}`;
|
|
1255
|
-
} else {
|
|
1256
|
-
throw new Error("GetCollectionParams requires id or key");
|
|
1257
|
-
}
|
|
1426
|
+
const identifier = params.id !== void 0 ? params.id : `${target_store_id}:${params.key}`;
|
|
1258
1427
|
return apiConfig.httpClient.get(
|
|
1259
1428
|
`/v1/stores/${target_store_id}/collections/${identifier}`,
|
|
1260
1429
|
options
|
|
@@ -1522,7 +1691,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
1522
1691
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1523
1692
|
const payload = {
|
|
1524
1693
|
...rest,
|
|
1525
|
-
...items ? { items
|
|
1694
|
+
...items ? { items } : {}
|
|
1526
1695
|
};
|
|
1527
1696
|
return apiConfig.httpClient.put(
|
|
1528
1697
|
`/v1/stores/${target_store_id}/orders/${params.id}`,
|
|
@@ -1573,7 +1742,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
1573
1742
|
`/v1/stores/${target_store_id}/carts`,
|
|
1574
1743
|
{
|
|
1575
1744
|
...payload,
|
|
1576
|
-
items:
|
|
1745
|
+
items: payload.items || []
|
|
1577
1746
|
},
|
|
1578
1747
|
options
|
|
1579
1748
|
);
|
|
@@ -1585,7 +1754,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
1585
1754
|
`/v1/stores/${target_store_id}/carts/${id}`,
|
|
1586
1755
|
{
|
|
1587
1756
|
...payload,
|
|
1588
|
-
...items ? { items
|
|
1757
|
+
...items ? { items } : {}
|
|
1589
1758
|
},
|
|
1590
1759
|
options
|
|
1591
1760
|
);
|
|
@@ -1595,7 +1764,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
1595
1764
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1596
1765
|
return apiConfig.httpClient.post(
|
|
1597
1766
|
`/v1/stores/${target_store_id}/carts/${id}/items`,
|
|
1598
|
-
{ item
|
|
1767
|
+
{ item },
|
|
1599
1768
|
options
|
|
1600
1769
|
);
|
|
1601
1770
|
},
|
|
@@ -1649,27 +1818,134 @@ var createEshopApi = (apiConfig) => {
|
|
|
1649
1818
|
`/v1/stores/${target_store_id}/orders/quote`,
|
|
1650
1819
|
{
|
|
1651
1820
|
...rest,
|
|
1652
|
-
items
|
|
1821
|
+
items,
|
|
1653
1822
|
shipping_address,
|
|
1654
1823
|
market: rest.market || apiConfig.market
|
|
1655
1824
|
},
|
|
1656
1825
|
options
|
|
1657
1826
|
);
|
|
1658
1827
|
},
|
|
1659
|
-
async
|
|
1828
|
+
async createRefund(params, options) {
|
|
1829
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1830
|
+
const response = await apiConfig.httpClient.post(
|
|
1831
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/refunds`,
|
|
1832
|
+
{
|
|
1833
|
+
amount: params.amount,
|
|
1834
|
+
refund_id: params.refund_id
|
|
1835
|
+
},
|
|
1836
|
+
options
|
|
1837
|
+
);
|
|
1838
|
+
if (response.refund_id !== params.refund_id) {
|
|
1839
|
+
throw new Error(
|
|
1840
|
+
"Refund response did not match the requested refund_id"
|
|
1841
|
+
);
|
|
1842
|
+
}
|
|
1843
|
+
if (!Number.isSafeInteger(response.amount) || response.amount !== params.amount) {
|
|
1844
|
+
throw new Error("Refund response did not match the requested amount");
|
|
1845
|
+
}
|
|
1846
|
+
if (![
|
|
1847
|
+
"requested",
|
|
1848
|
+
"processing",
|
|
1849
|
+
"succeeded",
|
|
1850
|
+
"rejected",
|
|
1851
|
+
"failed",
|
|
1852
|
+
"unknown"
|
|
1853
|
+
].includes(response.status)) {
|
|
1854
|
+
throw new Error("Refund response contained an invalid status");
|
|
1855
|
+
}
|
|
1856
|
+
return response;
|
|
1857
|
+
},
|
|
1858
|
+
async retryRefund(params, options) {
|
|
1859
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1660
1860
|
return apiConfig.httpClient.post(
|
|
1661
|
-
`/v1/stores/${
|
|
1662
|
-
{
|
|
1861
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/refunds/${params.refund_id}/retry`,
|
|
1862
|
+
{},
|
|
1663
1863
|
options
|
|
1664
1864
|
);
|
|
1665
1865
|
},
|
|
1866
|
+
async getPayment(params, options) {
|
|
1867
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1868
|
+
return apiConfig.httpClient.get(
|
|
1869
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/payment`,
|
|
1870
|
+
options
|
|
1871
|
+
);
|
|
1872
|
+
},
|
|
1873
|
+
async retryPaymentTransaction(params, options) {
|
|
1874
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1875
|
+
return apiConfig.httpClient.post(
|
|
1876
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/payment/transactions/${params.transaction_id}/retry`,
|
|
1877
|
+
{},
|
|
1878
|
+
options
|
|
1879
|
+
);
|
|
1880
|
+
},
|
|
1881
|
+
async getPaymentTransactions(params, options) {
|
|
1882
|
+
const { order_id, store_id, ...queryParams } = params;
|
|
1883
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1884
|
+
return apiConfig.httpClient.get(
|
|
1885
|
+
`/v1/stores/${target_store_id}/orders/${order_id}/payment/transactions`,
|
|
1886
|
+
{ ...options, params: queryParams }
|
|
1887
|
+
);
|
|
1888
|
+
},
|
|
1889
|
+
async getPaymentTransaction(params, options) {
|
|
1890
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1891
|
+
return apiConfig.httpClient.get(
|
|
1892
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/payment/transactions/${params.transaction_id}`,
|
|
1893
|
+
options
|
|
1894
|
+
);
|
|
1895
|
+
},
|
|
1896
|
+
async getRefund(params, options) {
|
|
1897
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1898
|
+
return apiConfig.httpClient.get(
|
|
1899
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/refunds/${params.refund_id}`,
|
|
1900
|
+
options
|
|
1901
|
+
);
|
|
1902
|
+
},
|
|
1903
|
+
async getRefunds(params, options) {
|
|
1904
|
+
const { order_id, store_id, ...queryParams } = params;
|
|
1905
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1906
|
+
return apiConfig.httpClient.get(
|
|
1907
|
+
`/v1/stores/${target_store_id}/orders/${order_id}/refunds`,
|
|
1908
|
+
{ ...options, params: queryParams }
|
|
1909
|
+
);
|
|
1910
|
+
},
|
|
1666
1911
|
async downloadDigitalAccess(params, options) {
|
|
1667
1912
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1668
1913
|
return apiConfig.httpClient.post(
|
|
1669
|
-
`/v1/stores/${target_store_id}/orders/${params.
|
|
1914
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/digital-access/${params.grant_id}/download`,
|
|
1915
|
+
{},
|
|
1916
|
+
options
|
|
1917
|
+
);
|
|
1918
|
+
},
|
|
1919
|
+
async activateDigitalAccess(params, options) {
|
|
1920
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1921
|
+
return apiConfig.httpClient.post(
|
|
1922
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/digital-access/${params.grant_id}/activate`,
|
|
1923
|
+
{},
|
|
1924
|
+
options
|
|
1925
|
+
);
|
|
1926
|
+
},
|
|
1927
|
+
async revokeDigitalAccess(params, options) {
|
|
1928
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1929
|
+
return apiConfig.httpClient.post(
|
|
1930
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/digital-access/${params.grant_id}/revoke`,
|
|
1670
1931
|
{},
|
|
1671
1932
|
options
|
|
1672
1933
|
);
|
|
1934
|
+
},
|
|
1935
|
+
async findDigitalAccess(params, options) {
|
|
1936
|
+
const { order_id, store_id, ...queryParams } = params;
|
|
1937
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1938
|
+
return apiConfig.httpClient.get(
|
|
1939
|
+
`/v1/stores/${target_store_id}/orders/${order_id}/digital-access`,
|
|
1940
|
+
{ ...options, params: queryParams }
|
|
1941
|
+
);
|
|
1942
|
+
},
|
|
1943
|
+
async getDigitalAccess(params, options) {
|
|
1944
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1945
|
+
return apiConfig.httpClient.get(
|
|
1946
|
+
`/v1/stores/${target_store_id}/orders/${params.order_id}/digital-access/${params.grant_id}`,
|
|
1947
|
+
options
|
|
1948
|
+
);
|
|
1673
1949
|
}
|
|
1674
1950
|
};
|
|
1675
1951
|
};
|
|
@@ -1868,17 +2144,27 @@ var createContactApi = (apiConfig) => {
|
|
|
1868
2144
|
options
|
|
1869
2145
|
);
|
|
1870
2146
|
},
|
|
1871
|
-
async
|
|
2147
|
+
async findSessions(params, options) {
|
|
2148
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2149
|
+
const queryParams = {};
|
|
2150
|
+
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
2151
|
+
if (params.cursor) queryParams.cursor = params.cursor;
|
|
2152
|
+
return apiConfig.httpClient.get(
|
|
2153
|
+
`/v1/stores/${store_id}/contacts/${params.contact_id}/sessions`,
|
|
2154
|
+
{ ...options, params: queryParams }
|
|
2155
|
+
);
|
|
2156
|
+
},
|
|
2157
|
+
async revokeSession(params, options) {
|
|
1872
2158
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1873
2159
|
return apiConfig.httpClient.delete(
|
|
1874
|
-
`/v1/stores/${store_id}/contacts/${params.
|
|
2160
|
+
`/v1/stores/${store_id}/contacts/${params.contact_id}/sessions/${params.session_id}`,
|
|
1875
2161
|
options
|
|
1876
2162
|
);
|
|
1877
2163
|
},
|
|
1878
|
-
async
|
|
2164
|
+
async revokeAllSessions(params, options) {
|
|
1879
2165
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1880
2166
|
return apiConfig.httpClient.delete(
|
|
1881
|
-
`/v1/stores/${store_id}/contacts/${params.
|
|
2167
|
+
`/v1/stores/${store_id}/contacts/${params.contact_id}/sessions`,
|
|
1882
2168
|
options
|
|
1883
2169
|
);
|
|
1884
2170
|
},
|
|
@@ -1916,6 +2202,49 @@ var createContactApi = (apiConfig) => {
|
|
|
1916
2202
|
{ ...options, params: queryParams }
|
|
1917
2203
|
);
|
|
1918
2204
|
},
|
|
2205
|
+
plans: {
|
|
2206
|
+
async create(params, options) {
|
|
2207
|
+
const { store_id, contact_list_id, ...payload } = params;
|
|
2208
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2209
|
+
return apiConfig.httpClient.post(
|
|
2210
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/plans`,
|
|
2211
|
+
payload,
|
|
2212
|
+
options
|
|
2213
|
+
);
|
|
2214
|
+
},
|
|
2215
|
+
async update(params, options) {
|
|
2216
|
+
const { id, store_id, contact_list_id, ...payload } = params;
|
|
2217
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2218
|
+
return apiConfig.httpClient.put(
|
|
2219
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/plans/${id}`,
|
|
2220
|
+
payload,
|
|
2221
|
+
options
|
|
2222
|
+
);
|
|
2223
|
+
},
|
|
2224
|
+
async get(params, options) {
|
|
2225
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2226
|
+
return apiConfig.httpClient.get(
|
|
2227
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/plans/${params.id}`,
|
|
2228
|
+
options
|
|
2229
|
+
);
|
|
2230
|
+
},
|
|
2231
|
+
async find(params, options) {
|
|
2232
|
+
const { store_id, contact_list_id, ...queryParams } = params;
|
|
2233
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2234
|
+
return apiConfig.httpClient.get(
|
|
2235
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/plans`,
|
|
2236
|
+
{ ...options, params: queryParams }
|
|
2237
|
+
);
|
|
2238
|
+
},
|
|
2239
|
+
async retryCatalog(params, options) {
|
|
2240
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2241
|
+
return apiConfig.httpClient.post(
|
|
2242
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/plans/${params.plan_id}/catalog/retry`,
|
|
2243
|
+
{},
|
|
2244
|
+
options
|
|
2245
|
+
);
|
|
2246
|
+
}
|
|
2247
|
+
},
|
|
1919
2248
|
async importContacts(params, options) {
|
|
1920
2249
|
const { store_id, contact_list_id, ...payload } = params;
|
|
1921
2250
|
const target_store_id = store_id || apiConfig.storeId;
|
|
@@ -1972,9 +2301,102 @@ var createContactApi = (apiConfig) => {
|
|
|
1972
2301
|
{ ...options, params: queryParams }
|
|
1973
2302
|
);
|
|
1974
2303
|
}
|
|
2304
|
+
},
|
|
2305
|
+
memberships: {
|
|
2306
|
+
async refund(params, options) {
|
|
2307
|
+
const { store_id, contact_list_id, membership_id, ...payload } = params;
|
|
2308
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2309
|
+
const response = await apiConfig.httpClient.post(
|
|
2310
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/memberships/${membership_id}/refund`,
|
|
2311
|
+
payload,
|
|
2312
|
+
options
|
|
2313
|
+
);
|
|
2314
|
+
if (response.refund_id !== params.refund_id) {
|
|
2315
|
+
throw new Error(
|
|
2316
|
+
"Membership refund response did not match the requested refund_id"
|
|
2317
|
+
);
|
|
2318
|
+
}
|
|
2319
|
+
return response;
|
|
2320
|
+
},
|
|
2321
|
+
paymentAttempts: {
|
|
2322
|
+
async find(params, options) {
|
|
2323
|
+
const { store_id, contact_list_id, membership_id, ...queryParams } = params;
|
|
2324
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2325
|
+
return apiConfig.httpClient.get(
|
|
2326
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/memberships/${membership_id}/payment-attempts`,
|
|
2327
|
+
{ ...options, params: queryParams }
|
|
2328
|
+
);
|
|
2329
|
+
},
|
|
2330
|
+
async get(params, options) {
|
|
2331
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2332
|
+
return apiConfig.httpClient.get(
|
|
2333
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/payment-attempts/${params.id}`,
|
|
2334
|
+
options
|
|
2335
|
+
);
|
|
2336
|
+
}
|
|
2337
|
+
},
|
|
2338
|
+
refunds: {
|
|
2339
|
+
async find(params, options) {
|
|
2340
|
+
const { store_id, contact_list_id, membership_id, ...queryParams } = params;
|
|
2341
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2342
|
+
return apiConfig.httpClient.get(
|
|
2343
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/memberships/${membership_id}/refunds`,
|
|
2344
|
+
{ ...options, params: queryParams }
|
|
2345
|
+
);
|
|
2346
|
+
},
|
|
2347
|
+
async get(params, options) {
|
|
2348
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2349
|
+
return apiConfig.httpClient.get(
|
|
2350
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/refunds/${params.id}`,
|
|
2351
|
+
options
|
|
2352
|
+
);
|
|
2353
|
+
},
|
|
2354
|
+
async retry(params, options) {
|
|
2355
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2356
|
+
return apiConfig.httpClient.post(
|
|
2357
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/refunds/${params.id}/retry`,
|
|
2358
|
+
{},
|
|
2359
|
+
options
|
|
2360
|
+
);
|
|
2361
|
+
}
|
|
2362
|
+
},
|
|
2363
|
+
cancellations: {
|
|
2364
|
+
async find(params, options) {
|
|
2365
|
+
const { store_id, contact_list_id, membership_id, ...queryParams } = params;
|
|
2366
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2367
|
+
return apiConfig.httpClient.get(
|
|
2368
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/memberships/${membership_id}/cancellations`,
|
|
2369
|
+
{ ...options, params: queryParams }
|
|
2370
|
+
);
|
|
2371
|
+
},
|
|
2372
|
+
async get(params, options) {
|
|
2373
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2374
|
+
return apiConfig.httpClient.get(
|
|
2375
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/cancellations/${params.id}`,
|
|
2376
|
+
options
|
|
2377
|
+
);
|
|
2378
|
+
},
|
|
2379
|
+
async retry(params, options) {
|
|
2380
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2381
|
+
return apiConfig.httpClient.post(
|
|
2382
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/cancellations/${params.id}/retry`,
|
|
2383
|
+
{},
|
|
2384
|
+
options
|
|
2385
|
+
);
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
1975
2388
|
}
|
|
1976
2389
|
},
|
|
1977
2390
|
mailbox: {
|
|
2391
|
+
async connectGoogle(params, options) {
|
|
2392
|
+
const { store_id, ...payload } = params;
|
|
2393
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2394
|
+
return apiConfig.httpClient.post(
|
|
2395
|
+
`/v1/stores/${target_store_id}/mailboxes/google/connect-url`,
|
|
2396
|
+
payload,
|
|
2397
|
+
options
|
|
2398
|
+
);
|
|
2399
|
+
},
|
|
1978
2400
|
async create(params, options) {
|
|
1979
2401
|
const { store_id, ...payload } = params;
|
|
1980
2402
|
const target_store_id = store_id || apiConfig.storeId;
|
|
@@ -2231,28 +2653,49 @@ function supportConversationQuery(params) {
|
|
|
2231
2653
|
if (params.after_id) qs.set("after_id", params.after_id);
|
|
2232
2654
|
return qs.toString();
|
|
2233
2655
|
}
|
|
2656
|
+
function storefrontSupportOptions(supportToken, options) {
|
|
2657
|
+
if (!/^[0-9a-f]{64}$/.test(supportToken)) {
|
|
2658
|
+
throw new Error("support_token must be a 64-character lowercase hexadecimal token");
|
|
2659
|
+
}
|
|
2660
|
+
const headers = { ...options?.headers };
|
|
2661
|
+
for (const name of Object.keys(headers)) {
|
|
2662
|
+
if (name.toLowerCase() === "x-arky-support-token") delete headers[name];
|
|
2663
|
+
}
|
|
2664
|
+
return {
|
|
2665
|
+
...options,
|
|
2666
|
+
headers: {
|
|
2667
|
+
...headers,
|
|
2668
|
+
"X-Arky-Support-Token": supportToken
|
|
2669
|
+
}
|
|
2670
|
+
};
|
|
2671
|
+
}
|
|
2234
2672
|
function createStorefrontSupportApi(config) {
|
|
2235
|
-
const { httpClient
|
|
2673
|
+
const { httpClient } = config;
|
|
2236
2674
|
return {
|
|
2237
2675
|
async startConversation(params = {}, opts) {
|
|
2676
|
+
const storeId = config.storeId;
|
|
2238
2677
|
return httpClient.post(
|
|
2239
2678
|
`/v1/storefront/${storeId}/support/conversations`,
|
|
2240
|
-
{ store_id: storeId
|
|
2679
|
+
{ ...params, store_id: storeId },
|
|
2241
2680
|
opts
|
|
2242
2681
|
);
|
|
2243
2682
|
},
|
|
2244
2683
|
async sendMessage(params, opts) {
|
|
2684
|
+
const { support_token, ...request } = params;
|
|
2685
|
+
const storeId = config.storeId;
|
|
2245
2686
|
return httpClient.post(
|
|
2246
|
-
`/v1/storefront/${storeId}/support/conversations/${
|
|
2247
|
-
{ store_id: storeId
|
|
2248
|
-
opts
|
|
2687
|
+
`/v1/storefront/${storeId}/support/conversations/${request.conversation_id}/messages`,
|
|
2688
|
+
{ ...request, store_id: storeId },
|
|
2689
|
+
storefrontSupportOptions(support_token, opts)
|
|
2249
2690
|
);
|
|
2250
2691
|
},
|
|
2251
2692
|
async getConversation(params, opts) {
|
|
2252
|
-
const
|
|
2693
|
+
const { support_token, ...request } = params;
|
|
2694
|
+
const storeId = config.storeId;
|
|
2695
|
+
const qs = supportConversationQuery({ ...request, store_id: storeId });
|
|
2253
2696
|
return httpClient.get(
|
|
2254
|
-
`/v1/storefront/${storeId}/support/conversations/${
|
|
2255
|
-
opts
|
|
2697
|
+
`/v1/storefront/${storeId}/support/conversations/${request.conversation_id}?${qs}`,
|
|
2698
|
+
storefrontSupportOptions(support_token, opts)
|
|
2256
2699
|
);
|
|
2257
2700
|
}
|
|
2258
2701
|
};
|
|
@@ -2574,11 +3017,50 @@ var createSocialApi = (apiConfig) => {
|
|
|
2574
3017
|
options
|
|
2575
3018
|
);
|
|
2576
3019
|
},
|
|
2577
|
-
async
|
|
2578
|
-
const { store_id, publication_id, comment_id,
|
|
3020
|
+
async createCommentReply(params, options) {
|
|
3021
|
+
const { store_id, publication_id, comment_id, ...payload } = params;
|
|
3022
|
+
return apiConfig.httpClient.post(
|
|
3023
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/replies`,
|
|
3024
|
+
payload,
|
|
3025
|
+
options
|
|
3026
|
+
);
|
|
3027
|
+
},
|
|
3028
|
+
async listCommentReplies(params, options) {
|
|
3029
|
+
const { store_id, publication_id, comment_id, ...queryParams } = params;
|
|
3030
|
+
return apiConfig.httpClient.get(
|
|
3031
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/replies`,
|
|
3032
|
+
{
|
|
3033
|
+
...options,
|
|
3034
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
3035
|
+
}
|
|
3036
|
+
);
|
|
3037
|
+
},
|
|
3038
|
+
async getCommentReply(params, options) {
|
|
3039
|
+
return apiConfig.httpClient.get(
|
|
3040
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/comments/${params.comment_id}/replies/${params.reply_id}`,
|
|
3041
|
+
options
|
|
3042
|
+
);
|
|
3043
|
+
},
|
|
3044
|
+
async retryCommentReply(params, options) {
|
|
2579
3045
|
return apiConfig.httpClient.post(
|
|
2580
|
-
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/
|
|
2581
|
-
{
|
|
3046
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/comments/${params.comment_id}/replies/${params.reply_id}/retry`,
|
|
3047
|
+
{},
|
|
3048
|
+
options
|
|
3049
|
+
);
|
|
3050
|
+
},
|
|
3051
|
+
async listPublicationEffects(params, options) {
|
|
3052
|
+
const { store_id, publication_id, ...queryParams } = params;
|
|
3053
|
+
return apiConfig.httpClient.get(
|
|
3054
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/effects`,
|
|
3055
|
+
{
|
|
3056
|
+
...options,
|
|
3057
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
3058
|
+
}
|
|
3059
|
+
);
|
|
3060
|
+
},
|
|
3061
|
+
async getPublicationEffect(params, options) {
|
|
3062
|
+
return apiConfig.httpClient.get(
|
|
3063
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/effects/${params.effect_id}`,
|
|
2582
3064
|
options
|
|
2583
3065
|
);
|
|
2584
3066
|
},
|
|
@@ -2605,41 +3087,41 @@ var createSocialApi = (apiConfig) => {
|
|
|
2605
3087
|
},
|
|
2606
3088
|
async getCapabilities(params, options) {
|
|
2607
3089
|
return apiConfig.httpClient.get(
|
|
2608
|
-
`/v1/stores/${storeId(params?.store_id)}/social-
|
|
3090
|
+
`/v1/stores/${storeId(params?.store_id)}/social-connections/capabilities`,
|
|
2609
3091
|
options
|
|
2610
3092
|
);
|
|
2611
3093
|
},
|
|
2612
|
-
async
|
|
3094
|
+
async listConnections(params, options) {
|
|
2613
3095
|
return apiConfig.httpClient.get(
|
|
2614
|
-
`/v1/stores/${storeId(params?.store_id)}/social-
|
|
3096
|
+
`/v1/stores/${storeId(params?.store_id)}/social-connections`,
|
|
2615
3097
|
options
|
|
2616
3098
|
);
|
|
2617
3099
|
},
|
|
2618
3100
|
async connect(params, options) {
|
|
2619
3101
|
const { store_id, ...payload } = params;
|
|
2620
3102
|
return apiConfig.httpClient.post(
|
|
2621
|
-
`/v1/stores/${storeId(store_id)}/social-
|
|
3103
|
+
`/v1/stores/${storeId(store_id)}/social-connections/oauth/connect`,
|
|
2622
3104
|
payload,
|
|
2623
3105
|
options
|
|
2624
3106
|
);
|
|
2625
3107
|
},
|
|
2626
3108
|
async getOAuthAttempt(params, options) {
|
|
2627
3109
|
return apiConfig.httpClient.get(
|
|
2628
|
-
`/v1/stores/${storeId(params.store_id)}/social-
|
|
3110
|
+
`/v1/stores/${storeId(params.store_id)}/social-connections/oauth/attempts/${params.attempt_id}`,
|
|
2629
3111
|
options
|
|
2630
3112
|
);
|
|
2631
3113
|
},
|
|
2632
3114
|
async selectDestination(params, options) {
|
|
2633
3115
|
const { store_id, ...payload } = params;
|
|
2634
3116
|
return apiConfig.httpClient.post(
|
|
2635
|
-
`/v1/stores/${storeId(store_id)}/social-
|
|
3117
|
+
`/v1/stores/${storeId(store_id)}/social-connections/oauth/select-destination`,
|
|
2636
3118
|
payload,
|
|
2637
3119
|
options
|
|
2638
3120
|
);
|
|
2639
3121
|
},
|
|
2640
|
-
async
|
|
3122
|
+
async deleteConnection(params, options) {
|
|
2641
3123
|
return apiConfig.httpClient.delete(
|
|
2642
|
-
`/v1/stores/${storeId(params.store_id)}/social-
|
|
3124
|
+
`/v1/stores/${storeId(params.store_id)}/social-connections/${params.id}`,
|
|
2643
3125
|
options
|
|
2644
3126
|
);
|
|
2645
3127
|
},
|
|
@@ -2725,26 +3207,44 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
2725
3207
|
options
|
|
2726
3208
|
);
|
|
2727
3209
|
},
|
|
2728
|
-
async
|
|
3210
|
+
async getWorkflowEffects(params, options) {
|
|
3211
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
3212
|
+
const { store_id: _, workflow_id, execution_id, ...queryParams } = params;
|
|
3213
|
+
return apiConfig.httpClient.get(
|
|
3214
|
+
`/v1/stores/${store_id}/workflows/${workflow_id}/executions/${execution_id}/effects`,
|
|
3215
|
+
{
|
|
3216
|
+
...options,
|
|
3217
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
3218
|
+
}
|
|
3219
|
+
);
|
|
3220
|
+
},
|
|
3221
|
+
async getWorkflowEffect(params, options) {
|
|
3222
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
3223
|
+
return apiConfig.httpClient.get(
|
|
3224
|
+
`/v1/stores/${store_id}/workflows/${params.workflow_id}/executions/${params.execution_id}/effects/${params.effect_id}`,
|
|
3225
|
+
options
|
|
3226
|
+
);
|
|
3227
|
+
},
|
|
3228
|
+
async getWorkflowConnections(params, options) {
|
|
2729
3229
|
const store_id = params?.store_id || apiConfig.storeId;
|
|
2730
3230
|
return apiConfig.httpClient.get(
|
|
2731
|
-
`/v1/stores/${store_id}/workflow-
|
|
3231
|
+
`/v1/stores/${store_id}/workflow-connections`,
|
|
2732
3232
|
options
|
|
2733
3233
|
);
|
|
2734
3234
|
},
|
|
2735
|
-
async
|
|
3235
|
+
async getWorkflowConnectionConnectUrl(params, options) {
|
|
2736
3236
|
const { store_id, type, ...payload } = params;
|
|
2737
3237
|
const target_store_id = store_id || apiConfig.storeId;
|
|
2738
3238
|
return apiConfig.httpClient.post(
|
|
2739
|
-
`/v1/stores/${target_store_id}/workflow-
|
|
3239
|
+
`/v1/stores/${target_store_id}/workflow-connections/connect-url`,
|
|
2740
3240
|
{ ...payload, type, store_id: target_store_id },
|
|
2741
3241
|
options
|
|
2742
3242
|
);
|
|
2743
3243
|
},
|
|
2744
|
-
async
|
|
3244
|
+
async deleteWorkflowConnection(params, options) {
|
|
2745
3245
|
const store_id = params.store_id || apiConfig.storeId;
|
|
2746
3246
|
return apiConfig.httpClient.delete(
|
|
2747
|
-
`/v1/stores/${store_id}/workflow-
|
|
3247
|
+
`/v1/stores/${store_id}/workflow-connections/${params.id}`,
|
|
2748
3248
|
options
|
|
2749
3249
|
);
|
|
2750
3250
|
}
|
|
@@ -2788,27 +3288,105 @@ var createPlatformApi = (apiConfig) => {
|
|
|
2788
3288
|
|
|
2789
3289
|
// src/api/shipping.ts
|
|
2790
3290
|
var createShippingApi = (apiConfig) => {
|
|
3291
|
+
const storeId = (value) => value || apiConfig.storeId;
|
|
2791
3292
|
return {
|
|
3293
|
+
async findFulfillmentOrders(params, options) {
|
|
3294
|
+
const { store_id, order_id, ...queryParams } = params;
|
|
3295
|
+
return apiConfig.httpClient.get(
|
|
3296
|
+
`/v1/stores/${storeId(store_id)}/orders/${order_id}/fulfillment-orders`,
|
|
3297
|
+
{ ...options, params: queryParams }
|
|
3298
|
+
);
|
|
3299
|
+
},
|
|
3300
|
+
async getFulfillmentOrder(params, options) {
|
|
3301
|
+
return apiConfig.httpClient.get(
|
|
3302
|
+
`/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/fulfillment-orders/${params.fulfillment_order_id}`,
|
|
3303
|
+
options
|
|
3304
|
+
);
|
|
3305
|
+
},
|
|
2792
3306
|
async getRates(params, options) {
|
|
2793
|
-
const { order_id, ...payload } = params;
|
|
3307
|
+
const { store_id, order_id, ...payload } = params;
|
|
2794
3308
|
return apiConfig.httpClient.post(
|
|
2795
|
-
`/v1/stores/${
|
|
3309
|
+
`/v1/stores/${storeId(store_id)}/orders/${order_id}/shipping/rates`,
|
|
2796
3310
|
payload,
|
|
2797
3311
|
options
|
|
2798
3312
|
);
|
|
2799
3313
|
},
|
|
2800
|
-
async
|
|
2801
|
-
const { order_id, ...
|
|
2802
|
-
return apiConfig.httpClient.
|
|
2803
|
-
`/v1/stores/${
|
|
3314
|
+
async findShipments(params, options) {
|
|
3315
|
+
const { store_id, order_id, ...queryParams } = params;
|
|
3316
|
+
return apiConfig.httpClient.get(
|
|
3317
|
+
`/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments`,
|
|
3318
|
+
{ ...options, params: queryParams }
|
|
3319
|
+
);
|
|
3320
|
+
},
|
|
3321
|
+
async getShipment(params, options) {
|
|
3322
|
+
return apiConfig.httpClient.get(
|
|
3323
|
+
`/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}`,
|
|
3324
|
+
options
|
|
3325
|
+
);
|
|
3326
|
+
},
|
|
3327
|
+
async createShipment(params, options) {
|
|
3328
|
+
const { store_id, order_id, ...payload } = params;
|
|
3329
|
+
const response = await apiConfig.httpClient.post(
|
|
3330
|
+
`/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments`,
|
|
2804
3331
|
payload,
|
|
2805
3332
|
options
|
|
2806
3333
|
);
|
|
3334
|
+
if (response.shipment_id !== params.shipment_id || response.shipment.id !== params.shipment_id) {
|
|
3335
|
+
throw new Error("Shipping response did not match the requested shipment_id");
|
|
3336
|
+
}
|
|
3337
|
+
return response;
|
|
3338
|
+
},
|
|
3339
|
+
async retryShipment(params, options) {
|
|
3340
|
+
return apiConfig.httpClient.post(
|
|
3341
|
+
`/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/retry`,
|
|
3342
|
+
{},
|
|
3343
|
+
options
|
|
3344
|
+
);
|
|
3345
|
+
},
|
|
3346
|
+
async requestRefund(params, options) {
|
|
3347
|
+
return apiConfig.httpClient.post(
|
|
3348
|
+
`/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/refunds`,
|
|
3349
|
+
{},
|
|
3350
|
+
options
|
|
3351
|
+
);
|
|
3352
|
+
},
|
|
3353
|
+
async findRefunds(params, options) {
|
|
3354
|
+
const { store_id, order_id, shipment_id, ...queryParams } = params;
|
|
3355
|
+
return apiConfig.httpClient.get(
|
|
3356
|
+
`/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments/${shipment_id}/refunds`,
|
|
3357
|
+
{ ...options, params: queryParams }
|
|
3358
|
+
);
|
|
3359
|
+
},
|
|
3360
|
+
async getRefund(params, options) {
|
|
3361
|
+
return apiConfig.httpClient.get(
|
|
3362
|
+
`/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/refunds/${params.refund_id}`,
|
|
3363
|
+
options
|
|
3364
|
+
);
|
|
3365
|
+
},
|
|
3366
|
+
async retryRefund(params, options) {
|
|
3367
|
+
return apiConfig.httpClient.post(
|
|
3368
|
+
`/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/refunds/${params.refund_id}/retry`,
|
|
3369
|
+
{},
|
|
3370
|
+
options
|
|
3371
|
+
);
|
|
3372
|
+
},
|
|
3373
|
+
async findAdjustments(params, options) {
|
|
3374
|
+
const { store_id, order_id, shipment_id, ...queryParams } = params;
|
|
3375
|
+
return apiConfig.httpClient.get(
|
|
3376
|
+
`/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments/${shipment_id}/adjustments`,
|
|
3377
|
+
{ ...options, params: queryParams }
|
|
3378
|
+
);
|
|
3379
|
+
},
|
|
3380
|
+
async findSettlements(params, options) {
|
|
3381
|
+
const { store_id, order_id, shipment_id, ...queryParams } = params;
|
|
3382
|
+
return apiConfig.httpClient.get(
|
|
3383
|
+
`/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments/${shipment_id}/settlements`,
|
|
3384
|
+
{ ...options, params: queryParams }
|
|
3385
|
+
);
|
|
2807
3386
|
},
|
|
2808
|
-
async
|
|
2809
|
-
const { order_id, shipment_id } = params;
|
|
3387
|
+
async retrySettlement(params, options) {
|
|
2810
3388
|
return apiConfig.httpClient.post(
|
|
2811
|
-
`/v1/stores/${
|
|
3389
|
+
`/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/settlements/${params.settlement_id}/retry`,
|
|
2812
3390
|
{},
|
|
2813
3391
|
options
|
|
2814
3392
|
);
|
|
@@ -3117,155 +3695,230 @@ var createExperimentsApi = (apiConfig) => {
|
|
|
3117
3695
|
};
|
|
3118
3696
|
|
|
3119
3697
|
// src/utils/blocks.ts
|
|
3120
|
-
function
|
|
3121
|
-
|
|
3122
|
-
return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) ?? "";
|
|
3698
|
+
function isRecord2(value) {
|
|
3699
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3123
3700
|
}
|
|
3124
|
-
function
|
|
3125
|
-
|
|
3126
|
-
const value = block.value;
|
|
3127
|
-
switch (block.type) {
|
|
3128
|
-
case "boolean":
|
|
3129
|
-
return value ? "Yes" : "No";
|
|
3130
|
-
case "number":
|
|
3131
|
-
if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
|
|
3132
|
-
return new Date(value).toLocaleDateString();
|
|
3133
|
-
}
|
|
3134
|
-
return String(value);
|
|
3135
|
-
case "media":
|
|
3136
|
-
if (value && typeof value === "object") {
|
|
3137
|
-
return value.mime_type ? value.name || value.id : value.title || value.name || value.id;
|
|
3138
|
-
}
|
|
3139
|
-
return String(value);
|
|
3140
|
-
default:
|
|
3141
|
-
return String(value);
|
|
3142
|
-
}
|
|
3701
|
+
function isBlock(value) {
|
|
3702
|
+
return isRecord2(value) && typeof value.key === "string" && typeof value.type === "string";
|
|
3143
3703
|
}
|
|
3144
|
-
function
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3704
|
+
function recordFromBlocks(values, locale) {
|
|
3705
|
+
const result = {};
|
|
3706
|
+
for (const value of values) {
|
|
3707
|
+
if (!isBlock(value)) continue;
|
|
3708
|
+
result[value.key] = unwrapBlock(value, locale);
|
|
3709
|
+
}
|
|
3710
|
+
return result;
|
|
3149
3711
|
}
|
|
3150
|
-
function
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
return values;
|
|
3712
|
+
function localizedValue(value, locale) {
|
|
3713
|
+
if (typeof value === "string") return value;
|
|
3714
|
+
if (!isRecord2(value)) return "";
|
|
3715
|
+
const selected = value[locale] ?? value.en;
|
|
3716
|
+
return typeof selected === "string" ? selected : "";
|
|
3156
3717
|
}
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
var getBlockTextValue = (block, locale = "en") => {
|
|
3162
|
-
if (!block || block.value === null || block.value === void 0) return "";
|
|
3163
|
-
const blockType = block.type;
|
|
3164
|
-
if (blockType === "localized_text" || blockType === "markdown") {
|
|
3165
|
-
if (typeof block.value === "object" && block.value !== null) {
|
|
3166
|
-
return block.value[locale] ?? block.value["en"] ?? "";
|
|
3167
|
-
}
|
|
3168
|
-
}
|
|
3169
|
-
if (typeof block.value === "string") return block.value;
|
|
3170
|
-
return String(block.value ?? "");
|
|
3171
|
-
};
|
|
3172
|
-
var getBlockValues = (entry, blockKey) => {
|
|
3173
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
3174
|
-
if (!block) return [];
|
|
3175
|
-
if (block.type === "array" && Array.isArray(block.value)) {
|
|
3176
|
-
return block.value;
|
|
3718
|
+
function unwrapBlock(value, locale) {
|
|
3719
|
+
if (!isBlock(value)) return value;
|
|
3720
|
+
if (value.type === "localized_text" || value.type === "markdown") {
|
|
3721
|
+
return localizedValue(value.value, locale);
|
|
3177
3722
|
}
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
return block.value.map((obj) => {
|
|
3185
|
-
const parsed = {};
|
|
3186
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
3187
|
-
parsed[k] = unwrapBlock(v, locale);
|
|
3723
|
+
if (value.type === "array") {
|
|
3724
|
+
if (!Array.isArray(value.value)) return [];
|
|
3725
|
+
return value.value.map((item) => {
|
|
3726
|
+
if (isBlock(item)) return unwrapBlock(item, locale);
|
|
3727
|
+
if (isRecord2(item) && Array.isArray(item.value)) {
|
|
3728
|
+
return recordFromBlocks(item.value, locale);
|
|
3188
3729
|
}
|
|
3189
|
-
return
|
|
3730
|
+
if (!isRecord2(item)) return item;
|
|
3731
|
+
return Object.fromEntries(
|
|
3732
|
+
Object.entries(item).map(([key, nested]) => [key, unwrapBlock(nested, locale)])
|
|
3733
|
+
);
|
|
3190
3734
|
});
|
|
3191
3735
|
}
|
|
3192
|
-
if (
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3736
|
+
if (value.type === "object") {
|
|
3737
|
+
if (Array.isArray(value.value)) return recordFromBlocks(value.value, locale);
|
|
3738
|
+
if (!isRecord2(value.value)) return {};
|
|
3739
|
+
return Object.fromEntries(
|
|
3740
|
+
Object.entries(value.value).map(([key, nested]) => [key, unwrapBlock(nested, locale)])
|
|
3741
|
+
);
|
|
3198
3742
|
}
|
|
3199
|
-
|
|
3200
|
-
|
|
3743
|
+
return value.value;
|
|
3744
|
+
}
|
|
3745
|
+
function blockContentArray(values, locale) {
|
|
3746
|
+
const blocks = values.filter(isBlock);
|
|
3747
|
+
if (blocks.length === 0) return [];
|
|
3748
|
+
if (blocks.every((block) => block.key === blocks[0].key)) {
|
|
3749
|
+
return blocks.map((block) => blockContentValue(block, locale));
|
|
3201
3750
|
}
|
|
3202
|
-
return
|
|
3751
|
+
return Object.fromEntries(
|
|
3752
|
+
blocks.map((block) => [block.key, blockContentValue(block, locale)])
|
|
3753
|
+
);
|
|
3203
3754
|
}
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
return acc;
|
|
3212
|
-
}, {});
|
|
3213
|
-
});
|
|
3214
|
-
};
|
|
3215
|
-
var getBlockFromArray = (entry, blockKey, locale = "en") => {
|
|
3216
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
3217
|
-
if (!block) return {};
|
|
3218
|
-
if (block.type === "array" && Array.isArray(block.value)) {
|
|
3219
|
-
return block.value.reduce((acc, current) => {
|
|
3220
|
-
acc[current.key] = unwrapBlock(current, locale);
|
|
3221
|
-
return acc;
|
|
3222
|
-
}, {});
|
|
3755
|
+
function blockContentValue(block, locale) {
|
|
3756
|
+
if (block.type === "localized_text" || block.type === "markdown") {
|
|
3757
|
+
return localizedValue(block.value, locale);
|
|
3758
|
+
}
|
|
3759
|
+
if (block.type === "media") return block.value ?? null;
|
|
3760
|
+
if (block.type === "array") {
|
|
3761
|
+
return Array.isArray(block.value) ? blockContentArray(block.value, locale) : [];
|
|
3223
3762
|
}
|
|
3224
|
-
if (block.type === "object"
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3763
|
+
if (block.type === "object") {
|
|
3764
|
+
if (Array.isArray(block.value)) return blockContentArray(block.value, locale);
|
|
3765
|
+
if (!isRecord2(block.value)) return {};
|
|
3766
|
+
return Object.fromEntries(
|
|
3767
|
+
Object.entries(block.value).map(([key, value]) => [
|
|
3768
|
+
key,
|
|
3769
|
+
isBlock(value) ? blockContentValue(value, locale) : value
|
|
3770
|
+
])
|
|
3771
|
+
);
|
|
3772
|
+
}
|
|
3773
|
+
return block.value;
|
|
3774
|
+
}
|
|
3775
|
+
function findBlock(entry, key) {
|
|
3776
|
+
return entry?.blocks?.find((block) => block.key === key);
|
|
3777
|
+
}
|
|
3778
|
+
function getBlockLabel(block) {
|
|
3779
|
+
return block?.key.replace(/_/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase()) ?? "";
|
|
3780
|
+
}
|
|
3781
|
+
function formatBlockValue(block) {
|
|
3782
|
+
if (block?.value === null || block?.value === void 0) return "";
|
|
3783
|
+
if (block.type === "boolean") return block.value ? "Yes" : "No";
|
|
3784
|
+
if (block.type === "number") {
|
|
3785
|
+
const properties = isRecord2(block.properties) ? block.properties : {};
|
|
3786
|
+
if (properties.variant === "DATE" || properties.variant === "DATE_TIME") {
|
|
3787
|
+
return new Date(Number(block.value)).toLocaleDateString();
|
|
3228
3788
|
}
|
|
3229
|
-
return result;
|
|
3230
3789
|
}
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
if (!imageBlock) return null;
|
|
3235
|
-
if (imageBlock.type === "media") {
|
|
3236
|
-
const mediaValue = imageBlock.value;
|
|
3237
|
-
return mediaValue?.resolutions?.original?.url || mediaValue?.url || null;
|
|
3790
|
+
if (block.type === "media" && isRecord2(block.value)) {
|
|
3791
|
+
const label = block.value.name ?? block.value.title ?? block.value.id;
|
|
3792
|
+
return typeof label === "string" ? label : "";
|
|
3238
3793
|
}
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3794
|
+
return String(block.value);
|
|
3795
|
+
}
|
|
3796
|
+
function prepareBlocksForSubmission(formData, blockTypes = {}) {
|
|
3797
|
+
return Object.entries(formData).filter(([, value]) => value !== null && value !== void 0).map(([key, value]) => ({
|
|
3798
|
+
key,
|
|
3799
|
+
value: blockTypes[key] === "array" && !Array.isArray(value) ? [value] : value
|
|
3800
|
+
}));
|
|
3801
|
+
}
|
|
3802
|
+
function extractBlockValues(blocks) {
|
|
3803
|
+
return Object.fromEntries(blocks.map((block) => [block.key, block.value ?? null]));
|
|
3804
|
+
}
|
|
3805
|
+
function getBlockValue(entry, key) {
|
|
3806
|
+
return findBlock(entry, key)?.value ?? null;
|
|
3807
|
+
}
|
|
3808
|
+
function getBlockTextValue(block, locale = "en") {
|
|
3809
|
+
if (!block || block.value === null || block.value === void 0) return "";
|
|
3810
|
+
if (block.type === "localized_text" || block.type === "markdown") {
|
|
3811
|
+
return localizedValue(block.value, locale);
|
|
3242
3812
|
}
|
|
3243
|
-
return
|
|
3244
|
-
}
|
|
3813
|
+
return typeof block.value === "string" ? block.value : String(block.value);
|
|
3814
|
+
}
|
|
3815
|
+
function getBlockContentValue(entry, key, locale = "en") {
|
|
3816
|
+
const block = findBlock(entry, key);
|
|
3817
|
+
return block ? blockContentValue(block, locale) : null;
|
|
3818
|
+
}
|
|
3819
|
+
function getBlockValues(entry, key) {
|
|
3820
|
+
const block = findBlock(entry, key);
|
|
3821
|
+
return block?.type === "array" && Array.isArray(block.value) ? block.value : [];
|
|
3822
|
+
}
|
|
3823
|
+
function getBlockObjectValues(entry, key, locale = "en") {
|
|
3824
|
+
return getBlockValues(entry, key).map((value) => {
|
|
3825
|
+
if (isRecord2(value) && Array.isArray(value.value)) {
|
|
3826
|
+
return recordFromBlocks(value.value, locale);
|
|
3827
|
+
}
|
|
3828
|
+
return isRecord2(value) ? Object.fromEntries(
|
|
3829
|
+
Object.entries(value).map(([field, nested]) => [field, unwrapBlock(nested, locale)])
|
|
3830
|
+
) : {};
|
|
3831
|
+
});
|
|
3832
|
+
}
|
|
3833
|
+
function getBlockFromArray(entry, key, locale = "en") {
|
|
3834
|
+
const block = findBlock(entry, key);
|
|
3835
|
+
if (!block) return {};
|
|
3836
|
+
const value = unwrapBlock(block, locale);
|
|
3837
|
+
if (isRecord2(value)) return value;
|
|
3838
|
+
if (Array.isArray(block.value)) return recordFromBlocks(block.value, locale);
|
|
3839
|
+
return { [block.key]: value };
|
|
3840
|
+
}
|
|
3841
|
+
function nestedUrl(value) {
|
|
3842
|
+
const resolutions = isRecord2(value.resolutions) ? value.resolutions : null;
|
|
3843
|
+
const original = resolutions && isRecord2(resolutions.original) ? resolutions.original : null;
|
|
3844
|
+
if (typeof original?.url === "string") return original.url;
|
|
3845
|
+
return typeof value.url === "string" ? value.url : null;
|
|
3846
|
+
}
|
|
3847
|
+
function getImageUrl(value, isBlock2 = true) {
|
|
3848
|
+
if (typeof value === "string") return value;
|
|
3849
|
+
if (!isRecord2(value)) return null;
|
|
3850
|
+
if (value.type === "media" && isRecord2(value.value)) return nestedUrl(value.value);
|
|
3851
|
+
if (isBlock2 && typeof value.url === "string") return value.url;
|
|
3852
|
+
return nestedUrl(value);
|
|
3853
|
+
}
|
|
3245
3854
|
|
|
3246
3855
|
// src/utils/price.ts
|
|
3856
|
+
var SUPPORTED_STORE_CURRENCIES = Object.freeze([
|
|
3857
|
+
"USD",
|
|
3858
|
+
"EUR",
|
|
3859
|
+
"GBP",
|
|
3860
|
+
"JPY",
|
|
3861
|
+
"CNY",
|
|
3862
|
+
"CHF",
|
|
3863
|
+
"AUD",
|
|
3864
|
+
"CAD",
|
|
3865
|
+
"HKD",
|
|
3866
|
+
"SGD",
|
|
3867
|
+
"NZD",
|
|
3868
|
+
"KRW",
|
|
3869
|
+
"SEK",
|
|
3870
|
+
"NOK",
|
|
3871
|
+
"DKK",
|
|
3872
|
+
"INR",
|
|
3873
|
+
"MXN",
|
|
3874
|
+
"BRL",
|
|
3875
|
+
"ZAR",
|
|
3876
|
+
"RUB",
|
|
3877
|
+
"TRY",
|
|
3878
|
+
"PLN",
|
|
3879
|
+
"THB",
|
|
3880
|
+
"IDR",
|
|
3881
|
+
"MYR",
|
|
3882
|
+
"PHP",
|
|
3883
|
+
"CZK",
|
|
3884
|
+
"ILS",
|
|
3885
|
+
"AED",
|
|
3886
|
+
"SAR",
|
|
3887
|
+
"HUF",
|
|
3888
|
+
"RON",
|
|
3889
|
+
"BGN",
|
|
3890
|
+
"HRK",
|
|
3891
|
+
"BAM",
|
|
3892
|
+
"RSD",
|
|
3893
|
+
"MKD",
|
|
3894
|
+
"ALL"
|
|
3895
|
+
]);
|
|
3896
|
+
var SUPPORTED_STORE_CURRENCY_SET = Object.freeze(
|
|
3897
|
+
new Set(SUPPORTED_STORE_CURRENCIES)
|
|
3898
|
+
);
|
|
3899
|
+
var ZERO_MINOR_UNIT_STORE_CURRENCIES = Object.freeze(
|
|
3900
|
+
/* @__PURE__ */ new Set(["JPY", "KRW"])
|
|
3901
|
+
);
|
|
3247
3902
|
function formatCurrency(amount, currencyCode, locale = "en") {
|
|
3248
|
-
|
|
3903
|
+
const normalized = currencyCode.trim().toUpperCase();
|
|
3904
|
+
if (!normalized) return "";
|
|
3905
|
+
const minorUnits = getCurrencyMinorUnits(normalized);
|
|
3249
3906
|
return new Intl.NumberFormat(locale, {
|
|
3250
3907
|
style: "currency",
|
|
3251
|
-
currency:
|
|
3908
|
+
currency: normalized,
|
|
3909
|
+
minimumFractionDigits: minorUnits,
|
|
3910
|
+
maximumFractionDigits: minorUnits
|
|
3252
3911
|
}).format(amount);
|
|
3253
3912
|
}
|
|
3254
|
-
function
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
currency: currency.toUpperCase()
|
|
3259
|
-
});
|
|
3260
|
-
const parts = formatter.formatToParts(1.11);
|
|
3261
|
-
const fractionPart = parts.find((p) => p.type === "fraction");
|
|
3262
|
-
return fractionPart?.value.length ?? 2;
|
|
3263
|
-
} catch {
|
|
3264
|
-
return 2;
|
|
3913
|
+
function getCurrencyMinorUnits(currency) {
|
|
3914
|
+
const normalized = currency.trim().toUpperCase();
|
|
3915
|
+
if (!SUPPORTED_STORE_CURRENCY_SET.has(normalized)) {
|
|
3916
|
+
throw new RangeError(`Unsupported currency '${currency}'`);
|
|
3265
3917
|
}
|
|
3918
|
+
return ZERO_MINOR_UNIT_STORE_CURRENCIES.has(normalized) ? 0 : 2;
|
|
3266
3919
|
}
|
|
3267
3920
|
function convertToMajor(minorAmount, currency) {
|
|
3268
|
-
const units =
|
|
3921
|
+
const units = getCurrencyMinorUnits(currency);
|
|
3269
3922
|
return minorAmount / Math.pow(10, units);
|
|
3270
3923
|
}
|
|
3271
3924
|
function getCurrencySymbol(currency) {
|
|
@@ -3287,22 +3940,24 @@ function getCurrencyName(currency) {
|
|
|
3287
3940
|
}
|
|
3288
3941
|
}
|
|
3289
3942
|
function formatMinor(amountMinor, currency) {
|
|
3290
|
-
if (!
|
|
3943
|
+
if (!Number.isSafeInteger(amountMinor)) {
|
|
3944
|
+
throw new RangeError("Minor-unit amount must be a safe integer");
|
|
3945
|
+
}
|
|
3291
3946
|
return formatCurrency(convertToMajor(amountMinor, currency), currency);
|
|
3292
3947
|
}
|
|
3293
3948
|
function formatPayment(payment) {
|
|
3294
3949
|
return formatMinor(payment.total, payment.currency);
|
|
3295
3950
|
}
|
|
3296
3951
|
function formatPrice(prices, marketId) {
|
|
3297
|
-
if (!prices || prices.length === 0) return "";
|
|
3298
|
-
const price =
|
|
3299
|
-
if (!price) return "";
|
|
3952
|
+
if (!prices || prices.length === 0 || !marketId) return "";
|
|
3953
|
+
const price = prices.find((p) => p.market === marketId);
|
|
3954
|
+
if (!price || !Number.isSafeInteger(price.amount) || price.amount < 0 || !price.currency) return "";
|
|
3300
3955
|
return formatMinor(price.amount, price.currency);
|
|
3301
3956
|
}
|
|
3302
3957
|
function getPriceAmount(prices, marketId) {
|
|
3303
|
-
if (!prices || prices.length === 0) return
|
|
3304
|
-
const price = prices.find((p) => p.market === marketId)
|
|
3305
|
-
return price
|
|
3958
|
+
if (!prices || prices.length === 0 || !marketId) return null;
|
|
3959
|
+
const price = prices.find((p) => p.market === marketId);
|
|
3960
|
+
return price && Number.isSafeInteger(price.amount) && price.amount >= 0 ? price.amount : null;
|
|
3306
3961
|
}
|
|
3307
3962
|
|
|
3308
3963
|
// src/utils/validation.ts
|
|
@@ -3403,6 +4058,7 @@ function formatDate(date, locale) {
|
|
|
3403
4058
|
async function fetchSvgContent(mediaObject) {
|
|
3404
4059
|
if (!mediaObject) return null;
|
|
3405
4060
|
const svgUrl = getImageUrl(mediaObject, false);
|
|
4061
|
+
if (!svgUrl) return null;
|
|
3406
4062
|
try {
|
|
3407
4063
|
const response = await fetch(svgUrl);
|
|
3408
4064
|
if (!response.ok) {
|
|
@@ -3493,7 +4149,7 @@ function getFirstAvailableFCId(variant, quantity = 1) {
|
|
|
3493
4149
|
}
|
|
3494
4150
|
|
|
3495
4151
|
// src/index.ts
|
|
3496
|
-
var SDK_VERSION = "0.9.
|
|
4152
|
+
var SDK_VERSION = "0.9.16";
|
|
3497
4153
|
var SUPPORTED_FRAMEWORKS = [
|
|
3498
4154
|
"astro",
|
|
3499
4155
|
"react",
|
|
@@ -3503,9 +4159,10 @@ var SUPPORTED_FRAMEWORKS = [
|
|
|
3503
4159
|
];
|
|
3504
4160
|
function createUtilitySurface(apiConfig) {
|
|
3505
4161
|
return {
|
|
3506
|
-
getImageUrl: (imageBlock,
|
|
4162
|
+
getImageUrl: (imageBlock, isBlock2 = true) => getImageUrl(imageBlock, isBlock2),
|
|
3507
4163
|
getBlockValue,
|
|
3508
4164
|
getBlockTextValue,
|
|
4165
|
+
getBlockContentValue,
|
|
3509
4166
|
getBlockValues,
|
|
3510
4167
|
getBlockLabel,
|
|
3511
4168
|
getBlockObjectValues,
|
|
@@ -3656,9 +4313,11 @@ function createAdmin(config) {
|
|
|
3656
4313
|
trigger: workflowApi.triggerWorkflow,
|
|
3657
4314
|
getExecutions: workflowApi.getWorkflowExecutions,
|
|
3658
4315
|
getExecution: workflowApi.getWorkflowExecution,
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
4316
|
+
listEffects: workflowApi.getWorkflowEffects,
|
|
4317
|
+
getEffect: workflowApi.getWorkflowEffect,
|
|
4318
|
+
listConnections: workflowApi.getWorkflowConnections,
|
|
4319
|
+
getConnectionConnectUrl: workflowApi.getWorkflowConnectionConnectUrl,
|
|
4320
|
+
deleteConnection: workflowApi.deleteWorkflowConnection
|
|
3662
4321
|
};
|
|
3663
4322
|
const formApi = createFormApi(apiConfig);
|
|
3664
4323
|
const taxonomyApi = createTaxonomyApi(apiConfig);
|
|
@@ -3671,22 +4330,43 @@ function createAdmin(config) {
|
|
|
3671
4330
|
delete: accountApi.deleteAccount,
|
|
3672
4331
|
getMe: accountApi.getMe,
|
|
3673
4332
|
search: accountApi.searchAccounts,
|
|
4333
|
+
apiToken: {
|
|
4334
|
+
list: accountApi.listApiTokens,
|
|
4335
|
+
create: accountApi.createApiToken,
|
|
4336
|
+
update: accountApi.updateApiToken,
|
|
4337
|
+
revoke: accountApi.revokeApiToken
|
|
4338
|
+
},
|
|
4339
|
+
session: {
|
|
4340
|
+
list: accountApi.listSessions,
|
|
4341
|
+
revoke: accountApi.revokeSession
|
|
4342
|
+
},
|
|
3674
4343
|
auth: authApi
|
|
3675
4344
|
},
|
|
3676
4345
|
store: {
|
|
3677
4346
|
create: storeApi.createStore,
|
|
3678
4347
|
update: storeApi.updateStore,
|
|
3679
|
-
delete: storeApi.deleteStore,
|
|
3680
4348
|
get: storeApi.getStore,
|
|
3681
4349
|
find: storeApi.getStores,
|
|
3682
4350
|
subscription: {
|
|
4351
|
+
get: storeApi.getSubscription,
|
|
3683
4352
|
getPlans: storeApi.getSubscriptionPlans,
|
|
3684
|
-
|
|
4353
|
+
action: {
|
|
4354
|
+
create: storeApi.createSubscriptionAction,
|
|
4355
|
+
find: storeApi.findSubscriptionActions,
|
|
4356
|
+
get: storeApi.getSubscriptionAction,
|
|
4357
|
+
retry: storeApi.retrySubscriptionAction,
|
|
4358
|
+
effect: {
|
|
4359
|
+
find: storeApi.findSubscriptionActionEffects,
|
|
4360
|
+
get: storeApi.getSubscriptionActionEffect
|
|
4361
|
+
}
|
|
4362
|
+
},
|
|
3685
4363
|
createPortalSession: storeApi.createPortalSession
|
|
3686
4364
|
},
|
|
3687
4365
|
member: {
|
|
3688
4366
|
add: storeApi.addMember,
|
|
3689
4367
|
invite: storeApi.inviteUser,
|
|
4368
|
+
find: storeApi.findMembers,
|
|
4369
|
+
findOwn: storeApi.findOwnMemberships,
|
|
3690
4370
|
remove: storeApi.removeMember
|
|
3691
4371
|
},
|
|
3692
4372
|
buildHook: {
|
|
@@ -3703,10 +4383,7 @@ function createAdmin(config) {
|
|
|
3703
4383
|
delete: storeApi.deleteWebhook
|
|
3704
4384
|
},
|
|
3705
4385
|
config: {
|
|
3706
|
-
|
|
3707
|
-
},
|
|
3708
|
-
media: {
|
|
3709
|
-
find: storeApi.getStoreMedia
|
|
4386
|
+
getPayment: storeApi.getPaymentConfig
|
|
3710
4387
|
},
|
|
3711
4388
|
location: locationApi,
|
|
3712
4389
|
market: marketApi,
|
|
@@ -3715,22 +4392,21 @@ function createAdmin(config) {
|
|
|
3715
4392
|
media: createMediaApi(apiConfig),
|
|
3716
4393
|
notification: {
|
|
3717
4394
|
email: {
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
send: notificationApi.trigger
|
|
4395
|
+
send: notificationApi.sendEmail,
|
|
4396
|
+
getDelivery: notificationApi.getEmailDelivery,
|
|
4397
|
+
retryDelivery: notificationApi.retryEmailDelivery
|
|
3722
4398
|
},
|
|
3723
4399
|
mailbox: crmApi.mailbox
|
|
3724
4400
|
},
|
|
3725
4401
|
platform: platformApi,
|
|
3726
4402
|
social: {
|
|
3727
|
-
|
|
4403
|
+
connection: {
|
|
3728
4404
|
getCapabilities: socialApi.getCapabilities,
|
|
3729
|
-
list: socialApi.
|
|
4405
|
+
list: socialApi.listConnections,
|
|
3730
4406
|
connect: socialApi.connect,
|
|
3731
4407
|
getOAuthAttempt: socialApi.getOAuthAttempt,
|
|
3732
4408
|
selectDestination: socialApi.selectDestination,
|
|
3733
|
-
delete: socialApi.
|
|
4409
|
+
delete: socialApi.deleteConnection
|
|
3734
4410
|
},
|
|
3735
4411
|
publication: {
|
|
3736
4412
|
create: socialApi.createPublication,
|
|
@@ -3746,7 +4422,16 @@ function createAdmin(config) {
|
|
|
3746
4422
|
syncCommentThread: socialApi.syncPublicationCommentThread,
|
|
3747
4423
|
findComments: socialApi.findPublicationComments,
|
|
3748
4424
|
classifyComments: socialApi.classifyPublicationComments,
|
|
3749
|
-
|
|
4425
|
+
commentReply: {
|
|
4426
|
+
create: socialApi.createCommentReply,
|
|
4427
|
+
list: socialApi.listCommentReplies,
|
|
4428
|
+
get: socialApi.getCommentReply,
|
|
4429
|
+
retry: socialApi.retryCommentReply
|
|
4430
|
+
},
|
|
4431
|
+
effect: {
|
|
4432
|
+
list: socialApi.listPublicationEffects,
|
|
4433
|
+
get: socialApi.getPublicationEffect
|
|
4434
|
+
},
|
|
3750
4435
|
getMetrics: socialApi.getPublicationMetrics,
|
|
3751
4436
|
syncMetrics: socialApi.syncPublicationMetrics,
|
|
3752
4437
|
syncEngagement: socialApi.syncEngagement
|
|
@@ -3808,11 +4493,43 @@ function createAdmin(config) {
|
|
|
3808
4493
|
get: eshopApi.getOrder,
|
|
3809
4494
|
find: eshopApi.getOrders,
|
|
3810
4495
|
getQuote: eshopApi.getQuote,
|
|
3811
|
-
|
|
4496
|
+
createRefund: eshopApi.createRefund,
|
|
4497
|
+
getRefund: eshopApi.getRefund,
|
|
4498
|
+
getRefunds: eshopApi.getRefunds,
|
|
4499
|
+
retryRefund: eshopApi.retryRefund,
|
|
4500
|
+
getPayment: eshopApi.getPayment,
|
|
4501
|
+
retryPaymentTransaction: eshopApi.retryPaymentTransaction,
|
|
4502
|
+
getPaymentTransactions: eshopApi.getPaymentTransactions,
|
|
4503
|
+
getPaymentTransaction: eshopApi.getPaymentTransaction,
|
|
4504
|
+
findDigitalAccess: eshopApi.findDigitalAccess,
|
|
4505
|
+
getDigitalAccess: eshopApi.getDigitalAccess,
|
|
3812
4506
|
downloadDigitalAccess: eshopApi.downloadDigitalAccess,
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
4507
|
+
activateDigitalAccess: eshopApi.activateDigitalAccess,
|
|
4508
|
+
revokeDigitalAccess: eshopApi.revokeDigitalAccess
|
|
4509
|
+
},
|
|
4510
|
+
shipment: {
|
|
4511
|
+
getRates: shippingApi.getRates,
|
|
4512
|
+
create: shippingApi.createShipment,
|
|
4513
|
+
get: shippingApi.getShipment,
|
|
4514
|
+
find: shippingApi.findShipments,
|
|
4515
|
+
retry: shippingApi.retryShipment,
|
|
4516
|
+
fulfillment: {
|
|
4517
|
+
find: shippingApi.findFulfillmentOrders,
|
|
4518
|
+
get: shippingApi.getFulfillmentOrder
|
|
4519
|
+
},
|
|
4520
|
+
refund: {
|
|
4521
|
+
request: shippingApi.requestRefund,
|
|
4522
|
+
get: shippingApi.getRefund,
|
|
4523
|
+
find: shippingApi.findRefunds,
|
|
4524
|
+
retry: shippingApi.retryRefund
|
|
4525
|
+
},
|
|
4526
|
+
adjustment: {
|
|
4527
|
+
find: shippingApi.findAdjustments
|
|
4528
|
+
},
|
|
4529
|
+
settlement: {
|
|
4530
|
+
find: shippingApi.findSettlements,
|
|
4531
|
+
retry: shippingApi.retrySettlement
|
|
4532
|
+
}
|
|
3816
4533
|
},
|
|
3817
4534
|
cart: {
|
|
3818
4535
|
create: eshopApi.createCart,
|
|
@@ -3854,8 +4571,9 @@ function createAdmin(config) {
|
|
|
3854
4571
|
update: crmApi.update,
|
|
3855
4572
|
merge: crmApi.merge,
|
|
3856
4573
|
import: crmApi.import,
|
|
3857
|
-
|
|
3858
|
-
|
|
4574
|
+
findSessions: crmApi.findSessions,
|
|
4575
|
+
revokeSession: crmApi.revokeSession,
|
|
4576
|
+
revokeAllSessions: crmApi.revokeAllSessions
|
|
3859
4577
|
},
|
|
3860
4578
|
contactList: {
|
|
3861
4579
|
create: crmApi.contactList.create,
|
|
@@ -3867,7 +4585,14 @@ function createAdmin(config) {
|
|
|
3867
4585
|
addMember: crmApi.contactList.members.add,
|
|
3868
4586
|
updateMember: crmApi.contactList.members.update,
|
|
3869
4587
|
removeMember: crmApi.contactList.members.remove,
|
|
3870
|
-
findMembers: crmApi.contactList.members.find
|
|
4588
|
+
findMembers: crmApi.contactList.members.find,
|
|
4589
|
+
plans: crmApi.contactList.plans,
|
|
4590
|
+
memberships: {
|
|
4591
|
+
refund: crmApi.contactList.memberships.refund,
|
|
4592
|
+
paymentAttempts: crmApi.contactList.memberships.paymentAttempts,
|
|
4593
|
+
refunds: crmApi.contactList.memberships.refunds,
|
|
4594
|
+
cancellations: crmApi.contactList.memberships.cancellations
|
|
4595
|
+
}
|
|
3871
4596
|
},
|
|
3872
4597
|
action: crmApi.action
|
|
3873
4598
|
},
|
|
@@ -3941,29 +4666,50 @@ function createAdmin(config) {
|
|
|
3941
4666
|
};
|
|
3942
4667
|
return sdk;
|
|
3943
4668
|
}
|
|
3944
|
-
|
|
3945
|
-
function readContactSession() {
|
|
4669
|
+
function defaultStorefrontSessionStorage() {
|
|
3946
4670
|
if (typeof window === "undefined") return null;
|
|
3947
4671
|
try {
|
|
3948
|
-
|
|
3949
|
-
return raw ? JSON.parse(raw) : null;
|
|
4672
|
+
return window.localStorage;
|
|
3950
4673
|
} catch {
|
|
3951
4674
|
return null;
|
|
3952
4675
|
}
|
|
3953
4676
|
}
|
|
3954
|
-
function
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
localStorage.setItem(CONTACT_STORAGE_KEY, JSON.stringify(s));
|
|
3958
|
-
} else {
|
|
3959
|
-
localStorage.removeItem(CONTACT_STORAGE_KEY);
|
|
3960
|
-
}
|
|
4677
|
+
function storefrontSessionStorageKey(baseUrl, storeId) {
|
|
4678
|
+
const normalizedBaseUrl = baseUrl.trim().replace(/\/+$/, "").toLowerCase();
|
|
4679
|
+
return `arky_contact_session:${encodeURIComponent(normalizedBaseUrl)}:${encodeURIComponent(storeId)}`;
|
|
3961
4680
|
}
|
|
3962
|
-
function
|
|
4681
|
+
function createStorefrontClient(config) {
|
|
3963
4682
|
const locale = config.locale || "en";
|
|
3964
4683
|
const initialMarket = config.market || "";
|
|
3965
4684
|
const listeners = /* @__PURE__ */ new Set();
|
|
3966
4685
|
let bareIdentifyPromise = null;
|
|
4686
|
+
let identityTail = Promise.resolve();
|
|
4687
|
+
const sessionStorage = config.sessionStorage || defaultStorefrontSessionStorage();
|
|
4688
|
+
let memorySession = null;
|
|
4689
|
+
function readContactSession() {
|
|
4690
|
+
if (!sessionStorage) return memorySession;
|
|
4691
|
+
try {
|
|
4692
|
+
const raw = sessionStorage.getItem(
|
|
4693
|
+
storefrontSessionStorageKey(config.baseUrl, config.storeId)
|
|
4694
|
+
);
|
|
4695
|
+
return raw ? JSON.parse(raw) : null;
|
|
4696
|
+
} catch {
|
|
4697
|
+
return memorySession;
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
function writeContactSession(session) {
|
|
4701
|
+
memorySession = session;
|
|
4702
|
+
if (!sessionStorage) return;
|
|
4703
|
+
const key = storefrontSessionStorageKey(config.baseUrl, config.storeId);
|
|
4704
|
+
try {
|
|
4705
|
+
if (session) {
|
|
4706
|
+
sessionStorage.setItem(key, JSON.stringify(session));
|
|
4707
|
+
} else {
|
|
4708
|
+
sessionStorage.removeItem(key);
|
|
4709
|
+
}
|
|
4710
|
+
} catch {
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
3967
4713
|
function toPublic(s) {
|
|
3968
4714
|
return s ? { contact: s.contact, store: s.store, market: s.market } : null;
|
|
3969
4715
|
}
|
|
@@ -4019,19 +4765,23 @@ function createStorefront(config) {
|
|
|
4019
4765
|
const contactApi = storefrontApi.crm.contact;
|
|
4020
4766
|
function identify(params) {
|
|
4021
4767
|
if (params?.market !== void 0) apiConfig.market = params.market;
|
|
4768
|
+
const market = apiConfig.market;
|
|
4022
4769
|
const isBareCall = !params?.email && !params?.verify;
|
|
4023
4770
|
if (isBareCall && bareIdentifyPromise) return bareIdentifyPromise;
|
|
4024
|
-
const
|
|
4771
|
+
const run = async () => {
|
|
4025
4772
|
try {
|
|
4026
|
-
const result = await contactApi.
|
|
4027
|
-
market
|
|
4028
|
-
email: params
|
|
4029
|
-
|
|
4030
|
-
|
|
4773
|
+
const result = await (params?.verify ? contactApi.requestCode({
|
|
4774
|
+
market,
|
|
4775
|
+
email: params.email
|
|
4776
|
+
}) : contactApi.identify({
|
|
4777
|
+
market,
|
|
4778
|
+
email: params?.email
|
|
4779
|
+
}));
|
|
4031
4780
|
return {
|
|
4032
4781
|
contact: result.contact,
|
|
4033
4782
|
store: result.store,
|
|
4034
|
-
market: result.market
|
|
4783
|
+
market: result.market,
|
|
4784
|
+
verification_challenge: result.verification_challenge
|
|
4035
4785
|
};
|
|
4036
4786
|
} catch (err) {
|
|
4037
4787
|
const e = err;
|
|
@@ -4039,21 +4789,34 @@ function createStorefront(config) {
|
|
|
4039
4789
|
if (isBareCall && status === 401) {
|
|
4040
4790
|
updateSession(() => null);
|
|
4041
4791
|
const result = await contactApi.identify({
|
|
4042
|
-
market
|
|
4792
|
+
market
|
|
4043
4793
|
});
|
|
4044
4794
|
return {
|
|
4045
4795
|
contact: result.contact,
|
|
4046
4796
|
store: result.store,
|
|
4047
|
-
market: result.market
|
|
4797
|
+
market: result.market,
|
|
4798
|
+
verification_challenge: result.verification_challenge
|
|
4048
4799
|
};
|
|
4049
4800
|
}
|
|
4050
4801
|
throw err;
|
|
4051
4802
|
}
|
|
4052
|
-
}
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4803
|
+
};
|
|
4804
|
+
const promise = identityTail.then(run);
|
|
4805
|
+
identityTail = promise.then(
|
|
4806
|
+
() => void 0,
|
|
4807
|
+
() => void 0
|
|
4808
|
+
);
|
|
4809
|
+
if (isBareCall) {
|
|
4810
|
+
bareIdentifyPromise = promise;
|
|
4811
|
+
void promise.then(
|
|
4812
|
+
() => {
|
|
4813
|
+
if (bareIdentifyPromise === promise) bareIdentifyPromise = null;
|
|
4814
|
+
},
|
|
4815
|
+
() => {
|
|
4816
|
+
if (bareIdentifyPromise === promise) bareIdentifyPromise = null;
|
|
4817
|
+
}
|
|
4818
|
+
);
|
|
4819
|
+
}
|
|
4057
4820
|
return promise;
|
|
4058
4821
|
}
|
|
4059
4822
|
async function verify(params) {
|
|
@@ -4096,17 +4859,12 @@ function createStorefront(config) {
|
|
|
4096
4859
|
};
|
|
4097
4860
|
},
|
|
4098
4861
|
store: storefrontApi.store,
|
|
4099
|
-
cart: createCartController(storefrontApi.eshop.cart),
|
|
4100
4862
|
cms: storefrontApi.cms,
|
|
4101
4863
|
eshop: storefrontApi.eshop,
|
|
4102
4864
|
crm: storefrontApi.crm,
|
|
4103
4865
|
action: storefrontApi.action,
|
|
4104
4866
|
experiments: storefrontApi.experiments,
|
|
4105
4867
|
support: createStorefrontSupportApi(apiConfig),
|
|
4106
|
-
setStoreId: (storeId) => {
|
|
4107
|
-
apiConfig.storeId = storeId;
|
|
4108
|
-
bareIdentifyPromise = null;
|
|
4109
|
-
},
|
|
4110
4868
|
getStoreId: () => apiConfig.storeId,
|
|
4111
4869
|
setMarket: (key) => {
|
|
4112
4870
|
apiConfig.market = key;
|
|
@@ -4120,6 +4878,26 @@ function createStorefront(config) {
|
|
|
4120
4878
|
utils: createUtilitySurface(apiConfig)
|
|
4121
4879
|
};
|
|
4122
4880
|
}
|
|
4881
|
+
function createStorefront(config) {
|
|
4882
|
+
const sessionStorage = config.sessionStorage || defaultStorefrontSessionStorage() || void 0;
|
|
4883
|
+
const scopedConfig = {
|
|
4884
|
+
...config,
|
|
4885
|
+
sessionStorage
|
|
4886
|
+
};
|
|
4887
|
+
const client = createStorefrontClient(scopedConfig);
|
|
4888
|
+
Object.defineProperty(client, "forStore", {
|
|
4889
|
+
enumerable: true,
|
|
4890
|
+
configurable: false,
|
|
4891
|
+
writable: false,
|
|
4892
|
+
value: (storeId) => createStorefront({
|
|
4893
|
+
...scopedConfig,
|
|
4894
|
+
storeId,
|
|
4895
|
+
market: client.getMarket(),
|
|
4896
|
+
locale: client.getLocale()
|
|
4897
|
+
})
|
|
4898
|
+
});
|
|
4899
|
+
return client;
|
|
4900
|
+
}
|
|
4123
4901
|
|
|
4124
4902
|
export { COMMON_ACTION_KEYS, PaymentMethodType, SDK_VERSION, SUPPORTED_FRAMEWORKS, createAdmin, createCartController, createStorefront };
|
|
4125
4903
|
//# sourceMappingURL=index.js.map
|