arky-sdk 0.9.6 → 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-DjYydKeB.d.ts → admin-BKXmDIVk.d.ts} +412 -405
- package/dist/{admin-DlL8mCxL.d.cts → admin-CAwQrMOX.d.cts} +412 -405
- package/dist/admin.cjs +767 -373
- 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 +767 -373
- package/dist/admin.js.map +1 -1
- package/dist/{api-BbBHcd4p.d.cts → api-DJI3S6XA.d.cts} +1440 -525
- package/dist/{api-BbBHcd4p.d.ts → api-DJI3S6XA.d.ts} +1440 -525
- package/dist/{index-CZxubTDA.d.ts → index-BaSBPLdF.d.ts} +1 -1
- package/dist/{index-nCF3Z6Af.d.cts → index-u-gjHnKs.d.cts} +1 -1
- package/dist/index.cjs +874 -471
- 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 +874 -471
- package/dist/index.js.map +1 -1
- package/dist/storefront.cjs +493 -300
- package/dist/storefront.cjs.map +1 -1
- package/dist/storefront.d.cts +172 -89
- package/dist/storefront.d.ts +172 -89
- package/dist/storefront.js +491 -299
- 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.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +7 -10
- package/scripts/contract-admin.mjs +137 -0
- package/scripts/contract-storefront.mjs +296 -0
- package/dist/storefront-store.cjs +0 -2809
- 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 -2807
- package/dist/storefront-store.js.map +0 -1
- package/scripts/smoke-store.mjs +0 -41
package/dist/admin.cjs
CHANGED
|
@@ -1,131 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/utils/blocks.ts
|
|
4
|
-
function getBlockLabel(block) {
|
|
5
|
-
if (!block) return "";
|
|
6
|
-
return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) ?? "";
|
|
7
|
-
}
|
|
8
|
-
function formatBlockValue(block) {
|
|
9
|
-
if (!block || block.value === null || block.value === void 0) return "";
|
|
10
|
-
const value = block.value;
|
|
11
|
-
switch (block.type) {
|
|
12
|
-
case "boolean":
|
|
13
|
-
return value ? "Yes" : "No";
|
|
14
|
-
case "number":
|
|
15
|
-
if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
|
|
16
|
-
return new Date(value).toLocaleDateString();
|
|
17
|
-
}
|
|
18
|
-
return String(value);
|
|
19
|
-
case "relationship_entry":
|
|
20
|
-
case "relationship_media":
|
|
21
|
-
if (value && typeof value === "object") {
|
|
22
|
-
return value.mime_type ? value.name || value.id : value.title || value.name || value.id;
|
|
23
|
-
}
|
|
24
|
-
return String(value);
|
|
25
|
-
default:
|
|
26
|
-
return String(value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function prepareBlocksForSubmission(formData, blockTypes) {
|
|
30
|
-
return Object.keys(formData).filter((key) => formData[key] !== null && formData[key] !== void 0).map((key) => ({
|
|
31
|
-
key,
|
|
32
|
-
value: blockTypes?.[key] === "list" && !Array.isArray(formData[key]) ? [formData[key]] : formData[key]
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
function extractBlockValues(blocks) {
|
|
36
|
-
const values = {};
|
|
37
|
-
blocks.forEach((block) => {
|
|
38
|
-
values[block.key] = block.value ?? null;
|
|
39
|
-
});
|
|
40
|
-
return values;
|
|
41
|
-
}
|
|
42
|
-
var getBlockValue = (entry, blockKey) => {
|
|
43
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
44
|
-
return block?.value ?? null;
|
|
45
|
-
};
|
|
46
|
-
var getBlockTextValue = (block, locale = "en") => {
|
|
47
|
-
if (!block || block.value === null || block.value === void 0) return "";
|
|
48
|
-
if (block.type === "localized_text" || block.type === "markdown") {
|
|
49
|
-
if (typeof block.value === "object" && block.value !== null) {
|
|
50
|
-
return block.value[locale] ?? block.value["en"] ?? "";
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (typeof block.value === "string") return block.value;
|
|
54
|
-
return String(block.value ?? "");
|
|
55
|
-
};
|
|
56
|
-
var getBlockValues = (entry, blockKey) => {
|
|
57
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
58
|
-
if (!block) return [];
|
|
59
|
-
if (block.type === "list" && Array.isArray(block.value)) {
|
|
60
|
-
return block.value;
|
|
61
|
-
}
|
|
62
|
-
return [];
|
|
63
|
-
};
|
|
64
|
-
function unwrapBlock(block, locale) {
|
|
65
|
-
if (!block?.type || block.value === void 0) return block;
|
|
66
|
-
if (block.type === "list") {
|
|
67
|
-
return block.value.map((obj) => {
|
|
68
|
-
const parsed = {};
|
|
69
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
70
|
-
parsed[k] = unwrapBlock(v, locale);
|
|
71
|
-
}
|
|
72
|
-
return parsed;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (block.type === "map") {
|
|
76
|
-
const parsed = {};
|
|
77
|
-
for (const [k, v] of Object.entries(block.value || {})) {
|
|
78
|
-
parsed[k] = unwrapBlock(v, locale);
|
|
79
|
-
}
|
|
80
|
-
return parsed;
|
|
81
|
-
}
|
|
82
|
-
if (block.type === "localized_text" || block.type === "markdown") {
|
|
83
|
-
return block.value?.[locale];
|
|
84
|
-
}
|
|
85
|
-
return block.value;
|
|
86
|
-
}
|
|
87
|
-
var getBlockObjectValues = (entry, blockKey, locale = "en") => {
|
|
88
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
89
|
-
if (!block || block.type !== "list" || !Array.isArray(block.value)) return [];
|
|
90
|
-
return block.value.map((obj) => {
|
|
91
|
-
if (!obj?.value || !Array.isArray(obj.value)) return {};
|
|
92
|
-
return obj.value.reduce((acc, current) => {
|
|
93
|
-
acc[current.key] = unwrapBlock(current, locale);
|
|
94
|
-
return acc;
|
|
95
|
-
}, {});
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
var getBlockFromArray = (entry, blockKey, locale = "en") => {
|
|
99
|
-
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
100
|
-
if (!block) return {};
|
|
101
|
-
if (block.type === "list" && Array.isArray(block.value)) {
|
|
102
|
-
return block.value.reduce((acc, current) => {
|
|
103
|
-
acc[current.key] = unwrapBlock(current, locale);
|
|
104
|
-
return acc;
|
|
105
|
-
}, {});
|
|
106
|
-
}
|
|
107
|
-
if (block.type === "map" && block.value && typeof block.value === "object") {
|
|
108
|
-
const result = {};
|
|
109
|
-
for (const [k, v] of Object.entries(block.value)) {
|
|
110
|
-
result[k] = unwrapBlock(v, locale);
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
return { [block.key]: unwrapBlock(block, locale) };
|
|
115
|
-
};
|
|
116
|
-
var getImageUrl = (imageBlock, isBlock = true) => {
|
|
117
|
-
if (!imageBlock) return null;
|
|
118
|
-
if (imageBlock.type === "relationship_media") {
|
|
119
|
-
const mediaValue = imageBlock.value;
|
|
120
|
-
return mediaValue?.resolutions?.original?.url || mediaValue?.url || null;
|
|
121
|
-
}
|
|
122
|
-
if (isBlock) {
|
|
123
|
-
if (typeof imageBlock === "string") return imageBlock;
|
|
124
|
-
if (imageBlock.url) return imageBlock.url;
|
|
125
|
-
}
|
|
126
|
-
return imageBlock.resolutions?.original?.url || null;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
3
|
// src/utils/orderItems.ts
|
|
130
4
|
function normalizeOrderQuoteItems(items) {
|
|
131
5
|
return items.map((item) => {
|
|
@@ -247,7 +121,7 @@ function createHttpClient(cfg) {
|
|
|
247
121
|
headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
248
122
|
}
|
|
249
123
|
const finalPath = options?.params ? path + buildQueryString(options.params) : path;
|
|
250
|
-
const fetchOpts = { method, headers };
|
|
124
|
+
const fetchOpts = { method, headers, signal: options?.signal };
|
|
251
125
|
if (!["GET", "DELETE"].includes(method) && body !== void 0) {
|
|
252
126
|
fetchOpts.body = JSON.stringify(body);
|
|
253
127
|
}
|
|
@@ -258,13 +132,15 @@ function createHttpClient(cfg) {
|
|
|
258
132
|
try {
|
|
259
133
|
res = await fetch(fullUrl, fetchOpts);
|
|
260
134
|
} catch (error) {
|
|
135
|
+
const aborted = options?.signal?.aborted || error instanceof Error && error.name === "AbortError";
|
|
261
136
|
const err = new Error(error instanceof Error ? error.message : "Network request failed");
|
|
262
|
-
err.name = "NetworkError";
|
|
137
|
+
err.name = aborted ? "AbortError" : "NetworkError";
|
|
263
138
|
err.method = method;
|
|
264
139
|
err.url = fullUrl;
|
|
140
|
+
err.aborted = aborted;
|
|
265
141
|
if (options?.onError && method !== "GET") {
|
|
266
142
|
Promise.resolve(
|
|
267
|
-
options.onError({ error: err, method, url: fullUrl, aborted
|
|
143
|
+
options.onError({ error: err, method, url: fullUrl, aborted })
|
|
268
144
|
).catch(() => {
|
|
269
145
|
});
|
|
270
146
|
}
|
|
@@ -427,9 +303,6 @@ var createAuthApi = (apiConfig, updateSession) => {
|
|
|
427
303
|
applyAuthToken(result, params.email);
|
|
428
304
|
}
|
|
429
305
|
return result;
|
|
430
|
-
},
|
|
431
|
-
async magicLink(params, options) {
|
|
432
|
-
return apiConfig.httpClient.post("/v1/auth/code", params, options);
|
|
433
306
|
}
|
|
434
307
|
};
|
|
435
308
|
};
|
|
@@ -466,14 +339,17 @@ var createStoreApi = (apiConfig, _updateSession) => {
|
|
|
466
339
|
});
|
|
467
340
|
},
|
|
468
341
|
async getSubscriptionPlans(_params, options) {
|
|
469
|
-
return apiConfig.httpClient.get(
|
|
342
|
+
return apiConfig.httpClient.get(
|
|
343
|
+
"/v1/stores/plans",
|
|
344
|
+
options
|
|
345
|
+
);
|
|
470
346
|
},
|
|
471
347
|
async subscribe(params, options) {
|
|
472
|
-
const { store_id, plan_id, success_url, cancel_url } = params;
|
|
348
|
+
const { store_id, plan_id, action, success_url, cancel_url } = params;
|
|
473
349
|
const target_store_id = store_id || apiConfig.storeId;
|
|
474
350
|
return apiConfig.httpClient.put(
|
|
475
351
|
`/v1/stores/${target_store_id}/subscribe`,
|
|
476
|
-
{ plan_id, success_url, cancel_url },
|
|
352
|
+
{ plan_id, action, success_url, cancel_url },
|
|
477
353
|
options
|
|
478
354
|
);
|
|
479
355
|
},
|
|
@@ -519,61 +395,52 @@ var createStoreApi = (apiConfig, _updateSession) => {
|
|
|
519
395
|
limit: params.limit
|
|
520
396
|
};
|
|
521
397
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
522
|
-
if (params.ids && params.ids.length > 0)
|
|
398
|
+
if (params.ids && params.ids.length > 0)
|
|
399
|
+
queryParams.ids = JSON.stringify(params.ids);
|
|
523
400
|
if (params.query) queryParams.query = params.query;
|
|
524
401
|
if (params.mime_type) queryParams.mime_type = params.mime_type;
|
|
525
402
|
if (params.sort_field) queryParams.sort_field = params.sort_field;
|
|
526
|
-
if (params.sort_direction)
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
params
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
`/v1/stores/${params.store_id}/oauth/connect`,
|
|
535
|
-
{ provider: params.provider, code: params.code, redirect_uri: params.redirect_uri },
|
|
536
|
-
options
|
|
537
|
-
);
|
|
538
|
-
},
|
|
539
|
-
async oauthDisconnect(params, options) {
|
|
540
|
-
return apiConfig.httpClient.post(
|
|
541
|
-
`/v1/stores/${params.store_id}/oauth/disconnect`,
|
|
542
|
-
{ provider: params.provider },
|
|
543
|
-
options
|
|
403
|
+
if (params.sort_direction)
|
|
404
|
+
queryParams.sort_direction = params.sort_direction;
|
|
405
|
+
return apiConfig.httpClient.get(
|
|
406
|
+
`/v1/stores/${params.id}/media`,
|
|
407
|
+
{
|
|
408
|
+
...options,
|
|
409
|
+
params: queryParams
|
|
410
|
+
}
|
|
544
411
|
);
|
|
545
412
|
},
|
|
546
|
-
async
|
|
413
|
+
async listBuildHooks(params, options) {
|
|
547
414
|
return apiConfig.httpClient.get(
|
|
548
|
-
`/v1/stores/${params.store_id}/
|
|
415
|
+
`/v1/stores/${params.store_id}/build-hooks`,
|
|
549
416
|
options
|
|
550
417
|
);
|
|
551
418
|
},
|
|
552
|
-
async
|
|
419
|
+
async createBuildHook(params, options) {
|
|
553
420
|
const { store_id, ...payload } = params;
|
|
554
421
|
return apiConfig.httpClient.post(
|
|
555
|
-
`/v1/stores/${store_id}/
|
|
422
|
+
`/v1/stores/${store_id}/build-hooks`,
|
|
556
423
|
payload,
|
|
557
424
|
options
|
|
558
425
|
);
|
|
559
426
|
},
|
|
560
|
-
async
|
|
427
|
+
async updateBuildHook(params, options) {
|
|
561
428
|
const { store_id, id, ...payload } = params;
|
|
562
429
|
return apiConfig.httpClient.put(
|
|
563
|
-
`/v1/stores/${store_id}/
|
|
430
|
+
`/v1/stores/${store_id}/build-hooks/${id}`,
|
|
564
431
|
payload,
|
|
565
432
|
options
|
|
566
433
|
);
|
|
567
434
|
},
|
|
568
|
-
async
|
|
435
|
+
async deleteBuildHook(params, options) {
|
|
569
436
|
return apiConfig.httpClient.delete(
|
|
570
|
-
`/v1/stores/${params.store_id}/
|
|
437
|
+
`/v1/stores/${params.store_id}/build-hooks/${params.id}`,
|
|
571
438
|
options
|
|
572
439
|
);
|
|
573
440
|
},
|
|
574
|
-
async
|
|
441
|
+
async getStoreConfig(params, options) {
|
|
575
442
|
return apiConfig.httpClient.get(
|
|
576
|
-
`/v1/stores/${params.store_id}/
|
|
443
|
+
`/v1/stores/${params.store_id}/config/${params.type}`,
|
|
577
444
|
options
|
|
578
445
|
);
|
|
579
446
|
},
|
|
@@ -618,7 +485,7 @@ var createMediaApi = (apiConfig) => {
|
|
|
618
485
|
options
|
|
619
486
|
);
|
|
620
487
|
},
|
|
621
|
-
async uploadStoreMedia(params,
|
|
488
|
+
async uploadStoreMedia(params, options) {
|
|
622
489
|
const { store_id, files = [], urls = [] } = params;
|
|
623
490
|
const target_store_id = store_id || apiConfig.storeId;
|
|
624
491
|
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
@@ -631,7 +498,8 @@ var createMediaApi = (apiConfig) => {
|
|
|
631
498
|
body: formData,
|
|
632
499
|
headers: {
|
|
633
500
|
Authorization: `Bearer ${tokens?.access_token || ""}`
|
|
634
|
-
}
|
|
501
|
+
},
|
|
502
|
+
signal: options?.signal
|
|
635
503
|
});
|
|
636
504
|
if (!response.ok) {
|
|
637
505
|
throw new Error("Upload failed, server said no");
|
|
@@ -645,7 +513,7 @@ var createMediaApi = (apiConfig) => {
|
|
|
645
513
|
options
|
|
646
514
|
);
|
|
647
515
|
},
|
|
648
|
-
async getStoreMedia(params,
|
|
516
|
+
async getStoreMedia(params, options) {
|
|
649
517
|
const { store_id, cursor, limit, ids, query, mime_type, sort_field, sort_direction } = params;
|
|
650
518
|
const target_store_id = store_id || apiConfig.storeId;
|
|
651
519
|
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
@@ -661,7 +529,8 @@ var createMediaApi = (apiConfig) => {
|
|
|
661
529
|
const response = await fetch(`${url}?${queryString}`, {
|
|
662
530
|
headers: {
|
|
663
531
|
Authorization: `Bearer ${tokens?.access_token || ""}`
|
|
664
|
-
}
|
|
532
|
+
},
|
|
533
|
+
signal: options?.signal
|
|
665
534
|
});
|
|
666
535
|
if (!response.ok) {
|
|
667
536
|
const errorData = await response.json().catch(() => null);
|
|
@@ -749,77 +618,97 @@ var createPromoCodeApi = (apiConfig) => {
|
|
|
749
618
|
// src/api/cms.ts
|
|
750
619
|
var createCmsApi = (apiConfig) => {
|
|
751
620
|
return {
|
|
752
|
-
async
|
|
621
|
+
async createCollection(params, options) {
|
|
753
622
|
const { store_id, ...payload } = params;
|
|
754
623
|
const target_store_id = store_id || apiConfig.storeId;
|
|
755
624
|
return apiConfig.httpClient.post(
|
|
756
|
-
`/v1/stores/${target_store_id}/
|
|
625
|
+
`/v1/stores/${target_store_id}/collections`,
|
|
757
626
|
payload,
|
|
758
627
|
options
|
|
759
628
|
);
|
|
760
629
|
},
|
|
761
|
-
async
|
|
630
|
+
async updateCollection(params, options) {
|
|
762
631
|
const { store_id, ...payload } = params;
|
|
763
632
|
const target_store_id = store_id || apiConfig.storeId;
|
|
764
633
|
return apiConfig.httpClient.put(
|
|
765
|
-
`/v1/stores/${target_store_id}/
|
|
634
|
+
`/v1/stores/${target_store_id}/collections/${params.id}`,
|
|
766
635
|
payload,
|
|
767
636
|
options
|
|
768
637
|
);
|
|
769
638
|
},
|
|
770
|
-
async
|
|
639
|
+
async deleteCollection(params, options) {
|
|
771
640
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
772
641
|
return apiConfig.httpClient.delete(
|
|
773
|
-
`/v1/stores/${target_store_id}/
|
|
642
|
+
`/v1/stores/${target_store_id}/collections/${params.id}`,
|
|
774
643
|
options
|
|
775
644
|
);
|
|
776
645
|
},
|
|
777
|
-
async
|
|
646
|
+
async getCollection(params, options) {
|
|
778
647
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
779
648
|
let identifier;
|
|
780
649
|
if (params.id) {
|
|
781
650
|
identifier = params.id;
|
|
782
|
-
} else if (params.slug) {
|
|
783
|
-
identifier = `${target_store_id}:${apiConfig.locale}:${params.slug}`;
|
|
784
651
|
} else if (params.key) {
|
|
785
652
|
identifier = `${target_store_id}:${params.key}`;
|
|
786
653
|
} else {
|
|
787
|
-
throw new Error("
|
|
654
|
+
throw new Error("GetCollectionParams requires id or key");
|
|
788
655
|
}
|
|
789
|
-
|
|
790
|
-
`/v1/stores/${target_store_id}/
|
|
656
|
+
return apiConfig.httpClient.get(
|
|
657
|
+
`/v1/stores/${target_store_id}/collections/${identifier}`,
|
|
791
658
|
options
|
|
792
659
|
);
|
|
793
|
-
return {
|
|
794
|
-
...response,
|
|
795
|
-
getBlock(key) {
|
|
796
|
-
return getBlockFromArray(response, key, apiConfig.locale);
|
|
797
|
-
},
|
|
798
|
-
getBlockValues(key) {
|
|
799
|
-
return getBlockObjectValues(response, key, apiConfig.locale);
|
|
800
|
-
},
|
|
801
|
-
getImage(key) {
|
|
802
|
-
const block = getBlockFromArray(response, key, apiConfig.locale);
|
|
803
|
-
return getImageUrl(block, true);
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
660
|
},
|
|
807
|
-
async
|
|
661
|
+
async getCollections(params = {}, options) {
|
|
808
662
|
const { store_id, ...queryParams } = params;
|
|
809
663
|
const target_store_id = store_id || apiConfig.storeId;
|
|
810
664
|
return apiConfig.httpClient.get(
|
|
811
|
-
`/v1/stores/${target_store_id}/
|
|
665
|
+
`/v1/stores/${target_store_id}/collections`,
|
|
812
666
|
{
|
|
813
667
|
...options,
|
|
814
668
|
params: queryParams
|
|
815
669
|
}
|
|
816
670
|
);
|
|
817
671
|
},
|
|
818
|
-
async
|
|
819
|
-
const {
|
|
672
|
+
async createEntry(params, options) {
|
|
673
|
+
const { store_id, ...payload } = params;
|
|
674
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
675
|
+
return apiConfig.httpClient.post(
|
|
676
|
+
`/v1/stores/${target_store_id}/entries`,
|
|
677
|
+
payload,
|
|
678
|
+
options
|
|
679
|
+
);
|
|
680
|
+
},
|
|
681
|
+
async updateEntry(params, options) {
|
|
682
|
+
const { store_id, ...payload } = params;
|
|
683
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
684
|
+
return apiConfig.httpClient.put(
|
|
685
|
+
`/v1/stores/${target_store_id}/entries/${params.id}`,
|
|
686
|
+
payload,
|
|
687
|
+
options
|
|
688
|
+
);
|
|
689
|
+
},
|
|
690
|
+
async deleteEntry(params, options) {
|
|
691
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
692
|
+
return apiConfig.httpClient.delete(
|
|
693
|
+
`/v1/stores/${target_store_id}/entries/${params.id}`,
|
|
694
|
+
options
|
|
695
|
+
);
|
|
696
|
+
},
|
|
697
|
+
async getEntry(params, options) {
|
|
698
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
699
|
+
if (!params.id) {
|
|
700
|
+
throw new Error("GetEntryParams requires id");
|
|
701
|
+
}
|
|
702
|
+
return apiConfig.httpClient.get(
|
|
703
|
+
`/v1/stores/${target_store_id}/entries/${params.id}`,
|
|
704
|
+
options
|
|
705
|
+
);
|
|
706
|
+
},
|
|
707
|
+
async getEntries(params, options) {
|
|
708
|
+
const { store_id, ...queryParams } = params;
|
|
820
709
|
const target_store_id = store_id || apiConfig.storeId;
|
|
821
710
|
return apiConfig.httpClient.get(
|
|
822
|
-
`/v1/stores/${target_store_id}/
|
|
711
|
+
`/v1/stores/${target_store_id}/entries`,
|
|
823
712
|
{
|
|
824
713
|
...options,
|
|
825
714
|
params: queryParams
|
|
@@ -830,13 +719,6 @@ var createCmsApi = (apiConfig) => {
|
|
|
830
719
|
};
|
|
831
720
|
|
|
832
721
|
// src/api/eshop.ts
|
|
833
|
-
var normalizeTaxonomyAliases = (payload) => {
|
|
834
|
-
const { filters, ...rest } = payload;
|
|
835
|
-
return {
|
|
836
|
-
...rest,
|
|
837
|
-
...!rest.taxonomies && filters ? { taxonomies: filters } : {}
|
|
838
|
-
};
|
|
839
|
-
};
|
|
840
722
|
var createEshopApi = (apiConfig) => {
|
|
841
723
|
return {
|
|
842
724
|
async createProduct(params, options) {
|
|
@@ -844,7 +726,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
844
726
|
const target_store_id = store_id || apiConfig.storeId;
|
|
845
727
|
return apiConfig.httpClient.post(
|
|
846
728
|
`/v1/stores/${target_store_id}/products`,
|
|
847
|
-
|
|
729
|
+
payload,
|
|
848
730
|
options
|
|
849
731
|
);
|
|
850
732
|
},
|
|
@@ -853,7 +735,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
853
735
|
const target_store_id = store_id || apiConfig.storeId;
|
|
854
736
|
return apiConfig.httpClient.put(
|
|
855
737
|
`/v1/stores/${target_store_id}/products/${params.id}`,
|
|
856
|
-
|
|
738
|
+
payload,
|
|
857
739
|
options
|
|
858
740
|
);
|
|
859
741
|
},
|
|
@@ -895,7 +777,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
895
777
|
const target_store_id = store_id || apiConfig.storeId;
|
|
896
778
|
return apiConfig.httpClient.post(
|
|
897
779
|
`/v1/stores/${target_store_id}/services`,
|
|
898
|
-
|
|
780
|
+
payload,
|
|
899
781
|
options
|
|
900
782
|
);
|
|
901
783
|
},
|
|
@@ -904,7 +786,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
904
786
|
const target_store_id = store_id || apiConfig.storeId;
|
|
905
787
|
return apiConfig.httpClient.put(
|
|
906
788
|
`/v1/stores/${target_store_id}/services/${params.id}`,
|
|
907
|
-
|
|
789
|
+
payload,
|
|
908
790
|
options
|
|
909
791
|
);
|
|
910
792
|
},
|
|
@@ -954,7 +836,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
954
836
|
const target_store_id = store_id || apiConfig.storeId;
|
|
955
837
|
return apiConfig.httpClient.post(
|
|
956
838
|
`/v1/stores/${target_store_id}/providers`,
|
|
957
|
-
|
|
839
|
+
payload,
|
|
958
840
|
options
|
|
959
841
|
);
|
|
960
842
|
},
|
|
@@ -963,7 +845,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
963
845
|
const target_store_id = store_id || apiConfig.storeId;
|
|
964
846
|
return apiConfig.httpClient.put(
|
|
965
847
|
`/v1/stores/${target_store_id}/providers/${params.id}`,
|
|
966
|
-
|
|
848
|
+
payload,
|
|
967
849
|
options
|
|
968
850
|
);
|
|
969
851
|
},
|
|
@@ -1178,6 +1060,14 @@ var createEshopApi = (apiConfig) => {
|
|
|
1178
1060
|
{ amount: params.amount },
|
|
1179
1061
|
options
|
|
1180
1062
|
);
|
|
1063
|
+
},
|
|
1064
|
+
async downloadDigitalAccess(params, options) {
|
|
1065
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1066
|
+
return apiConfig.httpClient.post(
|
|
1067
|
+
`/v1/stores/${target_store_id}/orders/${params.id}/digital-access/${params.grant_id}/download`,
|
|
1068
|
+
{},
|
|
1069
|
+
options
|
|
1070
|
+
);
|
|
1181
1071
|
}
|
|
1182
1072
|
};
|
|
1183
1073
|
};
|
|
@@ -1268,45 +1158,46 @@ var createMarketApi = (apiConfig) => {
|
|
|
1268
1158
|
};
|
|
1269
1159
|
|
|
1270
1160
|
// src/api/crm.ts
|
|
1271
|
-
var
|
|
1161
|
+
var createActionAdminApi = (apiConfig) => ({
|
|
1272
1162
|
async timeline(params, options) {
|
|
1273
1163
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1274
|
-
const queryParams = {
|
|
1164
|
+
const queryParams = { contact_id: params.contact_id };
|
|
1275
1165
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1276
1166
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1277
1167
|
return apiConfig.httpClient.get(
|
|
1278
|
-
`/v1/stores/${store_id}/
|
|
1168
|
+
`/v1/stores/${store_id}/contacts/${params.contact_id}/actions`,
|
|
1279
1169
|
{ ...options, params: queryParams }
|
|
1280
1170
|
);
|
|
1281
1171
|
},
|
|
1282
1172
|
async find(params, options) {
|
|
1283
1173
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1284
1174
|
const queryParams = {};
|
|
1285
|
-
if (params.
|
|
1175
|
+
if (params.query) queryParams.query = params.query;
|
|
1176
|
+
if (params.contact_id) queryParams.contact_id = params.contact_id;
|
|
1286
1177
|
if (params.types && params.types.length > 0) queryParams.types = params.types;
|
|
1287
1178
|
if (params.from !== void 0) queryParams.from = params.from;
|
|
1288
1179
|
if (params.to !== void 0) queryParams.to = params.to;
|
|
1289
1180
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1290
1181
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1291
1182
|
return apiConfig.httpClient.get(
|
|
1292
|
-
`/v1/stores/${store_id}/
|
|
1183
|
+
`/v1/stores/${store_id}/actions`,
|
|
1293
1184
|
{ ...options, params: queryParams }
|
|
1294
1185
|
);
|
|
1295
1186
|
}
|
|
1296
1187
|
});
|
|
1297
|
-
var
|
|
1188
|
+
var createContactApi = (apiConfig) => {
|
|
1298
1189
|
return {
|
|
1299
1190
|
async create(params, options) {
|
|
1300
1191
|
const { store_id, ...payload } = params;
|
|
1301
1192
|
return apiConfig.httpClient.post(
|
|
1302
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1193
|
+
`/v1/stores/${store_id || apiConfig.storeId}/contacts`,
|
|
1303
1194
|
payload,
|
|
1304
1195
|
options
|
|
1305
1196
|
);
|
|
1306
1197
|
},
|
|
1307
1198
|
async get(params, options) {
|
|
1308
1199
|
return apiConfig.httpClient.get(
|
|
1309
|
-
`/v1/stores/${params.store_id || apiConfig.storeId}/
|
|
1200
|
+
`/v1/stores/${params.store_id || apiConfig.storeId}/contacts/${params.id}`,
|
|
1310
1201
|
options
|
|
1311
1202
|
);
|
|
1312
1203
|
},
|
|
@@ -1319,22 +1210,32 @@ var createProfileApi = (apiConfig) => {
|
|
|
1319
1210
|
if (params?.query) queryParams.query = params.query;
|
|
1320
1211
|
if (params?.taxonomy_query) queryParams.taxonomy_query = params.taxonomy_query;
|
|
1321
1212
|
if (params?.status) queryParams.status = params.status;
|
|
1322
|
-
if (params?.
|
|
1213
|
+
if (params?.has_action !== void 0) queryParams.has_action = params.has_action;
|
|
1323
1214
|
if (params?.has_cart !== void 0) queryParams.has_cart = params.has_cart;
|
|
1324
1215
|
if (params?.sort_field) queryParams.sort_field = params.sort_field;
|
|
1325
1216
|
if (params?.sort_direction) queryParams.sort_direction = params.sort_direction;
|
|
1326
1217
|
return apiConfig.httpClient.get(
|
|
1327
|
-
`/v1/stores/${store_id}/
|
|
1218
|
+
`/v1/stores/${store_id}/contacts`,
|
|
1328
1219
|
{
|
|
1329
1220
|
...options,
|
|
1330
1221
|
params: queryParams
|
|
1331
1222
|
}
|
|
1332
1223
|
);
|
|
1333
1224
|
},
|
|
1225
|
+
async findActions(params, options) {
|
|
1226
|
+
const { store_id, ...queryParams } = params || {};
|
|
1227
|
+
return apiConfig.httpClient.get(
|
|
1228
|
+
`/v1/stores/${store_id || apiConfig.storeId}/actions`,
|
|
1229
|
+
{
|
|
1230
|
+
...options,
|
|
1231
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1232
|
+
}
|
|
1233
|
+
);
|
|
1234
|
+
},
|
|
1334
1235
|
async update(params, options) {
|
|
1335
1236
|
const { id, store_id, ...body } = params;
|
|
1336
1237
|
return apiConfig.httpClient.put(
|
|
1337
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1238
|
+
`/v1/stores/${store_id || apiConfig.storeId}/contacts/${id}`,
|
|
1338
1239
|
body,
|
|
1339
1240
|
options
|
|
1340
1241
|
);
|
|
@@ -1342,7 +1243,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1342
1243
|
async merge(params, options) {
|
|
1343
1244
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1344
1245
|
return apiConfig.httpClient.post(
|
|
1345
|
-
`/v1/stores/${store_id}/
|
|
1246
|
+
`/v1/stores/${store_id}/contacts/${params.target_id}/merge`,
|
|
1346
1247
|
{ source_id: params.source_id, store_id },
|
|
1347
1248
|
options
|
|
1348
1249
|
);
|
|
@@ -1351,7 +1252,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1351
1252
|
const { store_id, ...payload } = params;
|
|
1352
1253
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1353
1254
|
return apiConfig.httpClient.post(
|
|
1354
|
-
`/v1/stores/${target_store_id}/
|
|
1255
|
+
`/v1/stores/${target_store_id}/contacts/import`,
|
|
1355
1256
|
payload,
|
|
1356
1257
|
options
|
|
1357
1258
|
);
|
|
@@ -1360,7 +1261,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1360
1261
|
const { store_id, ...payload } = params;
|
|
1361
1262
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1362
1263
|
return apiConfig.httpClient.post(
|
|
1363
|
-
`/v1/stores/${target_store_id}/
|
|
1264
|
+
`/v1/stores/${target_store_id}/contacts/import/preview`,
|
|
1364
1265
|
payload,
|
|
1365
1266
|
options
|
|
1366
1267
|
);
|
|
@@ -1368,23 +1269,23 @@ var createProfileApi = (apiConfig) => {
|
|
|
1368
1269
|
async revokeToken(params, options) {
|
|
1369
1270
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1370
1271
|
return apiConfig.httpClient.delete(
|
|
1371
|
-
`/v1/stores/${store_id}/
|
|
1272
|
+
`/v1/stores/${store_id}/contacts/${params.id}/sessions/${params.token_id}`,
|
|
1372
1273
|
options
|
|
1373
1274
|
);
|
|
1374
1275
|
},
|
|
1375
1276
|
async revokeAllTokens(params, options) {
|
|
1376
1277
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1377
1278
|
return apiConfig.httpClient.delete(
|
|
1378
|
-
`/v1/stores/${store_id}/
|
|
1279
|
+
`/v1/stores/${store_id}/contacts/${params.id}/sessions`,
|
|
1379
1280
|
options
|
|
1380
1281
|
);
|
|
1381
1282
|
},
|
|
1382
|
-
|
|
1283
|
+
contactList: {
|
|
1383
1284
|
async create(params, options) {
|
|
1384
1285
|
const { store_id, ...payload } = params;
|
|
1385
1286
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1386
1287
|
return apiConfig.httpClient.post(
|
|
1387
|
-
`/v1/stores/${target_store_id}/
|
|
1288
|
+
`/v1/stores/${target_store_id}/contact-lists`,
|
|
1388
1289
|
payload,
|
|
1389
1290
|
options
|
|
1390
1291
|
);
|
|
@@ -1393,7 +1294,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1393
1294
|
const { id, store_id, ...payload } = params;
|
|
1394
1295
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1395
1296
|
return apiConfig.httpClient.put(
|
|
1396
|
-
`/v1/stores/${target_store_id}/
|
|
1297
|
+
`/v1/stores/${target_store_id}/contact-lists/${id}`,
|
|
1397
1298
|
payload,
|
|
1398
1299
|
options
|
|
1399
1300
|
);
|
|
@@ -1401,7 +1302,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1401
1302
|
async get(params, options) {
|
|
1402
1303
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1403
1304
|
return apiConfig.httpClient.get(
|
|
1404
|
-
`/v1/stores/${target_store_id}/
|
|
1305
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.id}`,
|
|
1405
1306
|
options
|
|
1406
1307
|
);
|
|
1407
1308
|
},
|
|
@@ -1409,79 +1310,43 @@ var createProfileApi = (apiConfig) => {
|
|
|
1409
1310
|
const { store_id, ...queryParams } = params || {};
|
|
1410
1311
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1411
1312
|
return apiConfig.httpClient.get(
|
|
1412
|
-
`/v1/stores/${target_store_id}/
|
|
1313
|
+
`/v1/stores/${target_store_id}/contact-lists`,
|
|
1413
1314
|
{ ...options, params: queryParams }
|
|
1414
1315
|
);
|
|
1415
1316
|
},
|
|
1416
|
-
async
|
|
1417
|
-
const { store_id,
|
|
1317
|
+
async importContacts(params, options) {
|
|
1318
|
+
const { store_id, contact_list_id, ...payload } = params;
|
|
1418
1319
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1419
1320
|
return apiConfig.httpClient.post(
|
|
1420
|
-
`/v1/stores/${target_store_id}/
|
|
1321
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/import`,
|
|
1421
1322
|
payload,
|
|
1422
1323
|
options
|
|
1423
1324
|
);
|
|
1424
1325
|
},
|
|
1425
|
-
async
|
|
1426
|
-
const { store_id,
|
|
1326
|
+
async previewImportContacts(params, options) {
|
|
1327
|
+
const { store_id, contact_list_id, ...payload } = params;
|
|
1427
1328
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1428
1329
|
return apiConfig.httpClient.post(
|
|
1429
|
-
`/v1/stores/${target_store_id}/
|
|
1330
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/import/preview`,
|
|
1430
1331
|
payload,
|
|
1431
1332
|
options
|
|
1432
1333
|
);
|
|
1433
1334
|
},
|
|
1434
1335
|
members: {
|
|
1435
1336
|
async add(params, options) {
|
|
1436
|
-
const { store_id,
|
|
1437
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1438
|
-
return apiConfig.httpClient.post(
|
|
1439
|
-
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
|
|
1440
|
-
{ fields, lead_description },
|
|
1441
|
-
options
|
|
1442
|
-
);
|
|
1443
|
-
},
|
|
1444
|
-
async update(params, options) {
|
|
1445
|
-
const { store_id, profile_list_id, profile_id, status, fields, lead_description } = params;
|
|
1446
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1447
|
-
return apiConfig.httpClient.patch(
|
|
1448
|
-
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
|
|
1449
|
-
{ status, fields, lead_description },
|
|
1450
|
-
options
|
|
1451
|
-
);
|
|
1452
|
-
},
|
|
1453
|
-
async remove(params, options) {
|
|
1454
|
-
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1455
|
-
return apiConfig.httpClient.delete(
|
|
1456
|
-
`/v1/stores/${target_store_id}/profile-lists/${params.profile_list_id}/members/${params.profile_id}`,
|
|
1457
|
-
options
|
|
1458
|
-
);
|
|
1459
|
-
},
|
|
1460
|
-
async find(params, options) {
|
|
1461
|
-
const { store_id, profile_list_id, ...queryParams } = params;
|
|
1462
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1463
|
-
const path = profile_list_id ? `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members` : `/v1/stores/${target_store_id}/profile-list-members`;
|
|
1464
|
-
return apiConfig.httpClient.get(
|
|
1465
|
-
path,
|
|
1466
|
-
{ ...options, params: queryParams }
|
|
1467
|
-
);
|
|
1468
|
-
}
|
|
1469
|
-
},
|
|
1470
|
-
profiles: {
|
|
1471
|
-
async add(params, options) {
|
|
1472
|
-
const { store_id, profile_list_id, profile_id, fields, lead_description } = params;
|
|
1337
|
+
const { store_id, contact_list_id, contact_id, fields, lead_description } = params;
|
|
1473
1338
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1474
1339
|
return apiConfig.httpClient.post(
|
|
1475
|
-
`/v1/stores/${target_store_id}/
|
|
1340
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/${contact_id}`,
|
|
1476
1341
|
{ fields, lead_description },
|
|
1477
1342
|
options
|
|
1478
1343
|
);
|
|
1479
1344
|
},
|
|
1480
1345
|
async update(params, options) {
|
|
1481
|
-
const { store_id,
|
|
1346
|
+
const { store_id, contact_list_id, contact_id, status, fields, lead_description } = params;
|
|
1482
1347
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1483
1348
|
return apiConfig.httpClient.patch(
|
|
1484
|
-
`/v1/stores/${target_store_id}/
|
|
1349
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/${contact_id}`,
|
|
1485
1350
|
{ status, fields, lead_description },
|
|
1486
1351
|
options
|
|
1487
1352
|
);
|
|
@@ -1489,14 +1354,17 @@ var createProfileApi = (apiConfig) => {
|
|
|
1489
1354
|
async remove(params, options) {
|
|
1490
1355
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1491
1356
|
return apiConfig.httpClient.delete(
|
|
1492
|
-
`/v1/stores/${target_store_id}/
|
|
1357
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/contacts/${params.contact_id}`,
|
|
1493
1358
|
options
|
|
1494
1359
|
);
|
|
1495
1360
|
},
|
|
1496
1361
|
async find(params, options) {
|
|
1497
|
-
const { store_id,
|
|
1362
|
+
const { store_id, contact_list_id, ...queryParams } = params;
|
|
1363
|
+
if (!contact_list_id && !queryParams.contact_id) {
|
|
1364
|
+
throw new Error("contact_list_id or contact_id is required");
|
|
1365
|
+
}
|
|
1498
1366
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1499
|
-
const path =
|
|
1367
|
+
const path = contact_list_id ? `/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts` : `/v1/stores/${target_store_id}/contact-lists/contacts`;
|
|
1500
1368
|
return apiConfig.httpClient.get(
|
|
1501
1369
|
path,
|
|
1502
1370
|
{ ...options, params: queryParams }
|
|
@@ -1613,11 +1481,11 @@ var createProfileApi = (apiConfig) => {
|
|
|
1613
1481
|
options
|
|
1614
1482
|
);
|
|
1615
1483
|
},
|
|
1616
|
-
async
|
|
1484
|
+
async importEnrollments(params, options) {
|
|
1617
1485
|
const { id, store_id, ...payload } = params;
|
|
1618
1486
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1619
1487
|
return apiConfig.httpClient.post(
|
|
1620
|
-
`/v1/stores/${target_store_id}/campaigns/${id}/
|
|
1488
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/enrollments/import`,
|
|
1621
1489
|
payload,
|
|
1622
1490
|
options
|
|
1623
1491
|
);
|
|
@@ -1632,12 +1500,12 @@ var createProfileApi = (apiConfig) => {
|
|
|
1632
1500
|
);
|
|
1633
1501
|
}
|
|
1634
1502
|
},
|
|
1635
|
-
|
|
1503
|
+
campaignEnrollment: {
|
|
1636
1504
|
async find(params, options) {
|
|
1637
1505
|
const { store_id, ...queryParams } = params || {};
|
|
1638
1506
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1639
1507
|
return apiConfig.httpClient.get(
|
|
1640
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1508
|
+
`/v1/stores/${target_store_id}/campaign-enrollments`,
|
|
1641
1509
|
{ ...options, params: queryParams }
|
|
1642
1510
|
);
|
|
1643
1511
|
},
|
|
@@ -1645,7 +1513,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1645
1513
|
const { store_id, id, ...queryParams } = params;
|
|
1646
1514
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1647
1515
|
return apiConfig.httpClient.get(
|
|
1648
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1516
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}`,
|
|
1649
1517
|
{ ...options, params: { ...queryParams, store_id: target_store_id } }
|
|
1650
1518
|
);
|
|
1651
1519
|
},
|
|
@@ -1653,7 +1521,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1653
1521
|
const { store_id, id, ...payload } = params;
|
|
1654
1522
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1655
1523
|
return apiConfig.httpClient.put(
|
|
1656
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1524
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}`,
|
|
1657
1525
|
payload,
|
|
1658
1526
|
options
|
|
1659
1527
|
);
|
|
@@ -1662,7 +1530,16 @@ var createProfileApi = (apiConfig) => {
|
|
|
1662
1530
|
const { store_id, id, draft_id, ...payload } = params;
|
|
1663
1531
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1664
1532
|
return apiConfig.httpClient.put(
|
|
1665
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1533
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/drafts/${draft_id}`,
|
|
1534
|
+
payload,
|
|
1535
|
+
options
|
|
1536
|
+
);
|
|
1537
|
+
},
|
|
1538
|
+
async updateStepExecution(params, options) {
|
|
1539
|
+
const { store_id, id, execution_id, ...payload } = params;
|
|
1540
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1541
|
+
return apiConfig.httpClient.post(
|
|
1542
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/step-executions/${execution_id}`,
|
|
1666
1543
|
payload,
|
|
1667
1544
|
options
|
|
1668
1545
|
);
|
|
@@ -1671,7 +1548,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1671
1548
|
const { store_id, id, ...payload } = params;
|
|
1672
1549
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1673
1550
|
return apiConfig.httpClient.post(
|
|
1674
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1551
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/reply`,
|
|
1675
1552
|
payload,
|
|
1676
1553
|
options
|
|
1677
1554
|
);
|
|
@@ -1680,7 +1557,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1680
1557
|
const { store_id, id, ...payload } = params;
|
|
1681
1558
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1682
1559
|
return apiConfig.httpClient.post(
|
|
1683
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1560
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/stop`,
|
|
1684
1561
|
payload,
|
|
1685
1562
|
options
|
|
1686
1563
|
);
|
|
@@ -1740,7 +1617,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1740
1617
|
);
|
|
1741
1618
|
}
|
|
1742
1619
|
},
|
|
1743
|
-
|
|
1620
|
+
action: createActionAdminApi(apiConfig)
|
|
1744
1621
|
};
|
|
1745
1622
|
};
|
|
1746
1623
|
|
|
@@ -1798,6 +1675,7 @@ function createAdminSupportApi(config) {
|
|
|
1798
1675
|
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
1799
1676
|
if (params.status) qs.set("status", params.status);
|
|
1800
1677
|
if (params.agent_id) qs.set("agent_id", params.agent_id);
|
|
1678
|
+
if (params.query) qs.set("query", params.query);
|
|
1801
1679
|
if (params.limit) qs.set("limit", String(params.limit));
|
|
1802
1680
|
if (params.cursor) qs.set("cursor", params.cursor);
|
|
1803
1681
|
return httpClient.get(
|
|
@@ -1910,23 +1788,212 @@ var createLeadResearchApi = (apiConfig) => {
|
|
|
1910
1788
|
};
|
|
1911
1789
|
};
|
|
1912
1790
|
|
|
1913
|
-
// src/api/
|
|
1914
|
-
var
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
const
|
|
1919
|
-
return apiConfig.httpClient.
|
|
1920
|
-
`/v1/stores/${
|
|
1921
|
-
{
|
|
1791
|
+
// src/api/social.ts
|
|
1792
|
+
var createSocialApi = (apiConfig) => {
|
|
1793
|
+
const storeId = (store_id) => store_id || apiConfig.storeId;
|
|
1794
|
+
const api = {
|
|
1795
|
+
async findPublications(params, options) {
|
|
1796
|
+
const { store_id, ...queryParams } = params || {};
|
|
1797
|
+
return apiConfig.httpClient.get(
|
|
1798
|
+
`/v1/stores/${storeId(store_id)}/social-publications`,
|
|
1799
|
+
{
|
|
1800
|
+
...options,
|
|
1801
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1802
|
+
}
|
|
1803
|
+
);
|
|
1804
|
+
},
|
|
1805
|
+
async getPublication(params, options) {
|
|
1806
|
+
return apiConfig.httpClient.get(
|
|
1807
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.id}`,
|
|
1922
1808
|
options
|
|
1923
1809
|
);
|
|
1924
1810
|
},
|
|
1925
|
-
async
|
|
1926
|
-
const { store_id,
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1811
|
+
async validatePublication(params, options) {
|
|
1812
|
+
const { store_id, ...payload } = params;
|
|
1813
|
+
return apiConfig.httpClient.post(
|
|
1814
|
+
`/v1/stores/${storeId(store_id)}/social-publications/validate`,
|
|
1815
|
+
payload,
|
|
1816
|
+
options
|
|
1817
|
+
);
|
|
1818
|
+
},
|
|
1819
|
+
async createPublication(params, options) {
|
|
1820
|
+
const { store_id, ...payload } = params;
|
|
1821
|
+
return apiConfig.httpClient.post(
|
|
1822
|
+
`/v1/stores/${storeId(store_id)}/social-publications`,
|
|
1823
|
+
payload,
|
|
1824
|
+
options
|
|
1825
|
+
);
|
|
1826
|
+
},
|
|
1827
|
+
async updatePublication(params, options) {
|
|
1828
|
+
const { store_id, id, ...payload } = params;
|
|
1829
|
+
return apiConfig.httpClient.put(
|
|
1830
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${id}`,
|
|
1831
|
+
payload,
|
|
1832
|
+
options
|
|
1833
|
+
);
|
|
1834
|
+
},
|
|
1835
|
+
async schedulePublication(params, options) {
|
|
1836
|
+
const { store_id, id, ...payload } = params;
|
|
1837
|
+
return apiConfig.httpClient.post(
|
|
1838
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${id}/schedule`,
|
|
1839
|
+
payload,
|
|
1840
|
+
options
|
|
1841
|
+
);
|
|
1842
|
+
},
|
|
1843
|
+
async cancelPublication(params, options) {
|
|
1844
|
+
return apiConfig.httpClient.post(
|
|
1845
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.id}/cancel`,
|
|
1846
|
+
{},
|
|
1847
|
+
options
|
|
1848
|
+
);
|
|
1849
|
+
},
|
|
1850
|
+
async getPublicationComments(params, options) {
|
|
1851
|
+
const { store_id, publication_id, ...queryParams } = params;
|
|
1852
|
+
return apiConfig.httpClient.get(
|
|
1853
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments`,
|
|
1854
|
+
{
|
|
1855
|
+
...options,
|
|
1856
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1857
|
+
}
|
|
1858
|
+
);
|
|
1859
|
+
},
|
|
1860
|
+
async syncPublicationComments(params, options) {
|
|
1861
|
+
const { store_id, publication_id, ...payload } = params;
|
|
1862
|
+
return apiConfig.httpClient.post(
|
|
1863
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/sync`,
|
|
1864
|
+
payload,
|
|
1865
|
+
options
|
|
1866
|
+
);
|
|
1867
|
+
},
|
|
1868
|
+
async getPublicationCommentThread(params, options) {
|
|
1869
|
+
const { store_id, publication_id, comment_id, ...queryParams } = params;
|
|
1870
|
+
return apiConfig.httpClient.get(
|
|
1871
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/thread`,
|
|
1872
|
+
{
|
|
1873
|
+
...options,
|
|
1874
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1875
|
+
}
|
|
1876
|
+
);
|
|
1877
|
+
},
|
|
1878
|
+
async syncPublicationCommentThread(params, options) {
|
|
1879
|
+
const { store_id, publication_id, comment_id, ...payload } = params;
|
|
1880
|
+
return apiConfig.httpClient.post(
|
|
1881
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/thread/sync`,
|
|
1882
|
+
payload,
|
|
1883
|
+
options
|
|
1884
|
+
);
|
|
1885
|
+
},
|
|
1886
|
+
async findPublicationComments(params, options) {
|
|
1887
|
+
const { store_id, ...queryParams } = params || {};
|
|
1888
|
+
return apiConfig.httpClient.get(`/v1/stores/${storeId(store_id)}/social-publications/comments`, {
|
|
1889
|
+
...options,
|
|
1890
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1891
|
+
});
|
|
1892
|
+
},
|
|
1893
|
+
async classifyPublicationComments(params, options) {
|
|
1894
|
+
const { store_id, ...payload } = params || {};
|
|
1895
|
+
return apiConfig.httpClient.post(
|
|
1896
|
+
`/v1/stores/${storeId(store_id)}/social-publications/comments/classify`,
|
|
1897
|
+
payload,
|
|
1898
|
+
options
|
|
1899
|
+
);
|
|
1900
|
+
},
|
|
1901
|
+
async replyToPublicationComment(params, options) {
|
|
1902
|
+
const { store_id, publication_id, comment_id, text } = params;
|
|
1903
|
+
return apiConfig.httpClient.post(
|
|
1904
|
+
`/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/reply`,
|
|
1905
|
+
{ text },
|
|
1906
|
+
options
|
|
1907
|
+
);
|
|
1908
|
+
},
|
|
1909
|
+
async getPublicationMetrics(params, options) {
|
|
1910
|
+
return apiConfig.httpClient.get(
|
|
1911
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/metrics`,
|
|
1912
|
+
options
|
|
1913
|
+
);
|
|
1914
|
+
},
|
|
1915
|
+
async syncPublicationMetrics(params, options) {
|
|
1916
|
+
return apiConfig.httpClient.post(
|
|
1917
|
+
`/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/metrics/sync`,
|
|
1918
|
+
{},
|
|
1919
|
+
options
|
|
1920
|
+
);
|
|
1921
|
+
},
|
|
1922
|
+
async syncEngagement(params, options) {
|
|
1923
|
+
const { store_id, ...payload } = params || {};
|
|
1924
|
+
return apiConfig.httpClient.post(
|
|
1925
|
+
`/v1/stores/${storeId(store_id)}/social-publications/engagement/sync`,
|
|
1926
|
+
payload,
|
|
1927
|
+
options
|
|
1928
|
+
);
|
|
1929
|
+
},
|
|
1930
|
+
async getCapabilities(params, options) {
|
|
1931
|
+
return apiConfig.httpClient.get(
|
|
1932
|
+
`/v1/stores/${storeId(params?.store_id)}/social-accounts/capabilities`,
|
|
1933
|
+
options
|
|
1934
|
+
);
|
|
1935
|
+
},
|
|
1936
|
+
async listAccounts(params, options) {
|
|
1937
|
+
return apiConfig.httpClient.get(
|
|
1938
|
+
`/v1/stores/${storeId(params?.store_id)}/social-accounts`,
|
|
1939
|
+
options
|
|
1940
|
+
);
|
|
1941
|
+
},
|
|
1942
|
+
async connect(params, options) {
|
|
1943
|
+
const { store_id, ...payload } = params;
|
|
1944
|
+
return apiConfig.httpClient.post(
|
|
1945
|
+
`/v1/stores/${storeId(store_id)}/social-accounts/oauth/connect`,
|
|
1946
|
+
payload,
|
|
1947
|
+
options
|
|
1948
|
+
);
|
|
1949
|
+
},
|
|
1950
|
+
async getOAuthAttempt(params, options) {
|
|
1951
|
+
return apiConfig.httpClient.get(
|
|
1952
|
+
`/v1/stores/${storeId(params.store_id)}/social-accounts/oauth/attempts/${params.attempt_id}`,
|
|
1953
|
+
options
|
|
1954
|
+
);
|
|
1955
|
+
},
|
|
1956
|
+
async selectDestination(params, options) {
|
|
1957
|
+
const { store_id, ...payload } = params;
|
|
1958
|
+
return apiConfig.httpClient.post(
|
|
1959
|
+
`/v1/stores/${storeId(store_id)}/social-accounts/oauth/select-destination`,
|
|
1960
|
+
payload,
|
|
1961
|
+
options
|
|
1962
|
+
);
|
|
1963
|
+
},
|
|
1964
|
+
async deleteAccount(params, options) {
|
|
1965
|
+
return apiConfig.httpClient.delete(
|
|
1966
|
+
`/v1/stores/${storeId(params.store_id)}/social-accounts/${params.id}`,
|
|
1967
|
+
options
|
|
1968
|
+
);
|
|
1969
|
+
},
|
|
1970
|
+
validatePublications(params, options) {
|
|
1971
|
+
return api.validatePublication(params, options);
|
|
1972
|
+
},
|
|
1973
|
+
createPublications(params, options) {
|
|
1974
|
+
return api.createPublication(params, options);
|
|
1975
|
+
}
|
|
1976
|
+
};
|
|
1977
|
+
return api;
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
// src/api/workflow.ts
|
|
1981
|
+
var createWorkflowApi = (apiConfig) => {
|
|
1982
|
+
return {
|
|
1983
|
+
async createWorkflow(params, options) {
|
|
1984
|
+
const { store_id, ...payload } = params;
|
|
1985
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1986
|
+
return apiConfig.httpClient.post(
|
|
1987
|
+
`/v1/stores/${target_store_id}/workflows`,
|
|
1988
|
+
{ ...payload, store_id: target_store_id },
|
|
1989
|
+
options
|
|
1990
|
+
);
|
|
1991
|
+
},
|
|
1992
|
+
async updateWorkflow(params, options) {
|
|
1993
|
+
const { store_id, id, ...payload } = params;
|
|
1994
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1995
|
+
return apiConfig.httpClient.put(
|
|
1996
|
+
`/v1/stores/${target_store_id}/workflows/${id}`,
|
|
1930
1997
|
payload,
|
|
1931
1998
|
options
|
|
1932
1999
|
);
|
|
@@ -1948,14 +2015,21 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1948
2015
|
async getWorkflows(params, options) {
|
|
1949
2016
|
const store_id = params?.store_id || apiConfig.storeId;
|
|
1950
2017
|
const { store_id: _, ...queryParams } = params || {};
|
|
1951
|
-
return apiConfig.httpClient.get(
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2018
|
+
return apiConfig.httpClient.get(
|
|
2019
|
+
`/v1/stores/${store_id}/workflows`,
|
|
2020
|
+
{
|
|
2021
|
+
...options,
|
|
2022
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2023
|
+
}
|
|
2024
|
+
);
|
|
1955
2025
|
},
|
|
1956
2026
|
async triggerWorkflow(params, options) {
|
|
1957
2027
|
const { secret, ...payload } = params;
|
|
1958
|
-
return apiConfig.httpClient.post(
|
|
2028
|
+
return apiConfig.httpClient.post(
|
|
2029
|
+
`/v1/workflows/trigger/${secret}`,
|
|
2030
|
+
payload,
|
|
2031
|
+
options
|
|
2032
|
+
);
|
|
1959
2033
|
},
|
|
1960
2034
|
async getWorkflowExecutions(params, options) {
|
|
1961
2035
|
const store_id = params.store_id || apiConfig.storeId;
|
|
@@ -1974,6 +2048,38 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1974
2048
|
`/v1/stores/${store_id}/workflows/${params.workflow_id}/executions/${params.execution_id}`,
|
|
1975
2049
|
options
|
|
1976
2050
|
);
|
|
2051
|
+
},
|
|
2052
|
+
async getWorkflowAccounts(params, options) {
|
|
2053
|
+
const store_id = params?.store_id || apiConfig.storeId;
|
|
2054
|
+
return apiConfig.httpClient.get(
|
|
2055
|
+
`/v1/stores/${store_id}/workflow-accounts`,
|
|
2056
|
+
options
|
|
2057
|
+
);
|
|
2058
|
+
},
|
|
2059
|
+
async getWorkflowAccountConnectUrl(params, options) {
|
|
2060
|
+
const { store_id, type, ...payload } = params;
|
|
2061
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2062
|
+
return apiConfig.httpClient.post(
|
|
2063
|
+
`/v1/stores/${target_store_id}/workflow-accounts/connect-url`,
|
|
2064
|
+
{ ...payload, type, store_id: target_store_id },
|
|
2065
|
+
options
|
|
2066
|
+
);
|
|
2067
|
+
},
|
|
2068
|
+
async connectWorkflowAccount(params, options) {
|
|
2069
|
+
const { store_id, type, ...payload } = params;
|
|
2070
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2071
|
+
return apiConfig.httpClient.post(
|
|
2072
|
+
`/v1/stores/${target_store_id}/workflow-accounts/connect`,
|
|
2073
|
+
{ ...payload, type, store_id: target_store_id },
|
|
2074
|
+
options
|
|
2075
|
+
);
|
|
2076
|
+
},
|
|
2077
|
+
async deleteWorkflowAccount(params, options) {
|
|
2078
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
2079
|
+
return apiConfig.httpClient.delete(
|
|
2080
|
+
`/v1/stores/${store_id}/workflow-accounts/${params.id}`,
|
|
2081
|
+
options
|
|
2082
|
+
);
|
|
1977
2083
|
}
|
|
1978
2084
|
};
|
|
1979
2085
|
};
|
|
@@ -1984,8 +2090,8 @@ var createPlatformApi = (apiConfig) => {
|
|
|
1984
2090
|
async getCurrencies(options) {
|
|
1985
2091
|
return apiConfig.httpClient.get("/v1/platform/currencies", options);
|
|
1986
2092
|
},
|
|
1987
|
-
async
|
|
1988
|
-
return apiConfig.httpClient.get("/v1/platform/
|
|
2093
|
+
async getWorkflowTools(options) {
|
|
2094
|
+
return apiConfig.httpClient.get("/v1/platform/workflow-tools", options);
|
|
1989
2095
|
},
|
|
1990
2096
|
async getWebhookEvents(options) {
|
|
1991
2097
|
return apiConfig.httpClient.get("/v1/platform/events", options);
|
|
@@ -2035,6 +2141,40 @@ var createShippingApi = (apiConfig) => {
|
|
|
2035
2141
|
};
|
|
2036
2142
|
};
|
|
2037
2143
|
|
|
2144
|
+
// src/api/paymentProvider.ts
|
|
2145
|
+
var createPaymentProviderApi = (apiConfig) => {
|
|
2146
|
+
const storeId = (store_id) => store_id || apiConfig.storeId;
|
|
2147
|
+
return {
|
|
2148
|
+
async list(params, options) {
|
|
2149
|
+
return apiConfig.httpClient.get(
|
|
2150
|
+
`/v1/stores/${storeId(params?.store_id)}/payment-providers`,
|
|
2151
|
+
options
|
|
2152
|
+
);
|
|
2153
|
+
},
|
|
2154
|
+
async refresh(params, options) {
|
|
2155
|
+
const targetStoreId = storeId(params?.store_id);
|
|
2156
|
+
return apiConfig.httpClient.post(
|
|
2157
|
+
`/v1/stores/${targetStoreId}/payment-providers/refresh`,
|
|
2158
|
+
{ store_id: targetStoreId },
|
|
2159
|
+
options
|
|
2160
|
+
);
|
|
2161
|
+
},
|
|
2162
|
+
async connectStripe(params, options) {
|
|
2163
|
+
return apiConfig.httpClient.post(
|
|
2164
|
+
`/v1/stores/${storeId(params.store_id)}/payment-providers/stripe/connect`,
|
|
2165
|
+
params,
|
|
2166
|
+
options
|
|
2167
|
+
);
|
|
2168
|
+
},
|
|
2169
|
+
async delete(params, options) {
|
|
2170
|
+
return apiConfig.httpClient.delete(
|
|
2171
|
+
`/v1/stores/${storeId(params.store_id)}/payment-providers/${params.id}`,
|
|
2172
|
+
options
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
};
|
|
2176
|
+
};
|
|
2177
|
+
|
|
2038
2178
|
// src/api/emailTemplate.ts
|
|
2039
2179
|
var createEmailTemplateApi = (apiConfig) => {
|
|
2040
2180
|
return {
|
|
@@ -2270,6 +2410,164 @@ var createAnalyticsApi = (apiConfig) => {
|
|
|
2270
2410
|
};
|
|
2271
2411
|
};
|
|
2272
2412
|
|
|
2413
|
+
// src/api/experiments.ts
|
|
2414
|
+
var createExperimentsApi = (apiConfig) => {
|
|
2415
|
+
const base = (storeId = apiConfig.storeId) => `/v1/stores/${storeId}/experiments`;
|
|
2416
|
+
return {
|
|
2417
|
+
create(params, options) {
|
|
2418
|
+
const { store_id, ...payload } = params;
|
|
2419
|
+
return apiConfig.httpClient.post(base(store_id), payload, options);
|
|
2420
|
+
},
|
|
2421
|
+
update(params, options) {
|
|
2422
|
+
const { store_id, key, ...payload } = params;
|
|
2423
|
+
return apiConfig.httpClient.put(`${base(store_id)}/${key}`, payload, options);
|
|
2424
|
+
},
|
|
2425
|
+
get(params, options) {
|
|
2426
|
+
return apiConfig.httpClient.get(`${base(params.store_id)}/${params.key}`, options);
|
|
2427
|
+
},
|
|
2428
|
+
find(params = {}, options) {
|
|
2429
|
+
const { store_id, ...queryParams } = params;
|
|
2430
|
+
return apiConfig.httpClient.get(base(store_id), {
|
|
2431
|
+
...options,
|
|
2432
|
+
params: queryParams
|
|
2433
|
+
});
|
|
2434
|
+
},
|
|
2435
|
+
results(params, options) {
|
|
2436
|
+
return apiConfig.httpClient.get(
|
|
2437
|
+
`${base(params.store_id)}/${params.key}/results`,
|
|
2438
|
+
options
|
|
2439
|
+
);
|
|
2440
|
+
}
|
|
2441
|
+
};
|
|
2442
|
+
};
|
|
2443
|
+
|
|
2444
|
+
// src/utils/blocks.ts
|
|
2445
|
+
function getBlockLabel(block) {
|
|
2446
|
+
if (!block) return "";
|
|
2447
|
+
return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) ?? "";
|
|
2448
|
+
}
|
|
2449
|
+
function formatBlockValue(block) {
|
|
2450
|
+
if (!block || block.value === null || block.value === void 0) return "";
|
|
2451
|
+
const value = block.value;
|
|
2452
|
+
switch (block.type) {
|
|
2453
|
+
case "boolean":
|
|
2454
|
+
return value ? "Yes" : "No";
|
|
2455
|
+
case "number":
|
|
2456
|
+
if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
|
|
2457
|
+
return new Date(value).toLocaleDateString();
|
|
2458
|
+
}
|
|
2459
|
+
return String(value);
|
|
2460
|
+
case "media":
|
|
2461
|
+
if (value && typeof value === "object") {
|
|
2462
|
+
return value.mime_type ? value.name || value.id : value.title || value.name || value.id;
|
|
2463
|
+
}
|
|
2464
|
+
return String(value);
|
|
2465
|
+
default:
|
|
2466
|
+
return String(value);
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
function prepareBlocksForSubmission(formData, blockTypes) {
|
|
2470
|
+
return Object.keys(formData).filter((key) => formData[key] !== null && formData[key] !== void 0).map((key) => ({
|
|
2471
|
+
key,
|
|
2472
|
+
value: (blockTypes?.[key] || "text") === "array" && !Array.isArray(formData[key]) ? [formData[key]] : formData[key]
|
|
2473
|
+
}));
|
|
2474
|
+
}
|
|
2475
|
+
function extractBlockValues(blocks) {
|
|
2476
|
+
const values = {};
|
|
2477
|
+
blocks.forEach((block) => {
|
|
2478
|
+
values[block.key] = block.value ?? null;
|
|
2479
|
+
});
|
|
2480
|
+
return values;
|
|
2481
|
+
}
|
|
2482
|
+
var getBlockValue = (entry, blockKey) => {
|
|
2483
|
+
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
2484
|
+
return block?.value ?? null;
|
|
2485
|
+
};
|
|
2486
|
+
var getBlockTextValue = (block, locale = "en") => {
|
|
2487
|
+
if (!block || block.value === null || block.value === void 0) return "";
|
|
2488
|
+
const blockType = block.type;
|
|
2489
|
+
if (blockType === "localized_text" || blockType === "markdown") {
|
|
2490
|
+
if (typeof block.value === "object" && block.value !== null) {
|
|
2491
|
+
return block.value[locale] ?? block.value["en"] ?? "";
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
if (typeof block.value === "string") return block.value;
|
|
2495
|
+
return String(block.value ?? "");
|
|
2496
|
+
};
|
|
2497
|
+
var getBlockValues = (entry, blockKey) => {
|
|
2498
|
+
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
2499
|
+
if (!block) return [];
|
|
2500
|
+
if (block.type === "array" && Array.isArray(block.value)) {
|
|
2501
|
+
return block.value;
|
|
2502
|
+
}
|
|
2503
|
+
return [];
|
|
2504
|
+
};
|
|
2505
|
+
function unwrapBlock(block, locale) {
|
|
2506
|
+
if (!block?.type || block.value === void 0) return block;
|
|
2507
|
+
const blockType = block.type;
|
|
2508
|
+
if (blockType === "array") {
|
|
2509
|
+
return block.value.map((obj) => {
|
|
2510
|
+
const parsed = {};
|
|
2511
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
2512
|
+
parsed[k] = unwrapBlock(v, locale);
|
|
2513
|
+
}
|
|
2514
|
+
return parsed;
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2517
|
+
if (blockType === "object") {
|
|
2518
|
+
const parsed = {};
|
|
2519
|
+
for (const [k, v] of Object.entries(block.value || {})) {
|
|
2520
|
+
parsed[k] = unwrapBlock(v, locale);
|
|
2521
|
+
}
|
|
2522
|
+
return parsed;
|
|
2523
|
+
}
|
|
2524
|
+
if (blockType === "localized_text" || blockType === "markdown") {
|
|
2525
|
+
return block.value?.[locale];
|
|
2526
|
+
}
|
|
2527
|
+
return block.value;
|
|
2528
|
+
}
|
|
2529
|
+
var getBlockObjectValues = (entry, blockKey, locale = "en") => {
|
|
2530
|
+
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
2531
|
+
if (!block || block.type !== "array" || !Array.isArray(block.value)) return [];
|
|
2532
|
+
return block.value.map((obj) => {
|
|
2533
|
+
if (!obj?.value || !Array.isArray(obj.value)) return {};
|
|
2534
|
+
return obj.value.reduce((acc, current) => {
|
|
2535
|
+
acc[current.key] = unwrapBlock(current, locale);
|
|
2536
|
+
return acc;
|
|
2537
|
+
}, {});
|
|
2538
|
+
});
|
|
2539
|
+
};
|
|
2540
|
+
var getBlockFromArray = (entry, blockKey, locale = "en") => {
|
|
2541
|
+
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
2542
|
+
if (!block) return {};
|
|
2543
|
+
if (block.type === "array" && Array.isArray(block.value)) {
|
|
2544
|
+
return block.value.reduce((acc, current) => {
|
|
2545
|
+
acc[current.key] = unwrapBlock(current, locale);
|
|
2546
|
+
return acc;
|
|
2547
|
+
}, {});
|
|
2548
|
+
}
|
|
2549
|
+
if (block.type === "object" && block.value && typeof block.value === "object") {
|
|
2550
|
+
const result = {};
|
|
2551
|
+
for (const [k, v] of Object.entries(block.value)) {
|
|
2552
|
+
result[k] = unwrapBlock(v, locale);
|
|
2553
|
+
}
|
|
2554
|
+
return result;
|
|
2555
|
+
}
|
|
2556
|
+
return { [block.key]: unwrapBlock(block, locale) };
|
|
2557
|
+
};
|
|
2558
|
+
var getImageUrl = (imageBlock, isBlock = true) => {
|
|
2559
|
+
if (!imageBlock) return null;
|
|
2560
|
+
if (imageBlock.type === "media") {
|
|
2561
|
+
const mediaValue = imageBlock.value;
|
|
2562
|
+
return mediaValue?.resolutions?.original?.url || mediaValue?.url || null;
|
|
2563
|
+
}
|
|
2564
|
+
if (isBlock) {
|
|
2565
|
+
if (typeof imageBlock === "string") return imageBlock;
|
|
2566
|
+
if (imageBlock.url) return imageBlock.url;
|
|
2567
|
+
}
|
|
2568
|
+
return imageBlock.resolutions?.original?.url || null;
|
|
2569
|
+
};
|
|
2570
|
+
|
|
2273
2571
|
// src/utils/price.ts
|
|
2274
2572
|
function formatCurrency(amount, currencyCode, locale = "en") {
|
|
2275
2573
|
if (!currencyCode) return "";
|
|
@@ -2650,63 +2948,142 @@ function createAdmin(config) {
|
|
|
2650
2948
|
const cmsApi = createCmsApi(apiConfig);
|
|
2651
2949
|
const eshopApi = createEshopApi(apiConfig);
|
|
2652
2950
|
const promoCodeApi = createPromoCodeApi(apiConfig);
|
|
2653
|
-
const crmApi =
|
|
2951
|
+
const crmApi = createContactApi(apiConfig);
|
|
2654
2952
|
const supportApi = createAdminSupportApi(apiConfig);
|
|
2655
2953
|
const leadResearchApi = createLeadResearchApi(apiConfig);
|
|
2656
|
-
const
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
get: leadResearchApi.getRun,
|
|
2661
|
-
update: leadResearchApi.updateRun,
|
|
2662
|
-
cancel: leadResearchApi.cancelRun,
|
|
2663
|
-
sendMessage: leadResearchApi.sendMessage,
|
|
2664
|
-
findMessages: leadResearchApi.findMessages
|
|
2665
|
-
},
|
|
2666
|
-
message: {
|
|
2667
|
-
send: leadResearchApi.sendMessage,
|
|
2668
|
-
find: leadResearchApi.findMessages
|
|
2669
|
-
},
|
|
2670
|
-
email: {
|
|
2671
|
-
validate: leadResearchApi.validateEmail
|
|
2672
|
-
},
|
|
2673
|
-
createRun: leadResearchApi.createRun,
|
|
2674
|
-
findRuns: leadResearchApi.findRuns,
|
|
2675
|
-
getRun: leadResearchApi.getRun,
|
|
2676
|
-
updateRun: leadResearchApi.updateRun,
|
|
2677
|
-
cancelRun: leadResearchApi.cancelRun,
|
|
2678
|
-
sendMessage: leadResearchApi.sendMessage,
|
|
2679
|
-
findMessages: leadResearchApi.findMessages,
|
|
2680
|
-
validateEmail: leadResearchApi.validateEmail
|
|
2681
|
-
};
|
|
2954
|
+
const socialApi = createSocialApi(apiConfig);
|
|
2955
|
+
const paymentProviderApi = createPaymentProviderApi(apiConfig);
|
|
2956
|
+
const notificationApi = createNotificationApi(apiConfig);
|
|
2957
|
+
const shippingApi = createShippingApi(apiConfig);
|
|
2682
2958
|
const locationApi = createLocationApi(apiConfig);
|
|
2683
2959
|
const marketApi = createMarketApi(apiConfig);
|
|
2684
2960
|
const workflowApi = createWorkflowApi(apiConfig);
|
|
2961
|
+
const storePaymentProviderApi = {
|
|
2962
|
+
list: paymentProviderApi.list,
|
|
2963
|
+
refresh: paymentProviderApi.refresh,
|
|
2964
|
+
connectStripe: paymentProviderApi.connectStripe,
|
|
2965
|
+
delete: paymentProviderApi.delete
|
|
2966
|
+
};
|
|
2967
|
+
const workflowPublicApi = {
|
|
2968
|
+
create: workflowApi.createWorkflow,
|
|
2969
|
+
update: workflowApi.updateWorkflow,
|
|
2970
|
+
delete: workflowApi.deleteWorkflow,
|
|
2971
|
+
get: workflowApi.getWorkflow,
|
|
2972
|
+
find: workflowApi.getWorkflows,
|
|
2973
|
+
trigger: workflowApi.triggerWorkflow,
|
|
2974
|
+
getExecutions: workflowApi.getWorkflowExecutions,
|
|
2975
|
+
getExecution: workflowApi.getWorkflowExecution,
|
|
2976
|
+
listAccounts: workflowApi.getWorkflowAccounts,
|
|
2977
|
+
getAccountConnectUrl: workflowApi.getWorkflowAccountConnectUrl,
|
|
2978
|
+
connectAccount: workflowApi.connectWorkflowAccount,
|
|
2979
|
+
deleteAccount: workflowApi.deleteWorkflowAccount
|
|
2980
|
+
};
|
|
2685
2981
|
const formApi = createFormApi(apiConfig);
|
|
2686
2982
|
const taxonomyApi = createTaxonomyApi(apiConfig);
|
|
2687
2983
|
const emailTemplateApi = createEmailTemplateApi(apiConfig);
|
|
2688
2984
|
const analyticsApi = createAnalyticsApi(apiConfig);
|
|
2985
|
+
const experimentsApi = createExperimentsApi(apiConfig);
|
|
2689
2986
|
const sdk = {
|
|
2690
|
-
|
|
2691
|
-
|
|
2987
|
+
account: {
|
|
2988
|
+
update: accountApi.updateAccount,
|
|
2989
|
+
delete: accountApi.deleteAccount,
|
|
2990
|
+
getMe: accountApi.getMe,
|
|
2991
|
+
search: accountApi.searchAccounts,
|
|
2992
|
+
auth: authApi
|
|
2993
|
+
},
|
|
2692
2994
|
store: {
|
|
2693
|
-
|
|
2995
|
+
create: storeApi.createStore,
|
|
2996
|
+
update: storeApi.updateStore,
|
|
2997
|
+
delete: storeApi.deleteStore,
|
|
2998
|
+
get: storeApi.getStore,
|
|
2999
|
+
find: storeApi.getStores,
|
|
3000
|
+
subscription: {
|
|
3001
|
+
getPlans: storeApi.getSubscriptionPlans,
|
|
3002
|
+
subscribe: storeApi.subscribe,
|
|
3003
|
+
createPortalSession: storeApi.createPortalSession
|
|
3004
|
+
},
|
|
3005
|
+
member: {
|
|
3006
|
+
add: storeApi.addMember,
|
|
3007
|
+
invite: storeApi.inviteUser,
|
|
3008
|
+
remove: storeApi.removeMember
|
|
3009
|
+
},
|
|
3010
|
+
buildHook: {
|
|
3011
|
+
list: storeApi.listBuildHooks,
|
|
3012
|
+
create: storeApi.createBuildHook,
|
|
3013
|
+
update: storeApi.updateBuildHook,
|
|
3014
|
+
delete: storeApi.deleteBuildHook
|
|
3015
|
+
},
|
|
3016
|
+
webhook: {
|
|
3017
|
+
test: storeApi.testWebhook,
|
|
3018
|
+
list: storeApi.listWebhooks,
|
|
3019
|
+
create: storeApi.createWebhook,
|
|
3020
|
+
update: storeApi.updateWebhook,
|
|
3021
|
+
delete: storeApi.deleteWebhook
|
|
3022
|
+
},
|
|
3023
|
+
config: {
|
|
3024
|
+
get: storeApi.getStoreConfig
|
|
3025
|
+
},
|
|
3026
|
+
media: {
|
|
3027
|
+
find: storeApi.getStoreMedia
|
|
3028
|
+
},
|
|
2694
3029
|
location: locationApi,
|
|
2695
|
-
market: marketApi
|
|
3030
|
+
market: marketApi,
|
|
3031
|
+
paymentProvider: storePaymentProviderApi
|
|
2696
3032
|
},
|
|
2697
3033
|
media: createMediaApi(apiConfig),
|
|
2698
|
-
notification:
|
|
2699
|
-
|
|
3034
|
+
notification: {
|
|
3035
|
+
email: {
|
|
3036
|
+
trackOpen: notificationApi.trackEmailOpen
|
|
3037
|
+
},
|
|
3038
|
+
trigger: {
|
|
3039
|
+
send: notificationApi.trigger
|
|
3040
|
+
},
|
|
3041
|
+
mailbox: crmApi.mailbox
|
|
3042
|
+
},
|
|
2700
3043
|
platform: platformApi,
|
|
2701
|
-
|
|
3044
|
+
social: {
|
|
3045
|
+
account: {
|
|
3046
|
+
getCapabilities: socialApi.getCapabilities,
|
|
3047
|
+
list: socialApi.listAccounts,
|
|
3048
|
+
connect: socialApi.connect,
|
|
3049
|
+
getOAuthAttempt: socialApi.getOAuthAttempt,
|
|
3050
|
+
selectDestination: socialApi.selectDestination,
|
|
3051
|
+
delete: socialApi.deleteAccount
|
|
3052
|
+
},
|
|
3053
|
+
publication: {
|
|
3054
|
+
create: socialApi.createPublication,
|
|
3055
|
+
update: socialApi.updatePublication,
|
|
3056
|
+
get: socialApi.getPublication,
|
|
3057
|
+
find: socialApi.findPublications,
|
|
3058
|
+
validate: socialApi.validatePublication,
|
|
3059
|
+
schedule: socialApi.schedulePublication,
|
|
3060
|
+
cancel: socialApi.cancelPublication,
|
|
3061
|
+
getComments: socialApi.getPublicationComments,
|
|
3062
|
+
syncComments: socialApi.syncPublicationComments,
|
|
3063
|
+
getCommentThread: socialApi.getPublicationCommentThread,
|
|
3064
|
+
syncCommentThread: socialApi.syncPublicationCommentThread,
|
|
3065
|
+
findComments: socialApi.findPublicationComments,
|
|
3066
|
+
classifyComments: socialApi.classifyPublicationComments,
|
|
3067
|
+
replyToComment: socialApi.replyToPublicationComment,
|
|
3068
|
+
getMetrics: socialApi.getPublicationMetrics,
|
|
3069
|
+
syncMetrics: socialApi.syncPublicationMetrics,
|
|
3070
|
+
syncEngagement: socialApi.syncEngagement
|
|
3071
|
+
}
|
|
3072
|
+
},
|
|
2702
3073
|
cms: {
|
|
2703
|
-
|
|
2704
|
-
create: cmsApi.
|
|
2705
|
-
update: cmsApi.
|
|
2706
|
-
delete: cmsApi.
|
|
2707
|
-
get: cmsApi.
|
|
2708
|
-
find: cmsApi.
|
|
2709
|
-
|
|
3074
|
+
collection: {
|
|
3075
|
+
create: cmsApi.createCollection,
|
|
3076
|
+
update: cmsApi.updateCollection,
|
|
3077
|
+
delete: cmsApi.deleteCollection,
|
|
3078
|
+
get: cmsApi.getCollection,
|
|
3079
|
+
find: cmsApi.getCollections
|
|
3080
|
+
},
|
|
3081
|
+
entry: {
|
|
3082
|
+
create: cmsApi.createEntry,
|
|
3083
|
+
update: cmsApi.updateEntry,
|
|
3084
|
+
delete: cmsApi.deleteEntry,
|
|
3085
|
+
get: cmsApi.getEntry,
|
|
3086
|
+
find: cmsApi.getEntries
|
|
2710
3087
|
},
|
|
2711
3088
|
form: {
|
|
2712
3089
|
create: formApi.createForm,
|
|
@@ -2749,7 +3126,10 @@ function createAdmin(config) {
|
|
|
2749
3126
|
get: eshopApi.getOrder,
|
|
2750
3127
|
find: eshopApi.getOrders,
|
|
2751
3128
|
getQuote: eshopApi.getQuote,
|
|
2752
|
-
processRefund: eshopApi.processRefund
|
|
3129
|
+
processRefund: eshopApi.processRefund,
|
|
3130
|
+
downloadDigitalAccess: eshopApi.downloadDigitalAccess,
|
|
3131
|
+
getShippingRates: shippingApi.getRates,
|
|
3132
|
+
ship: shippingApi.ship
|
|
2753
3133
|
},
|
|
2754
3134
|
cart: {
|
|
2755
3135
|
create: eshopApi.createCart,
|
|
@@ -2784,7 +3164,7 @@ function createAdmin(config) {
|
|
|
2784
3164
|
promoCode: promoCodeApi
|
|
2785
3165
|
},
|
|
2786
3166
|
crm: {
|
|
2787
|
-
|
|
3167
|
+
contact: {
|
|
2788
3168
|
create: crmApi.create,
|
|
2789
3169
|
get: crmApi.get,
|
|
2790
3170
|
find: crmApi.find,
|
|
@@ -2794,30 +3174,45 @@ function createAdmin(config) {
|
|
|
2794
3174
|
revokeToken: crmApi.revokeToken,
|
|
2795
3175
|
revokeAllTokens: crmApi.revokeAllTokens
|
|
2796
3176
|
},
|
|
2797
|
-
|
|
2798
|
-
|
|
3177
|
+
contactList: {
|
|
3178
|
+
create: crmApi.contactList.create,
|
|
3179
|
+
update: crmApi.contactList.update,
|
|
3180
|
+
get: crmApi.contactList.get,
|
|
3181
|
+
find: crmApi.contactList.find,
|
|
3182
|
+
importContacts: crmApi.contactList.importContacts,
|
|
3183
|
+
previewImportContacts: crmApi.contactList.previewImportContacts,
|
|
3184
|
+
addMember: crmApi.contactList.members.add,
|
|
3185
|
+
updateMember: crmApi.contactList.members.update,
|
|
3186
|
+
removeMember: crmApi.contactList.members.remove,
|
|
3187
|
+
findMembers: crmApi.contactList.members.find
|
|
3188
|
+
},
|
|
3189
|
+
action: crmApi.action
|
|
3190
|
+
},
|
|
3191
|
+
outreach: {
|
|
2799
3192
|
campaign: crmApi.campaign,
|
|
2800
|
-
|
|
3193
|
+
campaignEnrollment: crmApi.campaignEnrollment,
|
|
2801
3194
|
campaignMessage: crmApi.campaignMessage,
|
|
2802
3195
|
suppression: crmApi.suppression,
|
|
2803
|
-
leadResearch
|
|
2804
|
-
activity: crmApi.activity
|
|
3196
|
+
leadResearch: leadResearchApi
|
|
2805
3197
|
},
|
|
2806
|
-
leadResearch,
|
|
2807
3198
|
automation: {
|
|
2808
|
-
workflow:
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
3199
|
+
workflow: workflowPublicApi,
|
|
3200
|
+
support: {
|
|
3201
|
+
createAgent: supportApi.agent.create,
|
|
3202
|
+
getAgent: supportApi.agent.get,
|
|
3203
|
+
findAgents: supportApi.agent.find,
|
|
3204
|
+
updateAgent: supportApi.agent.update,
|
|
3205
|
+
deleteAgent: supportApi.agent.delete,
|
|
3206
|
+
findConversations: supportApi.conversation.find,
|
|
3207
|
+
getConversation: supportApi.conversation.get,
|
|
3208
|
+
sendConversationMessage: supportApi.conversation.sendMessage,
|
|
3209
|
+
replyToConversation: supportApi.conversation.reply,
|
|
3210
|
+
resolveConversation: supportApi.conversation.resolve,
|
|
3211
|
+
assignConversation: supportApi.conversation.assign
|
|
3212
|
+
}
|
|
2819
3213
|
},
|
|
2820
3214
|
analytics: analyticsApi,
|
|
3215
|
+
experiments: experimentsApi,
|
|
2821
3216
|
setStoreId: (storeId) => {
|
|
2822
3217
|
apiConfig.storeId = storeId;
|
|
2823
3218
|
},
|
|
@@ -2853,7 +3248,6 @@ function createAdmin(config) {
|
|
|
2853
3248
|
if (config.apiToken) return;
|
|
2854
3249
|
updateSession(() => null);
|
|
2855
3250
|
},
|
|
2856
|
-
extractBlockValues,
|
|
2857
3251
|
utils: createUtilitySurface(apiConfig)
|
|
2858
3252
|
};
|
|
2859
3253
|
return sdk;
|