@livechat/developer-studio-api 3.0.38 → 3.0.40

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
@@ -83,12 +83,13 @@ __export(src_exports, {
83
83
  getAppAutoReviewPayload: () => getAppAutoReviewPayload,
84
84
  getEmptyAppAutoReview: () => getEmptyAppAutoReview,
85
85
  getGitHubClientAuthorization: () => getGitHubClientAuthorization,
86
- getGithubClientRequestConfig: () => getGithubClientRequestConfig,
86
+ getGithubClientConfig: () => getGithubClientConfig,
87
87
  getIntegrationFlowUrl: () => getIntegrationFlowUrl,
88
88
  getLiveChatClientAuthorization: () => getLiveChatClientAuthorization,
89
89
  getLiveChatClientConfig: () => getLiveChatClientConfig,
90
90
  getMailchimpClientAuthorization: () => getMailchimpClientAuthorization,
91
91
  getMailchimpClientConfig: () => getMailchimpClientConfig,
92
+ getMailchimpClientUrl: () => getMailchimpClientUrl,
92
93
  getNeonClientAuthorization: () => getNeonClientAuthorization,
93
94
  getNeonClientConfig: () => getNeonClientConfig,
94
95
  getNetlifyClientAuthorization: () => getNetlifyClientAuthorization,
@@ -106,24 +107,28 @@ __export(src_exports, {
106
107
  getPlatformDpsClientAuthorization: () => getPlatformDpsClientAuthorization,
107
108
  getPlatformDpsClientConfig: () => getPlatformDpsClientConfig,
108
109
  getRegion: () => getRegion,
110
+ getShopifyClientAuthorization: () => getShopifyClientAuthorization,
111
+ getShopifyClientConfig: () => getShopifyClientConfig,
112
+ getShopifyClientUrl: () => getShopifyClientUrl,
109
113
  getTextClientAuthorization: () => getTextClientAuthorization,
110
114
  getTextClientConfig: () => getTextClientConfig,
111
115
  getVercelClientAuthorization: () => getVercelClientAuthorization,
112
116
  getVercelClientConfig: () => getVercelClientConfig,
113
117
  githubClientInstance: () => githubClientInstance,
114
118
  initApi: () => initApi,
115
- initGithubClientInstance: () => initGithubClientInstance,
116
- initLiveChatClientInstance: () => initLiveChatClientInstance,
117
- initMailchimpClientInstance: () => initMailchimpClientInstance,
118
- initNeonClientInstance: () => initNeonClientInstance,
119
- initNetlifyClientInstance: () => initNetlifyClientInstance,
120
- initPlanetScaleClientInstance: () => initPlanetScaleClientInstance,
121
- initPlatformAccountsClientInstance: () => initPlatformAccountsClientInstance,
122
- initPlatformAdapterClientInstance: () => initPlatformAdapterClientInstance,
123
- initPlatformBillingClientInstance: () => initPlatformBillingClientInstance,
124
- initPlatformDpsClientInstance: () => initPlatformDpsClientInstance,
125
- initTextClientInstance: () => initTextClientInstance,
126
- initVercelClientInstance: () => initVercelClientInstance,
119
+ initGithubClient: () => initGithubClient,
120
+ initLiveChatClient: () => initLiveChatClient,
121
+ initMailchimpClient: () => initMailchimpClient,
122
+ initNeonClient: () => initNeonClient,
123
+ initNetlifyClient: () => initNetlifyClient,
124
+ initPlanetScaleClient: () => initPlanetScaleClient,
125
+ initPlatformAccountsClient: () => initPlatformAccountsClient,
126
+ initPlatformAdapterClient: () => initPlatformAdapterClient,
127
+ initPlatformBillingClient: () => initPlatformBillingClient,
128
+ initPlatformDpsClient: () => initPlatformDpsClient,
129
+ initShopifyClient: () => initShopifyClient,
130
+ initTextClient: () => initTextClient,
131
+ initVercelClient: () => initVercelClient,
127
132
  livechatClientInstance: () => livechatClientInstance,
128
133
  mailchimpClientInstance: () => mailchimpClientInstance,
129
134
  neonClientInstance: () => neonClientInstance,
@@ -133,14 +138,16 @@ __export(src_exports, {
133
138
  platformAdapterClientInstance: () => platformAdapterClientInstance,
134
139
  platformBillingClientInstance: () => platformBillingClientInstance,
135
140
  platformDpsClientInstance: () => platformDpsClientInstance,
141
+ shopifyClientInstance: () => shopifyClientInstance,
136
142
  textClientInstance: () => textClientInstance,
137
- updateGithubClientInstance: () => updateGithubClientInstance,
143
+ updateGithubClient: () => updateGithubClient,
138
144
  updateMailchimpClientInstance: () => updateMailchimpClientInstance,
139
- updateNeonClientInstance: () => updateNeonClientInstance,
140
- updateNetlifyClientInstance: () => updateNetlifyClientInstance,
141
- updatePlanetScaleClientInstance: () => updatePlanetScaleClientInstance,
142
- updatePlatformAdapterClientInstance: () => updatePlatformAdapterClientInstance,
143
- updateVercelClientInstance: () => updateVercelClientInstance,
145
+ updateNeonClient: () => updateNeonClient,
146
+ updateNetlifyClient: () => updateNetlifyClient,
147
+ updatePlanetScaleClient: () => updatePlanetScaleClient,
148
+ updatePlatformAdapterClient: () => updatePlatformAdapterClient,
149
+ updateShopifyClient: () => updateShopifyClient,
150
+ updateVercelClient: () => updateVercelClient,
144
151
  vercelClientInstance: () => vercelClientInstance
145
152
  });
146
153
  module.exports = __toCommonJS(src_exports);
@@ -199,31 +206,29 @@ githubClientInstance.interceptors.response.use(
199
206
  );
200
207
  function getGitHubClientAuthorization(req) {
201
208
  return {
202
- tokens: {
203
- app: req.headers["github-app-token"],
204
- oauth: req.headers["github-oauth-token"]
205
- }
209
+ appToken: req.headers["github-app-token"],
210
+ oauthToken: req.headers["github-oauth-token"]
206
211
  };
207
212
  }
208
- function getGithubClientRequestConfig(options = {}) {
213
+ function getGithubClientConfig(options = {}) {
214
+ var _a;
209
215
  const currentHeaders = githubClientInstance.defaults.headers;
210
- const defaultAuthorization = currentHeaders.Authorization;
211
- const headers = {
212
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
216
+ const config = {
217
+ authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
213
218
  };
214
- if (options.ensureAuthorizationToken && !headers.authorization) {
219
+ if (options.ensureAuthorizationToken && !config.authorization) {
215
220
  throw new UnauthorizeApiError("github");
216
221
  }
217
222
  return {
218
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
223
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
219
224
  };
220
225
  }
221
- function initGithubClientInstance(token) {
226
+ function initGithubClient(token) {
222
227
  if (token) {
223
- updateGithubClientInstance(token);
228
+ updateGithubClient(token);
224
229
  }
225
230
  }
226
- function updateGithubClientInstance(token) {
231
+ function updateGithubClient(token) {
227
232
  const headers = githubClientInstance.defaults.headers;
228
233
  if (token) {
229
234
  headers.Authorization = `Bearer ${token}`;
@@ -244,11 +249,10 @@ var gitHubInstallationApi = {
244
249
  },
245
250
  getInstallations(authorization) {
246
251
  return __async(this, null, function* () {
247
- var _a;
248
252
  const response = yield githubClientInstance.get(
249
253
  `/user/installations?timestamp=${(/* @__PURE__ */ new Date()).getTime()}`,
250
- getGithubClientRequestConfig({
251
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
254
+ getGithubClientConfig({
255
+ token: authorization == null ? void 0 : authorization.appToken,
252
256
  ensureAuthorizationToken: true
253
257
  })
254
258
  );
@@ -257,11 +261,10 @@ var gitHubInstallationApi = {
257
261
  },
258
262
  getInstallationRepositories(installationId, authorization) {
259
263
  return __async(this, null, function* () {
260
- var _a;
261
264
  const response = yield githubClientInstance.get(
262
265
  `/user/installations/${installationId}/repositories?timestamp=${(/* @__PURE__ */ new Date()).getTime()}&per_page=100`,
263
- getGithubClientRequestConfig({
264
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
266
+ getGithubClientConfig({
267
+ token: authorization == null ? void 0 : authorization.appToken,
265
268
  ensureAuthorizationToken: true
266
269
  })
267
270
  );
@@ -275,11 +278,10 @@ var import_axios2 = require("axios");
275
278
  var gitHubRepositoryApi = {
276
279
  getRepository(repositoryName, authorization) {
277
280
  return __async(this, null, function* () {
278
- var _a;
279
281
  const response = yield githubClientInstance.get(
280
282
  `/repos/${repositoryName}`,
281
- getGithubClientRequestConfig({
282
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
283
+ getGithubClientConfig({
284
+ token: authorization == null ? void 0 : authorization.appToken,
283
285
  ensureAuthorizationToken: true
284
286
  })
285
287
  );
@@ -288,11 +290,10 @@ var gitHubRepositoryApi = {
288
290
  },
289
291
  getRepositoryBranches(repositoryName, authorization) {
290
292
  return __async(this, null, function* () {
291
- var _a;
292
293
  const response = yield githubClientInstance.get(
293
294
  `/repos/${repositoryName}/branches`,
294
- getGithubClientRequestConfig({
295
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
295
+ getGithubClientConfig({
296
+ token: authorization == null ? void 0 : authorization.appToken,
296
297
  ensureAuthorizationToken: true
297
298
  })
298
299
  );
@@ -301,11 +302,10 @@ var gitHubRepositoryApi = {
301
302
  },
302
303
  getRepositoryBranch(repositoryName, repositoryBranch, authorization) {
303
304
  return __async(this, null, function* () {
304
- var _a;
305
305
  const response = yield githubClientInstance.get(
306
306
  `/repos/${repositoryName}/branches`,
307
- getGithubClientRequestConfig({
308
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
307
+ getGithubClientConfig({
308
+ token: authorization == null ? void 0 : authorization.appToken,
309
309
  ensureAuthorizationToken: true
310
310
  })
311
311
  );
@@ -320,11 +320,10 @@ var gitHubRepositoryApi = {
320
320
  },
321
321
  getRepositorySeed(repositoryName, authorization) {
322
322
  return __async(this, null, function* () {
323
- var _a;
324
323
  const { data } = yield githubClientInstance.get(
325
324
  `/repos/${repositoryName}/contents/livechat.config.json`,
326
- getGithubClientRequestConfig({
327
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
325
+ getGithubClientConfig({
326
+ token: authorization == null ? void 0 : authorization.appToken,
328
327
  ensureAuthorizationToken: true
329
328
  })
330
329
  );
@@ -333,7 +332,6 @@ var gitHubRepositoryApi = {
333
332
  },
334
333
  createRepository(name, hasInstallation, template, authorization) {
335
334
  return __async(this, null, function* () {
336
- var _a, _b, _c, _d;
337
335
  if (template || !hasInstallation) {
338
336
  let repository;
339
337
  if (template) {
@@ -345,8 +343,8 @@ var gitHubRepositoryApi = {
345
343
  private: false,
346
344
  include_all_branches: false
347
345
  },
348
- getGithubClientRequestConfig({
349
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.oauth,
346
+ getGithubClientConfig({
347
+ token: authorization == null ? void 0 : authorization.oauthToken,
350
348
  ensureAuthorizationToken: true
351
349
  })
352
350
  );
@@ -361,8 +359,8 @@ var gitHubRepositoryApi = {
361
359
  auto_init: true,
362
360
  is_template: false
363
361
  },
364
- getGithubClientRequestConfig({
365
- token: (_b = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _b.oauth,
362
+ getGithubClientConfig({
363
+ token: authorization == null ? void 0 : authorization.oauthToken,
366
364
  ensureAuthorizationToken: true
367
365
  })
368
366
  );
@@ -373,8 +371,8 @@ var gitHubRepositoryApi = {
373
371
  {
374
372
  private: true
375
373
  },
376
- getGithubClientRequestConfig({
377
- token: (_c = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _c.oauth,
374
+ getGithubClientConfig({
375
+ token: authorization == null ? void 0 : authorization.oauthToken,
378
376
  ensureAuthorizationToken: true
379
377
  })
380
378
  );
@@ -389,8 +387,8 @@ var gitHubRepositoryApi = {
389
387
  auto_init: true,
390
388
  is_template: false
391
389
  },
392
- getGithubClientRequestConfig({
393
- token: (_d = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _d.app,
390
+ getGithubClientConfig({
391
+ token: authorization == null ? void 0 : authorization.appToken,
394
392
  ensureAuthorizationToken: true
395
393
  })
396
394
  );
@@ -400,7 +398,6 @@ var gitHubRepositoryApi = {
400
398
  seedRepository(repositoryName, manifest, isForLabs, authorization) {
401
399
  return __async(this, null, function* () {
402
400
  const upsert = (sha) => __async(this, null, function* () {
403
- var _a;
404
401
  const response = yield githubClientInstance.put(
405
402
  `/repos/${repositoryName}/contents/livechat.config.json`,
406
403
  {
@@ -416,8 +413,8 @@ var gitHubRepositoryApi = {
416
413
  )
417
414
  )
418
415
  },
419
- getGithubClientRequestConfig({
420
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
416
+ getGithubClientConfig({
417
+ token: authorization == null ? void 0 : authorization.appToken,
421
418
  ensureAuthorizationToken: true
422
419
  })
423
420
  );
@@ -433,11 +430,10 @@ var gitHubRepositoryApi = {
433
430
  },
434
431
  deleteRepository(repositoryName, authorization) {
435
432
  return __async(this, null, function* () {
436
- var _a;
437
433
  return githubClientInstance.delete(
438
434
  `/repos/${repositoryName}`,
439
- getGithubClientRequestConfig({
440
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
435
+ getGithubClientConfig({
436
+ token: authorization == null ? void 0 : authorization.appToken,
441
437
  ensureAuthorizationToken: true
442
438
  })
443
439
  );
@@ -445,15 +441,14 @@ var gitHubRepositoryApi = {
445
441
  },
446
442
  createRepositoryDeployKey(repositoryName, deployKey, authorization) {
447
443
  return __async(this, null, function* () {
448
- var _a;
449
444
  const response = yield githubClientInstance.post(
450
445
  `/repos/${repositoryName}/keys`,
451
446
  {
452
447
  title: "developer-console-to-netlify",
453
448
  key: deployKey
454
449
  },
455
- getGithubClientRequestConfig({
456
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
450
+ getGithubClientConfig({
451
+ token: authorization == null ? void 0 : authorization.appToken,
457
452
  ensureAuthorizationToken: true
458
453
  })
459
454
  );
@@ -462,7 +457,6 @@ var gitHubRepositoryApi = {
462
457
  },
463
458
  createRepositoryBuildHook(repositoryName, authorization) {
464
459
  return __async(this, null, function* () {
465
- var _a;
466
460
  try {
467
461
  const response = yield githubClientInstance.post(
468
462
  `/repos/${repositoryName}/hooks`,
@@ -483,8 +477,8 @@ var gitHubRepositoryApi = {
483
477
  content_type: "json"
484
478
  }
485
479
  },
486
- getGithubClientRequestConfig({
487
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
480
+ getGithubClientConfig({
481
+ token: authorization == null ? void 0 : authorization.appToken,
488
482
  ensureAuthorizationToken: true
489
483
  })
490
484
  );
@@ -495,11 +489,10 @@ var gitHubRepositoryApi = {
495
489
  },
496
490
  getFile(path, repositoryName, authorization) {
497
491
  return __async(this, null, function* () {
498
- var _a;
499
492
  const { data } = yield githubClientInstance.get(
500
493
  `/repos/${repositoryName}/contents/${path}`,
501
- getGithubClientRequestConfig({
502
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
494
+ getGithubClientConfig({
495
+ token: authorization == null ? void 0 : authorization.appToken,
503
496
  ensureAuthorizationToken: true
504
497
  })
505
498
  );
@@ -508,11 +501,10 @@ var gitHubRepositoryApi = {
508
501
  },
509
502
  getCommits(repositoryName, authorization) {
510
503
  return __async(this, null, function* () {
511
- var _a;
512
504
  const { data: commits } = yield githubClientInstance.get(
513
505
  `/repos/${repositoryName}/commits`,
514
- getGithubClientRequestConfig({
515
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
506
+ getGithubClientConfig({
507
+ token: authorization == null ? void 0 : authorization.appToken,
516
508
  ensureAuthorizationToken: true
517
509
  })
518
510
  );
@@ -521,7 +513,6 @@ var gitHubRepositoryApi = {
521
513
  },
522
514
  commitFiles(data, authorization) {
523
515
  return __async(this, null, function* () {
524
- var _a, _b, _c, _d, _e;
525
516
  const MODES = { FILE: "100644", FOLDER: "040000" };
526
517
  const TYPE = { BLOB: "blob", TREE: "tree" };
527
518
  const {
@@ -530,8 +521,8 @@ var gitHubRepositoryApi = {
530
521
  }
531
522
  } = yield githubClientInstance.get(
532
523
  `/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
533
- getGithubClientRequestConfig({
534
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
524
+ getGithubClientConfig({
525
+ token: authorization == null ? void 0 : authorization.appToken,
535
526
  ensureAuthorizationToken: true
536
527
  })
537
528
  );
@@ -541,8 +532,8 @@ var gitHubRepositoryApi = {
541
532
  }
542
533
  } = yield githubClientInstance.get(
543
534
  `/repos/${data.repositoryName}/git/commits/${currentCommitSha}`,
544
- getGithubClientRequestConfig({
545
- token: (_b = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _b.app,
535
+ getGithubClientConfig({
536
+ token: authorization == null ? void 0 : authorization.appToken,
546
537
  ensureAuthorizationToken: true
547
538
  })
548
539
  );
@@ -557,8 +548,8 @@ var gitHubRepositoryApi = {
557
548
  // If sha is null => the file gets deleted
558
549
  )
559
550
  },
560
- getGithubClientRequestConfig({
561
- token: (_c = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _c.app,
551
+ getGithubClientConfig({
552
+ token: authorization == null ? void 0 : authorization.appToken,
562
553
  ensureAuthorizationToken: true
563
554
  })
564
555
  );
@@ -571,16 +562,16 @@ var gitHubRepositoryApi = {
571
562
  tree: newTreeSha,
572
563
  parents: [currentCommitSha]
573
564
  },
574
- getGithubClientRequestConfig({
575
- token: (_d = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _d.app,
565
+ getGithubClientConfig({
566
+ token: authorization == null ? void 0 : authorization.appToken,
576
567
  ensureAuthorizationToken: true
577
568
  })
578
569
  );
579
570
  yield githubClientInstance.post(
580
571
  `/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
581
572
  { sha: newCommitSha },
582
- getGithubClientRequestConfig({
583
- token: (_e = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _e.app,
573
+ getGithubClientConfig({
574
+ token: authorization == null ? void 0 : authorization.appToken,
584
575
  ensureAuthorizationToken: true
585
576
  })
586
577
  );
@@ -604,9 +595,15 @@ var gitHubRepositoryApi = {
604
595
 
605
596
  // src/apis/integrations/github/user/api.ts
606
597
  var gitHubUserApi = {
607
- getUser() {
598
+ getUser(authorization) {
608
599
  return __async(this, null, function* () {
609
- const { data: user } = yield githubClientInstance.get(`/user`);
600
+ const { data: user } = yield githubClientInstance.get(
601
+ `/user`,
602
+ getGithubClientConfig({
603
+ token: authorization == null ? void 0 : authorization.appToken,
604
+ ensureAuthorizationToken: true
605
+ })
606
+ );
610
607
  return user;
611
608
  });
612
609
  }
@@ -670,24 +667,24 @@ function getNetlifyClientAuthorization(req) {
670
667
  };
671
668
  }
672
669
  function getNetlifyClientConfig(options = {}) {
670
+ var _a;
673
671
  const currentHeaders = netlifyClientInstance.defaults.headers;
674
- const defaultAuthorization = currentHeaders.Authorization;
675
- const headers = {
676
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
672
+ const config = {
673
+ authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
677
674
  };
678
- if (options.ensureAuthorizationToken && !headers.authorization) {
675
+ if (options.ensureAuthorizationToken && !config.authorization) {
679
676
  throw new UnauthorizeApiError("netlify");
680
677
  }
681
678
  return {
682
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
679
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
683
680
  };
684
681
  }
685
- function initNetlifyClientInstance(token) {
682
+ function initNetlifyClient(token) {
686
683
  if (token) {
687
- updateNetlifyClientInstance(token);
684
+ updateNetlifyClient(token);
688
685
  }
689
686
  }
690
- function updateNetlifyClientInstance(token) {
687
+ function updateNetlifyClient(token) {
691
688
  const headers = netlifyClientInstance.defaults.headers;
692
689
  if (token) {
693
690
  headers.Authorization = `Bearer ${token}`;
@@ -1106,7 +1103,10 @@ var import_axios7 = __toESM(require("axios"));
1106
1103
  // src/apis/integrations/planetscale/instance.ts
1107
1104
  var import_axios6 = __toESM(require("axios"));
1108
1105
  var planetScaleClientInstance = import_axios6.default.create({
1109
- baseURL: "https://api.planetscale.com"
1106
+ baseURL: "https://api.planetscale.com",
1107
+ headers: {
1108
+ "Content-Type": "application/json"
1109
+ }
1110
1110
  });
1111
1111
  planetScaleClientInstance.interceptors.response.use(
1112
1112
  (r) => r,
@@ -1126,24 +1126,24 @@ function getPlanetScaleClientAuthorization(req) {
1126
1126
  };
1127
1127
  }
1128
1128
  function getPlanetScaleClientConfig(options = {}) {
1129
+ var _a;
1129
1130
  const currentHeaders = planetScaleClientInstance.defaults.headers;
1130
- const defaultAuthorization = currentHeaders.Authorization;
1131
- const headers = {
1132
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `${options.token}` : void 0
1131
+ const config = {
1132
+ authorization: (_a = options.token ? `${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
1133
1133
  };
1134
- if (options.ensureAuthorizationToken && !headers.authorization) {
1134
+ if (options.ensureAuthorizationToken && !config.authorization) {
1135
1135
  throw new UnauthorizeApiError("planetscale");
1136
1136
  }
1137
1137
  return {
1138
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
1138
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
1139
1139
  };
1140
1140
  }
1141
- function initPlanetScaleClientInstance(token) {
1141
+ function initPlanetScaleClient(token) {
1142
1142
  if (token) {
1143
- updatePlanetScaleClientInstance(token);
1143
+ updatePlanetScaleClient(token);
1144
1144
  }
1145
1145
  }
1146
- function updatePlanetScaleClientInstance(token) {
1146
+ function updatePlanetScaleClient(token) {
1147
1147
  const headers = planetScaleClientInstance.defaults.headers;
1148
1148
  if (token) {
1149
1149
  headers.Authorization = `${token}`;
@@ -1334,21 +1334,21 @@ var textClientInstance = import_axios8.default.create({
1334
1334
  });
1335
1335
  function getTextClientAuthorization(req) {
1336
1336
  return {
1337
- token: req.headers["text-token"],
1337
+ token: req.headers["platform-token"],
1338
1338
  tokenType: "Bearer"
1339
1339
  };
1340
1340
  }
1341
1341
  function getTextClientConfig(option = {}) {
1342
+ var _a;
1342
1343
  const currentHeaders = textClientInstance.defaults.headers;
1343
- const defaultAuthorization = currentHeaders.Authorization;
1344
- const headers = {
1345
- authorization: defaultAuthorization != null ? defaultAuthorization : option.token ? `Bearer ${option.token}` : void 0
1344
+ const config = {
1345
+ authorization: (_a = option.token ? `Bearer ${option.token}` : void 0) != null ? _a : currentHeaders.Authorization
1346
1346
  };
1347
1347
  return {
1348
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
1348
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
1349
1349
  };
1350
1350
  }
1351
- function initTextClientInstance(baseUrl, token) {
1351
+ function initTextClient(baseUrl, token) {
1352
1352
  const headers = textClientInstance.defaults.headers;
1353
1353
  if (baseUrl) {
1354
1354
  textClientInstance.interceptors.request.use(
@@ -1757,24 +1757,24 @@ function getVercelClientAuthorization(req) {
1757
1757
  };
1758
1758
  }
1759
1759
  function getVercelClientConfig(options = {}) {
1760
+ var _a;
1760
1761
  const currentHeaders = vercelClientInstance.defaults.headers;
1761
- const defaultAuthorization = currentHeaders.Authorization;
1762
- const headers = {
1763
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
1762
+ const config = {
1763
+ authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
1764
1764
  };
1765
- if (options.ensureAuthorizationToken && !headers.authorization) {
1765
+ if (options.ensureAuthorizationToken && !config.authorization) {
1766
1766
  throw new UnauthorizeApiError("vercel");
1767
1767
  }
1768
1768
  return {
1769
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
1769
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
1770
1770
  };
1771
1771
  }
1772
- function initVercelClientInstance(token) {
1772
+ function initVercelClient(token) {
1773
1773
  if (token) {
1774
- updateVercelClientInstance(token);
1774
+ updateVercelClient(token);
1775
1775
  }
1776
1776
  }
1777
- function updateVercelClientInstance(token) {
1777
+ function updateVercelClient(token) {
1778
1778
  const headers = vercelClientInstance.defaults.headers;
1779
1779
  if (token) {
1780
1780
  headers.Authorization = `Bearer ${token}`;
@@ -2053,7 +2053,10 @@ var import_axios12 = __toESM(require("axios"));
2053
2053
  // src/apis/integrations/neon/instance.ts
2054
2054
  var import_axios11 = __toESM(require("axios"));
2055
2055
  var neonClientInstance = import_axios11.default.create({
2056
- baseURL: "https://console.neon.tech/api/v2/"
2056
+ baseURL: "https://console.neon.tech/api/v2",
2057
+ headers: {
2058
+ "Content-Type": "application/json"
2059
+ }
2057
2060
  });
2058
2061
  neonClientInstance.interceptors.response.use(
2059
2062
  (r) => r,
@@ -2073,24 +2076,24 @@ function getNeonClientAuthorization(req) {
2073
2076
  };
2074
2077
  }
2075
2078
  function getNeonClientConfig(options = {}) {
2079
+ var _a;
2076
2080
  const currentHeaders = neonClientInstance.defaults.headers;
2077
- const defaultAuthorization = currentHeaders.Authorization;
2078
- const headers = {
2079
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2081
+ const config = {
2082
+ authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
2080
2083
  };
2081
- if (options.ensureAuthorizationToken && !headers.authorization) {
2084
+ if (options.ensureAuthorizationToken && !config.authorization) {
2082
2085
  throw new UnauthorizeApiError("neon");
2083
2086
  }
2084
2087
  return {
2085
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2088
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
2086
2089
  };
2087
2090
  }
2088
- function initNeonClientInstance(token) {
2091
+ function initNeonClient(token) {
2089
2092
  if (token) {
2090
- updateNeonClientInstance(token);
2093
+ updateNeonClient(token);
2091
2094
  }
2092
2095
  }
2093
- function updateNeonClientInstance(token) {
2096
+ function updateNeonClient(token) {
2094
2097
  const headers = neonClientInstance.defaults.headers;
2095
2098
  if (token) {
2096
2099
  headers.Authorization = `Bearer ${token}`;
@@ -2373,7 +2376,7 @@ var mailchimpApi = {
2373
2376
  redirect_uri: redirectUri,
2374
2377
  grant_type: "authorization_code"
2375
2378
  });
2376
- const response = yield import_axios13.default.post(
2379
+ const tokenResponse = yield import_axios13.default.post(
2377
2380
  "https://login.mailchimp.com/oauth2/token",
2378
2381
  data,
2379
2382
  {
@@ -2382,11 +2385,31 @@ var mailchimpApi = {
2382
2385
  }
2383
2386
  }
2384
2387
  );
2385
- const params = new URLSearchParams(response.data);
2388
+ const params = new URLSearchParams(
2389
+ tokenResponse.data
2390
+ );
2386
2391
  return {
2387
2392
  token: (_a = params.get("access_token")) != null ? _a : ""
2388
2393
  };
2389
2394
  });
2395
+ },
2396
+ getMetadata(_0) {
2397
+ return __async(this, arguments, function* ({ token }) {
2398
+ const {
2399
+ data: { dc: server }
2400
+ } = yield import_axios13.default.get(
2401
+ "https://login.mailchimp.com/oauth2/metadata",
2402
+ {
2403
+ headers: {
2404
+ "Content-Type": "application/json",
2405
+ Authorization: `OAuth ${token}`
2406
+ }
2407
+ }
2408
+ );
2409
+ return {
2410
+ server
2411
+ };
2412
+ });
2390
2413
  }
2391
2414
  };
2392
2415
 
@@ -2452,7 +2475,7 @@ var livechatClientInstance = import_axios15.default.create({
2452
2475
  });
2453
2476
  function getLiveChatClientAuthorization(req) {
2454
2477
  return {
2455
- token: req.headers["livechat-token"]
2478
+ token: req.headers["platform-token"]
2456
2479
  };
2457
2480
  }
2458
2481
  function getLiveChatClientConfig(options = {}) {
@@ -2466,7 +2489,7 @@ function getLiveChatClientConfig(options = {}) {
2466
2489
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2467
2490
  };
2468
2491
  }
2469
- function initLiveChatClientInstance(baseUrl, token) {
2492
+ function initLiveChatClient(baseUrl, token) {
2470
2493
  const region = token ? getRegion(token) : void 0;
2471
2494
  const headers = livechatClientInstance.defaults.headers;
2472
2495
  if (baseUrl) {
@@ -2994,7 +3017,7 @@ platformAccountsClientInstance.interceptors.response.use(
2994
3017
  );
2995
3018
  function getPlatformAccountsClientAuthorization(req) {
2996
3019
  return {
2997
- token: req.headers["platform-accounts-token"]
3020
+ token: req.headers["platform-token"]
2998
3021
  };
2999
3022
  }
3000
3023
  function getPlatformAccountsClientConfig(options = {}) {
@@ -3007,7 +3030,7 @@ function getPlatformAccountsClientConfig(options = {}) {
3007
3030
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
3008
3031
  };
3009
3032
  }
3010
- function initPlatformAccountsClientInstance(baseUrl, token) {
3033
+ function initPlatformAccountsClient(baseUrl, token) {
3011
3034
  if (baseUrl) {
3012
3035
  platformAccountsClientInstance.interceptors.request.use(
3013
3036
  (config) => {
@@ -3330,9 +3353,8 @@ platformDpsClientInstance.interceptors.response.use(
3330
3353
  }
3331
3354
  );
3332
3355
  function getPlatformDpsClientAuthorization(req) {
3333
- var _a;
3334
3356
  return {
3335
- token: (_a = req.headers["platform-dps-token"]) != null ? _a : req.headers["platform-token"],
3357
+ token: req.headers["platform-token"],
3336
3358
  tokenType: "Bearer"
3337
3359
  };
3338
3360
  }
@@ -3354,7 +3376,7 @@ function getPlatformDpsClientConfig(options = {}) {
3354
3376
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
3355
3377
  };
3356
3378
  }
3357
- function initPlatformDpsClientInstance(baseUrl, token) {
3379
+ function initPlatformDpsClient(baseUrl, token) {
3358
3380
  const headers = platformDpsClientInstance.defaults.headers;
3359
3381
  if (baseUrl) {
3360
3382
  platformDpsClientInstance.interceptors.request.use(
@@ -4890,24 +4912,6 @@ var AdapterApiError = class extends ApiErrorBase {
4890
4912
  this.name = "adapter";
4891
4913
  }
4892
4914
  };
4893
- function getPlatformAdapterClientAuthorization(req) {
4894
- return {
4895
- platform: {
4896
- dps: req.headers["platform-dps-token"]
4897
- },
4898
- github: {
4899
- app: req.headers["github-app-token"],
4900
- oauth: req.headers["github-oauth-token"]
4901
- },
4902
- netlify: req.headers["netlify-token"],
4903
- vercel: req.headers["vercel-token"],
4904
- planetscale: req.headers["planetscale-token"],
4905
- neon: req.headers["neon-token"],
4906
- mailchimp: req.headers["mailchimp-token"],
4907
- shopify: req.headers["shopify-token"],
4908
- openai: req.headers["openai-token"]
4909
- };
4910
- }
4911
4915
  var platformAdapterClientInstance = import_axios18.default.create({
4912
4916
  baseURL: "https://platform.labs.text.com/console-adapter/api",
4913
4917
  headers: {
@@ -4930,69 +4934,96 @@ platformAdapterClientInstance.interceptors.response.use(
4930
4934
  return Promise.reject(error);
4931
4935
  }
4932
4936
  );
4937
+ function getPlatformAdapterClientAuthorization(req) {
4938
+ return {
4939
+ platform: {
4940
+ token: req.headers["platform-token"]
4941
+ },
4942
+ github: {
4943
+ appToken: req.headers["github-app-token"],
4944
+ oauthToken: req.headers["github-oauth-token"]
4945
+ },
4946
+ netlify: {
4947
+ token: req.headers["netlify-token"]
4948
+ },
4949
+ vercel: {
4950
+ token: req.headers["vercel-token"]
4951
+ },
4952
+ planetscale: {
4953
+ token: req.headers["planetscale-token"]
4954
+ },
4955
+ neon: {
4956
+ token: req.headers["neon-token"]
4957
+ },
4958
+ mailchimp: {
4959
+ token: req.headers["mailchimp-token"],
4960
+ server: req.headers["mailchimp-server"]
4961
+ },
4962
+ shopify: {
4963
+ token: req.headers["shopify-token"],
4964
+ shop: req.headers["shopify-shop"]
4965
+ }
4966
+ };
4967
+ }
4933
4968
  function getPlatformAdapterClientConfig(options = {}) {
4934
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
4969
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
4935
4970
  const currentHeaders = platformAdapterClientInstance.defaults.headers;
4936
4971
  const headers = {
4937
4972
  platform: {
4938
- dps: (_b = currentHeaders["platform-dps-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.dps
4973
+ token: (_b = currentHeaders["platform-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.token
4939
4974
  },
4940
4975
  integrations: {
4941
4976
  github: {
4942
- app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.app,
4943
- oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauth
4977
+ app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.appToken,
4978
+ oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauthToken
4944
4979
  },
4945
- netlify: (_g = currentHeaders["netlify-token"]) != null ? _g : options.netlify,
4946
- vercel: (_h = currentHeaders["vercel-token"]) != null ? _h : options.vercel,
4947
- planetscale: (_i = currentHeaders["planetscale-token"]) != null ? _i : options.planetscale,
4948
- neon: (_j = currentHeaders["neon-token"]) != null ? _j : options.neon,
4949
- mailchimp: (_k = currentHeaders["mailchimp-token"]) != null ? _k : options.mailchimp,
4950
- shopify: (_l = currentHeaders["shopify-token"]) != null ? _l : options.shopify,
4951
- openai: (_m = currentHeaders["openai-token"]) != null ? _m : options.openai
4980
+ netlify: (_h = currentHeaders["netlify-token"]) != null ? _h : (_g = options.netlify) == null ? void 0 : _g.token,
4981
+ vercel: (_j = currentHeaders["vercel-token"]) != null ? _j : (_i = options.vercel) == null ? void 0 : _i.token,
4982
+ planetscale: (_l = currentHeaders["planetscale-token"]) != null ? _l : (_k = options.planetscale) == null ? void 0 : _k.token,
4983
+ neon: (_n = currentHeaders["neon-token"]) != null ? _n : (_m = options.neon) == null ? void 0 : _m.token,
4984
+ mailchimp: (_p = currentHeaders["mailchimp-token"]) != null ? _p : (_o = options.mailchimp) == null ? void 0 : _o.token,
4985
+ mailchimpServer: (_r = currentHeaders["mailchimp-server"]) != null ? _r : (_q = options.mailchimp) == null ? void 0 : _q.server,
4986
+ shopify: (_t = currentHeaders["shopify-token"]) != null ? _t : (_s = options.shopify) == null ? void 0 : _s.token,
4987
+ shopifyShop: (_v = currentHeaders["shopify-shop"]) != null ? _v : (_u = options.shopify) == null ? void 0 : _u.shop
4952
4988
  }
4953
4989
  };
4954
- if (currentHeaders["platform-dps-token"]) {
4955
- currentHeaders["X-Region"] = (_n = getRegion2(currentHeaders["platform-dps-token"])) != null ? _n : void 0;
4990
+ if (currentHeaders["platform-token"]) {
4991
+ currentHeaders["X-Region"] = (_w = getRegion2(currentHeaders["platform-token"])) != null ? _w : void 0;
4956
4992
  }
4957
- if (((_p = (_o = options.ensureAuthorizationToken) == null ? void 0 : _o.platform) == null ? void 0 : _p.dps) && !headers.platform.dps) {
4993
+ if (((_x = options.ensureAuthorizationToken) == null ? void 0 : _x.platform) && !headers.platform.token) {
4958
4994
  throw new UnauthorizeApiError("accounts");
4959
4995
  }
4960
- if (((_q = options.ensureAuthorizationToken) == null ? void 0 : _q.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
4996
+ if (((_y = options.ensureAuthorizationToken) == null ? void 0 : _y.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
4961
4997
  throw new UnauthorizeApiError("github");
4962
4998
  }
4963
- if (((_r = options.ensureAuthorizationToken) == null ? void 0 : _r.vercel) && !headers.integrations.vercel) {
4999
+ if (((_z = options.ensureAuthorizationToken) == null ? void 0 : _z.vercel) && !headers.integrations.vercel) {
4964
5000
  throw new UnauthorizeApiError("vercel");
4965
5001
  }
4966
- if (((_s = options.ensureAuthorizationToken) == null ? void 0 : _s.netlify) && !headers.integrations.netlify) {
5002
+ if (((_A = options.ensureAuthorizationToken) == null ? void 0 : _A.netlify) && !headers.integrations.netlify) {
4967
5003
  throw new UnauthorizeApiError("netlify");
4968
5004
  }
4969
- if (((_t = options.ensureAuthorizationToken) == null ? void 0 : _t.planetscale) && !headers.integrations.planetscale) {
5005
+ if (((_B = options.ensureAuthorizationToken) == null ? void 0 : _B.planetscale) && !headers.integrations.planetscale) {
4970
5006
  throw new UnauthorizeApiError("planetscale");
4971
5007
  }
4972
- if (((_u = options.ensureAuthorizationToken) == null ? void 0 : _u.neon) && !headers.integrations.neon) {
5008
+ if (((_C = options.ensureAuthorizationToken) == null ? void 0 : _C.neon) && !headers.integrations.neon) {
4973
5009
  throw new UnauthorizeApiError("neon");
4974
5010
  }
4975
- if (((_v = options.ensureAuthorizationToken) == null ? void 0 : _v.mailchimp) && !headers.integrations.mailchimp) {
5011
+ if (((_D = options.ensureAuthorizationToken) == null ? void 0 : _D.mailchimp) && (!headers.integrations.mailchimp || !headers.integrations.mailchimpServer)) {
4976
5012
  throw new UnauthorizeApiError("mailchimp");
4977
5013
  }
4978
- if (((_w = options.ensureAuthorizationToken) == null ? void 0 : _w.shopify) && !headers.integrations.shopify) {
5014
+ if (((_E = options.ensureAuthorizationToken) == null ? void 0 : _E.shopify) && (!headers.integrations.shopify || !headers.integrations.shopifyShop)) {
4979
5015
  throw new UnauthorizeApiError("shopify");
4980
5016
  }
4981
- if (((_x = options.ensureAuthorizationToken) == null ? void 0 : _x.openai) && !headers.integrations.openai) {
4982
- throw new UnauthorizeApiError("openai");
4983
- }
4984
5017
  return {
4985
- headers: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, headers.platform.dps ? { "platform-dps-token": headers.platform.dps } : {}), headers.integrations.github.app ? { "github-app-token": headers.integrations.github.app } : {}), headers.integrations.github.oauth ? { "github-oauth-token": headers.integrations.github.oauth } : {}), headers.integrations.netlify ? { "netlify-token": headers.integrations.netlify } : {}), headers.integrations.vercel ? { "vercel-token": headers.integrations.vercel } : {}), headers.integrations.planetscale ? { "planetscale-token": headers.integrations.planetscale } : {}), headers.integrations.neon ? { "neon-token": headers.integrations.neon } : {}), headers.integrations.mailchimp ? { "mailchimp-token": headers.integrations.mailchimp } : {}), headers.integrations.shopify ? { "shopify-token": headers.integrations.shopify } : {}), headers.integrations.openai ? { "openai-token": headers.integrations.openai } : {})
5018
+ headers: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, headers.platform.token ? { "platform-token": headers.platform.token } : {}), headers.integrations.github.app ? { "github-app-token": headers.integrations.github.app } : {}), headers.integrations.github.oauth ? { "github-oauth-token": headers.integrations.github.oauth } : {}), headers.integrations.netlify ? { "netlify-token": headers.integrations.netlify } : {}), headers.integrations.vercel ? { "vercel-token": headers.integrations.vercel } : {}), headers.integrations.planetscale ? { "planetscale-token": headers.integrations.planetscale } : {}), headers.integrations.neon ? { "neon-token": headers.integrations.neon } : {}), headers.integrations.mailchimp ? { "mailchimp-token": headers.integrations.mailchimp } : {}), headers.integrations.mailchimpServer ? { "mailchimp-server": headers.integrations.mailchimpServer } : {}), headers.integrations.shopify ? { "shopify-token": headers.integrations.shopify } : {}), headers.integrations.shopifyShop ? { "shopify-shop": headers.integrations.shopifyShop } : {})
4986
5019
  };
4987
5020
  }
4988
5021
  var getPlatformAdapterClientDefaultConfig = (authorization) => getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4989
5022
  ensureAuthorizationToken: {
4990
- platform: {
4991
- dps: true
4992
- }
5023
+ platform: true
4993
5024
  }
4994
5025
  }));
4995
- function initPlatformAdapterClientInstance(baseUrl, tokens) {
5026
+ function initPlatformAdapterClient(baseUrl, tokens) {
4996
5027
  if (baseUrl) {
4997
5028
  platformAdapterClientInstance.interceptors.request.use(
4998
5029
  (config) => {
@@ -5003,41 +5034,44 @@ function initPlatformAdapterClientInstance(baseUrl, tokens) {
5003
5034
  );
5004
5035
  }
5005
5036
  if (tokens) {
5006
- updatePlatformAdapterClientInstance(tokens);
5037
+ updatePlatformAdapterClient(tokens);
5007
5038
  }
5008
5039
  }
5009
- function updatePlatformAdapterClientInstance(tokens) {
5010
- var _a, _b, _c;
5040
+ function updatePlatformAdapterClient(tokens) {
5041
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5011
5042
  const headers = platformAdapterClientInstance.defaults.headers;
5012
- if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.dps) {
5013
- headers["platform-dps-token"] = tokens.platform.dps;
5043
+ if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.token) {
5044
+ headers["platform-token"] = tokens.platform.token;
5045
+ }
5046
+ if ((_b = tokens == null ? void 0 : tokens.github) == null ? void 0 : _b.appToken) {
5047
+ headers["github-app-token"] = tokens.github.appToken;
5014
5048
  }
5015
- if ((_b = tokens == null ? void 0 : tokens.github) == null ? void 0 : _b.app) {
5016
- headers["github-app-token"] = tokens.github.app;
5049
+ if ((_c = tokens == null ? void 0 : tokens.github) == null ? void 0 : _c.oauthToken) {
5050
+ headers["github-oauth-token"] = tokens.github.oauthToken;
5017
5051
  }
5018
- if ((_c = tokens == null ? void 0 : tokens.github) == null ? void 0 : _c.oauth) {
5019
- headers["github-oauth-token"] = tokens.github.oauth;
5052
+ if ((_d = tokens == null ? void 0 : tokens.netlify) == null ? void 0 : _d.token) {
5053
+ headers["netlify-token"] = tokens.netlify.token;
5020
5054
  }
5021
- if (tokens == null ? void 0 : tokens.netlify) {
5022
- headers["netlify-token"] = tokens.netlify;
5055
+ if ((_e = tokens == null ? void 0 : tokens.vercel) == null ? void 0 : _e.token) {
5056
+ headers["vercel-token"] = tokens.vercel.token;
5023
5057
  }
5024
- if (tokens == null ? void 0 : tokens.vercel) {
5025
- headers["vercel-token"] = tokens.vercel;
5058
+ if ((_f = tokens == null ? void 0 : tokens.planetscale) == null ? void 0 : _f.token) {
5059
+ headers["planetscale-token"] = tokens.planetscale.token;
5026
5060
  }
5027
- if (tokens == null ? void 0 : tokens.planetscale) {
5028
- headers["planetscale-token"] = tokens.planetscale;
5061
+ if ((_g = tokens == null ? void 0 : tokens.neon) == null ? void 0 : _g.token) {
5062
+ headers["neon-token"] = tokens.neon.token;
5029
5063
  }
5030
- if (tokens == null ? void 0 : tokens.neon) {
5031
- headers["neon-token"] = tokens.neon;
5064
+ if ((_h = tokens == null ? void 0 : tokens.mailchimp) == null ? void 0 : _h.server) {
5065
+ headers["mailchimp-server"] = tokens.mailchimp.server;
5032
5066
  }
5033
- if (tokens == null ? void 0 : tokens.mailchimp) {
5034
- headers["mailchimp-token"] = tokens.mailchimp;
5067
+ if ((_i = tokens == null ? void 0 : tokens.mailchimp) == null ? void 0 : _i.token) {
5068
+ headers["mailchimp-token"] = tokens.mailchimp.token;
5035
5069
  }
5036
- if (tokens == null ? void 0 : tokens.shopify) {
5037
- headers["shopify-token"] = tokens.shopify;
5070
+ if ((_j = tokens == null ? void 0 : tokens.shopify) == null ? void 0 : _j.shop) {
5071
+ headers["shopify-shop"] = tokens.shopify.shop;
5038
5072
  }
5039
- if (tokens == null ? void 0 : tokens.openai) {
5040
- headers["openai-token"] = tokens.openai;
5073
+ if ((_k = tokens == null ? void 0 : tokens.shopify) == null ? void 0 : _k.token) {
5074
+ headers["shopify-token"] = tokens.shopify.token;
5041
5075
  }
5042
5076
  }
5043
5077
 
@@ -5531,8 +5565,11 @@ var platformAdapterConductorApi = {
5531
5565
 
5532
5566
  // src/apis/integrations/mailchimp/instance.ts
5533
5567
  var import_axios19 = __toESM(require("axios"));
5568
+ var getMailchimpClientUrl = (server) => `https://${server}.api.mailchimp.com/3.0`;
5534
5569
  var mailchimpClientInstance = import_axios19.default.create({
5535
- baseURL: "https://us6.api.mailchimp.com/3.0/"
5570
+ headers: {
5571
+ "Content-Type": "application/json"
5572
+ }
5536
5573
  });
5537
5574
  mailchimpClientInstance.interceptors.response.use(
5538
5575
  (r) => r,
@@ -5548,39 +5585,106 @@ mailchimpClientInstance.interceptors.response.use(
5548
5585
  );
5549
5586
  function getMailchimpClientAuthorization(req) {
5550
5587
  return {
5588
+ server: req.headers["mailchimp-server"],
5551
5589
  token: req.headers["mailchimp-token"]
5552
5590
  };
5553
5591
  }
5554
5592
  function getMailchimpClientConfig(options = {}) {
5593
+ var _a, _b;
5594
+ const currentBaseUrl = mailchimpClientInstance.defaults.baseURL;
5555
5595
  const currentHeaders = mailchimpClientInstance.defaults.headers;
5556
- const defaultAuthorization = currentHeaders.Authorization;
5557
- const headers = {
5558
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
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
5559
5599
  };
5560
- if (options.ensureAuthorizationToken && !headers.authorization) {
5600
+ if (options.ensureAuthorizationToken && (!config.authorization || !config.baseUrl)) {
5561
5601
  throw new UnauthorizeApiError("mailchimp");
5562
5602
  }
5563
5603
  return {
5564
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
5604
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
5565
5605
  };
5566
5606
  }
5567
- function initMailchimpClientInstance(token) {
5568
- if (token) {
5607
+ function initMailchimpClient(token, server) {
5608
+ if (token && server) {
5569
5609
  updateMailchimpClientInstance(token);
5570
5610
  }
5571
5611
  }
5572
- function updateMailchimpClientInstance(token) {
5573
- const headers = mailchimpClientInstance.defaults.headers;
5612
+ function updateMailchimpClientInstance(token, server) {
5613
+ const defaults = mailchimpClientInstance.defaults;
5614
+ const headers = defaults.headers;
5574
5615
  if (token) {
5575
5616
  headers.Authorization = `Bearer ${token}`;
5576
5617
  } else {
5577
5618
  delete headers.Authorization;
5578
5619
  }
5620
+ if (server) {
5621
+ defaults.baseURL = getMailchimpClientUrl(server);
5622
+ } else {
5623
+ delete defaults.baseURL;
5624
+ }
5579
5625
  }
5580
5626
 
5581
- // src/apis/platform/billing/instance.ts
5627
+ // src/apis/integrations/shopify/instance.ts
5582
5628
  var import_axios20 = __toESM(require("axios"));
5583
- var platformBillingClientInstance = import_axios20.default.create({
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
+ // src/apis/platform/billing/instance.ts
5686
+ var import_axios21 = __toESM(require("axios"));
5687
+ var platformBillingClientInstance = import_axios21.default.create({
5584
5688
  baseURL: "https://billing.labs.livechatinc.com"
5585
5689
  });
5586
5690
  function getPlatformBillingClientAuthorization(req) {
@@ -5598,7 +5702,7 @@ function getPlatformBillingClientConfig(options = {}) {
5598
5702
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
5599
5703
  };
5600
5704
  }
5601
- function initPlatformBillingClientInstance(baseUrl, token) {
5705
+ function initPlatformBillingClient(baseUrl, token) {
5602
5706
  if (baseUrl) {
5603
5707
  platformBillingClientInstance.interceptors.request.use(
5604
5708
  (config) => {
@@ -5779,45 +5883,38 @@ var api = {
5779
5883
  isInitialized: false
5780
5884
  };
5781
5885
  function initApi(config, tokens) {
5782
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
5783
- initPlatformAccountsClientInstance(
5886
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
5887
+ initPlatformAccountsClient(
5784
5888
  (_a = config.urls.platform) == null ? void 0 : _a.accounts,
5785
- (_b = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _b.dps
5889
+ (_b = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _b.token
5786
5890
  );
5787
- initPlatformBillingClientInstance(
5891
+ initPlatformBillingClient(
5788
5892
  (_c = config.urls.platform) == null ? void 0 : _c.billing,
5789
- (_d = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _d.dps
5790
- );
5791
- initPlatformDpsClientInstance(
5792
- (_e = config.urls.platform) == null ? void 0 : _e.dps,
5793
- (_f = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _f.dps
5893
+ (_d = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _d.token
5794
5894
  );
5795
- initPlatformAdapterClientInstance(
5895
+ initPlatformDpsClient((_e = config.urls.platform) == null ? void 0 : _e.dps, (_f = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _f.token);
5896
+ initPlatformAdapterClient(
5796
5897
  (_g = config.urls.platform) == null ? void 0 : _g.adapter,
5797
5898
  tokens ? {
5798
- platform: {
5799
- dps: (_h = tokens.platform) == null ? void 0 : _h.dps
5800
- },
5801
- github: {
5802
- app: (_i = tokens.github) == null ? void 0 : _i.apps,
5803
- oauth: (_j = tokens.github) == null ? void 0 : _j.oauth
5804
- },
5805
- netlify: (_k = tokens.netlify) == null ? void 0 : _k.token,
5806
- vercel: (_l = tokens.vercel) == null ? void 0 : _l.token,
5807
- neon: (_m = tokens.neon) == null ? void 0 : _m.token,
5808
- planetscale: (_n = tokens.planetscale) == null ? void 0 : _n.token
5899
+ platform: tokens.platform,
5900
+ github: tokens.github,
5901
+ netlify: tokens.netlify,
5902
+ vercel: tokens.vercel,
5903
+ neon: tokens.neon,
5904
+ planetscale: tokens.planetscale,
5905
+ mailchimp: tokens.mailchimp,
5906
+ shopify: tokens.shopify
5809
5907
  } : void 0
5810
5908
  );
5811
- initLiveChatClientInstance(
5812
- (_o = config.urls.products) == null ? void 0 : _o.livechat,
5813
- (_p = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _p.dps
5814
- );
5815
- initTextClientInstance((_q = config.urls.integrations) == null ? void 0 : _q.text, (_r = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _r.dps);
5816
- initGithubClientInstance((_s = tokens == null ? void 0 : tokens.github) == null ? void 0 : _s.apps);
5817
- initNetlifyClientInstance((_t = tokens == null ? void 0 : tokens.netlify) == null ? void 0 : _t.token);
5818
- initVercelClientInstance((_u = tokens == null ? void 0 : tokens.vercel) == null ? void 0 : _u.token);
5819
- initNeonClientInstance((_v = tokens == null ? void 0 : tokens.neon) == null ? void 0 : _v.token);
5820
- initPlanetScaleClientInstance((_w = tokens == null ? void 0 : tokens.planetscale) == null ? void 0 : _w.token);
5909
+ initLiveChatClient((_h = config.urls.products) == null ? void 0 : _h.livechat, (_i = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _i.token);
5910
+ initTextClient((_j = config.urls.integrations) == null ? void 0 : _j.text, (_k = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _k.token);
5911
+ initGithubClient((_l = tokens == null ? void 0 : tokens.github) == null ? void 0 : _l.appToken);
5912
+ initNetlifyClient((_m = tokens == null ? void 0 : tokens.netlify) == null ? void 0 : _m.token);
5913
+ initVercelClient((_n = tokens == null ? void 0 : tokens.vercel) == null ? void 0 : _n.token);
5914
+ initNeonClient((_o = tokens == null ? void 0 : tokens.neon) == null ? void 0 : _o.token);
5915
+ initPlanetScaleClient((_p = tokens == null ? void 0 : tokens.planetscale) == null ? void 0 : _p.token);
5916
+ initMailchimpClient((_q = tokens == null ? void 0 : tokens.mailchimp) == null ? void 0 : _q.token, (_r = tokens == null ? void 0 : tokens.mailchimp) == null ? void 0 : _r.server);
5917
+ initShopifyClient((_s = tokens == null ? void 0 : tokens.shopify) == null ? void 0 : _s.token, (_t = tokens == null ? void 0 : tokens.shopify) == null ? void 0 : _t.shop);
5821
5918
  api.isInitialized = true;
5822
5919
  }
5823
5920
 
@@ -5860,12 +5957,13 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
5860
5957
  getAppAutoReviewPayload,
5861
5958
  getEmptyAppAutoReview,
5862
5959
  getGitHubClientAuthorization,
5863
- getGithubClientRequestConfig,
5960
+ getGithubClientConfig,
5864
5961
  getIntegrationFlowUrl,
5865
5962
  getLiveChatClientAuthorization,
5866
5963
  getLiveChatClientConfig,
5867
5964
  getMailchimpClientAuthorization,
5868
5965
  getMailchimpClientConfig,
5966
+ getMailchimpClientUrl,
5869
5967
  getNeonClientAuthorization,
5870
5968
  getNeonClientConfig,
5871
5969
  getNetlifyClientAuthorization,
@@ -5883,24 +5981,28 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
5883
5981
  getPlatformDpsClientAuthorization,
5884
5982
  getPlatformDpsClientConfig,
5885
5983
  getRegion,
5984
+ getShopifyClientAuthorization,
5985
+ getShopifyClientConfig,
5986
+ getShopifyClientUrl,
5886
5987
  getTextClientAuthorization,
5887
5988
  getTextClientConfig,
5888
5989
  getVercelClientAuthorization,
5889
5990
  getVercelClientConfig,
5890
5991
  githubClientInstance,
5891
5992
  initApi,
5892
- initGithubClientInstance,
5893
- initLiveChatClientInstance,
5894
- initMailchimpClientInstance,
5895
- initNeonClientInstance,
5896
- initNetlifyClientInstance,
5897
- initPlanetScaleClientInstance,
5898
- initPlatformAccountsClientInstance,
5899
- initPlatformAdapterClientInstance,
5900
- initPlatformBillingClientInstance,
5901
- initPlatformDpsClientInstance,
5902
- initTextClientInstance,
5903
- initVercelClientInstance,
5993
+ initGithubClient,
5994
+ initLiveChatClient,
5995
+ initMailchimpClient,
5996
+ initNeonClient,
5997
+ initNetlifyClient,
5998
+ initPlanetScaleClient,
5999
+ initPlatformAccountsClient,
6000
+ initPlatformAdapterClient,
6001
+ initPlatformBillingClient,
6002
+ initPlatformDpsClient,
6003
+ initShopifyClient,
6004
+ initTextClient,
6005
+ initVercelClient,
5904
6006
  livechatClientInstance,
5905
6007
  mailchimpClientInstance,
5906
6008
  neonClientInstance,
@@ -5910,13 +6012,15 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
5910
6012
  platformAdapterClientInstance,
5911
6013
  platformBillingClientInstance,
5912
6014
  platformDpsClientInstance,
6015
+ shopifyClientInstance,
5913
6016
  textClientInstance,
5914
- updateGithubClientInstance,
6017
+ updateGithubClient,
5915
6018
  updateMailchimpClientInstance,
5916
- updateNeonClientInstance,
5917
- updateNetlifyClientInstance,
5918
- updatePlanetScaleClientInstance,
5919
- updatePlatformAdapterClientInstance,
5920
- updateVercelClientInstance,
6019
+ updateNeonClient,
6020
+ updateNetlifyClient,
6021
+ updatePlanetScaleClient,
6022
+ updatePlatformAdapterClient,
6023
+ updateShopifyClient,
6024
+ updateVercelClient,
5921
6025
  vercelClientInstance
5922
6026
  });