arky-sdk 0.9.0 → 0.9.6
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 +2 -2
- package/dist/{admin-CfHen7c5.d.cts → admin-DjYydKeB.d.ts} +477 -124
- package/dist/{admin-ru7pX5bd.d.ts → admin-DlL8mCxL.d.cts} +477 -124
- package/dist/admin.cjs +592 -202
- 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 +592 -202
- package/dist/admin.js.map +1 -1
- package/dist/api-BbBHcd4p.d.cts +3289 -0
- package/dist/api-BbBHcd4p.d.ts +3289 -0
- package/dist/{index-C5gikdBg.d.cts → index-CZxubTDA.d.ts} +1 -1
- package/dist/{index-MFMjlIfS.d.ts → index-nCF3Z6Af.d.cts} +1 -1
- package/dist/index.cjs +666 -319
- 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 +666 -319
- package/dist/index.js.map +1 -1
- package/dist/storefront-store.cjs +149 -134
- package/dist/storefront-store.cjs.map +1 -1
- package/dist/storefront-store.d.cts +3 -3
- package/dist/storefront-store.d.ts +3 -3
- package/dist/storefront-store.js +149 -134
- package/dist/storefront-store.js.map +1 -1
- package/dist/storefront.cjs +149 -134
- package/dist/storefront.cjs.map +1 -1
- package/dist/storefront.d.cts +45 -102
- package/dist/storefront.d.ts +45 -102
- package/dist/storefront.js +149 -134
- 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 +3 -2
package/dist/index.cjs
CHANGED
|
@@ -193,7 +193,7 @@ var createActivityApi = (apiConfig) => ({
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
|
-
var createStorefrontApi = (apiConfig,
|
|
196
|
+
var createStorefrontApi = (apiConfig, updateProfileSession) => {
|
|
197
197
|
const base = (storeId = apiConfig.storeId) => `/v1/storefront/${storeId}`;
|
|
198
198
|
return {
|
|
199
199
|
store: {
|
|
@@ -514,11 +514,11 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
|
|
|
514
514
|
}
|
|
515
515
|
},
|
|
516
516
|
crm: {
|
|
517
|
-
|
|
517
|
+
profile: {
|
|
518
518
|
async identify(params, options) {
|
|
519
519
|
const store_id = apiConfig.storeId;
|
|
520
520
|
const result = await apiConfig.httpClient.post(
|
|
521
|
-
`${base(store_id)}/
|
|
521
|
+
`${base(store_id)}/profiles/identify`,
|
|
522
522
|
{
|
|
523
523
|
store_id,
|
|
524
524
|
market: params?.market || apiConfig.market || null,
|
|
@@ -528,9 +528,9 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
|
|
|
528
528
|
options
|
|
529
529
|
);
|
|
530
530
|
if (result?.token?.token) {
|
|
531
|
-
|
|
531
|
+
updateProfileSession(() => ({
|
|
532
532
|
access_token: result.token.token,
|
|
533
|
-
|
|
533
|
+
profile: result.profile,
|
|
534
534
|
store: result.store,
|
|
535
535
|
market: result.market
|
|
536
536
|
}));
|
|
@@ -540,12 +540,12 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
|
|
|
540
540
|
async verify(params, options) {
|
|
541
541
|
const store_id = apiConfig.storeId;
|
|
542
542
|
const result = await apiConfig.httpClient.post(
|
|
543
|
-
`${base(store_id)}/
|
|
543
|
+
`${base(store_id)}/profiles/verify`,
|
|
544
544
|
{ store_id, code: params.code },
|
|
545
545
|
options
|
|
546
546
|
);
|
|
547
547
|
if (result?.token) {
|
|
548
|
-
|
|
548
|
+
updateProfileSession(
|
|
549
549
|
(prev) => prev ? { ...prev, access_token: result.token } : null
|
|
550
550
|
);
|
|
551
551
|
}
|
|
@@ -555,132 +555,63 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
|
|
|
555
555
|
const store_id = apiConfig.storeId;
|
|
556
556
|
try {
|
|
557
557
|
await apiConfig.httpClient.post(
|
|
558
|
-
`${base(store_id)}/
|
|
558
|
+
`${base(store_id)}/profiles/logout`,
|
|
559
559
|
{},
|
|
560
560
|
options
|
|
561
561
|
);
|
|
562
562
|
} finally {
|
|
563
|
-
|
|
563
|
+
updateProfileSession(() => null);
|
|
564
564
|
}
|
|
565
565
|
},
|
|
566
566
|
getMe(options) {
|
|
567
|
-
return apiConfig.httpClient.get(`${base()}/
|
|
567
|
+
return apiConfig.httpClient.get(`${base()}/profiles/me`, options);
|
|
568
568
|
}
|
|
569
569
|
},
|
|
570
|
-
|
|
570
|
+
profileList: {
|
|
571
571
|
get(params, options) {
|
|
572
|
-
|
|
573
|
-
if (params.id) {
|
|
574
|
-
identifier = params.id;
|
|
575
|
-
} else if (params.key) {
|
|
576
|
-
identifier = `${apiConfig.storeId}:${params.key}`;
|
|
577
|
-
} else {
|
|
578
|
-
throw new Error("GetAudienceParams requires id or key");
|
|
579
|
-
}
|
|
572
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
580
573
|
return apiConfig.httpClient.get(
|
|
581
|
-
`${base(
|
|
574
|
+
`${base(store_id)}/profile-lists/${params.id}`,
|
|
582
575
|
options
|
|
583
576
|
);
|
|
584
577
|
},
|
|
585
578
|
find(params, options) {
|
|
586
|
-
|
|
579
|
+
const { store_id, ...queryParams } = params || {};
|
|
580
|
+
return apiConfig.httpClient.get(`${base(store_id)}/profile-lists`, {
|
|
587
581
|
...options,
|
|
588
|
-
params
|
|
582
|
+
params: queryParams
|
|
589
583
|
});
|
|
590
584
|
},
|
|
591
585
|
subscribe(params, options) {
|
|
586
|
+
const { store_id, id, ...payload } = params;
|
|
592
587
|
return apiConfig.httpClient.post(
|
|
593
|
-
`${base()}/
|
|
594
|
-
|
|
595
|
-
customer_id: params.customer_id,
|
|
596
|
-
price_id: params.price_id,
|
|
597
|
-
success_url: params.success_url,
|
|
598
|
-
cancel_url: params.cancel_url,
|
|
599
|
-
confirm_url: params.confirm_url
|
|
600
|
-
},
|
|
588
|
+
`${base(store_id)}/profile-lists/${id}/subscribe`,
|
|
589
|
+
payload,
|
|
601
590
|
options
|
|
602
591
|
);
|
|
603
592
|
},
|
|
604
593
|
checkAccess(params, options) {
|
|
594
|
+
const store_id = params.store_id || apiConfig.storeId;
|
|
605
595
|
return apiConfig.httpClient.get(
|
|
606
|
-
`${base()}/
|
|
596
|
+
`${base(store_id)}/profile-lists/${params.id}/access`,
|
|
607
597
|
options
|
|
608
598
|
);
|
|
609
599
|
},
|
|
610
600
|
unsubscribe(token, options) {
|
|
611
|
-
return apiConfig.httpClient.get(`${base()}/
|
|
601
|
+
return apiConfig.httpClient.get(`${base()}/profile-lists/unsubscribe`, {
|
|
612
602
|
...options,
|
|
613
603
|
params: { token }
|
|
614
604
|
});
|
|
615
605
|
},
|
|
616
606
|
confirm(token, options) {
|
|
617
|
-
return apiConfig.httpClient.get(`${base()}/
|
|
607
|
+
return apiConfig.httpClient.get(`${base()}/profile-lists/confirm`, {
|
|
618
608
|
...options,
|
|
619
609
|
params: { token }
|
|
620
610
|
});
|
|
621
611
|
}
|
|
622
612
|
}
|
|
623
613
|
},
|
|
624
|
-
activity: createActivityApi(apiConfig)
|
|
625
|
-
automation: {
|
|
626
|
-
agent: {
|
|
627
|
-
getAgents(params, options) {
|
|
628
|
-
const store_id = params?.store_id || apiConfig.storeId;
|
|
629
|
-
const queryParams = { ...params || {} };
|
|
630
|
-
delete queryParams.store_id;
|
|
631
|
-
return apiConfig.httpClient.get(`${base(store_id)}/agents`, {
|
|
632
|
-
...options,
|
|
633
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
634
|
-
});
|
|
635
|
-
},
|
|
636
|
-
getAgent(params, options) {
|
|
637
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
638
|
-
return apiConfig.httpClient.get(
|
|
639
|
-
`${base(store_id)}/agents/${params.id}`,
|
|
640
|
-
options
|
|
641
|
-
);
|
|
642
|
-
},
|
|
643
|
-
sendMessage(params, options) {
|
|
644
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
645
|
-
const body = { message: params.message };
|
|
646
|
-
if (params.chat_id) body.chat_id = params.chat_id;
|
|
647
|
-
return apiConfig.httpClient.post(
|
|
648
|
-
`${base(store_id)}/agents/${params.id}/chats/messages`,
|
|
649
|
-
body,
|
|
650
|
-
options
|
|
651
|
-
);
|
|
652
|
-
},
|
|
653
|
-
getChat(params, options) {
|
|
654
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
655
|
-
return apiConfig.httpClient.get(
|
|
656
|
-
`${base(store_id)}/agents/${params.id}/chats/${params.chat_id}`,
|
|
657
|
-
options
|
|
658
|
-
);
|
|
659
|
-
},
|
|
660
|
-
getChatMessages(params, options) {
|
|
661
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
662
|
-
const queryParams = {};
|
|
663
|
-
if (params.limit) queryParams.limit = String(params.limit);
|
|
664
|
-
return apiConfig.httpClient.get(
|
|
665
|
-
`${base(store_id)}/agents/${params.id}/chats/${params.chat_id}/messages`,
|
|
666
|
-
{
|
|
667
|
-
...options,
|
|
668
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
669
|
-
}
|
|
670
|
-
);
|
|
671
|
-
},
|
|
672
|
-
rateChat(params, options) {
|
|
673
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
674
|
-
const body = { rating: params.rating };
|
|
675
|
-
if (params.comment) body.comment = params.comment;
|
|
676
|
-
return apiConfig.httpClient.post(
|
|
677
|
-
`${base(store_id)}/agents/${params.id}/chats/${params.chat_id}/rate`,
|
|
678
|
-
body,
|
|
679
|
-
options
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
614
|
+
activity: createActivityApi(apiConfig)
|
|
684
615
|
};
|
|
685
616
|
};
|
|
686
617
|
|
|
@@ -1093,7 +1024,7 @@ var createAuthApi = (apiConfig, updateSession) => {
|
|
|
1093
1024
|
};
|
|
1094
1025
|
|
|
1095
1026
|
// src/api/store.ts
|
|
1096
|
-
var createStoreApi = (apiConfig,
|
|
1027
|
+
var createStoreApi = (apiConfig, _updateSession) => {
|
|
1097
1028
|
return {
|
|
1098
1029
|
async createStore(params, options) {
|
|
1099
1030
|
return apiConfig.httpClient.post(`/v1/stores`, params, options);
|
|
@@ -1143,10 +1074,19 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
1143
1074
|
options
|
|
1144
1075
|
);
|
|
1145
1076
|
},
|
|
1077
|
+
async addMember(params, options) {
|
|
1078
|
+
const { store_id, ...payload } = params;
|
|
1079
|
+
return apiConfig.httpClient.post(
|
|
1080
|
+
`/v1/stores/${store_id || apiConfig.storeId}/members`,
|
|
1081
|
+
payload,
|
|
1082
|
+
options
|
|
1083
|
+
);
|
|
1084
|
+
},
|
|
1146
1085
|
async inviteUser(params, options) {
|
|
1086
|
+
const { store_id, ...payload } = params;
|
|
1147
1087
|
return apiConfig.httpClient.post(
|
|
1148
|
-
`/v1/stores/${apiConfig.storeId}/
|
|
1149
|
-
|
|
1088
|
+
`/v1/stores/${store_id || apiConfig.storeId}/members`,
|
|
1089
|
+
payload,
|
|
1150
1090
|
options
|
|
1151
1091
|
);
|
|
1152
1092
|
},
|
|
@@ -1156,22 +1096,6 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
1156
1096
|
options
|
|
1157
1097
|
);
|
|
1158
1098
|
},
|
|
1159
|
-
async handleInvitation(params, options) {
|
|
1160
|
-
const { store_id, ...payload } = params;
|
|
1161
|
-
const result = await apiConfig.httpClient.put(
|
|
1162
|
-
`/v1/stores/${store_id || apiConfig.storeId}/invitation`,
|
|
1163
|
-
payload,
|
|
1164
|
-
options
|
|
1165
|
-
);
|
|
1166
|
-
if (params.action === "accept" && result?.auth?.access_token) {
|
|
1167
|
-
updateSession(() => ({
|
|
1168
|
-
access_token: result.auth.access_token,
|
|
1169
|
-
refresh_token: result.auth.refresh_token,
|
|
1170
|
-
access_expires_at: result.auth.access_expires_at
|
|
1171
|
-
}));
|
|
1172
|
-
}
|
|
1173
|
-
return result;
|
|
1174
|
-
},
|
|
1175
1099
|
async testWebhook(params, options) {
|
|
1176
1100
|
return apiConfig.httpClient.post(
|
|
1177
1101
|
`/v1/stores/${apiConfig.storeId}/webhooks/test`,
|
|
@@ -1184,7 +1108,7 @@ var createStoreApi = (apiConfig, updateSession) => {
|
|
|
1184
1108
|
limit: params.limit
|
|
1185
1109
|
};
|
|
1186
1110
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1187
|
-
if (params.ids && params.ids.length > 0) queryParams.ids = params.ids
|
|
1111
|
+
if (params.ids && params.ids.length > 0) queryParams.ids = JSON.stringify(params.ids);
|
|
1188
1112
|
if (params.query) queryParams.query = params.query;
|
|
1189
1113
|
if (params.mime_type) queryParams.mime_type = params.mime_type;
|
|
1190
1114
|
if (params.sort_field) queryParams.sort_field = params.sort_field;
|
|
@@ -1316,7 +1240,7 @@ var createMediaApi = (apiConfig) => {
|
|
|
1316
1240
|
const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
|
|
1317
1241
|
const queryParams = { limit: String(limit) };
|
|
1318
1242
|
if (cursor) queryParams.cursor = cursor;
|
|
1319
|
-
if (ids && ids.length > 0) queryParams.ids =
|
|
1243
|
+
if (ids && ids.length > 0) queryParams.ids = JSON.stringify(ids);
|
|
1320
1244
|
if (query) queryParams.query = query;
|
|
1321
1245
|
if (mime_type) queryParams.mime_type = mime_type;
|
|
1322
1246
|
if (sort_field) queryParams.sort_field = sort_field;
|
|
@@ -1936,7 +1860,7 @@ var createMarketApi = (apiConfig) => {
|
|
|
1936
1860
|
var createActivityAdminApi = (apiConfig) => ({
|
|
1937
1861
|
async timeline(params, options) {
|
|
1938
1862
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1939
|
-
const queryParams = {
|
|
1863
|
+
const queryParams = { profile_id: params.profile_id };
|
|
1940
1864
|
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1941
1865
|
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1942
1866
|
return apiConfig.httpClient.get(
|
|
@@ -1947,7 +1871,7 @@ var createActivityAdminApi = (apiConfig) => ({
|
|
|
1947
1871
|
async find(params, options) {
|
|
1948
1872
|
const store_id = params.store_id || apiConfig.storeId;
|
|
1949
1873
|
const queryParams = {};
|
|
1950
|
-
if (params.
|
|
1874
|
+
if (params.profile_id) queryParams.profile_id = params.profile_id;
|
|
1951
1875
|
if (params.types && params.types.length > 0) queryParams.types = params.types;
|
|
1952
1876
|
if (params.from !== void 0) queryParams.from = params.from;
|
|
1953
1877
|
if (params.to !== void 0) queryParams.to = params.to;
|
|
@@ -1959,25 +1883,26 @@ var createActivityAdminApi = (apiConfig) => ({
|
|
|
1959
1883
|
);
|
|
1960
1884
|
}
|
|
1961
1885
|
});
|
|
1962
|
-
var
|
|
1886
|
+
var createProfileApi = (apiConfig) => {
|
|
1963
1887
|
return {
|
|
1964
1888
|
async create(params, options) {
|
|
1965
1889
|
const { store_id, ...payload } = params;
|
|
1966
1890
|
return apiConfig.httpClient.post(
|
|
1967
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1891
|
+
`/v1/stores/${store_id || apiConfig.storeId}/profiles`,
|
|
1968
1892
|
payload,
|
|
1969
1893
|
options
|
|
1970
1894
|
);
|
|
1971
1895
|
},
|
|
1972
1896
|
async get(params, options) {
|
|
1973
1897
|
return apiConfig.httpClient.get(
|
|
1974
|
-
`/v1/stores/${params.store_id || apiConfig.storeId}/
|
|
1898
|
+
`/v1/stores/${params.store_id || apiConfig.storeId}/profiles/${params.id}`,
|
|
1975
1899
|
options
|
|
1976
1900
|
);
|
|
1977
1901
|
},
|
|
1978
1902
|
async find(params, options) {
|
|
1979
1903
|
const store_id = params?.store_id || apiConfig.storeId;
|
|
1980
1904
|
const queryParams = {};
|
|
1905
|
+
if (params?.ids && params.ids.length > 0) queryParams.ids = JSON.stringify(params.ids);
|
|
1981
1906
|
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
1982
1907
|
if (params?.cursor) queryParams.cursor = params.cursor;
|
|
1983
1908
|
if (params?.query) queryParams.query = params.query;
|
|
@@ -1988,7 +1913,7 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1988
1913
|
if (params?.sort_field) queryParams.sort_field = params.sort_field;
|
|
1989
1914
|
if (params?.sort_direction) queryParams.sort_direction = params.sort_direction;
|
|
1990
1915
|
return apiConfig.httpClient.get(
|
|
1991
|
-
`/v1/stores/${store_id}/
|
|
1916
|
+
`/v1/stores/${store_id}/profiles`,
|
|
1992
1917
|
{
|
|
1993
1918
|
...options,
|
|
1994
1919
|
params: queryParams
|
|
@@ -1998,7 +1923,7 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1998
1923
|
async update(params, options) {
|
|
1999
1924
|
const { id, store_id, ...body } = params;
|
|
2000
1925
|
return apiConfig.httpClient.put(
|
|
2001
|
-
`/v1/stores/${store_id || apiConfig.storeId}/
|
|
1926
|
+
`/v1/stores/${store_id || apiConfig.storeId}/profiles/${id}`,
|
|
2002
1927
|
body,
|
|
2003
1928
|
options
|
|
2004
1929
|
);
|
|
@@ -2006,87 +1931,600 @@ var createCustomerApi = (apiConfig) => {
|
|
|
2006
1931
|
async merge(params, options) {
|
|
2007
1932
|
const store_id = params.store_id || apiConfig.storeId;
|
|
2008
1933
|
return apiConfig.httpClient.post(
|
|
2009
|
-
`/v1/stores/${store_id}/
|
|
1934
|
+
`/v1/stores/${store_id}/profiles/${params.target_id}/merge`,
|
|
2010
1935
|
{ source_id: params.source_id, store_id },
|
|
2011
1936
|
options
|
|
2012
1937
|
);
|
|
2013
1938
|
},
|
|
1939
|
+
"import": async (params, options) => {
|
|
1940
|
+
const { store_id, ...payload } = params;
|
|
1941
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1942
|
+
return apiConfig.httpClient.post(
|
|
1943
|
+
`/v1/stores/${target_store_id}/profiles/import`,
|
|
1944
|
+
payload,
|
|
1945
|
+
options
|
|
1946
|
+
);
|
|
1947
|
+
},
|
|
1948
|
+
previewImport: async (params, options) => {
|
|
1949
|
+
const { store_id, ...payload } = params;
|
|
1950
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
1951
|
+
return apiConfig.httpClient.post(
|
|
1952
|
+
`/v1/stores/${target_store_id}/profiles/import/preview`,
|
|
1953
|
+
payload,
|
|
1954
|
+
options
|
|
1955
|
+
);
|
|
1956
|
+
},
|
|
2014
1957
|
async revokeToken(params, options) {
|
|
2015
1958
|
const store_id = params.store_id || apiConfig.storeId;
|
|
2016
1959
|
return apiConfig.httpClient.delete(
|
|
2017
|
-
`/v1/stores/${store_id}/
|
|
1960
|
+
`/v1/stores/${store_id}/profiles/${params.id}/sessions/${params.token_id}`,
|
|
2018
1961
|
options
|
|
2019
1962
|
);
|
|
2020
1963
|
},
|
|
2021
1964
|
async revokeAllTokens(params, options) {
|
|
2022
1965
|
const store_id = params.store_id || apiConfig.storeId;
|
|
2023
1966
|
return apiConfig.httpClient.delete(
|
|
2024
|
-
`/v1/stores/${store_id}/
|
|
1967
|
+
`/v1/stores/${store_id}/profiles/${params.id}/sessions`,
|
|
2025
1968
|
options
|
|
2026
1969
|
);
|
|
2027
1970
|
},
|
|
2028
|
-
|
|
1971
|
+
profileList: {
|
|
2029
1972
|
async create(params, options) {
|
|
1973
|
+
const { store_id, ...payload } = params;
|
|
1974
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2030
1975
|
return apiConfig.httpClient.post(
|
|
2031
|
-
`/v1/stores/${
|
|
2032
|
-
|
|
1976
|
+
`/v1/stores/${target_store_id}/profile-lists`,
|
|
1977
|
+
payload,
|
|
2033
1978
|
options
|
|
2034
1979
|
);
|
|
2035
1980
|
},
|
|
2036
1981
|
async update(params, options) {
|
|
1982
|
+
const { id, store_id, ...payload } = params;
|
|
1983
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2037
1984
|
return apiConfig.httpClient.put(
|
|
2038
|
-
`/v1/stores/${
|
|
2039
|
-
|
|
1985
|
+
`/v1/stores/${target_store_id}/profile-lists/${id}`,
|
|
1986
|
+
payload,
|
|
2040
1987
|
options
|
|
2041
1988
|
);
|
|
2042
1989
|
},
|
|
2043
1990
|
async get(params, options) {
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
1991
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
1992
|
+
return apiConfig.httpClient.get(
|
|
1993
|
+
`/v1/stores/${target_store_id}/profile-lists/${params.id}`,
|
|
1994
|
+
options
|
|
1995
|
+
);
|
|
1996
|
+
},
|
|
1997
|
+
async find(params, options) {
|
|
1998
|
+
const { store_id, ...queryParams } = params || {};
|
|
1999
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2000
|
+
return apiConfig.httpClient.get(
|
|
2001
|
+
`/v1/stores/${target_store_id}/profile-lists`,
|
|
2002
|
+
{ ...options, params: queryParams }
|
|
2003
|
+
);
|
|
2004
|
+
},
|
|
2005
|
+
async importProfiles(params, options) {
|
|
2006
|
+
const { store_id, profile_list_id, ...payload } = params;
|
|
2007
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2008
|
+
return apiConfig.httpClient.post(
|
|
2009
|
+
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/profiles/import`,
|
|
2010
|
+
payload,
|
|
2011
|
+
options
|
|
2012
|
+
);
|
|
2013
|
+
},
|
|
2014
|
+
async previewImportProfiles(params, options) {
|
|
2015
|
+
const { store_id, profile_list_id, ...payload } = params;
|
|
2016
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2017
|
+
return apiConfig.httpClient.post(
|
|
2018
|
+
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/profiles/import/preview`,
|
|
2019
|
+
payload,
|
|
2020
|
+
options
|
|
2021
|
+
);
|
|
2022
|
+
},
|
|
2023
|
+
members: {
|
|
2024
|
+
async add(params, options) {
|
|
2025
|
+
const { store_id, profile_list_id, profile_id, fields, lead_description } = params;
|
|
2026
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2027
|
+
return apiConfig.httpClient.post(
|
|
2028
|
+
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
|
|
2029
|
+
{ fields, lead_description },
|
|
2030
|
+
options
|
|
2031
|
+
);
|
|
2032
|
+
},
|
|
2033
|
+
async update(params, options) {
|
|
2034
|
+
const { store_id, profile_list_id, profile_id, status, fields, lead_description } = params;
|
|
2035
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2036
|
+
return apiConfig.httpClient.patch(
|
|
2037
|
+
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
|
|
2038
|
+
{ status, fields, lead_description },
|
|
2039
|
+
options
|
|
2040
|
+
);
|
|
2041
|
+
},
|
|
2042
|
+
async remove(params, options) {
|
|
2043
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2044
|
+
return apiConfig.httpClient.delete(
|
|
2045
|
+
`/v1/stores/${target_store_id}/profile-lists/${params.profile_list_id}/members/${params.profile_id}`,
|
|
2046
|
+
options
|
|
2047
|
+
);
|
|
2048
|
+
},
|
|
2049
|
+
async find(params, options) {
|
|
2050
|
+
const { store_id, profile_list_id, ...queryParams } = params;
|
|
2051
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2052
|
+
const path = profile_list_id ? `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members` : `/v1/stores/${target_store_id}/profile-list-members`;
|
|
2053
|
+
return apiConfig.httpClient.get(
|
|
2054
|
+
path,
|
|
2055
|
+
{ ...options, params: queryParams }
|
|
2056
|
+
);
|
|
2057
|
+
}
|
|
2058
|
+
},
|
|
2059
|
+
profiles: {
|
|
2060
|
+
async add(params, options) {
|
|
2061
|
+
const { store_id, profile_list_id, profile_id, fields, lead_description } = params;
|
|
2062
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2063
|
+
return apiConfig.httpClient.post(
|
|
2064
|
+
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
|
|
2065
|
+
{ fields, lead_description },
|
|
2066
|
+
options
|
|
2067
|
+
);
|
|
2068
|
+
},
|
|
2069
|
+
async update(params, options) {
|
|
2070
|
+
const { store_id, profile_list_id, profile_id, status, fields, lead_description } = params;
|
|
2071
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2072
|
+
return apiConfig.httpClient.patch(
|
|
2073
|
+
`/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
|
|
2074
|
+
{ status, fields, lead_description },
|
|
2075
|
+
options
|
|
2076
|
+
);
|
|
2077
|
+
},
|
|
2078
|
+
async remove(params, options) {
|
|
2079
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2080
|
+
return apiConfig.httpClient.delete(
|
|
2081
|
+
`/v1/stores/${target_store_id}/profile-lists/${params.profile_list_id}/members/${params.profile_id}`,
|
|
2082
|
+
options
|
|
2083
|
+
);
|
|
2084
|
+
},
|
|
2085
|
+
async find(params, options) {
|
|
2086
|
+
const { store_id, profile_list_id, ...queryParams } = params;
|
|
2087
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2088
|
+
const path = profile_list_id ? `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members` : `/v1/stores/${target_store_id}/profile-list-members`;
|
|
2089
|
+
return apiConfig.httpClient.get(
|
|
2090
|
+
path,
|
|
2091
|
+
{ ...options, params: queryParams }
|
|
2092
|
+
);
|
|
2051
2093
|
}
|
|
2094
|
+
}
|
|
2095
|
+
},
|
|
2096
|
+
mailbox: {
|
|
2097
|
+
async create(params, options) {
|
|
2098
|
+
const { store_id, ...payload } = params;
|
|
2099
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2100
|
+
return apiConfig.httpClient.post(
|
|
2101
|
+
`/v1/stores/${target_store_id}/mailboxes`,
|
|
2102
|
+
payload,
|
|
2103
|
+
options
|
|
2104
|
+
);
|
|
2105
|
+
},
|
|
2106
|
+
async update(params, options) {
|
|
2107
|
+
const { id, store_id, ...payload } = params;
|
|
2108
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2109
|
+
return apiConfig.httpClient.put(
|
|
2110
|
+
`/v1/stores/${target_store_id}/mailboxes/${id}`,
|
|
2111
|
+
payload,
|
|
2112
|
+
options
|
|
2113
|
+
);
|
|
2114
|
+
},
|
|
2115
|
+
async get(params, options) {
|
|
2116
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2117
|
+
return apiConfig.httpClient.get(
|
|
2118
|
+
`/v1/stores/${target_store_id}/mailboxes/${params.id}`,
|
|
2119
|
+
options
|
|
2120
|
+
);
|
|
2121
|
+
},
|
|
2122
|
+
async test(params, options) {
|
|
2123
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2124
|
+
return apiConfig.httpClient.post(
|
|
2125
|
+
`/v1/stores/${target_store_id}/mailboxes/${params.id}/test`,
|
|
2126
|
+
{},
|
|
2127
|
+
options
|
|
2128
|
+
);
|
|
2129
|
+
},
|
|
2130
|
+
async prepare(params, options) {
|
|
2131
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2132
|
+
return apiConfig.httpClient.post(
|
|
2133
|
+
`/v1/stores/${target_store_id}/mailboxes/${params.id}/prepare`,
|
|
2134
|
+
{},
|
|
2135
|
+
options
|
|
2136
|
+
);
|
|
2137
|
+
},
|
|
2138
|
+
async find(params, options) {
|
|
2139
|
+
const { store_id, ...queryParams } = params || {};
|
|
2140
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2141
|
+
return apiConfig.httpClient.get(
|
|
2142
|
+
`/v1/stores/${target_store_id}/mailboxes`,
|
|
2143
|
+
{ ...options, params: queryParams }
|
|
2144
|
+
);
|
|
2145
|
+
}
|
|
2146
|
+
},
|
|
2147
|
+
campaign: {
|
|
2148
|
+
async create(params, options) {
|
|
2149
|
+
const { store_id, ...payload } = params;
|
|
2150
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2151
|
+
return apiConfig.httpClient.post(
|
|
2152
|
+
`/v1/stores/${target_store_id}/campaigns`,
|
|
2153
|
+
payload,
|
|
2154
|
+
options
|
|
2155
|
+
);
|
|
2156
|
+
},
|
|
2157
|
+
async update(params, options) {
|
|
2158
|
+
const { id, store_id, ...payload } = params;
|
|
2159
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2160
|
+
return apiConfig.httpClient.put(
|
|
2161
|
+
`/v1/stores/${target_store_id}/campaigns/${id}`,
|
|
2162
|
+
payload,
|
|
2163
|
+
options
|
|
2164
|
+
);
|
|
2165
|
+
},
|
|
2166
|
+
async get(params, options) {
|
|
2167
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2052
2168
|
return apiConfig.httpClient.get(
|
|
2053
|
-
`/v1/stores/${
|
|
2169
|
+
`/v1/stores/${target_store_id}/campaigns/${params.id}`,
|
|
2054
2170
|
options
|
|
2055
2171
|
);
|
|
2056
2172
|
},
|
|
2057
2173
|
async find(params, options) {
|
|
2174
|
+
const { store_id, ...queryParams } = params || {};
|
|
2175
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2058
2176
|
return apiConfig.httpClient.get(
|
|
2059
|
-
`/v1/stores/${
|
|
2060
|
-
{ ...options, params }
|
|
2177
|
+
`/v1/stores/${target_store_id}/campaigns`,
|
|
2178
|
+
{ ...options, params: queryParams }
|
|
2179
|
+
);
|
|
2180
|
+
},
|
|
2181
|
+
async launch(params, options) {
|
|
2182
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2183
|
+
return apiConfig.httpClient.post(
|
|
2184
|
+
`/v1/stores/${target_store_id}/campaigns/${params.id}/launch`,
|
|
2185
|
+
{},
|
|
2186
|
+
options
|
|
2061
2187
|
);
|
|
2062
2188
|
},
|
|
2063
|
-
async
|
|
2189
|
+
async duplicate(params, options) {
|
|
2190
|
+
const { id, store_id, ...payload } = params;
|
|
2191
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2192
|
+
return apiConfig.httpClient.post(
|
|
2193
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/duplicate`,
|
|
2194
|
+
payload,
|
|
2195
|
+
options
|
|
2196
|
+
);
|
|
2197
|
+
},
|
|
2198
|
+
async launchReadiness(params, options) {
|
|
2199
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2064
2200
|
return apiConfig.httpClient.get(
|
|
2065
|
-
`/v1/stores/${
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2201
|
+
`/v1/stores/${target_store_id}/campaigns/${params.id}/launch-readiness`,
|
|
2202
|
+
options
|
|
2203
|
+
);
|
|
2204
|
+
},
|
|
2205
|
+
async importRecipients(params, options) {
|
|
2206
|
+
const { id, store_id, ...payload } = params;
|
|
2207
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2208
|
+
return apiConfig.httpClient.post(
|
|
2209
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/recipients/import`,
|
|
2210
|
+
payload,
|
|
2211
|
+
options
|
|
2212
|
+
);
|
|
2213
|
+
},
|
|
2214
|
+
async generatePersonalizedDrafts(params, options) {
|
|
2215
|
+
const { id, store_id, ...payload } = params;
|
|
2216
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2217
|
+
return apiConfig.httpClient.post(
|
|
2218
|
+
`/v1/stores/${target_store_id}/campaigns/${id}/personalized-drafts`,
|
|
2219
|
+
payload,
|
|
2220
|
+
options
|
|
2221
|
+
);
|
|
2222
|
+
}
|
|
2223
|
+
},
|
|
2224
|
+
campaignRecipient: {
|
|
2225
|
+
async find(params, options) {
|
|
2226
|
+
const { store_id, ...queryParams } = params || {};
|
|
2227
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2228
|
+
return apiConfig.httpClient.get(
|
|
2229
|
+
`/v1/stores/${target_store_id}/campaign-recipients`,
|
|
2230
|
+
{ ...options, params: queryParams }
|
|
2231
|
+
);
|
|
2232
|
+
},
|
|
2233
|
+
async get(params, options) {
|
|
2234
|
+
const { store_id, id, ...queryParams } = params;
|
|
2235
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2236
|
+
return apiConfig.httpClient.get(
|
|
2237
|
+
`/v1/stores/${target_store_id}/campaign-recipients/${id}`,
|
|
2238
|
+
{ ...options, params: { ...queryParams, store_id: target_store_id } }
|
|
2239
|
+
);
|
|
2240
|
+
},
|
|
2241
|
+
async update(params, options) {
|
|
2242
|
+
const { store_id, id, ...payload } = params;
|
|
2243
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2244
|
+
return apiConfig.httpClient.put(
|
|
2245
|
+
`/v1/stores/${target_store_id}/campaign-recipients/${id}`,
|
|
2246
|
+
payload,
|
|
2247
|
+
options
|
|
2070
2248
|
);
|
|
2071
2249
|
},
|
|
2072
|
-
async
|
|
2250
|
+
async updateDraft(params, options) {
|
|
2251
|
+
const { store_id, id, draft_id, ...payload } = params;
|
|
2252
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2253
|
+
return apiConfig.httpClient.put(
|
|
2254
|
+
`/v1/stores/${target_store_id}/campaign-recipients/${id}/drafts/${draft_id}`,
|
|
2255
|
+
payload,
|
|
2256
|
+
options
|
|
2257
|
+
);
|
|
2258
|
+
},
|
|
2259
|
+
async reply(params, options) {
|
|
2260
|
+
const { store_id, id, ...payload } = params;
|
|
2261
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2073
2262
|
return apiConfig.httpClient.post(
|
|
2074
|
-
`/v1/stores/${
|
|
2075
|
-
|
|
2263
|
+
`/v1/stores/${target_store_id}/campaign-recipients/${id}/reply`,
|
|
2264
|
+
payload,
|
|
2076
2265
|
options
|
|
2077
2266
|
);
|
|
2078
2267
|
},
|
|
2079
|
-
async
|
|
2080
|
-
|
|
2081
|
-
|
|
2268
|
+
async stop(params, options) {
|
|
2269
|
+
const { store_id, id, ...payload } = params;
|
|
2270
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2271
|
+
return apiConfig.httpClient.post(
|
|
2272
|
+
`/v1/stores/${target_store_id}/campaign-recipients/${id}/stop`,
|
|
2273
|
+
payload,
|
|
2082
2274
|
options
|
|
2083
2275
|
);
|
|
2084
2276
|
}
|
|
2085
2277
|
},
|
|
2278
|
+
campaignMessage: {
|
|
2279
|
+
async find(params, options) {
|
|
2280
|
+
const { store_id, ...queryParams } = params || {};
|
|
2281
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2282
|
+
return apiConfig.httpClient.get(
|
|
2283
|
+
`/v1/stores/${target_store_id}/campaign-messages`,
|
|
2284
|
+
{ ...options, params: queryParams }
|
|
2285
|
+
);
|
|
2286
|
+
},
|
|
2287
|
+
async update(params, options) {
|
|
2288
|
+
const { id, store_id, ...payload } = params;
|
|
2289
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2290
|
+
return apiConfig.httpClient.put(
|
|
2291
|
+
`/v1/stores/${target_store_id}/campaign-messages/${id}`,
|
|
2292
|
+
payload,
|
|
2293
|
+
options
|
|
2294
|
+
);
|
|
2295
|
+
}
|
|
2296
|
+
},
|
|
2297
|
+
suppression: {
|
|
2298
|
+
async create(params, options) {
|
|
2299
|
+
const { store_id, ...payload } = params;
|
|
2300
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2301
|
+
return apiConfig.httpClient.post(
|
|
2302
|
+
`/v1/stores/${target_store_id}/suppressions`,
|
|
2303
|
+
payload,
|
|
2304
|
+
options
|
|
2305
|
+
);
|
|
2306
|
+
},
|
|
2307
|
+
async update(params, options) {
|
|
2308
|
+
const { id, store_id, ...payload } = params;
|
|
2309
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2310
|
+
return apiConfig.httpClient.put(
|
|
2311
|
+
`/v1/stores/${target_store_id}/suppressions/${id}`,
|
|
2312
|
+
payload,
|
|
2313
|
+
options
|
|
2314
|
+
);
|
|
2315
|
+
},
|
|
2316
|
+
async get(params, options) {
|
|
2317
|
+
const target_store_id = params.store_id || apiConfig.storeId;
|
|
2318
|
+
return apiConfig.httpClient.get(
|
|
2319
|
+
`/v1/stores/${target_store_id}/suppressions/${params.id}`,
|
|
2320
|
+
options
|
|
2321
|
+
);
|
|
2322
|
+
},
|
|
2323
|
+
async find(params, options) {
|
|
2324
|
+
const { store_id, ...queryParams } = params || {};
|
|
2325
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2326
|
+
return apiConfig.httpClient.get(
|
|
2327
|
+
`/v1/stores/${target_store_id}/suppressions`,
|
|
2328
|
+
{ ...options, params: queryParams }
|
|
2329
|
+
);
|
|
2330
|
+
}
|
|
2331
|
+
},
|
|
2086
2332
|
activity: createActivityAdminApi(apiConfig)
|
|
2087
2333
|
};
|
|
2088
2334
|
};
|
|
2089
2335
|
|
|
2336
|
+
// src/api/support.ts
|
|
2337
|
+
function supportConversationQuery(params) {
|
|
2338
|
+
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
2339
|
+
if (params.message_limit) qs.set("message_limit", String(params.message_limit));
|
|
2340
|
+
if (typeof params.after_created_at === "number") qs.set("after_created_at", String(params.after_created_at));
|
|
2341
|
+
if (params.after_id) qs.set("after_id", params.after_id);
|
|
2342
|
+
return qs.toString();
|
|
2343
|
+
}
|
|
2344
|
+
function createStorefrontSupportApi(config) {
|
|
2345
|
+
const { httpClient, storeId } = config;
|
|
2346
|
+
return {
|
|
2347
|
+
async startConversation(params = {}, opts) {
|
|
2348
|
+
return httpClient.post(
|
|
2349
|
+
`/v1/storefront/${storeId}/support/conversations`,
|
|
2350
|
+
{ store_id: storeId, ...params },
|
|
2351
|
+
opts
|
|
2352
|
+
);
|
|
2353
|
+
},
|
|
2354
|
+
async sendMessage(params, opts) {
|
|
2355
|
+
return httpClient.post(
|
|
2356
|
+
`/v1/storefront/${storeId}/support/conversations/${params.conversation_id}/messages`,
|
|
2357
|
+
{ store_id: storeId, ...params },
|
|
2358
|
+
opts
|
|
2359
|
+
);
|
|
2360
|
+
},
|
|
2361
|
+
async getConversation(params, opts) {
|
|
2362
|
+
const qs = supportConversationQuery({ store_id: storeId, ...params });
|
|
2363
|
+
return httpClient.get(
|
|
2364
|
+
`/v1/storefront/${storeId}/support/conversations/${params.conversation_id}?${qs}`,
|
|
2365
|
+
opts
|
|
2366
|
+
);
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
function createAdminSupportApi(config) {
|
|
2371
|
+
const { httpClient } = config;
|
|
2372
|
+
return {
|
|
2373
|
+
agent: {
|
|
2374
|
+
async create(params, opts) {
|
|
2375
|
+
return httpClient.post(
|
|
2376
|
+
`/v1/stores/${params.store_id}/support/agents`,
|
|
2377
|
+
params,
|
|
2378
|
+
opts
|
|
2379
|
+
);
|
|
2380
|
+
},
|
|
2381
|
+
async get(params, opts) {
|
|
2382
|
+
return httpClient.get(
|
|
2383
|
+
`/v1/stores/${params.store_id}/support/agents/${params.id}?store_id=${params.store_id}`,
|
|
2384
|
+
opts
|
|
2385
|
+
);
|
|
2386
|
+
},
|
|
2387
|
+
async find(params, opts) {
|
|
2388
|
+
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
2389
|
+
if (params.status) qs.set("status", params.status);
|
|
2390
|
+
if (params.limit) qs.set("limit", String(params.limit));
|
|
2391
|
+
if (params.cursor) qs.set("cursor", params.cursor);
|
|
2392
|
+
return httpClient.get(
|
|
2393
|
+
`/v1/stores/${params.store_id}/support/agents?${qs}`,
|
|
2394
|
+
opts
|
|
2395
|
+
);
|
|
2396
|
+
},
|
|
2397
|
+
async update(params, opts) {
|
|
2398
|
+
return httpClient.put(
|
|
2399
|
+
`/v1/stores/${params.store_id}/support/agents/${params.id}`,
|
|
2400
|
+
params,
|
|
2401
|
+
opts
|
|
2402
|
+
);
|
|
2403
|
+
},
|
|
2404
|
+
async delete(params, opts) {
|
|
2405
|
+
return httpClient.delete(
|
|
2406
|
+
`/v1/stores/${params.store_id}/support/agents/${params.id}?store_id=${params.store_id}`,
|
|
2407
|
+
opts
|
|
2408
|
+
);
|
|
2409
|
+
}
|
|
2410
|
+
},
|
|
2411
|
+
conversation: {
|
|
2412
|
+
async find(params, opts) {
|
|
2413
|
+
const qs = new URLSearchParams({ store_id: params.store_id });
|
|
2414
|
+
if (params.status) qs.set("status", params.status);
|
|
2415
|
+
if (params.agent_id) qs.set("agent_id", params.agent_id);
|
|
2416
|
+
if (params.limit) qs.set("limit", String(params.limit));
|
|
2417
|
+
if (params.cursor) qs.set("cursor", params.cursor);
|
|
2418
|
+
return httpClient.get(
|
|
2419
|
+
`/v1/stores/${params.store_id}/support/conversations?${qs}`,
|
|
2420
|
+
opts
|
|
2421
|
+
);
|
|
2422
|
+
},
|
|
2423
|
+
async get(params, opts) {
|
|
2424
|
+
const qs = supportConversationQuery(params);
|
|
2425
|
+
return httpClient.get(
|
|
2426
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}?${qs}`,
|
|
2427
|
+
opts
|
|
2428
|
+
);
|
|
2429
|
+
},
|
|
2430
|
+
async sendMessage(params, opts) {
|
|
2431
|
+
return httpClient.post(
|
|
2432
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/messages`,
|
|
2433
|
+
params,
|
|
2434
|
+
opts
|
|
2435
|
+
);
|
|
2436
|
+
},
|
|
2437
|
+
async reply(params, opts) {
|
|
2438
|
+
return httpClient.post(
|
|
2439
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/reply`,
|
|
2440
|
+
params,
|
|
2441
|
+
opts
|
|
2442
|
+
);
|
|
2443
|
+
},
|
|
2444
|
+
async resolve(params, opts) {
|
|
2445
|
+
return httpClient.post(
|
|
2446
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/resolve`,
|
|
2447
|
+
params,
|
|
2448
|
+
opts
|
|
2449
|
+
);
|
|
2450
|
+
},
|
|
2451
|
+
async assign(params, opts) {
|
|
2452
|
+
return httpClient.post(
|
|
2453
|
+
`/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/assign`,
|
|
2454
|
+
params,
|
|
2455
|
+
opts
|
|
2456
|
+
);
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
// src/api/leadResearch.ts
|
|
2463
|
+
var createLeadResearchApi = (apiConfig) => {
|
|
2464
|
+
const storeId = (store_id) => store_id || apiConfig.storeId;
|
|
2465
|
+
return {
|
|
2466
|
+
async createRun(params, options) {
|
|
2467
|
+
const { store_id, ...payload } = params;
|
|
2468
|
+
return apiConfig.httpClient.post(
|
|
2469
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs`,
|
|
2470
|
+
payload,
|
|
2471
|
+
options
|
|
2472
|
+
);
|
|
2473
|
+
},
|
|
2474
|
+
async findRuns(params, options) {
|
|
2475
|
+
const { store_id, ...queryParams } = params || {};
|
|
2476
|
+
return apiConfig.httpClient.get(
|
|
2477
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs`,
|
|
2478
|
+
{ ...options, params: queryParams }
|
|
2479
|
+
);
|
|
2480
|
+
},
|
|
2481
|
+
async getRun(params, options) {
|
|
2482
|
+
return apiConfig.httpClient.get(
|
|
2483
|
+
`/v1/stores/${storeId(params.store_id)}/lead-research/runs/${params.id}`,
|
|
2484
|
+
options
|
|
2485
|
+
);
|
|
2486
|
+
},
|
|
2487
|
+
async updateRun(params, options) {
|
|
2488
|
+
const { store_id, id, ...payload } = params;
|
|
2489
|
+
return apiConfig.httpClient.patch(
|
|
2490
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs/${id}`,
|
|
2491
|
+
payload,
|
|
2492
|
+
options
|
|
2493
|
+
);
|
|
2494
|
+
},
|
|
2495
|
+
async cancelRun(params, options) {
|
|
2496
|
+
return apiConfig.httpClient.post(
|
|
2497
|
+
`/v1/stores/${storeId(params.store_id)}/lead-research/runs/${params.id}/cancel`,
|
|
2498
|
+
{},
|
|
2499
|
+
options
|
|
2500
|
+
);
|
|
2501
|
+
},
|
|
2502
|
+
async sendMessage(params, options) {
|
|
2503
|
+
const { store_id, run_id, ...payload } = params;
|
|
2504
|
+
return apiConfig.httpClient.post(
|
|
2505
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs/${run_id}/messages`,
|
|
2506
|
+
payload,
|
|
2507
|
+
options
|
|
2508
|
+
);
|
|
2509
|
+
},
|
|
2510
|
+
async findMessages(params, options) {
|
|
2511
|
+
const { store_id, run_id, ...queryParams } = params;
|
|
2512
|
+
return apiConfig.httpClient.get(
|
|
2513
|
+
`/v1/stores/${storeId(store_id)}/lead-research/runs/${run_id}/messages`,
|
|
2514
|
+
{ ...options, params: queryParams }
|
|
2515
|
+
);
|
|
2516
|
+
},
|
|
2517
|
+
async validateEmail(params, options) {
|
|
2518
|
+
const { store_id, ...payload } = params;
|
|
2519
|
+
return apiConfig.httpClient.post(
|
|
2520
|
+
`/v1/stores/${storeId(store_id)}/lead-research/validate-email`,
|
|
2521
|
+
payload,
|
|
2522
|
+
options
|
|
2523
|
+
);
|
|
2524
|
+
}
|
|
2525
|
+
};
|
|
2526
|
+
};
|
|
2527
|
+
|
|
2090
2528
|
// src/api/workflow.ts
|
|
2091
2529
|
var createWorkflowApi = (apiConfig) => {
|
|
2092
2530
|
return {
|
|
@@ -2212,121 +2650,6 @@ var createShippingApi = (apiConfig) => {
|
|
|
2212
2650
|
};
|
|
2213
2651
|
};
|
|
2214
2652
|
|
|
2215
|
-
// src/api/agent.ts
|
|
2216
|
-
var createAgentApi = (apiConfig) => {
|
|
2217
|
-
return {
|
|
2218
|
-
async createAgent(params, options) {
|
|
2219
|
-
const { store_id, ...payload } = params;
|
|
2220
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
2221
|
-
return apiConfig.httpClient.post(
|
|
2222
|
-
`/v1/stores/${target_store_id}/agents`,
|
|
2223
|
-
{ ...payload, store_id: target_store_id },
|
|
2224
|
-
options
|
|
2225
|
-
);
|
|
2226
|
-
},
|
|
2227
|
-
async updateAgent(params, options) {
|
|
2228
|
-
const { store_id, id, ...payload } = params;
|
|
2229
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
2230
|
-
return apiConfig.httpClient.put(
|
|
2231
|
-
`/v1/stores/${target_store_id}/agents/${id}`,
|
|
2232
|
-
payload,
|
|
2233
|
-
options
|
|
2234
|
-
);
|
|
2235
|
-
},
|
|
2236
|
-
async deleteAgent(params, options) {
|
|
2237
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2238
|
-
return apiConfig.httpClient.delete(
|
|
2239
|
-
`/v1/stores/${store_id}/agents/${params.id}`,
|
|
2240
|
-
options
|
|
2241
|
-
);
|
|
2242
|
-
},
|
|
2243
|
-
async getAgent(params, options) {
|
|
2244
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2245
|
-
return apiConfig.httpClient.get(
|
|
2246
|
-
`/v1/stores/${store_id}/agents/${params.id}`,
|
|
2247
|
-
options
|
|
2248
|
-
);
|
|
2249
|
-
},
|
|
2250
|
-
async getAgents(params, options) {
|
|
2251
|
-
const store_id = params?.store_id || apiConfig.storeId;
|
|
2252
|
-
const { store_id: _, ...queryParams } = params || {};
|
|
2253
|
-
return apiConfig.httpClient.get(`/v1/stores/${store_id}/agents`, {
|
|
2254
|
-
...options,
|
|
2255
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2256
|
-
});
|
|
2257
|
-
},
|
|
2258
|
-
async sendMessage(params, options) {
|
|
2259
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2260
|
-
const body = { message: params.message };
|
|
2261
|
-
if (params.chat_id) body.chat_id = params.chat_id;
|
|
2262
|
-
if (params.direct) body.direct = params.direct;
|
|
2263
|
-
return apiConfig.httpClient.post(
|
|
2264
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/messages`,
|
|
2265
|
-
body,
|
|
2266
|
-
options
|
|
2267
|
-
);
|
|
2268
|
-
},
|
|
2269
|
-
async getChats(params, options) {
|
|
2270
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2271
|
-
const queryParams = {};
|
|
2272
|
-
if (params.limit) queryParams.limit = String(params.limit);
|
|
2273
|
-
if (params.cursor) queryParams.cursor = params.cursor;
|
|
2274
|
-
return apiConfig.httpClient.get(
|
|
2275
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats`,
|
|
2276
|
-
{
|
|
2277
|
-
...options,
|
|
2278
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2279
|
-
}
|
|
2280
|
-
);
|
|
2281
|
-
},
|
|
2282
|
-
async getChat(params, options) {
|
|
2283
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2284
|
-
return apiConfig.httpClient.get(
|
|
2285
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
|
|
2286
|
-
options
|
|
2287
|
-
);
|
|
2288
|
-
},
|
|
2289
|
-
async updateChat(params, options) {
|
|
2290
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2291
|
-
return apiConfig.httpClient.put(
|
|
2292
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
|
|
2293
|
-
{ status: params.status },
|
|
2294
|
-
options
|
|
2295
|
-
);
|
|
2296
|
-
},
|
|
2297
|
-
async rateChat(params, options) {
|
|
2298
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2299
|
-
const body = { rating: params.rating };
|
|
2300
|
-
if (params.comment) body.comment = params.comment;
|
|
2301
|
-
return apiConfig.httpClient.post(
|
|
2302
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/rate`,
|
|
2303
|
-
body,
|
|
2304
|
-
options
|
|
2305
|
-
);
|
|
2306
|
-
},
|
|
2307
|
-
async getStoreChats(params, options) {
|
|
2308
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2309
|
-
const { store_id: _, ...queryParams } = params;
|
|
2310
|
-
return apiConfig.httpClient.get(`/v1/stores/${store_id}/chats`, {
|
|
2311
|
-
...options,
|
|
2312
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2313
|
-
});
|
|
2314
|
-
},
|
|
2315
|
-
async getChatMessages(params, options) {
|
|
2316
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
2317
|
-
const queryParams = {};
|
|
2318
|
-
if (params.limit) queryParams.limit = String(params.limit);
|
|
2319
|
-
return apiConfig.httpClient.get(
|
|
2320
|
-
`/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/messages`,
|
|
2321
|
-
{
|
|
2322
|
-
...options,
|
|
2323
|
-
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2324
|
-
}
|
|
2325
|
-
);
|
|
2326
|
-
}
|
|
2327
|
-
};
|
|
2328
|
-
};
|
|
2329
|
-
|
|
2330
2653
|
// src/api/emailTemplate.ts
|
|
2331
2654
|
var createEmailTemplateApi = (apiConfig) => {
|
|
2332
2655
|
return {
|
|
@@ -2380,6 +2703,15 @@ var createEmailTemplateApi = (apiConfig) => {
|
|
|
2380
2703
|
params: queryParams
|
|
2381
2704
|
}
|
|
2382
2705
|
);
|
|
2706
|
+
},
|
|
2707
|
+
async previewEmailTemplate(params, options) {
|
|
2708
|
+
const { store_id, id, ...payload } = params;
|
|
2709
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
2710
|
+
return apiConfig.httpClient.post(
|
|
2711
|
+
`/v1/stores/${target_store_id}/email-templates/${id}/preview`,
|
|
2712
|
+
payload,
|
|
2713
|
+
options
|
|
2714
|
+
);
|
|
2383
2715
|
}
|
|
2384
2716
|
};
|
|
2385
2717
|
};
|
|
@@ -2803,7 +3135,7 @@ function getFirstAvailableFCId(variant, quantity = 1) {
|
|
|
2803
3135
|
}
|
|
2804
3136
|
|
|
2805
3137
|
// src/index.ts
|
|
2806
|
-
var SDK_VERSION = "0.
|
|
3138
|
+
var SDK_VERSION = "0.9.2";
|
|
2807
3139
|
var SUPPORTED_FRAMEWORKS = [
|
|
2808
3140
|
"astro",
|
|
2809
3141
|
"react",
|
|
@@ -2936,15 +3268,42 @@ function createAdmin(config) {
|
|
|
2936
3268
|
};
|
|
2937
3269
|
const accountApi = createAccountApi(apiConfig);
|
|
2938
3270
|
const authApi = createAuthApi(apiConfig, updateSession);
|
|
2939
|
-
const storeApi = createStoreApi(apiConfig
|
|
3271
|
+
const storeApi = createStoreApi(apiConfig);
|
|
2940
3272
|
const platformApi = createPlatformApi(apiConfig);
|
|
2941
3273
|
const cmsApi = createCmsApi(apiConfig);
|
|
2942
3274
|
const eshopApi = createEshopApi(apiConfig);
|
|
2943
3275
|
const promoCodeApi = createPromoCodeApi(apiConfig);
|
|
2944
|
-
const crmApi =
|
|
3276
|
+
const crmApi = createProfileApi(apiConfig);
|
|
3277
|
+
const supportApi = createAdminSupportApi(apiConfig);
|
|
3278
|
+
const leadResearchApi = createLeadResearchApi(apiConfig);
|
|
3279
|
+
const leadResearch = {
|
|
3280
|
+
run: {
|
|
3281
|
+
create: leadResearchApi.createRun,
|
|
3282
|
+
find: leadResearchApi.findRuns,
|
|
3283
|
+
get: leadResearchApi.getRun,
|
|
3284
|
+
update: leadResearchApi.updateRun,
|
|
3285
|
+
cancel: leadResearchApi.cancelRun,
|
|
3286
|
+
sendMessage: leadResearchApi.sendMessage,
|
|
3287
|
+
findMessages: leadResearchApi.findMessages
|
|
3288
|
+
},
|
|
3289
|
+
message: {
|
|
3290
|
+
send: leadResearchApi.sendMessage,
|
|
3291
|
+
find: leadResearchApi.findMessages
|
|
3292
|
+
},
|
|
3293
|
+
email: {
|
|
3294
|
+
validate: leadResearchApi.validateEmail
|
|
3295
|
+
},
|
|
3296
|
+
createRun: leadResearchApi.createRun,
|
|
3297
|
+
findRuns: leadResearchApi.findRuns,
|
|
3298
|
+
getRun: leadResearchApi.getRun,
|
|
3299
|
+
updateRun: leadResearchApi.updateRun,
|
|
3300
|
+
cancelRun: leadResearchApi.cancelRun,
|
|
3301
|
+
sendMessage: leadResearchApi.sendMessage,
|
|
3302
|
+
findMessages: leadResearchApi.findMessages,
|
|
3303
|
+
validateEmail: leadResearchApi.validateEmail
|
|
3304
|
+
};
|
|
2945
3305
|
const locationApi = createLocationApi(apiConfig);
|
|
2946
3306
|
const marketApi = createMarketApi(apiConfig);
|
|
2947
|
-
const agentApi = createAgentApi(apiConfig);
|
|
2948
3307
|
const workflowApi = createWorkflowApi(apiConfig);
|
|
2949
3308
|
const formApi = createFormApi(apiConfig);
|
|
2950
3309
|
const taxonomyApi = createTaxonomyApi(apiConfig);
|
|
@@ -2996,7 +3355,8 @@ function createAdmin(config) {
|
|
|
2996
3355
|
update: emailTemplateApi.updateEmailTemplate,
|
|
2997
3356
|
delete: emailTemplateApi.deleteEmailTemplate,
|
|
2998
3357
|
get: emailTemplateApi.getEmailTemplate,
|
|
2999
|
-
find: emailTemplateApi.getEmailTemplates
|
|
3358
|
+
find: emailTemplateApi.getEmailTemplates,
|
|
3359
|
+
preview: emailTemplateApi.previewEmailTemplate
|
|
3000
3360
|
}
|
|
3001
3361
|
},
|
|
3002
3362
|
eshop: {
|
|
@@ -3047,41 +3407,27 @@ function createAdmin(config) {
|
|
|
3047
3407
|
promoCode: promoCodeApi
|
|
3048
3408
|
},
|
|
3049
3409
|
crm: {
|
|
3050
|
-
|
|
3410
|
+
profile: {
|
|
3051
3411
|
create: crmApi.create,
|
|
3052
3412
|
get: crmApi.get,
|
|
3053
3413
|
find: crmApi.find,
|
|
3054
3414
|
update: crmApi.update,
|
|
3055
3415
|
merge: crmApi.merge,
|
|
3416
|
+
import: crmApi.import,
|
|
3056
3417
|
revokeToken: crmApi.revokeToken,
|
|
3057
3418
|
revokeAllTokens: crmApi.revokeAllTokens
|
|
3058
3419
|
},
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
removeSubscriber: crmApi.audiences.removeSubscriber
|
|
3067
|
-
},
|
|
3420
|
+
profileList: crmApi.profileList,
|
|
3421
|
+
mailbox: crmApi.mailbox,
|
|
3422
|
+
campaign: crmApi.campaign,
|
|
3423
|
+
campaignRecipient: crmApi.campaignRecipient,
|
|
3424
|
+
campaignMessage: crmApi.campaignMessage,
|
|
3425
|
+
suppression: crmApi.suppression,
|
|
3426
|
+
leadResearch,
|
|
3068
3427
|
activity: crmApi.activity
|
|
3069
3428
|
},
|
|
3429
|
+
leadResearch,
|
|
3070
3430
|
automation: {
|
|
3071
|
-
agent: {
|
|
3072
|
-
create: agentApi.createAgent,
|
|
3073
|
-
update: agentApi.updateAgent,
|
|
3074
|
-
delete: agentApi.deleteAgent,
|
|
3075
|
-
get: agentApi.getAgent,
|
|
3076
|
-
find: agentApi.getAgents,
|
|
3077
|
-
sendMessage: agentApi.sendMessage,
|
|
3078
|
-
getChats: agentApi.getChats,
|
|
3079
|
-
getChat: agentApi.getChat,
|
|
3080
|
-
updateChat: agentApi.updateChat,
|
|
3081
|
-
rateChat: agentApi.rateChat,
|
|
3082
|
-
getStoreChats: agentApi.getStoreChats,
|
|
3083
|
-
getChatMessages: agentApi.getChatMessages
|
|
3084
|
-
},
|
|
3085
3431
|
workflow: {
|
|
3086
3432
|
create: workflowApi.createWorkflow,
|
|
3087
3433
|
update: workflowApi.updateWorkflow,
|
|
@@ -3091,7 +3437,8 @@ function createAdmin(config) {
|
|
|
3091
3437
|
trigger: workflowApi.triggerWorkflow,
|
|
3092
3438
|
getExecutions: workflowApi.getWorkflowExecutions,
|
|
3093
3439
|
getExecution: workflowApi.getWorkflowExecution
|
|
3094
|
-
}
|
|
3440
|
+
},
|
|
3441
|
+
support: supportApi
|
|
3095
3442
|
},
|
|
3096
3443
|
analytics: analyticsApi,
|
|
3097
3444
|
setStoreId: (storeId) => {
|
|
@@ -3134,22 +3481,22 @@ function createAdmin(config) {
|
|
|
3134
3481
|
};
|
|
3135
3482
|
return sdk;
|
|
3136
3483
|
}
|
|
3137
|
-
var
|
|
3138
|
-
function
|
|
3484
|
+
var PROFILE_STORAGE_KEY = "arky_profile_session";
|
|
3485
|
+
function readProfileSession() {
|
|
3139
3486
|
if (typeof window === "undefined") return null;
|
|
3140
3487
|
try {
|
|
3141
|
-
const raw = localStorage.getItem(
|
|
3488
|
+
const raw = localStorage.getItem(PROFILE_STORAGE_KEY);
|
|
3142
3489
|
return raw ? JSON.parse(raw) : null;
|
|
3143
3490
|
} catch {
|
|
3144
3491
|
return null;
|
|
3145
3492
|
}
|
|
3146
3493
|
}
|
|
3147
|
-
function
|
|
3494
|
+
function writeProfileSession(s) {
|
|
3148
3495
|
if (typeof window === "undefined") return;
|
|
3149
3496
|
if (s) {
|
|
3150
|
-
localStorage.setItem(
|
|
3497
|
+
localStorage.setItem(PROFILE_STORAGE_KEY, JSON.stringify(s));
|
|
3151
3498
|
} else {
|
|
3152
|
-
localStorage.removeItem(
|
|
3499
|
+
localStorage.removeItem(PROFILE_STORAGE_KEY);
|
|
3153
3500
|
}
|
|
3154
3501
|
}
|
|
3155
3502
|
function createStorefront(config) {
|
|
@@ -3158,10 +3505,10 @@ function createStorefront(config) {
|
|
|
3158
3505
|
const listeners = /* @__PURE__ */ new Set();
|
|
3159
3506
|
let bareIdentifyPromise = null;
|
|
3160
3507
|
function toPublic(s) {
|
|
3161
|
-
return s ? {
|
|
3508
|
+
return s ? { profile: s.profile, store: s.store, market: s.market } : null;
|
|
3162
3509
|
}
|
|
3163
3510
|
function emit() {
|
|
3164
|
-
const pub = toPublic(
|
|
3511
|
+
const pub = toPublic(readProfileSession());
|
|
3165
3512
|
for (const l of listeners) {
|
|
3166
3513
|
Promise.resolve().then(() => l(pub)).catch(() => {
|
|
3167
3514
|
});
|
|
@@ -3169,9 +3516,9 @@ function createStorefront(config) {
|
|
|
3169
3516
|
}
|
|
3170
3517
|
const updateSession = (updater) => {
|
|
3171
3518
|
if (config.apiToken) return;
|
|
3172
|
-
const prev =
|
|
3519
|
+
const prev = readProfileSession();
|
|
3173
3520
|
const next = updater(prev);
|
|
3174
|
-
|
|
3521
|
+
writeProfileSession(next);
|
|
3175
3522
|
emit();
|
|
3176
3523
|
};
|
|
3177
3524
|
const authStorage = config.apiToken ? {
|
|
@@ -3182,7 +3529,7 @@ function createStorefront(config) {
|
|
|
3182
3529
|
}
|
|
3183
3530
|
} : {
|
|
3184
3531
|
getTokens() {
|
|
3185
|
-
const s =
|
|
3532
|
+
const s = readProfileSession();
|
|
3186
3533
|
return s ? { access_token: s.access_token } : null;
|
|
3187
3534
|
},
|
|
3188
3535
|
onTokensRefreshed() {
|
|
@@ -3209,20 +3556,20 @@ function createStorefront(config) {
|
|
|
3209
3556
|
authStorage
|
|
3210
3557
|
};
|
|
3211
3558
|
const storefrontApi = createStorefrontApi(apiConfig, updateSession);
|
|
3212
|
-
const
|
|
3559
|
+
const profileApi = storefrontApi.crm.profile;
|
|
3213
3560
|
function identify(params) {
|
|
3214
3561
|
if (params?.market !== void 0) apiConfig.market = params.market;
|
|
3215
3562
|
const isBareCall = !params?.email && !params?.verify;
|
|
3216
3563
|
if (isBareCall && bareIdentifyPromise) return bareIdentifyPromise;
|
|
3217
3564
|
const promise = (async () => {
|
|
3218
3565
|
try {
|
|
3219
|
-
const result = await
|
|
3566
|
+
const result = await profileApi.identify({
|
|
3220
3567
|
market: apiConfig.market,
|
|
3221
3568
|
email: params?.email,
|
|
3222
3569
|
verify: params?.verify
|
|
3223
3570
|
});
|
|
3224
3571
|
return {
|
|
3225
|
-
|
|
3572
|
+
profile: result.profile,
|
|
3226
3573
|
store: result.store,
|
|
3227
3574
|
market: result.market
|
|
3228
3575
|
};
|
|
@@ -3231,9 +3578,9 @@ function createStorefront(config) {
|
|
|
3231
3578
|
const status = e?.statusCode || e?.status || e?.response?.status;
|
|
3232
3579
|
if (isBareCall && status === 401) {
|
|
3233
3580
|
updateSession(() => null);
|
|
3234
|
-
const result = await
|
|
3581
|
+
const result = await profileApi.identify({ market: apiConfig.market });
|
|
3235
3582
|
return {
|
|
3236
|
-
|
|
3583
|
+
profile: result.profile,
|
|
3237
3584
|
store: result.store,
|
|
3238
3585
|
market: result.market
|
|
3239
3586
|
};
|
|
@@ -3248,7 +3595,7 @@ function createStorefront(config) {
|
|
|
3248
3595
|
return promise;
|
|
3249
3596
|
}
|
|
3250
3597
|
async function verify(params) {
|
|
3251
|
-
const result = await
|
|
3598
|
+
const result = await profileApi.verify(params);
|
|
3252
3599
|
bareIdentifyPromise = null;
|
|
3253
3600
|
return result;
|
|
3254
3601
|
}
|
|
@@ -3256,7 +3603,7 @@ function createStorefront(config) {
|
|
|
3256
3603
|
if (config.apiToken) return;
|
|
3257
3604
|
bareIdentifyPromise = null;
|
|
3258
3605
|
try {
|
|
3259
|
-
await
|
|
3606
|
+
await profileApi.logout();
|
|
3260
3607
|
} catch {
|
|
3261
3608
|
updateSession(() => null);
|
|
3262
3609
|
}
|
|
@@ -3265,19 +3612,19 @@ function createStorefront(config) {
|
|
|
3265
3612
|
identify,
|
|
3266
3613
|
verify,
|
|
3267
3614
|
logout,
|
|
3268
|
-
me: () =>
|
|
3615
|
+
me: () => profileApi.getMe(),
|
|
3269
3616
|
get session() {
|
|
3270
3617
|
if (config.apiToken) return null;
|
|
3271
|
-
return toPublic(
|
|
3618
|
+
return toPublic(readProfileSession());
|
|
3272
3619
|
},
|
|
3273
3620
|
get isAuthenticated() {
|
|
3274
3621
|
if (config.apiToken) return true;
|
|
3275
|
-
const s =
|
|
3622
|
+
const s = readProfileSession();
|
|
3276
3623
|
return s !== null && !!s.access_token;
|
|
3277
3624
|
},
|
|
3278
3625
|
onAuthStateChanged(listener) {
|
|
3279
3626
|
listeners.add(listener);
|
|
3280
|
-
const current = toPublic(
|
|
3627
|
+
const current = toPublic(readProfileSession());
|
|
3281
3628
|
if (current) {
|
|
3282
3629
|
Promise.resolve().then(() => listener(current)).catch(() => {
|
|
3283
3630
|
});
|
|
@@ -3292,7 +3639,7 @@ function createStorefront(config) {
|
|
|
3292
3639
|
eshop: storefrontApi.eshop,
|
|
3293
3640
|
crm: storefrontApi.crm,
|
|
3294
3641
|
activity: storefrontApi.activity,
|
|
3295
|
-
|
|
3642
|
+
support: createStorefrontSupportApi(apiConfig),
|
|
3296
3643
|
setStoreId: (storeId) => {
|
|
3297
3644
|
apiConfig.storeId = storeId;
|
|
3298
3645
|
bareIdentifyPromise = null;
|