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