@livechat/developer-studio-api 3.0.43 → 3.0.45
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/dist/index.d.mts +135 -82
- package/dist/index.d.ts +135 -82
- package/dist/index.js +250 -132
- package/dist/index.mjs +248 -132
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -72,6 +72,8 @@ __export(src_exports, {
|
|
|
72
72
|
AdapterApiError: () => AdapterApiError,
|
|
73
73
|
ApiErrorBase: () => ApiErrorBase,
|
|
74
74
|
DpsApiError: () => DpsApiError,
|
|
75
|
+
MailchimpApiError: () => MailchimpApiError,
|
|
76
|
+
ShopifyApiError: () => ShopifyApiError,
|
|
75
77
|
UnauthorizeApiError: () => UnauthorizeApiError,
|
|
76
78
|
allAppTemplates: () => allAppTemplates,
|
|
77
79
|
api: () => api,
|
|
@@ -2364,8 +2366,128 @@ var neonApi = {
|
|
|
2364
2366
|
};
|
|
2365
2367
|
|
|
2366
2368
|
// src/apis/integrations/mailchimp/api.ts
|
|
2369
|
+
var import_axios14 = __toESM(require("axios"));
|
|
2370
|
+
|
|
2371
|
+
// src/apis/integrations/mailchimp/instance.ts
|
|
2367
2372
|
var import_axios13 = __toESM(require("axios"));
|
|
2373
|
+
var MailchimpApiError = class extends ApiErrorBase {
|
|
2374
|
+
constructor() {
|
|
2375
|
+
super(...arguments);
|
|
2376
|
+
this.name = "mailchimp";
|
|
2377
|
+
}
|
|
2378
|
+
};
|
|
2379
|
+
var getMailchimpClientUrl = (server) => `https://${server}.api.mailchimp.com/3.0`;
|
|
2380
|
+
var mailchimpClientInstance = import_axios13.default.create({
|
|
2381
|
+
headers: {
|
|
2382
|
+
"Content-Type": "application/json"
|
|
2383
|
+
}
|
|
2384
|
+
});
|
|
2385
|
+
mailchimpClientInstance.interceptors.response.use(
|
|
2386
|
+
(r) => r,
|
|
2387
|
+
(error) => {
|
|
2388
|
+
var _a, _b, _c, _d;
|
|
2389
|
+
if (import_axios13.default.isAxiosError(error)) {
|
|
2390
|
+
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
2391
|
+
throw new UnauthorizeApiError("mailchimp");
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
return Promise.reject(
|
|
2395
|
+
new MailchimpApiError(
|
|
2396
|
+
error.message,
|
|
2397
|
+
(_b = error.response) == null ? void 0 : _b.data,
|
|
2398
|
+
(_d = (_c = error.response) == null ? void 0 : _c.status) != null ? _d : 400
|
|
2399
|
+
)
|
|
2400
|
+
);
|
|
2401
|
+
}
|
|
2402
|
+
);
|
|
2403
|
+
function getMailchimpClientAuthorization(req) {
|
|
2404
|
+
return {
|
|
2405
|
+
server: req.headers["mailchimp-server"],
|
|
2406
|
+
token: req.headers["mailchimp-token"]
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
function getMailchimpClientConfig(options = {}) {
|
|
2410
|
+
var _a, _b;
|
|
2411
|
+
const currentBaseUrl = mailchimpClientInstance.defaults.baseURL;
|
|
2412
|
+
const currentHeaders = mailchimpClientInstance.defaults.headers;
|
|
2413
|
+
const config = {
|
|
2414
|
+
baseUrl: (_a = options.server ? getMailchimpClientUrl(options.server) : void 0) != null ? _a : currentBaseUrl,
|
|
2415
|
+
authorization: (_b = options.token ? `Bearer ${options.token}` : void 0) != null ? _b : currentHeaders.Authorization
|
|
2416
|
+
};
|
|
2417
|
+
if (options.ensureAuthorizationToken && (!config.authorization || !config.baseUrl)) {
|
|
2418
|
+
throw new UnauthorizeApiError("mailchimp");
|
|
2419
|
+
}
|
|
2420
|
+
return {
|
|
2421
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
2422
|
+
};
|
|
2423
|
+
}
|
|
2424
|
+
function initMailchimpClient(token, server) {
|
|
2425
|
+
if (token && server) {
|
|
2426
|
+
updateMailchimpClient(token);
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
function updateMailchimpClient(token, server) {
|
|
2430
|
+
const defaults = mailchimpClientInstance.defaults;
|
|
2431
|
+
const headers = defaults.headers;
|
|
2432
|
+
if (token) {
|
|
2433
|
+
headers.Authorization = `Bearer ${token}`;
|
|
2434
|
+
} else {
|
|
2435
|
+
delete headers.Authorization;
|
|
2436
|
+
}
|
|
2437
|
+
if (server) {
|
|
2438
|
+
defaults.baseURL = getMailchimpClientUrl(server);
|
|
2439
|
+
} else {
|
|
2440
|
+
delete defaults.baseURL;
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
// src/apis/integrations/mailchimp/lists/webhooks/api.ts
|
|
2445
|
+
var mailchimpListsWebhooksApi = {
|
|
2446
|
+
list(listId, authorization) {
|
|
2447
|
+
return __async(this, null, function* () {
|
|
2448
|
+
const response = yield mailchimpClientInstance.get(
|
|
2449
|
+
`/lists/${listId}/webhooks`,
|
|
2450
|
+
getMailchimpClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
2451
|
+
ensureAuthorizationToken: true
|
|
2452
|
+
}))
|
|
2453
|
+
);
|
|
2454
|
+
return response.data;
|
|
2455
|
+
});
|
|
2456
|
+
},
|
|
2457
|
+
add(listId, webhook, authorization) {
|
|
2458
|
+
return __async(this, null, function* () {
|
|
2459
|
+
const response = yield mailchimpClientInstance.post(
|
|
2460
|
+
`/list/${listId}/webhooks`,
|
|
2461
|
+
{
|
|
2462
|
+
webhook
|
|
2463
|
+
},
|
|
2464
|
+
getMailchimpClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
2465
|
+
ensureAuthorizationToken: true
|
|
2466
|
+
}))
|
|
2467
|
+
);
|
|
2468
|
+
return response.data;
|
|
2469
|
+
});
|
|
2470
|
+
},
|
|
2471
|
+
delete(listId, webhookId, authorization) {
|
|
2472
|
+
return __async(this, null, function* () {
|
|
2473
|
+
yield mailchimpClientInstance.delete(
|
|
2474
|
+
`/lists/${listId}/webhooks/${webhookId}`,
|
|
2475
|
+
getMailchimpClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
2476
|
+
ensureAuthorizationToken: true
|
|
2477
|
+
}))
|
|
2478
|
+
);
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
};
|
|
2482
|
+
|
|
2483
|
+
// src/apis/integrations/mailchimp/lists/api.ts
|
|
2484
|
+
var mailchimpListsApi = {
|
|
2485
|
+
webhooks: mailchimpListsWebhooksApi
|
|
2486
|
+
};
|
|
2487
|
+
|
|
2488
|
+
// src/apis/integrations/mailchimp/api.ts
|
|
2368
2489
|
var mailchimpApi = {
|
|
2490
|
+
lists: mailchimpListsApi,
|
|
2369
2491
|
getToken(code, clientId, clientSecret, redirectUri) {
|
|
2370
2492
|
return __async(this, null, function* () {
|
|
2371
2493
|
var _a;
|
|
@@ -2376,7 +2498,7 @@ var mailchimpApi = {
|
|
|
2376
2498
|
redirect_uri: redirectUri,
|
|
2377
2499
|
grant_type: "authorization_code"
|
|
2378
2500
|
});
|
|
2379
|
-
const tokenResponse = yield
|
|
2501
|
+
const tokenResponse = yield import_axios14.default.post(
|
|
2380
2502
|
"https://login.mailchimp.com/oauth2/token",
|
|
2381
2503
|
data,
|
|
2382
2504
|
{
|
|
@@ -2397,7 +2519,7 @@ var mailchimpApi = {
|
|
|
2397
2519
|
return __async(this, arguments, function* ({ token }) {
|
|
2398
2520
|
const {
|
|
2399
2521
|
data: { dc: server }
|
|
2400
|
-
} = yield
|
|
2522
|
+
} = yield import_axios14.default.get(
|
|
2401
2523
|
"https://login.mailchimp.com/oauth2/metadata",
|
|
2402
2524
|
{
|
|
2403
2525
|
headers: {
|
|
@@ -2414,8 +2536,121 @@ var mailchimpApi = {
|
|
|
2414
2536
|
};
|
|
2415
2537
|
|
|
2416
2538
|
// src/apis/integrations/shopify/api.ts
|
|
2417
|
-
var
|
|
2539
|
+
var import_axios16 = __toESM(require("axios"));
|
|
2540
|
+
|
|
2541
|
+
// src/apis/integrations/shopify/instance.ts
|
|
2542
|
+
var import_axios15 = __toESM(require("axios"));
|
|
2543
|
+
var ShopifyApiError = class extends ApiErrorBase {
|
|
2544
|
+
constructor() {
|
|
2545
|
+
super(...arguments);
|
|
2546
|
+
this.name = "shopify";
|
|
2547
|
+
}
|
|
2548
|
+
};
|
|
2549
|
+
var shopifyClientInstance = import_axios15.default.create();
|
|
2550
|
+
shopifyClientInstance.interceptors.response.use(
|
|
2551
|
+
(r) => r,
|
|
2552
|
+
(error) => {
|
|
2553
|
+
var _a, _b, _c, _d;
|
|
2554
|
+
if (import_axios15.default.isAxiosError(error)) {
|
|
2555
|
+
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
2556
|
+
throw new UnauthorizeApiError("shopify");
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
return Promise.reject(
|
|
2560
|
+
new ShopifyApiError(
|
|
2561
|
+
error.message,
|
|
2562
|
+
(_b = error.response) == null ? void 0 : _b.data,
|
|
2563
|
+
(_d = (_c = error.response) == null ? void 0 : _c.status) != null ? _d : 400
|
|
2564
|
+
)
|
|
2565
|
+
);
|
|
2566
|
+
}
|
|
2567
|
+
);
|
|
2568
|
+
var getShopifyClientUrl = (store) => `https://${store}.myshopify.com/admin/api/2024-04`;
|
|
2569
|
+
function getShopifyClientAuthorization(req) {
|
|
2570
|
+
return {
|
|
2571
|
+
shop: req.headers["shopify-shop"],
|
|
2572
|
+
token: req.headers["shopify-token"]
|
|
2573
|
+
};
|
|
2574
|
+
}
|
|
2575
|
+
function getShopifyClientConfig(options) {
|
|
2576
|
+
var _a, _b;
|
|
2577
|
+
const currentBaseUrl = shopifyClientInstance.defaults.baseURL;
|
|
2578
|
+
const currentHeaders = shopifyClientInstance.defaults.headers;
|
|
2579
|
+
const config = {
|
|
2580
|
+
baseUrl: (_a = options.shop ? getShopifyClientUrl(options.shop) : void 0) != null ? _a : currentBaseUrl,
|
|
2581
|
+
authorization: (_b = options.token ? options.token : void 0) != null ? _b : currentHeaders["X-Shopify-Access-Token"]
|
|
2582
|
+
};
|
|
2583
|
+
if (options.ensureAuthorizationToken && (!config.authorization || !config.baseUrl)) {
|
|
2584
|
+
throw new UnauthorizeApiError("shopify");
|
|
2585
|
+
}
|
|
2586
|
+
return {
|
|
2587
|
+
baseURL: config.baseUrl,
|
|
2588
|
+
headers: __spreadValues({}, config.authorization ? { "X-Shopify-Access-Token": config.authorization } : {})
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
function initShopifyClient(token, shop) {
|
|
2592
|
+
if (token && shop) {
|
|
2593
|
+
updateShopifyClient(token);
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
function updateShopifyClient(token, shop) {
|
|
2597
|
+
const defaults = shopifyClientInstance.defaults;
|
|
2598
|
+
const headers = defaults.headers;
|
|
2599
|
+
if (token) {
|
|
2600
|
+
headers.Authorization = `Bearer ${token}`;
|
|
2601
|
+
} else {
|
|
2602
|
+
delete headers.Authorization;
|
|
2603
|
+
}
|
|
2604
|
+
if (shop) {
|
|
2605
|
+
defaults.baseURL = getShopifyClientUrl(shop);
|
|
2606
|
+
} else {
|
|
2607
|
+
delete defaults.baseURL;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
// src/apis/integrations/shopify/webhooks/api.ts
|
|
2612
|
+
var shopifyWebhooksApi = {
|
|
2613
|
+
list(options, authorization) {
|
|
2614
|
+
return __async(this, null, function* () {
|
|
2615
|
+
const params = new URLSearchParams(options);
|
|
2616
|
+
const response = yield shopifyClientInstance.get(
|
|
2617
|
+
`/webhooks.json?${params.toString()}`,
|
|
2618
|
+
getShopifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
2619
|
+
ensureAuthorizationToken: true
|
|
2620
|
+
}))
|
|
2621
|
+
);
|
|
2622
|
+
return response.data;
|
|
2623
|
+
});
|
|
2624
|
+
},
|
|
2625
|
+
register(webhook, authorization) {
|
|
2626
|
+
return __async(this, null, function* () {
|
|
2627
|
+
const response = yield shopifyClientInstance.post(
|
|
2628
|
+
`/webhooks.json`,
|
|
2629
|
+
{
|
|
2630
|
+
webhook
|
|
2631
|
+
},
|
|
2632
|
+
getShopifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
2633
|
+
ensureAuthorizationToken: true
|
|
2634
|
+
}))
|
|
2635
|
+
);
|
|
2636
|
+
return response.data;
|
|
2637
|
+
});
|
|
2638
|
+
},
|
|
2639
|
+
unregister(webhookId, authorization) {
|
|
2640
|
+
return __async(this, null, function* () {
|
|
2641
|
+
yield shopifyClientInstance.delete(
|
|
2642
|
+
`/webhooks/${webhookId}.json`,
|
|
2643
|
+
getShopifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
2644
|
+
ensureAuthorizationToken: true
|
|
2645
|
+
}))
|
|
2646
|
+
);
|
|
2647
|
+
});
|
|
2648
|
+
}
|
|
2649
|
+
};
|
|
2650
|
+
|
|
2651
|
+
// src/apis/integrations/shopify/api.ts
|
|
2418
2652
|
var shopifyApi = {
|
|
2653
|
+
webhooks: shopifyWebhooksApi,
|
|
2419
2654
|
getToken(shop, code, clientId, clientSecret, redirectUri) {
|
|
2420
2655
|
return __async(this, null, function* () {
|
|
2421
2656
|
var _a;
|
|
@@ -2426,8 +2661,8 @@ var shopifyApi = {
|
|
|
2426
2661
|
redirect_uri: redirectUri,
|
|
2427
2662
|
grant_type: "authorization_code"
|
|
2428
2663
|
});
|
|
2429
|
-
const response = yield
|
|
2430
|
-
`https://${shop
|
|
2664
|
+
const response = yield import_axios16.default.post(
|
|
2665
|
+
`https://${shop}.myshopify.com/admin/oauth/access_token`,
|
|
2431
2666
|
data,
|
|
2432
2667
|
{
|
|
2433
2668
|
headers: {
|
|
@@ -2456,7 +2691,7 @@ var integrationsApi = {
|
|
|
2456
2691
|
};
|
|
2457
2692
|
|
|
2458
2693
|
// src/apis/products/livechat/instance.ts
|
|
2459
|
-
var
|
|
2694
|
+
var import_axios17 = __toESM(require("axios"));
|
|
2460
2695
|
var REGION = {
|
|
2461
2696
|
FRA: "fra",
|
|
2462
2697
|
DAL: "dal",
|
|
@@ -2470,7 +2705,7 @@ var getRegion = (token) => {
|
|
|
2470
2705
|
return region;
|
|
2471
2706
|
}
|
|
2472
2707
|
};
|
|
2473
|
-
var livechatClientInstance =
|
|
2708
|
+
var livechatClientInstance = import_axios17.default.create({
|
|
2474
2709
|
baseURL: "https://api.labs.livechatinc.com"
|
|
2475
2710
|
});
|
|
2476
2711
|
function getLiveChatClientAuthorization(req) {
|
|
@@ -2989,14 +3224,14 @@ var productsApi = {
|
|
|
2989
3224
|
};
|
|
2990
3225
|
|
|
2991
3226
|
// src/apis/platform/accounts/instance.ts
|
|
2992
|
-
var
|
|
3227
|
+
var import_axios18 = __toESM(require("axios"));
|
|
2993
3228
|
var AccountsApiError = class extends ApiErrorBase {
|
|
2994
3229
|
constructor() {
|
|
2995
3230
|
super(...arguments);
|
|
2996
3231
|
this.name = "accounts";
|
|
2997
3232
|
}
|
|
2998
3233
|
};
|
|
2999
|
-
var platformAccountsClientInstance =
|
|
3234
|
+
var platformAccountsClientInstance = import_axios18.default.create({
|
|
3000
3235
|
baseURL: "https://accounts.labs.livechatinc.com"
|
|
3001
3236
|
});
|
|
3002
3237
|
platformAccountsClientInstance.interceptors.response.use(
|
|
@@ -3326,14 +3561,14 @@ var platformAccountsApi = {
|
|
|
3326
3561
|
};
|
|
3327
3562
|
|
|
3328
3563
|
// src/apis/platform/dps/instance.ts
|
|
3329
|
-
var
|
|
3564
|
+
var import_axios19 = __toESM(require("axios"));
|
|
3330
3565
|
var DpsApiError = class extends ApiErrorBase {
|
|
3331
3566
|
constructor() {
|
|
3332
3567
|
super(...arguments);
|
|
3333
3568
|
this.name = "dps";
|
|
3334
3569
|
}
|
|
3335
3570
|
};
|
|
3336
|
-
var platformDpsClientInstance =
|
|
3571
|
+
var platformDpsClientInstance = import_axios19.default.create({
|
|
3337
3572
|
baseURL: "https://dev-platform.labs.livechatinc.com"
|
|
3338
3573
|
});
|
|
3339
3574
|
platformDpsClientInstance.interceptors.response.use(
|
|
@@ -4892,7 +5127,7 @@ var platformDpsApi = {
|
|
|
4892
5127
|
};
|
|
4893
5128
|
|
|
4894
5129
|
// src/apis/platform/adapter/instance.ts
|
|
4895
|
-
var
|
|
5130
|
+
var import_axios20 = __toESM(require("axios"));
|
|
4896
5131
|
var REGION2 = {
|
|
4897
5132
|
FRA: "fra",
|
|
4898
5133
|
DAL: "dal",
|
|
@@ -4912,7 +5147,7 @@ var AdapterApiError = class extends ApiErrorBase {
|
|
|
4912
5147
|
this.name = "adapter";
|
|
4913
5148
|
}
|
|
4914
5149
|
};
|
|
4915
|
-
var platformAdapterClientInstance =
|
|
5150
|
+
var platformAdapterClientInstance = import_axios20.default.create({
|
|
4916
5151
|
baseURL: "https://platform.labs.text.com/console-adapter/api",
|
|
4917
5152
|
headers: {
|
|
4918
5153
|
"Content-Type": "application/json"
|
|
@@ -5563,125 +5798,6 @@ var platformAdapterConductorApi = {
|
|
|
5563
5798
|
}
|
|
5564
5799
|
};
|
|
5565
5800
|
|
|
5566
|
-
// src/apis/integrations/mailchimp/instance.ts
|
|
5567
|
-
var import_axios19 = __toESM(require("axios"));
|
|
5568
|
-
var getMailchimpClientUrl = (server) => `https://${server}.api.mailchimp.com/3.0`;
|
|
5569
|
-
var mailchimpClientInstance = import_axios19.default.create({
|
|
5570
|
-
headers: {
|
|
5571
|
-
"Content-Type": "application/json"
|
|
5572
|
-
}
|
|
5573
|
-
});
|
|
5574
|
-
mailchimpClientInstance.interceptors.response.use(
|
|
5575
|
-
(r) => r,
|
|
5576
|
-
(error) => {
|
|
5577
|
-
var _a;
|
|
5578
|
-
if (import_axios19.default.isAxiosError(error)) {
|
|
5579
|
-
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
5580
|
-
throw new UnauthorizeApiError("mailchimp");
|
|
5581
|
-
}
|
|
5582
|
-
}
|
|
5583
|
-
throw error;
|
|
5584
|
-
}
|
|
5585
|
-
);
|
|
5586
|
-
function getMailchimpClientAuthorization(req) {
|
|
5587
|
-
return {
|
|
5588
|
-
server: req.headers["mailchimp-server"],
|
|
5589
|
-
token: req.headers["mailchimp-token"]
|
|
5590
|
-
};
|
|
5591
|
-
}
|
|
5592
|
-
function getMailchimpClientConfig(options = {}) {
|
|
5593
|
-
var _a, _b;
|
|
5594
|
-
const currentBaseUrl = mailchimpClientInstance.defaults.baseURL;
|
|
5595
|
-
const currentHeaders = mailchimpClientInstance.defaults.headers;
|
|
5596
|
-
const config = {
|
|
5597
|
-
baseUrl: (_a = options.server ? getMailchimpClientUrl(options.server) : void 0) != null ? _a : currentBaseUrl,
|
|
5598
|
-
authorization: (_b = options.token ? `Bearer ${options.token}` : void 0) != null ? _b : currentHeaders.Authorization
|
|
5599
|
-
};
|
|
5600
|
-
if (options.ensureAuthorizationToken && (!config.authorization || !config.baseUrl)) {
|
|
5601
|
-
throw new UnauthorizeApiError("mailchimp");
|
|
5602
|
-
}
|
|
5603
|
-
return {
|
|
5604
|
-
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
5605
|
-
};
|
|
5606
|
-
}
|
|
5607
|
-
function initMailchimpClient(token, server) {
|
|
5608
|
-
if (token && server) {
|
|
5609
|
-
updateMailchimpClient(token);
|
|
5610
|
-
}
|
|
5611
|
-
}
|
|
5612
|
-
function updateMailchimpClient(token, server) {
|
|
5613
|
-
const defaults = mailchimpClientInstance.defaults;
|
|
5614
|
-
const headers = defaults.headers;
|
|
5615
|
-
if (token) {
|
|
5616
|
-
headers.Authorization = `Bearer ${token}`;
|
|
5617
|
-
} else {
|
|
5618
|
-
delete headers.Authorization;
|
|
5619
|
-
}
|
|
5620
|
-
if (server) {
|
|
5621
|
-
defaults.baseURL = getMailchimpClientUrl(server);
|
|
5622
|
-
} else {
|
|
5623
|
-
delete defaults.baseURL;
|
|
5624
|
-
}
|
|
5625
|
-
}
|
|
5626
|
-
|
|
5627
|
-
// src/apis/integrations/shopify/instance.ts
|
|
5628
|
-
var import_axios20 = __toESM(require("axios"));
|
|
5629
|
-
var shopifyClientInstance = import_axios20.default.create();
|
|
5630
|
-
shopifyClientInstance.interceptors.response.use(
|
|
5631
|
-
(r) => r,
|
|
5632
|
-
(error) => {
|
|
5633
|
-
var _a;
|
|
5634
|
-
if (import_axios20.default.isAxiosError(error)) {
|
|
5635
|
-
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
5636
|
-
throw new UnauthorizeApiError("shopify");
|
|
5637
|
-
}
|
|
5638
|
-
}
|
|
5639
|
-
throw error;
|
|
5640
|
-
}
|
|
5641
|
-
);
|
|
5642
|
-
var getShopifyClientUrl = (store) => `https://${store}.myshopify.com/admin/api`;
|
|
5643
|
-
function getShopifyClientAuthorization(req) {
|
|
5644
|
-
return {
|
|
5645
|
-
shop: req.headers["shopify-shop"],
|
|
5646
|
-
token: req.headers["shopify-token"]
|
|
5647
|
-
};
|
|
5648
|
-
}
|
|
5649
|
-
function getShopifyClientConfig(options) {
|
|
5650
|
-
var _a, _b;
|
|
5651
|
-
const currentBaseUrl = shopifyClientInstance.defaults.baseURL;
|
|
5652
|
-
const currentHeaders = shopifyClientInstance.defaults.headers;
|
|
5653
|
-
const config = {
|
|
5654
|
-
baseUrl: (_a = options.shop ? getShopifyClientUrl(options.shop) : void 0) != null ? _a : currentBaseUrl,
|
|
5655
|
-
authorization: (_b = options.token ? options.token : void 0) != null ? _b : currentHeaders["X-Shopify-Access-Token"]
|
|
5656
|
-
};
|
|
5657
|
-
if (options.ensureAuthorizationToken && (!config.authorization || !config.baseUrl)) {
|
|
5658
|
-
throw new UnauthorizeApiError("shopify");
|
|
5659
|
-
}
|
|
5660
|
-
return {
|
|
5661
|
-
baseURL: config.baseUrl,
|
|
5662
|
-
headers: __spreadValues({}, config.authorization ? { "X-Shopify-Access-Token": config.authorization } : {})
|
|
5663
|
-
};
|
|
5664
|
-
}
|
|
5665
|
-
function initShopifyClient(token, shop) {
|
|
5666
|
-
if (token && shop) {
|
|
5667
|
-
updateShopifyClient(token);
|
|
5668
|
-
}
|
|
5669
|
-
}
|
|
5670
|
-
function updateShopifyClient(token, shop) {
|
|
5671
|
-
const defaults = shopifyClientInstance.defaults;
|
|
5672
|
-
const headers = defaults.headers;
|
|
5673
|
-
if (token) {
|
|
5674
|
-
headers.Authorization = `Bearer ${token}`;
|
|
5675
|
-
} else {
|
|
5676
|
-
delete headers.Authorization;
|
|
5677
|
-
}
|
|
5678
|
-
if (shop) {
|
|
5679
|
-
defaults.baseURL = getShopifyClientUrl(shop);
|
|
5680
|
-
} else {
|
|
5681
|
-
delete defaults.baseURL;
|
|
5682
|
-
}
|
|
5683
|
-
}
|
|
5684
|
-
|
|
5685
5801
|
// src/apis/platform/billing/instance.ts
|
|
5686
5802
|
var import_axios21 = __toESM(require("axios"));
|
|
5687
5803
|
var platformBillingClientInstance = import_axios21.default.create({
|
|
@@ -5946,6 +6062,8 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
|
|
|
5946
6062
|
AdapterApiError,
|
|
5947
6063
|
ApiErrorBase,
|
|
5948
6064
|
DpsApiError,
|
|
6065
|
+
MailchimpApiError,
|
|
6066
|
+
ShopifyApiError,
|
|
5949
6067
|
UnauthorizeApiError,
|
|
5950
6068
|
allAppTemplates,
|
|
5951
6069
|
api,
|