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.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,9 +301,6 @@ 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
|
};
|
|
@@ -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
|
},
|
|
@@ -517,61 +393,52 @@ var createStoreApi = (apiConfig, _updateSession) => {
|
|
|
517
393
|
limit: params.limit
|
|
518
394
|
};
|
|
519
395
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
520
|
-
if (params.ids && params.ids.length > 0)
|
|
396
|
+
if (params.ids && params.ids.length > 0)
|
|
397
|
+
queryParams.ids = JSON.stringify(params.ids);
|
|
521
398
|
if (params.query) queryParams.query = params.query;
|
|
522
399
|
if (params.mime_type) queryParams.mime_type = params.mime_type;
|
|
523
400
|
if (params.sort_field) queryParams.sort_field = params.sort_field;
|
|
524
|
-
if (params.sort_direction)
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
params
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
`/v1/stores/${params.store_id}/oauth/connect`,
|
|
533
|
-
{ provider: params.provider, code: params.code, redirect_uri: params.redirect_uri },
|
|
534
|
-
options
|
|
535
|
-
);
|
|
536
|
-
},
|
|
537
|
-
async oauthDisconnect(params, options) {
|
|
538
|
-
return apiConfig.httpClient.post(
|
|
539
|
-
`/v1/stores/${params.store_id}/oauth/disconnect`,
|
|
540
|
-
{ provider: params.provider },
|
|
541
|
-
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
|
+
}
|
|
542
409
|
);
|
|
543
410
|
},
|
|
544
|
-
async
|
|
411
|
+
async listBuildHooks(params, options) {
|
|
545
412
|
return apiConfig.httpClient.get(
|
|
546
|
-
`/v1/stores/${params.store_id}/
|
|
413
|
+
`/v1/stores/${params.store_id}/build-hooks`,
|
|
547
414
|
options
|
|
548
415
|
);
|
|
549
416
|
},
|
|
550
|
-
async
|
|
417
|
+
async createBuildHook(params, options) {
|
|
551
418
|
const { store_id, ...payload } = params;
|
|
552
419
|
return apiConfig.httpClient.post(
|
|
553
|
-
`/v1/stores/${store_id}/
|
|
420
|
+
`/v1/stores/${store_id}/build-hooks`,
|
|
554
421
|
payload,
|
|
555
422
|
options
|
|
556
423
|
);
|
|
557
424
|
},
|
|
558
|
-
async
|
|
425
|
+
async updateBuildHook(params, options) {
|
|
559
426
|
const { store_id, id, ...payload } = params;
|
|
560
427
|
return apiConfig.httpClient.put(
|
|
561
|
-
`/v1/stores/${store_id}/
|
|
428
|
+
`/v1/stores/${store_id}/build-hooks/${id}`,
|
|
562
429
|
payload,
|
|
563
430
|
options
|
|
564
431
|
);
|
|
565
432
|
},
|
|
566
|
-
async
|
|
433
|
+
async deleteBuildHook(params, options) {
|
|
567
434
|
return apiConfig.httpClient.delete(
|
|
568
|
-
`/v1/stores/${params.store_id}/
|
|
435
|
+
`/v1/stores/${params.store_id}/build-hooks/${params.id}`,
|
|
569
436
|
options
|
|
570
437
|
);
|
|
571
438
|
},
|
|
572
|
-
async
|
|
439
|
+
async getStoreConfig(params, options) {
|
|
573
440
|
return apiConfig.httpClient.get(
|
|
574
|
-
`/v1/stores/${params.store_id}/
|
|
441
|
+
`/v1/stores/${params.store_id}/config/${params.type}`,
|
|
575
442
|
options
|
|
576
443
|
);
|
|
577
444
|
},
|
|
@@ -616,7 +483,7 @@ var createMediaApi = (apiConfig) => {
|
|
|
616
483
|
options
|
|
617
484
|
);
|
|
618
485
|
},
|
|
619
|
-
async uploadStoreMedia(params,
|
|
486
|
+
async uploadStoreMedia(params, options) {
|
|
620
487
|
const { store_id, files = [], urls = [] } = params;
|
|
621
488
|
const target_store_id = store_id || apiConfig.storeId;
|
|
622
489
|
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
@@ -629,7 +496,8 @@ var createMediaApi = (apiConfig) => {
|
|
|
629
496
|
body: formData,
|
|
630
497
|
headers: {
|
|
631
498
|
Authorization: `Bearer ${tokens?.access_token || ""}`
|
|
632
|
-
}
|
|
499
|
+
},
|
|
500
|
+
signal: options?.signal
|
|
633
501
|
});
|
|
634
502
|
if (!response.ok) {
|
|
635
503
|
throw new Error("Upload failed, server said no");
|
|
@@ -643,7 +511,7 @@ var createMediaApi = (apiConfig) => {
|
|
|
643
511
|
options
|
|
644
512
|
);
|
|
645
513
|
},
|
|
646
|
-
async getStoreMedia(params,
|
|
514
|
+
async getStoreMedia(params, options) {
|
|
647
515
|
const { store_id, cursor, limit, ids, query, mime_type, sort_field, sort_direction } = params;
|
|
648
516
|
const target_store_id = store_id || apiConfig.storeId;
|
|
649
517
|
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
@@ -659,7 +527,8 @@ var createMediaApi = (apiConfig) => {
|
|
|
659
527
|
const response = await fetch(`${url}?${queryString}`, {
|
|
660
528
|
headers: {
|
|
661
529
|
Authorization: `Bearer ${tokens?.access_token || ""}`
|
|
662
|
-
}
|
|
530
|
+
},
|
|
531
|
+
signal: options?.signal
|
|
663
532
|
});
|
|
664
533
|
if (!response.ok) {
|
|
665
534
|
const errorData = await response.json().catch(() => null);
|
|
@@ -747,77 +616,97 @@ var createPromoCodeApi = (apiConfig) => {
|
|
|
747
616
|
// src/api/cms.ts
|
|
748
617
|
var createCmsApi = (apiConfig) => {
|
|
749
618
|
return {
|
|
750
|
-
async
|
|
619
|
+
async createCollection(params, options) {
|
|
751
620
|
const { store_id, ...payload } = params;
|
|
752
621
|
const target_store_id = store_id || apiConfig.storeId;
|
|
753
622
|
return apiConfig.httpClient.post(
|
|
754
|
-
`/v1/stores/${target_store_id}/
|
|
623
|
+
`/v1/stores/${target_store_id}/collections`,
|
|
755
624
|
payload,
|
|
756
625
|
options
|
|
757
626
|
);
|
|
758
627
|
},
|
|
759
|
-
async
|
|
628
|
+
async updateCollection(params, options) {
|
|
760
629
|
const { store_id, ...payload } = params;
|
|
761
630
|
const target_store_id = store_id || apiConfig.storeId;
|
|
762
631
|
return apiConfig.httpClient.put(
|
|
763
|
-
`/v1/stores/${target_store_id}/
|
|
632
|
+
`/v1/stores/${target_store_id}/collections/${params.id}`,
|
|
764
633
|
payload,
|
|
765
634
|
options
|
|
766
635
|
);
|
|
767
636
|
},
|
|
768
|
-
async
|
|
637
|
+
async deleteCollection(params, options) {
|
|
769
638
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
770
639
|
return apiConfig.httpClient.delete(
|
|
771
|
-
`/v1/stores/${target_store_id}/
|
|
640
|
+
`/v1/stores/${target_store_id}/collections/${params.id}`,
|
|
772
641
|
options
|
|
773
642
|
);
|
|
774
643
|
},
|
|
775
|
-
async
|
|
644
|
+
async getCollection(params, options) {
|
|
776
645
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
777
646
|
let identifier;
|
|
778
647
|
if (params.id) {
|
|
779
648
|
identifier = params.id;
|
|
780
|
-
} else if (params.slug) {
|
|
781
|
-
identifier = `${target_store_id}:${apiConfig.locale}:${params.slug}`;
|
|
782
649
|
} else if (params.key) {
|
|
783
650
|
identifier = `${target_store_id}:${params.key}`;
|
|
784
651
|
} else {
|
|
785
|
-
throw new Error("
|
|
652
|
+
throw new Error("GetCollectionParams requires id or key");
|
|
786
653
|
}
|
|
787
|
-
|
|
788
|
-
`/v1/stores/${target_store_id}/
|
|
654
|
+
return apiConfig.httpClient.get(
|
|
655
|
+
`/v1/stores/${target_store_id}/collections/${identifier}`,
|
|
789
656
|
options
|
|
790
657
|
);
|
|
791
|
-
return {
|
|
792
|
-
...response,
|
|
793
|
-
getBlock(key) {
|
|
794
|
-
return getBlockFromArray(response, key, apiConfig.locale);
|
|
795
|
-
},
|
|
796
|
-
getBlockValues(key) {
|
|
797
|
-
return getBlockObjectValues(response, key, apiConfig.locale);
|
|
798
|
-
},
|
|
799
|
-
getImage(key) {
|
|
800
|
-
const block = getBlockFromArray(response, key, apiConfig.locale);
|
|
801
|
-
return getImageUrl(block, true);
|
|
802
|
-
}
|
|
803
|
-
};
|
|
804
658
|
},
|
|
805
|
-
async
|
|
659
|
+
async getCollections(params = {}, options) {
|
|
806
660
|
const { store_id, ...queryParams } = params;
|
|
807
661
|
const target_store_id = store_id || apiConfig.storeId;
|
|
808
662
|
return apiConfig.httpClient.get(
|
|
809
|
-
`/v1/stores/${target_store_id}/
|
|
663
|
+
`/v1/stores/${target_store_id}/collections`,
|
|
810
664
|
{
|
|
811
665
|
...options,
|
|
812
666
|
params: queryParams
|
|
813
667
|
}
|
|
814
668
|
);
|
|
815
669
|
},
|
|
816
|
-
async
|
|
817
|
-
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;
|
|
818
707
|
const target_store_id = store_id || apiConfig.storeId;
|
|
819
708
|
return apiConfig.httpClient.get(
|
|
820
|
-
`/v1/stores/${target_store_id}/
|
|
709
|
+
`/v1/stores/${target_store_id}/entries`,
|
|
821
710
|
{
|
|
822
711
|
...options,
|
|
823
712
|
params: queryParams
|
|
@@ -828,13 +717,6 @@ var createCmsApi = (apiConfig) => {
|
|
|
828
717
|
};
|
|
829
718
|
|
|
830
719
|
// src/api/eshop.ts
|
|
831
|
-
var normalizeTaxonomyAliases = (payload) => {
|
|
832
|
-
const { filters, ...rest } = payload;
|
|
833
|
-
return {
|
|
834
|
-
...rest,
|
|
835
|
-
...!rest.taxonomies && filters ? { taxonomies: filters } : {}
|
|
836
|
-
};
|
|
837
|
-
};
|
|
838
720
|
var createEshopApi = (apiConfig) => {
|
|
839
721
|
return {
|
|
840
722
|
async createProduct(params, options) {
|
|
@@ -842,7 +724,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
842
724
|
const target_store_id = store_id || apiConfig.storeId;
|
|
843
725
|
return apiConfig.httpClient.post(
|
|
844
726
|
`/v1/stores/${target_store_id}/products`,
|
|
845
|
-
|
|
727
|
+
payload,
|
|
846
728
|
options
|
|
847
729
|
);
|
|
848
730
|
},
|
|
@@ -851,7 +733,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
851
733
|
const target_store_id = store_id || apiConfig.storeId;
|
|
852
734
|
return apiConfig.httpClient.put(
|
|
853
735
|
`/v1/stores/${target_store_id}/products/${params.id}`,
|
|
854
|
-
|
|
736
|
+
payload,
|
|
855
737
|
options
|
|
856
738
|
);
|
|
857
739
|
},
|
|
@@ -893,7 +775,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
893
775
|
const target_store_id = store_id || apiConfig.storeId;
|
|
894
776
|
return apiConfig.httpClient.post(
|
|
895
777
|
`/v1/stores/${target_store_id}/services`,
|
|
896
|
-
|
|
778
|
+
payload,
|
|
897
779
|
options
|
|
898
780
|
);
|
|
899
781
|
},
|
|
@@ -902,7 +784,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
902
784
|
const target_store_id = store_id || apiConfig.storeId;
|
|
903
785
|
return apiConfig.httpClient.put(
|
|
904
786
|
`/v1/stores/${target_store_id}/services/${params.id}`,
|
|
905
|
-
|
|
787
|
+
payload,
|
|
906
788
|
options
|
|
907
789
|
);
|
|
908
790
|
},
|
|
@@ -952,7 +834,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
952
834
|
const target_store_id = store_id || apiConfig.storeId;
|
|
953
835
|
return apiConfig.httpClient.post(
|
|
954
836
|
`/v1/stores/${target_store_id}/providers`,
|
|
955
|
-
|
|
837
|
+
payload,
|
|
956
838
|
options
|
|
957
839
|
);
|
|
958
840
|
},
|
|
@@ -961,7 +843,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
961
843
|
const target_store_id = store_id || apiConfig.storeId;
|
|
962
844
|
return apiConfig.httpClient.put(
|
|
963
845
|
`/v1/stores/${target_store_id}/providers/${params.id}`,
|
|
964
|
-
|
|
846
|
+
payload,
|
|
965
847
|
options
|
|
966
848
|
);
|
|
967
849
|
},
|
|
@@ -1176,6 +1058,14 @@ var createEshopApi = (apiConfig) => {
|
|
|
1176
1058
|
{ amount: params.amount },
|
|
1177
1059
|
options
|
|
1178
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
|
+
);
|
|
1179
1069
|
}
|
|
1180
1070
|
};
|
|
1181
1071
|
};
|
|
@@ -1266,45 +1156,46 @@ var createMarketApi = (apiConfig) => {
|
|
|
1266
1156
|
};
|
|
1267
1157
|
|
|
1268
1158
|
// src/api/crm.ts
|
|
1269
|
-
var
|
|
1159
|
+
var createActionAdminApi = (apiConfig) => ({
|
|
1270
1160
|
async timeline(params, options) {
|
|
1271
1161
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1272
|
-
const queryParams = {
|
|
1162
|
+
const queryParams = { contact_id: params.contact_id };
|
|
1273
1163
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1274
1164
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1275
1165
|
return apiConfig.httpClient.get(
|
|
1276
|
-
`/v1/stores/${store_id}/
|
|
1166
|
+
`/v1/stores/${store_id}/contacts/${params.contact_id}/actions`,
|
|
1277
1167
|
{ ...options, params: queryParams }
|
|
1278
1168
|
);
|
|
1279
1169
|
},
|
|
1280
1170
|
async find(params, options) {
|
|
1281
1171
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1282
1172
|
const queryParams = {};
|
|
1283
|
-
if (params.
|
|
1173
|
+
if (params.query) queryParams.query = params.query;
|
|
1174
|
+
if (params.contact_id) queryParams.contact_id = params.contact_id;
|
|
1284
1175
|
if (params.types && params.types.length > 0) queryParams.types = params.types;
|
|
1285
1176
|
if (params.from !== void 0) queryParams.from = params.from;
|
|
1286
1177
|
if (params.to !== void 0) queryParams.to = params.to;
|
|
1287
1178
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1288
1179
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1289
1180
|
return apiConfig.httpClient.get(
|
|
1290
|
-
`/v1/stores/${store_id}/
|
|
1181
|
+
`/v1/stores/${store_id}/actions`,
|
|
1291
1182
|
{ ...options, params: queryParams }
|
|
1292
1183
|
);
|
|
1293
1184
|
}
|
|
1294
1185
|
});
|
|
1295
|
-
var
|
|
1186
|
+
var createContactApi = (apiConfig) => {
|
|
1296
1187
|
return {
|
|
1297
1188
|
async create(params, options) {
|
|
1298
1189
|
const { store_id, ...payload } = params;
|
|
1299
1190
|
return apiConfig.httpClient.post(
|
|
1300
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1191
|
+
`/v1/stores/${store_id || apiConfig.storeId}/contacts`,
|
|
1301
1192
|
payload,
|
|
1302
1193
|
options
|
|
1303
1194
|
);
|
|
1304
1195
|
},
|
|
1305
1196
|
async get(params, options) {
|
|
1306
1197
|
return apiConfig.httpClient.get(
|
|
1307
|
-
`/v1/stores/${params.store_id || apiConfig.storeId}/
|
|
1198
|
+
`/v1/stores/${params.store_id || apiConfig.storeId}/contacts/${params.id}`,
|
|
1308
1199
|
options
|
|
1309
1200
|
);
|
|
1310
1201
|
},
|
|
@@ -1317,22 +1208,32 @@ var createProfileApi = (apiConfig) => {
|
|
|
1317
1208
|
if (params?.query) queryParams.query = params.query;
|
|
1318
1209
|
if (params?.taxonomy_query) queryParams.taxonomy_query = params.taxonomy_query;
|
|
1319
1210
|
if (params?.status) queryParams.status = params.status;
|
|
1320
|
-
if (params?.
|
|
1211
|
+
if (params?.has_action !== void 0) queryParams.has_action = params.has_action;
|
|
1321
1212
|
if (params?.has_cart !== void 0) queryParams.has_cart = params.has_cart;
|
|
1322
1213
|
if (params?.sort_field) queryParams.sort_field = params.sort_field;
|
|
1323
1214
|
if (params?.sort_direction) queryParams.sort_direction = params.sort_direction;
|
|
1324
1215
|
return apiConfig.httpClient.get(
|
|
1325
|
-
`/v1/stores/${store_id}/
|
|
1216
|
+
`/v1/stores/${store_id}/contacts`,
|
|
1326
1217
|
{
|
|
1327
1218
|
...options,
|
|
1328
1219
|
params: queryParams
|
|
1329
1220
|
}
|
|
1330
1221
|
);
|
|
1331
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
|
+
},
|
|
1332
1233
|
async update(params, options) {
|
|
1333
1234
|
const { id, store_id, ...body } = params;
|
|
1334
1235
|
return apiConfig.httpClient.put(
|
|
1335
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1236
|
+
`/v1/stores/${store_id || apiConfig.storeId}/contacts/${id}`,
|
|
1336
1237
|
body,
|
|
1337
1238
|
options
|
|
1338
1239
|
);
|
|
@@ -1340,7 +1241,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1340
1241
|
async merge(params, options) {
|
|
1341
1242
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1342
1243
|
return apiConfig.httpClient.post(
|
|
1343
|
-
`/v1/stores/${store_id}/
|
|
1244
|
+
`/v1/stores/${store_id}/contacts/${params.target_id}/merge`,
|
|
1344
1245
|
{ source_id: params.source_id, store_id },
|
|
1345
1246
|
options
|
|
1346
1247
|
);
|
|
@@ -1349,7 +1250,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1349
1250
|
const { store_id, ...payload } = params;
|
|
1350
1251
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1351
1252
|
return apiConfig.httpClient.post(
|
|
1352
|
-
`/v1/stores/${target_store_id}/
|
|
1253
|
+
`/v1/stores/${target_store_id}/contacts/import`,
|
|
1353
1254
|
payload,
|
|
1354
1255
|
options
|
|
1355
1256
|
);
|
|
@@ -1358,7 +1259,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1358
1259
|
const { store_id, ...payload } = params;
|
|
1359
1260
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1360
1261
|
return apiConfig.httpClient.post(
|
|
1361
|
-
`/v1/stores/${target_store_id}/
|
|
1262
|
+
`/v1/stores/${target_store_id}/contacts/import/preview`,
|
|
1362
1263
|
payload,
|
|
1363
1264
|
options
|
|
1364
1265
|
);
|
|
@@ -1366,23 +1267,23 @@ var createProfileApi = (apiConfig) => {
|
|
|
1366
1267
|
async revokeToken(params, options) {
|
|
1367
1268
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1368
1269
|
return apiConfig.httpClient.delete(
|
|
1369
|
-
`/v1/stores/${store_id}/
|
|
1270
|
+
`/v1/stores/${store_id}/contacts/${params.id}/sessions/${params.token_id}`,
|
|
1370
1271
|
options
|
|
1371
1272
|
);
|
|
1372
1273
|
},
|
|
1373
1274
|
async revokeAllTokens(params, options) {
|
|
1374
1275
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1375
1276
|
return apiConfig.httpClient.delete(
|
|
1376
|
-
`/v1/stores/${store_id}/
|
|
1277
|
+
`/v1/stores/${store_id}/contacts/${params.id}/sessions`,
|
|
1377
1278
|
options
|
|
1378
1279
|
);
|
|
1379
1280
|
},
|
|
1380
|
-
|
|
1281
|
+
contactList: {
|
|
1381
1282
|
async create(params, options) {
|
|
1382
1283
|
const { store_id, ...payload } = params;
|
|
1383
1284
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1384
1285
|
return apiConfig.httpClient.post(
|
|
1385
|
-
`/v1/stores/${target_store_id}/
|
|
1286
|
+
`/v1/stores/${target_store_id}/contact-lists`,
|
|
1386
1287
|
payload,
|
|
1387
1288
|
options
|
|
1388
1289
|
);
|
|
@@ -1391,7 +1292,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1391
1292
|
const { id, store_id, ...payload } = params;
|
|
1392
1293
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1393
1294
|
return apiConfig.httpClient.put(
|
|
1394
|
-
`/v1/stores/${target_store_id}/
|
|
1295
|
+
`/v1/stores/${target_store_id}/contact-lists/${id}`,
|
|
1395
1296
|
payload,
|
|
1396
1297
|
options
|
|
1397
1298
|
);
|
|
@@ -1399,7 +1300,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1399
1300
|
async get(params, options) {
|
|
1400
1301
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1401
1302
|
return apiConfig.httpClient.get(
|
|
1402
|
-
`/v1/stores/${target_store_id}/
|
|
1303
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.id}`,
|
|
1403
1304
|
options
|
|
1404
1305
|
);
|
|
1405
1306
|
},
|
|
@@ -1407,79 +1308,43 @@ var createProfileApi = (apiConfig) => {
|
|
|
1407
1308
|
const { store_id, ...queryParams } = params || {};
|
|
1408
1309
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1409
1310
|
return apiConfig.httpClient.get(
|
|
1410
|
-
`/v1/stores/${target_store_id}/
|
|
1311
|
+
`/v1/stores/${target_store_id}/contact-lists`,
|
|
1411
1312
|
{ ...options, params: queryParams }
|
|
1412
1313
|
);
|
|
1413
1314
|
},
|
|
1414
|
-
async
|
|
1415
|
-
const { store_id,
|
|
1315
|
+
async importContacts(params, options) {
|
|
1316
|
+
const { store_id, contact_list_id, ...payload } = params;
|
|
1416
1317
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1417
1318
|
return apiConfig.httpClient.post(
|
|
1418
|
-
`/v1/stores/${target_store_id}/
|
|
1319
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/import`,
|
|
1419
1320
|
payload,
|
|
1420
1321
|
options
|
|
1421
1322
|
);
|
|
1422
1323
|
},
|
|
1423
|
-
async
|
|
1424
|
-
const { store_id,
|
|
1324
|
+
async previewImportContacts(params, options) {
|
|
1325
|
+
const { store_id, contact_list_id, ...payload } = params;
|
|
1425
1326
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1426
1327
|
return apiConfig.httpClient.post(
|
|
1427
|
-
`/v1/stores/${target_store_id}/
|
|
1328
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/import/preview`,
|
|
1428
1329
|
payload,
|
|
1429
1330
|
options
|
|
1430
1331
|
);
|
|
1431
1332
|
},
|
|
1432
1333
|
members: {
|
|
1433
1334
|
async add(params, options) {
|
|
1434
|
-
const { store_id,
|
|
1435
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1436
|
-
return apiConfig.httpClient.post(
|
|
1437
|
-
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
|
|
1438
|
-
{ fields, lead_description },
|
|
1439
|
-
options
|
|
1440
|
-
);
|
|
1441
|
-
},
|
|
1442
|
-
async update(params, options) {
|
|
1443
|
-
const { store_id, profile_list_id, profile_id, status, fields, lead_description } = params;
|
|
1444
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1445
|
-
return apiConfig.httpClient.patch(
|
|
1446
|
-
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
|
|
1447
|
-
{ status, fields, lead_description },
|
|
1448
|
-
options
|
|
1449
|
-
);
|
|
1450
|
-
},
|
|
1451
|
-
async remove(params, options) {
|
|
1452
|
-
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1453
|
-
return apiConfig.httpClient.delete(
|
|
1454
|
-
`/v1/stores/${target_store_id}/profile-lists/${params.profile_list_id}/members/${params.profile_id}`,
|
|
1455
|
-
options
|
|
1456
|
-
);
|
|
1457
|
-
},
|
|
1458
|
-
async find(params, options) {
|
|
1459
|
-
const { store_id, profile_list_id, ...queryParams } = params;
|
|
1460
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1461
|
-
const path = profile_list_id ? `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members` : `/v1/stores/${target_store_id}/profile-list-members`;
|
|
1462
|
-
return apiConfig.httpClient.get(
|
|
1463
|
-
path,
|
|
1464
|
-
{ ...options, params: queryParams }
|
|
1465
|
-
);
|
|
1466
|
-
}
|
|
1467
|
-
},
|
|
1468
|
-
profiles: {
|
|
1469
|
-
async add(params, options) {
|
|
1470
|
-
const { store_id, profile_list_id, profile_id, fields, lead_description } = params;
|
|
1335
|
+
const { store_id, contact_list_id, contact_id, fields, lead_description } = params;
|
|
1471
1336
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1472
1337
|
return apiConfig.httpClient.post(
|
|
1473
|
-
`/v1/stores/${target_store_id}/
|
|
1338
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/${contact_id}`,
|
|
1474
1339
|
{ fields, lead_description },
|
|
1475
1340
|
options
|
|
1476
1341
|
);
|
|
1477
1342
|
},
|
|
1478
1343
|
async update(params, options) {
|
|
1479
|
-
const { store_id,
|
|
1344
|
+
const { store_id, contact_list_id, contact_id, status, fields, lead_description } = params;
|
|
1480
1345
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1481
1346
|
return apiConfig.httpClient.patch(
|
|
1482
|
-
`/v1/stores/${target_store_id}/
|
|
1347
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/${contact_id}`,
|
|
1483
1348
|
{ status, fields, lead_description },
|
|
1484
1349
|
options
|
|
1485
1350
|
);
|
|
@@ -1487,14 +1352,17 @@ var createProfileApi = (apiConfig) => {
|
|
|
1487
1352
|
async remove(params, options) {
|
|
1488
1353
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1489
1354
|
return apiConfig.httpClient.delete(
|
|
1490
|
-
`/v1/stores/${target_store_id}/
|
|
1355
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/contacts/${params.contact_id}`,
|
|
1491
1356
|
options
|
|
1492
1357
|
);
|
|
1493
1358
|
},
|
|
1494
1359
|
async find(params, options) {
|
|
1495
|
-
const { store_id,
|
|
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
|
+
}
|
|
1496
1364
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1497
|
-
const path =
|
|
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`;
|
|
1498
1366
|
return apiConfig.httpClient.get(
|
|
1499
1367
|
path,
|
|
1500
1368
|
{ ...options, params: queryParams }
|
|
@@ -1611,11 +1479,11 @@ var createProfileApi = (apiConfig) => {
|
|
|
1611
1479
|
options
|
|
1612
1480
|
);
|
|
1613
1481
|
},
|
|
1614
|
-
async
|
|
1482
|
+
async importEnrollments(params, options) {
|
|
1615
1483
|
const { id, store_id, ...payload } = params;
|
|
1616
1484
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1617
1485
|
return apiConfig.httpClient.post(
|
|
1618
|
-
`/v1/stores/${target_store_id}/campaigns/${id}/
|
|
1486
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/enrollments/import`,
|
|
1619
1487
|
payload,
|
|
1620
1488
|
options
|
|
1621
1489
|
);
|
|
@@ -1630,12 +1498,12 @@ var createProfileApi = (apiConfig) => {
|
|
|
1630
1498
|
);
|
|
1631
1499
|
}
|
|
1632
1500
|
},
|
|
1633
|
-
|
|
1501
|
+
campaignEnrollment: {
|
|
1634
1502
|
async find(params, options) {
|
|
1635
1503
|
const { store_id, ...queryParams } = params || {};
|
|
1636
1504
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1637
1505
|
return apiConfig.httpClient.get(
|
|
1638
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1506
|
+
`/v1/stores/${target_store_id}/campaign-enrollments`,
|
|
1639
1507
|
{ ...options, params: queryParams }
|
|
1640
1508
|
);
|
|
1641
1509
|
},
|
|
@@ -1643,7 +1511,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1643
1511
|
const { store_id, id, ...queryParams } = params;
|
|
1644
1512
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1645
1513
|
return apiConfig.httpClient.get(
|
|
1646
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1514
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}`,
|
|
1647
1515
|
{ ...options, params: { ...queryParams, store_id: target_store_id } }
|
|
1648
1516
|
);
|
|
1649
1517
|
},
|
|
@@ -1651,7 +1519,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1651
1519
|
const { store_id, id, ...payload } = params;
|
|
1652
1520
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1653
1521
|
return apiConfig.httpClient.put(
|
|
1654
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1522
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}`,
|
|
1655
1523
|
payload,
|
|
1656
1524
|
options
|
|
1657
1525
|
);
|
|
@@ -1660,7 +1528,16 @@ var createProfileApi = (apiConfig) => {
|
|
|
1660
1528
|
const { store_id, id, draft_id, ...payload } = params;
|
|
1661
1529
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1662
1530
|
return apiConfig.httpClient.put(
|
|
1663
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
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}`,
|
|
1664
1541
|
payload,
|
|
1665
1542
|
options
|
|
1666
1543
|
);
|
|
@@ -1669,7 +1546,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1669
1546
|
const { store_id, id, ...payload } = params;
|
|
1670
1547
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1671
1548
|
return apiConfig.httpClient.post(
|
|
1672
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1549
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/reply`,
|
|
1673
1550
|
payload,
|
|
1674
1551
|
options
|
|
1675
1552
|
);
|
|
@@ -1678,7 +1555,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1678
1555
|
const { store_id, id, ...payload } = params;
|
|
1679
1556
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1680
1557
|
return apiConfig.httpClient.post(
|
|
1681
|
-
`/v1/stores/${target_store_id}/campaign-
|
|
1558
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/stop`,
|
|
1682
1559
|
payload,
|
|
1683
1560
|
options
|
|
1684
1561
|
);
|
|
@@ -1738,7 +1615,7 @@ var createProfileApi = (apiConfig) => {
|
|
|
1738
1615
|
);
|
|
1739
1616
|
}
|
|
1740
1617
|
},
|
|
1741
|
-
|
|
1618
|
+
action: createActionAdminApi(apiConfig)
|
|
1742
1619
|
};
|
|
1743
1620
|
};
|
|
1744
1621
|
|
|
@@ -1796,6 +1673,7 @@ function createAdminSupportApi(config) {
|
|
|
1796
1673
|
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
1797
1674
|
if (params.status) qs.set("status", params.status);
|
|
1798
1675
|
if (params.agent_id) qs.set("agent_id", params.agent_id);
|
|
1676
|
+
if (params.query) qs.set("query", params.query);
|
|
1799
1677
|
if (params.limit) qs.set("limit", String(params.limit));
|
|
1800
1678
|
if (params.cursor) qs.set("cursor", params.cursor);
|
|
1801
1679
|
return httpClient.get(
|
|
@@ -1908,23 +1786,212 @@ var createLeadResearchApi = (apiConfig) => {
|
|
|
1908
1786
|
};
|
|
1909
1787
|
};
|
|
1910
1788
|
|
|
1911
|
-
// src/api/
|
|
1912
|
-
var
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
const
|
|
1917
|
-
return apiConfig.httpClient.
|
|
1918
|
-
`/v1/stores/${
|
|
1919
|
-
{
|
|
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}`,
|
|
1920
1806
|
options
|
|
1921
1807
|
);
|
|
1922
1808
|
},
|
|
1923
|
-
async
|
|
1924
|
-
const { store_id,
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
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;
|
|
1992
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1993
|
+
return apiConfig.httpClient.put(
|
|
1994
|
+
`/v1/stores/${target_store_id}/workflows/${id}`,
|
|
1928
1995
|
payload,
|
|
1929
1996
|
options
|
|
1930
1997
|
);
|
|
@@ -1946,14 +2013,21 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1946
2013
|
async getWorkflows(params, options) {
|
|
1947
2014
|
const store_id = params?.store_id || apiConfig.storeId;
|
|
1948
2015
|
const { store_id: _, ...queryParams } = params || {};
|
|
1949
|
-
return apiConfig.httpClient.get(
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
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
|
+
);
|
|
1953
2023
|
},
|
|
1954
2024
|
async triggerWorkflow(params, options) {
|
|
1955
2025
|
const { secret, ...payload } = params;
|
|
1956
|
-
return apiConfig.httpClient.post(
|
|
2026
|
+
return apiConfig.httpClient.post(
|
|
2027
|
+
`/v1/workflows/trigger/${secret}`,
|
|
2028
|
+
payload,
|
|
2029
|
+
options
|
|
2030
|
+
);
|
|
1957
2031
|
},
|
|
1958
2032
|
async getWorkflowExecutions(params, options) {
|
|
1959
2033
|
const store_id = params.store_id || apiConfig.storeId;
|
|
@@ -1972,6 +2046,38 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1972
2046
|
`/v1/stores/${store_id}/workflows/${params.workflow_id}/executions/${params.execution_id}`,
|
|
1973
2047
|
options
|
|
1974
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
|
+
);
|
|
1975
2081
|
}
|
|
1976
2082
|
};
|
|
1977
2083
|
};
|
|
@@ -1982,8 +2088,8 @@ var createPlatformApi = (apiConfig) => {
|
|
|
1982
2088
|
async getCurrencies(options) {
|
|
1983
2089
|
return apiConfig.httpClient.get("/v1/platform/currencies", options);
|
|
1984
2090
|
},
|
|
1985
|
-
async
|
|
1986
|
-
return apiConfig.httpClient.get("/v1/platform/
|
|
2091
|
+
async getWorkflowTools(options) {
|
|
2092
|
+
return apiConfig.httpClient.get("/v1/platform/workflow-tools", options);
|
|
1987
2093
|
},
|
|
1988
2094
|
async getWebhookEvents(options) {
|
|
1989
2095
|
return apiConfig.httpClient.get("/v1/platform/events", options);
|
|
@@ -2033,6 +2139,40 @@ var createShippingApi = (apiConfig) => {
|
|
|
2033
2139
|
};
|
|
2034
2140
|
};
|
|
2035
2141
|
|
|
2142
|
+
// src/api/paymentProvider.ts
|
|
2143
|
+
var createPaymentProviderApi = (apiConfig) => {
|
|
2144
|
+
const storeId = (store_id) => store_id || apiConfig.storeId;
|
|
2145
|
+
return {
|
|
2146
|
+
async list(params, options) {
|
|
2147
|
+
return apiConfig.httpClient.get(
|
|
2148
|
+
`/v1/stores/${storeId(params?.store_id)}/payment-providers`,
|
|
2149
|
+
options
|
|
2150
|
+
);
|
|
2151
|
+
},
|
|
2152
|
+
async refresh(params, options) {
|
|
2153
|
+
const targetStoreId = storeId(params?.store_id);
|
|
2154
|
+
return apiConfig.httpClient.post(
|
|
2155
|
+
`/v1/stores/${targetStoreId}/payment-providers/refresh`,
|
|
2156
|
+
{ store_id: targetStoreId },
|
|
2157
|
+
options
|
|
2158
|
+
);
|
|
2159
|
+
},
|
|
2160
|
+
async connectStripe(params, options) {
|
|
2161
|
+
return apiConfig.httpClient.post(
|
|
2162
|
+
`/v1/stores/${storeId(params.store_id)}/payment-providers/stripe/connect`,
|
|
2163
|
+
params,
|
|
2164
|
+
options
|
|
2165
|
+
);
|
|
2166
|
+
},
|
|
2167
|
+
async delete(params, options) {
|
|
2168
|
+
return apiConfig.httpClient.delete(
|
|
2169
|
+
`/v1/stores/${storeId(params.store_id)}/payment-providers/${params.id}`,
|
|
2170
|
+
options
|
|
2171
|
+
);
|
|
2172
|
+
}
|
|
2173
|
+
};
|
|
2174
|
+
};
|
|
2175
|
+
|
|
2036
2176
|
// src/api/emailTemplate.ts
|
|
2037
2177
|
var createEmailTemplateApi = (apiConfig) => {
|
|
2038
2178
|
return {
|
|
@@ -2268,6 +2408,164 @@ var createAnalyticsApi = (apiConfig) => {
|
|
|
2268
2408
|
};
|
|
2269
2409
|
};
|
|
2270
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
|
+
|
|
2271
2569
|
// src/utils/price.ts
|
|
2272
2570
|
function formatCurrency(amount, currencyCode, locale = "en") {
|
|
2273
2571
|
if (!currencyCode) return "";
|
|
@@ -2648,63 +2946,142 @@ function createAdmin(config) {
|
|
|
2648
2946
|
const cmsApi = createCmsApi(apiConfig);
|
|
2649
2947
|
const eshopApi = createEshopApi(apiConfig);
|
|
2650
2948
|
const promoCodeApi = createPromoCodeApi(apiConfig);
|
|
2651
|
-
const crmApi =
|
|
2949
|
+
const crmApi = createContactApi(apiConfig);
|
|
2652
2950
|
const supportApi = createAdminSupportApi(apiConfig);
|
|
2653
2951
|
const leadResearchApi = createLeadResearchApi(apiConfig);
|
|
2654
|
-
const
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
get: leadResearchApi.getRun,
|
|
2659
|
-
update: leadResearchApi.updateRun,
|
|
2660
|
-
cancel: leadResearchApi.cancelRun,
|
|
2661
|
-
sendMessage: leadResearchApi.sendMessage,
|
|
2662
|
-
findMessages: leadResearchApi.findMessages
|
|
2663
|
-
},
|
|
2664
|
-
message: {
|
|
2665
|
-
send: leadResearchApi.sendMessage,
|
|
2666
|
-
find: leadResearchApi.findMessages
|
|
2667
|
-
},
|
|
2668
|
-
email: {
|
|
2669
|
-
validate: leadResearchApi.validateEmail
|
|
2670
|
-
},
|
|
2671
|
-
createRun: leadResearchApi.createRun,
|
|
2672
|
-
findRuns: leadResearchApi.findRuns,
|
|
2673
|
-
getRun: leadResearchApi.getRun,
|
|
2674
|
-
updateRun: leadResearchApi.updateRun,
|
|
2675
|
-
cancelRun: leadResearchApi.cancelRun,
|
|
2676
|
-
sendMessage: leadResearchApi.sendMessage,
|
|
2677
|
-
findMessages: leadResearchApi.findMessages,
|
|
2678
|
-
validateEmail: leadResearchApi.validateEmail
|
|
2679
|
-
};
|
|
2952
|
+
const socialApi = createSocialApi(apiConfig);
|
|
2953
|
+
const paymentProviderApi = createPaymentProviderApi(apiConfig);
|
|
2954
|
+
const notificationApi = createNotificationApi(apiConfig);
|
|
2955
|
+
const shippingApi = createShippingApi(apiConfig);
|
|
2680
2956
|
const locationApi = createLocationApi(apiConfig);
|
|
2681
2957
|
const marketApi = createMarketApi(apiConfig);
|
|
2682
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
|
+
};
|
|
2683
2979
|
const formApi = createFormApi(apiConfig);
|
|
2684
2980
|
const taxonomyApi = createTaxonomyApi(apiConfig);
|
|
2685
2981
|
const emailTemplateApi = createEmailTemplateApi(apiConfig);
|
|
2686
2982
|
const analyticsApi = createAnalyticsApi(apiConfig);
|
|
2983
|
+
const experimentsApi = createExperimentsApi(apiConfig);
|
|
2687
2984
|
const sdk = {
|
|
2688
|
-
|
|
2689
|
-
|
|
2985
|
+
account: {
|
|
2986
|
+
update: accountApi.updateAccount,
|
|
2987
|
+
delete: accountApi.deleteAccount,
|
|
2988
|
+
getMe: accountApi.getMe,
|
|
2989
|
+
search: accountApi.searchAccounts,
|
|
2990
|
+
auth: authApi
|
|
2991
|
+
},
|
|
2690
2992
|
store: {
|
|
2691
|
-
|
|
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
|
+
},
|
|
2692
3027
|
location: locationApi,
|
|
2693
|
-
market: marketApi
|
|
3028
|
+
market: marketApi,
|
|
3029
|
+
paymentProvider: storePaymentProviderApi
|
|
2694
3030
|
},
|
|
2695
3031
|
media: createMediaApi(apiConfig),
|
|
2696
|
-
notification:
|
|
2697
|
-
|
|
3032
|
+
notification: {
|
|
3033
|
+
email: {
|
|
3034
|
+
trackOpen: notificationApi.trackEmailOpen
|
|
3035
|
+
},
|
|
3036
|
+
trigger: {
|
|
3037
|
+
send: notificationApi.trigger
|
|
3038
|
+
},
|
|
3039
|
+
mailbox: crmApi.mailbox
|
|
3040
|
+
},
|
|
2698
3041
|
platform: platformApi,
|
|
2699
|
-
|
|
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
|
+
},
|
|
2700
3071
|
cms: {
|
|
2701
|
-
|
|
2702
|
-
create: cmsApi.
|
|
2703
|
-
update: cmsApi.
|
|
2704
|
-
delete: cmsApi.
|
|
2705
|
-
get: cmsApi.
|
|
2706
|
-
find: cmsApi.
|
|
2707
|
-
|
|
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
|
|
2708
3085
|
},
|
|
2709
3086
|
form: {
|
|
2710
3087
|
create: formApi.createForm,
|
|
@@ -2747,7 +3124,10 @@ function createAdmin(config) {
|
|
|
2747
3124
|
get: eshopApi.getOrder,
|
|
2748
3125
|
find: eshopApi.getOrders,
|
|
2749
3126
|
getQuote: eshopApi.getQuote,
|
|
2750
|
-
processRefund: eshopApi.processRefund
|
|
3127
|
+
processRefund: eshopApi.processRefund,
|
|
3128
|
+
downloadDigitalAccess: eshopApi.downloadDigitalAccess,
|
|
3129
|
+
getShippingRates: shippingApi.getRates,
|
|
3130
|
+
ship: shippingApi.ship
|
|
2751
3131
|
},
|
|
2752
3132
|
cart: {
|
|
2753
3133
|
create: eshopApi.createCart,
|
|
@@ -2782,7 +3162,7 @@ function createAdmin(config) {
|
|
|
2782
3162
|
promoCode: promoCodeApi
|
|
2783
3163
|
},
|
|
2784
3164
|
crm: {
|
|
2785
|
-
|
|
3165
|
+
contact: {
|
|
2786
3166
|
create: crmApi.create,
|
|
2787
3167
|
get: crmApi.get,
|
|
2788
3168
|
find: crmApi.find,
|
|
@@ -2792,30 +3172,45 @@ function createAdmin(config) {
|
|
|
2792
3172
|
revokeToken: crmApi.revokeToken,
|
|
2793
3173
|
revokeAllTokens: crmApi.revokeAllTokens
|
|
2794
3174
|
},
|
|
2795
|
-
|
|
2796
|
-
|
|
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
|
|
3186
|
+
},
|
|
3187
|
+
action: crmApi.action
|
|
3188
|
+
},
|
|
3189
|
+
outreach: {
|
|
2797
3190
|
campaign: crmApi.campaign,
|
|
2798
|
-
|
|
3191
|
+
campaignEnrollment: crmApi.campaignEnrollment,
|
|
2799
3192
|
campaignMessage: crmApi.campaignMessage,
|
|
2800
3193
|
suppression: crmApi.suppression,
|
|
2801
|
-
leadResearch
|
|
2802
|
-
activity: crmApi.activity
|
|
3194
|
+
leadResearch: leadResearchApi
|
|
2803
3195
|
},
|
|
2804
|
-
leadResearch,
|
|
2805
3196
|
automation: {
|
|
2806
|
-
workflow:
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
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
|
|
3210
|
+
}
|
|
2817
3211
|
},
|
|
2818
3212
|
analytics: analyticsApi,
|
|
3213
|
+
experiments: experimentsApi,
|
|
2819
3214
|
setStoreId: (storeId) => {
|
|
2820
3215
|
apiConfig.storeId = storeId;
|
|
2821
3216
|
},
|
|
@@ -2851,7 +3246,6 @@ function createAdmin(config) {
|
|
|
2851
3246
|
if (config.apiToken) return;
|
|
2852
3247
|
updateSession(() => null);
|
|
2853
3248
|
},
|
|
2854
|
-
extractBlockValues,
|
|
2855
3249
|
utils: createUtilitySurface(apiConfig)
|
|
2856
3250
|
};
|
|
2857
3251
|
return sdk;
|