@livechat/developer-studio-api 3.0.8 → 3.0.9

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.js CHANGED
@@ -84,6 +84,7 @@ __export(src_exports, {
84
84
  getEmptyAppAutoReview: () => getEmptyAppAutoReview,
85
85
  getGitHubClientAuthorization: () => getGitHubClientAuthorization,
86
86
  getGithubClientRequestConfig: () => getGithubClientRequestConfig,
87
+ getIntegrationFlowUrl: () => getIntegrationFlowUrl,
87
88
  getLiveChatClientAuthorization: () => getLiveChatClientAuthorization,
88
89
  getLiveChatClientConfig: () => getLiveChatClientConfig,
89
90
  getNeonClientAuthorization: () => getNeonClientAuthorization,
@@ -166,6 +167,9 @@ var UnauthorizeApiError = class extends Error {
166
167
  this.kind = "unauthorized";
167
168
  this.code = 401;
168
169
  }
170
+ withCustomMessage(_message) {
171
+ return this;
172
+ }
169
173
  };
170
174
 
171
175
  // src/apis/integrations/github/instance.ts
@@ -632,6 +636,9 @@ var gitHubApi = {
632
636
  }
633
637
  };
634
638
 
639
+ // src/apis/integrations/netlify/account/api.ts
640
+ var import_axios5 = require("axios");
641
+
635
642
  // src/apis/integrations/netlify/instance.ts
636
643
  var import_axios4 = __toESM(require("axios"));
637
644
  var netlifyClientInstance = import_axios4.default.create({
@@ -704,7 +711,7 @@ var netlifyAccountApi = {
704
711
  targetAccountId = yield this.getAccount(authorization);
705
712
  }
706
713
  if (!targetAccountId) {
707
- throw new Error("No account");
714
+ throw new import_axios5.AxiosError("No account", "404");
708
715
  }
709
716
  const { data: envs } = yield netlifyClientInstance.get(
710
717
  `/accounts/${targetAccountId}/env?site_id=${siteId}&scope=all&context=all&level=all`,
@@ -722,7 +729,7 @@ var netlifyAccountApi = {
722
729
  targetAccountId = yield this.getAccount(authorization);
723
730
  }
724
731
  if (!targetAccountId) {
725
- throw new Error("No account");
732
+ throw new import_axios5.AxiosError("No account", "404");
726
733
  }
727
734
  const { data: envs } = yield netlifyClientInstance.get(
728
735
  `/accounts/${targetAccountId}/env/${envKey}?site_id=${siteId}`,
@@ -741,7 +748,7 @@ var netlifyAccountApi = {
741
748
  targetAccountId = yield this.getAccount(authorization);
742
749
  }
743
750
  if (!targetAccountId) {
744
- throw new Error("No account");
751
+ throw new import_axios5.AxiosError("No account", "404");
745
752
  }
746
753
  if (!targetEnvs) {
747
754
  const response = yield netlifyClientInstance.get(
@@ -789,7 +796,7 @@ var netlifyAccountApi = {
789
796
  targetAccountId = yield this.getAccount(authorization);
790
797
  }
791
798
  if (!accountId) {
792
- throw new Error("No account");
799
+ throw new import_axios5.AxiosError("No account", "404");
793
800
  }
794
801
  yield netlifyClientInstance.delete(
795
802
  `/accounts/${targetAccountId}/env/${envKey}?site_id=${siteId}`,
@@ -1089,18 +1096,18 @@ var netlifyApi = {
1089
1096
  };
1090
1097
 
1091
1098
  // src/apis/integrations/planetscale/api.ts
1092
- var import_axios6 = __toESM(require("axios"));
1099
+ var import_axios7 = __toESM(require("axios"));
1093
1100
 
1094
1101
  // src/apis/integrations/planetscale/instance.ts
1095
- var import_axios5 = __toESM(require("axios"));
1096
- var planetScaleClientInstance = import_axios5.default.create({
1102
+ var import_axios6 = __toESM(require("axios"));
1103
+ var planetScaleClientInstance = import_axios6.default.create({
1097
1104
  baseURL: "https://api.planetscale.com"
1098
1105
  });
1099
1106
  planetScaleClientInstance.interceptors.response.use(
1100
1107
  (r) => r,
1101
1108
  (error) => {
1102
1109
  var _a;
1103
- if (import_axios5.default.isAxiosError(error)) {
1110
+ if (import_axios6.default.isAxiosError(error)) {
1104
1111
  if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
1105
1112
  throw new UnauthorizeApiError("planetscale");
1106
1113
  }
@@ -1296,7 +1303,7 @@ var planetscaleApi = {
1296
1303
  redirect_uri: redirectUrl,
1297
1304
  grant_type: "authorization_code"
1298
1305
  });
1299
- const response = yield import_axios6.default.post(
1306
+ const response = yield import_axios7.default.post(
1300
1307
  `https://api.planetscale.com/v1/organizations/${organization}/oauth-applications/${applicationId}/token`,
1301
1308
  data,
1302
1309
  {
@@ -1316,8 +1323,8 @@ var planetscaleApi = {
1316
1323
  };
1317
1324
 
1318
1325
  // src/apis/integrations/text/instance.ts
1319
- var import_axios7 = __toESM(require("axios"));
1320
- var textClientInstance = import_axios7.default.create({
1326
+ var import_axios8 = __toESM(require("axios"));
1327
+ var textClientInstance = import_axios8.default.create({
1321
1328
  baseURL: "https://api.labs.text.com"
1322
1329
  });
1323
1330
  function getTextClientAuthorization(req) {
@@ -1720,18 +1727,18 @@ var textApi = {
1720
1727
  };
1721
1728
 
1722
1729
  // src/apis/integrations/vercel/api.ts
1723
- var import_axios9 = __toESM(require("axios"));
1730
+ var import_axios10 = __toESM(require("axios"));
1724
1731
 
1725
1732
  // src/apis/integrations/vercel/instance.ts
1726
- var import_axios8 = __toESM(require("axios"));
1727
- var vercelClientInstance = import_axios8.default.create({
1733
+ var import_axios9 = __toESM(require("axios"));
1734
+ var vercelClientInstance = import_axios9.default.create({
1728
1735
  baseURL: "https://api.vercel.com"
1729
1736
  });
1730
1737
  vercelClientInstance.interceptors.response.use(
1731
1738
  (r) => r,
1732
1739
  (error) => {
1733
1740
  var _a, _b;
1734
- if (import_axios8.default.isAxiosError(error)) {
1741
+ if (import_axios9.default.isAxiosError(error)) {
1735
1742
  if (((_a = error.response) == null ? void 0 : _a.status) === 401 || ((_b = error.response) == null ? void 0 : _b.status) === 403) {
1736
1743
  throw new UnauthorizeApiError("vercel");
1737
1744
  }
@@ -2020,7 +2027,7 @@ var vercelApi = {
2020
2027
  client_secret: clientSecret,
2021
2028
  redirect_uri: redirectUrl
2022
2029
  });
2023
- const response = yield import_axios9.default.post("https://api.vercel.com/v2/oauth/access_token", data, {
2030
+ const response = yield import_axios10.default.post("https://api.vercel.com/v2/oauth/access_token", data, {
2024
2031
  headers: {
2025
2032
  "Content-Type": "application/x-www-form-urlencoded"
2026
2033
  }
@@ -2036,18 +2043,18 @@ var vercelApi = {
2036
2043
  };
2037
2044
 
2038
2045
  // src/apis/integrations/neon/api.ts
2039
- var import_axios11 = __toESM(require("axios"));
2046
+ var import_axios12 = __toESM(require("axios"));
2040
2047
 
2041
2048
  // src/apis/integrations/neon/instance.ts
2042
- var import_axios10 = __toESM(require("axios"));
2043
- var neonClientInstance = import_axios10.default.create({
2049
+ var import_axios11 = __toESM(require("axios"));
2050
+ var neonClientInstance = import_axios11.default.create({
2044
2051
  baseURL: "https://console.neon.tech/api/v2/"
2045
2052
  });
2046
2053
  neonClientInstance.interceptors.response.use(
2047
2054
  (r) => r,
2048
2055
  (error) => {
2049
2056
  var _a;
2050
- if (import_axios10.default.isAxiosError(error)) {
2057
+ if (import_axios11.default.isAxiosError(error)) {
2051
2058
  if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
2052
2059
  throw new UnauthorizeApiError("neon");
2053
2060
  }
@@ -2260,7 +2267,7 @@ var neonApi = {
2260
2267
  redirect_uri: redirectUri,
2261
2268
  grant_type: "authorization_code"
2262
2269
  });
2263
- const response = yield import_axios11.default.post(
2270
+ const response = yield import_axios12.default.post(
2264
2271
  "https://oauth2.neon.tech/oauth2/token",
2265
2272
  data,
2266
2273
  {
@@ -2285,7 +2292,7 @@ var neonApi = {
2285
2292
  client_secret: clientSecret,
2286
2293
  grant_type: "refresh_token"
2287
2294
  });
2288
- const response = yield import_axios11.default.post("https://oauth2.neon.tech/oauth2/token", data, {
2295
+ const response = yield import_axios12.default.post("https://oauth2.neon.tech/oauth2/token", data, {
2289
2296
  headers: {
2290
2297
  "Content-Type": "application/x-www-form-urlencoded"
2291
2298
  }
@@ -2310,7 +2317,7 @@ var integrationsApi = {
2310
2317
  };
2311
2318
 
2312
2319
  // src/apis/products/livechat/instance.ts
2313
- var import_axios12 = __toESM(require("axios"));
2320
+ var import_axios13 = __toESM(require("axios"));
2314
2321
  var REGION = {
2315
2322
  FRA: "fra",
2316
2323
  DAL: "dal",
@@ -2324,7 +2331,7 @@ var getRegion = (token) => {
2324
2331
  return region;
2325
2332
  }
2326
2333
  };
2327
- var livechatClientInstance = import_axios12.default.create({
2334
+ var livechatClientInstance = import_axios13.default.create({
2328
2335
  baseURL: "https://api.labs.livechatinc.com"
2329
2336
  });
2330
2337
  function getLiveChatClientAuthorization(req) {
@@ -2842,14 +2849,14 @@ var productsApi = {
2842
2849
  };
2843
2850
 
2844
2851
  // src/apis/platform/accounts/instance.ts
2845
- var import_axios13 = __toESM(require("axios"));
2852
+ var import_axios14 = __toESM(require("axios"));
2846
2853
  var AccountsApiError = class extends ApiErrorBase {
2847
2854
  constructor() {
2848
2855
  super(...arguments);
2849
2856
  this.name = "accounts";
2850
2857
  }
2851
2858
  };
2852
- var platformAccountsClientInstance = import_axios13.default.create({
2859
+ var platformAccountsClientInstance = import_axios14.default.create({
2853
2860
  baseURL: "https://accounts.labs.livechatinc.com"
2854
2861
  });
2855
2862
  platformAccountsClientInstance.interceptors.response.use(
@@ -3178,14 +3185,14 @@ var platformAccountsApi = {
3178
3185
  };
3179
3186
 
3180
3187
  // src/apis/platform/dps/instance.ts
3181
- var import_axios14 = __toESM(require("axios"));
3188
+ var import_axios15 = __toESM(require("axios"));
3182
3189
  var DpsApiError = class extends ApiErrorBase {
3183
3190
  constructor() {
3184
3191
  super(...arguments);
3185
3192
  this.name = "dps";
3186
3193
  }
3187
3194
  };
3188
- var platformDpsClientInstance = import_axios14.default.create({
3195
+ var platformDpsClientInstance = import_axios15.default.create({
3189
3196
  baseURL: "https://dev-platform.labs.livechatinc.com"
3190
3197
  });
3191
3198
  platformDpsClientInstance.interceptors.response.use(
@@ -3549,21 +3556,19 @@ var getAppAutoReviewPayload = (value) => {
3549
3556
  var platformDpsApplicationAutoReviewApi = {
3550
3557
  getAutoReview(appId, authorization) {
3551
3558
  return __async(this, null, function* () {
3552
- try {
3553
- const response = yield platformDpsClientInstance.get(
3554
- `/v2/applications/${appId}/auto-review`,
3555
- getPlatformDpsClientConfig(authorization)
3556
- );
3557
- if (response.status === 204) {
3559
+ return platformDpsClientInstance.get(
3560
+ `/v2/applications/${appId}/auto-review`,
3561
+ getPlatformDpsClientConfig(authorization)
3562
+ ).then(({ status, data }) => {
3563
+ if (status === 204) {
3558
3564
  return getEmptyAppAutoReview();
3559
3565
  }
3560
- return response.data;
3561
- } catch (error) {
3562
- if (error instanceof Error) {
3563
- throw new Error(`The review couldn\u2019t be completed. [${error.message}]`);
3564
- }
3565
- throw error;
3566
- }
3566
+ return data;
3567
+ }).catch((error) => {
3568
+ throw error.withCustomMessage(
3569
+ `The review couldn\u2019t be completed. [${error.message}]`
3570
+ );
3571
+ });
3567
3572
  });
3568
3573
  },
3569
3574
  submitAutoReview(appId, payload, authorization) {
@@ -4288,99 +4293,74 @@ var platformDpsApplicationApi = {
4288
4293
  },
4289
4294
  createApp(payload, authorization) {
4290
4295
  return __async(this, null, function* () {
4291
- try {
4292
- const response = yield platformDpsClientInstance.post(
4293
- `/v2/applications`,
4294
- payload,
4295
- getPlatformDpsClientConfig(authorization)
4296
+ return platformDpsClientInstance.post(
4297
+ `/v2/applications`,
4298
+ payload,
4299
+ getPlatformDpsClientConfig(authorization)
4300
+ ).then(({ data }) => data).catch((error) => {
4301
+ throw error.withCustomMessage(
4302
+ `App couldn't be created. [${error.message}]`
4296
4303
  );
4297
- return response.data;
4298
- } catch (error) {
4299
- if (error instanceof Error) {
4300
- throw new Error(`App couldn't be created. [${error.message}]`);
4301
- }
4302
- throw error;
4303
- }
4304
+ });
4304
4305
  });
4305
4306
  },
4306
4307
  fork(appId, authorization) {
4307
4308
  return __async(this, null, function* () {
4308
- try {
4309
- return yield platformDpsClientInstance.post(
4310
- `/v2/applications/${appId}/fork`,
4311
- {},
4312
- getPlatformDpsClientConfig(authorization)
4309
+ return platformDpsClientInstance.post(
4310
+ `/v2/applications/${appId}/fork`,
4311
+ {},
4312
+ getPlatformDpsClientConfig(authorization)
4313
+ ).catch((error) => {
4314
+ throw error.withCustomMessage(
4315
+ `App couldn't be forked. [${error.message}]`
4313
4316
  );
4314
- } catch (error) {
4315
- if (error instanceof Error) {
4316
- throw new Error(`App couldn't be forked. [${error.message}]`);
4317
- }
4318
- throw error;
4319
- }
4317
+ });
4320
4318
  });
4321
4319
  },
4322
4320
  publish(appId, authorization) {
4323
4321
  return __async(this, null, function* () {
4324
- try {
4325
- return yield platformDpsClientInstance.put(
4326
- `/v2/applications/${appId}/publish`,
4327
- {},
4328
- getPlatformDpsClientConfig(authorization)
4322
+ return platformDpsClientInstance.put(
4323
+ `/v2/applications/${appId}/publish`,
4324
+ {},
4325
+ getPlatformDpsClientConfig(authorization)
4326
+ ).catch((error) => {
4327
+ throw error.withCustomMessage(
4328
+ `App couldn't be published. [${error.message}]`
4329
4329
  );
4330
- } catch (error) {
4331
- if (error instanceof Error) {
4332
- throw new Error(`App couldn't be published. [${error.message}]`);
4333
- }
4334
- throw error;
4335
- }
4330
+ });
4336
4331
  });
4337
4332
  },
4338
4333
  updateQL(appId) {
4339
4334
  return __async(this, null, function* () {
4340
- try {
4341
- yield platformDpsClientInstance.patch(
4342
- `/v2/applications/${appId}/qualified-lead`
4335
+ yield platformDpsClientInstance.patch(`/v2/applications/${appId}/qualified-lead`).catch((error) => {
4336
+ throw error.withCustomMessage(
4337
+ `QL couldn't be updated. [${error.message}]`
4343
4338
  );
4344
- } catch (error) {
4345
- if (error instanceof Error) {
4346
- throw new Error(`QL couldn't be updated. [${error.message}]`);
4347
- }
4348
- throw error;
4349
- }
4339
+ });
4350
4340
  });
4351
4341
  },
4352
4342
  deleteApp(appId, authorization) {
4353
4343
  return __async(this, null, function* () {
4354
- try {
4355
- yield platformDpsClientInstance.delete(
4356
- `/v2/applications/${appId}`,
4357
- getPlatformDpsClientConfig(authorization)
4344
+ yield platformDpsClientInstance.delete(
4345
+ `/v2/applications/${appId}`,
4346
+ getPlatformDpsClientConfig(authorization)
4347
+ ).catch((error) => {
4348
+ throw error.withCustomMessage(
4349
+ `App couldn't be created. [${error.message}]`
4358
4350
  );
4359
- } catch (error) {
4360
- if (error instanceof Error) {
4361
- throw new Error(`App couldn't be created. [${error.message}]`);
4362
- }
4363
- throw error;
4364
- }
4351
+ });
4365
4352
  });
4366
4353
  },
4367
4354
  createAiContent(appId, appName, appSummary) {
4368
4355
  return __async(this, null, function* () {
4369
- try {
4370
- const response = yield platformDpsClientInstance.post(
4371
- `/v2/ai/application/${appId}/content`,
4372
- {
4373
- name: appName,
4374
- summary: appSummary
4375
- }
4356
+ return platformDpsClientInstance.post(`/v2/ai/application/${appId}/content`, {
4357
+ name: appName,
4358
+ summary: appSummary
4359
+ }).catch((error) => {
4360
+ throw error.withCustomMessage(
4361
+ `AI content couldn't be created. [${error.message}]`
4376
4362
  );
4377
- return response;
4378
- } catch (error) {
4379
- if (error instanceof Error) {
4380
- throw new Error(`AI content couldn't be created. [${error.message}]`);
4381
- }
4382
- throw error;
4383
- }
4363
+ });
4384
4364
  });
4385
4365
  }
4386
4366
  };
@@ -4415,43 +4395,35 @@ var platformDpsApplicationsPurchasesApi = {
4415
4395
  },
4416
4396
  getSummaryPurchases(apps, options, authorization) {
4417
4397
  return __async(this, null, function* () {
4418
- try {
4419
- const { from, to, duration } = options;
4420
- const clientIds = apps.map((app) => app.clientId);
4421
- const params = `applications=${clientIds.join(",")}${from ? `&from=${from}` : ""}${to ? `&to=${to}` : ""}&duration=${duration}&by=supplier`;
4422
- const response = yield platformDpsClientInstance.get(
4423
- `/v2/applications/purchases?${params}`,
4424
- getPlatformDpsClientConfig(authorization)
4398
+ const { from, to, duration } = options;
4399
+ const clientIds = apps.map((app) => app.clientId);
4400
+ const params = `applications=${clientIds.join(",")}${from ? `&from=${from}` : ""}${to ? `&to=${to}` : ""}&duration=${duration}&by=supplier`;
4401
+ return platformDpsClientInstance.get(
4402
+ `/v2/applications/purchases?${params}`,
4403
+ getPlatformDpsClientConfig(authorization)
4404
+ ).then(({ data }) => {
4405
+ return [{ data, appId: "All apps" }];
4406
+ }).catch((error) => {
4407
+ throw error.withCustomMessage(
4408
+ `App summary purchases couldn't be fetched. [${error.message}]`
4425
4409
  );
4426
- return [{ data: response.data, appId: "All apps" }];
4427
- } catch (error) {
4428
- if (error instanceof Error) {
4429
- throw new Error(
4430
- `App summary purchases couldn't be fetched. [${error.message}]`
4431
- );
4432
- }
4433
- throw error;
4434
- }
4410
+ });
4435
4411
  });
4436
4412
  },
4437
4413
  getSummaryPurchasesHistory(apps, options, authorization) {
4438
4414
  return __async(this, null, function* () {
4439
- try {
4440
- const { from, to, duration } = options;
4441
- const params = `applications=${apps.join(",")}${from ? `&from=${from}` : ""}${to ? `&to=${to}` : ""}&duration=${duration}`;
4442
- const response = yield platformDpsClientInstance.get(
4443
- `/v2/applications/purchases/history?${params}`,
4444
- getPlatformDpsClientConfig(authorization)
4415
+ const { from, to, duration } = options;
4416
+ const params = `applications=${apps.join(",")}${from ? `&from=${from}` : ""}${to ? `&to=${to}` : ""}&duration=${duration}`;
4417
+ return platformDpsClientInstance.get(
4418
+ `/v2/applications/purchases/history?${params}`,
4419
+ getPlatformDpsClientConfig(authorization)
4420
+ ).then(({ data }) => {
4421
+ return [{ data, appId: "All apps" }];
4422
+ }).catch((error) => {
4423
+ throw error.withCustomMessage(
4424
+ `App summary purchases history couldn't be fetched. [${error.message}]`
4445
4425
  );
4446
- return [{ data: response.data, appId: "All apps" }];
4447
- } catch (error) {
4448
- if (error instanceof Error) {
4449
- throw new Error(
4450
- `App summary purchases history couldn't be fetched. [${error.message}]`
4451
- );
4452
- }
4453
- throw error;
4454
- }
4426
+ });
4455
4427
  });
4456
4428
  }
4457
4429
  };
@@ -4492,16 +4464,12 @@ var platformDpsApplicationsApi = {
4492
4464
  purchases: platformDpsApplicationsPurchasesApi,
4493
4465
  getApps() {
4494
4466
  return __async(this, arguments, function* ({ filter = "licensed" } = {}) {
4495
- try {
4496
- const params = `filter=${filter}`;
4497
- const response = yield platformDpsClientInstance.get(`/v2/applications?${params}`);
4498
- return response.data;
4499
- } catch (error) {
4500
- if (error instanceof Error) {
4501
- throw new Error(`Apps couldn't be fetched. [${error.message}]`);
4502
- }
4503
- throw error;
4504
- }
4467
+ const params = `filter=${filter}`;
4468
+ return platformDpsClientInstance.get(`/v2/applications?${params}`).then(({ data }) => data).catch((error) => {
4469
+ throw error.withCustomMessage(
4470
+ `Apps couldn't be fetched. [${error.message}]`
4471
+ );
4472
+ });
4505
4473
  });
4506
4474
  }
4507
4475
  };
@@ -4510,18 +4478,14 @@ var platformDpsApplicationsApi = {
4510
4478
  var platformDpsCategoriesApi = {
4511
4479
  getCategories(authorization) {
4512
4480
  return __async(this, null, function* () {
4513
- try {
4514
- const response = yield platformDpsClientInstance.get(
4515
- `/v2/categories`,
4516
- getPlatformDpsClientConfig(authorization)
4481
+ return platformDpsClientInstance.get(
4482
+ `/v2/categories`,
4483
+ getPlatformDpsClientConfig(authorization)
4484
+ ).then(({ data }) => data).catch((error) => {
4485
+ throw error.withCustomMessage(
4486
+ `Categories couldn't be fetched. [${error.message}]`
4517
4487
  );
4518
- return response.data;
4519
- } catch (error) {
4520
- if (error instanceof Error) {
4521
- throw new Error(`Categories couldn't be fetched. [${error.message}]`);
4522
- }
4523
- throw error;
4524
- }
4488
+ });
4525
4489
  });
4526
4490
  }
4527
4491
  };
@@ -4530,32 +4494,28 @@ var platformDpsCategoriesApi = {
4530
4494
  var platformDpsDeveloperApi = {
4531
4495
  getLedger(userId, options, authorization) {
4532
4496
  return __async(this, null, function* () {
4533
- try {
4534
- const { startAt, endAt, size, page } = options;
4535
- const withRange = Boolean(startAt && endAt);
4536
- const withPagination = Boolean(size && typeof page === "number");
4537
- let params = withRange || withPagination ? `?` : "";
4497
+ const { startAt, endAt, size, page } = options;
4498
+ const withRange = Boolean(startAt && endAt);
4499
+ const withPagination = Boolean(size && typeof page === "number");
4500
+ let params = withRange || withPagination ? `?` : "";
4501
+ if (withRange) {
4502
+ params += `from=${startAt}&to=${endAt}`;
4503
+ }
4504
+ if (withPagination) {
4538
4505
  if (withRange) {
4539
- params += `from=${startAt}&to=${endAt}`;
4540
- }
4541
- if (withPagination) {
4542
- if (withRange) {
4543
- params += `&size=${size}&page=${page}`;
4544
- } else {
4545
- params += `size=${size}&page=${page}`;
4546
- }
4547
- }
4548
- const response = yield platformDpsClientInstance.get(
4549
- `/v2/developers/${userId}/account/ledger${params}`,
4550
- getPlatformDpsClientConfig(authorization)
4551
- );
4552
- return response.data;
4553
- } catch (error) {
4554
- if (error instanceof Error) {
4555
- throw new Error(`Ledger couldn't be fetched. [${error.message}]`);
4506
+ params += `&size=${size}&page=${page}`;
4507
+ } else {
4508
+ params += `size=${size}&page=${page}`;
4556
4509
  }
4557
- throw error;
4558
4510
  }
4511
+ return platformDpsClientInstance.get(
4512
+ `/v2/developers/${userId}/account/ledger${params}`,
4513
+ getPlatformDpsClientConfig(authorization)
4514
+ ).then(({ data }) => data).catch((error) => {
4515
+ throw error.withCustomMessage(
4516
+ `Ledger couldn't be fetched. [${error.message}]`
4517
+ );
4518
+ });
4559
4519
  });
4560
4520
  },
4561
4521
  requestWithdrawal(_0, _1) {
@@ -4564,19 +4524,15 @@ var platformDpsDeveloperApi = {
4564
4524
  note,
4565
4525
  userId
4566
4526
  }, authorization) {
4567
- try {
4568
- const response = yield platformDpsClientInstance.patch(
4569
- `/v2/developers/${userId}/account/withdrawal/request`,
4570
- { amount, note },
4571
- getPlatformDpsClientConfig(authorization)
4527
+ return platformDpsClientInstance.patch(
4528
+ `/v2/developers/${userId}/account/withdrawal/request`,
4529
+ { amount, note },
4530
+ getPlatformDpsClientConfig(authorization)
4531
+ ).then(({ data }) => data).catch((error) => {
4532
+ throw error.withCustomMessage(
4533
+ `Withdrawal couldn't be requested. [${error.message}]`
4572
4534
  );
4573
- return response.data;
4574
- } catch (error) {
4575
- if (error instanceof Error) {
4576
- throw new Error(`Withdrawal couldn't be requested. [${error.message}]`);
4577
- }
4578
- throw error;
4579
- }
4535
+ });
4580
4536
  });
4581
4537
  }
4582
4538
  };
@@ -4590,18 +4546,15 @@ var platformDpsDevelopersApi = {
4590
4546
  var platformDpsLinksApi = {
4591
4547
  updateShortcuts(links, authorization) {
4592
4548
  return __async(this, null, function* () {
4593
- try {
4594
- yield platformDpsClientInstance.put(
4595
- `/v2/links`,
4596
- links,
4597
- getPlatformDpsClientConfig(authorization)
4549
+ yield platformDpsClientInstance.put(
4550
+ `/v2/links`,
4551
+ links,
4552
+ getPlatformDpsClientConfig(authorization)
4553
+ ).catch((error) => {
4554
+ throw error.withCustomMessage(
4555
+ `Shortcuts couldn't be updated. [${error.message}]`
4598
4556
  );
4599
- } catch (error) {
4600
- if (error instanceof Error) {
4601
- throw new Error(`Shortcuts couldn't be updated. [${error.message}]`);
4602
- }
4603
- throw error;
4604
- }
4557
+ });
4605
4558
  });
4606
4559
  }
4607
4560
  };
@@ -4610,56 +4563,38 @@ var platformDpsLinksApi = {
4610
4563
  var dpsResearchCustomerApi = {
4611
4564
  getResearchCustomersLicenses(authorization) {
4612
4565
  return __async(this, null, function* () {
4613
- try {
4614
- const response = yield platformDpsClientInstance.get(
4615
- `/v2/research/customers/licenses`,
4616
- getPlatformDpsClientConfig(authorization)
4566
+ return platformDpsClientInstance.get(
4567
+ `/v2/research/customers/licenses`,
4568
+ getPlatformDpsClientConfig(authorization)
4569
+ ).then(({ data }) => data).catch((error) => {
4570
+ throw error.withCustomMessage(
4571
+ `We couldn't fetch the research toolkit data. [${error.message}]`
4617
4572
  );
4618
- return response.data;
4619
- } catch (error) {
4620
- if (error instanceof Error) {
4621
- throw new Error(
4622
- `We couldn't fetch the research toolkit data. [${error.message}]`
4623
- );
4624
- }
4625
- throw error;
4626
- }
4573
+ });
4627
4574
  });
4628
4575
  },
4629
4576
  getResearchCustomersBusiness(authorization) {
4630
4577
  return __async(this, null, function* () {
4631
- try {
4632
- const response = yield platformDpsClientInstance.get(
4633
- `/v2/research/customers/business`,
4634
- getPlatformDpsClientConfig(authorization)
4578
+ return platformDpsClientInstance.get(
4579
+ `/v2/research/customers/business`,
4580
+ getPlatformDpsClientConfig(authorization)
4581
+ ).then(({ data }) => data).catch((error) => {
4582
+ throw error.withCustomMessage(
4583
+ `We couldn't fetch the research toolkit data. [${error.message}]`
4635
4584
  );
4636
- return response.data;
4637
- } catch (error) {
4638
- if (error instanceof Error) {
4639
- throw new Error(
4640
- `We couldn't fetch the research toolkit data. [${error.message}]`
4641
- );
4642
- }
4643
- throw error;
4644
- }
4585
+ });
4645
4586
  });
4646
4587
  },
4647
4588
  getResearchCustomersLocation(authorization) {
4648
4589
  return __async(this, null, function* () {
4649
- try {
4650
- const response = yield platformDpsClientInstance.get(
4651
- `/v2/research/customers/location`,
4652
- getPlatformDpsClientConfig(authorization)
4590
+ return platformDpsClientInstance.get(
4591
+ `/v2/research/customers/location`,
4592
+ getPlatformDpsClientConfig(authorization)
4593
+ ).then(({ data }) => data).catch((error) => {
4594
+ throw error.withCustomMessage(
4595
+ `We couldn't fetch the research toolkit data. [${error.message}]`
4653
4596
  );
4654
- return response.data;
4655
- } catch (error) {
4656
- if (error instanceof Error) {
4657
- throw new Error(
4658
- `We couldn't fetch the research toolkit data. [${error.message}]`
4659
- );
4660
- }
4661
- throw error;
4662
- }
4597
+ });
4663
4598
  });
4664
4599
  }
4665
4600
  };
@@ -4668,21 +4603,15 @@ var dpsResearchCustomerApi = {
4668
4603
  var dpsResearchDictionaryApi = {
4669
4604
  getResearchDictionary() {
4670
4605
  return __async(this, arguments, function* (options = {}, authorization) {
4671
- try {
4672
- const params = new URLSearchParams(options);
4673
- const response = yield platformDpsClientInstance.get(
4674
- `/v2/research/dictionary?${params.toString()}`,
4675
- getPlatformDpsClientConfig(authorization)
4606
+ const params = new URLSearchParams(options);
4607
+ return platformDpsClientInstance.get(
4608
+ `/v2/research/dictionary?${params.toString()}`,
4609
+ getPlatformDpsClientConfig(authorization)
4610
+ ).then(({ data }) => data).catch((error) => {
4611
+ throw error.withCustomMessage(
4612
+ `We couldn't fetch the research toolkit data. [${error.message}]`
4676
4613
  );
4677
- return response.data;
4678
- } catch (error) {
4679
- if (error instanceof Error) {
4680
- throw new Error(
4681
- `We couldn't fetch the research toolkit data. [${error.message}]`
4682
- );
4683
- }
4684
- throw error;
4685
- }
4614
+ });
4686
4615
  });
4687
4616
  }
4688
4617
  };
@@ -4691,40 +4620,28 @@ var dpsResearchDictionaryApi = {
4691
4620
  var dpsResearchMarketplaceApi = {
4692
4621
  getResearchMarketplaceApps() {
4693
4622
  return __async(this, arguments, function* (options = {}, authorization) {
4694
- try {
4695
- const params = new URLSearchParams(options);
4696
- const response = yield platformDpsClientInstance.get(
4697
- `/v2/research/marketplace/apps?${params.toString()}`,
4698
- getPlatformDpsClientConfig(authorization)
4623
+ const params = new URLSearchParams(options);
4624
+ return platformDpsClientInstance.get(
4625
+ `/v2/research/marketplace/apps?${params.toString()}`,
4626
+ getPlatformDpsClientConfig(authorization)
4627
+ ).then(({ data }) => data).catch((error) => {
4628
+ throw error.withCustomMessage(
4629
+ `We couldn't fetch the research toolkit data. [${error.message}]`
4699
4630
  );
4700
- return response.data;
4701
- } catch (error) {
4702
- if (error instanceof Error) {
4703
- throw new Error(
4704
- `We couldn't fetch the research toolkit data. [${error.message}]`
4705
- );
4706
- }
4707
- throw error;
4708
- }
4631
+ });
4709
4632
  });
4710
4633
  },
4711
4634
  getResearchMarketplaceViews() {
4712
4635
  return __async(this, arguments, function* (options = {}, authorization) {
4713
- try {
4714
- const params = new URLSearchParams(options);
4715
- const response = yield platformDpsClientInstance.get(
4716
- `/v2/research/marketplace/views?${params.toString()}`,
4717
- getPlatformDpsClientConfig(authorization)
4636
+ const params = new URLSearchParams(options);
4637
+ return platformDpsClientInstance.get(
4638
+ `/v2/research/marketplace/views?${params.toString()}`,
4639
+ getPlatformDpsClientConfig(authorization)
4640
+ ).then(({ data }) => data).catch((error) => {
4641
+ throw error.withCustomMessage(
4642
+ `We couldn't fetch the research toolkit data. [${error.message}]`
4718
4643
  );
4719
- return response.data;
4720
- } catch (error) {
4721
- if (error instanceof Error) {
4722
- throw new Error(
4723
- `We couldn't fetch the research toolkit data. [${error.message}]`
4724
- );
4725
- }
4726
- throw error;
4727
- }
4644
+ });
4728
4645
  });
4729
4646
  }
4730
4647
  };
@@ -4733,40 +4650,28 @@ var dpsResearchMarketplaceApi = {
4733
4650
  var dpsResearchTrafficApi = {
4734
4651
  getResearchTrafficAgents() {
4735
4652
  return __async(this, arguments, function* (options = {}, authorization) {
4736
- try {
4737
- const params = new URLSearchParams(options);
4738
- const response = yield platformDpsClientInstance.get(
4739
- `/v2/research/traffic/agents?${params.toString()}`,
4740
- getPlatformDpsClientConfig(authorization)
4653
+ const params = new URLSearchParams(options);
4654
+ return platformDpsClientInstance.get(
4655
+ `/v2/research/traffic/agents?${params.toString()}`,
4656
+ getPlatformDpsClientConfig(authorization)
4657
+ ).then(({ data }) => data).catch((error) => {
4658
+ throw error.withCustomMessage(
4659
+ `We couldn't fetch the research toolkit data. [${error.message}]`
4741
4660
  );
4742
- return response.data;
4743
- } catch (error) {
4744
- if (error instanceof Error) {
4745
- throw new Error(
4746
- `We couldn't fetch the research toolkit data. [${error.message}]`
4747
- );
4748
- }
4749
- throw error;
4750
- }
4661
+ });
4751
4662
  });
4752
4663
  },
4753
4664
  getResearchTrafficChats() {
4754
4665
  return __async(this, arguments, function* (options = {}, authorization) {
4755
- try {
4756
- const params = new URLSearchParams(options);
4757
- const response = yield platformDpsClientInstance.get(
4758
- `/v2/research/traffic/chats?${params.toString()}`,
4759
- getPlatformDpsClientConfig(authorization)
4666
+ const params = new URLSearchParams(options);
4667
+ return platformDpsClientInstance.get(
4668
+ `/v2/research/traffic/chats?${params.toString()}`,
4669
+ getPlatformDpsClientConfig(authorization)
4670
+ ).then(({ data }) => data).catch((error) => {
4671
+ throw error.withCustomMessage(
4672
+ `We couldn't fetch the research toolkit data. [${error.message}]`
4760
4673
  );
4761
- return response.data;
4762
- } catch (error) {
4763
- if (error instanceof Error) {
4764
- throw new Error(
4765
- `We couldn't fetch the research toolkit data. [${error.message}]`
4766
- );
4767
- }
4768
- throw error;
4769
- }
4674
+ });
4770
4675
  });
4771
4676
  }
4772
4677
  };
@@ -4859,7 +4764,7 @@ var platformDpsApi = {
4859
4764
  };
4860
4765
 
4861
4766
  // src/apis/platform/adapter/instance.ts
4862
- var import_axios15 = __toESM(require("axios"));
4767
+ var import_axios16 = __toESM(require("axios"));
4863
4768
  var REGION2 = {
4864
4769
  FRA: "fra",
4865
4770
  DAL: "dal",
@@ -4895,7 +4800,7 @@ function getPlatformAdapterClientAuthorization(req) {
4895
4800
  openai: req.headers["openai-token"]
4896
4801
  };
4897
4802
  }
4898
- var platformAdapterClientInstance = import_axios15.default.create({
4803
+ var platformAdapterClientInstance = import_axios16.default.create({
4899
4804
  baseURL: "https://platform.labs.text.com/console-adapter/api",
4900
4805
  headers: {
4901
4806
  "Content-Type": "application/json"
@@ -5503,8 +5408,8 @@ var platformAdapterConductorApi = {
5503
5408
  };
5504
5409
 
5505
5410
  // src/apis/platform/billing/instance.ts
5506
- var import_axios16 = __toESM(require("axios"));
5507
- var platformBillingClientInstance = import_axios16.default.create({
5411
+ var import_axios17 = __toESM(require("axios"));
5412
+ var platformBillingClientInstance = import_axios17.default.create({
5508
5413
  baseURL: "https://billing.labs.livechatinc.com"
5509
5414
  });
5510
5415
  function getPlatformBillingClientAuthorization(req) {
@@ -5734,6 +5639,28 @@ function initApi(config, tokens) {
5734
5639
  initPlanetScaleClientInstance((_w = tokens == null ? void 0 : tokens.planetscale) == null ? void 0 : _w.token);
5735
5640
  api.isInitialized = true;
5736
5641
  }
5642
+
5643
+ // ../../private/utils/src/serializers/base64.ts
5644
+ var serializerBase64 = {
5645
+ serialize(state) {
5646
+ return btoa(escape(JSON.stringify(state)));
5647
+ },
5648
+ deserialize(message) {
5649
+ try {
5650
+ return message ? JSON.parse(unescape(atob(unescape(message)))) : void 0;
5651
+ } catch (e) {
5652
+ }
5653
+ }
5654
+ };
5655
+
5656
+ // src/utils/integrations/getIntegrationFlowUrl.ts
5657
+ function getIntegrationFlowUrl(provider, flow, data, context, config) {
5658
+ const serializedFlowState = serializerBase64.serialize(data);
5659
+ const serializedContext = serializerBase64.serialize(__spreadProps(__spreadValues({}, context), {
5660
+ state: serializedFlowState
5661
+ }));
5662
+ return `${config.adapterUrl}/integrations/${provider}/flow?flow=${flow}&context=${serializedContext}`;
5663
+ }
5737
5664
  // Annotate the CommonJS export names for ESM import in node:
5738
5665
  0 && (module.exports = {
5739
5666
  API_NOTIFICATIONS,
@@ -5753,6 +5680,7 @@ function initApi(config, tokens) {
5753
5680
  getEmptyAppAutoReview,
5754
5681
  getGitHubClientAuthorization,
5755
5682
  getGithubClientRequestConfig,
5683
+ getIntegrationFlowUrl,
5756
5684
  getLiveChatClientAuthorization,
5757
5685
  getLiveChatClientConfig,
5758
5686
  getNeonClientAuthorization,