@livechat/developer-studio-api 3.0.39 → 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,
@@ -108,25 +109,26 @@ __export(src_exports, {
108
109
  getRegion: () => getRegion,
109
110
  getShopifyClientAuthorization: () => getShopifyClientAuthorization,
110
111
  getShopifyClientConfig: () => getShopifyClientConfig,
112
+ getShopifyClientUrl: () => getShopifyClientUrl,
111
113
  getTextClientAuthorization: () => getTextClientAuthorization,
112
114
  getTextClientConfig: () => getTextClientConfig,
113
115
  getVercelClientAuthorization: () => getVercelClientAuthorization,
114
116
  getVercelClientConfig: () => getVercelClientConfig,
115
117
  githubClientInstance: () => githubClientInstance,
116
118
  initApi: () => initApi,
117
- initGithubClientInstance: () => initGithubClientInstance,
118
- initLiveChatClientInstance: () => initLiveChatClientInstance,
119
- initMailchimpClientInstance: () => initMailchimpClientInstance,
120
- initNeonClientInstance: () => initNeonClientInstance,
121
- initNetlifyClientInstance: () => initNetlifyClientInstance,
122
- initPlanetScaleClientInstance: () => initPlanetScaleClientInstance,
123
- initPlatformAccountsClientInstance: () => initPlatformAccountsClientInstance,
124
- initPlatformAdapterClientInstance: () => initPlatformAdapterClientInstance,
125
- initPlatformBillingClientInstance: () => initPlatformBillingClientInstance,
126
- initPlatformDpsClientInstance: () => initPlatformDpsClientInstance,
127
- initShopifyClientInstance: () => initShopifyClientInstance,
128
- initTextClientInstance: () => initTextClientInstance,
129
- 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,
130
132
  livechatClientInstance: () => livechatClientInstance,
131
133
  mailchimpClientInstance: () => mailchimpClientInstance,
132
134
  neonClientInstance: () => neonClientInstance,
@@ -136,17 +138,16 @@ __export(src_exports, {
136
138
  platformAdapterClientInstance: () => platformAdapterClientInstance,
137
139
  platformBillingClientInstance: () => platformBillingClientInstance,
138
140
  platformDpsClientInstance: () => platformDpsClientInstance,
139
- shopifyApiUrl: () => shopifyApiUrl,
140
141
  shopifyClientInstance: () => shopifyClientInstance,
141
142
  textClientInstance: () => textClientInstance,
142
- updateGithubClientInstance: () => updateGithubClientInstance,
143
+ updateGithubClient: () => updateGithubClient,
143
144
  updateMailchimpClientInstance: () => updateMailchimpClientInstance,
144
- updateNeonClientInstance: () => updateNeonClientInstance,
145
- updateNetlifyClientInstance: () => updateNetlifyClientInstance,
146
- updatePlanetScaleClientInstance: () => updatePlanetScaleClientInstance,
147
- updatePlatformAdapterClientInstance: () => updatePlatformAdapterClientInstance,
148
- updateShopifyClientInstance: () => updateShopifyClientInstance,
149
- updateVercelClientInstance: () => updateVercelClientInstance,
145
+ updateNeonClient: () => updateNeonClient,
146
+ updateNetlifyClient: () => updateNetlifyClient,
147
+ updatePlanetScaleClient: () => updatePlanetScaleClient,
148
+ updatePlatformAdapterClient: () => updatePlatformAdapterClient,
149
+ updateShopifyClient: () => updateShopifyClient,
150
+ updateVercelClient: () => updateVercelClient,
150
151
  vercelClientInstance: () => vercelClientInstance
151
152
  });
152
153
  module.exports = __toCommonJS(src_exports);
@@ -205,31 +206,29 @@ githubClientInstance.interceptors.response.use(
205
206
  );
206
207
  function getGitHubClientAuthorization(req) {
207
208
  return {
208
- tokens: {
209
- app: req.headers["github-app-token"],
210
- oauth: req.headers["github-oauth-token"]
211
- }
209
+ appToken: req.headers["github-app-token"],
210
+ oauthToken: req.headers["github-oauth-token"]
212
211
  };
213
212
  }
214
- function getGithubClientRequestConfig(options = {}) {
213
+ function getGithubClientConfig(options = {}) {
214
+ var _a;
215
215
  const currentHeaders = githubClientInstance.defaults.headers;
216
- const defaultAuthorization = currentHeaders.Authorization;
217
- const headers = {
218
- 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
219
218
  };
220
- if (options.ensureAuthorizationToken && !headers.authorization) {
219
+ if (options.ensureAuthorizationToken && !config.authorization) {
221
220
  throw new UnauthorizeApiError("github");
222
221
  }
223
222
  return {
224
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
223
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
225
224
  };
226
225
  }
227
- function initGithubClientInstance(token) {
226
+ function initGithubClient(token) {
228
227
  if (token) {
229
- updateGithubClientInstance(token);
228
+ updateGithubClient(token);
230
229
  }
231
230
  }
232
- function updateGithubClientInstance(token) {
231
+ function updateGithubClient(token) {
233
232
  const headers = githubClientInstance.defaults.headers;
234
233
  if (token) {
235
234
  headers.Authorization = `Bearer ${token}`;
@@ -250,11 +249,10 @@ var gitHubInstallationApi = {
250
249
  },
251
250
  getInstallations(authorization) {
252
251
  return __async(this, null, function* () {
253
- var _a;
254
252
  const response = yield githubClientInstance.get(
255
253
  `/user/installations?timestamp=${(/* @__PURE__ */ new Date()).getTime()}`,
256
- getGithubClientRequestConfig({
257
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
254
+ getGithubClientConfig({
255
+ token: authorization == null ? void 0 : authorization.appToken,
258
256
  ensureAuthorizationToken: true
259
257
  })
260
258
  );
@@ -263,11 +261,10 @@ var gitHubInstallationApi = {
263
261
  },
264
262
  getInstallationRepositories(installationId, authorization) {
265
263
  return __async(this, null, function* () {
266
- var _a;
267
264
  const response = yield githubClientInstance.get(
268
265
  `/user/installations/${installationId}/repositories?timestamp=${(/* @__PURE__ */ new Date()).getTime()}&per_page=100`,
269
- getGithubClientRequestConfig({
270
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
266
+ getGithubClientConfig({
267
+ token: authorization == null ? void 0 : authorization.appToken,
271
268
  ensureAuthorizationToken: true
272
269
  })
273
270
  );
@@ -281,11 +278,10 @@ var import_axios2 = require("axios");
281
278
  var gitHubRepositoryApi = {
282
279
  getRepository(repositoryName, authorization) {
283
280
  return __async(this, null, function* () {
284
- var _a;
285
281
  const response = yield githubClientInstance.get(
286
282
  `/repos/${repositoryName}`,
287
- getGithubClientRequestConfig({
288
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
283
+ getGithubClientConfig({
284
+ token: authorization == null ? void 0 : authorization.appToken,
289
285
  ensureAuthorizationToken: true
290
286
  })
291
287
  );
@@ -294,11 +290,10 @@ var gitHubRepositoryApi = {
294
290
  },
295
291
  getRepositoryBranches(repositoryName, authorization) {
296
292
  return __async(this, null, function* () {
297
- var _a;
298
293
  const response = yield githubClientInstance.get(
299
294
  `/repos/${repositoryName}/branches`,
300
- getGithubClientRequestConfig({
301
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
295
+ getGithubClientConfig({
296
+ token: authorization == null ? void 0 : authorization.appToken,
302
297
  ensureAuthorizationToken: true
303
298
  })
304
299
  );
@@ -307,11 +302,10 @@ var gitHubRepositoryApi = {
307
302
  },
308
303
  getRepositoryBranch(repositoryName, repositoryBranch, authorization) {
309
304
  return __async(this, null, function* () {
310
- var _a;
311
305
  const response = yield githubClientInstance.get(
312
306
  `/repos/${repositoryName}/branches`,
313
- getGithubClientRequestConfig({
314
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
307
+ getGithubClientConfig({
308
+ token: authorization == null ? void 0 : authorization.appToken,
315
309
  ensureAuthorizationToken: true
316
310
  })
317
311
  );
@@ -326,11 +320,10 @@ var gitHubRepositoryApi = {
326
320
  },
327
321
  getRepositorySeed(repositoryName, authorization) {
328
322
  return __async(this, null, function* () {
329
- var _a;
330
323
  const { data } = yield githubClientInstance.get(
331
324
  `/repos/${repositoryName}/contents/livechat.config.json`,
332
- getGithubClientRequestConfig({
333
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
325
+ getGithubClientConfig({
326
+ token: authorization == null ? void 0 : authorization.appToken,
334
327
  ensureAuthorizationToken: true
335
328
  })
336
329
  );
@@ -339,7 +332,6 @@ var gitHubRepositoryApi = {
339
332
  },
340
333
  createRepository(name, hasInstallation, template, authorization) {
341
334
  return __async(this, null, function* () {
342
- var _a, _b, _c, _d;
343
335
  if (template || !hasInstallation) {
344
336
  let repository;
345
337
  if (template) {
@@ -351,8 +343,8 @@ var gitHubRepositoryApi = {
351
343
  private: false,
352
344
  include_all_branches: false
353
345
  },
354
- getGithubClientRequestConfig({
355
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.oauth,
346
+ getGithubClientConfig({
347
+ token: authorization == null ? void 0 : authorization.oauthToken,
356
348
  ensureAuthorizationToken: true
357
349
  })
358
350
  );
@@ -367,8 +359,8 @@ var gitHubRepositoryApi = {
367
359
  auto_init: true,
368
360
  is_template: false
369
361
  },
370
- getGithubClientRequestConfig({
371
- token: (_b = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _b.oauth,
362
+ getGithubClientConfig({
363
+ token: authorization == null ? void 0 : authorization.oauthToken,
372
364
  ensureAuthorizationToken: true
373
365
  })
374
366
  );
@@ -379,8 +371,8 @@ var gitHubRepositoryApi = {
379
371
  {
380
372
  private: true
381
373
  },
382
- getGithubClientRequestConfig({
383
- token: (_c = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _c.oauth,
374
+ getGithubClientConfig({
375
+ token: authorization == null ? void 0 : authorization.oauthToken,
384
376
  ensureAuthorizationToken: true
385
377
  })
386
378
  );
@@ -395,8 +387,8 @@ var gitHubRepositoryApi = {
395
387
  auto_init: true,
396
388
  is_template: false
397
389
  },
398
- getGithubClientRequestConfig({
399
- token: (_d = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _d.app,
390
+ getGithubClientConfig({
391
+ token: authorization == null ? void 0 : authorization.appToken,
400
392
  ensureAuthorizationToken: true
401
393
  })
402
394
  );
@@ -406,7 +398,6 @@ var gitHubRepositoryApi = {
406
398
  seedRepository(repositoryName, manifest, isForLabs, authorization) {
407
399
  return __async(this, null, function* () {
408
400
  const upsert = (sha) => __async(this, null, function* () {
409
- var _a;
410
401
  const response = yield githubClientInstance.put(
411
402
  `/repos/${repositoryName}/contents/livechat.config.json`,
412
403
  {
@@ -422,8 +413,8 @@ var gitHubRepositoryApi = {
422
413
  )
423
414
  )
424
415
  },
425
- getGithubClientRequestConfig({
426
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
416
+ getGithubClientConfig({
417
+ token: authorization == null ? void 0 : authorization.appToken,
427
418
  ensureAuthorizationToken: true
428
419
  })
429
420
  );
@@ -439,11 +430,10 @@ var gitHubRepositoryApi = {
439
430
  },
440
431
  deleteRepository(repositoryName, authorization) {
441
432
  return __async(this, null, function* () {
442
- var _a;
443
433
  return githubClientInstance.delete(
444
434
  `/repos/${repositoryName}`,
445
- getGithubClientRequestConfig({
446
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
435
+ getGithubClientConfig({
436
+ token: authorization == null ? void 0 : authorization.appToken,
447
437
  ensureAuthorizationToken: true
448
438
  })
449
439
  );
@@ -451,15 +441,14 @@ var gitHubRepositoryApi = {
451
441
  },
452
442
  createRepositoryDeployKey(repositoryName, deployKey, authorization) {
453
443
  return __async(this, null, function* () {
454
- var _a;
455
444
  const response = yield githubClientInstance.post(
456
445
  `/repos/${repositoryName}/keys`,
457
446
  {
458
447
  title: "developer-console-to-netlify",
459
448
  key: deployKey
460
449
  },
461
- getGithubClientRequestConfig({
462
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
450
+ getGithubClientConfig({
451
+ token: authorization == null ? void 0 : authorization.appToken,
463
452
  ensureAuthorizationToken: true
464
453
  })
465
454
  );
@@ -468,7 +457,6 @@ var gitHubRepositoryApi = {
468
457
  },
469
458
  createRepositoryBuildHook(repositoryName, authorization) {
470
459
  return __async(this, null, function* () {
471
- var _a;
472
460
  try {
473
461
  const response = yield githubClientInstance.post(
474
462
  `/repos/${repositoryName}/hooks`,
@@ -489,8 +477,8 @@ var gitHubRepositoryApi = {
489
477
  content_type: "json"
490
478
  }
491
479
  },
492
- getGithubClientRequestConfig({
493
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
480
+ getGithubClientConfig({
481
+ token: authorization == null ? void 0 : authorization.appToken,
494
482
  ensureAuthorizationToken: true
495
483
  })
496
484
  );
@@ -501,11 +489,10 @@ var gitHubRepositoryApi = {
501
489
  },
502
490
  getFile(path, repositoryName, authorization) {
503
491
  return __async(this, null, function* () {
504
- var _a;
505
492
  const { data } = yield githubClientInstance.get(
506
493
  `/repos/${repositoryName}/contents/${path}`,
507
- getGithubClientRequestConfig({
508
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
494
+ getGithubClientConfig({
495
+ token: authorization == null ? void 0 : authorization.appToken,
509
496
  ensureAuthorizationToken: true
510
497
  })
511
498
  );
@@ -514,11 +501,10 @@ var gitHubRepositoryApi = {
514
501
  },
515
502
  getCommits(repositoryName, authorization) {
516
503
  return __async(this, null, function* () {
517
- var _a;
518
504
  const { data: commits } = yield githubClientInstance.get(
519
505
  `/repos/${repositoryName}/commits`,
520
- getGithubClientRequestConfig({
521
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
506
+ getGithubClientConfig({
507
+ token: authorization == null ? void 0 : authorization.appToken,
522
508
  ensureAuthorizationToken: true
523
509
  })
524
510
  );
@@ -527,7 +513,6 @@ var gitHubRepositoryApi = {
527
513
  },
528
514
  commitFiles(data, authorization) {
529
515
  return __async(this, null, function* () {
530
- var _a, _b, _c, _d, _e;
531
516
  const MODES = { FILE: "100644", FOLDER: "040000" };
532
517
  const TYPE = { BLOB: "blob", TREE: "tree" };
533
518
  const {
@@ -536,8 +521,8 @@ var gitHubRepositoryApi = {
536
521
  }
537
522
  } = yield githubClientInstance.get(
538
523
  `/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
539
- getGithubClientRequestConfig({
540
- token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
524
+ getGithubClientConfig({
525
+ token: authorization == null ? void 0 : authorization.appToken,
541
526
  ensureAuthorizationToken: true
542
527
  })
543
528
  );
@@ -547,8 +532,8 @@ var gitHubRepositoryApi = {
547
532
  }
548
533
  } = yield githubClientInstance.get(
549
534
  `/repos/${data.repositoryName}/git/commits/${currentCommitSha}`,
550
- getGithubClientRequestConfig({
551
- token: (_b = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _b.app,
535
+ getGithubClientConfig({
536
+ token: authorization == null ? void 0 : authorization.appToken,
552
537
  ensureAuthorizationToken: true
553
538
  })
554
539
  );
@@ -563,8 +548,8 @@ var gitHubRepositoryApi = {
563
548
  // If sha is null => the file gets deleted
564
549
  )
565
550
  },
566
- getGithubClientRequestConfig({
567
- token: (_c = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _c.app,
551
+ getGithubClientConfig({
552
+ token: authorization == null ? void 0 : authorization.appToken,
568
553
  ensureAuthorizationToken: true
569
554
  })
570
555
  );
@@ -577,16 +562,16 @@ var gitHubRepositoryApi = {
577
562
  tree: newTreeSha,
578
563
  parents: [currentCommitSha]
579
564
  },
580
- getGithubClientRequestConfig({
581
- token: (_d = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _d.app,
565
+ getGithubClientConfig({
566
+ token: authorization == null ? void 0 : authorization.appToken,
582
567
  ensureAuthorizationToken: true
583
568
  })
584
569
  );
585
570
  yield githubClientInstance.post(
586
571
  `/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
587
572
  { sha: newCommitSha },
588
- getGithubClientRequestConfig({
589
- token: (_e = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _e.app,
573
+ getGithubClientConfig({
574
+ token: authorization == null ? void 0 : authorization.appToken,
590
575
  ensureAuthorizationToken: true
591
576
  })
592
577
  );
@@ -610,9 +595,15 @@ var gitHubRepositoryApi = {
610
595
 
611
596
  // src/apis/integrations/github/user/api.ts
612
597
  var gitHubUserApi = {
613
- getUser() {
598
+ getUser(authorization) {
614
599
  return __async(this, null, function* () {
615
- 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
+ );
616
607
  return user;
617
608
  });
618
609
  }
@@ -676,24 +667,24 @@ function getNetlifyClientAuthorization(req) {
676
667
  };
677
668
  }
678
669
  function getNetlifyClientConfig(options = {}) {
670
+ var _a;
679
671
  const currentHeaders = netlifyClientInstance.defaults.headers;
680
- const defaultAuthorization = currentHeaders.Authorization;
681
- const headers = {
682
- 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
683
674
  };
684
- if (options.ensureAuthorizationToken && !headers.authorization) {
675
+ if (options.ensureAuthorizationToken && !config.authorization) {
685
676
  throw new UnauthorizeApiError("netlify");
686
677
  }
687
678
  return {
688
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
679
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
689
680
  };
690
681
  }
691
- function initNetlifyClientInstance(token) {
682
+ function initNetlifyClient(token) {
692
683
  if (token) {
693
- updateNetlifyClientInstance(token);
684
+ updateNetlifyClient(token);
694
685
  }
695
686
  }
696
- function updateNetlifyClientInstance(token) {
687
+ function updateNetlifyClient(token) {
697
688
  const headers = netlifyClientInstance.defaults.headers;
698
689
  if (token) {
699
690
  headers.Authorization = `Bearer ${token}`;
@@ -1112,7 +1103,10 @@ var import_axios7 = __toESM(require("axios"));
1112
1103
  // src/apis/integrations/planetscale/instance.ts
1113
1104
  var import_axios6 = __toESM(require("axios"));
1114
1105
  var planetScaleClientInstance = import_axios6.default.create({
1115
- baseURL: "https://api.planetscale.com"
1106
+ baseURL: "https://api.planetscale.com",
1107
+ headers: {
1108
+ "Content-Type": "application/json"
1109
+ }
1116
1110
  });
1117
1111
  planetScaleClientInstance.interceptors.response.use(
1118
1112
  (r) => r,
@@ -1132,24 +1126,24 @@ function getPlanetScaleClientAuthorization(req) {
1132
1126
  };
1133
1127
  }
1134
1128
  function getPlanetScaleClientConfig(options = {}) {
1129
+ var _a;
1135
1130
  const currentHeaders = planetScaleClientInstance.defaults.headers;
1136
- const defaultAuthorization = currentHeaders.Authorization;
1137
- const headers = {
1138
- 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
1139
1133
  };
1140
- if (options.ensureAuthorizationToken && !headers.authorization) {
1134
+ if (options.ensureAuthorizationToken && !config.authorization) {
1141
1135
  throw new UnauthorizeApiError("planetscale");
1142
1136
  }
1143
1137
  return {
1144
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
1138
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
1145
1139
  };
1146
1140
  }
1147
- function initPlanetScaleClientInstance(token) {
1141
+ function initPlanetScaleClient(token) {
1148
1142
  if (token) {
1149
- updatePlanetScaleClientInstance(token);
1143
+ updatePlanetScaleClient(token);
1150
1144
  }
1151
1145
  }
1152
- function updatePlanetScaleClientInstance(token) {
1146
+ function updatePlanetScaleClient(token) {
1153
1147
  const headers = planetScaleClientInstance.defaults.headers;
1154
1148
  if (token) {
1155
1149
  headers.Authorization = `${token}`;
@@ -1340,21 +1334,21 @@ var textClientInstance = import_axios8.default.create({
1340
1334
  });
1341
1335
  function getTextClientAuthorization(req) {
1342
1336
  return {
1343
- token: req.headers["text-token"],
1337
+ token: req.headers["platform-token"],
1344
1338
  tokenType: "Bearer"
1345
1339
  };
1346
1340
  }
1347
1341
  function getTextClientConfig(option = {}) {
1342
+ var _a;
1348
1343
  const currentHeaders = textClientInstance.defaults.headers;
1349
- const defaultAuthorization = currentHeaders.Authorization;
1350
- const headers = {
1351
- 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
1352
1346
  };
1353
1347
  return {
1354
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
1348
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
1355
1349
  };
1356
1350
  }
1357
- function initTextClientInstance(baseUrl, token) {
1351
+ function initTextClient(baseUrl, token) {
1358
1352
  const headers = textClientInstance.defaults.headers;
1359
1353
  if (baseUrl) {
1360
1354
  textClientInstance.interceptors.request.use(
@@ -1763,24 +1757,24 @@ function getVercelClientAuthorization(req) {
1763
1757
  };
1764
1758
  }
1765
1759
  function getVercelClientConfig(options = {}) {
1760
+ var _a;
1766
1761
  const currentHeaders = vercelClientInstance.defaults.headers;
1767
- const defaultAuthorization = currentHeaders.Authorization;
1768
- const headers = {
1769
- 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
1770
1764
  };
1771
- if (options.ensureAuthorizationToken && !headers.authorization) {
1765
+ if (options.ensureAuthorizationToken && !config.authorization) {
1772
1766
  throw new UnauthorizeApiError("vercel");
1773
1767
  }
1774
1768
  return {
1775
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
1769
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
1776
1770
  };
1777
1771
  }
1778
- function initVercelClientInstance(token) {
1772
+ function initVercelClient(token) {
1779
1773
  if (token) {
1780
- updateVercelClientInstance(token);
1774
+ updateVercelClient(token);
1781
1775
  }
1782
1776
  }
1783
- function updateVercelClientInstance(token) {
1777
+ function updateVercelClient(token) {
1784
1778
  const headers = vercelClientInstance.defaults.headers;
1785
1779
  if (token) {
1786
1780
  headers.Authorization = `Bearer ${token}`;
@@ -2059,7 +2053,10 @@ var import_axios12 = __toESM(require("axios"));
2059
2053
  // src/apis/integrations/neon/instance.ts
2060
2054
  var import_axios11 = __toESM(require("axios"));
2061
2055
  var neonClientInstance = import_axios11.default.create({
2062
- baseURL: "https://console.neon.tech/api/v2/"
2056
+ baseURL: "https://console.neon.tech/api/v2",
2057
+ headers: {
2058
+ "Content-Type": "application/json"
2059
+ }
2063
2060
  });
2064
2061
  neonClientInstance.interceptors.response.use(
2065
2062
  (r) => r,
@@ -2079,24 +2076,24 @@ function getNeonClientAuthorization(req) {
2079
2076
  };
2080
2077
  }
2081
2078
  function getNeonClientConfig(options = {}) {
2079
+ var _a;
2082
2080
  const currentHeaders = neonClientInstance.defaults.headers;
2083
- const defaultAuthorization = currentHeaders.Authorization;
2084
- const headers = {
2085
- 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
2086
2083
  };
2087
- if (options.ensureAuthorizationToken && !headers.authorization) {
2084
+ if (options.ensureAuthorizationToken && !config.authorization) {
2088
2085
  throw new UnauthorizeApiError("neon");
2089
2086
  }
2090
2087
  return {
2091
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2088
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
2092
2089
  };
2093
2090
  }
2094
- function initNeonClientInstance(token) {
2091
+ function initNeonClient(token) {
2095
2092
  if (token) {
2096
- updateNeonClientInstance(token);
2093
+ updateNeonClient(token);
2097
2094
  }
2098
2095
  }
2099
- function updateNeonClientInstance(token) {
2096
+ function updateNeonClient(token) {
2100
2097
  const headers = neonClientInstance.defaults.headers;
2101
2098
  if (token) {
2102
2099
  headers.Authorization = `Bearer ${token}`;
@@ -2379,7 +2376,7 @@ var mailchimpApi = {
2379
2376
  redirect_uri: redirectUri,
2380
2377
  grant_type: "authorization_code"
2381
2378
  });
2382
- const response = yield import_axios13.default.post(
2379
+ const tokenResponse = yield import_axios13.default.post(
2383
2380
  "https://login.mailchimp.com/oauth2/token",
2384
2381
  data,
2385
2382
  {
@@ -2388,11 +2385,31 @@ var mailchimpApi = {
2388
2385
  }
2389
2386
  }
2390
2387
  );
2391
- const params = new URLSearchParams(response.data);
2388
+ const params = new URLSearchParams(
2389
+ tokenResponse.data
2390
+ );
2392
2391
  return {
2393
2392
  token: (_a = params.get("access_token")) != null ? _a : ""
2394
2393
  };
2395
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
+ });
2396
2413
  }
2397
2414
  };
2398
2415
 
@@ -2458,7 +2475,7 @@ var livechatClientInstance = import_axios15.default.create({
2458
2475
  });
2459
2476
  function getLiveChatClientAuthorization(req) {
2460
2477
  return {
2461
- token: req.headers["livechat-token"]
2478
+ token: req.headers["platform-token"]
2462
2479
  };
2463
2480
  }
2464
2481
  function getLiveChatClientConfig(options = {}) {
@@ -2472,7 +2489,7 @@ function getLiveChatClientConfig(options = {}) {
2472
2489
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2473
2490
  };
2474
2491
  }
2475
- function initLiveChatClientInstance(baseUrl, token) {
2492
+ function initLiveChatClient(baseUrl, token) {
2476
2493
  const region = token ? getRegion(token) : void 0;
2477
2494
  const headers = livechatClientInstance.defaults.headers;
2478
2495
  if (baseUrl) {
@@ -3000,7 +3017,7 @@ platformAccountsClientInstance.interceptors.response.use(
3000
3017
  );
3001
3018
  function getPlatformAccountsClientAuthorization(req) {
3002
3019
  return {
3003
- token: req.headers["platform-accounts-token"]
3020
+ token: req.headers["platform-token"]
3004
3021
  };
3005
3022
  }
3006
3023
  function getPlatformAccountsClientConfig(options = {}) {
@@ -3013,7 +3030,7 @@ function getPlatformAccountsClientConfig(options = {}) {
3013
3030
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
3014
3031
  };
3015
3032
  }
3016
- function initPlatformAccountsClientInstance(baseUrl, token) {
3033
+ function initPlatformAccountsClient(baseUrl, token) {
3017
3034
  if (baseUrl) {
3018
3035
  platformAccountsClientInstance.interceptors.request.use(
3019
3036
  (config) => {
@@ -3336,9 +3353,8 @@ platformDpsClientInstance.interceptors.response.use(
3336
3353
  }
3337
3354
  );
3338
3355
  function getPlatformDpsClientAuthorization(req) {
3339
- var _a;
3340
3356
  return {
3341
- token: (_a = req.headers["platform-dps-token"]) != null ? _a : req.headers["platform-token"],
3357
+ token: req.headers["platform-token"],
3342
3358
  tokenType: "Bearer"
3343
3359
  };
3344
3360
  }
@@ -3360,7 +3376,7 @@ function getPlatformDpsClientConfig(options = {}) {
3360
3376
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
3361
3377
  };
3362
3378
  }
3363
- function initPlatformDpsClientInstance(baseUrl, token) {
3379
+ function initPlatformDpsClient(baseUrl, token) {
3364
3380
  const headers = platformDpsClientInstance.defaults.headers;
3365
3381
  if (baseUrl) {
3366
3382
  platformDpsClientInstance.interceptors.request.use(
@@ -4896,24 +4912,6 @@ var AdapterApiError = class extends ApiErrorBase {
4896
4912
  this.name = "adapter";
4897
4913
  }
4898
4914
  };
4899
- function getPlatformAdapterClientAuthorization(req) {
4900
- return {
4901
- platform: {
4902
- dps: req.headers["platform-dps-token"]
4903
- },
4904
- github: {
4905
- app: req.headers["github-app-token"],
4906
- oauth: req.headers["github-oauth-token"]
4907
- },
4908
- netlify: req.headers["netlify-token"],
4909
- vercel: req.headers["vercel-token"],
4910
- planetscale: req.headers["planetscale-token"],
4911
- neon: req.headers["neon-token"],
4912
- mailchimp: req.headers["mailchimp-token"],
4913
- shopify: req.headers["shopify-token"],
4914
- openai: req.headers["openai-token"]
4915
- };
4916
- }
4917
4915
  var platformAdapterClientInstance = import_axios18.default.create({
4918
4916
  baseURL: "https://platform.labs.text.com/console-adapter/api",
4919
4917
  headers: {
@@ -4936,69 +4934,96 @@ platformAdapterClientInstance.interceptors.response.use(
4936
4934
  return Promise.reject(error);
4937
4935
  }
4938
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
+ }
4939
4968
  function getPlatformAdapterClientConfig(options = {}) {
4940
- 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;
4941
4970
  const currentHeaders = platformAdapterClientInstance.defaults.headers;
4942
4971
  const headers = {
4943
4972
  platform: {
4944
- 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
4945
4974
  },
4946
4975
  integrations: {
4947
4976
  github: {
4948
- app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.app,
4949
- 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
4950
4979
  },
4951
- netlify: (_g = currentHeaders["netlify-token"]) != null ? _g : options.netlify,
4952
- vercel: (_h = currentHeaders["vercel-token"]) != null ? _h : options.vercel,
4953
- planetscale: (_i = currentHeaders["planetscale-token"]) != null ? _i : options.planetscale,
4954
- neon: (_j = currentHeaders["neon-token"]) != null ? _j : options.neon,
4955
- mailchimp: (_k = currentHeaders["mailchimp-token"]) != null ? _k : options.mailchimp,
4956
- shopify: (_l = currentHeaders["shopify-token"]) != null ? _l : options.shopify,
4957
- 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
4958
4988
  }
4959
4989
  };
4960
- if (currentHeaders["platform-dps-token"]) {
4961
- 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;
4962
4992
  }
4963
- 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) {
4964
4994
  throw new UnauthorizeApiError("accounts");
4965
4995
  }
4966
- 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)) {
4967
4997
  throw new UnauthorizeApiError("github");
4968
4998
  }
4969
- 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) {
4970
5000
  throw new UnauthorizeApiError("vercel");
4971
5001
  }
4972
- 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) {
4973
5003
  throw new UnauthorizeApiError("netlify");
4974
5004
  }
4975
- 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) {
4976
5006
  throw new UnauthorizeApiError("planetscale");
4977
5007
  }
4978
- 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) {
4979
5009
  throw new UnauthorizeApiError("neon");
4980
5010
  }
4981
- 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)) {
4982
5012
  throw new UnauthorizeApiError("mailchimp");
4983
5013
  }
4984
- 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)) {
4985
5015
  throw new UnauthorizeApiError("shopify");
4986
5016
  }
4987
- if (((_x = options.ensureAuthorizationToken) == null ? void 0 : _x.openai) && !headers.integrations.openai) {
4988
- throw new UnauthorizeApiError("openai");
4989
- }
4990
5017
  return {
4991
- 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 } : {})
4992
5019
  };
4993
5020
  }
4994
5021
  var getPlatformAdapterClientDefaultConfig = (authorization) => getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4995
5022
  ensureAuthorizationToken: {
4996
- platform: {
4997
- dps: true
4998
- }
5023
+ platform: true
4999
5024
  }
5000
5025
  }));
5001
- function initPlatformAdapterClientInstance(baseUrl, tokens) {
5026
+ function initPlatformAdapterClient(baseUrl, tokens) {
5002
5027
  if (baseUrl) {
5003
5028
  platformAdapterClientInstance.interceptors.request.use(
5004
5029
  (config) => {
@@ -5009,41 +5034,44 @@ function initPlatformAdapterClientInstance(baseUrl, tokens) {
5009
5034
  );
5010
5035
  }
5011
5036
  if (tokens) {
5012
- updatePlatformAdapterClientInstance(tokens);
5037
+ updatePlatformAdapterClient(tokens);
5013
5038
  }
5014
5039
  }
5015
- function updatePlatformAdapterClientInstance(tokens) {
5016
- var _a, _b, _c;
5040
+ function updatePlatformAdapterClient(tokens) {
5041
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5017
5042
  const headers = platformAdapterClientInstance.defaults.headers;
5018
- if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.dps) {
5019
- 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;
5020
5048
  }
5021
- if ((_b = tokens == null ? void 0 : tokens.github) == null ? void 0 : _b.app) {
5022
- 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;
5023
5051
  }
5024
- if ((_c = tokens == null ? void 0 : tokens.github) == null ? void 0 : _c.oauth) {
5025
- 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;
5026
5054
  }
5027
- if (tokens == null ? void 0 : tokens.netlify) {
5028
- 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;
5029
5057
  }
5030
- if (tokens == null ? void 0 : tokens.vercel) {
5031
- 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;
5032
5060
  }
5033
- if (tokens == null ? void 0 : tokens.planetscale) {
5034
- 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;
5035
5063
  }
5036
- if (tokens == null ? void 0 : tokens.neon) {
5037
- 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;
5038
5066
  }
5039
- if (tokens == null ? void 0 : tokens.mailchimp) {
5040
- 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;
5041
5069
  }
5042
- if (tokens == null ? void 0 : tokens.shopify) {
5043
- 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;
5044
5072
  }
5045
- if (tokens == null ? void 0 : tokens.openai) {
5046
- 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;
5047
5075
  }
5048
5076
  }
5049
5077
 
@@ -5537,8 +5565,11 @@ var platformAdapterConductorApi = {
5537
5565
 
5538
5566
  // src/apis/integrations/mailchimp/instance.ts
5539
5567
  var import_axios19 = __toESM(require("axios"));
5568
+ var getMailchimpClientUrl = (server) => `https://${server}.api.mailchimp.com/3.0`;
5540
5569
  var mailchimpClientInstance = import_axios19.default.create({
5541
- baseURL: "https://us6.api.mailchimp.com/3.0/"
5570
+ headers: {
5571
+ "Content-Type": "application/json"
5572
+ }
5542
5573
  });
5543
5574
  mailchimpClientInstance.interceptors.response.use(
5544
5575
  (r) => r,
@@ -5554,42 +5585,48 @@ mailchimpClientInstance.interceptors.response.use(
5554
5585
  );
5555
5586
  function getMailchimpClientAuthorization(req) {
5556
5587
  return {
5588
+ server: req.headers["mailchimp-server"],
5557
5589
  token: req.headers["mailchimp-token"]
5558
5590
  };
5559
5591
  }
5560
5592
  function getMailchimpClientConfig(options = {}) {
5593
+ var _a, _b;
5594
+ const currentBaseUrl = mailchimpClientInstance.defaults.baseURL;
5561
5595
  const currentHeaders = mailchimpClientInstance.defaults.headers;
5562
- const defaultAuthorization = currentHeaders.Authorization;
5563
- const headers = {
5564
- 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
5565
5599
  };
5566
- if (options.ensureAuthorizationToken && !headers.authorization) {
5600
+ if (options.ensureAuthorizationToken && (!config.authorization || !config.baseUrl)) {
5567
5601
  throw new UnauthorizeApiError("mailchimp");
5568
5602
  }
5569
5603
  return {
5570
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
5604
+ headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
5571
5605
  };
5572
5606
  }
5573
- function initMailchimpClientInstance(token) {
5574
- if (token) {
5607
+ function initMailchimpClient(token, server) {
5608
+ if (token && server) {
5575
5609
  updateMailchimpClientInstance(token);
5576
5610
  }
5577
5611
  }
5578
- function updateMailchimpClientInstance(token) {
5579
- const headers = mailchimpClientInstance.defaults.headers;
5612
+ function updateMailchimpClientInstance(token, server) {
5613
+ const defaults = mailchimpClientInstance.defaults;
5614
+ const headers = defaults.headers;
5580
5615
  if (token) {
5581
5616
  headers.Authorization = `Bearer ${token}`;
5582
5617
  } else {
5583
5618
  delete headers.Authorization;
5584
5619
  }
5620
+ if (server) {
5621
+ defaults.baseURL = getMailchimpClientUrl(server);
5622
+ } else {
5623
+ delete defaults.baseURL;
5624
+ }
5585
5625
  }
5586
5626
 
5587
5627
  // src/apis/integrations/shopify/instance.ts
5588
5628
  var import_axios20 = __toESM(require("axios"));
5589
- var shopifyApiUrl = (store) => `https://${store}.myshopify.com/admin/api`;
5590
- var shopifyClientInstance = import_axios20.default.create({
5591
- baseURL: "https://myshopify.com/admin/api"
5592
- });
5629
+ var shopifyClientInstance = import_axios20.default.create();
5593
5630
  shopifyClientInstance.interceptors.response.use(
5594
5631
  (r) => r,
5595
5632
  (error) => {
@@ -5602,36 +5639,47 @@ shopifyClientInstance.interceptors.response.use(
5602
5639
  throw error;
5603
5640
  }
5604
5641
  );
5642
+ var getShopifyClientUrl = (store) => `https://${store}.myshopify.com/admin/api`;
5605
5643
  function getShopifyClientAuthorization(req) {
5606
5644
  return {
5645
+ shop: req.headers["shopify-shop"],
5607
5646
  token: req.headers["shopify-token"]
5608
5647
  };
5609
5648
  }
5610
- function getShopifyClientConfig(options = {}) {
5649
+ function getShopifyClientConfig(options) {
5650
+ var _a, _b;
5651
+ const currentBaseUrl = shopifyClientInstance.defaults.baseURL;
5611
5652
  const currentHeaders = shopifyClientInstance.defaults.headers;
5612
- const defaultAuthorization = currentHeaders.Authorization;
5613
- const headers = {
5614
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
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"]
5615
5656
  };
5616
- if (options.ensureAuthorizationToken && !headers.authorization) {
5657
+ if (options.ensureAuthorizationToken && (!config.authorization || !config.baseUrl)) {
5617
5658
  throw new UnauthorizeApiError("shopify");
5618
5659
  }
5619
5660
  return {
5620
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
5661
+ baseURL: config.baseUrl,
5662
+ headers: __spreadValues({}, config.authorization ? { "X-Shopify-Access-Token": config.authorization } : {})
5621
5663
  };
5622
5664
  }
5623
- function initShopifyClientInstance(token) {
5624
- if (token) {
5625
- updateShopifyClientInstance(token);
5665
+ function initShopifyClient(token, shop) {
5666
+ if (token && shop) {
5667
+ updateShopifyClient(token);
5626
5668
  }
5627
5669
  }
5628
- function updateShopifyClientInstance(token) {
5629
- const headers = shopifyClientInstance.defaults.headers;
5670
+ function updateShopifyClient(token, shop) {
5671
+ const defaults = shopifyClientInstance.defaults;
5672
+ const headers = defaults.headers;
5630
5673
  if (token) {
5631
5674
  headers.Authorization = `Bearer ${token}`;
5632
5675
  } else {
5633
5676
  delete headers.Authorization;
5634
5677
  }
5678
+ if (shop) {
5679
+ defaults.baseURL = getShopifyClientUrl(shop);
5680
+ } else {
5681
+ delete defaults.baseURL;
5682
+ }
5635
5683
  }
5636
5684
 
5637
5685
  // src/apis/platform/billing/instance.ts
@@ -5654,7 +5702,7 @@ function getPlatformBillingClientConfig(options = {}) {
5654
5702
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
5655
5703
  };
5656
5704
  }
5657
- function initPlatformBillingClientInstance(baseUrl, token) {
5705
+ function initPlatformBillingClient(baseUrl, token) {
5658
5706
  if (baseUrl) {
5659
5707
  platformBillingClientInstance.interceptors.request.use(
5660
5708
  (config) => {
@@ -5835,45 +5883,38 @@ var api = {
5835
5883
  isInitialized: false
5836
5884
  };
5837
5885
  function initApi(config, tokens) {
5838
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
5839
- 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(
5840
5888
  (_a = config.urls.platform) == null ? void 0 : _a.accounts,
5841
- (_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
5842
5890
  );
5843
- initPlatformBillingClientInstance(
5891
+ initPlatformBillingClient(
5844
5892
  (_c = config.urls.platform) == null ? void 0 : _c.billing,
5845
- (_d = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _d.dps
5846
- );
5847
- initPlatformDpsClientInstance(
5848
- (_e = config.urls.platform) == null ? void 0 : _e.dps,
5849
- (_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
5850
5894
  );
5851
- 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(
5852
5897
  (_g = config.urls.platform) == null ? void 0 : _g.adapter,
5853
5898
  tokens ? {
5854
- platform: {
5855
- dps: (_h = tokens.platform) == null ? void 0 : _h.dps
5856
- },
5857
- github: {
5858
- app: (_i = tokens.github) == null ? void 0 : _i.apps,
5859
- oauth: (_j = tokens.github) == null ? void 0 : _j.oauth
5860
- },
5861
- netlify: (_k = tokens.netlify) == null ? void 0 : _k.token,
5862
- vercel: (_l = tokens.vercel) == null ? void 0 : _l.token,
5863
- neon: (_m = tokens.neon) == null ? void 0 : _m.token,
5864
- 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
5865
5907
  } : void 0
5866
5908
  );
5867
- initLiveChatClientInstance(
5868
- (_o = config.urls.products) == null ? void 0 : _o.livechat,
5869
- (_p = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _p.dps
5870
- );
5871
- initTextClientInstance((_q = config.urls.integrations) == null ? void 0 : _q.text, (_r = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _r.dps);
5872
- initGithubClientInstance((_s = tokens == null ? void 0 : tokens.github) == null ? void 0 : _s.apps);
5873
- initNetlifyClientInstance((_t = tokens == null ? void 0 : tokens.netlify) == null ? void 0 : _t.token);
5874
- initVercelClientInstance((_u = tokens == null ? void 0 : tokens.vercel) == null ? void 0 : _u.token);
5875
- initNeonClientInstance((_v = tokens == null ? void 0 : tokens.neon) == null ? void 0 : _v.token);
5876
- 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);
5877
5918
  api.isInitialized = true;
5878
5919
  }
5879
5920
 
@@ -5916,12 +5957,13 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
5916
5957
  getAppAutoReviewPayload,
5917
5958
  getEmptyAppAutoReview,
5918
5959
  getGitHubClientAuthorization,
5919
- getGithubClientRequestConfig,
5960
+ getGithubClientConfig,
5920
5961
  getIntegrationFlowUrl,
5921
5962
  getLiveChatClientAuthorization,
5922
5963
  getLiveChatClientConfig,
5923
5964
  getMailchimpClientAuthorization,
5924
5965
  getMailchimpClientConfig,
5966
+ getMailchimpClientUrl,
5925
5967
  getNeonClientAuthorization,
5926
5968
  getNeonClientConfig,
5927
5969
  getNetlifyClientAuthorization,
@@ -5941,25 +5983,26 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
5941
5983
  getRegion,
5942
5984
  getShopifyClientAuthorization,
5943
5985
  getShopifyClientConfig,
5986
+ getShopifyClientUrl,
5944
5987
  getTextClientAuthorization,
5945
5988
  getTextClientConfig,
5946
5989
  getVercelClientAuthorization,
5947
5990
  getVercelClientConfig,
5948
5991
  githubClientInstance,
5949
5992
  initApi,
5950
- initGithubClientInstance,
5951
- initLiveChatClientInstance,
5952
- initMailchimpClientInstance,
5953
- initNeonClientInstance,
5954
- initNetlifyClientInstance,
5955
- initPlanetScaleClientInstance,
5956
- initPlatformAccountsClientInstance,
5957
- initPlatformAdapterClientInstance,
5958
- initPlatformBillingClientInstance,
5959
- initPlatformDpsClientInstance,
5960
- initShopifyClientInstance,
5961
- initTextClientInstance,
5962
- 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,
5963
6006
  livechatClientInstance,
5964
6007
  mailchimpClientInstance,
5965
6008
  neonClientInstance,
@@ -5969,16 +6012,15 @@ function getIntegrationFlowUrl(provider, flow, data, context, config) {
5969
6012
  platformAdapterClientInstance,
5970
6013
  platformBillingClientInstance,
5971
6014
  platformDpsClientInstance,
5972
- shopifyApiUrl,
5973
6015
  shopifyClientInstance,
5974
6016
  textClientInstance,
5975
- updateGithubClientInstance,
6017
+ updateGithubClient,
5976
6018
  updateMailchimpClientInstance,
5977
- updateNeonClientInstance,
5978
- updateNetlifyClientInstance,
5979
- updatePlanetScaleClientInstance,
5980
- updatePlatformAdapterClientInstance,
5981
- updateShopifyClientInstance,
5982
- updateVercelClientInstance,
6019
+ updateNeonClient,
6020
+ updateNetlifyClient,
6021
+ updatePlanetScaleClient,
6022
+ updatePlatformAdapterClient,
6023
+ updateShopifyClient,
6024
+ updateVercelClient,
5983
6025
  vercelClientInstance
5984
6026
  });