@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.d.mts +402 -442
- package/dist/index.d.ts +402 -442
- package/dist/index.js +333 -291
- package/dist/index.mjs +310 -269
- package/package.json +6 -4
package/dist/index.mjs
CHANGED
|
@@ -92,31 +92,29 @@ githubClientInstance.interceptors.response.use(
|
|
|
92
92
|
);
|
|
93
93
|
function getGitHubClientAuthorization(req) {
|
|
94
94
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
oauth: req.headers["github-oauth-token"]
|
|
98
|
-
}
|
|
95
|
+
appToken: req.headers["github-app-token"],
|
|
96
|
+
oauthToken: req.headers["github-oauth-token"]
|
|
99
97
|
};
|
|
100
98
|
}
|
|
101
|
-
function
|
|
99
|
+
function getGithubClientConfig(options = {}) {
|
|
100
|
+
var _a;
|
|
102
101
|
const currentHeaders = githubClientInstance.defaults.headers;
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
102
|
+
const config = {
|
|
103
|
+
authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
106
104
|
};
|
|
107
|
-
if (options.ensureAuthorizationToken && !
|
|
105
|
+
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
108
106
|
throw new UnauthorizeApiError("github");
|
|
109
107
|
}
|
|
110
108
|
return {
|
|
111
|
-
headers: __spreadValues({},
|
|
109
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
112
110
|
};
|
|
113
111
|
}
|
|
114
|
-
function
|
|
112
|
+
function initGithubClient(token) {
|
|
115
113
|
if (token) {
|
|
116
|
-
|
|
114
|
+
updateGithubClient(token);
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
|
-
function
|
|
117
|
+
function updateGithubClient(token) {
|
|
120
118
|
const headers = githubClientInstance.defaults.headers;
|
|
121
119
|
if (token) {
|
|
122
120
|
headers.Authorization = `Bearer ${token}`;
|
|
@@ -137,11 +135,10 @@ var gitHubInstallationApi = {
|
|
|
137
135
|
},
|
|
138
136
|
getInstallations(authorization) {
|
|
139
137
|
return __async(this, null, function* () {
|
|
140
|
-
var _a;
|
|
141
138
|
const response = yield githubClientInstance.get(
|
|
142
139
|
`/user/installations?timestamp=${(/* @__PURE__ */ new Date()).getTime()}`,
|
|
143
|
-
|
|
144
|
-
token:
|
|
140
|
+
getGithubClientConfig({
|
|
141
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
145
142
|
ensureAuthorizationToken: true
|
|
146
143
|
})
|
|
147
144
|
);
|
|
@@ -150,11 +147,10 @@ var gitHubInstallationApi = {
|
|
|
150
147
|
},
|
|
151
148
|
getInstallationRepositories(installationId, authorization) {
|
|
152
149
|
return __async(this, null, function* () {
|
|
153
|
-
var _a;
|
|
154
150
|
const response = yield githubClientInstance.get(
|
|
155
151
|
`/user/installations/${installationId}/repositories?timestamp=${(/* @__PURE__ */ new Date()).getTime()}&per_page=100`,
|
|
156
|
-
|
|
157
|
-
token:
|
|
152
|
+
getGithubClientConfig({
|
|
153
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
158
154
|
ensureAuthorizationToken: true
|
|
159
155
|
})
|
|
160
156
|
);
|
|
@@ -168,11 +164,10 @@ import { AxiosError } from "axios";
|
|
|
168
164
|
var gitHubRepositoryApi = {
|
|
169
165
|
getRepository(repositoryName, authorization) {
|
|
170
166
|
return __async(this, null, function* () {
|
|
171
|
-
var _a;
|
|
172
167
|
const response = yield githubClientInstance.get(
|
|
173
168
|
`/repos/${repositoryName}`,
|
|
174
|
-
|
|
175
|
-
token:
|
|
169
|
+
getGithubClientConfig({
|
|
170
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
176
171
|
ensureAuthorizationToken: true
|
|
177
172
|
})
|
|
178
173
|
);
|
|
@@ -181,11 +176,10 @@ var gitHubRepositoryApi = {
|
|
|
181
176
|
},
|
|
182
177
|
getRepositoryBranches(repositoryName, authorization) {
|
|
183
178
|
return __async(this, null, function* () {
|
|
184
|
-
var _a;
|
|
185
179
|
const response = yield githubClientInstance.get(
|
|
186
180
|
`/repos/${repositoryName}/branches`,
|
|
187
|
-
|
|
188
|
-
token:
|
|
181
|
+
getGithubClientConfig({
|
|
182
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
189
183
|
ensureAuthorizationToken: true
|
|
190
184
|
})
|
|
191
185
|
);
|
|
@@ -194,11 +188,10 @@ var gitHubRepositoryApi = {
|
|
|
194
188
|
},
|
|
195
189
|
getRepositoryBranch(repositoryName, repositoryBranch, authorization) {
|
|
196
190
|
return __async(this, null, function* () {
|
|
197
|
-
var _a;
|
|
198
191
|
const response = yield githubClientInstance.get(
|
|
199
192
|
`/repos/${repositoryName}/branches`,
|
|
200
|
-
|
|
201
|
-
token:
|
|
193
|
+
getGithubClientConfig({
|
|
194
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
202
195
|
ensureAuthorizationToken: true
|
|
203
196
|
})
|
|
204
197
|
);
|
|
@@ -213,11 +206,10 @@ var gitHubRepositoryApi = {
|
|
|
213
206
|
},
|
|
214
207
|
getRepositorySeed(repositoryName, authorization) {
|
|
215
208
|
return __async(this, null, function* () {
|
|
216
|
-
var _a;
|
|
217
209
|
const { data } = yield githubClientInstance.get(
|
|
218
210
|
`/repos/${repositoryName}/contents/livechat.config.json`,
|
|
219
|
-
|
|
220
|
-
token:
|
|
211
|
+
getGithubClientConfig({
|
|
212
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
221
213
|
ensureAuthorizationToken: true
|
|
222
214
|
})
|
|
223
215
|
);
|
|
@@ -226,7 +218,6 @@ var gitHubRepositoryApi = {
|
|
|
226
218
|
},
|
|
227
219
|
createRepository(name, hasInstallation, template, authorization) {
|
|
228
220
|
return __async(this, null, function* () {
|
|
229
|
-
var _a, _b, _c, _d;
|
|
230
221
|
if (template || !hasInstallation) {
|
|
231
222
|
let repository;
|
|
232
223
|
if (template) {
|
|
@@ -238,8 +229,8 @@ var gitHubRepositoryApi = {
|
|
|
238
229
|
private: false,
|
|
239
230
|
include_all_branches: false
|
|
240
231
|
},
|
|
241
|
-
|
|
242
|
-
token:
|
|
232
|
+
getGithubClientConfig({
|
|
233
|
+
token: authorization == null ? void 0 : authorization.oauthToken,
|
|
243
234
|
ensureAuthorizationToken: true
|
|
244
235
|
})
|
|
245
236
|
);
|
|
@@ -254,8 +245,8 @@ var gitHubRepositoryApi = {
|
|
|
254
245
|
auto_init: true,
|
|
255
246
|
is_template: false
|
|
256
247
|
},
|
|
257
|
-
|
|
258
|
-
token:
|
|
248
|
+
getGithubClientConfig({
|
|
249
|
+
token: authorization == null ? void 0 : authorization.oauthToken,
|
|
259
250
|
ensureAuthorizationToken: true
|
|
260
251
|
})
|
|
261
252
|
);
|
|
@@ -266,8 +257,8 @@ var gitHubRepositoryApi = {
|
|
|
266
257
|
{
|
|
267
258
|
private: true
|
|
268
259
|
},
|
|
269
|
-
|
|
270
|
-
token:
|
|
260
|
+
getGithubClientConfig({
|
|
261
|
+
token: authorization == null ? void 0 : authorization.oauthToken,
|
|
271
262
|
ensureAuthorizationToken: true
|
|
272
263
|
})
|
|
273
264
|
);
|
|
@@ -282,8 +273,8 @@ var gitHubRepositoryApi = {
|
|
|
282
273
|
auto_init: true,
|
|
283
274
|
is_template: false
|
|
284
275
|
},
|
|
285
|
-
|
|
286
|
-
token:
|
|
276
|
+
getGithubClientConfig({
|
|
277
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
287
278
|
ensureAuthorizationToken: true
|
|
288
279
|
})
|
|
289
280
|
);
|
|
@@ -293,7 +284,6 @@ var gitHubRepositoryApi = {
|
|
|
293
284
|
seedRepository(repositoryName, manifest, isForLabs, authorization) {
|
|
294
285
|
return __async(this, null, function* () {
|
|
295
286
|
const upsert = (sha) => __async(this, null, function* () {
|
|
296
|
-
var _a;
|
|
297
287
|
const response = yield githubClientInstance.put(
|
|
298
288
|
`/repos/${repositoryName}/contents/livechat.config.json`,
|
|
299
289
|
{
|
|
@@ -309,8 +299,8 @@ var gitHubRepositoryApi = {
|
|
|
309
299
|
)
|
|
310
300
|
)
|
|
311
301
|
},
|
|
312
|
-
|
|
313
|
-
token:
|
|
302
|
+
getGithubClientConfig({
|
|
303
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
314
304
|
ensureAuthorizationToken: true
|
|
315
305
|
})
|
|
316
306
|
);
|
|
@@ -326,11 +316,10 @@ var gitHubRepositoryApi = {
|
|
|
326
316
|
},
|
|
327
317
|
deleteRepository(repositoryName, authorization) {
|
|
328
318
|
return __async(this, null, function* () {
|
|
329
|
-
var _a;
|
|
330
319
|
return githubClientInstance.delete(
|
|
331
320
|
`/repos/${repositoryName}`,
|
|
332
|
-
|
|
333
|
-
token:
|
|
321
|
+
getGithubClientConfig({
|
|
322
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
334
323
|
ensureAuthorizationToken: true
|
|
335
324
|
})
|
|
336
325
|
);
|
|
@@ -338,15 +327,14 @@ var gitHubRepositoryApi = {
|
|
|
338
327
|
},
|
|
339
328
|
createRepositoryDeployKey(repositoryName, deployKey, authorization) {
|
|
340
329
|
return __async(this, null, function* () {
|
|
341
|
-
var _a;
|
|
342
330
|
const response = yield githubClientInstance.post(
|
|
343
331
|
`/repos/${repositoryName}/keys`,
|
|
344
332
|
{
|
|
345
333
|
title: "developer-console-to-netlify",
|
|
346
334
|
key: deployKey
|
|
347
335
|
},
|
|
348
|
-
|
|
349
|
-
token:
|
|
336
|
+
getGithubClientConfig({
|
|
337
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
350
338
|
ensureAuthorizationToken: true
|
|
351
339
|
})
|
|
352
340
|
);
|
|
@@ -355,7 +343,6 @@ var gitHubRepositoryApi = {
|
|
|
355
343
|
},
|
|
356
344
|
createRepositoryBuildHook(repositoryName, authorization) {
|
|
357
345
|
return __async(this, null, function* () {
|
|
358
|
-
var _a;
|
|
359
346
|
try {
|
|
360
347
|
const response = yield githubClientInstance.post(
|
|
361
348
|
`/repos/${repositoryName}/hooks`,
|
|
@@ -376,8 +363,8 @@ var gitHubRepositoryApi = {
|
|
|
376
363
|
content_type: "json"
|
|
377
364
|
}
|
|
378
365
|
},
|
|
379
|
-
|
|
380
|
-
token:
|
|
366
|
+
getGithubClientConfig({
|
|
367
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
381
368
|
ensureAuthorizationToken: true
|
|
382
369
|
})
|
|
383
370
|
);
|
|
@@ -388,11 +375,10 @@ var gitHubRepositoryApi = {
|
|
|
388
375
|
},
|
|
389
376
|
getFile(path, repositoryName, authorization) {
|
|
390
377
|
return __async(this, null, function* () {
|
|
391
|
-
var _a;
|
|
392
378
|
const { data } = yield githubClientInstance.get(
|
|
393
379
|
`/repos/${repositoryName}/contents/${path}`,
|
|
394
|
-
|
|
395
|
-
token:
|
|
380
|
+
getGithubClientConfig({
|
|
381
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
396
382
|
ensureAuthorizationToken: true
|
|
397
383
|
})
|
|
398
384
|
);
|
|
@@ -401,11 +387,10 @@ var gitHubRepositoryApi = {
|
|
|
401
387
|
},
|
|
402
388
|
getCommits(repositoryName, authorization) {
|
|
403
389
|
return __async(this, null, function* () {
|
|
404
|
-
var _a;
|
|
405
390
|
const { data: commits } = yield githubClientInstance.get(
|
|
406
391
|
`/repos/${repositoryName}/commits`,
|
|
407
|
-
|
|
408
|
-
token:
|
|
392
|
+
getGithubClientConfig({
|
|
393
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
409
394
|
ensureAuthorizationToken: true
|
|
410
395
|
})
|
|
411
396
|
);
|
|
@@ -414,7 +399,6 @@ var gitHubRepositoryApi = {
|
|
|
414
399
|
},
|
|
415
400
|
commitFiles(data, authorization) {
|
|
416
401
|
return __async(this, null, function* () {
|
|
417
|
-
var _a, _b, _c, _d, _e;
|
|
418
402
|
const MODES = { FILE: "100644", FOLDER: "040000" };
|
|
419
403
|
const TYPE = { BLOB: "blob", TREE: "tree" };
|
|
420
404
|
const {
|
|
@@ -423,8 +407,8 @@ var gitHubRepositoryApi = {
|
|
|
423
407
|
}
|
|
424
408
|
} = yield githubClientInstance.get(
|
|
425
409
|
`/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
|
|
426
|
-
|
|
427
|
-
token:
|
|
410
|
+
getGithubClientConfig({
|
|
411
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
428
412
|
ensureAuthorizationToken: true
|
|
429
413
|
})
|
|
430
414
|
);
|
|
@@ -434,8 +418,8 @@ var gitHubRepositoryApi = {
|
|
|
434
418
|
}
|
|
435
419
|
} = yield githubClientInstance.get(
|
|
436
420
|
`/repos/${data.repositoryName}/git/commits/${currentCommitSha}`,
|
|
437
|
-
|
|
438
|
-
token:
|
|
421
|
+
getGithubClientConfig({
|
|
422
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
439
423
|
ensureAuthorizationToken: true
|
|
440
424
|
})
|
|
441
425
|
);
|
|
@@ -450,8 +434,8 @@ var gitHubRepositoryApi = {
|
|
|
450
434
|
// If sha is null => the file gets deleted
|
|
451
435
|
)
|
|
452
436
|
},
|
|
453
|
-
|
|
454
|
-
token:
|
|
437
|
+
getGithubClientConfig({
|
|
438
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
455
439
|
ensureAuthorizationToken: true
|
|
456
440
|
})
|
|
457
441
|
);
|
|
@@ -464,16 +448,16 @@ var gitHubRepositoryApi = {
|
|
|
464
448
|
tree: newTreeSha,
|
|
465
449
|
parents: [currentCommitSha]
|
|
466
450
|
},
|
|
467
|
-
|
|
468
|
-
token:
|
|
451
|
+
getGithubClientConfig({
|
|
452
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
469
453
|
ensureAuthorizationToken: true
|
|
470
454
|
})
|
|
471
455
|
);
|
|
472
456
|
yield githubClientInstance.post(
|
|
473
457
|
`/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
|
|
474
458
|
{ sha: newCommitSha },
|
|
475
|
-
|
|
476
|
-
token:
|
|
459
|
+
getGithubClientConfig({
|
|
460
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
477
461
|
ensureAuthorizationToken: true
|
|
478
462
|
})
|
|
479
463
|
);
|
|
@@ -497,9 +481,15 @@ var gitHubRepositoryApi = {
|
|
|
497
481
|
|
|
498
482
|
// src/apis/integrations/github/user/api.ts
|
|
499
483
|
var gitHubUserApi = {
|
|
500
|
-
getUser() {
|
|
484
|
+
getUser(authorization) {
|
|
501
485
|
return __async(this, null, function* () {
|
|
502
|
-
const { data: user } = yield githubClientInstance.get(
|
|
486
|
+
const { data: user } = yield githubClientInstance.get(
|
|
487
|
+
`/user`,
|
|
488
|
+
getGithubClientConfig({
|
|
489
|
+
token: authorization == null ? void 0 : authorization.appToken,
|
|
490
|
+
ensureAuthorizationToken: true
|
|
491
|
+
})
|
|
492
|
+
);
|
|
503
493
|
return user;
|
|
504
494
|
});
|
|
505
495
|
}
|
|
@@ -563,24 +553,24 @@ function getNetlifyClientAuthorization(req) {
|
|
|
563
553
|
};
|
|
564
554
|
}
|
|
565
555
|
function getNetlifyClientConfig(options = {}) {
|
|
556
|
+
var _a;
|
|
566
557
|
const currentHeaders = netlifyClientInstance.defaults.headers;
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
558
|
+
const config = {
|
|
559
|
+
authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
570
560
|
};
|
|
571
|
-
if (options.ensureAuthorizationToken && !
|
|
561
|
+
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
572
562
|
throw new UnauthorizeApiError("netlify");
|
|
573
563
|
}
|
|
574
564
|
return {
|
|
575
|
-
headers: __spreadValues({},
|
|
565
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
576
566
|
};
|
|
577
567
|
}
|
|
578
|
-
function
|
|
568
|
+
function initNetlifyClient(token) {
|
|
579
569
|
if (token) {
|
|
580
|
-
|
|
570
|
+
updateNetlifyClient(token);
|
|
581
571
|
}
|
|
582
572
|
}
|
|
583
|
-
function
|
|
573
|
+
function updateNetlifyClient(token) {
|
|
584
574
|
const headers = netlifyClientInstance.defaults.headers;
|
|
585
575
|
if (token) {
|
|
586
576
|
headers.Authorization = `Bearer ${token}`;
|
|
@@ -999,7 +989,10 @@ import axios5 from "axios";
|
|
|
999
989
|
// src/apis/integrations/planetscale/instance.ts
|
|
1000
990
|
import axios4 from "axios";
|
|
1001
991
|
var planetScaleClientInstance = axios4.create({
|
|
1002
|
-
baseURL: "https://api.planetscale.com"
|
|
992
|
+
baseURL: "https://api.planetscale.com",
|
|
993
|
+
headers: {
|
|
994
|
+
"Content-Type": "application/json"
|
|
995
|
+
}
|
|
1003
996
|
});
|
|
1004
997
|
planetScaleClientInstance.interceptors.response.use(
|
|
1005
998
|
(r) => r,
|
|
@@ -1019,24 +1012,24 @@ function getPlanetScaleClientAuthorization(req) {
|
|
|
1019
1012
|
};
|
|
1020
1013
|
}
|
|
1021
1014
|
function getPlanetScaleClientConfig(options = {}) {
|
|
1015
|
+
var _a;
|
|
1022
1016
|
const currentHeaders = planetScaleClientInstance.defaults.headers;
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `${options.token}` : void 0
|
|
1017
|
+
const config = {
|
|
1018
|
+
authorization: (_a = options.token ? `${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
1026
1019
|
};
|
|
1027
|
-
if (options.ensureAuthorizationToken && !
|
|
1020
|
+
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
1028
1021
|
throw new UnauthorizeApiError("planetscale");
|
|
1029
1022
|
}
|
|
1030
1023
|
return {
|
|
1031
|
-
headers: __spreadValues({},
|
|
1024
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
1032
1025
|
};
|
|
1033
1026
|
}
|
|
1034
|
-
function
|
|
1027
|
+
function initPlanetScaleClient(token) {
|
|
1035
1028
|
if (token) {
|
|
1036
|
-
|
|
1029
|
+
updatePlanetScaleClient(token);
|
|
1037
1030
|
}
|
|
1038
1031
|
}
|
|
1039
|
-
function
|
|
1032
|
+
function updatePlanetScaleClient(token) {
|
|
1040
1033
|
const headers = planetScaleClientInstance.defaults.headers;
|
|
1041
1034
|
if (token) {
|
|
1042
1035
|
headers.Authorization = `${token}`;
|
|
@@ -1227,21 +1220,21 @@ var textClientInstance = axios6.create({
|
|
|
1227
1220
|
});
|
|
1228
1221
|
function getTextClientAuthorization(req) {
|
|
1229
1222
|
return {
|
|
1230
|
-
token: req.headers["
|
|
1223
|
+
token: req.headers["platform-token"],
|
|
1231
1224
|
tokenType: "Bearer"
|
|
1232
1225
|
};
|
|
1233
1226
|
}
|
|
1234
1227
|
function getTextClientConfig(option = {}) {
|
|
1228
|
+
var _a;
|
|
1235
1229
|
const currentHeaders = textClientInstance.defaults.headers;
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1238
|
-
authorization: defaultAuthorization != null ? defaultAuthorization : option.token ? `Bearer ${option.token}` : void 0
|
|
1230
|
+
const config = {
|
|
1231
|
+
authorization: (_a = option.token ? `Bearer ${option.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
1239
1232
|
};
|
|
1240
1233
|
return {
|
|
1241
|
-
headers: __spreadValues({},
|
|
1234
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
1242
1235
|
};
|
|
1243
1236
|
}
|
|
1244
|
-
function
|
|
1237
|
+
function initTextClient(baseUrl, token) {
|
|
1245
1238
|
const headers = textClientInstance.defaults.headers;
|
|
1246
1239
|
if (baseUrl) {
|
|
1247
1240
|
textClientInstance.interceptors.request.use(
|
|
@@ -1650,24 +1643,24 @@ function getVercelClientAuthorization(req) {
|
|
|
1650
1643
|
};
|
|
1651
1644
|
}
|
|
1652
1645
|
function getVercelClientConfig(options = {}) {
|
|
1646
|
+
var _a;
|
|
1653
1647
|
const currentHeaders = vercelClientInstance.defaults.headers;
|
|
1654
|
-
const
|
|
1655
|
-
|
|
1656
|
-
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
1648
|
+
const config = {
|
|
1649
|
+
authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
1657
1650
|
};
|
|
1658
|
-
if (options.ensureAuthorizationToken && !
|
|
1651
|
+
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
1659
1652
|
throw new UnauthorizeApiError("vercel");
|
|
1660
1653
|
}
|
|
1661
1654
|
return {
|
|
1662
|
-
headers: __spreadValues({},
|
|
1655
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
1663
1656
|
};
|
|
1664
1657
|
}
|
|
1665
|
-
function
|
|
1658
|
+
function initVercelClient(token) {
|
|
1666
1659
|
if (token) {
|
|
1667
|
-
|
|
1660
|
+
updateVercelClient(token);
|
|
1668
1661
|
}
|
|
1669
1662
|
}
|
|
1670
|
-
function
|
|
1663
|
+
function updateVercelClient(token) {
|
|
1671
1664
|
const headers = vercelClientInstance.defaults.headers;
|
|
1672
1665
|
if (token) {
|
|
1673
1666
|
headers.Authorization = `Bearer ${token}`;
|
|
@@ -1946,7 +1939,10 @@ import axios10 from "axios";
|
|
|
1946
1939
|
// src/apis/integrations/neon/instance.ts
|
|
1947
1940
|
import axios9 from "axios";
|
|
1948
1941
|
var neonClientInstance = axios9.create({
|
|
1949
|
-
baseURL: "https://console.neon.tech/api/v2
|
|
1942
|
+
baseURL: "https://console.neon.tech/api/v2",
|
|
1943
|
+
headers: {
|
|
1944
|
+
"Content-Type": "application/json"
|
|
1945
|
+
}
|
|
1950
1946
|
});
|
|
1951
1947
|
neonClientInstance.interceptors.response.use(
|
|
1952
1948
|
(r) => r,
|
|
@@ -1966,24 +1962,24 @@ function getNeonClientAuthorization(req) {
|
|
|
1966
1962
|
};
|
|
1967
1963
|
}
|
|
1968
1964
|
function getNeonClientConfig(options = {}) {
|
|
1965
|
+
var _a;
|
|
1969
1966
|
const currentHeaders = neonClientInstance.defaults.headers;
|
|
1970
|
-
const
|
|
1971
|
-
|
|
1972
|
-
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
1967
|
+
const config = {
|
|
1968
|
+
authorization: (_a = options.token ? `Bearer ${options.token}` : void 0) != null ? _a : currentHeaders.Authorization
|
|
1973
1969
|
};
|
|
1974
|
-
if (options.ensureAuthorizationToken && !
|
|
1970
|
+
if (options.ensureAuthorizationToken && !config.authorization) {
|
|
1975
1971
|
throw new UnauthorizeApiError("neon");
|
|
1976
1972
|
}
|
|
1977
1973
|
return {
|
|
1978
|
-
headers: __spreadValues({},
|
|
1974
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
1979
1975
|
};
|
|
1980
1976
|
}
|
|
1981
|
-
function
|
|
1977
|
+
function initNeonClient(token) {
|
|
1982
1978
|
if (token) {
|
|
1983
|
-
|
|
1979
|
+
updateNeonClient(token);
|
|
1984
1980
|
}
|
|
1985
1981
|
}
|
|
1986
|
-
function
|
|
1982
|
+
function updateNeonClient(token) {
|
|
1987
1983
|
const headers = neonClientInstance.defaults.headers;
|
|
1988
1984
|
if (token) {
|
|
1989
1985
|
headers.Authorization = `Bearer ${token}`;
|
|
@@ -2266,7 +2262,7 @@ var mailchimpApi = {
|
|
|
2266
2262
|
redirect_uri: redirectUri,
|
|
2267
2263
|
grant_type: "authorization_code"
|
|
2268
2264
|
});
|
|
2269
|
-
const
|
|
2265
|
+
const tokenResponse = yield axios11.post(
|
|
2270
2266
|
"https://login.mailchimp.com/oauth2/token",
|
|
2271
2267
|
data,
|
|
2272
2268
|
{
|
|
@@ -2275,11 +2271,31 @@ var mailchimpApi = {
|
|
|
2275
2271
|
}
|
|
2276
2272
|
}
|
|
2277
2273
|
);
|
|
2278
|
-
const params = new URLSearchParams(
|
|
2274
|
+
const params = new URLSearchParams(
|
|
2275
|
+
tokenResponse.data
|
|
2276
|
+
);
|
|
2279
2277
|
return {
|
|
2280
2278
|
token: (_a = params.get("access_token")) != null ? _a : ""
|
|
2281
2279
|
};
|
|
2282
2280
|
});
|
|
2281
|
+
},
|
|
2282
|
+
getMetadata(_0) {
|
|
2283
|
+
return __async(this, arguments, function* ({ token }) {
|
|
2284
|
+
const {
|
|
2285
|
+
data: { dc: server }
|
|
2286
|
+
} = yield axios11.get(
|
|
2287
|
+
"https://login.mailchimp.com/oauth2/metadata",
|
|
2288
|
+
{
|
|
2289
|
+
headers: {
|
|
2290
|
+
"Content-Type": "application/json",
|
|
2291
|
+
Authorization: `OAuth ${token}`
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
);
|
|
2295
|
+
return {
|
|
2296
|
+
server
|
|
2297
|
+
};
|
|
2298
|
+
});
|
|
2283
2299
|
}
|
|
2284
2300
|
};
|
|
2285
2301
|
|
|
@@ -2345,7 +2361,7 @@ var livechatClientInstance = axios13.create({
|
|
|
2345
2361
|
});
|
|
2346
2362
|
function getLiveChatClientAuthorization(req) {
|
|
2347
2363
|
return {
|
|
2348
|
-
token: req.headers["
|
|
2364
|
+
token: req.headers["platform-token"]
|
|
2349
2365
|
};
|
|
2350
2366
|
}
|
|
2351
2367
|
function getLiveChatClientConfig(options = {}) {
|
|
@@ -2359,7 +2375,7 @@ function getLiveChatClientConfig(options = {}) {
|
|
|
2359
2375
|
headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
|
|
2360
2376
|
};
|
|
2361
2377
|
}
|
|
2362
|
-
function
|
|
2378
|
+
function initLiveChatClient(baseUrl, token) {
|
|
2363
2379
|
const region = token ? getRegion(token) : void 0;
|
|
2364
2380
|
const headers = livechatClientInstance.defaults.headers;
|
|
2365
2381
|
if (baseUrl) {
|
|
@@ -2887,7 +2903,7 @@ platformAccountsClientInstance.interceptors.response.use(
|
|
|
2887
2903
|
);
|
|
2888
2904
|
function getPlatformAccountsClientAuthorization(req) {
|
|
2889
2905
|
return {
|
|
2890
|
-
token: req.headers["platform-
|
|
2906
|
+
token: req.headers["platform-token"]
|
|
2891
2907
|
};
|
|
2892
2908
|
}
|
|
2893
2909
|
function getPlatformAccountsClientConfig(options = {}) {
|
|
@@ -2900,7 +2916,7 @@ function getPlatformAccountsClientConfig(options = {}) {
|
|
|
2900
2916
|
headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
|
|
2901
2917
|
};
|
|
2902
2918
|
}
|
|
2903
|
-
function
|
|
2919
|
+
function initPlatformAccountsClient(baseUrl, token) {
|
|
2904
2920
|
if (baseUrl) {
|
|
2905
2921
|
platformAccountsClientInstance.interceptors.request.use(
|
|
2906
2922
|
(config) => {
|
|
@@ -3223,9 +3239,8 @@ platformDpsClientInstance.interceptors.response.use(
|
|
|
3223
3239
|
}
|
|
3224
3240
|
);
|
|
3225
3241
|
function getPlatformDpsClientAuthorization(req) {
|
|
3226
|
-
var _a;
|
|
3227
3242
|
return {
|
|
3228
|
-
token:
|
|
3243
|
+
token: req.headers["platform-token"],
|
|
3229
3244
|
tokenType: "Bearer"
|
|
3230
3245
|
};
|
|
3231
3246
|
}
|
|
@@ -3247,7 +3262,7 @@ function getPlatformDpsClientConfig(options = {}) {
|
|
|
3247
3262
|
headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
|
|
3248
3263
|
};
|
|
3249
3264
|
}
|
|
3250
|
-
function
|
|
3265
|
+
function initPlatformDpsClient(baseUrl, token) {
|
|
3251
3266
|
const headers = platformDpsClientInstance.defaults.headers;
|
|
3252
3267
|
if (baseUrl) {
|
|
3253
3268
|
platformDpsClientInstance.interceptors.request.use(
|
|
@@ -4783,24 +4798,6 @@ var AdapterApiError = class extends ApiErrorBase {
|
|
|
4783
4798
|
this.name = "adapter";
|
|
4784
4799
|
}
|
|
4785
4800
|
};
|
|
4786
|
-
function getPlatformAdapterClientAuthorization(req) {
|
|
4787
|
-
return {
|
|
4788
|
-
platform: {
|
|
4789
|
-
dps: req.headers["platform-dps-token"]
|
|
4790
|
-
},
|
|
4791
|
-
github: {
|
|
4792
|
-
app: req.headers["github-app-token"],
|
|
4793
|
-
oauth: req.headers["github-oauth-token"]
|
|
4794
|
-
},
|
|
4795
|
-
netlify: req.headers["netlify-token"],
|
|
4796
|
-
vercel: req.headers["vercel-token"],
|
|
4797
|
-
planetscale: req.headers["planetscale-token"],
|
|
4798
|
-
neon: req.headers["neon-token"],
|
|
4799
|
-
mailchimp: req.headers["mailchimp-token"],
|
|
4800
|
-
shopify: req.headers["shopify-token"],
|
|
4801
|
-
openai: req.headers["openai-token"]
|
|
4802
|
-
};
|
|
4803
|
-
}
|
|
4804
4801
|
var platformAdapterClientInstance = axios16.create({
|
|
4805
4802
|
baseURL: "https://platform.labs.text.com/console-adapter/api",
|
|
4806
4803
|
headers: {
|
|
@@ -4823,69 +4820,96 @@ platformAdapterClientInstance.interceptors.response.use(
|
|
|
4823
4820
|
return Promise.reject(error);
|
|
4824
4821
|
}
|
|
4825
4822
|
);
|
|
4823
|
+
function getPlatformAdapterClientAuthorization(req) {
|
|
4824
|
+
return {
|
|
4825
|
+
platform: {
|
|
4826
|
+
token: req.headers["platform-token"]
|
|
4827
|
+
},
|
|
4828
|
+
github: {
|
|
4829
|
+
appToken: req.headers["github-app-token"],
|
|
4830
|
+
oauthToken: req.headers["github-oauth-token"]
|
|
4831
|
+
},
|
|
4832
|
+
netlify: {
|
|
4833
|
+
token: req.headers["netlify-token"]
|
|
4834
|
+
},
|
|
4835
|
+
vercel: {
|
|
4836
|
+
token: req.headers["vercel-token"]
|
|
4837
|
+
},
|
|
4838
|
+
planetscale: {
|
|
4839
|
+
token: req.headers["planetscale-token"]
|
|
4840
|
+
},
|
|
4841
|
+
neon: {
|
|
4842
|
+
token: req.headers["neon-token"]
|
|
4843
|
+
},
|
|
4844
|
+
mailchimp: {
|
|
4845
|
+
token: req.headers["mailchimp-token"],
|
|
4846
|
+
server: req.headers["mailchimp-server"]
|
|
4847
|
+
},
|
|
4848
|
+
shopify: {
|
|
4849
|
+
token: req.headers["shopify-token"],
|
|
4850
|
+
shop: req.headers["shopify-shop"]
|
|
4851
|
+
}
|
|
4852
|
+
};
|
|
4853
|
+
}
|
|
4826
4854
|
function getPlatformAdapterClientConfig(options = {}) {
|
|
4827
|
-
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;
|
|
4855
|
+
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;
|
|
4828
4856
|
const currentHeaders = platformAdapterClientInstance.defaults.headers;
|
|
4829
4857
|
const headers = {
|
|
4830
4858
|
platform: {
|
|
4831
|
-
|
|
4859
|
+
token: (_b = currentHeaders["platform-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.token
|
|
4832
4860
|
},
|
|
4833
4861
|
integrations: {
|
|
4834
4862
|
github: {
|
|
4835
|
-
app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.
|
|
4836
|
-
oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.
|
|
4863
|
+
app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.appToken,
|
|
4864
|
+
oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauthToken
|
|
4837
4865
|
},
|
|
4838
|
-
netlify: (
|
|
4839
|
-
vercel: (
|
|
4840
|
-
planetscale: (
|
|
4841
|
-
neon: (
|
|
4842
|
-
mailchimp: (
|
|
4843
|
-
|
|
4844
|
-
|
|
4866
|
+
netlify: (_h = currentHeaders["netlify-token"]) != null ? _h : (_g = options.netlify) == null ? void 0 : _g.token,
|
|
4867
|
+
vercel: (_j = currentHeaders["vercel-token"]) != null ? _j : (_i = options.vercel) == null ? void 0 : _i.token,
|
|
4868
|
+
planetscale: (_l = currentHeaders["planetscale-token"]) != null ? _l : (_k = options.planetscale) == null ? void 0 : _k.token,
|
|
4869
|
+
neon: (_n = currentHeaders["neon-token"]) != null ? _n : (_m = options.neon) == null ? void 0 : _m.token,
|
|
4870
|
+
mailchimp: (_p = currentHeaders["mailchimp-token"]) != null ? _p : (_o = options.mailchimp) == null ? void 0 : _o.token,
|
|
4871
|
+
mailchimpServer: (_r = currentHeaders["mailchimp-server"]) != null ? _r : (_q = options.mailchimp) == null ? void 0 : _q.server,
|
|
4872
|
+
shopify: (_t = currentHeaders["shopify-token"]) != null ? _t : (_s = options.shopify) == null ? void 0 : _s.token,
|
|
4873
|
+
shopifyShop: (_v = currentHeaders["shopify-shop"]) != null ? _v : (_u = options.shopify) == null ? void 0 : _u.shop
|
|
4845
4874
|
}
|
|
4846
4875
|
};
|
|
4847
|
-
if (currentHeaders["platform-
|
|
4848
|
-
currentHeaders["X-Region"] = (
|
|
4876
|
+
if (currentHeaders["platform-token"]) {
|
|
4877
|
+
currentHeaders["X-Region"] = (_w = getRegion2(currentHeaders["platform-token"])) != null ? _w : void 0;
|
|
4849
4878
|
}
|
|
4850
|
-
if (((
|
|
4879
|
+
if (((_x = options.ensureAuthorizationToken) == null ? void 0 : _x.platform) && !headers.platform.token) {
|
|
4851
4880
|
throw new UnauthorizeApiError("accounts");
|
|
4852
4881
|
}
|
|
4853
|
-
if (((
|
|
4882
|
+
if (((_y = options.ensureAuthorizationToken) == null ? void 0 : _y.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
|
|
4854
4883
|
throw new UnauthorizeApiError("github");
|
|
4855
4884
|
}
|
|
4856
|
-
if (((
|
|
4885
|
+
if (((_z = options.ensureAuthorizationToken) == null ? void 0 : _z.vercel) && !headers.integrations.vercel) {
|
|
4857
4886
|
throw new UnauthorizeApiError("vercel");
|
|
4858
4887
|
}
|
|
4859
|
-
if (((
|
|
4888
|
+
if (((_A = options.ensureAuthorizationToken) == null ? void 0 : _A.netlify) && !headers.integrations.netlify) {
|
|
4860
4889
|
throw new UnauthorizeApiError("netlify");
|
|
4861
4890
|
}
|
|
4862
|
-
if (((
|
|
4891
|
+
if (((_B = options.ensureAuthorizationToken) == null ? void 0 : _B.planetscale) && !headers.integrations.planetscale) {
|
|
4863
4892
|
throw new UnauthorizeApiError("planetscale");
|
|
4864
4893
|
}
|
|
4865
|
-
if (((
|
|
4894
|
+
if (((_C = options.ensureAuthorizationToken) == null ? void 0 : _C.neon) && !headers.integrations.neon) {
|
|
4866
4895
|
throw new UnauthorizeApiError("neon");
|
|
4867
4896
|
}
|
|
4868
|
-
if (((
|
|
4897
|
+
if (((_D = options.ensureAuthorizationToken) == null ? void 0 : _D.mailchimp) && (!headers.integrations.mailchimp || !headers.integrations.mailchimpServer)) {
|
|
4869
4898
|
throw new UnauthorizeApiError("mailchimp");
|
|
4870
4899
|
}
|
|
4871
|
-
if (((
|
|
4900
|
+
if (((_E = options.ensureAuthorizationToken) == null ? void 0 : _E.shopify) && (!headers.integrations.shopify || !headers.integrations.shopifyShop)) {
|
|
4872
4901
|
throw new UnauthorizeApiError("shopify");
|
|
4873
4902
|
}
|
|
4874
|
-
if (((_x = options.ensureAuthorizationToken) == null ? void 0 : _x.openai) && !headers.integrations.openai) {
|
|
4875
|
-
throw new UnauthorizeApiError("openai");
|
|
4876
|
-
}
|
|
4877
4903
|
return {
|
|
4878
|
-
headers: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, headers.platform.
|
|
4904
|
+
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 } : {})
|
|
4879
4905
|
};
|
|
4880
4906
|
}
|
|
4881
4907
|
var getPlatformAdapterClientDefaultConfig = (authorization) => getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
4882
4908
|
ensureAuthorizationToken: {
|
|
4883
|
-
platform:
|
|
4884
|
-
dps: true
|
|
4885
|
-
}
|
|
4909
|
+
platform: true
|
|
4886
4910
|
}
|
|
4887
4911
|
}));
|
|
4888
|
-
function
|
|
4912
|
+
function initPlatformAdapterClient(baseUrl, tokens) {
|
|
4889
4913
|
if (baseUrl) {
|
|
4890
4914
|
platformAdapterClientInstance.interceptors.request.use(
|
|
4891
4915
|
(config) => {
|
|
@@ -4896,41 +4920,44 @@ function initPlatformAdapterClientInstance(baseUrl, tokens) {
|
|
|
4896
4920
|
);
|
|
4897
4921
|
}
|
|
4898
4922
|
if (tokens) {
|
|
4899
|
-
|
|
4923
|
+
updatePlatformAdapterClient(tokens);
|
|
4900
4924
|
}
|
|
4901
4925
|
}
|
|
4902
|
-
function
|
|
4903
|
-
var _a, _b, _c;
|
|
4926
|
+
function updatePlatformAdapterClient(tokens) {
|
|
4927
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4904
4928
|
const headers = platformAdapterClientInstance.defaults.headers;
|
|
4905
|
-
if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.
|
|
4906
|
-
headers["platform-
|
|
4929
|
+
if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.token) {
|
|
4930
|
+
headers["platform-token"] = tokens.platform.token;
|
|
4931
|
+
}
|
|
4932
|
+
if ((_b = tokens == null ? void 0 : tokens.github) == null ? void 0 : _b.appToken) {
|
|
4933
|
+
headers["github-app-token"] = tokens.github.appToken;
|
|
4907
4934
|
}
|
|
4908
|
-
if ((
|
|
4909
|
-
headers["github-
|
|
4935
|
+
if ((_c = tokens == null ? void 0 : tokens.github) == null ? void 0 : _c.oauthToken) {
|
|
4936
|
+
headers["github-oauth-token"] = tokens.github.oauthToken;
|
|
4910
4937
|
}
|
|
4911
|
-
if ((
|
|
4912
|
-
headers["
|
|
4938
|
+
if ((_d = tokens == null ? void 0 : tokens.netlify) == null ? void 0 : _d.token) {
|
|
4939
|
+
headers["netlify-token"] = tokens.netlify.token;
|
|
4913
4940
|
}
|
|
4914
|
-
if (tokens == null ? void 0 : tokens.
|
|
4915
|
-
headers["
|
|
4941
|
+
if ((_e = tokens == null ? void 0 : tokens.vercel) == null ? void 0 : _e.token) {
|
|
4942
|
+
headers["vercel-token"] = tokens.vercel.token;
|
|
4916
4943
|
}
|
|
4917
|
-
if (tokens == null ? void 0 : tokens.
|
|
4918
|
-
headers["
|
|
4944
|
+
if ((_f = tokens == null ? void 0 : tokens.planetscale) == null ? void 0 : _f.token) {
|
|
4945
|
+
headers["planetscale-token"] = tokens.planetscale.token;
|
|
4919
4946
|
}
|
|
4920
|
-
if (tokens == null ? void 0 : tokens.
|
|
4921
|
-
headers["
|
|
4947
|
+
if ((_g = tokens == null ? void 0 : tokens.neon) == null ? void 0 : _g.token) {
|
|
4948
|
+
headers["neon-token"] = tokens.neon.token;
|
|
4922
4949
|
}
|
|
4923
|
-
if (tokens == null ? void 0 : tokens.
|
|
4924
|
-
headers["
|
|
4950
|
+
if ((_h = tokens == null ? void 0 : tokens.mailchimp) == null ? void 0 : _h.server) {
|
|
4951
|
+
headers["mailchimp-server"] = tokens.mailchimp.server;
|
|
4925
4952
|
}
|
|
4926
|
-
if (tokens == null ? void 0 : tokens.mailchimp) {
|
|
4927
|
-
headers["mailchimp-token"] = tokens.mailchimp;
|
|
4953
|
+
if ((_i = tokens == null ? void 0 : tokens.mailchimp) == null ? void 0 : _i.token) {
|
|
4954
|
+
headers["mailchimp-token"] = tokens.mailchimp.token;
|
|
4928
4955
|
}
|
|
4929
|
-
if (tokens == null ? void 0 : tokens.shopify) {
|
|
4930
|
-
headers["shopify-
|
|
4956
|
+
if ((_j = tokens == null ? void 0 : tokens.shopify) == null ? void 0 : _j.shop) {
|
|
4957
|
+
headers["shopify-shop"] = tokens.shopify.shop;
|
|
4931
4958
|
}
|
|
4932
|
-
if (tokens == null ? void 0 : tokens.
|
|
4933
|
-
headers["
|
|
4959
|
+
if ((_k = tokens == null ? void 0 : tokens.shopify) == null ? void 0 : _k.token) {
|
|
4960
|
+
headers["shopify-token"] = tokens.shopify.token;
|
|
4934
4961
|
}
|
|
4935
4962
|
}
|
|
4936
4963
|
|
|
@@ -5424,8 +5451,11 @@ var platformAdapterConductorApi = {
|
|
|
5424
5451
|
|
|
5425
5452
|
// src/apis/integrations/mailchimp/instance.ts
|
|
5426
5453
|
import axios17 from "axios";
|
|
5454
|
+
var getMailchimpClientUrl = (server) => `https://${server}.api.mailchimp.com/3.0`;
|
|
5427
5455
|
var mailchimpClientInstance = axios17.create({
|
|
5428
|
-
|
|
5456
|
+
headers: {
|
|
5457
|
+
"Content-Type": "application/json"
|
|
5458
|
+
}
|
|
5429
5459
|
});
|
|
5430
5460
|
mailchimpClientInstance.interceptors.response.use(
|
|
5431
5461
|
(r) => r,
|
|
@@ -5441,42 +5471,48 @@ mailchimpClientInstance.interceptors.response.use(
|
|
|
5441
5471
|
);
|
|
5442
5472
|
function getMailchimpClientAuthorization(req) {
|
|
5443
5473
|
return {
|
|
5474
|
+
server: req.headers["mailchimp-server"],
|
|
5444
5475
|
token: req.headers["mailchimp-token"]
|
|
5445
5476
|
};
|
|
5446
5477
|
}
|
|
5447
5478
|
function getMailchimpClientConfig(options = {}) {
|
|
5479
|
+
var _a, _b;
|
|
5480
|
+
const currentBaseUrl = mailchimpClientInstance.defaults.baseURL;
|
|
5448
5481
|
const currentHeaders = mailchimpClientInstance.defaults.headers;
|
|
5449
|
-
const
|
|
5450
|
-
|
|
5451
|
-
authorization:
|
|
5482
|
+
const config = {
|
|
5483
|
+
baseUrl: (_a = options.server ? getMailchimpClientUrl(options.server) : void 0) != null ? _a : currentBaseUrl,
|
|
5484
|
+
authorization: (_b = options.token ? `Bearer ${options.token}` : void 0) != null ? _b : currentHeaders.Authorization
|
|
5452
5485
|
};
|
|
5453
|
-
if (options.ensureAuthorizationToken && !
|
|
5486
|
+
if (options.ensureAuthorizationToken && (!config.authorization || !config.baseUrl)) {
|
|
5454
5487
|
throw new UnauthorizeApiError("mailchimp");
|
|
5455
5488
|
}
|
|
5456
5489
|
return {
|
|
5457
|
-
headers: __spreadValues({},
|
|
5490
|
+
headers: __spreadValues({}, config.authorization ? { Authorization: config.authorization } : {})
|
|
5458
5491
|
};
|
|
5459
5492
|
}
|
|
5460
|
-
function
|
|
5461
|
-
if (token) {
|
|
5493
|
+
function initMailchimpClient(token, server) {
|
|
5494
|
+
if (token && server) {
|
|
5462
5495
|
updateMailchimpClientInstance(token);
|
|
5463
5496
|
}
|
|
5464
5497
|
}
|
|
5465
|
-
function updateMailchimpClientInstance(token) {
|
|
5466
|
-
const
|
|
5498
|
+
function updateMailchimpClientInstance(token, server) {
|
|
5499
|
+
const defaults = mailchimpClientInstance.defaults;
|
|
5500
|
+
const headers = defaults.headers;
|
|
5467
5501
|
if (token) {
|
|
5468
5502
|
headers.Authorization = `Bearer ${token}`;
|
|
5469
5503
|
} else {
|
|
5470
5504
|
delete headers.Authorization;
|
|
5471
5505
|
}
|
|
5506
|
+
if (server) {
|
|
5507
|
+
defaults.baseURL = getMailchimpClientUrl(server);
|
|
5508
|
+
} else {
|
|
5509
|
+
delete defaults.baseURL;
|
|
5510
|
+
}
|
|
5472
5511
|
}
|
|
5473
5512
|
|
|
5474
5513
|
// src/apis/integrations/shopify/instance.ts
|
|
5475
5514
|
import axios18 from "axios";
|
|
5476
|
-
var
|
|
5477
|
-
var shopifyClientInstance = axios18.create({
|
|
5478
|
-
baseURL: "https://myshopify.com/admin/api"
|
|
5479
|
-
});
|
|
5515
|
+
var shopifyClientInstance = axios18.create();
|
|
5480
5516
|
shopifyClientInstance.interceptors.response.use(
|
|
5481
5517
|
(r) => r,
|
|
5482
5518
|
(error) => {
|
|
@@ -5489,36 +5525,47 @@ shopifyClientInstance.interceptors.response.use(
|
|
|
5489
5525
|
throw error;
|
|
5490
5526
|
}
|
|
5491
5527
|
);
|
|
5528
|
+
var getShopifyClientUrl = (store) => `https://${store}.myshopify.com/admin/api`;
|
|
5492
5529
|
function getShopifyClientAuthorization(req) {
|
|
5493
5530
|
return {
|
|
5531
|
+
shop: req.headers["shopify-shop"],
|
|
5494
5532
|
token: req.headers["shopify-token"]
|
|
5495
5533
|
};
|
|
5496
5534
|
}
|
|
5497
|
-
function getShopifyClientConfig(options
|
|
5535
|
+
function getShopifyClientConfig(options) {
|
|
5536
|
+
var _a, _b;
|
|
5537
|
+
const currentBaseUrl = shopifyClientInstance.defaults.baseURL;
|
|
5498
5538
|
const currentHeaders = shopifyClientInstance.defaults.headers;
|
|
5499
|
-
const
|
|
5500
|
-
|
|
5501
|
-
authorization:
|
|
5539
|
+
const config = {
|
|
5540
|
+
baseUrl: (_a = options.shop ? getShopifyClientUrl(options.shop) : void 0) != null ? _a : currentBaseUrl,
|
|
5541
|
+
authorization: (_b = options.token ? options.token : void 0) != null ? _b : currentHeaders["X-Shopify-Access-Token"]
|
|
5502
5542
|
};
|
|
5503
|
-
if (options.ensureAuthorizationToken && !
|
|
5543
|
+
if (options.ensureAuthorizationToken && (!config.authorization || !config.baseUrl)) {
|
|
5504
5544
|
throw new UnauthorizeApiError("shopify");
|
|
5505
5545
|
}
|
|
5506
5546
|
return {
|
|
5507
|
-
|
|
5547
|
+
baseURL: config.baseUrl,
|
|
5548
|
+
headers: __spreadValues({}, config.authorization ? { "X-Shopify-Access-Token": config.authorization } : {})
|
|
5508
5549
|
};
|
|
5509
5550
|
}
|
|
5510
|
-
function
|
|
5511
|
-
if (token) {
|
|
5512
|
-
|
|
5551
|
+
function initShopifyClient(token, shop) {
|
|
5552
|
+
if (token && shop) {
|
|
5553
|
+
updateShopifyClient(token);
|
|
5513
5554
|
}
|
|
5514
5555
|
}
|
|
5515
|
-
function
|
|
5516
|
-
const
|
|
5556
|
+
function updateShopifyClient(token, shop) {
|
|
5557
|
+
const defaults = shopifyClientInstance.defaults;
|
|
5558
|
+
const headers = defaults.headers;
|
|
5517
5559
|
if (token) {
|
|
5518
5560
|
headers.Authorization = `Bearer ${token}`;
|
|
5519
5561
|
} else {
|
|
5520
5562
|
delete headers.Authorization;
|
|
5521
5563
|
}
|
|
5564
|
+
if (shop) {
|
|
5565
|
+
defaults.baseURL = getShopifyClientUrl(shop);
|
|
5566
|
+
} else {
|
|
5567
|
+
delete defaults.baseURL;
|
|
5568
|
+
}
|
|
5522
5569
|
}
|
|
5523
5570
|
|
|
5524
5571
|
// src/apis/platform/billing/instance.ts
|
|
@@ -5541,7 +5588,7 @@ function getPlatformBillingClientConfig(options = {}) {
|
|
|
5541
5588
|
headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
|
|
5542
5589
|
};
|
|
5543
5590
|
}
|
|
5544
|
-
function
|
|
5591
|
+
function initPlatformBillingClient(baseUrl, token) {
|
|
5545
5592
|
if (baseUrl) {
|
|
5546
5593
|
platformBillingClientInstance.interceptors.request.use(
|
|
5547
5594
|
(config) => {
|
|
@@ -5722,45 +5769,38 @@ var api = {
|
|
|
5722
5769
|
isInitialized: false
|
|
5723
5770
|
};
|
|
5724
5771
|
function initApi(config, tokens) {
|
|
5725
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t
|
|
5726
|
-
|
|
5772
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
5773
|
+
initPlatformAccountsClient(
|
|
5727
5774
|
(_a = config.urls.platform) == null ? void 0 : _a.accounts,
|
|
5728
|
-
(_b = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _b.
|
|
5775
|
+
(_b = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _b.token
|
|
5729
5776
|
);
|
|
5730
|
-
|
|
5777
|
+
initPlatformBillingClient(
|
|
5731
5778
|
(_c = config.urls.platform) == null ? void 0 : _c.billing,
|
|
5732
|
-
(_d = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _d.
|
|
5733
|
-
);
|
|
5734
|
-
initPlatformDpsClientInstance(
|
|
5735
|
-
(_e = config.urls.platform) == null ? void 0 : _e.dps,
|
|
5736
|
-
(_f = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _f.dps
|
|
5779
|
+
(_d = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _d.token
|
|
5737
5780
|
);
|
|
5738
|
-
|
|
5781
|
+
initPlatformDpsClient((_e = config.urls.platform) == null ? void 0 : _e.dps, (_f = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _f.token);
|
|
5782
|
+
initPlatformAdapterClient(
|
|
5739
5783
|
(_g = config.urls.platform) == null ? void 0 : _g.adapter,
|
|
5740
5784
|
tokens ? {
|
|
5741
|
-
platform:
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
vercel: (_l = tokens.vercel) == null ? void 0 : _l.token,
|
|
5750
|
-
neon: (_m = tokens.neon) == null ? void 0 : _m.token,
|
|
5751
|
-
planetscale: (_n = tokens.planetscale) == null ? void 0 : _n.token
|
|
5785
|
+
platform: tokens.platform,
|
|
5786
|
+
github: tokens.github,
|
|
5787
|
+
netlify: tokens.netlify,
|
|
5788
|
+
vercel: tokens.vercel,
|
|
5789
|
+
neon: tokens.neon,
|
|
5790
|
+
planetscale: tokens.planetscale,
|
|
5791
|
+
mailchimp: tokens.mailchimp,
|
|
5792
|
+
shopify: tokens.shopify
|
|
5752
5793
|
} : void 0
|
|
5753
5794
|
);
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
);
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
initPlanetScaleClientInstance((_w = tokens == null ? void 0 : tokens.planetscale) == null ? void 0 : _w.token);
|
|
5795
|
+
initLiveChatClient((_h = config.urls.products) == null ? void 0 : _h.livechat, (_i = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _i.token);
|
|
5796
|
+
initTextClient((_j = config.urls.integrations) == null ? void 0 : _j.text, (_k = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _k.token);
|
|
5797
|
+
initGithubClient((_l = tokens == null ? void 0 : tokens.github) == null ? void 0 : _l.appToken);
|
|
5798
|
+
initNetlifyClient((_m = tokens == null ? void 0 : tokens.netlify) == null ? void 0 : _m.token);
|
|
5799
|
+
initVercelClient((_n = tokens == null ? void 0 : tokens.vercel) == null ? void 0 : _n.token);
|
|
5800
|
+
initNeonClient((_o = tokens == null ? void 0 : tokens.neon) == null ? void 0 : _o.token);
|
|
5801
|
+
initPlanetScaleClient((_p = tokens == null ? void 0 : tokens.planetscale) == null ? void 0 : _p.token);
|
|
5802
|
+
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);
|
|
5803
|
+
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);
|
|
5764
5804
|
api.isInitialized = true;
|
|
5765
5805
|
}
|
|
5766
5806
|
|
|
@@ -5802,12 +5842,13 @@ export {
|
|
|
5802
5842
|
getAppAutoReviewPayload,
|
|
5803
5843
|
getEmptyAppAutoReview,
|
|
5804
5844
|
getGitHubClientAuthorization,
|
|
5805
|
-
|
|
5845
|
+
getGithubClientConfig,
|
|
5806
5846
|
getIntegrationFlowUrl,
|
|
5807
5847
|
getLiveChatClientAuthorization,
|
|
5808
5848
|
getLiveChatClientConfig,
|
|
5809
5849
|
getMailchimpClientAuthorization,
|
|
5810
5850
|
getMailchimpClientConfig,
|
|
5851
|
+
getMailchimpClientUrl,
|
|
5811
5852
|
getNeonClientAuthorization,
|
|
5812
5853
|
getNeonClientConfig,
|
|
5813
5854
|
getNetlifyClientAuthorization,
|
|
@@ -5827,25 +5868,26 @@ export {
|
|
|
5827
5868
|
getRegion,
|
|
5828
5869
|
getShopifyClientAuthorization,
|
|
5829
5870
|
getShopifyClientConfig,
|
|
5871
|
+
getShopifyClientUrl,
|
|
5830
5872
|
getTextClientAuthorization,
|
|
5831
5873
|
getTextClientConfig,
|
|
5832
5874
|
getVercelClientAuthorization,
|
|
5833
5875
|
getVercelClientConfig,
|
|
5834
5876
|
githubClientInstance,
|
|
5835
5877
|
initApi,
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5878
|
+
initGithubClient,
|
|
5879
|
+
initLiveChatClient,
|
|
5880
|
+
initMailchimpClient,
|
|
5881
|
+
initNeonClient,
|
|
5882
|
+
initNetlifyClient,
|
|
5883
|
+
initPlanetScaleClient,
|
|
5884
|
+
initPlatformAccountsClient,
|
|
5885
|
+
initPlatformAdapterClient,
|
|
5886
|
+
initPlatformBillingClient,
|
|
5887
|
+
initPlatformDpsClient,
|
|
5888
|
+
initShopifyClient,
|
|
5889
|
+
initTextClient,
|
|
5890
|
+
initVercelClient,
|
|
5849
5891
|
livechatClientInstance,
|
|
5850
5892
|
mailchimpClientInstance,
|
|
5851
5893
|
neonClientInstance,
|
|
@@ -5855,16 +5897,15 @@ export {
|
|
|
5855
5897
|
platformAdapterClientInstance,
|
|
5856
5898
|
platformBillingClientInstance,
|
|
5857
5899
|
platformDpsClientInstance,
|
|
5858
|
-
shopifyApiUrl,
|
|
5859
5900
|
shopifyClientInstance,
|
|
5860
5901
|
textClientInstance,
|
|
5861
|
-
|
|
5902
|
+
updateGithubClient,
|
|
5862
5903
|
updateMailchimpClientInstance,
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5904
|
+
updateNeonClient,
|
|
5905
|
+
updateNetlifyClient,
|
|
5906
|
+
updatePlanetScaleClient,
|
|
5907
|
+
updatePlatformAdapterClient,
|
|
5908
|
+
updateShopifyClient,
|
|
5909
|
+
updateVercelClient,
|
|
5869
5910
|
vercelClientInstance
|
|
5870
5911
|
};
|