arky-sdk 0.9.0 → 0.9.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -194
- package/dist/admin-BKXmDIVk.d.ts +1396 -0
- package/dist/admin-CAwQrMOX.d.cts +1396 -0
- package/dist/admin.cjs +1239 -455
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.d.cts +3 -3
- package/dist/admin.d.ts +3 -3
- package/dist/admin.js +1239 -455
- package/dist/admin.js.map +1 -1
- package/dist/api-DJI3S6XA.d.cts +4204 -0
- package/dist/api-DJI3S6XA.d.ts +4204 -0
- package/dist/{index-C5gikdBg.d.cts → index-BaSBPLdF.d.ts} +1 -1
- package/dist/{index-MFMjlIfS.d.ts → index-u-gjHnKs.d.cts} +1 -1
- package/dist/index.cjs +1360 -610
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1360 -610
- package/dist/index.js.map +1 -1
- package/dist/storefront.cjs +590 -382
- package/dist/storefront.cjs.map +1 -1
- package/dist/storefront.d.cts +182 -156
- package/dist/storefront.d.ts +182 -156
- package/dist/storefront.js +588 -381
- package/dist/storefront.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -2666
- package/dist/types.d.ts +1 -2666
- package/dist/types.js.map +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +9 -11
- package/scripts/contract-admin.mjs +137 -0
- package/scripts/contract-storefront.mjs +296 -0
- package/dist/admin-CfHen7c5.d.cts +0 -1036
- package/dist/admin-ru7pX5bd.d.ts +0 -1036
- package/dist/storefront-store.cjs +0 -2794
- package/dist/storefront-store.cjs.map +0 -1
- package/dist/storefront-store.d.cts +0 -5
- package/dist/storefront-store.d.ts +0 -5
- package/dist/storefront-store.js +0 -2792
- package/dist/storefront-store.js.map +0 -1
- package/scripts/smoke-store.mjs +0 -41
package/dist/admin.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,15 +303,12 @@ 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
|
};
|
|
436
309
|
|
|
437
310
|
// src/api/store.ts
|
|
438
|
-
var createStoreApi = (apiConfig,
|
|
311
|
+
var createStoreApi = (apiConfig, _updateSession) => {
|
|
439
312
|
return {
|
|
440
313
|
async createStore(params, options) {
|
|
441
314
|
return apiConfig.httpClient.post(`/v1/stores`, params, options);
|
|
@@ -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
|
},
|
|
@@ -485,10 +361,19 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
485
361
|
options
|
|
486
362
|
);
|
|
487
363
|
},
|
|
364
|
+
async addMember(params, options) {
|
|
365
|
+
const { store_id, ...payload } = params;
|
|
366
|
+
return apiConfig.httpClient.post(
|
|
367
|
+
`/v1/stores/${store_id || apiConfig.storeId}/members`,
|
|
368
|
+
payload,
|
|
369
|
+
options
|
|
370
|
+
);
|
|
371
|
+
},
|
|
488
372
|
async inviteUser(params, options) {
|
|
373
|
+
const { store_id, ...payload } = params;
|
|
489
374
|
return apiConfig.httpClient.post(
|
|
490
|
-
`/v1/stores/${apiConfig.storeId}/
|
|
491
|
-
|
|
375
|
+
`/v1/stores/${store_id || apiConfig.storeId}/members`,
|
|
376
|
+
payload,
|
|
492
377
|
options
|
|
493
378
|
);
|
|
494
379
|
},
|
|
@@ -498,22 +383,6 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
498
383
|
options
|
|
499
384
|
);
|
|
500
385
|
},
|
|
501
|
-
async handleInvitation(params, options) {
|
|
502
|
-
const { store_id, ...payload } = params;
|
|
503
|
-
const result = await apiConfig.httpClient.put(
|
|
504
|
-
`/v1/stores/${store_id || apiConfig.storeId}/invitation`,
|
|
505
|
-
payload,
|
|
506
|
-
options
|
|
507
|
-
);
|
|
508
|
-
if (params.action === "accept" && result?.auth?.access_token) {
|
|
509
|
-
updateSession(() => ({
|
|
510
|
-
access_token: result.auth.access_token,
|
|
511
|
-
refresh_token: result.auth.refresh_token,
|
|
512
|
-
access_expires_at: result.auth.access_expires_at
|
|
513
|
-
}));
|
|
514
|
-
}
|
|
515
|
-
return result;
|
|
516
|
-
},
|
|
517
386
|
async testWebhook(params, options) {
|
|
518
387
|
return apiConfig.httpClient.post(
|
|
519
388
|
`/v1/stores/${apiConfig.storeId}/webhooks/test`,
|
|
@@ -526,61 +395,52 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
526
395
|
limit: params.limit
|
|
527
396
|
};
|
|
528
397
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
529
|
-
if (params.ids && params.ids.length > 0)
|
|
398
|
+
if (params.ids && params.ids.length > 0)
|
|
399
|
+
queryParams.ids = JSON.stringify(params.ids);
|
|
530
400
|
if (params.query) queryParams.query = params.query;
|
|
531
401
|
if (params.mime_type) queryParams.mime_type = params.mime_type;
|
|
532
402
|
if (params.sort_field) queryParams.sort_field = params.sort_field;
|
|
533
|
-
if (params.sort_direction)
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
params
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
`/v1/stores/${params.store_id}/oauth/connect`,
|
|
542
|
-
{ provider: params.provider, code: params.code, redirect_uri: params.redirect_uri },
|
|
543
|
-
options
|
|
544
|
-
);
|
|
545
|
-
},
|
|
546
|
-
async oauthDisconnect(params, options) {
|
|
547
|
-
return apiConfig.httpClient.post(
|
|
548
|
-
`/v1/stores/${params.store_id}/oauth/disconnect`,
|
|
549
|
-
{ provider: params.provider },
|
|
550
|
-
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
|
+
}
|
|
551
411
|
);
|
|
552
412
|
},
|
|
553
|
-
async
|
|
413
|
+
async listBuildHooks(params, options) {
|
|
554
414
|
return apiConfig.httpClient.get(
|
|
555
|
-
`/v1/stores/${params.store_id}/
|
|
415
|
+
`/v1/stores/${params.store_id}/build-hooks`,
|
|
556
416
|
options
|
|
557
417
|
);
|
|
558
418
|
},
|
|
559
|
-
async
|
|
419
|
+
async createBuildHook(params, options) {
|
|
560
420
|
const { store_id, ...payload } = params;
|
|
561
421
|
return apiConfig.httpClient.post(
|
|
562
|
-
`/v1/stores/${store_id}/
|
|
422
|
+
`/v1/stores/${store_id}/build-hooks`,
|
|
563
423
|
payload,
|
|
564
424
|
options
|
|
565
425
|
);
|
|
566
426
|
},
|
|
567
|
-
async
|
|
427
|
+
async updateBuildHook(params, options) {
|
|
568
428
|
const { store_id, id, ...payload } = params;
|
|
569
429
|
return apiConfig.httpClient.put(
|
|
570
|
-
`/v1/stores/${store_id}/
|
|
430
|
+
`/v1/stores/${store_id}/build-hooks/${id}`,
|
|
571
431
|
payload,
|
|
572
432
|
options
|
|
573
433
|
);
|
|
574
434
|
},
|
|
575
|
-
async
|
|
435
|
+
async deleteBuildHook(params, options) {
|
|
576
436
|
return apiConfig.httpClient.delete(
|
|
577
|
-
`/v1/stores/${params.store_id}/
|
|
437
|
+
`/v1/stores/${params.store_id}/build-hooks/${params.id}`,
|
|
578
438
|
options
|
|
579
439
|
);
|
|
580
440
|
},
|
|
581
|
-
async
|
|
441
|
+
async getStoreConfig(params, options) {
|
|
582
442
|
return apiConfig.httpClient.get(
|
|
583
|
-
`/v1/stores/${params.store_id}/
|
|
443
|
+
`/v1/stores/${params.store_id}/config/${params.type}`,
|
|
584
444
|
options
|
|
585
445
|
);
|
|
586
446
|
},
|
|
@@ -625,7 +485,7 @@ var createMediaApi = (apiConfig) => {
|
|
|
625
485
|
options
|
|
626
486
|
);
|
|
627
487
|
},
|
|
628
|
-
async uploadStoreMedia(params,
|
|
488
|
+
async uploadStoreMedia(params, options) {
|
|
629
489
|
const { store_id, files = [], urls = [] } = params;
|
|
630
490
|
const target_store_id = store_id || apiConfig.storeId;
|
|
631
491
|
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
@@ -638,7 +498,8 @@ var createMediaApi = (apiConfig) => {
|
|
|
638
498
|
body: formData,
|
|
639
499
|
headers: {
|
|
640
500
|
Authorization: `Bearer ${tokens?.access_token || ""}`
|
|
641
|
-
}
|
|
501
|
+
},
|
|
502
|
+
signal: options?.signal
|
|
642
503
|
});
|
|
643
504
|
if (!response.ok) {
|
|
644
505
|
throw new Error("Upload failed, server said no");
|
|
@@ -652,13 +513,13 @@ var createMediaApi = (apiConfig) => {
|
|
|
652
513
|
options
|
|
653
514
|
);
|
|
654
515
|
},
|
|
655
|
-
async getStoreMedia(params,
|
|
516
|
+
async getStoreMedia(params, options) {
|
|
656
517
|
const { store_id, cursor, limit, ids, query, mime_type, sort_field, sort_direction } = params;
|
|
657
518
|
const target_store_id = store_id || apiConfig.storeId;
|
|
658
519
|
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
659
520
|
const queryParams = { limit: String(limit) };
|
|
660
521
|
if (cursor) queryParams.cursor = cursor;
|
|
661
|
-
if (ids && ids.length > 0) queryParams.ids =
|
|
522
|
+
if (ids && ids.length > 0) queryParams.ids = JSON.stringify(ids);
|
|
662
523
|
if (query) queryParams.query = query;
|
|
663
524
|
if (mime_type) queryParams.mime_type = mime_type;
|
|
664
525
|
if (sort_field) queryParams.sort_field = sort_field;
|
|
@@ -668,7 +529,8 @@ var createMediaApi = (apiConfig) => {
|
|
|
668
529
|
const response = await fetch(`${url}?${queryString}`, {
|
|
669
530
|
headers: {
|
|
670
531
|
Authorization: `Bearer ${tokens?.access_token || ""}`
|
|
671
|
-
}
|
|
532
|
+
},
|
|
533
|
+
signal: options?.signal
|
|
672
534
|
});
|
|
673
535
|
if (!response.ok) {
|
|
674
536
|
const errorData = await response.json().catch(() => null);
|
|
@@ -756,77 +618,97 @@ var createPromoCodeApi = (apiConfig) => {
|
|
|
756
618
|
// src/api/cms.ts
|
|
757
619
|
var createCmsApi = (apiConfig) => {
|
|
758
620
|
return {
|
|
759
|
-
async
|
|
621
|
+
async createCollection(params, options) {
|
|
760
622
|
const { store_id, ...payload } = params;
|
|
761
623
|
const target_store_id = store_id || apiConfig.storeId;
|
|
762
624
|
return apiConfig.httpClient.post(
|
|
763
|
-
`/v1/stores/${target_store_id}/
|
|
625
|
+
`/v1/stores/${target_store_id}/collections`,
|
|
764
626
|
payload,
|
|
765
627
|
options
|
|
766
628
|
);
|
|
767
629
|
},
|
|
768
|
-
async
|
|
630
|
+
async updateCollection(params, options) {
|
|
769
631
|
const { store_id, ...payload } = params;
|
|
770
632
|
const target_store_id = store_id || apiConfig.storeId;
|
|
771
633
|
return apiConfig.httpClient.put(
|
|
772
|
-
`/v1/stores/${target_store_id}/
|
|
634
|
+
`/v1/stores/${target_store_id}/collections/${params.id}`,
|
|
773
635
|
payload,
|
|
774
636
|
options
|
|
775
637
|
);
|
|
776
638
|
},
|
|
777
|
-
async
|
|
639
|
+
async deleteCollection(params, options) {
|
|
778
640
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
779
641
|
return apiConfig.httpClient.delete(
|
|
780
|
-
`/v1/stores/${target_store_id}/
|
|
642
|
+
`/v1/stores/${target_store_id}/collections/${params.id}`,
|
|
781
643
|
options
|
|
782
644
|
);
|
|
783
645
|
},
|
|
784
|
-
async
|
|
646
|
+
async getCollection(params, options) {
|
|
785
647
|
const target_store_id = params.store_id || apiConfig.storeId;
|
|
786
648
|
let identifier;
|
|
787
649
|
if (params.id) {
|
|
788
650
|
identifier = params.id;
|
|
789
|
-
} else if (params.slug) {
|
|
790
|
-
identifier = `${target_store_id}:${apiConfig.locale}:${params.slug}`;
|
|
791
651
|
} else if (params.key) {
|
|
792
652
|
identifier = `${target_store_id}:${params.key}`;
|
|
793
653
|
} else {
|
|
794
|
-
throw new Error("
|
|
654
|
+
throw new Error("GetCollectionParams requires id or key");
|
|
795
655
|
}
|
|
796
|
-
|
|
797
|
-
`/v1/stores/${target_store_id}/
|
|
656
|
+
return apiConfig.httpClient.get(
|
|
657
|
+
`/v1/stores/${target_store_id}/collections/${identifier}`,
|
|
798
658
|
options
|
|
799
659
|
);
|
|
800
|
-
return {
|
|
801
|
-
...response,
|
|
802
|
-
getBlock(key) {
|
|
803
|
-
return getBlockFromArray(response, key, apiConfig.locale);
|
|
804
|
-
},
|
|
805
|
-
getBlockValues(key) {
|
|
806
|
-
return getBlockObjectValues(response, key, apiConfig.locale);
|
|
807
|
-
},
|
|
808
|
-
getImage(key) {
|
|
809
|
-
const block = getBlockFromArray(response, key, apiConfig.locale);
|
|
810
|
-
return getImageUrl(block, true);
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
660
|
},
|
|
814
|
-
async
|
|
661
|
+
async getCollections(params = {}, options) {
|
|
815
662
|
const { store_id, ...queryParams } = params;
|
|
816
663
|
const target_store_id = store_id || apiConfig.storeId;
|
|
817
664
|
return apiConfig.httpClient.get(
|
|
818
|
-
`/v1/stores/${target_store_id}/
|
|
665
|
+
`/v1/stores/${target_store_id}/collections`,
|
|
819
666
|
{
|
|
820
667
|
...options,
|
|
821
668
|
params: queryParams
|
|
822
669
|
}
|
|
823
670
|
);
|
|
824
671
|
},
|
|
825
|
-
async
|
|
826
|
-
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;
|
|
827
709
|
const target_store_id = store_id || apiConfig.storeId;
|
|
828
710
|
return apiConfig.httpClient.get(
|
|
829
|
-
`/v1/stores/${target_store_id}/
|
|
711
|
+
`/v1/stores/${target_store_id}/entries`,
|
|
830
712
|
{
|
|
831
713
|
...options,
|
|
832
714
|
params: queryParams
|
|
@@ -837,13 +719,6 @@ var createCmsApi = (apiConfig) => {
|
|
|
837
719
|
};
|
|
838
720
|
|
|
839
721
|
// src/api/eshop.ts
|
|
840
|
-
var normalizeTaxonomyAliases = (payload) => {
|
|
841
|
-
const { filters, ...rest } = payload;
|
|
842
|
-
return {
|
|
843
|
-
...rest,
|
|
844
|
-
...!rest.taxonomies && filters ? { taxonomies: filters } : {}
|
|
845
|
-
};
|
|
846
|
-
};
|
|
847
722
|
var createEshopApi = (apiConfig) => {
|
|
848
723
|
return {
|
|
849
724
|
async createProduct(params, options) {
|
|
@@ -851,7 +726,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
851
726
|
const target_store_id = store_id || apiConfig.storeId;
|
|
852
727
|
return apiConfig.httpClient.post(
|
|
853
728
|
`/v1/stores/${target_store_id}/products`,
|
|
854
|
-
|
|
729
|
+
payload,
|
|
855
730
|
options
|
|
856
731
|
);
|
|
857
732
|
},
|
|
@@ -860,7 +735,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
860
735
|
const target_store_id = store_id || apiConfig.storeId;
|
|
861
736
|
return apiConfig.httpClient.put(
|
|
862
737
|
`/v1/stores/${target_store_id}/products/${params.id}`,
|
|
863
|
-
|
|
738
|
+
payload,
|
|
864
739
|
options
|
|
865
740
|
);
|
|
866
741
|
},
|
|
@@ -902,7 +777,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
902
777
|
const target_store_id = store_id || apiConfig.storeId;
|
|
903
778
|
return apiConfig.httpClient.post(
|
|
904
779
|
`/v1/stores/${target_store_id}/services`,
|
|
905
|
-
|
|
780
|
+
payload,
|
|
906
781
|
options
|
|
907
782
|
);
|
|
908
783
|
},
|
|
@@ -911,7 +786,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
911
786
|
const target_store_id = store_id || apiConfig.storeId;
|
|
912
787
|
return apiConfig.httpClient.put(
|
|
913
788
|
`/v1/stores/${target_store_id}/services/${params.id}`,
|
|
914
|
-
|
|
789
|
+
payload,
|
|
915
790
|
options
|
|
916
791
|
);
|
|
917
792
|
},
|
|
@@ -961,7 +836,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
961
836
|
const target_store_id = store_id || apiConfig.storeId;
|
|
962
837
|
return apiConfig.httpClient.post(
|
|
963
838
|
`/v1/stores/${target_store_id}/providers`,
|
|
964
|
-
|
|
839
|
+
payload,
|
|
965
840
|
options
|
|
966
841
|
);
|
|
967
842
|
},
|
|
@@ -970,7 +845,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
970
845
|
const target_store_id = store_id || apiConfig.storeId;
|
|
971
846
|
return apiConfig.httpClient.put(
|
|
972
847
|
`/v1/stores/${target_store_id}/providers/${params.id}`,
|
|
973
|
-
|
|
848
|
+
payload,
|
|
974
849
|
options
|
|
975
850
|
);
|
|
976
851
|
},
|
|
@@ -1185,6 +1060,14 @@ var createEshopApi = (apiConfig) => {
|
|
|
1185
1060
|
{ amount: params.amount },
|
|
1186
1061
|
options
|
|
1187
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
|
+
);
|
|
1188
1071
|
}
|
|
1189
1072
|
};
|
|
1190
1073
|
};
|
|
@@ -1275,72 +1158,84 @@ var createMarketApi = (apiConfig) => {
|
|
|
1275
1158
|
};
|
|
1276
1159
|
|
|
1277
1160
|
// src/api/crm.ts
|
|
1278
|
-
var
|
|
1161
|
+
var createActionAdminApi = (apiConfig) => ({
|
|
1279
1162
|
async timeline(params, options) {
|
|
1280
1163
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1281
|
-
const queryParams = {
|
|
1164
|
+
const queryParams = { contact_id: params.contact_id };
|
|
1282
1165
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1283
1166
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1284
1167
|
return apiConfig.httpClient.get(
|
|
1285
|
-
`/v1/stores/${store_id}/
|
|
1168
|
+
`/v1/stores/${store_id}/contacts/${params.contact_id}/actions`,
|
|
1286
1169
|
{ ...options, params: queryParams }
|
|
1287
1170
|
);
|
|
1288
1171
|
},
|
|
1289
1172
|
async find(params, options) {
|
|
1290
1173
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1291
1174
|
const queryParams = {};
|
|
1292
|
-
if (params.
|
|
1175
|
+
if (params.query) queryParams.query = params.query;
|
|
1176
|
+
if (params.contact_id) queryParams.contact_id = params.contact_id;
|
|
1293
1177
|
if (params.types && params.types.length > 0) queryParams.types = params.types;
|
|
1294
1178
|
if (params.from !== void 0) queryParams.from = params.from;
|
|
1295
1179
|
if (params.to !== void 0) queryParams.to = params.to;
|
|
1296
1180
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1297
1181
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1298
1182
|
return apiConfig.httpClient.get(
|
|
1299
|
-
`/v1/stores/${store_id}/
|
|
1183
|
+
`/v1/stores/${store_id}/actions`,
|
|
1300
1184
|
{ ...options, params: queryParams }
|
|
1301
1185
|
);
|
|
1302
1186
|
}
|
|
1303
1187
|
});
|
|
1304
|
-
var
|
|
1188
|
+
var createContactApi = (apiConfig) => {
|
|
1305
1189
|
return {
|
|
1306
1190
|
async create(params, options) {
|
|
1307
1191
|
const { store_id, ...payload } = params;
|
|
1308
1192
|
return apiConfig.httpClient.post(
|
|
1309
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1193
|
+
`/v1/stores/${store_id || apiConfig.storeId}/contacts`,
|
|
1310
1194
|
payload,
|
|
1311
1195
|
options
|
|
1312
1196
|
);
|
|
1313
1197
|
},
|
|
1314
1198
|
async get(params, options) {
|
|
1315
1199
|
return apiConfig.httpClient.get(
|
|
1316
|
-
`/v1/stores/${params.store_id || apiConfig.storeId}/
|
|
1200
|
+
`/v1/stores/${params.store_id || apiConfig.storeId}/contacts/${params.id}`,
|
|
1317
1201
|
options
|
|
1318
1202
|
);
|
|
1319
1203
|
},
|
|
1320
1204
|
async find(params, options) {
|
|
1321
1205
|
const store_id = params?.store_id || apiConfig.storeId;
|
|
1322
1206
|
const queryParams = {};
|
|
1207
|
+
if (params?.ids && params.ids.length > 0) queryParams.ids = JSON.stringify(params.ids);
|
|
1323
1208
|
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
1324
1209
|
if (params?.cursor) queryParams.cursor = params.cursor;
|
|
1325
1210
|
if (params?.query) queryParams.query = params.query;
|
|
1326
1211
|
if (params?.taxonomy_query) queryParams.taxonomy_query = params.taxonomy_query;
|
|
1327
1212
|
if (params?.status) queryParams.status = params.status;
|
|
1328
|
-
if (params?.
|
|
1213
|
+
if (params?.has_action !== void 0) queryParams.has_action = params.has_action;
|
|
1329
1214
|
if (params?.has_cart !== void 0) queryParams.has_cart = params.has_cart;
|
|
1330
1215
|
if (params?.sort_field) queryParams.sort_field = params.sort_field;
|
|
1331
1216
|
if (params?.sort_direction) queryParams.sort_direction = params.sort_direction;
|
|
1332
1217
|
return apiConfig.httpClient.get(
|
|
1333
|
-
`/v1/stores/${store_id}/
|
|
1218
|
+
`/v1/stores/${store_id}/contacts`,
|
|
1334
1219
|
{
|
|
1335
1220
|
...options,
|
|
1336
1221
|
params: queryParams
|
|
1337
1222
|
}
|
|
1338
1223
|
);
|
|
1339
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
|
+
},
|
|
1340
1235
|
async update(params, options) {
|
|
1341
1236
|
const { id, store_id, ...body } = params;
|
|
1342
1237
|
return apiConfig.httpClient.put(
|
|
1343
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1238
|
+
`/v1/stores/${store_id || apiConfig.storeId}/contacts/${id}`,
|
|
1344
1239
|
body,
|
|
1345
1240
|
options
|
|
1346
1241
|
);
|
|
@@ -1348,101 +1243,754 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1348
1243
|
async merge(params, options) {
|
|
1349
1244
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1350
1245
|
return apiConfig.httpClient.post(
|
|
1351
|
-
`/v1/stores/${store_id}/
|
|
1246
|
+
`/v1/stores/${store_id}/contacts/${params.target_id}/merge`,
|
|
1352
1247
|
{ source_id: params.source_id, store_id },
|
|
1353
1248
|
options
|
|
1354
1249
|
);
|
|
1355
1250
|
},
|
|
1251
|
+
"import": async (params, options) => {
|
|
1252
|
+
const { store_id, ...payload } = params;
|
|
1253
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1254
|
+
return apiConfig.httpClient.post(
|
|
1255
|
+
`/v1/stores/${target_store_id}/contacts/import`,
|
|
1256
|
+
payload,
|
|
1257
|
+
options
|
|
1258
|
+
);
|
|
1259
|
+
},
|
|
1260
|
+
previewImport: async (params, options) => {
|
|
1261
|
+
const { store_id, ...payload } = params;
|
|
1262
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1263
|
+
return apiConfig.httpClient.post(
|
|
1264
|
+
`/v1/stores/${target_store_id}/contacts/import/preview`,
|
|
1265
|
+
payload,
|
|
1266
|
+
options
|
|
1267
|
+
);
|
|
1268
|
+
},
|
|
1356
1269
|
async revokeToken(params, options) {
|
|
1357
1270
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1358
1271
|
return apiConfig.httpClient.delete(
|
|
1359
|
-
`/v1/stores/${store_id}/
|
|
1272
|
+
`/v1/stores/${store_id}/contacts/${params.id}/sessions/${params.token_id}`,
|
|
1360
1273
|
options
|
|
1361
1274
|
);
|
|
1362
1275
|
},
|
|
1363
1276
|
async revokeAllTokens(params, options) {
|
|
1364
1277
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1365
1278
|
return apiConfig.httpClient.delete(
|
|
1366
|
-
`/v1/stores/${store_id}/
|
|
1279
|
+
`/v1/stores/${store_id}/contacts/${params.id}/sessions`,
|
|
1367
1280
|
options
|
|
1368
1281
|
);
|
|
1369
1282
|
},
|
|
1370
|
-
|
|
1283
|
+
contactList: {
|
|
1371
1284
|
async create(params, options) {
|
|
1285
|
+
const { store_id, ...payload } = params;
|
|
1286
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1372
1287
|
return apiConfig.httpClient.post(
|
|
1373
|
-
`/v1/stores/${
|
|
1374
|
-
|
|
1288
|
+
`/v1/stores/${target_store_id}/contact-lists`,
|
|
1289
|
+
payload,
|
|
1375
1290
|
options
|
|
1376
1291
|
);
|
|
1377
1292
|
},
|
|
1378
1293
|
async update(params, options) {
|
|
1294
|
+
const { id, store_id, ...payload } = params;
|
|
1295
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1379
1296
|
return apiConfig.httpClient.put(
|
|
1380
|
-
`/v1/stores/${
|
|
1381
|
-
|
|
1297
|
+
`/v1/stores/${target_store_id}/contact-lists/${id}`,
|
|
1298
|
+
payload,
|
|
1382
1299
|
options
|
|
1383
1300
|
);
|
|
1384
1301
|
},
|
|
1385
1302
|
async get(params, options) {
|
|
1386
|
-
|
|
1387
|
-
if (params.id) {
|
|
1388
|
-
identifier = params.id;
|
|
1389
|
-
} else if (params.key) {
|
|
1390
|
-
identifier = `${apiConfig.storeId}:${params.key}`;
|
|
1391
|
-
} else {
|
|
1392
|
-
throw new Error("GetAudienceParams requires id or key");
|
|
1393
|
-
}
|
|
1303
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1394
1304
|
return apiConfig.httpClient.get(
|
|
1395
|
-
`/v1/stores/${
|
|
1305
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.id}`,
|
|
1396
1306
|
options
|
|
1397
1307
|
);
|
|
1398
1308
|
},
|
|
1399
1309
|
async find(params, options) {
|
|
1310
|
+
const { store_id, ...queryParams } = params || {};
|
|
1311
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1400
1312
|
return apiConfig.httpClient.get(
|
|
1401
|
-
`/v1/stores/${
|
|
1402
|
-
{ ...options, params }
|
|
1403
|
-
);
|
|
1404
|
-
},
|
|
1405
|
-
async getSubscribers(params, options) {
|
|
1406
|
-
return apiConfig.httpClient.get(
|
|
1407
|
-
`/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers`,
|
|
1408
|
-
{
|
|
1409
|
-
...options,
|
|
1410
|
-
params: { limit: params.limit, cursor: params.cursor }
|
|
1411
|
-
}
|
|
1313
|
+
`/v1/stores/${target_store_id}/contact-lists`,
|
|
1314
|
+
{ ...options, params: queryParams }
|
|
1412
1315
|
);
|
|
1413
1316
|
},
|
|
1414
|
-
async
|
|
1317
|
+
async importContacts(params, options) {
|
|
1318
|
+
const { store_id, contact_list_id, ...payload } = params;
|
|
1319
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1415
1320
|
return apiConfig.httpClient.post(
|
|
1416
|
-
`/v1/stores/${
|
|
1417
|
-
|
|
1321
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/import`,
|
|
1322
|
+
payload,
|
|
1418
1323
|
options
|
|
1419
1324
|
);
|
|
1420
1325
|
},
|
|
1421
|
-
async
|
|
1422
|
-
|
|
1423
|
-
|
|
1326
|
+
async previewImportContacts(params, options) {
|
|
1327
|
+
const { store_id, contact_list_id, ...payload } = params;
|
|
1328
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1329
|
+
return apiConfig.httpClient.post(
|
|
1330
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/import/preview`,
|
|
1331
|
+
payload,
|
|
1424
1332
|
options
|
|
1425
1333
|
);
|
|
1334
|
+
},
|
|
1335
|
+
members: {
|
|
1336
|
+
async add(params, options) {
|
|
1337
|
+
const { store_id, contact_list_id, contact_id, fields, lead_description } = params;
|
|
1338
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1339
|
+
return apiConfig.httpClient.post(
|
|
1340
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/${contact_id}`,
|
|
1341
|
+
{ fields, lead_description },
|
|
1342
|
+
options
|
|
1343
|
+
);
|
|
1344
|
+
},
|
|
1345
|
+
async update(params, options) {
|
|
1346
|
+
const { store_id, contact_list_id, contact_id, status, fields, lead_description } = params;
|
|
1347
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1348
|
+
return apiConfig.httpClient.patch(
|
|
1349
|
+
`/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/contacts/${contact_id}`,
|
|
1350
|
+
{ status, fields, lead_description },
|
|
1351
|
+
options
|
|
1352
|
+
);
|
|
1353
|
+
},
|
|
1354
|
+
async remove(params, options) {
|
|
1355
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1356
|
+
return apiConfig.httpClient.delete(
|
|
1357
|
+
`/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/contacts/${params.contact_id}`,
|
|
1358
|
+
options
|
|
1359
|
+
);
|
|
1360
|
+
},
|
|
1361
|
+
async find(params, options) {
|
|
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
|
+
}
|
|
1366
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
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`;
|
|
1368
|
+
return apiConfig.httpClient.get(
|
|
1369
|
+
path,
|
|
1370
|
+
{ ...options, params: queryParams }
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1426
1373
|
}
|
|
1427
1374
|
},
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
};
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1375
|
+
mailbox: {
|
|
1376
|
+
async create(params, options) {
|
|
1377
|
+
const { store_id, ...payload } = params;
|
|
1378
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1379
|
+
return apiConfig.httpClient.post(
|
|
1380
|
+
`/v1/stores/${target_store_id}/mailboxes`,
|
|
1381
|
+
payload,
|
|
1382
|
+
options
|
|
1383
|
+
);
|
|
1384
|
+
},
|
|
1385
|
+
async update(params, options) {
|
|
1386
|
+
const { id, store_id, ...payload } = params;
|
|
1387
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1388
|
+
return apiConfig.httpClient.put(
|
|
1389
|
+
`/v1/stores/${target_store_id}/mailboxes/${id}`,
|
|
1390
|
+
payload,
|
|
1391
|
+
options
|
|
1392
|
+
);
|
|
1393
|
+
},
|
|
1394
|
+
async get(params, options) {
|
|
1395
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1396
|
+
return apiConfig.httpClient.get(
|
|
1397
|
+
`/v1/stores/${target_store_id}/mailboxes/${params.id}`,
|
|
1398
|
+
options
|
|
1399
|
+
);
|
|
1400
|
+
},
|
|
1401
|
+
async test(params, options) {
|
|
1402
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1403
|
+
return apiConfig.httpClient.post(
|
|
1404
|
+
`/v1/stores/${target_store_id}/mailboxes/${params.id}/test`,
|
|
1405
|
+
{},
|
|
1406
|
+
options
|
|
1407
|
+
);
|
|
1408
|
+
},
|
|
1409
|
+
async prepare(params, options) {
|
|
1410
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1411
|
+
return apiConfig.httpClient.post(
|
|
1412
|
+
`/v1/stores/${target_store_id}/mailboxes/${params.id}/prepare`,
|
|
1413
|
+
{},
|
|
1414
|
+
options
|
|
1415
|
+
);
|
|
1416
|
+
},
|
|
1417
|
+
async find(params, options) {
|
|
1418
|
+
const { store_id, ...queryParams } = params || {};
|
|
1419
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1420
|
+
return apiConfig.httpClient.get(
|
|
1421
|
+
`/v1/stores/${target_store_id}/mailboxes`,
|
|
1422
|
+
{ ...options, params: queryParams }
|
|
1423
|
+
);
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
campaign: {
|
|
1427
|
+
async create(params, options) {
|
|
1428
|
+
const { store_id, ...payload } = params;
|
|
1429
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1430
|
+
return apiConfig.httpClient.post(
|
|
1431
|
+
`/v1/stores/${target_store_id}/campaigns`,
|
|
1432
|
+
payload,
|
|
1433
|
+
options
|
|
1434
|
+
);
|
|
1435
|
+
},
|
|
1436
|
+
async update(params, options) {
|
|
1437
|
+
const { id, store_id, ...payload } = params;
|
|
1438
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1439
|
+
return apiConfig.httpClient.put(
|
|
1440
|
+
`/v1/stores/${target_store_id}/campaigns/${id}`,
|
|
1441
|
+
payload,
|
|
1442
|
+
options
|
|
1443
|
+
);
|
|
1444
|
+
},
|
|
1445
|
+
async get(params, options) {
|
|
1446
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1447
|
+
return apiConfig.httpClient.get(
|
|
1448
|
+
`/v1/stores/${target_store_id}/campaigns/${params.id}`,
|
|
1449
|
+
options
|
|
1450
|
+
);
|
|
1451
|
+
},
|
|
1452
|
+
async find(params, options) {
|
|
1453
|
+
const { store_id, ...queryParams } = params || {};
|
|
1454
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1455
|
+
return apiConfig.httpClient.get(
|
|
1456
|
+
`/v1/stores/${target_store_id}/campaigns`,
|
|
1457
|
+
{ ...options, params: queryParams }
|
|
1458
|
+
);
|
|
1459
|
+
},
|
|
1460
|
+
async launch(params, options) {
|
|
1461
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1462
|
+
return apiConfig.httpClient.post(
|
|
1463
|
+
`/v1/stores/${target_store_id}/campaigns/${params.id}/launch`,
|
|
1464
|
+
{},
|
|
1465
|
+
options
|
|
1466
|
+
);
|
|
1467
|
+
},
|
|
1468
|
+
async duplicate(params, options) {
|
|
1469
|
+
const { id, store_id, ...payload } = params;
|
|
1470
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1471
|
+
return apiConfig.httpClient.post(
|
|
1472
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/duplicate`,
|
|
1473
|
+
payload,
|
|
1474
|
+
options
|
|
1475
|
+
);
|
|
1476
|
+
},
|
|
1477
|
+
async launchReadiness(params, options) {
|
|
1478
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1479
|
+
return apiConfig.httpClient.get(
|
|
1480
|
+
`/v1/stores/${target_store_id}/campaigns/${params.id}/launch-readiness`,
|
|
1481
|
+
options
|
|
1482
|
+
);
|
|
1483
|
+
},
|
|
1484
|
+
async importEnrollments(params, options) {
|
|
1485
|
+
const { id, store_id, ...payload } = params;
|
|
1486
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1487
|
+
return apiConfig.httpClient.post(
|
|
1488
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/enrollments/import`,
|
|
1489
|
+
payload,
|
|
1490
|
+
options
|
|
1491
|
+
);
|
|
1492
|
+
},
|
|
1493
|
+
async generatePersonalizedDrafts(params, options) {
|
|
1494
|
+
const { id, store_id, ...payload } = params;
|
|
1495
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1496
|
+
return apiConfig.httpClient.post(
|
|
1497
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/personalized-drafts`,
|
|
1498
|
+
payload,
|
|
1499
|
+
options
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
},
|
|
1503
|
+
campaignEnrollment: {
|
|
1504
|
+
async find(params, options) {
|
|
1505
|
+
const { store_id, ...queryParams } = params || {};
|
|
1506
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1507
|
+
return apiConfig.httpClient.get(
|
|
1508
|
+
`/v1/stores/${target_store_id}/campaign-enrollments`,
|
|
1509
|
+
{ ...options, params: queryParams }
|
|
1510
|
+
);
|
|
1511
|
+
},
|
|
1512
|
+
async get(params, options) {
|
|
1513
|
+
const { store_id, id, ...queryParams } = params;
|
|
1514
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1515
|
+
return apiConfig.httpClient.get(
|
|
1516
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}`,
|
|
1517
|
+
{ ...options, params: { ...queryParams, store_id: target_store_id } }
|
|
1518
|
+
);
|
|
1519
|
+
},
|
|
1520
|
+
async update(params, options) {
|
|
1521
|
+
const { store_id, id, ...payload } = params;
|
|
1522
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1523
|
+
return apiConfig.httpClient.put(
|
|
1524
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}`,
|
|
1525
|
+
payload,
|
|
1526
|
+
options
|
|
1527
|
+
);
|
|
1528
|
+
},
|
|
1529
|
+
async updateDraft(params, options) {
|
|
1530
|
+
const { store_id, id, draft_id, ...payload } = params;
|
|
1531
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1532
|
+
return apiConfig.httpClient.put(
|
|
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}`,
|
|
1543
|
+
payload,
|
|
1544
|
+
options
|
|
1545
|
+
);
|
|
1546
|
+
},
|
|
1547
|
+
async reply(params, options) {
|
|
1548
|
+
const { store_id, id, ...payload } = params;
|
|
1549
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1550
|
+
return apiConfig.httpClient.post(
|
|
1551
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/reply`,
|
|
1552
|
+
payload,
|
|
1553
|
+
options
|
|
1554
|
+
);
|
|
1555
|
+
},
|
|
1556
|
+
async stop(params, options) {
|
|
1557
|
+
const { store_id, id, ...payload } = params;
|
|
1558
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1559
|
+
return apiConfig.httpClient.post(
|
|
1560
|
+
`/v1/stores/${target_store_id}/campaign-enrollments/${id}/stop`,
|
|
1561
|
+
payload,
|
|
1562
|
+
options
|
|
1563
|
+
);
|
|
1564
|
+
}
|
|
1565
|
+
},
|
|
1566
|
+
campaignMessage: {
|
|
1567
|
+
async find(params, options) {
|
|
1568
|
+
const { store_id, ...queryParams } = params || {};
|
|
1569
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1570
|
+
return apiConfig.httpClient.get(
|
|
1571
|
+
`/v1/stores/${target_store_id}/campaign-messages`,
|
|
1572
|
+
{ ...options, params: queryParams }
|
|
1573
|
+
);
|
|
1574
|
+
},
|
|
1575
|
+
async update(params, options) {
|
|
1576
|
+
const { id, store_id, ...payload } = params;
|
|
1577
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1578
|
+
return apiConfig.httpClient.put(
|
|
1579
|
+
`/v1/stores/${target_store_id}/campaign-messages/${id}`,
|
|
1580
|
+
payload,
|
|
1581
|
+
options
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
},
|
|
1585
|
+
suppression: {
|
|
1586
|
+
async create(params, options) {
|
|
1587
|
+
const { store_id, ...payload } = params;
|
|
1588
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1589
|
+
return apiConfig.httpClient.post(
|
|
1590
|
+
`/v1/stores/${target_store_id}/suppressions`,
|
|
1591
|
+
payload,
|
|
1592
|
+
options
|
|
1593
|
+
);
|
|
1594
|
+
},
|
|
1595
|
+
async update(params, options) {
|
|
1596
|
+
const { id, store_id, ...payload } = params;
|
|
1597
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1598
|
+
return apiConfig.httpClient.put(
|
|
1599
|
+
`/v1/stores/${target_store_id}/suppressions/${id}`,
|
|
1600
|
+
payload,
|
|
1601
|
+
options
|
|
1602
|
+
);
|
|
1603
|
+
},
|
|
1604
|
+
async get(params, options) {
|
|
1605
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1606
|
+
return apiConfig.httpClient.get(
|
|
1607
|
+
`/v1/stores/${target_store_id}/suppressions/${params.id}`,
|
|
1608
|
+
options
|
|
1609
|
+
);
|
|
1610
|
+
},
|
|
1611
|
+
async find(params, options) {
|
|
1612
|
+
const { store_id, ...queryParams } = params || {};
|
|
1613
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1614
|
+
return apiConfig.httpClient.get(
|
|
1615
|
+
`/v1/stores/${target_store_id}/suppressions`,
|
|
1616
|
+
{ ...options, params: queryParams }
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
},
|
|
1620
|
+
action: createActionAdminApi(apiConfig)
|
|
1621
|
+
};
|
|
1622
|
+
};
|
|
1623
|
+
|
|
1624
|
+
// src/api/support.ts
|
|
1625
|
+
function supportConversationQuery(params) {
|
|
1626
|
+
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
1627
|
+
if (params.message_limit) qs.set("message_limit", String(params.message_limit));
|
|
1628
|
+
if (typeof params.after_created_at === "number") qs.set("after_created_at", String(params.after_created_at));
|
|
1629
|
+
if (params.after_id) qs.set("after_id", params.after_id);
|
|
1630
|
+
return qs.toString();
|
|
1631
|
+
}
|
|
1632
|
+
function createAdminSupportApi(config) {
|
|
1633
|
+
const { httpClient } = config;
|
|
1634
|
+
return {
|
|
1635
|
+
agent: {
|
|
1636
|
+
async create(params, opts) {
|
|
1637
|
+
return httpClient.post(
|
|
1638
|
+
`/v1/stores/${params.store_id}/support/agents`,
|
|
1639
|
+
params,
|
|
1640
|
+
opts
|
|
1641
|
+
);
|
|
1642
|
+
},
|
|
1643
|
+
async get(params, opts) {
|
|
1644
|
+
return httpClient.get(
|
|
1645
|
+
`/v1/stores/${params.store_id}/support/agents/${params.id}?store_id=${params.store_id}`,
|
|
1646
|
+
opts
|
|
1647
|
+
);
|
|
1648
|
+
},
|
|
1649
|
+
async find(params, opts) {
|
|
1650
|
+
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
1651
|
+
if (params.status) qs.set("status", params.status);
|
|
1652
|
+
if (params.limit) qs.set("limit", String(params.limit));
|
|
1653
|
+
if (params.cursor) qs.set("cursor", params.cursor);
|
|
1654
|
+
return httpClient.get(
|
|
1655
|
+
`/v1/stores/${params.store_id}/support/agents?${qs}`,
|
|
1656
|
+
opts
|
|
1657
|
+
);
|
|
1658
|
+
},
|
|
1659
|
+
async update(params, opts) {
|
|
1660
|
+
return httpClient.put(
|
|
1661
|
+
`/v1/stores/${params.store_id}/support/agents/${params.id}`,
|
|
1662
|
+
params,
|
|
1663
|
+
opts
|
|
1664
|
+
);
|
|
1665
|
+
},
|
|
1666
|
+
async delete(params, opts) {
|
|
1667
|
+
return httpClient.delete(
|
|
1668
|
+
`/v1/stores/${params.store_id}/support/agents/${params.id}?store_id=${params.store_id}`,
|
|
1669
|
+
opts
|
|
1670
|
+
);
|
|
1671
|
+
}
|
|
1672
|
+
},
|
|
1673
|
+
conversation: {
|
|
1674
|
+
async find(params, opts) {
|
|
1675
|
+
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
1676
|
+
if (params.status) qs.set("status", params.status);
|
|
1677
|
+
if (params.agent_id) qs.set("agent_id", params.agent_id);
|
|
1678
|
+
if (params.query) qs.set("query", params.query);
|
|
1679
|
+
if (params.limit) qs.set("limit", String(params.limit));
|
|
1680
|
+
if (params.cursor) qs.set("cursor", params.cursor);
|
|
1681
|
+
return httpClient.get(
|
|
1682
|
+
`/v1/stores/${params.store_id}/support/conversations?${qs}`,
|
|
1683
|
+
opts
|
|
1684
|
+
);
|
|
1685
|
+
},
|
|
1686
|
+
async get(params, opts) {
|
|
1687
|
+
const qs = supportConversationQuery(params);
|
|
1688
|
+
return httpClient.get(
|
|
1689
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}?${qs}`,
|
|
1690
|
+
opts
|
|
1691
|
+
);
|
|
1692
|
+
},
|
|
1693
|
+
async sendMessage(params, opts) {
|
|
1694
|
+
return httpClient.post(
|
|
1695
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/messages`,
|
|
1696
|
+
params,
|
|
1697
|
+
opts
|
|
1698
|
+
);
|
|
1699
|
+
},
|
|
1700
|
+
async reply(params, opts) {
|
|
1701
|
+
return httpClient.post(
|
|
1702
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/reply`,
|
|
1703
|
+
params,
|
|
1704
|
+
opts
|
|
1705
|
+
);
|
|
1706
|
+
},
|
|
1707
|
+
async resolve(params, opts) {
|
|
1708
|
+
return httpClient.post(
|
|
1709
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/resolve`,
|
|
1710
|
+
params,
|
|
1711
|
+
opts
|
|
1712
|
+
);
|
|
1713
|
+
},
|
|
1714
|
+
async assign(params, opts) {
|
|
1715
|
+
return httpClient.post(
|
|
1716
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/assign`,
|
|
1717
|
+
params,
|
|
1718
|
+
opts
|
|
1719
|
+
);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
// src/api/leadResearch.ts
|
|
1726
|
+
var createLeadResearchApi = (apiConfig) => {
|
|
1727
|
+
const storeId = (store_id) => store_id || apiConfig.storeId;
|
|
1728
|
+
return {
|
|
1729
|
+
async createRun(params, options) {
|
|
1730
|
+
const { store_id, ...payload } = params;
|
|
1731
|
+
return apiConfig.httpClient.post(
|
|
1732
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs`,
|
|
1733
|
+
payload,
|
|
1734
|
+
options
|
|
1735
|
+
);
|
|
1736
|
+
},
|
|
1737
|
+
async findRuns(params, options) {
|
|
1738
|
+
const { store_id, ...queryParams } = params || {};
|
|
1739
|
+
return apiConfig.httpClient.get(
|
|
1740
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs`,
|
|
1741
|
+
{ ...options, params: queryParams }
|
|
1742
|
+
);
|
|
1743
|
+
},
|
|
1744
|
+
async getRun(params, options) {
|
|
1745
|
+
return apiConfig.httpClient.get(
|
|
1746
|
+
`/v1/stores/${storeId(params.store_id)}/lead-research/runs/${params.id}`,
|
|
1747
|
+
options
|
|
1748
|
+
);
|
|
1749
|
+
},
|
|
1750
|
+
async updateRun(params, options) {
|
|
1751
|
+
const { store_id, id, ...payload } = params;
|
|
1752
|
+
return apiConfig.httpClient.patch(
|
|
1753
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs/${id}`,
|
|
1754
|
+
payload,
|
|
1755
|
+
options
|
|
1756
|
+
);
|
|
1757
|
+
},
|
|
1758
|
+
async cancelRun(params, options) {
|
|
1759
|
+
return apiConfig.httpClient.post(
|
|
1760
|
+
`/v1/stores/${storeId(params.store_id)}/lead-research/runs/${params.id}/cancel`,
|
|
1761
|
+
{},
|
|
1762
|
+
options
|
|
1763
|
+
);
|
|
1764
|
+
},
|
|
1765
|
+
async sendMessage(params, options) {
|
|
1766
|
+
const { store_id, run_id, ...payload } = params;
|
|
1767
|
+
return apiConfig.httpClient.post(
|
|
1768
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs/${run_id}/messages`,
|
|
1769
|
+
payload,
|
|
1770
|
+
options
|
|
1771
|
+
);
|
|
1772
|
+
},
|
|
1773
|
+
async findMessages(params, options) {
|
|
1774
|
+
const { store_id, run_id, ...queryParams } = params;
|
|
1775
|
+
return apiConfig.httpClient.get(
|
|
1776
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs/${run_id}/messages`,
|
|
1777
|
+
{ ...options, params: queryParams }
|
|
1778
|
+
);
|
|
1779
|
+
},
|
|
1780
|
+
async validateEmail(params, options) {
|
|
1781
|
+
const { store_id, ...payload } = params;
|
|
1782
|
+
return apiConfig.httpClient.post(
|
|
1783
|
+
`/v1/stores/${storeId(store_id)}/lead-research/validate-email`,
|
|
1784
|
+
payload,
|
|
1785
|
+
options
|
|
1786
|
+
);
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
};
|
|
1790
|
+
|
|
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}`,
|
|
1808
|
+
options
|
|
1809
|
+
);
|
|
1810
|
+
},
|
|
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;
|
|
1446
1994
|
const target_store_id = store_id || apiConfig.storeId;
|
|
1447
1995
|
return apiConfig.httpClient.put(
|
|
1448
1996
|
`/v1/stores/${target_store_id}/workflows/${id}`,
|
|
@@ -1464,17 +2012,24 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1464
2012
|
options
|
|
1465
2013
|
);
|
|
1466
2014
|
},
|
|
1467
|
-
async getWorkflows(params, options) {
|
|
1468
|
-
const store_id = params?.store_id || apiConfig.storeId;
|
|
1469
|
-
const { store_id: _, ...queryParams } = params || {};
|
|
1470
|
-
return apiConfig.httpClient.get(
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
2015
|
+
async getWorkflows(params, options) {
|
|
2016
|
+
const store_id = params?.store_id || apiConfig.storeId;
|
|
2017
|
+
const { store_id: _, ...queryParams } = params || {};
|
|
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
|
+
);
|
|
2025
|
+
},
|
|
1475
2026
|
async triggerWorkflow(params, options) {
|
|
1476
2027
|
const { secret, ...payload } = params;
|
|
1477
|
-
return apiConfig.httpClient.post(
|
|
2028
|
+
return apiConfig.httpClient.post(
|
|
2029
|
+
`/v1/workflows/trigger/${secret}`,
|
|
2030
|
+
payload,
|
|
2031
|
+
options
|
|
2032
|
+
);
|
|
1478
2033
|
},
|
|
1479
2034
|
async getWorkflowExecutions(params, options) {
|
|
1480
2035
|
const store_id = params.store_id || apiConfig.storeId;
|
|
@@ -1493,6 +2048,38 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1493
2048
|
`/v1/stores/${store_id}/workflows/${params.workflow_id}/executions/${params.execution_id}`,
|
|
1494
2049
|
options
|
|
1495
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
|
+
);
|
|
1496
2083
|
}
|
|
1497
2084
|
};
|
|
1498
2085
|
};
|
|
@@ -1503,8 +2090,8 @@ var createPlatformApi = (apiConfig) => {
|
|
|
1503
2090
|
async getCurrencies(options) {
|
|
1504
2091
|
return apiConfig.httpClient.get("/v1/platform/currencies", options);
|
|
1505
2092
|
},
|
|
1506
|
-
async
|
|
1507
|
-
return apiConfig.httpClient.get("/v1/platform/
|
|
2093
|
+
async getWorkflowTools(options) {
|
|
2094
|
+
return apiConfig.httpClient.get("/v1/platform/workflow-tools", options);
|
|
1508
2095
|
},
|
|
1509
2096
|
async getWebhookEvents(options) {
|
|
1510
2097
|
return apiConfig.httpClient.get("/v1/platform/events", options);
|
|
@@ -1554,116 +2141,35 @@ var createShippingApi = (apiConfig) => {
|
|
|
1554
2141
|
};
|
|
1555
2142
|
};
|
|
1556
2143
|
|
|
1557
|
-
// src/api/
|
|
1558
|
-
var
|
|
2144
|
+
// src/api/paymentProvider.ts
|
|
2145
|
+
var createPaymentProviderApi = (apiConfig) => {
|
|
2146
|
+
const storeId = (store_id) => store_id || apiConfig.storeId;
|
|
1559
2147
|
return {
|
|
1560
|
-
async
|
|
1561
|
-
const { store_id, ...payload } = params;
|
|
1562
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1563
|
-
return apiConfig.httpClient.post(
|
|
1564
|
-
`/v1/stores/${target_store_id}/agents`,
|
|
1565
|
-
{ ...payload, store_id: target_store_id },
|
|
1566
|
-
options
|
|
1567
|
-
);
|
|
1568
|
-
},
|
|
1569
|
-
async updateAgent(params, options) {
|
|
1570
|
-
const { store_id, id, ...payload } = params;
|
|
1571
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
1572
|
-
return apiConfig.httpClient.put(
|
|
1573
|
-
`/v1/stores/${target_store_id}/agents/${id}`,
|
|
1574
|
-
payload,
|
|
1575
|
-
options
|
|
1576
|
-
);
|
|
1577
|
-
},
|
|
1578
|
-
async deleteAgent(params, options) {
|
|
1579
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1580
|
-
return apiConfig.httpClient.delete(
|
|
1581
|
-
`/v1/stores/${store_id}/agents/${params.id}`,
|
|
1582
|
-
options
|
|
1583
|
-
);
|
|
1584
|
-
},
|
|
1585
|
-
async getAgent(params, options) {
|
|
1586
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2148
|
+
async list(params, options) {
|
|
1587
2149
|
return apiConfig.httpClient.get(
|
|
1588
|
-
`/v1/stores/${store_id}/
|
|
2150
|
+
`/v1/stores/${storeId(params?.store_id)}/payment-providers`,
|
|
1589
2151
|
options
|
|
1590
2152
|
);
|
|
1591
2153
|
},
|
|
1592
|
-
async
|
|
1593
|
-
const
|
|
1594
|
-
const { store_id: _, ...queryParams } = params || {};
|
|
1595
|
-
return apiConfig.httpClient.get(`/v1/stores/${store_id}/agents`, {
|
|
1596
|
-
...options,
|
|
1597
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1598
|
-
});
|
|
1599
|
-
},
|
|
1600
|
-
async sendMessage(params, options) {
|
|
1601
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1602
|
-
const body = { message: params.message };
|
|
1603
|
-
if (params.chat_id) body.chat_id = params.chat_id;
|
|
1604
|
-
if (params.direct) body.direct = params.direct;
|
|
2154
|
+
async refresh(params, options) {
|
|
2155
|
+
const targetStoreId = storeId(params?.store_id);
|
|
1605
2156
|
return apiConfig.httpClient.post(
|
|
1606
|
-
`/v1/stores/${
|
|
1607
|
-
|
|
1608
|
-
options
|
|
1609
|
-
);
|
|
1610
|
-
},
|
|
1611
|
-
async getChats(params, options) {
|
|
1612
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1613
|
-
const queryParams = {};
|
|
1614
|
-
if (params.limit) queryParams.limit = String(params.limit);
|
|
1615
|
-
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1616
|
-
return apiConfig.httpClient.get(
|
|
1617
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats`,
|
|
1618
|
-
{
|
|
1619
|
-
...options,
|
|
1620
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1621
|
-
}
|
|
1622
|
-
);
|
|
1623
|
-
},
|
|
1624
|
-
async getChat(params, options) {
|
|
1625
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1626
|
-
return apiConfig.httpClient.get(
|
|
1627
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
|
|
1628
|
-
options
|
|
1629
|
-
);
|
|
1630
|
-
},
|
|
1631
|
-
async updateChat(params, options) {
|
|
1632
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1633
|
-
return apiConfig.httpClient.put(
|
|
1634
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
|
|
1635
|
-
{ status: params.status },
|
|
2157
|
+
`/v1/stores/${targetStoreId}/payment-providers/refresh`,
|
|
2158
|
+
{ store_id: targetStoreId },
|
|
1636
2159
|
options
|
|
1637
2160
|
);
|
|
1638
2161
|
},
|
|
1639
|
-
async
|
|
1640
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1641
|
-
const body = { rating: params.rating };
|
|
1642
|
-
if (params.comment) body.comment = params.comment;
|
|
2162
|
+
async connectStripe(params, options) {
|
|
1643
2163
|
return apiConfig.httpClient.post(
|
|
1644
|
-
`/v1/stores/${
|
|
1645
|
-
|
|
2164
|
+
`/v1/stores/${storeId(params.store_id)}/payment-providers/stripe/connect`,
|
|
2165
|
+
params,
|
|
1646
2166
|
options
|
|
1647
2167
|
);
|
|
1648
2168
|
},
|
|
1649
|
-
async
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
...options,
|
|
1654
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1655
|
-
});
|
|
1656
|
-
},
|
|
1657
|
-
async getChatMessages(params, options) {
|
|
1658
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
1659
|
-
const queryParams = {};
|
|
1660
|
-
if (params.limit) queryParams.limit = String(params.limit);
|
|
1661
|
-
return apiConfig.httpClient.get(
|
|
1662
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/messages`,
|
|
1663
|
-
{
|
|
1664
|
-
...options,
|
|
1665
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1666
|
-
}
|
|
2169
|
+
async delete(params, options) {
|
|
2170
|
+
return apiConfig.httpClient.delete(
|
|
2171
|
+
`/v1/stores/${storeId(params.store_id)}/payment-providers/${params.id}`,
|
|
2172
|
+
options
|
|
1667
2173
|
);
|
|
1668
2174
|
}
|
|
1669
2175
|
};
|
|
@@ -1722,6 +2228,15 @@ var createEmailTemplateApi = (apiConfig) => {
|
|
|
1722
2228
|
params: queryParams
|
|
1723
2229
|
}
|
|
1724
2230
|
);
|
|
2231
|
+
},
|
|
2232
|
+
async previewEmailTemplate(params, options) {
|
|
2233
|
+
const { store_id, id, ...payload } = params;
|
|
2234
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2235
|
+
return apiConfig.httpClient.post(
|
|
2236
|
+
`/v1/stores/${target_store_id}/email-templates/${id}/preview`,
|
|
2237
|
+
payload,
|
|
2238
|
+
options
|
|
2239
|
+
);
|
|
1725
2240
|
}
|
|
1726
2241
|
};
|
|
1727
2242
|
};
|
|
@@ -1895,6 +2410,164 @@ var createAnalyticsApi = (apiConfig) => {
|
|
|
1895
2410
|
};
|
|
1896
2411
|
};
|
|
1897
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
|
+
|
|
1898
2571
|
// src/utils/price.ts
|
|
1899
2572
|
function formatCurrency(amount, currencyCode, locale = "en") {
|
|
1900
2573
|
if (!currencyCode) return "";
|
|
@@ -2270,41 +2943,147 @@ function createAdmin(config) {
|
|
|
2270
2943
|
};
|
|
2271
2944
|
const accountApi = createAccountApi(apiConfig);
|
|
2272
2945
|
const authApi = createAuthApi(apiConfig, updateSession);
|
|
2273
|
-
const storeApi = createStoreApi(apiConfig
|
|
2946
|
+
const storeApi = createStoreApi(apiConfig);
|
|
2274
2947
|
const platformApi = createPlatformApi(apiConfig);
|
|
2275
2948
|
const cmsApi = createCmsApi(apiConfig);
|
|
2276
2949
|
const eshopApi = createEshopApi(apiConfig);
|
|
2277
2950
|
const promoCodeApi = createPromoCodeApi(apiConfig);
|
|
2278
|
-
const crmApi =
|
|
2951
|
+
const crmApi = createContactApi(apiConfig);
|
|
2952
|
+
const supportApi = createAdminSupportApi(apiConfig);
|
|
2953
|
+
const leadResearchApi = createLeadResearchApi(apiConfig);
|
|
2954
|
+
const socialApi = createSocialApi(apiConfig);
|
|
2955
|
+
const paymentProviderApi = createPaymentProviderApi(apiConfig);
|
|
2956
|
+
const notificationApi = createNotificationApi(apiConfig);
|
|
2957
|
+
const shippingApi = createShippingApi(apiConfig);
|
|
2279
2958
|
const locationApi = createLocationApi(apiConfig);
|
|
2280
2959
|
const marketApi = createMarketApi(apiConfig);
|
|
2281
|
-
const agentApi = createAgentApi(apiConfig);
|
|
2282
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
|
+
};
|
|
2283
2981
|
const formApi = createFormApi(apiConfig);
|
|
2284
2982
|
const taxonomyApi = createTaxonomyApi(apiConfig);
|
|
2285
2983
|
const emailTemplateApi = createEmailTemplateApi(apiConfig);
|
|
2286
2984
|
const analyticsApi = createAnalyticsApi(apiConfig);
|
|
2985
|
+
const experimentsApi = createExperimentsApi(apiConfig);
|
|
2287
2986
|
const sdk = {
|
|
2288
|
-
|
|
2289
|
-
|
|
2987
|
+
account: {
|
|
2988
|
+
update: accountApi.updateAccount,
|
|
2989
|
+
delete: accountApi.deleteAccount,
|
|
2990
|
+
getMe: accountApi.getMe,
|
|
2991
|
+
search: accountApi.searchAccounts,
|
|
2992
|
+
auth: authApi
|
|
2993
|
+
},
|
|
2290
2994
|
store: {
|
|
2291
|
-
|
|
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
|
+
},
|
|
2292
3029
|
location: locationApi,
|
|
2293
|
-
market: marketApi
|
|
3030
|
+
market: marketApi,
|
|
3031
|
+
paymentProvider: storePaymentProviderApi
|
|
2294
3032
|
},
|
|
2295
3033
|
media: createMediaApi(apiConfig),
|
|
2296
|
-
notification:
|
|
2297
|
-
|
|
3034
|
+
notification: {
|
|
3035
|
+
email: {
|
|
3036
|
+
trackOpen: notificationApi.trackEmailOpen
|
|
3037
|
+
},
|
|
3038
|
+
trigger: {
|
|
3039
|
+
send: notificationApi.trigger
|
|
3040
|
+
},
|
|
3041
|
+
mailbox: crmApi.mailbox
|
|
3042
|
+
},
|
|
2298
3043
|
platform: platformApi,
|
|
2299
|
-
|
|
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
|
+
},
|
|
2300
3073
|
cms: {
|
|
2301
|
-
|
|
2302
|
-
create: cmsApi.
|
|
2303
|
-
update: cmsApi.
|
|
2304
|
-
delete: cmsApi.
|
|
2305
|
-
get: cmsApi.
|
|
2306
|
-
find: cmsApi.
|
|
2307
|
-
|
|
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
|
|
2308
3087
|
},
|
|
2309
3088
|
form: {
|
|
2310
3089
|
create: formApi.createForm,
|
|
@@ -2330,7 +3109,8 @@ function createAdmin(config) {
|
|
|
2330
3109
|
update: emailTemplateApi.updateEmailTemplate,
|
|
2331
3110
|
delete: emailTemplateApi.deleteEmailTemplate,
|
|
2332
3111
|
get: emailTemplateApi.getEmailTemplate,
|
|
2333
|
-
find: emailTemplateApi.getEmailTemplates
|
|
3112
|
+
find: emailTemplateApi.getEmailTemplates,
|
|
3113
|
+
preview: emailTemplateApi.previewEmailTemplate
|
|
2334
3114
|
}
|
|
2335
3115
|
},
|
|
2336
3116
|
eshop: {
|
|
@@ -2346,7 +3126,10 @@ function createAdmin(config) {
|
|
|
2346
3126
|
get: eshopApi.getOrder,
|
|
2347
3127
|
find: eshopApi.getOrders,
|
|
2348
3128
|
getQuote: eshopApi.getQuote,
|
|
2349
|
-
processRefund: eshopApi.processRefund
|
|
3129
|
+
processRefund: eshopApi.processRefund,
|
|
3130
|
+
downloadDigitalAccess: eshopApi.downloadDigitalAccess,
|
|
3131
|
+
getShippingRates: shippingApi.getRates,
|
|
3132
|
+
ship: shippingApi.ship
|
|
2350
3133
|
},
|
|
2351
3134
|
cart: {
|
|
2352
3135
|
create: eshopApi.createCart,
|
|
@@ -2381,53 +3164,55 @@ function createAdmin(config) {
|
|
|
2381
3164
|
promoCode: promoCodeApi
|
|
2382
3165
|
},
|
|
2383
3166
|
crm: {
|
|
2384
|
-
|
|
3167
|
+
contact: {
|
|
2385
3168
|
create: crmApi.create,
|
|
2386
3169
|
get: crmApi.get,
|
|
2387
3170
|
find: crmApi.find,
|
|
2388
3171
|
update: crmApi.update,
|
|
2389
3172
|
merge: crmApi.merge,
|
|
3173
|
+
import: crmApi.import,
|
|
2390
3174
|
revokeToken: crmApi.revokeToken,
|
|
2391
3175
|
revokeAllTokens: crmApi.revokeAllTokens
|
|
2392
3176
|
},
|
|
2393
|
-
|
|
2394
|
-
create: crmApi.
|
|
2395
|
-
update: crmApi.
|
|
2396
|
-
get: crmApi.
|
|
2397
|
-
find: crmApi.
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
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
|
|
2401
3188
|
},
|
|
2402
|
-
|
|
3189
|
+
action: crmApi.action
|
|
3190
|
+
},
|
|
3191
|
+
outreach: {
|
|
3192
|
+
campaign: crmApi.campaign,
|
|
3193
|
+
campaignEnrollment: crmApi.campaignEnrollment,
|
|
3194
|
+
campaignMessage: crmApi.campaignMessage,
|
|
3195
|
+
suppression: crmApi.suppression,
|
|
3196
|
+
leadResearch: leadResearchApi
|
|
2403
3197
|
},
|
|
2404
3198
|
automation: {
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
},
|
|
2419
|
-
workflow: {
|
|
2420
|
-
create: workflowApi.createWorkflow,
|
|
2421
|
-
update: workflowApi.updateWorkflow,
|
|
2422
|
-
delete: workflowApi.deleteWorkflow,
|
|
2423
|
-
get: workflowApi.getWorkflow,
|
|
2424
|
-
find: workflowApi.getWorkflows,
|
|
2425
|
-
trigger: workflowApi.triggerWorkflow,
|
|
2426
|
-
getExecutions: workflowApi.getWorkflowExecutions,
|
|
2427
|
-
getExecution: workflowApi.getWorkflowExecution
|
|
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
|
|
2428
3212
|
}
|
|
2429
3213
|
},
|
|
2430
3214
|
analytics: analyticsApi,
|
|
3215
|
+
experiments: experimentsApi,
|
|
2431
3216
|
setStoreId: (storeId) => {
|
|
2432
3217
|
apiConfig.storeId = storeId;
|
|
2433
3218
|
},
|
|
@@ -2463,7 +3248,6 @@ function createAdmin(config) {
|
|
|
2463
3248
|
if (config.apiToken) return;
|
|
2464
3249
|
updateSession(() => null);
|
|
2465
3250
|
},
|
|
2466
|
-
extractBlockValues,
|
|
2467
3251
|
utils: createUtilitySurface(apiConfig)
|
|
2468
3252
|
};
|
|
2469
3253
|
return sdk;
|