arky-sdk 0.9.0 → 0.9.11
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 +113 -194
- package/dist/admin-BKXmDIVk.d.ts +1396 -0
- package/dist/admin-CAwQrMOX.d.cts +1396 -0
- package/dist/admin.cjs +1239 -455
- 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 +1239 -455
- package/dist/admin.js.map +1 -1
- package/dist/api-DJI3S6XA.d.cts +4204 -0
- package/dist/api-DJI3S6XA.d.ts +4204 -0
- package/dist/{index-C5gikdBg.d.cts → index-BaSBPLdF.d.ts} +1 -1
- package/dist/{index-MFMjlIfS.d.ts → index-u-gjHnKs.d.cts} +1 -1
- package/dist/index.cjs +1360 -610
- 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 +1360 -610
- package/dist/index.js.map +1 -1
- package/dist/storefront.cjs +590 -382
- package/dist/storefront.cjs.map +1 -1
- package/dist/storefront.d.cts +182 -156
- package/dist/storefront.d.ts +182 -156
- package/dist/storefront.js +588 -381
- package/dist/storefront.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -2666
- package/dist/types.d.ts +1 -2666
- package/dist/types.js.map +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +9 -11
- package/scripts/contract-admin.mjs +137 -0
- package/scripts/contract-storefront.mjs +296 -0
- package/dist/admin-CfHen7c5.d.cts +0 -1036
- package/dist/admin-ru7pX5bd.d.ts +0 -1036
- package/dist/storefront-store.cjs +0 -2794
- package/dist/storefront-store.cjs.map +0 -1
- package/dist/storefront-store.d.cts +0 -5
- package/dist/storefront-store.d.ts +0 -5
- package/dist/storefront-store.js +0 -2792
- package/dist/storefront-store.js.map +0 -1
- package/scripts/smoke-store.mjs +0 -41
package/dist/admin.js
CHANGED
|
@@ -1,129 +1,3 @@
|
|
|
1
|
-
// src/utils/blocks.ts
|
|
2
|
-
function getBlockLabel(block) {
|
|
3
|
-
if (!block) return "";
|
|
4
|
-
return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) ?? "";
|
|
5
|
-
}
|
|
6
|
-
function formatBlockValue(block) {
|
|
7
|
-
if (!block || block.value === null || block.value === void 0) return "";
|
|
8
|
-
const value = block.value;
|
|
9
|
-
switch (block.type) {
|
|
10
|
-
case "boolean":
|
|
11
|
-
return value ? "Yes" : "No";
|
|
12
|
-
case "number":
|
|
13
|
-
if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
|
|
14
|
-
return new Date(value).toLocaleDateString();
|
|
15
|
-
}
|
|
16
|
-
return String(value);
|
|
17
|
-
case "relationship_entry":
|
|
18
|
-
case "relationship_media":
|
|
19
|
-
if (value && typeof value === "object") {
|
|
20
|
-
return value.mime_type ? value.name || value.id : value.title || value.name || value.id;
|
|
21
|
-
}
|
|
22
|
-
return String(value);
|
|
23
|
-
default:
|
|
24
|
-
return String(value);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function prepareBlocksForSubmission(formData, blockTypes) {
|
|
28
|
-
return Object.keys(formData).filter((key) => formData[key] !== null && formData[key] !== void 0).map((key) => ({
|
|
29
|
-
key,
|
|
30
|
-
value: blockTypes?.[key] === "list" && !Array.isArray(formData[key]) ? [formData[key]] : formData[key]
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
function extractBlockValues(blocks) {
|
|
34
|
-
const values = {};
|
|
35
|
-
blocks.forEach((block) => {
|
|
36
|
-
values[block.key] = block.value ?? null;
|
|
37
|
-
});
|
|
38
|
-
return values;
|
|
39
|
-
}
|
|
40
|
-
var getBlockValue = (entry, blockKey) => {
|
|
41
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
42
|
-
return block?.value ?? null;
|
|
43
|
-
};
|
|
44
|
-
var getBlockTextValue = (block, locale = "en") => {
|
|
45
|
-
if (!block || block.value === null || block.value === void 0) return "";
|
|
46
|
-
if (block.type === "localized_text" || block.type === "markdown") {
|
|
47
|
-
if (typeof block.value === "object" && block.value !== null) {
|
|
48
|
-
return block.value[locale] ?? block.value["en"] ?? "";
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (typeof block.value === "string") return block.value;
|
|
52
|
-
return String(block.value ?? "");
|
|
53
|
-
};
|
|
54
|
-
var getBlockValues = (entry, blockKey) => {
|
|
55
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
56
|
-
if (!block) return [];
|
|
57
|
-
if (block.type === "list" && Array.isArray(block.value)) {
|
|
58
|
-
return block.value;
|
|
59
|
-
}
|
|
60
|
-
return [];
|
|
61
|
-
};
|
|
62
|
-
function unwrapBlock(block, locale) {
|
|
63
|
-
if (!block?.type || block.value === void 0) return block;
|
|
64
|
-
if (block.type === "list") {
|
|
65
|
-
return block.value.map((obj) => {
|
|
66
|
-
const parsed = {};
|
|
67
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
68
|
-
parsed[k] = unwrapBlock(v, locale);
|
|
69
|
-
}
|
|
70
|
-
return parsed;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
if (block.type === "map") {
|
|
74
|
-
const parsed = {};
|
|
75
|
-
for (const [k, v] of Object.entries(block.value || {})) {
|
|
76
|
-
parsed[k] = unwrapBlock(v, locale);
|
|
77
|
-
}
|
|
78
|
-
return parsed;
|
|
79
|
-
}
|
|
80
|
-
if (block.type === "localized_text" || block.type === "markdown") {
|
|
81
|
-
return block.value?.[locale];
|
|
82
|
-
}
|
|
83
|
-
return block.value;
|
|
84
|
-
}
|
|
85
|
-
var getBlockObjectValues = (entry, blockKey, locale = "en") => {
|
|
86
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
87
|
-
if (!block || block.type !== "list" || !Array.isArray(block.value)) return [];
|
|
88
|
-
return block.value.map((obj) => {
|
|
89
|
-
if (!obj?.value || !Array.isArray(obj.value)) return {};
|
|
90
|
-
return obj.value.reduce((acc, current) => {
|
|
91
|
-
acc[current.key] = unwrapBlock(current, locale);
|
|
92
|
-
return acc;
|
|
93
|
-
}, {});
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
var getBlockFromArray = (entry, blockKey, locale = "en") => {
|
|
97
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
98
|
-
if (!block) return {};
|
|
99
|
-
if (block.type === "list" && Array.isArray(block.value)) {
|
|
100
|
-
return block.value.reduce((acc, current) => {
|
|
101
|
-
acc[current.key] = unwrapBlock(current, locale);
|
|
102
|
-
return acc;
|
|
103
|
-
}, {});
|
|
104
|
-
}
|
|
105
|
-
if (block.type === "map" && block.value && typeof block.value === "object") {
|
|
106
|
-
const result = {};
|
|
107
|
-
for (const [k, v] of Object.entries(block.value)) {
|
|
108
|
-
result[k] = unwrapBlock(v, locale);
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
}
|
|
112
|
-
return { [block.key]: unwrapBlock(block, locale) };
|
|
113
|
-
};
|
|
114
|
-
var getImageUrl = (imageBlock, isBlock = true) => {
|
|
115
|
-
if (!imageBlock) return null;
|
|
116
|
-
if (imageBlock.type === "relationship_media") {
|
|
117
|
-
const mediaValue = imageBlock.value;
|
|
118
|
-
return mediaValue?.resolutions?.original?.url || mediaValue?.url || null;
|
|
119
|
-
}
|
|
120
|
-
if (isBlock) {
|
|
121
|
-
if (typeof imageBlock === "string") return imageBlock;
|
|
122
|
-
if (imageBlock.url) return imageBlock.url;
|
|
123
|
-
}
|
|
124
|
-
return imageBlock.resolutions?.original?.url || null;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
1
|
// src/utils/orderItems.ts
|
|
128
2
|
function normalizeOrderQuoteItems(items) {
|
|
129
3
|
return items.map((item) => {
|
|
@@ -245,7 +119,7 @@ function createHttpClient(cfg) {
|
|
|
245
119
|
headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
246
120
|
}
|
|
247
121
|
const finalPath = options?.params ? path + buildQueryString(options.params) : path;
|
|
248
|
-
const fetchOpts = { method, headers };
|
|
122
|
+
const fetchOpts = { method, headers, signal: options?.signal };
|
|
249
123
|
if (!["GET", "DELETE"].includes(method) && body !== void 0) {
|
|
250
124
|
fetchOpts.body = JSON.stringify(body);
|
|
251
125
|
}
|
|
@@ -256,13 +130,15 @@ function createHttpClient(cfg) {
|
|
|
256
130
|
try {
|
|
257
131
|
res = await fetch(fullUrl, fetchOpts);
|
|
258
132
|
} catch (error) {
|
|
133
|
+
const aborted = options?.signal?.aborted || error instanceof Error && error.name === "AbortError";
|
|
259
134
|
const err = new Error(error instanceof Error ? error.message : "Network request failed");
|
|
260
|
-
err.name = "NetworkError";
|
|
135
|
+
err.name = aborted ? "AbortError" : "NetworkError";
|
|
261
136
|
err.method = method;
|
|
262
137
|
err.url = fullUrl;
|
|
138
|
+
err.aborted = aborted;
|
|
263
139
|
if (options?.onError && method !== "GET") {
|
|
264
140
|
Promise.resolve(
|
|
265
|
-
options.onError({ error: err, method, url: fullUrl, aborted
|
|
141
|
+
options.onError({ error: err, method, url: fullUrl, aborted })
|
|
266
142
|
).catch(() => {
|
|
267
143
|
});
|
|
268
144
|
}
|
|
@@ -425,15 +301,12 @@ var createAuthApi = (apiConfig, updateSession) => {
|
|
|
425
301
|
applyAuthToken(result, params.email);
|
|
426
302
|
}
|
|
427
303
|
return result;
|
|
428
|
-
},
|
|
429
|
-
async magicLink(params, options) {
|
|
430
|
-
return apiConfig.httpClient.post("/v1/auth/code", params, options);
|
|
431
304
|
}
|
|
432
305
|
};
|
|
433
306
|
};
|
|
434
307
|
|
|
435
308
|
// src/api/store.ts
|
|
436
|
-
var createStoreApi = (apiConfig,
|
|
309
|
+
var createStoreApi = (apiConfig, _updateSession) => {
|
|
437
310
|
return {
|
|
438
311
|
async createStore(params, options) {
|
|
439
312
|
return apiConfig.httpClient.post(`/v1/stores`, params, options);
|
|
@@ -464,14 +337,17 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
464
337
|
});
|
|
465
338
|
},
|
|
466
339
|
async getSubscriptionPlans(_params, options) {
|
|
467
|
-
return apiConfig.httpClient.get(
|
|
340
|
+
return apiConfig.httpClient.get(
|
|
341
|
+
"/v1/stores/plans",
|
|
342
|
+
options
|
|
343
|
+
);
|
|
468
344
|
},
|
|
469
345
|
async subscribe(params, options) {
|
|
470
|
-
const { store_id, plan_id, success_url, cancel_url } = params;
|
|
346
|
+
const { store_id, plan_id, action, success_url, cancel_url } = params;
|
|
471
347
|
const target_store_id = store_id || apiConfig.storeId;
|
|
472
348
|
return apiConfig.httpClient.put(
|
|
473
349
|
`/v1/stores/${target_store_id}/subscribe`,
|
|
474
|
-
{ plan_id, success_url, cancel_url },
|
|
350
|
+
{ plan_id, action, success_url, cancel_url },
|
|
475
351
|
options
|
|
476
352
|
);
|
|
477
353
|
},
|
|
@@ -483,10 +359,19 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
483
359
|
options
|
|
484
360
|
);
|
|
485
361
|
},
|
|
362
|
+
async addMember(params, options) {
|
|
363
|
+
const { store_id, ...payload } = params;
|
|
364
|
+
return apiConfig.httpClient.post(
|
|
365
|
+
`/v1/stores/${store_id || apiConfig.storeId}/members`,
|
|
366
|
+
payload,
|
|
367
|
+
options
|
|
368
|
+
);
|
|
369
|
+
},
|
|
486
370
|
async inviteUser(params, options) {
|
|
371
|
+
const { store_id, ...payload } = params;
|
|
487
372
|
return apiConfig.httpClient.post(
|
|
488
|
-
`/v1/stores/${apiConfig.storeId}/
|
|
489
|
-
|
|
373
|
+
`/v1/stores/${store_id || apiConfig.storeId}/members`,
|
|
374
|
+
payload,
|
|
490
375
|
options
|
|
491
376
|
);
|
|
492
377
|
},
|
|
@@ -496,22 +381,6 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
496
381
|
options
|
|
497
382
|
);
|
|
498
383
|
},
|
|
499
|
-
async handleInvitation(params, options) {
|
|
500
|
-
const { store_id, ...payload } = params;
|
|
501
|
-
const result = await apiConfig.httpClient.put(
|
|
502
|
-
`/v1/stores/${store_id || apiConfig.storeId}/invitation`,
|
|
503
|
-
payload,
|
|
504
|
-
options
|
|
505
|
-
);
|
|
506
|
-
if (params.action === "accept" && result?.auth?.access_token) {
|
|
507
|
-
updateSession(() => ({
|
|
508
|
-
access_token: result.auth.access_token,
|
|
509
|
-
refresh_token: result.auth.refresh_token,
|
|
510
|
-
access_expires_at: result.auth.access_expires_at
|
|
511
|
-
}));
|
|
512
|
-
}
|
|
513
|
-
return result;
|
|
514
|
-
},
|
|
515
384
|
async testWebhook(params, options) {
|
|
516
385
|
return apiConfig.httpClient.post(
|
|
517
386
|
`/v1/stores/${apiConfig.storeId}/webhooks/test`,
|
|
@@ -524,61 +393,52 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
524
393
|
limit: params.limit
|
|
525
394
|
};
|
|
526
395
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
527
|
-
if (params.ids && params.ids.length > 0)
|
|
396
|
+
if (params.ids && params.ids.length > 0)
|
|
397
|
+
queryParams.ids = JSON.stringify(params.ids);
|
|
528
398
|
if (params.query) queryParams.query = params.query;
|
|
529
399
|
if (params.mime_type) queryParams.mime_type = params.mime_type;
|
|
530
400
|
if (params.sort_field) queryParams.sort_field = params.sort_field;
|
|
531
|
-
if (params.sort_direction)
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
params
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
`/v1/stores/${params.store_id}/oauth/connect`,
|
|
540
|
-
{ provider: params.provider, code: params.code, redirect_uri: params.redirect_uri },
|
|
541
|
-
options
|
|
542
|
-
);
|
|
543
|
-
},
|
|
544
|
-
async oauthDisconnect(params, options) {
|
|
545
|
-
return apiConfig.httpClient.post(
|
|
546
|
-
`/v1/stores/${params.store_id}/oauth/disconnect`,
|
|
547
|
-
{ provider: params.provider },
|
|
548
|
-
options
|
|
401
|
+
if (params.sort_direction)
|
|
402
|
+
queryParams.sort_direction = params.sort_direction;
|
|
403
|
+
return apiConfig.httpClient.get(
|
|
404
|
+
`/v1/stores/${params.id}/media`,
|
|
405
|
+
{
|
|
406
|
+
...options,
|
|
407
|
+
params: queryParams
|
|
408
|
+
}
|
|
549
409
|
);
|
|
550
410
|
},
|
|
551
|
-
async
|
|
411
|
+
async listBuildHooks(params, options) {
|
|
552
412
|
return apiConfig.httpClient.get(
|
|
553
|
-
`/v1/stores/${params.store_id}/
|
|
413
|
+
`/v1/stores/${params.store_id}/build-hooks`,
|
|
554
414
|
options
|
|
555
415
|
);
|
|
556
416
|
},
|
|
557
|
-
async
|
|
417
|
+
async createBuildHook(params, options) {
|
|
558
418
|
const { store_id, ...payload } = params;
|
|
559
419
|
return apiConfig.httpClient.post(
|
|
560
|
-
`/v1/stores/${store_id}/
|
|
420
|
+
`/v1/stores/${store_id}/build-hooks`,
|
|
561
421
|
payload,
|
|
562
422
|
options
|
|
563
423
|
);
|
|
564
424
|
},
|
|
565
|
-
async
|
|
425
|
+
async updateBuildHook(params, options) {
|
|
566
426
|
const { store_id, id, ...payload } = params;
|
|
567
427
|
return apiConfig.httpClient.put(
|
|
568
|
-
`/v1/stores/${store_id}/
|
|
428
|
+
`/v1/stores/${store_id}/build-hooks/${id}`,
|
|
569
429
|
payload,
|
|
570
430
|
options
|
|
571
431
|
);
|
|
572
432
|
},
|
|
573
|
-
async
|
|
433
|
+
async deleteBuildHook(params, options) {
|
|
574
434
|
return apiConfig.httpClient.delete(
|
|
575
|
-
`/v1/stores/${params.store_id}/
|
|
435
|
+
`/v1/stores/${params.store_id}/build-hooks/${params.id}`,
|
|
576
436
|
options
|
|
577
437
|
);
|
|
578
438
|
},
|
|
579
|
-
async
|
|
439
|
+
async getStoreConfig(params, options) {
|
|
580
440
|
return apiConfig.httpClient.get(
|
|
581
|
-
`/v1/stores/${params.store_id}/
|
|
441
|
+
`/v1/stores/${params.store_id}/config/${params.type}`,
|
|
582
442
|
options
|
|
583
443
|
);
|
|
584
444
|
},
|
|
@@ -623,7 +483,7 @@ var createMediaApi = (apiConfig) => {
|
|
|
623
483
|
options
|
|
624
484
|
);
|
|
625
485
|
},
|
|
626
|
-
async uploadStoreMedia(params,
|
|
486
|
+
async uploadStoreMedia(params, options) {
|
|
627
487
|
const { store_id, files = [], urls = [] } = params;
|
|
628
488
|
const target_store_id = store_id || apiConfig.storeId;
|
|
629
489
|
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
@@ -636,7 +496,8 @@ var createMediaApi = (apiConfig) => {
|
|
|
636
496
|
body: formData,
|
|
637
497
|
headers: {
|
|
638
498
|
Authorization: `Bearer ${tokens?.access_token || ""}`
|
|
639
|
-
}
|
|
499
|
+
},
|
|
500
|
+
signal: options?.signal
|
|
640
501
|
});
|
|
641
502
|
if (!response.ok) {
|
|
642
503
|
throw new Error("Upload failed, server said no");
|
|
@@ -650,13 +511,13 @@ var createMediaApi = (apiConfig) => {
|
|
|
650
511
|
options
|
|
651
512
|
);
|
|
652
513
|
},
|
|
653
|
-
async getStoreMedia(params,
|
|
514
|
+
async getStoreMedia(params, options) {
|
|
654
515
|
const { store_id, cursor, limit, ids, query, mime_type, sort_field, sort_direction } = params;
|
|
655
516
|
const target_store_id = store_id || apiConfig.storeId;
|
|
656
517
|
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
657
518
|
const queryParams = { limit: String(limit) };
|
|
658
519
|
if (cursor) queryParams.cursor = cursor;
|
|
659
|
-
if (ids && ids.length > 0) queryParams.ids =
|
|
520
|
+
if (ids && ids.length > 0) queryParams.ids = JSON.stringify(ids);
|
|
660
521
|
if (query) queryParams.query = query;
|
|
661
522
|
if (mime_type) queryParams.mime_type = mime_type;
|
|
662
523
|
if (sort_field) queryParams.sort_field = sort_field;
|
|
@@ -666,7 +527,8 @@ var createMediaApi = (apiConfig) => {
|
|
|
666
527
|
const response = await fetch(`${url}?${queryString}`, {
|
|
667
528
|
headers: {
|
|
668
529
|
Authorization: `Bearer ${tokens?.access_token || ""}`
|
|
669
|
-
}
|
|
530
|
+
},
|
|
531
|
+
signal: options?.signal
|
|
670
532
|
});
|
|
671
533
|
if (!response.ok) {
|
|
672
534
|
const errorData = await response.json().catch(() => null);
|
|
@@ -754,77 +616,97 @@ var createPromoCodeApi = (apiConfig) => {
|
|
|
754
616
|
// src/api/cms.ts
|
|
755
617
|
var createCmsApi = (apiConfig) => {
|
|
756
618
|
return {
|
|
757
|
-
async
|
|
619
|
+
async createCollection(params, options) {
|
|
758
620
|
const { store_id, ...payload } = params;
|
|
759
621
|
const target_store_id = store_id || apiConfig.storeId;
|
|
760
622
|
return apiConfig.httpClient.post(
|
|
761
|
-
`/v1/stores/${target_store_id}/
|
|
623
|
+
`/v1/stores/${target_store_id}/collections`,
|
|
762
624
|
payload,
|
|
763
625
|
options
|
|
764
626
|
);
|
|
765
627
|
},
|
|
766
|
-
async
|
|
628
|
+
async updateCollection(params, options) {
|
|
767
629
|
const { store_id, ...payload } = params;
|
|
768
630
|
const target_store_id = store_id || apiConfig.storeId;
|
|
769
631
|
return apiConfig.httpClient.put(
|
|
770
|
-
`/v1/stores/${target_store_id}/
|
|
632
|
+
`/v1/stores/${target_store_id}/collections/${params.id}`,
|
|
771
633
|
payload,
|
|
772
634
|
options
|
|
773
635
|
);
|
|
774
636
|
},
|
|
775
|
-
async
|
|
637
|
+
async deleteCollection(params, options) {
|
|
776
638
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
777
639
|
return apiConfig.httpClient.delete(
|
|
778
|
-
`/v1/stores/${target_store_id}/
|
|
640
|
+
`/v1/stores/${target_store_id}/collections/${params.id}`,
|
|
779
641
|
options
|
|
780
642
|
);
|
|
781
643
|
},
|
|
782
|
-
async
|
|
644
|
+
async getCollection(params, options) {
|
|
783
645
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
784
646
|
let identifier;
|
|
785
647
|
if (params.id) {
|
|
786
648
|
identifier = params.id;
|
|
787
|
-
} else if (params.slug) {
|
|
788
|
-
identifier = `${target_store_id}:${apiConfig.locale}:${params.slug}`;
|
|
789
649
|
} else if (params.key) {
|
|
790
650
|
identifier = `${target_store_id}:${params.key}`;
|
|
791
651
|
} else {
|
|
792
|
-
throw new Error("
|
|
652
|
+
throw new Error("GetCollectionParams requires id or key");
|
|
793
653
|
}
|
|
794
|
-
|
|
795
|
-
`/v1/stores/${target_store_id}/
|
|
654
|
+
return apiConfig.httpClient.get(
|
|
655
|
+
`/v1/stores/${target_store_id}/collections/${identifier}`,
|
|
796
656
|
options
|
|
797
657
|
);
|
|
798
|
-
return {
|
|
799
|
-
...response,
|
|
800
|
-
getBlock(key) {
|
|
801
|
-
return getBlockFromArray(response, key, apiConfig.locale);
|
|
802
|
-
},
|
|
803
|
-
getBlockValues(key) {
|
|
804
|
-
return getBlockObjectValues(response, key, apiConfig.locale);
|
|
805
|
-
},
|
|
806
|
-
getImage(key) {
|
|
807
|
-
const block = getBlockFromArray(response, key, apiConfig.locale);
|
|
808
|
-
return getImageUrl(block, true);
|
|
809
|
-
}
|
|
810
|
-
};
|
|
811
658
|
},
|
|
812
|
-
async
|
|
659
|
+
async getCollections(params = {}, options) {
|
|
813
660
|
const { store_id, ...queryParams } = params;
|
|
814
661
|
const target_store_id = store_id || apiConfig.storeId;
|
|
815
662
|
return apiConfig.httpClient.get(
|
|
816
|
-
`/v1/stores/${target_store_id}/
|
|
663
|
+
`/v1/stores/${target_store_id}/collections`,
|
|
817
664
|
{
|
|
818
665
|
...options,
|
|
819
666
|
params: queryParams
|
|
820
667
|
}
|
|
821
668
|
);
|
|
822
669
|
},
|
|
823
|
-
async
|
|
824
|
-
const {
|
|
670
|
+
async createEntry(params, options) {
|
|
671
|
+
const { store_id, ...payload } = params;
|
|
672
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
673
|
+
return apiConfig.httpClient.post(
|
|
674
|
+
`/v1/stores/${target_store_id}/entries`,
|
|
675
|
+
payload,
|
|
676
|
+
options
|
|
677
|
+
);
|
|
678
|
+
},
|
|
679
|
+
async updateEntry(params, options) {
|
|
680
|
+
const { store_id, ...payload } = params;
|
|
681
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
682
|
+
return apiConfig.httpClient.put(
|
|
683
|
+
`/v1/stores/${target_store_id}/entries/${params.id}`,
|
|
684
|
+
payload,
|
|
685
|
+
options
|
|
686
|
+
);
|
|
687
|
+
},
|
|
688
|
+
async deleteEntry(params, options) {
|
|
689
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
690
|
+
return apiConfig.httpClient.delete(
|
|
691
|
+
`/v1/stores/${target_store_id}/entries/${params.id}`,
|
|
692
|
+
options
|
|
693
|
+
);
|
|
694
|
+
},
|
|
695
|
+
async getEntry(params, options) {
|
|
696
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
697
|
+
if (!params.id) {
|
|
698
|
+
throw new Error("GetEntryParams requires id");
|
|
699
|
+
}
|
|
700
|
+
return apiConfig.httpClient.get(
|
|
701
|
+
`/v1/stores/${target_store_id}/entries/${params.id}`,
|
|
702
|
+
options
|
|
703
|
+
);
|
|
704
|
+
},
|
|
705
|
+
async getEntries(params, options) {
|
|
706
|
+
const { store_id, ...queryParams } = params;
|
|
825
707
|
const target_store_id = store_id || apiConfig.storeId;
|
|
826
708
|
return apiConfig.httpClient.get(
|
|
827
|
-
`/v1/stores/${target_store_id}/
|
|
709
|
+
`/v1/stores/${target_store_id}/entries`,
|
|
828
710
|
{
|
|
829
711
|
...options,
|
|
830
712
|
params: queryParams
|
|
@@ -835,13 +717,6 @@ var createCmsApi = (apiConfig) => {
|
|
|
835
717
|
};
|
|
836
718
|
|
|
837
719
|
// src/api/eshop.ts
|
|
838
|
-
var normalizeTaxonomyAliases = (payload) => {
|
|
839
|
-
const { filters, ...rest } = payload;
|
|
840
|
-
return {
|
|
841
|
-
...rest,
|
|
842
|
-
...!rest.taxonomies && filters ? { taxonomies: filters } : {}
|
|
843
|
-
};
|
|
844
|
-
};
|
|
845
720
|
var createEshopApi = (apiConfig) => {
|
|
846
721
|
return {
|
|
847
722
|
async createProduct(params, options) {
|
|
@@ -849,7 +724,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
849
724
|
const target_store_id = store_id || apiConfig.storeId;
|
|
850
725
|
return apiConfig.httpClient.post(
|
|
851
726
|
`/v1/stores/${target_store_id}/products`,
|
|
852
|
-
|
|
727
|
+
payload,
|
|
853
728
|
options
|
|
854
729
|
);
|
|
855
730
|
},
|
|
@@ -858,7 +733,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
858
733
|
const target_store_id = store_id || apiConfig.storeId;
|
|
859
734
|
return apiConfig.httpClient.put(
|
|
860
735
|
`/v1/stores/${target_store_id}/products/${params.id}`,
|
|
861
|
-
|
|
736
|
+
payload,
|
|
862
737
|
options
|
|
863
738
|
);
|
|
864
739
|
},
|
|
@@ -900,7 +775,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
900
775
|
const target_store_id = store_id || apiConfig.storeId;
|
|
901
776
|
return apiConfig.httpClient.post(
|
|
902
777
|
`/v1/stores/${target_store_id}/services`,
|
|
903
|
-
|
|
778
|
+
payload,
|
|
904
779
|
options
|
|
905
780
|
);
|
|
906
781
|
},
|
|
@@ -909,7 +784,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
909
784
|
const target_store_id = store_id || apiConfig.storeId;
|
|
910
785
|
return apiConfig.httpClient.put(
|
|
911
786
|
`/v1/stores/${target_store_id}/services/${params.id}`,
|
|
912
|
-
|
|
787
|
+
payload,
|
|
913
788
|
options
|
|
914
789
|
);
|
|
915
790
|
},
|
|
@@ -959,7 +834,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
959
834
|
const target_store_id = store_id || apiConfig.storeId;
|
|
960
835
|
return apiConfig.httpClient.post(
|
|
961
836
|
`/v1/stores/${target_store_id}/providers`,
|
|
962
|
-
|
|
837
|
+
payload,
|
|
963
838
|
options
|
|
964
839
|
);
|
|
965
840
|
},
|
|
@@ -968,7 +843,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
968
843
|
const target_store_id = store_id || apiConfig.storeId;
|
|
969
844
|
return apiConfig.httpClient.put(
|
|
970
845
|
`/v1/stores/${target_store_id}/providers/${params.id}`,
|
|
971
|
-
|
|
846
|
+
payload,
|
|
972
847
|
options
|
|
973
848
|
);
|
|
974
849
|
},
|
|
@@ -1183,6 +1058,14 @@ var createEshopApi = (apiConfig) => {
|
|
|
1183
1058
|
{ amount: params.amount },
|
|
1184
1059
|
options
|
|
1185
1060
|
);
|
|
1061
|
+
},
|
|
1062
|
+
async downloadDigitalAccess(params, options) {
|
|
1063
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1064
|
+
return apiConfig.httpClient.post(
|
|
1065
|
+
`/v1/stores/${target_store_id}/orders/${params.id}/digital-access/${params.grant_id}/download`,
|
|
1066
|
+
{},
|
|
1067
|
+
options
|
|
1068
|
+
);
|
|
1186
1069
|
}
|
|
1187
1070
|
};
|
|
1188
1071
|
};
|
|
@@ -1273,72 +1156,84 @@ var createMarketApi = (apiConfig) => {
|
|
|
1273
1156
|
};
|
|
1274
1157
|
|
|
1275
1158
|
// src/api/crm.ts
|
|
1276
|
-
var
|
|
1159
|
+
var createActionAdminApi = (apiConfig) => ({
|
|
1277
1160
|
async timeline(params, options) {
|
|
1278
1161
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1279
|
-
const queryParams = {
|
|
1162
|
+
const queryParams = { contact_id: params.contact_id };
|
|
1280
1163
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1281
1164
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1282
1165
|
return apiConfig.httpClient.get(
|
|
1283
|
-
`/v1/stores/${store_id}/
|
|
1166
|
+
`/v1/stores/${store_id}/contacts/${params.contact_id}/actions`,
|
|
1284
1167
|
{ ...options, params: queryParams }
|
|
1285
1168
|
);
|
|
1286
1169
|
},
|
|
1287
1170
|
async find(params, options) {
|
|
1288
1171
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1289
1172
|
const queryParams = {};
|
|
1290
|
-
if (params.
|
|
1173
|
+
if (params.query) queryParams.query = params.query;
|
|
1174
|
+
if (params.contact_id) queryParams.contact_id = params.contact_id;
|
|
1291
1175
|
if (params.types && params.types.length > 0) queryParams.types = params.types;
|
|
1292
1176
|
if (params.from !== void 0) queryParams.from = params.from;
|
|
1293
1177
|
if (params.to !== void 0) queryParams.to = params.to;
|
|
1294
1178
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1295
1179
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1296
1180
|
return apiConfig.httpClient.get(
|
|
1297
|
-
`/v1/stores/${store_id}/
|
|
1181
|
+
`/v1/stores/${store_id}/actions`,
|
|
1298
1182
|
{ ...options, params: queryParams }
|
|
1299
1183
|
);
|
|
1300
1184
|
}
|
|
1301
1185
|
});
|
|
1302
|
-
var
|
|
1186
|
+
var createContactApi = (apiConfig) => {
|
|
1303
1187
|
return {
|
|
1304
1188
|
async create(params, options) {
|
|
1305
1189
|
const { store_id, ...payload } = params;
|
|
1306
1190
|
return apiConfig.httpClient.post(
|
|
1307
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1191
|
+
`/v1/stores/${store_id || apiConfig.storeId}/contacts`,
|
|
1308
1192
|
payload,
|
|
1309
1193
|
options
|
|
1310
1194
|
);
|
|
1311
1195
|
},
|
|
1312
1196
|
async get(params, options) {
|
|
1313
1197
|
return apiConfig.httpClient.get(
|
|
1314
|
-
`/v1/stores/${params.store_id || apiConfig.storeId}/
|
|
1198
|
+
`/v1/stores/${params.store_id || apiConfig.storeId}/contacts/${params.id}`,
|
|
1315
1199
|
options
|
|
1316
1200
|
);
|
|
1317
1201
|
},
|
|
1318
1202
|
async find(params, options) {
|
|
1319
1203
|
const store_id = params?.store_id || apiConfig.storeId;
|
|
1320
1204
|
const queryParams = {};
|
|
1205
|
+
if (params?.ids && params.ids.length > 0) queryParams.ids = JSON.stringify(params.ids);
|
|
1321
1206
|
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
1322
1207
|
if (params?.cursor) queryParams.cursor = params.cursor;
|
|
1323
1208
|
if (params?.query) queryParams.query = params.query;
|
|
1324
1209
|
if (params?.taxonomy_query) queryParams.taxonomy_query = params.taxonomy_query;
|
|
1325
1210
|
if (params?.status) queryParams.status = params.status;
|
|
1326
|
-
if (params?.
|
|
1211
|
+
if (params?.has_action !== void 0) queryParams.has_action = params.has_action;
|
|
1327
1212
|
if (params?.has_cart !== void 0) queryParams.has_cart = params.has_cart;
|
|
1328
1213
|
if (params?.sort_field) queryParams.sort_field = params.sort_field;
|
|
1329
1214
|
if (params?.sort_direction) queryParams.sort_direction = params.sort_direction;
|
|
1330
1215
|
return apiConfig.httpClient.get(
|
|
1331
|
-
`/v1/stores/${store_id}/
|
|
1216
|
+
`/v1/stores/${store_id}/contacts`,
|
|
1332
1217
|
{
|
|
1333
1218
|
...options,
|
|
1334
1219
|
params: queryParams
|
|
1335
1220
|
}
|
|
1336
1221
|
);
|
|
1337
1222
|
},
|
|
1223
|
+
async findActions(params, options) {
|
|
1224
|
+
const { store_id, ...queryParams } = params || {};
|
|
1225
|
+
return apiConfig.httpClient.get(
|
|
1226
|
+
`/v1/stores/${store_id || apiConfig.storeId}/actions`,
|
|
1227
|
+
{
|
|
1228
|
+
...options,
|
|
1229
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1230
|
+
}
|
|
1231
|
+
);
|
|
1232
|
+
},
|
|
1338
1233
|
async update(params, options) {
|
|
1339
1234
|
const { id, store_id, ...body } = params;
|
|
1340
1235
|
return apiConfig.httpClient.put(
|
|
1341
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1236
|
+
`/v1/stores/${store_id || apiConfig.storeId}/contacts/${id}`,
|
|
1342
1237
|
body,
|
|
1343
1238
|
options
|
|
1344
1239
|
);
|
|
@@ -1346,101 +1241,754 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1346
1241
|
async merge(params, options) {
|
|
1347
1242
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1348
1243
|
return apiConfig.httpClient.post(
|
|
1349
|
-
`/v1/stores/${store_id}/
|
|
1244
|
+
`/v1/stores/${store_id}/contacts/${params.target_id}/merge`,
|
|
1350
1245
|
{ source_id: params.source_id, store_id },
|
|
1351
1246
|
options
|
|
1352
1247
|
);
|
|
1353
1248
|
},
|
|
1249
|
+
"import": async (params, options) => {
|
|
1250
|
+
const { store_id, ...payload } = params;
|
|
1251
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1252
|
+
return apiConfig.httpClient.post(
|
|
1253
|
+
`/v1/stores/${target_store_id}/contacts/import`,
|
|
1254
|
+
payload,
|
|
1255
|
+
options
|
|
1256
|
+
);
|
|
1257
|
+
},
|
|
1258
|
+
previewImport: async (params, options) => {
|
|
1259
|
+
const { store_id, ...payload } = params;
|
|
1260
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1261
|
+
return apiConfig.httpClient.post(
|
|
1262
|
+
`/v1/stores/${target_store_id}/contacts/import/preview`,
|
|
1263
|
+
payload,
|
|
1264
|
+
options
|
|
1265
|
+
);
|
|
1266
|
+
},
|
|
1354
1267
|
async revokeToken(params, options) {
|
|
1355
1268
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1356
1269
|
return apiConfig.httpClient.delete(
|
|
1357
|
-
`/v1/stores/${store_id}/
|
|
1270
|
+
`/v1/stores/${store_id}/contacts/${params.id}/sessions/${params.token_id}`,
|
|
1358
1271
|
options
|
|
1359
1272
|
);
|
|
1360
1273
|
},
|
|
1361
1274
|
async revokeAllTokens(params, options) {
|
|
1362
1275
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1363
1276
|
return apiConfig.httpClient.delete(
|
|
1364
|
-
`/v1/stores/${store_id}/
|
|
1277
|
+
`/v1/stores/${store_id}/contacts/${params.id}/sessions`,
|
|
1365
1278
|
options
|
|
1366
1279
|
);
|
|
1367
1280
|
},
|
|
1368
|
-
|
|
1281
|
+
contactList: {
|
|
1369
1282
|
async create(params, options) {
|
|
1283
|
+
const { store_id, ...payload } = params;
|
|
1284
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1370
1285
|
return apiConfig.httpClient.post(
|
|
1371
|
-
`/v1/stores/${
|
|
1372
|
-
|
|
1286
|
+
`/v1/stores/${target_store_id}/contact-lists`,
|
|
1287
|
+
payload,
|
|
1373
1288
|
options
|
|
1374
1289
|
);
|
|
1375
1290
|
},
|
|
1376
1291
|
async update(params, options) {
|
|
1292
|
+
const { id, store_id, ...payload } = params;
|
|
1293
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1377
1294
|
return apiConfig.httpClient.put(
|
|
1378
|
-
`/v1/stores/${
|
|
1379
|
-
|
|
1295
|
+
`/v1/stores/${target_store_id}/contact-lists/${id}`,
|
|
1296
|
+
payload,
|
|
1380
1297
|
options
|
|
1381
1298
|
);
|
|
1382
1299
|
},
|
|
1383
1300
|
async get(params, options) {
|
|
1384
|
-
|
|
1385
|
-
if (params.id) {
|
|
1386
|
-
identifier = params.id;
|
|
1387
|
-
} else if (params.key) {
|
|
1388
|
-
identifier = `${apiConfig.storeId}:${params.key}`;
|
|
1389
|
-
} else {
|
|
1390
|
-
throw new Error("GetAudienceParams requires id or key");
|
|
1391
|
-
}
|
|
1301
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1392
1302
|
return apiConfig.httpClient.get(
|
|
1393
|
-
`/v1/stores/${
|
|
1303
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.id}`,
|
|
1394
1304
|
options
|
|
1395
1305
|
);
|
|
1396
1306
|
},
|
|
1397
1307
|
async find(params, options) {
|
|
1308
|
+
const { store_id, ...queryParams } = params || {};
|
|
1309
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1398
1310
|
return apiConfig.httpClient.get(
|
|
1399
|
-
`/v1/stores/${
|
|
1400
|
-
{ ...options, params }
|
|
1401
|
-
);
|
|
1402
|
-
},
|
|
1403
|
-
async getSubscribers(params, options) {
|
|
1404
|
-
return apiConfig.httpClient.get(
|
|
1405
|
-
`/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers`,
|
|
1406
|
-
{
|
|
1407
|
-
...options,
|
|
1408
|
-
params: { limit: params.limit, cursor: params.cursor }
|
|
1409
|
-
}
|
|
1311
|
+
`/v1/stores/${target_store_id}/contact-lists`,
|
|
1312
|
+
{ ...options, params: queryParams }
|
|
1410
1313
|
);
|
|
1411
1314
|
},
|
|
1412
|
-
async
|
|
1315
|
+
async importContacts(params, options) {
|
|
1316
|
+
const { store_id, contact_list_id, ...payload } = params;
|
|
1317
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1413
1318
|
return apiConfig.httpClient.post(
|
|
1414
|
-
`/v1/stores/${
|
|
1415
|
-
|
|
1319
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/import`,
|
|
1320
|
+
payload,
|
|
1416
1321
|
options
|
|
1417
1322
|
);
|
|
1418
1323
|
},
|
|
1419
|
-
async
|
|
1420
|
-
|
|
1421
|
-
|
|
1324
|
+
async previewImportContacts(params, options) {
|
|
1325
|
+
const { store_id, contact_list_id, ...payload } = params;
|
|
1326
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1327
|
+
return apiConfig.httpClient.post(
|
|
1328
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/import/preview`,
|
|
1329
|
+
payload,
|
|
1422
1330
|
options
|
|
1423
1331
|
);
|
|
1332
|
+
},
|
|
1333
|
+
members: {
|
|
1334
|
+
async add(params, options) {
|
|
1335
|
+
const { store_id, contact_list_id, contact_id, fields, lead_description } = params;
|
|
1336
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1337
|
+
return apiConfig.httpClient.post(
|
|
1338
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/${contact_id}`,
|
|
1339
|
+
{ fields, lead_description },
|
|
1340
|
+
options
|
|
1341
|
+
);
|
|
1342
|
+
},
|
|
1343
|
+
async update(params, options) {
|
|
1344
|
+
const { store_id, contact_list_id, contact_id, status, fields, lead_description } = params;
|
|
1345
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1346
|
+
return apiConfig.httpClient.patch(
|
|
1347
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/${contact_id}`,
|
|
1348
|
+
{ status, fields, lead_description },
|
|
1349
|
+
options
|
|
1350
|
+
);
|
|
1351
|
+
},
|
|
1352
|
+
async remove(params, options) {
|
|
1353
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1354
|
+
return apiConfig.httpClient.delete(
|
|
1355
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/contacts/${params.contact_id}`,
|
|
1356
|
+
options
|
|
1357
|
+
);
|
|
1358
|
+
},
|
|
1359
|
+
async find(params, options) {
|
|
1360
|
+
const { store_id, contact_list_id, ...queryParams } = params;
|
|
1361
|
+
if (!contact_list_id && !queryParams.contact_id) {
|
|
1362
|
+
throw new Error("contact_list_id or contact_id is required");
|
|
1363
|
+
}
|
|
1364
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1365
|
+
const path = contact_list_id ? `/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts` : `/v1/stores/${target_store_id}/contact-lists/contacts`;
|
|
1366
|
+
return apiConfig.httpClient.get(
|
|
1367
|
+
path,
|
|
1368
|
+
{ ...options, params: queryParams }
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1424
1371
|
}
|
|
1425
1372
|
},
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
};
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1373
|
+
mailbox: {
|
|
1374
|
+
async create(params, options) {
|
|
1375
|
+
const { store_id, ...payload } = params;
|
|
1376
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1377
|
+
return apiConfig.httpClient.post(
|
|
1378
|
+
`/v1/stores/${target_store_id}/mailboxes`,
|
|
1379
|
+
payload,
|
|
1380
|
+
options
|
|
1381
|
+
);
|
|
1382
|
+
},
|
|
1383
|
+
async update(params, options) {
|
|
1384
|
+
const { id, store_id, ...payload } = params;
|
|
1385
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1386
|
+
return apiConfig.httpClient.put(
|
|
1387
|
+
`/v1/stores/${target_store_id}/mailboxes/${id}`,
|
|
1388
|
+
payload,
|
|
1389
|
+
options
|
|
1390
|
+
);
|
|
1391
|
+
},
|
|
1392
|
+
async get(params, options) {
|
|
1393
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1394
|
+
return apiConfig.httpClient.get(
|
|
1395
|
+
`/v1/stores/${target_store_id}/mailboxes/${params.id}`,
|
|
1396
|
+
options
|
|
1397
|
+
);
|
|
1398
|
+
},
|
|
1399
|
+
async test(params, options) {
|
|
1400
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1401
|
+
return apiConfig.httpClient.post(
|
|
1402
|
+
`/v1/stores/${target_store_id}/mailboxes/${params.id}/test`,
|
|
1403
|
+
{},
|
|
1404
|
+
options
|
|
1405
|
+
);
|
|
1406
|
+
},
|
|
1407
|
+
async prepare(params, options) {
|
|
1408
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1409
|
+
return apiConfig.httpClient.post(
|
|
1410
|
+
`/v1/stores/${target_store_id}/mailboxes/${params.id}/prepare`,
|
|
1411
|
+
{},
|
|
1412
|
+
options
|
|
1413
|
+
);
|
|
1414
|
+
},
|
|
1415
|
+
async find(params, options) {
|
|
1416
|
+
const { store_id, ...queryParams } = params || {};
|
|
1417
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1418
|
+
return apiConfig.httpClient.get(
|
|
1419
|
+
`/v1/stores/${target_store_id}/mailboxes`,
|
|
1420
|
+
{ ...options, params: queryParams }
|
|
1421
|
+
);
|
|
1422
|
+
}
|
|
1423
|
+
},
|
|
1424
|
+
campaign: {
|
|
1425
|
+
async create(params, options) {
|
|
1426
|
+
const { store_id, ...payload } = params;
|
|
1427
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1428
|
+
return apiConfig.httpClient.post(
|
|
1429
|
+
`/v1/stores/${target_store_id}/campaigns`,
|
|
1430
|
+
payload,
|
|
1431
|
+
options
|
|
1432
|
+
);
|
|
1433
|
+
},
|
|
1434
|
+
async update(params, options) {
|
|
1435
|
+
const { id, store_id, ...payload } = params;
|
|
1436
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1437
|
+
return apiConfig.httpClient.put(
|
|
1438
|
+
`/v1/stores/${target_store_id}/campaigns/${id}`,
|
|
1439
|
+
payload,
|
|
1440
|
+
options
|
|
1441
|
+
);
|
|
1442
|
+
},
|
|
1443
|
+
async get(params, options) {
|
|
1444
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1445
|
+
return apiConfig.httpClient.get(
|
|
1446
|
+
`/v1/stores/${target_store_id}/campaigns/${params.id}`,
|
|
1447
|
+
options
|
|
1448
|
+
);
|
|
1449
|
+
},
|
|
1450
|
+
async find(params, options) {
|
|
1451
|
+
const { store_id, ...queryParams } = params || {};
|
|
1452
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1453
|
+
return apiConfig.httpClient.get(
|
|
1454
|
+
`/v1/stores/${target_store_id}/campaigns`,
|
|
1455
|
+
{ ...options, params: queryParams }
|
|
1456
|
+
);
|
|
1457
|
+
},
|
|
1458
|
+
async launch(params, options) {
|
|
1459
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1460
|
+
return apiConfig.httpClient.post(
|
|
1461
|
+
`/v1/stores/${target_store_id}/campaigns/${params.id}/launch`,
|
|
1462
|
+
{},
|
|
1463
|
+
options
|
|
1464
|
+
);
|
|
1465
|
+
},
|
|
1466
|
+
async duplicate(params, options) {
|
|
1467
|
+
const { id, store_id, ...payload } = params;
|
|
1468
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1469
|
+
return apiConfig.httpClient.post(
|
|
1470
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/duplicate`,
|
|
1471
|
+
payload,
|
|
1472
|
+
options
|
|
1473
|
+
);
|
|
1474
|
+
},
|
|
1475
|
+
async launchReadiness(params, options) {
|
|
1476
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1477
|
+
return apiConfig.httpClient.get(
|
|
1478
|
+
`/v1/stores/${target_store_id}/campaigns/${params.id}/launch-readiness`,
|
|
1479
|
+
options
|
|
1480
|
+
);
|
|
1481
|
+
},
|
|
1482
|
+
async importEnrollments(params, options) {
|
|
1483
|
+
const { id, store_id, ...payload } = params;
|
|
1484
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1485
|
+
return apiConfig.httpClient.post(
|
|
1486
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/enrollments/import`,
|
|
1487
|
+
payload,
|
|
1488
|
+
options
|
|
1489
|
+
);
|
|
1490
|
+
},
|
|
1491
|
+
async generatePersonalizedDrafts(params, options) {
|
|
1492
|
+
const { id, store_id, ...payload } = params;
|
|
1493
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1494
|
+
return apiConfig.httpClient.post(
|
|
1495
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/personalized-drafts`,
|
|
1496
|
+
payload,
|
|
1497
|
+
options
|
|
1498
|
+
);
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
campaignEnrollment: {
|
|
1502
|
+
async find(params, options) {
|
|
1503
|
+
const { store_id, ...queryParams } = params || {};
|
|
1504
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1505
|
+
return apiConfig.httpClient.get(
|
|
1506
|
+
`/v1/stores/${target_store_id}/campaign-enrollments`,
|
|
1507
|
+
{ ...options, params: queryParams }
|
|
1508
|
+
);
|
|
1509
|
+
},
|
|
1510
|
+
async get(params, options) {
|
|
1511
|
+
const { store_id, id, ...queryParams } = params;
|
|
1512
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1513
|
+
return apiConfig.httpClient.get(
|
|
1514
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}`,
|
|
1515
|
+
{ ...options, params: { ...queryParams, store_id: target_store_id } }
|
|
1516
|
+
);
|
|
1517
|
+
},
|
|
1518
|
+
async update(params, options) {
|
|
1519
|
+
const { store_id, id, ...payload } = params;
|
|
1520
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1521
|
+
return apiConfig.httpClient.put(
|
|
1522
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}`,
|
|
1523
|
+
payload,
|
|
1524
|
+
options
|
|
1525
|
+
);
|
|
1526
|
+
},
|
|
1527
|
+
async updateDraft(params, options) {
|
|
1528
|
+
const { store_id, id, draft_id, ...payload } = params;
|
|
1529
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1530
|
+
return apiConfig.httpClient.put(
|
|
1531
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/drafts/${draft_id}`,
|
|
1532
|
+
payload,
|
|
1533
|
+
options
|
|
1534
|
+
);
|
|
1535
|
+
},
|
|
1536
|
+
async updateStepExecution(params, options) {
|
|
1537
|
+
const { store_id, id, execution_id, ...payload } = params;
|
|
1538
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1539
|
+
return apiConfig.httpClient.post(
|
|
1540
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/step-executions/${execution_id}`,
|
|
1541
|
+
payload,
|
|
1542
|
+
options
|
|
1543
|
+
);
|
|
1544
|
+
},
|
|
1545
|
+
async reply(params, options) {
|
|
1546
|
+
const { store_id, id, ...payload } = params;
|
|
1547
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1548
|
+
return apiConfig.httpClient.post(
|
|
1549
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/reply`,
|
|
1550
|
+
payload,
|
|
1551
|
+
options
|
|
1552
|
+
);
|
|
1553
|
+
},
|
|
1554
|
+
async stop(params, options) {
|
|
1555
|
+
const { store_id, id, ...payload } = params;
|
|
1556
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1557
|
+
return apiConfig.httpClient.post(
|
|
1558
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/stop`,
|
|
1559
|
+
payload,
|
|
1560
|
+
options
|
|
1561
|
+
);
|
|
1562
|
+
}
|
|
1563
|
+
},
|
|
1564
|
+
campaignMessage: {
|
|
1565
|
+
async find(params, options) {
|
|
1566
|
+
const { store_id, ...queryParams } = params || {};
|
|
1567
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1568
|
+
return apiConfig.httpClient.get(
|
|
1569
|
+
`/v1/stores/${target_store_id}/campaign-messages`,
|
|
1570
|
+
{ ...options, params: queryParams }
|
|
1571
|
+
);
|
|
1572
|
+
},
|
|
1573
|
+
async update(params, options) {
|
|
1574
|
+
const { id, store_id, ...payload } = params;
|
|
1575
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1576
|
+
return apiConfig.httpClient.put(
|
|
1577
|
+
`/v1/stores/${target_store_id}/campaign-messages/${id}`,
|
|
1578
|
+
payload,
|
|
1579
|
+
options
|
|
1580
|
+
);
|
|
1581
|
+
}
|
|
1582
|
+
},
|
|
1583
|
+
suppression: {
|
|
1584
|
+
async create(params, options) {
|
|
1585
|
+
const { store_id, ...payload } = params;
|
|
1586
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1587
|
+
return apiConfig.httpClient.post(
|
|
1588
|
+
`/v1/stores/${target_store_id}/suppressions`,
|
|
1589
|
+
payload,
|
|
1590
|
+
options
|
|
1591
|
+
);
|
|
1592
|
+
},
|
|
1593
|
+
async update(params, options) {
|
|
1594
|
+
const { id, store_id, ...payload } = params;
|
|
1595
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1596
|
+
return apiConfig.httpClient.put(
|
|
1597
|
+
`/v1/stores/${target_store_id}/suppressions/${id}`,
|
|
1598
|
+
payload,
|
|
1599
|
+
options
|
|
1600
|
+
);
|
|
1601
|
+
},
|
|
1602
|
+
async get(params, options) {
|
|
1603
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1604
|
+
return apiConfig.httpClient.get(
|
|
1605
|
+
`/v1/stores/${target_store_id}/suppressions/${params.id}`,
|
|
1606
|
+
options
|
|
1607
|
+
);
|
|
1608
|
+
},
|
|
1609
|
+
async find(params, options) {
|
|
1610
|
+
const { store_id, ...queryParams } = params || {};
|
|
1611
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1612
|
+
return apiConfig.httpClient.get(
|
|
1613
|
+
`/v1/stores/${target_store_id}/suppressions`,
|
|
1614
|
+
{ ...options, params: queryParams }
|
|
1615
|
+
);
|
|
1616
|
+
}
|
|
1617
|
+
},
|
|
1618
|
+
action: createActionAdminApi(apiConfig)
|
|
1619
|
+
};
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
// src/api/support.ts
|
|
1623
|
+
function supportConversationQuery(params) {
|
|
1624
|
+
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
1625
|
+
if (params.message_limit) qs.set("message_limit", String(params.message_limit));
|
|
1626
|
+
if (typeof params.after_created_at === "number") qs.set("after_created_at", String(params.after_created_at));
|
|
1627
|
+
if (params.after_id) qs.set("after_id", params.after_id);
|
|
1628
|
+
return qs.toString();
|
|
1629
|
+
}
|
|
1630
|
+
function createAdminSupportApi(config) {
|
|
1631
|
+
const { httpClient } = config;
|
|
1632
|
+
return {
|
|
1633
|
+
agent: {
|
|
1634
|
+
async create(params, opts) {
|
|
1635
|
+
return httpClient.post(
|
|
1636
|
+
`/v1/stores/${params.store_id}/support/agents`,
|
|
1637
|
+
params,
|
|
1638
|
+
opts
|
|
1639
|
+
);
|
|
1640
|
+
},
|
|
1641
|
+
async get(params, opts) {
|
|
1642
|
+
return httpClient.get(
|
|
1643
|
+
`/v1/stores/${params.store_id}/support/agents/${params.id}?store_id=${params.store_id}`,
|
|
1644
|
+
opts
|
|
1645
|
+
);
|
|
1646
|
+
},
|
|
1647
|
+
async find(params, opts) {
|
|
1648
|
+
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
1649
|
+
if (params.status) qs.set("status", params.status);
|
|
1650
|
+
if (params.limit) qs.set("limit", String(params.limit));
|
|
1651
|
+
if (params.cursor) qs.set("cursor", params.cursor);
|
|
1652
|
+
return httpClient.get(
|
|
1653
|
+
`/v1/stores/${params.store_id}/support/agents?${qs}`,
|
|
1654
|
+
opts
|
|
1655
|
+
);
|
|
1656
|
+
},
|
|
1657
|
+
async update(params, opts) {
|
|
1658
|
+
return httpClient.put(
|
|
1659
|
+
`/v1/stores/${params.store_id}/support/agents/${params.id}`,
|
|
1660
|
+
params,
|
|
1661
|
+
opts
|
|
1662
|
+
);
|
|
1663
|
+
},
|
|
1664
|
+
async delete(params, opts) {
|
|
1665
|
+
return httpClient.delete(
|
|
1666
|
+
`/v1/stores/${params.store_id}/support/agents/${params.id}?store_id=${params.store_id}`,
|
|
1667
|
+
opts
|
|
1668
|
+
);
|
|
1669
|
+
}
|
|
1670
|
+
},
|
|
1671
|
+
conversation: {
|
|
1672
|
+
async find(params, opts) {
|
|
1673
|
+
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
1674
|
+
if (params.status) qs.set("status", params.status);
|
|
1675
|
+
if (params.agent_id) qs.set("agent_id", params.agent_id);
|
|
1676
|
+
if (params.query) qs.set("query", params.query);
|
|
1677
|
+
if (params.limit) qs.set("limit", String(params.limit));
|
|
1678
|
+
if (params.cursor) qs.set("cursor", params.cursor);
|
|
1679
|
+
return httpClient.get(
|
|
1680
|
+
`/v1/stores/${params.store_id}/support/conversations?${qs}`,
|
|
1681
|
+
opts
|
|
1682
|
+
);
|
|
1683
|
+
},
|
|
1684
|
+
async get(params, opts) {
|
|
1685
|
+
const qs = supportConversationQuery(params);
|
|
1686
|
+
return httpClient.get(
|
|
1687
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}?${qs}`,
|
|
1688
|
+
opts
|
|
1689
|
+
);
|
|
1690
|
+
},
|
|
1691
|
+
async sendMessage(params, opts) {
|
|
1692
|
+
return httpClient.post(
|
|
1693
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/messages`,
|
|
1694
|
+
params,
|
|
1695
|
+
opts
|
|
1696
|
+
);
|
|
1697
|
+
},
|
|
1698
|
+
async reply(params, opts) {
|
|
1699
|
+
return httpClient.post(
|
|
1700
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/reply`,
|
|
1701
|
+
params,
|
|
1702
|
+
opts
|
|
1703
|
+
);
|
|
1704
|
+
},
|
|
1705
|
+
async resolve(params, opts) {
|
|
1706
|
+
return httpClient.post(
|
|
1707
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/resolve`,
|
|
1708
|
+
params,
|
|
1709
|
+
opts
|
|
1710
|
+
);
|
|
1711
|
+
},
|
|
1712
|
+
async assign(params, opts) {
|
|
1713
|
+
return httpClient.post(
|
|
1714
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/assign`,
|
|
1715
|
+
params,
|
|
1716
|
+
opts
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
// src/api/leadResearch.ts
|
|
1724
|
+
var createLeadResearchApi = (apiConfig) => {
|
|
1725
|
+
const storeId = (store_id) => store_id || apiConfig.storeId;
|
|
1726
|
+
return {
|
|
1727
|
+
async createRun(params, options) {
|
|
1728
|
+
const { store_id, ...payload } = params;
|
|
1729
|
+
return apiConfig.httpClient.post(
|
|
1730
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs`,
|
|
1731
|
+
payload,
|
|
1732
|
+
options
|
|
1733
|
+
);
|
|
1734
|
+
},
|
|
1735
|
+
async findRuns(params, options) {
|
|
1736
|
+
const { store_id, ...queryParams } = params || {};
|
|
1737
|
+
return apiConfig.httpClient.get(
|
|
1738
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs`,
|
|
1739
|
+
{ ...options, params: queryParams }
|
|
1740
|
+
);
|
|
1741
|
+
},
|
|
1742
|
+
async getRun(params, options) {
|
|
1743
|
+
return apiConfig.httpClient.get(
|
|
1744
|
+
`/v1/stores/${storeId(params.store_id)}/lead-research/runs/${params.id}`,
|
|
1745
|
+
options
|
|
1746
|
+
);
|
|
1747
|
+
},
|
|
1748
|
+
async updateRun(params, options) {
|
|
1749
|
+
const { store_id, id, ...payload } = params;
|
|
1750
|
+
return apiConfig.httpClient.patch(
|
|
1751
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs/${id}`,
|
|
1752
|
+
payload,
|
|
1753
|
+
options
|
|
1754
|
+
);
|
|
1755
|
+
},
|
|
1756
|
+
async cancelRun(params, options) {
|
|
1757
|
+
return apiConfig.httpClient.post(
|
|
1758
|
+
`/v1/stores/${storeId(params.store_id)}/lead-research/runs/${params.id}/cancel`,
|
|
1759
|
+
{},
|
|
1760
|
+
options
|
|
1761
|
+
);
|
|
1762
|
+
},
|
|
1763
|
+
async sendMessage(params, options) {
|
|
1764
|
+
const { store_id, run_id, ...payload } = params;
|
|
1765
|
+
return apiConfig.httpClient.post(
|
|
1766
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs/${run_id}/messages`,
|
|
1767
|
+
payload,
|
|
1768
|
+
options
|
|
1769
|
+
);
|
|
1770
|
+
},
|
|
1771
|
+
async findMessages(params, options) {
|
|
1772
|
+
const { store_id, run_id, ...queryParams } = params;
|
|
1773
|
+
return apiConfig.httpClient.get(
|
|
1774
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs/${run_id}/messages`,
|
|
1775
|
+
{ ...options, params: queryParams }
|
|
1776
|
+
);
|
|
1777
|
+
},
|
|
1778
|
+
async validateEmail(params, options) {
|
|
1779
|
+
const { store_id, ...payload } = params;
|
|
1780
|
+
return apiConfig.httpClient.post(
|
|
1781
|
+
`/v1/stores/${storeId(store_id)}/lead-research/validate-email`,
|
|
1782
|
+
payload,
|
|
1783
|
+
options
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1787
|
+
};
|
|
1788
|
+
|
|
1789
|
+
// src/api/social.ts
|
|
1790
|
+
var createSocialApi = (apiConfig) => {
|
|
1791
|
+
const storeId = (store_id) => store_id || apiConfig.storeId;
|
|
1792
|
+
const api = {
|
|
1793
|
+
async findPublications(params, options) {
|
|
1794
|
+
const { store_id, ...queryParams } = params || {};
|
|
1795
|
+
return apiConfig.httpClient.get(
|
|
1796
|
+
`/v1/stores/${storeId(store_id)}/social-publications`,
|
|
1797
|
+
{
|
|
1798
|
+
...options,
|
|
1799
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1800
|
+
}
|
|
1801
|
+
);
|
|
1802
|
+
},
|
|
1803
|
+
async getPublication(params, options) {
|
|
1804
|
+
return apiConfig.httpClient.get(
|
|
1805
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.id}`,
|
|
1806
|
+
options
|
|
1807
|
+
);
|
|
1808
|
+
},
|
|
1809
|
+
async validatePublication(params, options) {
|
|
1810
|
+
const { store_id, ...payload } = params;
|
|
1811
|
+
return apiConfig.httpClient.post(
|
|
1812
|
+
`/v1/stores/${storeId(store_id)}/social-publications/validate`,
|
|
1813
|
+
payload,
|
|
1814
|
+
options
|
|
1815
|
+
);
|
|
1816
|
+
},
|
|
1817
|
+
async createPublication(params, options) {
|
|
1818
|
+
const { store_id, ...payload } = params;
|
|
1819
|
+
return apiConfig.httpClient.post(
|
|
1820
|
+
`/v1/stores/${storeId(store_id)}/social-publications`,
|
|
1821
|
+
payload,
|
|
1822
|
+
options
|
|
1823
|
+
);
|
|
1824
|
+
},
|
|
1825
|
+
async updatePublication(params, options) {
|
|
1826
|
+
const { store_id, id, ...payload } = params;
|
|
1827
|
+
return apiConfig.httpClient.put(
|
|
1828
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${id}`,
|
|
1829
|
+
payload,
|
|
1830
|
+
options
|
|
1831
|
+
);
|
|
1832
|
+
},
|
|
1833
|
+
async schedulePublication(params, options) {
|
|
1834
|
+
const { store_id, id, ...payload } = params;
|
|
1835
|
+
return apiConfig.httpClient.post(
|
|
1836
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${id}/schedule`,
|
|
1837
|
+
payload,
|
|
1838
|
+
options
|
|
1839
|
+
);
|
|
1840
|
+
},
|
|
1841
|
+
async cancelPublication(params, options) {
|
|
1842
|
+
return apiConfig.httpClient.post(
|
|
1843
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.id}/cancel`,
|
|
1844
|
+
{},
|
|
1845
|
+
options
|
|
1846
|
+
);
|
|
1847
|
+
},
|
|
1848
|
+
async getPublicationComments(params, options) {
|
|
1849
|
+
const { store_id, publication_id, ...queryParams } = params;
|
|
1850
|
+
return apiConfig.httpClient.get(
|
|
1851
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments`,
|
|
1852
|
+
{
|
|
1853
|
+
...options,
|
|
1854
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1855
|
+
}
|
|
1856
|
+
);
|
|
1857
|
+
},
|
|
1858
|
+
async syncPublicationComments(params, options) {
|
|
1859
|
+
const { store_id, publication_id, ...payload } = params;
|
|
1860
|
+
return apiConfig.httpClient.post(
|
|
1861
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/sync`,
|
|
1862
|
+
payload,
|
|
1863
|
+
options
|
|
1864
|
+
);
|
|
1865
|
+
},
|
|
1866
|
+
async getPublicationCommentThread(params, options) {
|
|
1867
|
+
const { store_id, publication_id, comment_id, ...queryParams } = params;
|
|
1868
|
+
return apiConfig.httpClient.get(
|
|
1869
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/thread`,
|
|
1870
|
+
{
|
|
1871
|
+
...options,
|
|
1872
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1873
|
+
}
|
|
1874
|
+
);
|
|
1875
|
+
},
|
|
1876
|
+
async syncPublicationCommentThread(params, options) {
|
|
1877
|
+
const { store_id, publication_id, comment_id, ...payload } = params;
|
|
1878
|
+
return apiConfig.httpClient.post(
|
|
1879
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/thread/sync`,
|
|
1880
|
+
payload,
|
|
1881
|
+
options
|
|
1882
|
+
);
|
|
1883
|
+
},
|
|
1884
|
+
async findPublicationComments(params, options) {
|
|
1885
|
+
const { store_id, ...queryParams } = params || {};
|
|
1886
|
+
return apiConfig.httpClient.get(`/v1/stores/${storeId(store_id)}/social-publications/comments`, {
|
|
1887
|
+
...options,
|
|
1888
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1889
|
+
});
|
|
1890
|
+
},
|
|
1891
|
+
async classifyPublicationComments(params, options) {
|
|
1892
|
+
const { store_id, ...payload } = params || {};
|
|
1893
|
+
return apiConfig.httpClient.post(
|
|
1894
|
+
`/v1/stores/${storeId(store_id)}/social-publications/comments/classify`,
|
|
1895
|
+
payload,
|
|
1896
|
+
options
|
|
1897
|
+
);
|
|
1898
|
+
},
|
|
1899
|
+
async replyToPublicationComment(params, options) {
|
|
1900
|
+
const { store_id, publication_id, comment_id, text } = params;
|
|
1901
|
+
return apiConfig.httpClient.post(
|
|
1902
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/reply`,
|
|
1903
|
+
{ text },
|
|
1904
|
+
options
|
|
1905
|
+
);
|
|
1906
|
+
},
|
|
1907
|
+
async getPublicationMetrics(params, options) {
|
|
1908
|
+
return apiConfig.httpClient.get(
|
|
1909
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/metrics`,
|
|
1910
|
+
options
|
|
1911
|
+
);
|
|
1912
|
+
},
|
|
1913
|
+
async syncPublicationMetrics(params, options) {
|
|
1914
|
+
return apiConfig.httpClient.post(
|
|
1915
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/metrics/sync`,
|
|
1916
|
+
{},
|
|
1917
|
+
options
|
|
1918
|
+
);
|
|
1919
|
+
},
|
|
1920
|
+
async syncEngagement(params, options) {
|
|
1921
|
+
const { store_id, ...payload } = params || {};
|
|
1922
|
+
return apiConfig.httpClient.post(
|
|
1923
|
+
`/v1/stores/${storeId(store_id)}/social-publications/engagement/sync`,
|
|
1924
|
+
payload,
|
|
1925
|
+
options
|
|
1926
|
+
);
|
|
1927
|
+
},
|
|
1928
|
+
async getCapabilities(params, options) {
|
|
1929
|
+
return apiConfig.httpClient.get(
|
|
1930
|
+
`/v1/stores/${storeId(params?.store_id)}/social-accounts/capabilities`,
|
|
1931
|
+
options
|
|
1932
|
+
);
|
|
1933
|
+
},
|
|
1934
|
+
async listAccounts(params, options) {
|
|
1935
|
+
return apiConfig.httpClient.get(
|
|
1936
|
+
`/v1/stores/${storeId(params?.store_id)}/social-accounts`,
|
|
1937
|
+
options
|
|
1938
|
+
);
|
|
1939
|
+
},
|
|
1940
|
+
async connect(params, options) {
|
|
1941
|
+
const { store_id, ...payload } = params;
|
|
1942
|
+
return apiConfig.httpClient.post(
|
|
1943
|
+
`/v1/stores/${storeId(store_id)}/social-accounts/oauth/connect`,
|
|
1944
|
+
payload,
|
|
1945
|
+
options
|
|
1946
|
+
);
|
|
1947
|
+
},
|
|
1948
|
+
async getOAuthAttempt(params, options) {
|
|
1949
|
+
return apiConfig.httpClient.get(
|
|
1950
|
+
`/v1/stores/${storeId(params.store_id)}/social-accounts/oauth/attempts/${params.attempt_id}`,
|
|
1951
|
+
options
|
|
1952
|
+
);
|
|
1953
|
+
},
|
|
1954
|
+
async selectDestination(params, options) {
|
|
1955
|
+
const { store_id, ...payload } = params;
|
|
1956
|
+
return apiConfig.httpClient.post(
|
|
1957
|
+
`/v1/stores/${storeId(store_id)}/social-accounts/oauth/select-destination`,
|
|
1958
|
+
payload,
|
|
1959
|
+
options
|
|
1960
|
+
);
|
|
1961
|
+
},
|
|
1962
|
+
async deleteAccount(params, options) {
|
|
1963
|
+
return apiConfig.httpClient.delete(
|
|
1964
|
+
`/v1/stores/${storeId(params.store_id)}/social-accounts/${params.id}`,
|
|
1965
|
+
options
|
|
1966
|
+
);
|
|
1967
|
+
},
|
|
1968
|
+
validatePublications(params, options) {
|
|
1969
|
+
return api.validatePublication(params, options);
|
|
1970
|
+
},
|
|
1971
|
+
createPublications(params, options) {
|
|
1972
|
+
return api.createPublication(params, options);
|
|
1973
|
+
}
|
|
1974
|
+
};
|
|
1975
|
+
return api;
|
|
1976
|
+
};
|
|
1977
|
+
|
|
1978
|
+
// src/api/workflow.ts
|
|
1979
|
+
var createWorkflowApi = (apiConfig) => {
|
|
1980
|
+
return {
|
|
1981
|
+
async createWorkflow(params, options) {
|
|
1982
|
+
const { store_id, ...payload } = params;
|
|
1983
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1984
|
+
return apiConfig.httpClient.post(
|
|
1985
|
+
`/v1/stores/${target_store_id}/workflows`,
|
|
1986
|
+
{ ...payload, store_id: target_store_id },
|
|
1987
|
+
options
|
|
1988
|
+
);
|
|
1989
|
+
},
|
|
1990
|
+
async updateWorkflow(params, options) {
|
|
1991
|
+
const { store_id, id, ...payload } = params;
|
|
1444
1992
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1445
1993
|
return apiConfig.httpClient.put(
|
|
1446
1994
|
`/v1/stores/${target_store_id}/workflows/${id}`,
|
|
@@ -1462,17 +2010,24 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1462
2010
|
options
|
|
1463
2011
|
);
|
|
1464
2012
|
},
|
|
1465
|
-
async getWorkflows(params, options) {
|
|
1466
|
-
const store_id = params?.store_id || apiConfig.storeId;
|
|
1467
|
-
const { store_id: _, ...queryParams } = params || {};
|
|
1468
|
-
return apiConfig.httpClient.get(
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
2013
|
+
async getWorkflows(params, options) {
|
|
2014
|
+
const store_id = params?.store_id || apiConfig.storeId;
|
|
2015
|
+
const { store_id: _, ...queryParams } = params || {};
|
|
2016
|
+
return apiConfig.httpClient.get(
|
|
2017
|
+
`/v1/stores/${store_id}/workflows`,
|
|
2018
|
+
{
|
|
2019
|
+
...options,
|
|
2020
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2021
|
+
}
|
|
2022
|
+
);
|
|
2023
|
+
},
|
|
1473
2024
|
async triggerWorkflow(params, options) {
|
|
1474
2025
|
const { secret, ...payload } = params;
|
|
1475
|
-
return apiConfig.httpClient.post(
|
|
2026
|
+
return apiConfig.httpClient.post(
|
|
2027
|
+
`/v1/workflows/trigger/${secret}`,
|
|
2028
|
+
payload,
|
|
2029
|
+
options
|
|
2030
|
+
);
|
|
1476
2031
|
},
|
|
1477
2032
|
async getWorkflowExecutions(params, options) {
|
|
1478
2033
|
const store_id = params.store_id || apiConfig.storeId;
|
|
@@ -1491,6 +2046,38 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1491
2046
|
`/v1/stores/${store_id}/workflows/${params.workflow_id}/executions/${params.execution_id}`,
|
|
1492
2047
|
options
|
|
1493
2048
|
);
|
|
2049
|
+
},
|
|
2050
|
+
async getWorkflowAccounts(params, options) {
|
|
2051
|
+
const store_id = params?.store_id || apiConfig.storeId;
|
|
2052
|
+
return apiConfig.httpClient.get(
|
|
2053
|
+
`/v1/stores/${store_id}/workflow-accounts`,
|
|
2054
|
+
options
|
|
2055
|
+
);
|
|
2056
|
+
},
|
|
2057
|
+
async getWorkflowAccountConnectUrl(params, options) {
|
|
2058
|
+
const { store_id, type, ...payload } = params;
|
|
2059
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2060
|
+
return apiConfig.httpClient.post(
|
|
2061
|
+
`/v1/stores/${target_store_id}/workflow-accounts/connect-url`,
|
|
2062
|
+
{ ...payload, type, store_id: target_store_id },
|
|
2063
|
+
options
|
|
2064
|
+
);
|
|
2065
|
+
},
|
|
2066
|
+
async connectWorkflowAccount(params, options) {
|
|
2067
|
+
const { store_id, type, ...payload } = params;
|
|
2068
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2069
|
+
return apiConfig.httpClient.post(
|
|
2070
|
+
`/v1/stores/${target_store_id}/workflow-accounts/connect`,
|
|
2071
|
+
{ ...payload, type, store_id: target_store_id },
|
|
2072
|
+
options
|
|
2073
|
+
);
|
|
2074
|
+
},
|
|
2075
|
+
async deleteWorkflowAccount(params, options) {
|
|
2076
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2077
|
+
return apiConfig.httpClient.delete(
|
|
2078
|
+
`/v1/stores/${store_id}/workflow-accounts/${params.id}`,
|
|
2079
|
+
options
|
|
2080
|
+
);
|
|
1494
2081
|
}
|
|
1495
2082
|
};
|
|
1496
2083
|
};
|
|
@@ -1501,8 +2088,8 @@ var createPlatformApi = (apiConfig) => {
|
|
|
1501
2088
|
async getCurrencies(options) {
|
|
1502
2089
|
return apiConfig.httpClient.get("/v1/platform/currencies", options);
|
|
1503
2090
|
},
|
|
1504
|
-
async
|
|
1505
|
-
return apiConfig.httpClient.get("/v1/platform/
|
|
2091
|
+
async getWorkflowTools(options) {
|
|
2092
|
+
return apiConfig.httpClient.get("/v1/platform/workflow-tools", options);
|
|
1506
2093
|
},
|
|
1507
2094
|
async getWebhookEvents(options) {
|
|
1508
2095
|
return apiConfig.httpClient.get("/v1/platform/events", options);
|
|
@@ -1552,116 +2139,35 @@ var createShippingApi = (apiConfig) => {
|
|
|
1552
2139
|
};
|
|
1553
2140
|
};
|
|
1554
2141
|
|
|
1555
|
-
// src/api/
|
|
1556
|
-
var
|
|
2142
|
+
// src/api/paymentProvider.ts
|
|
2143
|
+
var createPaymentProviderApi = (apiConfig) => {
|
|
2144
|
+
const storeId = (store_id) => store_id || apiConfig.storeId;
|
|
1557
2145
|
return {
|
|
1558
|
-
async
|
|
1559
|
-
const { store_id, ...payload } = params;
|
|
1560
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1561
|
-
return apiConfig.httpClient.post(
|
|
1562
|
-
`/v1/stores/${target_store_id}/agents`,
|
|
1563
|
-
{ ...payload, store_id: target_store_id },
|
|
1564
|
-
options
|
|
1565
|
-
);
|
|
1566
|
-
},
|
|
1567
|
-
async updateAgent(params, options) {
|
|
1568
|
-
const { store_id, id, ...payload } = params;
|
|
1569
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1570
|
-
return apiConfig.httpClient.put(
|
|
1571
|
-
`/v1/stores/${target_store_id}/agents/${id}`,
|
|
1572
|
-
payload,
|
|
1573
|
-
options
|
|
1574
|
-
);
|
|
1575
|
-
},
|
|
1576
|
-
async deleteAgent(params, options) {
|
|
1577
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1578
|
-
return apiConfig.httpClient.delete(
|
|
1579
|
-
`/v1/stores/${store_id}/agents/${params.id}`,
|
|
1580
|
-
options
|
|
1581
|
-
);
|
|
1582
|
-
},
|
|
1583
|
-
async getAgent(params, options) {
|
|
1584
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2146
|
+
async list(params, options) {
|
|
1585
2147
|
return apiConfig.httpClient.get(
|
|
1586
|
-
`/v1/stores/${store_id}/
|
|
2148
|
+
`/v1/stores/${storeId(params?.store_id)}/payment-providers`,
|
|
1587
2149
|
options
|
|
1588
2150
|
);
|
|
1589
2151
|
},
|
|
1590
|
-
async
|
|
1591
|
-
const
|
|
1592
|
-
const { store_id: _, ...queryParams } = params || {};
|
|
1593
|
-
return apiConfig.httpClient.get(`/v1/stores/${store_id}/agents`, {
|
|
1594
|
-
...options,
|
|
1595
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1596
|
-
});
|
|
1597
|
-
},
|
|
1598
|
-
async sendMessage(params, options) {
|
|
1599
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1600
|
-
const body = { message: params.message };
|
|
1601
|
-
if (params.chat_id) body.chat_id = params.chat_id;
|
|
1602
|
-
if (params.direct) body.direct = params.direct;
|
|
2152
|
+
async refresh(params, options) {
|
|
2153
|
+
const targetStoreId = storeId(params?.store_id);
|
|
1603
2154
|
return apiConfig.httpClient.post(
|
|
1604
|
-
`/v1/stores/${
|
|
1605
|
-
|
|
1606
|
-
options
|
|
1607
|
-
);
|
|
1608
|
-
},
|
|
1609
|
-
async getChats(params, options) {
|
|
1610
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1611
|
-
const queryParams = {};
|
|
1612
|
-
if (params.limit) queryParams.limit = String(params.limit);
|
|
1613
|
-
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1614
|
-
return apiConfig.httpClient.get(
|
|
1615
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats`,
|
|
1616
|
-
{
|
|
1617
|
-
...options,
|
|
1618
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1619
|
-
}
|
|
1620
|
-
);
|
|
1621
|
-
},
|
|
1622
|
-
async getChat(params, options) {
|
|
1623
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1624
|
-
return apiConfig.httpClient.get(
|
|
1625
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
|
|
1626
|
-
options
|
|
1627
|
-
);
|
|
1628
|
-
},
|
|
1629
|
-
async updateChat(params, options) {
|
|
1630
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1631
|
-
return apiConfig.httpClient.put(
|
|
1632
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
|
|
1633
|
-
{ status: params.status },
|
|
2155
|
+
`/v1/stores/${targetStoreId}/payment-providers/refresh`,
|
|
2156
|
+
{ store_id: targetStoreId },
|
|
1634
2157
|
options
|
|
1635
2158
|
);
|
|
1636
2159
|
},
|
|
1637
|
-
async
|
|
1638
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1639
|
-
const body = { rating: params.rating };
|
|
1640
|
-
if (params.comment) body.comment = params.comment;
|
|
2160
|
+
async connectStripe(params, options) {
|
|
1641
2161
|
return apiConfig.httpClient.post(
|
|
1642
|
-
`/v1/stores/${
|
|
1643
|
-
|
|
2162
|
+
`/v1/stores/${storeId(params.store_id)}/payment-providers/stripe/connect`,
|
|
2163
|
+
params,
|
|
1644
2164
|
options
|
|
1645
2165
|
);
|
|
1646
2166
|
},
|
|
1647
|
-
async
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
...options,
|
|
1652
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1653
|
-
});
|
|
1654
|
-
},
|
|
1655
|
-
async getChatMessages(params, options) {
|
|
1656
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1657
|
-
const queryParams = {};
|
|
1658
|
-
if (params.limit) queryParams.limit = String(params.limit);
|
|
1659
|
-
return apiConfig.httpClient.get(
|
|
1660
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/messages`,
|
|
1661
|
-
{
|
|
1662
|
-
...options,
|
|
1663
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1664
|
-
}
|
|
2167
|
+
async delete(params, options) {
|
|
2168
|
+
return apiConfig.httpClient.delete(
|
|
2169
|
+
`/v1/stores/${storeId(params.store_id)}/payment-providers/${params.id}`,
|
|
2170
|
+
options
|
|
1665
2171
|
);
|
|
1666
2172
|
}
|
|
1667
2173
|
};
|
|
@@ -1720,6 +2226,15 @@ var createEmailTemplateApi = (apiConfig) => {
|
|
|
1720
2226
|
params: queryParams
|
|
1721
2227
|
}
|
|
1722
2228
|
);
|
|
2229
|
+
},
|
|
2230
|
+
async previewEmailTemplate(params, options) {
|
|
2231
|
+
const { store_id, id, ...payload } = params;
|
|
2232
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2233
|
+
return apiConfig.httpClient.post(
|
|
2234
|
+
`/v1/stores/${target_store_id}/email-templates/${id}/preview`,
|
|
2235
|
+
payload,
|
|
2236
|
+
options
|
|
2237
|
+
);
|
|
1723
2238
|
}
|
|
1724
2239
|
};
|
|
1725
2240
|
};
|
|
@@ -1893,6 +2408,164 @@ var createAnalyticsApi = (apiConfig) => {
|
|
|
1893
2408
|
};
|
|
1894
2409
|
};
|
|
1895
2410
|
|
|
2411
|
+
// src/api/experiments.ts
|
|
2412
|
+
var createExperimentsApi = (apiConfig) => {
|
|
2413
|
+
const base = (storeId = apiConfig.storeId) => `/v1/stores/${storeId}/experiments`;
|
|
2414
|
+
return {
|
|
2415
|
+
create(params, options) {
|
|
2416
|
+
const { store_id, ...payload } = params;
|
|
2417
|
+
return apiConfig.httpClient.post(base(store_id), payload, options);
|
|
2418
|
+
},
|
|
2419
|
+
update(params, options) {
|
|
2420
|
+
const { store_id, key, ...payload } = params;
|
|
2421
|
+
return apiConfig.httpClient.put(`${base(store_id)}/${key}`, payload, options);
|
|
2422
|
+
},
|
|
2423
|
+
get(params, options) {
|
|
2424
|
+
return apiConfig.httpClient.get(`${base(params.store_id)}/${params.key}`, options);
|
|
2425
|
+
},
|
|
2426
|
+
find(params = {}, options) {
|
|
2427
|
+
const { store_id, ...queryParams } = params;
|
|
2428
|
+
return apiConfig.httpClient.get(base(store_id), {
|
|
2429
|
+
...options,
|
|
2430
|
+
params: queryParams
|
|
2431
|
+
});
|
|
2432
|
+
},
|
|
2433
|
+
results(params, options) {
|
|
2434
|
+
return apiConfig.httpClient.get(
|
|
2435
|
+
`${base(params.store_id)}/${params.key}/results`,
|
|
2436
|
+
options
|
|
2437
|
+
);
|
|
2438
|
+
}
|
|
2439
|
+
};
|
|
2440
|
+
};
|
|
2441
|
+
|
|
2442
|
+
// src/utils/blocks.ts
|
|
2443
|
+
function getBlockLabel(block) {
|
|
2444
|
+
if (!block) return "";
|
|
2445
|
+
return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) ?? "";
|
|
2446
|
+
}
|
|
2447
|
+
function formatBlockValue(block) {
|
|
2448
|
+
if (!block || block.value === null || block.value === void 0) return "";
|
|
2449
|
+
const value = block.value;
|
|
2450
|
+
switch (block.type) {
|
|
2451
|
+
case "boolean":
|
|
2452
|
+
return value ? "Yes" : "No";
|
|
2453
|
+
case "number":
|
|
2454
|
+
if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
|
|
2455
|
+
return new Date(value).toLocaleDateString();
|
|
2456
|
+
}
|
|
2457
|
+
return String(value);
|
|
2458
|
+
case "media":
|
|
2459
|
+
if (value && typeof value === "object") {
|
|
2460
|
+
return value.mime_type ? value.name || value.id : value.title || value.name || value.id;
|
|
2461
|
+
}
|
|
2462
|
+
return String(value);
|
|
2463
|
+
default:
|
|
2464
|
+
return String(value);
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
function prepareBlocksForSubmission(formData, blockTypes) {
|
|
2468
|
+
return Object.keys(formData).filter((key) => formData[key] !== null && formData[key] !== void 0).map((key) => ({
|
|
2469
|
+
key,
|
|
2470
|
+
value: (blockTypes?.[key] || "text") === "array" && !Array.isArray(formData[key]) ? [formData[key]] : formData[key]
|
|
2471
|
+
}));
|
|
2472
|
+
}
|
|
2473
|
+
function extractBlockValues(blocks) {
|
|
2474
|
+
const values = {};
|
|
2475
|
+
blocks.forEach((block) => {
|
|
2476
|
+
values[block.key] = block.value ?? null;
|
|
2477
|
+
});
|
|
2478
|
+
return values;
|
|
2479
|
+
}
|
|
2480
|
+
var getBlockValue = (entry, blockKey) => {
|
|
2481
|
+
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
2482
|
+
return block?.value ?? null;
|
|
2483
|
+
};
|
|
2484
|
+
var getBlockTextValue = (block, locale = "en") => {
|
|
2485
|
+
if (!block || block.value === null || block.value === void 0) return "";
|
|
2486
|
+
const blockType = block.type;
|
|
2487
|
+
if (blockType === "localized_text" || blockType === "markdown") {
|
|
2488
|
+
if (typeof block.value === "object" && block.value !== null) {
|
|
2489
|
+
return block.value[locale] ?? block.value["en"] ?? "";
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
if (typeof block.value === "string") return block.value;
|
|
2493
|
+
return String(block.value ?? "");
|
|
2494
|
+
};
|
|
2495
|
+
var getBlockValues = (entry, blockKey) => {
|
|
2496
|
+
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
2497
|
+
if (!block) return [];
|
|
2498
|
+
if (block.type === "array" && Array.isArray(block.value)) {
|
|
2499
|
+
return block.value;
|
|
2500
|
+
}
|
|
2501
|
+
return [];
|
|
2502
|
+
};
|
|
2503
|
+
function unwrapBlock(block, locale) {
|
|
2504
|
+
if (!block?.type || block.value === void 0) return block;
|
|
2505
|
+
const blockType = block.type;
|
|
2506
|
+
if (blockType === "array") {
|
|
2507
|
+
return block.value.map((obj) => {
|
|
2508
|
+
const parsed = {};
|
|
2509
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
2510
|
+
parsed[k] = unwrapBlock(v, locale);
|
|
2511
|
+
}
|
|
2512
|
+
return parsed;
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
if (blockType === "object") {
|
|
2516
|
+
const parsed = {};
|
|
2517
|
+
for (const [k, v] of Object.entries(block.value || {})) {
|
|
2518
|
+
parsed[k] = unwrapBlock(v, locale);
|
|
2519
|
+
}
|
|
2520
|
+
return parsed;
|
|
2521
|
+
}
|
|
2522
|
+
if (blockType === "localized_text" || blockType === "markdown") {
|
|
2523
|
+
return block.value?.[locale];
|
|
2524
|
+
}
|
|
2525
|
+
return block.value;
|
|
2526
|
+
}
|
|
2527
|
+
var getBlockObjectValues = (entry, blockKey, locale = "en") => {
|
|
2528
|
+
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
2529
|
+
if (!block || block.type !== "array" || !Array.isArray(block.value)) return [];
|
|
2530
|
+
return block.value.map((obj) => {
|
|
2531
|
+
if (!obj?.value || !Array.isArray(obj.value)) return {};
|
|
2532
|
+
return obj.value.reduce((acc, current) => {
|
|
2533
|
+
acc[current.key] = unwrapBlock(current, locale);
|
|
2534
|
+
return acc;
|
|
2535
|
+
}, {});
|
|
2536
|
+
});
|
|
2537
|
+
};
|
|
2538
|
+
var getBlockFromArray = (entry, blockKey, locale = "en") => {
|
|
2539
|
+
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
2540
|
+
if (!block) return {};
|
|
2541
|
+
if (block.type === "array" && Array.isArray(block.value)) {
|
|
2542
|
+
return block.value.reduce((acc, current) => {
|
|
2543
|
+
acc[current.key] = unwrapBlock(current, locale);
|
|
2544
|
+
return acc;
|
|
2545
|
+
}, {});
|
|
2546
|
+
}
|
|
2547
|
+
if (block.type === "object" && block.value && typeof block.value === "object") {
|
|
2548
|
+
const result = {};
|
|
2549
|
+
for (const [k, v] of Object.entries(block.value)) {
|
|
2550
|
+
result[k] = unwrapBlock(v, locale);
|
|
2551
|
+
}
|
|
2552
|
+
return result;
|
|
2553
|
+
}
|
|
2554
|
+
return { [block.key]: unwrapBlock(block, locale) };
|
|
2555
|
+
};
|
|
2556
|
+
var getImageUrl = (imageBlock, isBlock = true) => {
|
|
2557
|
+
if (!imageBlock) return null;
|
|
2558
|
+
if (imageBlock.type === "media") {
|
|
2559
|
+
const mediaValue = imageBlock.value;
|
|
2560
|
+
return mediaValue?.resolutions?.original?.url || mediaValue?.url || null;
|
|
2561
|
+
}
|
|
2562
|
+
if (isBlock) {
|
|
2563
|
+
if (typeof imageBlock === "string") return imageBlock;
|
|
2564
|
+
if (imageBlock.url) return imageBlock.url;
|
|
2565
|
+
}
|
|
2566
|
+
return imageBlock.resolutions?.original?.url || null;
|
|
2567
|
+
};
|
|
2568
|
+
|
|
1896
2569
|
// src/utils/price.ts
|
|
1897
2570
|
function formatCurrency(amount, currencyCode, locale = "en") {
|
|
1898
2571
|
if (!currencyCode) return "";
|
|
@@ -2268,41 +2941,147 @@ function createAdmin(config) {
|
|
|
2268
2941
|
};
|
|
2269
2942
|
const accountApi = createAccountApi(apiConfig);
|
|
2270
2943
|
const authApi = createAuthApi(apiConfig, updateSession);
|
|
2271
|
-
const storeApi = createStoreApi(apiConfig
|
|
2944
|
+
const storeApi = createStoreApi(apiConfig);
|
|
2272
2945
|
const platformApi = createPlatformApi(apiConfig);
|
|
2273
2946
|
const cmsApi = createCmsApi(apiConfig);
|
|
2274
2947
|
const eshopApi = createEshopApi(apiConfig);
|
|
2275
2948
|
const promoCodeApi = createPromoCodeApi(apiConfig);
|
|
2276
|
-
const crmApi =
|
|
2949
|
+
const crmApi = createContactApi(apiConfig);
|
|
2950
|
+
const supportApi = createAdminSupportApi(apiConfig);
|
|
2951
|
+
const leadResearchApi = createLeadResearchApi(apiConfig);
|
|
2952
|
+
const socialApi = createSocialApi(apiConfig);
|
|
2953
|
+
const paymentProviderApi = createPaymentProviderApi(apiConfig);
|
|
2954
|
+
const notificationApi = createNotificationApi(apiConfig);
|
|
2955
|
+
const shippingApi = createShippingApi(apiConfig);
|
|
2277
2956
|
const locationApi = createLocationApi(apiConfig);
|
|
2278
2957
|
const marketApi = createMarketApi(apiConfig);
|
|
2279
|
-
const agentApi = createAgentApi(apiConfig);
|
|
2280
2958
|
const workflowApi = createWorkflowApi(apiConfig);
|
|
2959
|
+
const storePaymentProviderApi = {
|
|
2960
|
+
list: paymentProviderApi.list,
|
|
2961
|
+
refresh: paymentProviderApi.refresh,
|
|
2962
|
+
connectStripe: paymentProviderApi.connectStripe,
|
|
2963
|
+
delete: paymentProviderApi.delete
|
|
2964
|
+
};
|
|
2965
|
+
const workflowPublicApi = {
|
|
2966
|
+
create: workflowApi.createWorkflow,
|
|
2967
|
+
update: workflowApi.updateWorkflow,
|
|
2968
|
+
delete: workflowApi.deleteWorkflow,
|
|
2969
|
+
get: workflowApi.getWorkflow,
|
|
2970
|
+
find: workflowApi.getWorkflows,
|
|
2971
|
+
trigger: workflowApi.triggerWorkflow,
|
|
2972
|
+
getExecutions: workflowApi.getWorkflowExecutions,
|
|
2973
|
+
getExecution: workflowApi.getWorkflowExecution,
|
|
2974
|
+
listAccounts: workflowApi.getWorkflowAccounts,
|
|
2975
|
+
getAccountConnectUrl: workflowApi.getWorkflowAccountConnectUrl,
|
|
2976
|
+
connectAccount: workflowApi.connectWorkflowAccount,
|
|
2977
|
+
deleteAccount: workflowApi.deleteWorkflowAccount
|
|
2978
|
+
};
|
|
2281
2979
|
const formApi = createFormApi(apiConfig);
|
|
2282
2980
|
const taxonomyApi = createTaxonomyApi(apiConfig);
|
|
2283
2981
|
const emailTemplateApi = createEmailTemplateApi(apiConfig);
|
|
2284
2982
|
const analyticsApi = createAnalyticsApi(apiConfig);
|
|
2983
|
+
const experimentsApi = createExperimentsApi(apiConfig);
|
|
2285
2984
|
const sdk = {
|
|
2286
|
-
|
|
2287
|
-
|
|
2985
|
+
account: {
|
|
2986
|
+
update: accountApi.updateAccount,
|
|
2987
|
+
delete: accountApi.deleteAccount,
|
|
2988
|
+
getMe: accountApi.getMe,
|
|
2989
|
+
search: accountApi.searchAccounts,
|
|
2990
|
+
auth: authApi
|
|
2991
|
+
},
|
|
2288
2992
|
store: {
|
|
2289
|
-
|
|
2993
|
+
create: storeApi.createStore,
|
|
2994
|
+
update: storeApi.updateStore,
|
|
2995
|
+
delete: storeApi.deleteStore,
|
|
2996
|
+
get: storeApi.getStore,
|
|
2997
|
+
find: storeApi.getStores,
|
|
2998
|
+
subscription: {
|
|
2999
|
+
getPlans: storeApi.getSubscriptionPlans,
|
|
3000
|
+
subscribe: storeApi.subscribe,
|
|
3001
|
+
createPortalSession: storeApi.createPortalSession
|
|
3002
|
+
},
|
|
3003
|
+
member: {
|
|
3004
|
+
add: storeApi.addMember,
|
|
3005
|
+
invite: storeApi.inviteUser,
|
|
3006
|
+
remove: storeApi.removeMember
|
|
3007
|
+
},
|
|
3008
|
+
buildHook: {
|
|
3009
|
+
list: storeApi.listBuildHooks,
|
|
3010
|
+
create: storeApi.createBuildHook,
|
|
3011
|
+
update: storeApi.updateBuildHook,
|
|
3012
|
+
delete: storeApi.deleteBuildHook
|
|
3013
|
+
},
|
|
3014
|
+
webhook: {
|
|
3015
|
+
test: storeApi.testWebhook,
|
|
3016
|
+
list: storeApi.listWebhooks,
|
|
3017
|
+
create: storeApi.createWebhook,
|
|
3018
|
+
update: storeApi.updateWebhook,
|
|
3019
|
+
delete: storeApi.deleteWebhook
|
|
3020
|
+
},
|
|
3021
|
+
config: {
|
|
3022
|
+
get: storeApi.getStoreConfig
|
|
3023
|
+
},
|
|
3024
|
+
media: {
|
|
3025
|
+
find: storeApi.getStoreMedia
|
|
3026
|
+
},
|
|
2290
3027
|
location: locationApi,
|
|
2291
|
-
market: marketApi
|
|
3028
|
+
market: marketApi,
|
|
3029
|
+
paymentProvider: storePaymentProviderApi
|
|
2292
3030
|
},
|
|
2293
3031
|
media: createMediaApi(apiConfig),
|
|
2294
|
-
notification:
|
|
2295
|
-
|
|
3032
|
+
notification: {
|
|
3033
|
+
email: {
|
|
3034
|
+
trackOpen: notificationApi.trackEmailOpen
|
|
3035
|
+
},
|
|
3036
|
+
trigger: {
|
|
3037
|
+
send: notificationApi.trigger
|
|
3038
|
+
},
|
|
3039
|
+
mailbox: crmApi.mailbox
|
|
3040
|
+
},
|
|
2296
3041
|
platform: platformApi,
|
|
2297
|
-
|
|
3042
|
+
social: {
|
|
3043
|
+
account: {
|
|
3044
|
+
getCapabilities: socialApi.getCapabilities,
|
|
3045
|
+
list: socialApi.listAccounts,
|
|
3046
|
+
connect: socialApi.connect,
|
|
3047
|
+
getOAuthAttempt: socialApi.getOAuthAttempt,
|
|
3048
|
+
selectDestination: socialApi.selectDestination,
|
|
3049
|
+
delete: socialApi.deleteAccount
|
|
3050
|
+
},
|
|
3051
|
+
publication: {
|
|
3052
|
+
create: socialApi.createPublication,
|
|
3053
|
+
update: socialApi.updatePublication,
|
|
3054
|
+
get: socialApi.getPublication,
|
|
3055
|
+
find: socialApi.findPublications,
|
|
3056
|
+
validate: socialApi.validatePublication,
|
|
3057
|
+
schedule: socialApi.schedulePublication,
|
|
3058
|
+
cancel: socialApi.cancelPublication,
|
|
3059
|
+
getComments: socialApi.getPublicationComments,
|
|
3060
|
+
syncComments: socialApi.syncPublicationComments,
|
|
3061
|
+
getCommentThread: socialApi.getPublicationCommentThread,
|
|
3062
|
+
syncCommentThread: socialApi.syncPublicationCommentThread,
|
|
3063
|
+
findComments: socialApi.findPublicationComments,
|
|
3064
|
+
classifyComments: socialApi.classifyPublicationComments,
|
|
3065
|
+
replyToComment: socialApi.replyToPublicationComment,
|
|
3066
|
+
getMetrics: socialApi.getPublicationMetrics,
|
|
3067
|
+
syncMetrics: socialApi.syncPublicationMetrics,
|
|
3068
|
+
syncEngagement: socialApi.syncEngagement
|
|
3069
|
+
}
|
|
3070
|
+
},
|
|
2298
3071
|
cms: {
|
|
2299
|
-
|
|
2300
|
-
create: cmsApi.
|
|
2301
|
-
update: cmsApi.
|
|
2302
|
-
delete: cmsApi.
|
|
2303
|
-
get: cmsApi.
|
|
2304
|
-
find: cmsApi.
|
|
2305
|
-
|
|
3072
|
+
collection: {
|
|
3073
|
+
create: cmsApi.createCollection,
|
|
3074
|
+
update: cmsApi.updateCollection,
|
|
3075
|
+
delete: cmsApi.deleteCollection,
|
|
3076
|
+
get: cmsApi.getCollection,
|
|
3077
|
+
find: cmsApi.getCollections
|
|
3078
|
+
},
|
|
3079
|
+
entry: {
|
|
3080
|
+
create: cmsApi.createEntry,
|
|
3081
|
+
update: cmsApi.updateEntry,
|
|
3082
|
+
delete: cmsApi.deleteEntry,
|
|
3083
|
+
get: cmsApi.getEntry,
|
|
3084
|
+
find: cmsApi.getEntries
|
|
2306
3085
|
},
|
|
2307
3086
|
form: {
|
|
2308
3087
|
create: formApi.createForm,
|
|
@@ -2328,7 +3107,8 @@ function createAdmin(config) {
|
|
|
2328
3107
|
update: emailTemplateApi.updateEmailTemplate,
|
|
2329
3108
|
delete: emailTemplateApi.deleteEmailTemplate,
|
|
2330
3109
|
get: emailTemplateApi.getEmailTemplate,
|
|
2331
|
-
find: emailTemplateApi.getEmailTemplates
|
|
3110
|
+
find: emailTemplateApi.getEmailTemplates,
|
|
3111
|
+
preview: emailTemplateApi.previewEmailTemplate
|
|
2332
3112
|
}
|
|
2333
3113
|
},
|
|
2334
3114
|
eshop: {
|
|
@@ -2344,7 +3124,10 @@ function createAdmin(config) {
|
|
|
2344
3124
|
get: eshopApi.getOrder,
|
|
2345
3125
|
find: eshopApi.getOrders,
|
|
2346
3126
|
getQuote: eshopApi.getQuote,
|
|
2347
|
-
processRefund: eshopApi.processRefund
|
|
3127
|
+
processRefund: eshopApi.processRefund,
|
|
3128
|
+
downloadDigitalAccess: eshopApi.downloadDigitalAccess,
|
|
3129
|
+
getShippingRates: shippingApi.getRates,
|
|
3130
|
+
ship: shippingApi.ship
|
|
2348
3131
|
},
|
|
2349
3132
|
cart: {
|
|
2350
3133
|
create: eshopApi.createCart,
|
|
@@ -2379,53 +3162,55 @@ function createAdmin(config) {
|
|
|
2379
3162
|
promoCode: promoCodeApi
|
|
2380
3163
|
},
|
|
2381
3164
|
crm: {
|
|
2382
|
-
|
|
3165
|
+
contact: {
|
|
2383
3166
|
create: crmApi.create,
|
|
2384
3167
|
get: crmApi.get,
|
|
2385
3168
|
find: crmApi.find,
|
|
2386
3169
|
update: crmApi.update,
|
|
2387
3170
|
merge: crmApi.merge,
|
|
3171
|
+
import: crmApi.import,
|
|
2388
3172
|
revokeToken: crmApi.revokeToken,
|
|
2389
3173
|
revokeAllTokens: crmApi.revokeAllTokens
|
|
2390
3174
|
},
|
|
2391
|
-
|
|
2392
|
-
create: crmApi.
|
|
2393
|
-
update: crmApi.
|
|
2394
|
-
get: crmApi.
|
|
2395
|
-
find: crmApi.
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
3175
|
+
contactList: {
|
|
3176
|
+
create: crmApi.contactList.create,
|
|
3177
|
+
update: crmApi.contactList.update,
|
|
3178
|
+
get: crmApi.contactList.get,
|
|
3179
|
+
find: crmApi.contactList.find,
|
|
3180
|
+
importContacts: crmApi.contactList.importContacts,
|
|
3181
|
+
previewImportContacts: crmApi.contactList.previewImportContacts,
|
|
3182
|
+
addMember: crmApi.contactList.members.add,
|
|
3183
|
+
updateMember: crmApi.contactList.members.update,
|
|
3184
|
+
removeMember: crmApi.contactList.members.remove,
|
|
3185
|
+
findMembers: crmApi.contactList.members.find
|
|
2399
3186
|
},
|
|
2400
|
-
|
|
3187
|
+
action: crmApi.action
|
|
3188
|
+
},
|
|
3189
|
+
outreach: {
|
|
3190
|
+
campaign: crmApi.campaign,
|
|
3191
|
+
campaignEnrollment: crmApi.campaignEnrollment,
|
|
3192
|
+
campaignMessage: crmApi.campaignMessage,
|
|
3193
|
+
suppression: crmApi.suppression,
|
|
3194
|
+
leadResearch: leadResearchApi
|
|
2401
3195
|
},
|
|
2402
3196
|
automation: {
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
},
|
|
2417
|
-
workflow: {
|
|
2418
|
-
create: workflowApi.createWorkflow,
|
|
2419
|
-
update: workflowApi.updateWorkflow,
|
|
2420
|
-
delete: workflowApi.deleteWorkflow,
|
|
2421
|
-
get: workflowApi.getWorkflow,
|
|
2422
|
-
find: workflowApi.getWorkflows,
|
|
2423
|
-
trigger: workflowApi.triggerWorkflow,
|
|
2424
|
-
getExecutions: workflowApi.getWorkflowExecutions,
|
|
2425
|
-
getExecution: workflowApi.getWorkflowExecution
|
|
3197
|
+
workflow: workflowPublicApi,
|
|
3198
|
+
support: {
|
|
3199
|
+
createAgent: supportApi.agent.create,
|
|
3200
|
+
getAgent: supportApi.agent.get,
|
|
3201
|
+
findAgents: supportApi.agent.find,
|
|
3202
|
+
updateAgent: supportApi.agent.update,
|
|
3203
|
+
deleteAgent: supportApi.agent.delete,
|
|
3204
|
+
findConversations: supportApi.conversation.find,
|
|
3205
|
+
getConversation: supportApi.conversation.get,
|
|
3206
|
+
sendConversationMessage: supportApi.conversation.sendMessage,
|
|
3207
|
+
replyToConversation: supportApi.conversation.reply,
|
|
3208
|
+
resolveConversation: supportApi.conversation.resolve,
|
|
3209
|
+
assignConversation: supportApi.conversation.assign
|
|
2426
3210
|
}
|
|
2427
3211
|
},
|
|
2428
3212
|
analytics: analyticsApi,
|
|
3213
|
+
experiments: experimentsApi,
|
|
2429
3214
|
setStoreId: (storeId) => {
|
|
2430
3215
|
apiConfig.storeId = storeId;
|
|
2431
3216
|
},
|
|
@@ -2461,7 +3246,6 @@ function createAdmin(config) {
|
|
|
2461
3246
|
if (config.apiToken) return;
|
|
2462
3247
|
updateSession(() => null);
|
|
2463
3248
|
},
|
|
2464
|
-
extractBlockValues,
|
|
2465
3249
|
utils: createUtilitySurface(apiConfig)
|
|
2466
3250
|
};
|
|
2467
3251
|
return sdk;
|