@livechat/developer-studio-api 1.0.1

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.mjs ADDED
@@ -0,0 +1,4673 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+
41
+ // src/apis/integrations/github/api.ts
42
+ import axios2 from "axios";
43
+
44
+ // src/apis/integrations/github/instance.ts
45
+ import axios from "axios";
46
+
47
+ // src/types/errors/api.ts
48
+ var UnauthorizeApiError = class extends Error {
49
+ constructor(source) {
50
+ super("Unauthorized API call");
51
+ this.source = source;
52
+ }
53
+ };
54
+
55
+ // src/apis/integrations/github/instance.ts
56
+ var githubClientInstance = axios.create({
57
+ baseURL: "https://api.github.com",
58
+ headers: {
59
+ ["Accept"]: "application/vnd.github+json",
60
+ ["Content-Type"]: "application/json"
61
+ }
62
+ });
63
+ githubClientInstance.interceptors.response.use(
64
+ (r) => r,
65
+ (error) => {
66
+ var _a;
67
+ if (axios.isAxiosError(error)) {
68
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
69
+ error = new UnauthorizeApiError("github");
70
+ }
71
+ }
72
+ throw error;
73
+ }
74
+ );
75
+ function getGitHubClientAuthorization(req) {
76
+ return {
77
+ tokens: {
78
+ app: req.headers["github-app-token"],
79
+ oauth: req.headers["github-oauth-token"]
80
+ }
81
+ };
82
+ }
83
+ function getGithubClientRequestConfig(options = {}) {
84
+ const defaultAuthorization = githubClientInstance.defaults.headers["Authorization"];
85
+ const headers = {
86
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
87
+ };
88
+ return {
89
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
90
+ };
91
+ }
92
+ function initGithubClientInstance(token) {
93
+ if (token) {
94
+ updateGithubClientInstance(token);
95
+ }
96
+ }
97
+ function updateGithubClientInstance(token) {
98
+ if (token) {
99
+ githubClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
100
+ } else {
101
+ delete githubClientInstance.defaults.headers["Authorization"];
102
+ }
103
+ }
104
+
105
+ // ../../private/config/src/integrations/github.ts
106
+ var GITHUB_CONFIG = {
107
+ url: "https://github.com/login/oauth/authorize",
108
+ app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
109
+ id: 265597,
110
+ client_name: "text-platform-developer-console",
111
+ client_id: "Iv1.c582ec1de0bf8428",
112
+ client_secret: process.env.GITHUB_APP_CLIENT_SECRET,
113
+ redirect_uri: "https://platform.text.com/console-adapter/integrations/github/callbacks/app"
114
+ } : {
115
+ id: 319969,
116
+ client_name: "text-platform-labs",
117
+ client_id: "Iv1.e631130cf8ac91d7",
118
+ client_secret: process.env.GITHUB_APP_CLIENT_SECRET_LABS,
119
+ redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/github/callbacks/app"
120
+ },
121
+ oauth: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
122
+ client_id: "ebbb08fa2c26d3e7911d",
123
+ client_secret: process.env.GITHUB_OAUTH_CLIENT_SECRET,
124
+ redirect_uri: "https://platform.text.com/console-adapter/integrations/github/callbacks/oauth"
125
+ } : {
126
+ client_id: "bcffd61bd0edd23bca45",
127
+ client_secret: process.env.GITHUB_OAUTH_CLIENT_SECRET_LABS,
128
+ redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/github/callbacks/oauth"
129
+ }
130
+ };
131
+
132
+ // ../../private/config/src/integrations/netlify.ts
133
+ var NETLIFY_CONFIG = {
134
+ url: "https://app.netlify.com/authorize",
135
+ github_app_client_name: "netlify",
136
+ app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
137
+ client_id: "qUoHYb2DdVwKxot9Gc7URTdsZQYHYaumykjkv5K3_Mw",
138
+ redirect_uri: "https://platform.text.com/console-adapter/integrations/netlify/callbacks/oauth",
139
+ client_secret: process.env.NETLIFY_CLIENT_SECRET
140
+ } : {
141
+ client_id: "vDmNXNN9rTkZJtCwOHot2IKOherrm8t7gGA5kStotlo",
142
+ redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/netlify/callbacks/oauth",
143
+ client_secret: process.env.NETLIFY_CLIENT_SECRET_LABS
144
+ }
145
+ };
146
+
147
+ // ../../private/config/src/integrations/planetscale.ts
148
+ var PLANETSCALE_CONFIG = {
149
+ url: "http://app.planetscale.com/oauth/authorize",
150
+ github_app_client_name: "planetscale",
151
+ app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
152
+ organization: "livechat",
153
+ appId: "bw2hi8knpzbl",
154
+ client_id: "pscale_app_b0aa82ae3d32f32010d7352d88f22fb2",
155
+ service_token_id: "be5l1vy34g6h",
156
+ redirect_uri: "https://platform.text.com/console-adapter/integrations/planetscale/callbacks/oauth",
157
+ client_secret: process.env.PLANETSCALE_CLIENT_SECRET,
158
+ service_token: process.env.PLANETSCALE_SERVICE_TOKEN
159
+ } : {
160
+ organization: "livechat",
161
+ appId: "oz4pafhcyshn",
162
+ client_id: "pscale_app_54606de46e127f664df359639baf6b66",
163
+ service_token_id: "qdpgtmrqpdsm",
164
+ redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/planetscale/callbacks/oauth",
165
+ client_secret: process.env.PLANETSCALE_CLIENT_SECRET_LABS,
166
+ service_token: process.env.PLANETSCALE_SERVICE_TOKEN_LABS
167
+ }
168
+ };
169
+
170
+ // ../../private/config/src/integrations/sentry.ts
171
+ var SENTRY_CONFIG = {
172
+ github_app_client_name: "sentry-io",
173
+ app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
174
+ client_id: "8c8296fe87cb446e9ded22f8b6f4b078363500062155476490d4583b5406d30a",
175
+ client_secret: process.env.SENTRY_CLIENT_SECRET,
176
+ redirect_uri: "https://platform.text.com/console-adapter/integrations/sentry/callbacks/oauth"
177
+ } : {
178
+ client_id: "d35803a39bab43b3b6dbe0b89cb99dc54689c35a74dd442baaef0f5b9b0d70bc",
179
+ client_secret: process.env.SENTRY_CLIENT_SECRET_LABS,
180
+ redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/sentry/callbacks/oauth"
181
+ }
182
+ };
183
+
184
+ // ../../private/config/src/integrations/vercel.ts
185
+ var VERCEL_CONFIG = {
186
+ github_app_client_name: "vercel",
187
+ app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
188
+ client_name: "text-platform-developer-console",
189
+ client_id: "oac_0nV7q5jDmCQKqpwEdGljaaLp",
190
+ client_secret: process.env.VERCEL_CLIENT_SECRET,
191
+ redirect_uri: "https://platform.text.com/console-adapter/integrations/vercel/callbacks/oauth"
192
+ } : {
193
+ client_name: "text-platform-labs",
194
+ client_id: "oac_bgwv72AO8fJWj8I9qIROY7wI",
195
+ client_secret: process.env.VERCEL_CLIENT_SECRET_LABS,
196
+ redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/vercel/callbacks/oauth"
197
+ }
198
+ };
199
+
200
+ // src/apis/integrations/github/installation/api.ts
201
+ var gitHubInstallationApi = {
202
+ getInstallation(account, authorization) {
203
+ return __async(this, null, function* () {
204
+ const installations = yield this.getInstallations(authorization);
205
+ return installations.find(
206
+ (installation) => installation.app_id === GITHUB_CONFIG.app.id && account ? installation.account.login === account : installation.target_type === "User"
207
+ );
208
+ });
209
+ },
210
+ getInstallations(authorization) {
211
+ return __async(this, null, function* () {
212
+ var _a;
213
+ const response = yield githubClientInstance.get(
214
+ `/user/installations?timestamp=${(/* @__PURE__ */ new Date()).getTime()}`,
215
+ getGithubClientRequestConfig({
216
+ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app
217
+ })
218
+ );
219
+ return response.data.installations;
220
+ });
221
+ },
222
+ getInstallationRepositories(installationId) {
223
+ return __async(this, null, function* () {
224
+ const response = yield githubClientInstance.get(
225
+ `/user/installations/${installationId}/repositories?timestamp=${(/* @__PURE__ */ new Date()).getTime()}&per_page=100`
226
+ );
227
+ return response.data.repositories;
228
+ });
229
+ }
230
+ };
231
+
232
+ // src/apis/integrations/github/repository/api.ts
233
+ var gitHubRepositoryApi = {
234
+ getRepository(repositoryName, authorization) {
235
+ return __async(this, null, function* () {
236
+ var _a;
237
+ const response = yield githubClientInstance.get(
238
+ `/repos/${repositoryName}`,
239
+ getGithubClientRequestConfig({
240
+ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app
241
+ })
242
+ );
243
+ return response.data;
244
+ });
245
+ },
246
+ getRepositoryBranches(repositoryName, authorization) {
247
+ return __async(this, null, function* () {
248
+ var _a;
249
+ const response = yield githubClientInstance.get(
250
+ `/repos/${repositoryName}/branches`,
251
+ getGithubClientRequestConfig({
252
+ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app
253
+ })
254
+ );
255
+ return response.data;
256
+ });
257
+ },
258
+ getRepositoryBranch(repositoryName, repositoryBranch, authorization) {
259
+ return __async(this, null, function* () {
260
+ var _a;
261
+ const response = yield githubClientInstance.get(
262
+ `/repos/${repositoryName}/branches`,
263
+ getGithubClientRequestConfig({
264
+ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app
265
+ })
266
+ );
267
+ const branch = response.data.find(
268
+ (branch2) => branch2.name === repositoryBranch
269
+ );
270
+ if (!branch) {
271
+ throw new Error("Branch not found");
272
+ }
273
+ return branch;
274
+ });
275
+ },
276
+ getRepositorySeed(repositoryName, authorization) {
277
+ return __async(this, null, function* () {
278
+ var _a;
279
+ const { data } = yield githubClientInstance.get(
280
+ `/repos/${repositoryName}/contents/livechat.config.json`,
281
+ getGithubClientRequestConfig({
282
+ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app
283
+ })
284
+ );
285
+ return data;
286
+ });
287
+ },
288
+ createRepository(name, hasInstallation, templateName, authorization) {
289
+ return __async(this, null, function* () {
290
+ var _a, _b, _c, _d;
291
+ const fullTemplateName = templateName === "nextjs" ? "livechat/developer-app-template-nextjs" : void 0;
292
+ if (fullTemplateName || !hasInstallation) {
293
+ let repository;
294
+ if (fullTemplateName) {
295
+ const response2 = yield githubClientInstance.post(
296
+ `/repos/${fullTemplateName}/generate`,
297
+ {
298
+ name,
299
+ description: name,
300
+ private: false,
301
+ include_all_branches: false
302
+ },
303
+ getGithubClientRequestConfig({
304
+ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.oauth
305
+ })
306
+ );
307
+ repository = response2.data;
308
+ } else {
309
+ const response2 = yield githubClientInstance.post(
310
+ `/user/repos`,
311
+ {
312
+ name,
313
+ description: name,
314
+ private: false,
315
+ auto_init: true,
316
+ is_template: false
317
+ },
318
+ getGithubClientRequestConfig({
319
+ token: (_b = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _b.oauth
320
+ })
321
+ );
322
+ repository = response2.data;
323
+ }
324
+ yield githubClientInstance.patch(
325
+ `/repos/${repository.full_name}`,
326
+ {
327
+ private: true
328
+ },
329
+ getGithubClientRequestConfig({
330
+ token: (_c = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _c.oauth
331
+ })
332
+ );
333
+ return repository;
334
+ }
335
+ const response = yield githubClientInstance.post(
336
+ `/user/repos`,
337
+ {
338
+ name,
339
+ description: name,
340
+ private: true,
341
+ auto_init: true,
342
+ is_template: false
343
+ },
344
+ getGithubClientRequestConfig({
345
+ token: (_d = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _d.app
346
+ })
347
+ );
348
+ return response.data;
349
+ });
350
+ },
351
+ seedRepository(repositoryName, appId, clientId, authorization) {
352
+ return __async(this, null, function* () {
353
+ const upsert = (sha) => __async(this, null, function* () {
354
+ var _a;
355
+ const response = yield githubClientInstance.put(
356
+ `/repos/${repositoryName}/contents/livechat.config.json`,
357
+ {
358
+ message: "Added LiveChat Developer App configuration",
359
+ sha,
360
+ content: btoa(
361
+ JSON.stringify(
362
+ {
363
+ appId,
364
+ auth: {
365
+ clientId
366
+ }
367
+ },
368
+ null,
369
+ 4
370
+ )
371
+ )
372
+ },
373
+ getGithubClientRequestConfig({ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app })
374
+ );
375
+ return response.data.content;
376
+ });
377
+ let seed = void 0;
378
+ try {
379
+ seed = yield this.getRepositorySeed(repositoryName, authorization);
380
+ } catch (e) {
381
+ }
382
+ return yield upsert(seed == null ? void 0 : seed.sha);
383
+ });
384
+ },
385
+ deleteRepository(repositoryName, authorization) {
386
+ return __async(this, null, function* () {
387
+ var _a;
388
+ return yield githubClientInstance.delete(
389
+ `/repos/${repositoryName}`,
390
+ getGithubClientRequestConfig({
391
+ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app
392
+ })
393
+ );
394
+ });
395
+ },
396
+ createRepositoryDeployKey(repositoryName, deployKey, authorization) {
397
+ return __async(this, null, function* () {
398
+ var _a;
399
+ const response = yield githubClientInstance.post(
400
+ `/repos/${repositoryName}/keys`,
401
+ {
402
+ title: "developer-console-to-netlify",
403
+ key: deployKey
404
+ },
405
+ getGithubClientRequestConfig({
406
+ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app
407
+ })
408
+ );
409
+ return response.data;
410
+ });
411
+ },
412
+ createRepositoryBuildHook(repositoryName, authorization) {
413
+ return __async(this, null, function* () {
414
+ var _a;
415
+ try {
416
+ const response = yield githubClientInstance.post(
417
+ `/repos/${repositoryName}/hooks`,
418
+ {
419
+ name: "web",
420
+ active: true,
421
+ events: [
422
+ "delete",
423
+ "push",
424
+ "pull_request",
425
+ "create",
426
+ "issue_comment",
427
+ "pull_request_review",
428
+ "pull_request_review_comment"
429
+ ],
430
+ config: {
431
+ url: "https://api.netlify.com/hooks/github",
432
+ content_type: "json"
433
+ }
434
+ },
435
+ getGithubClientRequestConfig({
436
+ token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app
437
+ })
438
+ );
439
+ return response.data;
440
+ } catch (e) {
441
+ }
442
+ });
443
+ }
444
+ };
445
+
446
+ // src/apis/integrations/github/api.ts
447
+ var gitHubApi = {
448
+ installation: gitHubInstallationApi,
449
+ repository: gitHubRepositoryApi,
450
+ getToken(code, clientId, clientSecret, redirectUrl) {
451
+ return __async(this, null, function* () {
452
+ var _a;
453
+ const data = new URLSearchParams({
454
+ code,
455
+ client_id: clientId,
456
+ client_secret: clientSecret,
457
+ redirect_uri: redirectUrl
458
+ });
459
+ const response = yield axios2.post(
460
+ "https://github.com/login/oauth/access_token",
461
+ data,
462
+ {
463
+ headers: {
464
+ "Content-Type": "application/x-www-form-urlencoded"
465
+ }
466
+ }
467
+ );
468
+ let params = new URLSearchParams(response.data);
469
+ return (_a = params.get("access_token")) != null ? _a : "";
470
+ });
471
+ }
472
+ };
473
+
474
+ // src/apis/integrations/netlify/instance.ts
475
+ import axios3 from "axios";
476
+ var netlifyClientInstance = axios3.create({
477
+ baseURL: "https://api.netlify.com/api/v1",
478
+ headers: {
479
+ ["Content-Type"]: "application/json"
480
+ }
481
+ });
482
+ netlifyClientInstance.interceptors.response.use(
483
+ (r) => r,
484
+ (error) => {
485
+ var _a;
486
+ if (axios3.isAxiosError(error)) {
487
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
488
+ error = new UnauthorizeApiError("netlify");
489
+ }
490
+ }
491
+ throw error;
492
+ }
493
+ );
494
+ function getNetlifyClientAuthorization(req) {
495
+ return {
496
+ token: req.headers["netlify-token"]
497
+ };
498
+ }
499
+ function getNetlifyClientConfig(options = {}) {
500
+ const defaultAuthorization = netlifyClientInstance.defaults.headers["Authorization"];
501
+ const headers = {
502
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
503
+ };
504
+ return {
505
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
506
+ };
507
+ }
508
+ function initNetlifyClientInstance(token) {
509
+ if (token) {
510
+ updateNetlifyClientInstance(token);
511
+ }
512
+ }
513
+ function updateNetlifyClientInstance(token) {
514
+ if (token) {
515
+ netlifyClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
516
+ } else {
517
+ delete netlifyClientInstance.defaults.headers["Authorization"];
518
+ }
519
+ }
520
+
521
+ // src/apis/integrations/netlify/account/api.ts
522
+ var netlifyAccountApi = {
523
+ getAccount(authorization) {
524
+ return __async(this, null, function* () {
525
+ const { data: accounts } = yield netlifyClientInstance.get(`/accounts`, getNetlifyClientConfig(authorization));
526
+ return accounts[0].id;
527
+ });
528
+ },
529
+ getAccountEnvs(accountId, siteId, authorization) {
530
+ return __async(this, null, function* () {
531
+ if (!accountId) {
532
+ accountId = yield this.getAccount(authorization);
533
+ }
534
+ if (!accountId) {
535
+ throw new Error("No account");
536
+ }
537
+ const { data: envs } = yield netlifyClientInstance.get(
538
+ `/accounts/${accountId}/env?site_id=${siteId}&scope=all&context=all&level=all`,
539
+ getNetlifyClientConfig(authorization)
540
+ );
541
+ return envs;
542
+ });
543
+ },
544
+ getAccountEnv(accountId, siteId, envKey, authorization) {
545
+ return __async(this, null, function* () {
546
+ if (!accountId) {
547
+ accountId = yield this.getAccount(authorization);
548
+ }
549
+ if (!accountId) {
550
+ throw new Error("No account");
551
+ }
552
+ const { data: envs } = yield netlifyClientInstance.get(
553
+ `/accounts/${accountId}/env/${envKey}?site_id=${siteId}`,
554
+ getNetlifyClientConfig(authorization)
555
+ );
556
+ return envs;
557
+ });
558
+ },
559
+ createAccountEnv(accountId, siteId, envName, envValue, envs, authorization) {
560
+ return __async(this, null, function* () {
561
+ if (!accountId) {
562
+ accountId = yield this.getAccount(authorization);
563
+ }
564
+ if (!accountId) {
565
+ throw new Error("No account");
566
+ }
567
+ if (!envs) {
568
+ const response = yield netlifyClientInstance.get(
569
+ `/accounts/${accountId}/env?site_id=${siteId}&scope=all&context=all&level=all`,
570
+ getNetlifyClientConfig(authorization)
571
+ );
572
+ envs = response.data;
573
+ }
574
+ const existingEnv = envs.find((env) => env.key === envName);
575
+ if (existingEnv) {
576
+ yield netlifyClientInstance.put(
577
+ `/accounts/${accountId}/env/${existingEnv.key}?site_id=${siteId}`,
578
+ {
579
+ key: existingEnv.key,
580
+ scopes: ["builds", "functions", "runtime", "post_processing"],
581
+ values: [{ context: "all", value: envValue }]
582
+ },
583
+ getNetlifyClientConfig(authorization)
584
+ );
585
+ } else {
586
+ yield netlifyClientInstance.post(
587
+ `/accounts/${accountId}/env?site_id=${siteId}`,
588
+ [
589
+ {
590
+ key: envName,
591
+ scopes: ["builds", "functions", "runtime", "post_processing"],
592
+ values: [{ context: "all", value: envValue }]
593
+ }
594
+ ],
595
+ getNetlifyClientConfig(authorization)
596
+ );
597
+ }
598
+ });
599
+ },
600
+ addAccountSentryTokenEnv(siteId, token, authorization) {
601
+ return __async(this, null, function* () {
602
+ const accounts = yield netlifyClientInstance.get(
603
+ `/accounts`,
604
+ getNetlifyClientConfig(authorization)
605
+ );
606
+ const accountId = accounts.data[0].id;
607
+ yield this.createAccountEnv(
608
+ accountId,
609
+ siteId,
610
+ "SENTRY_AUTH_TOKEN",
611
+ token,
612
+ void 0,
613
+ authorization
614
+ );
615
+ });
616
+ }
617
+ };
618
+
619
+ // src/apis/integrations/netlify/hook/api.ts
620
+ var netlifyHookApi = {
621
+ addBuildHooks(siteId, authorization) {
622
+ return __async(this, null, function* () {
623
+ try {
624
+ netlifyClientInstance.post(
625
+ "/hooks",
626
+ {
627
+ site_id: siteId,
628
+ event: "deploy_created",
629
+ type: "url",
630
+ data: {
631
+ url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_BASE_PATH}/api/integrations/netlify/webhook`
632
+ }
633
+ },
634
+ getNetlifyClientConfig(authorization)
635
+ );
636
+ } catch (e) {
637
+ }
638
+ try {
639
+ netlifyClientInstance.post(
640
+ "/hooks",
641
+ {
642
+ site_id: siteId,
643
+ event: "deploy_failed",
644
+ type: "url",
645
+ data: {
646
+ url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_BASE_PATH}/api/integrations/netlify/webhook`
647
+ }
648
+ },
649
+ getNetlifyClientConfig(authorization)
650
+ );
651
+ } catch (e) {
652
+ }
653
+ try {
654
+ netlifyClientInstance.post(
655
+ "/hooks",
656
+ {
657
+ site_id: siteId,
658
+ event: "deploy_building",
659
+ type: "url",
660
+ data: {
661
+ url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_BASE_PATH}/api/integrations/netlify/webhook`
662
+ }
663
+ },
664
+ getNetlifyClientConfig(authorization)
665
+ );
666
+ } catch (e) {
667
+ }
668
+ });
669
+ }
670
+ };
671
+
672
+ // src/apis/integrations/netlify/key/api.ts
673
+ var netlifyKeyApi = {
674
+ createDeployKey(authorization) {
675
+ return __async(this, null, function* () {
676
+ const response = yield netlifyClientInstance.post(
677
+ "/deploy_keys",
678
+ void 0,
679
+ getNetlifyClientConfig(authorization)
680
+ );
681
+ return response.data;
682
+ });
683
+ }
684
+ };
685
+
686
+ // src/apis/integrations/netlify/site/api.ts
687
+ var netlifySiteApi = {
688
+ getSites(authorization) {
689
+ return __async(this, null, function* () {
690
+ const response = yield netlifyClientInstance.get(
691
+ "/sites",
692
+ getNetlifyClientConfig(authorization)
693
+ );
694
+ return response.data;
695
+ });
696
+ },
697
+ getSite(siteId, authorization) {
698
+ return __async(this, null, function* () {
699
+ const response = yield netlifyClientInstance.get(
700
+ `/sites/${siteId}`,
701
+ getNetlifyClientConfig(authorization)
702
+ );
703
+ return response.data;
704
+ });
705
+ },
706
+ getSiteDeploy(siteId, authorization) {
707
+ return __async(this, null, function* () {
708
+ const { data: deploys } = yield netlifyClientInstance.get(
709
+ `/sites/${siteId}/deploys/`,
710
+ getNetlifyClientConfig(authorization)
711
+ );
712
+ const deploy = deploys.filter(
713
+ (deploy2) => deploy2.context === "production"
714
+ )[0];
715
+ const { data: pluginRuns } = yield netlifyClientInstance.get(
716
+ `/deploys/${deploy.id}/plugin_runs`,
717
+ getNetlifyClientConfig(authorization)
718
+ );
719
+ deploy.plugin_runs = pluginRuns;
720
+ return deploy;
721
+ });
722
+ },
723
+ getSiteDeploys(siteId, authorization) {
724
+ return __async(this, null, function* () {
725
+ const { data: deploys } = yield netlifyClientInstance.get(
726
+ `/sites/${siteId}/deploys`,
727
+ getNetlifyClientConfig(authorization)
728
+ );
729
+ return deploys;
730
+ });
731
+ },
732
+ getSiteSnippets(siteId, authorization) {
733
+ return __async(this, null, function* () {
734
+ const { data: snippets } = yield netlifyClientInstance.get(`sites/${siteId}/snippets`, getNetlifyClientConfig(authorization));
735
+ return snippets;
736
+ });
737
+ },
738
+ createSiteByInstallationId(name, repositoryFullName, installationId, branch, authorization) {
739
+ return __async(this, null, function* () {
740
+ const response = yield netlifyClientInstance.post(
741
+ `/sites`,
742
+ {
743
+ name,
744
+ repo: {
745
+ provider: "github",
746
+ repo: repositoryFullName,
747
+ branch,
748
+ private: true,
749
+ installation_id: installationId,
750
+ owner_type: "User",
751
+ plugins: ["@netlify/plugin-nextjs"],
752
+ env: {},
753
+ dir: ".next",
754
+ cmd: "npm run build"
755
+ },
756
+ default_hooks_data: {},
757
+ plugins: [{ package: "@netlify/plugin-nextjs" }],
758
+ created_via: ""
759
+ },
760
+ getNetlifyClientConfig(authorization)
761
+ );
762
+ yield netlifyHookApi.addBuildHooks(response.data.id, authorization);
763
+ return response.data;
764
+ });
765
+ },
766
+ createSiteByDeployKey(name, repositoryFullName, deployKeyId, branch, authorization) {
767
+ return __async(this, null, function* () {
768
+ const response = yield netlifyClientInstance.post(
769
+ `/sites`,
770
+ {
771
+ name,
772
+ repo: {
773
+ provider: "github",
774
+ branch,
775
+ repo: repositoryFullName,
776
+ deploy_key_id: deployKeyId,
777
+ plugins: [
778
+ {
779
+ package: "@netlify/plugin-nextjs"
780
+ }
781
+ ],
782
+ dir: ".next",
783
+ env: {},
784
+ cmd: "npm run build",
785
+ private: true
786
+ },
787
+ plugins: [
788
+ {
789
+ package: "@netlify/plugin-nextjs"
790
+ }
791
+ ],
792
+ created_via: ""
793
+ },
794
+ getNetlifyClientConfig(authorization)
795
+ );
796
+ yield netlifyHookApi.addBuildHooks(response.data.id, authorization);
797
+ return response.data;
798
+ });
799
+ },
800
+ removeSite(siteId, authorization) {
801
+ return __async(this, null, function* () {
802
+ const response = yield netlifyClientInstance.delete(
803
+ `/sites/${siteId}`,
804
+ getNetlifyClientConfig(authorization)
805
+ );
806
+ return response.data;
807
+ });
808
+ },
809
+ triggerSiteBuild(siteId, authorization) {
810
+ return __async(this, null, function* () {
811
+ yield netlifyClientInstance.post(
812
+ `/sites/${siteId}/builds`,
813
+ {},
814
+ getNetlifyClientConfig(authorization)
815
+ );
816
+ });
817
+ },
818
+ addGitHubInstallationToSite(siteId, installationId, authorization) {
819
+ return __async(this, null, function* () {
820
+ const site = yield netlifyClientInstance.get(
821
+ `/sites/${siteId}`,
822
+ getNetlifyClientConfig(authorization)
823
+ );
824
+ yield netlifyClientInstance.put(
825
+ `/sites/${siteId}`,
826
+ {
827
+ repo: {
828
+ provider: site.data.build_settings.provider,
829
+ repo: site.data.build_settings.repo_path,
830
+ branch: site.data.build_settings.allowed_branches[0],
831
+ private: !site.data.build_settings.public_repo,
832
+ installation_id: installationId,
833
+ plugins: site.data.plugins,
834
+ env: site.data.build_settings.env,
835
+ dir: site.data.build_settings.dir,
836
+ cmd: site.data.build_settings.cmd
837
+ }
838
+ },
839
+ getNetlifyClientConfig(authorization)
840
+ );
841
+ });
842
+ },
843
+ addSentryPluginToSite(siteId, projectOrg, projectName, projectKey, token, authorization) {
844
+ return __async(this, null, function* () {
845
+ yield netlifyClientInstance.put(
846
+ `/sites/${siteId}`,
847
+ {
848
+ plugins: [
849
+ {
850
+ package: "@netlify/plugin-nextjs"
851
+ },
852
+ {
853
+ package: "@sentry/netlify-build-plugin"
854
+ }
855
+ ]
856
+ },
857
+ getNetlifyClientConfig(authorization)
858
+ );
859
+ const accountId = yield netlifyAccountApi.getAccount(authorization);
860
+ if (!accountId) {
861
+ throw new Error("Account is missing");
862
+ }
863
+ const snippets = yield this.getSiteSnippets(siteId, authorization);
864
+ const envs = yield netlifyAccountApi.getAccountEnvs(
865
+ accountId,
866
+ siteId,
867
+ authorization
868
+ );
869
+ if (token) {
870
+ yield netlifyAccountApi.createAccountEnv(
871
+ accountId,
872
+ siteId,
873
+ "SENTRY_AUTH_TOKEN",
874
+ token,
875
+ envs,
876
+ authorization
877
+ );
878
+ }
879
+ yield netlifyAccountApi.createAccountEnv(
880
+ accountId,
881
+ siteId,
882
+ "SENTRY_ORG",
883
+ projectOrg,
884
+ envs,
885
+ authorization
886
+ );
887
+ yield netlifyAccountApi.createAccountEnv(
888
+ accountId,
889
+ siteId,
890
+ "SENTRY_PROJECT",
891
+ projectName,
892
+ envs,
893
+ authorization
894
+ );
895
+ const currentSnippet = snippets.find(
896
+ (snippet) => snippet.title === "sentry"
897
+ );
898
+ if (currentSnippet) {
899
+ yield netlifyClientInstance.delete(
900
+ `sites/${siteId}/snippets/${currentSnippet.id}`,
901
+ getNetlifyClientConfig(authorization)
902
+ );
903
+ }
904
+ yield netlifyClientInstance.post(
905
+ `sites/${siteId}/snippets`,
906
+ {
907
+ general_position: "footer",
908
+ title: "sentry",
909
+ // eslint-disable-next-line no-useless-escape
910
+ general: `<script src='https://js.sentry-cdn.com/${projectKey}.min.js' crossorigin="anonymous"></script>`
911
+ },
912
+ getNetlifyClientConfig(authorization)
913
+ );
914
+ return;
915
+ });
916
+ }
917
+ };
918
+
919
+ // src/apis/integrations/netlify/api.ts
920
+ var netlifyApi = {
921
+ account: netlifyAccountApi,
922
+ site: netlifySiteApi,
923
+ key: netlifyKeyApi,
924
+ hook: netlifyHookApi
925
+ };
926
+
927
+ // src/apis/integrations/planetscale/api.ts
928
+ import axios5 from "axios";
929
+
930
+ // src/apis/integrations/planetscale/instance.ts
931
+ import axios4 from "axios";
932
+ var planetScaleClientInstance = axios4.create({
933
+ baseURL: "https://api.planetscale.com"
934
+ });
935
+ planetScaleClientInstance.interceptors.response.use(
936
+ (r) => r,
937
+ (error) => {
938
+ var _a;
939
+ if (axios4.isAxiosError(error)) {
940
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
941
+ error = new UnauthorizeApiError("planetscale");
942
+ }
943
+ }
944
+ throw error;
945
+ }
946
+ );
947
+ function getPlanetScaleClientAuthorization(req) {
948
+ return {
949
+ token: req.headers["planetscale-token"]
950
+ };
951
+ }
952
+ function getPlanetScaleClientConfig(options = {}) {
953
+ const defaultAuthorization = planetScaleClientInstance.defaults.headers["Authorization"];
954
+ const headers = {
955
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `${options.token}` : void 0
956
+ };
957
+ if (options.ensureAuthorizationToken && !headers.authorization) {
958
+ throw new UnauthorizeApiError("planetscale");
959
+ }
960
+ return {
961
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
962
+ };
963
+ }
964
+ function initPlanetScaleClientInstance(token) {
965
+ if (token) {
966
+ updatePlanetScaleClientInstance(token);
967
+ }
968
+ }
969
+ function updatePlanetScaleClientInstance(token) {
970
+ if (token) {
971
+ planetScaleClientInstance.defaults.headers["Authorization"] = `${token}`;
972
+ } else {
973
+ delete planetScaleClientInstance.defaults.headers["Authorization"];
974
+ }
975
+ }
976
+
977
+ // src/apis/integrations/planetscale/database/password/api.ts
978
+ var planescaleDatabasePasswordApi = {
979
+ getDatabasePasswords(organization, databaseName, branchName, authorization) {
980
+ return __async(this, null, function* () {
981
+ const response = yield planetScaleClientInstance.get(
982
+ `/v1/organizations/${organization}/databases/${databaseName}/branches/${branchName}/passwords`,
983
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
984
+ ensureAuthorizationToken: true
985
+ }))
986
+ );
987
+ return response.data;
988
+ });
989
+ },
990
+ getDatabasePassword(organization, databaseName, branchName, passwordId, authorization) {
991
+ return __async(this, null, function* () {
992
+ const response = yield planetScaleClientInstance.get(
993
+ `/v1/organizations/${organization}/databases/${databaseName}/branches/${branchName}/passwords/${passwordId}`,
994
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
995
+ ensureAuthorizationToken: true
996
+ }))
997
+ );
998
+ return response.data;
999
+ });
1000
+ },
1001
+ createDatabasePassword(organization, databaseName, branchName, passwordName, authorization) {
1002
+ return __async(this, null, function* () {
1003
+ const response = yield planetScaleClientInstance.post(
1004
+ `/v1/organizations/${organization}/databases/${databaseName}/branches/${branchName}/passwords`,
1005
+ {
1006
+ name: passwordName
1007
+ },
1008
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
1009
+ ensureAuthorizationToken: true
1010
+ }))
1011
+ );
1012
+ return response.data;
1013
+ });
1014
+ },
1015
+ deleteDatabasePassword(organization, databaseName, branchName, passwordId, authorization) {
1016
+ return __async(this, null, function* () {
1017
+ yield planetScaleClientInstance.delete(
1018
+ `/v1/organizations/${organization}/databases/${databaseName}/branches/${branchName}/passwords/${passwordId}`,
1019
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
1020
+ ensureAuthorizationToken: true
1021
+ }))
1022
+ );
1023
+ });
1024
+ }
1025
+ };
1026
+
1027
+ // src/apis/integrations/planetscale/database/api.ts
1028
+ var planescaleDatabaseApi = {
1029
+ password: planescaleDatabasePasswordApi,
1030
+ getDatabases(organization, authorization) {
1031
+ return __async(this, null, function* () {
1032
+ const response = yield planetScaleClientInstance.get(
1033
+ `/v1/organizations/${organization}/databases`,
1034
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
1035
+ ensureAuthorizationToken: true
1036
+ }))
1037
+ );
1038
+ return response.data;
1039
+ });
1040
+ },
1041
+ getDatabase(organization, databaseName, authorization) {
1042
+ return __async(this, null, function* () {
1043
+ const response = yield planetScaleClientInstance.get(
1044
+ `/v1/organizations/${organization}/databases/${databaseName}`,
1045
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
1046
+ ensureAuthorizationToken: true
1047
+ }))
1048
+ );
1049
+ return response.data;
1050
+ });
1051
+ },
1052
+ createDatabase(organization, name, authorization) {
1053
+ return __async(this, null, function* () {
1054
+ const response = yield planetScaleClientInstance.post(
1055
+ `/v1/organizations/${organization}/databases`,
1056
+ {
1057
+ name
1058
+ },
1059
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
1060
+ ensureAuthorizationToken: true
1061
+ }))
1062
+ );
1063
+ return response.data;
1064
+ });
1065
+ },
1066
+ removeDatabase(organization, databaseName, authorization) {
1067
+ return __async(this, null, function* () {
1068
+ yield planetScaleClientInstance.delete(
1069
+ `/v1/organizations/${organization}/databases/${databaseName}`,
1070
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
1071
+ ensureAuthorizationToken: true
1072
+ }))
1073
+ );
1074
+ });
1075
+ }
1076
+ };
1077
+
1078
+ // src/apis/integrations/planetscale/organization/api.ts
1079
+ var planescaleOrganizationApi = {
1080
+ getOrganizations(authorization) {
1081
+ return __async(this, null, function* () {
1082
+ const response = yield planetScaleClientInstance.get(
1083
+ `/v1/organizations`,
1084
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
1085
+ ensureAuthorizationToken: true
1086
+ }))
1087
+ );
1088
+ return response.data;
1089
+ });
1090
+ },
1091
+ getOrganization(organization, authorization) {
1092
+ return __async(this, null, function* () {
1093
+ const response = yield planetScaleClientInstance.get(
1094
+ `/v1/organizations/${organization}`,
1095
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
1096
+ ensureAuthorizationToken: true
1097
+ }))
1098
+ );
1099
+ return response.data;
1100
+ });
1101
+ }
1102
+ };
1103
+
1104
+ // src/apis/integrations/planetscale/user/api.ts
1105
+ var planescaleUserApi = {
1106
+ getUser(authorization) {
1107
+ return __async(this, null, function* () {
1108
+ const response = yield planetScaleClientInstance.get(
1109
+ `/v1/user`,
1110
+ getPlanetScaleClientConfig(__spreadProps(__spreadValues({}, authorization), {
1111
+ ensureAuthorizationToken: true
1112
+ }))
1113
+ );
1114
+ return response.data;
1115
+ });
1116
+ }
1117
+ };
1118
+
1119
+ // src/apis/integrations/planetscale/api.ts
1120
+ var planetscaleApi = {
1121
+ database: planescaleDatabaseApi,
1122
+ organization: planescaleOrganizationApi,
1123
+ user: planescaleUserApi,
1124
+ getToken(applicationId, organization, code, clientId, clientSecret, serviceTokenId, serviceToken, redirectUrl) {
1125
+ return __async(this, null, function* () {
1126
+ const data = new URLSearchParams({
1127
+ code,
1128
+ client_id: clientId,
1129
+ client_secret: clientSecret,
1130
+ redirect_uri: redirectUrl,
1131
+ grant_type: "authorization_code"
1132
+ });
1133
+ const response = yield axios5.post(
1134
+ `https://api.planetscale.com/v1/organizations/${organization}/oauth-applications/${applicationId}/token`,
1135
+ data,
1136
+ {
1137
+ headers: {
1138
+ "Content-Type": "application/x-www-form-urlencoded",
1139
+ Authorization: `${serviceTokenId}:${serviceToken}`
1140
+ }
1141
+ }
1142
+ );
1143
+ return {
1144
+ tokenId: response.data.id,
1145
+ token: response.data.token,
1146
+ refreshToken: response.data.plain_text_refresh_token
1147
+ };
1148
+ });
1149
+ }
1150
+ };
1151
+
1152
+ // src/apis/integrations/sentry/instance.ts
1153
+ import axios6 from "axios";
1154
+ var sentryClientInstance = axios6.create({
1155
+ baseURL: "https://sentry.io/api/0/",
1156
+ headers: {
1157
+ ["Content-Type"]: "application/json"
1158
+ }
1159
+ });
1160
+ sentryClientInstance.interceptors.response.use(
1161
+ (r) => r,
1162
+ (error) => {
1163
+ var _a;
1164
+ if (axios6.isAxiosError(error)) {
1165
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
1166
+ error = new UnauthorizeApiError("sentry");
1167
+ }
1168
+ }
1169
+ throw error;
1170
+ }
1171
+ );
1172
+ function getSentryClientAuthorization(req) {
1173
+ return {
1174
+ token: req.headers["sentry-token"]
1175
+ };
1176
+ }
1177
+ function getSentryClientConfig(options = {}) {
1178
+ const defaultAuthorization = sentryClientInstance.defaults.headers["Authorization"];
1179
+ const headers = {
1180
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
1181
+ };
1182
+ return {
1183
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
1184
+ };
1185
+ }
1186
+ function initSentryClientInstance(token) {
1187
+ updateSentryClientInstance(token);
1188
+ if (token) {
1189
+ updateSentryClientInstance(token);
1190
+ }
1191
+ }
1192
+ function updateSentryClientInstance(token) {
1193
+ if (token) {
1194
+ sentryClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
1195
+ } else {
1196
+ delete sentryClientInstance.defaults.headers["Authorization"];
1197
+ }
1198
+ }
1199
+
1200
+ // src/apis/integrations/sentry/api.ts
1201
+ var sentryApi = {
1202
+ getTeam(teamSlug, authorization) {
1203
+ return __async(this, null, function* () {
1204
+ const response = yield sentryClientInstance.get(
1205
+ `/teams/${teamSlug}/`,
1206
+ getSentryClientConfig(authorization)
1207
+ );
1208
+ return response.data;
1209
+ });
1210
+ },
1211
+ getOrganizations(authorization) {
1212
+ return __async(this, null, function* () {
1213
+ const response = yield sentryClientInstance.get(
1214
+ "/organizations/",
1215
+ getSentryClientConfig(authorization)
1216
+ );
1217
+ return response.data;
1218
+ });
1219
+ },
1220
+ getOrganization(organizationSlug, authorization) {
1221
+ return __async(this, null, function* () {
1222
+ const response = yield sentryClientInstance.get(
1223
+ `/organizations/${organizationSlug}/`,
1224
+ getSentryClientConfig(authorization)
1225
+ );
1226
+ return response.data;
1227
+ });
1228
+ },
1229
+ getOrganizationRepos(organizationSlug, authorization) {
1230
+ return __async(this, null, function* () {
1231
+ const response = yield sentryClientInstance.get(
1232
+ `/organizations/${organizationSlug}/repos/`,
1233
+ getSentryClientConfig(authorization)
1234
+ );
1235
+ return response.data;
1236
+ });
1237
+ },
1238
+ getOrganizationIntegrations(organizationSlug, authorization) {
1239
+ return __async(this, null, function* () {
1240
+ const response = yield sentryClientInstance.get(
1241
+ `/organizations/${organizationSlug}/integrations/`,
1242
+ getSentryClientConfig(authorization)
1243
+ );
1244
+ return response.data;
1245
+ });
1246
+ },
1247
+ getProjects(authorization) {
1248
+ return __async(this, null, function* () {
1249
+ const response = yield sentryClientInstance.get(
1250
+ "/projects/",
1251
+ getSentryClientConfig(authorization)
1252
+ );
1253
+ return response.data;
1254
+ });
1255
+ },
1256
+ getProject(projectFullName, authorization) {
1257
+ return __async(this, null, function* () {
1258
+ const response = yield sentryClientInstance.get(
1259
+ `/projects/${projectFullName}/`,
1260
+ getSentryClientConfig(authorization)
1261
+ );
1262
+ return response.data;
1263
+ });
1264
+ },
1265
+ getProjectIssues(projectFullName, authorization) {
1266
+ return __async(this, null, function* () {
1267
+ const response = yield sentryClientInstance.get(
1268
+ `/projects/${projectFullName}/issues/`,
1269
+ getSentryClientConfig(authorization)
1270
+ );
1271
+ return response.data;
1272
+ });
1273
+ },
1274
+ getProjectIssueLatestEvent(issueId, authorization) {
1275
+ return __async(this, null, function* () {
1276
+ const response = yield sentryClientInstance.get(
1277
+ `/issues/${issueId}/events/latest/`,
1278
+ getSentryClientConfig(authorization)
1279
+ );
1280
+ return response.data;
1281
+ });
1282
+ },
1283
+ getProjectKeys(projectFullName, authorization) {
1284
+ return __async(this, null, function* () {
1285
+ const response = yield sentryClientInstance.get(
1286
+ `/projects/${projectFullName}/keys/`,
1287
+ getSentryClientConfig(authorization)
1288
+ );
1289
+ return response.data;
1290
+ });
1291
+ },
1292
+ createTeam(organizationSlug, teamName, authorization) {
1293
+ return __async(this, null, function* () {
1294
+ const { data: team } = yield sentryClientInstance.post(
1295
+ `/organizations/${organizationSlug}/teams/`,
1296
+ {
1297
+ name: teamName,
1298
+ slug: teamName
1299
+ },
1300
+ getSentryClientConfig(authorization)
1301
+ );
1302
+ return team;
1303
+ });
1304
+ },
1305
+ createRepo(organizationSlug, projectId, repositoryFullName, repositoryBranch, githubIntegrationId, authorization) {
1306
+ return __async(this, null, function* () {
1307
+ var _a, _b, _c, _d;
1308
+ let repository;
1309
+ try {
1310
+ const response = yield sentryClientInstance.post(
1311
+ `/organizations/${organizationSlug}/repos/`,
1312
+ {
1313
+ installation: githubIntegrationId,
1314
+ identifier: repositoryFullName,
1315
+ provider: "integrations:github"
1316
+ },
1317
+ getSentryClientConfig(authorization)
1318
+ );
1319
+ repository = response.data;
1320
+ } catch (err) {
1321
+ const error = err;
1322
+ if (((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error_type) === "validation" || ((_d = (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.error_type) === "unknown") {
1323
+ throw error;
1324
+ }
1325
+ const response = yield sentryClientInstance.get(
1326
+ `/organizations/${organizationSlug}/repos/`,
1327
+ getSentryClientConfig(authorization)
1328
+ );
1329
+ repository = response.data.find(
1330
+ (repo) => repo.externalSlug === repositoryFullName
1331
+ );
1332
+ }
1333
+ if (!repository) {
1334
+ throw new Error("Couldn't get repository");
1335
+ }
1336
+ try {
1337
+ yield sentryClientInstance.post(
1338
+ `/organizations/${organizationSlug}/code-mappings/`,
1339
+ {
1340
+ defaultBranch: repositoryBranch,
1341
+ stackRoot: "",
1342
+ sourceRoot: "",
1343
+ repositoryId: repository.id,
1344
+ integrationId: githubIntegrationId,
1345
+ projectId
1346
+ },
1347
+ getSentryClientConfig(authorization)
1348
+ );
1349
+ } catch (e) {
1350
+ }
1351
+ });
1352
+ },
1353
+ createProject(organizationSlug, appName, authorization) {
1354
+ return __async(this, null, function* () {
1355
+ var _a;
1356
+ const name = appName.toLowerCase();
1357
+ try {
1358
+ yield this.createTeam(organizationSlug, name, authorization);
1359
+ } catch (e) {
1360
+ }
1361
+ try {
1362
+ const response = yield sentryClientInstance.post(
1363
+ `/teams/${organizationSlug}/${name}/projects/`,
1364
+ {
1365
+ name,
1366
+ slug: name
1367
+ },
1368
+ getSentryClientConfig(authorization)
1369
+ );
1370
+ return yield this.getProject(
1371
+ `${organizationSlug}/${response.data.slug}`,
1372
+ authorization
1373
+ );
1374
+ } catch (error) {
1375
+ if (((_a = error.response) == null ? void 0 : _a.status) === 409) {
1376
+ return yield this.getProject(
1377
+ `${organizationSlug}/${name}`,
1378
+ authorization
1379
+ );
1380
+ }
1381
+ throw error;
1382
+ }
1383
+ });
1384
+ },
1385
+ deleteProject(projectFullName, authorization) {
1386
+ return __async(this, null, function* () {
1387
+ const response = yield sentryClientInstance.delete(
1388
+ `/projects/${projectFullName}/`,
1389
+ getSentryClientConfig(authorization)
1390
+ );
1391
+ return response.data;
1392
+ });
1393
+ }
1394
+ };
1395
+
1396
+ // src/apis/integrations/vercel/api.ts
1397
+ import axios8 from "axios";
1398
+
1399
+ // src/apis/integrations/vercel/instance.ts
1400
+ import axios7 from "axios";
1401
+ var vercelClientInstance = axios7.create({
1402
+ baseURL: "https://api.vercel.com"
1403
+ });
1404
+ vercelClientInstance.interceptors.response.use(
1405
+ (r) => r,
1406
+ (error) => {
1407
+ var _a;
1408
+ if (axios7.isAxiosError(error)) {
1409
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
1410
+ error = new UnauthorizeApiError("vercel");
1411
+ }
1412
+ }
1413
+ throw error;
1414
+ }
1415
+ );
1416
+ function getVercelClientAuthorization(req) {
1417
+ return {
1418
+ token: req.headers["vercel-token"]
1419
+ };
1420
+ }
1421
+ function getVercelClientConfig(options = {}) {
1422
+ const defaultAuthorization = vercelClientInstance.defaults.headers["Authorization"];
1423
+ const headers = {
1424
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
1425
+ };
1426
+ return {
1427
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
1428
+ };
1429
+ }
1430
+ function initVercelClientInstance(token) {
1431
+ if (token) {
1432
+ updateVercelClientInstance(token);
1433
+ }
1434
+ }
1435
+ function updateVercelClientInstance(token) {
1436
+ if (token) {
1437
+ vercelClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
1438
+ } else {
1439
+ delete vercelClientInstance.defaults.headers["Authorization"];
1440
+ }
1441
+ }
1442
+
1443
+ // src/apis/integrations/vercel/deploy/api.ts
1444
+ var vercelDeployApi = {
1445
+ createDeploy(project, repoId, branch, authorization) {
1446
+ return __async(this, null, function* () {
1447
+ const response = yield vercelClientInstance.post(
1448
+ `/v13/deployments`,
1449
+ {
1450
+ gitSource: { type: "github", ref: branch, repoId },
1451
+ name: project,
1452
+ target: "production",
1453
+ source: "import"
1454
+ },
1455
+ getVercelClientConfig(authorization)
1456
+ );
1457
+ return response.data;
1458
+ });
1459
+ }
1460
+ };
1461
+
1462
+ // src/apis/integrations/vercel/integrations/api.ts
1463
+ var vercelIntegrationApi = {
1464
+ getGitNamespaces(authorization) {
1465
+ return __async(this, null, function* () {
1466
+ const response = yield vercelClientInstance.get(
1467
+ `/v1/integrations/git-namespaces?provider=github`,
1468
+ getVercelClientConfig(authorization)
1469
+ );
1470
+ return response.data;
1471
+ });
1472
+ },
1473
+ getGitRepos(repositoryName, namespaceId, authorization) {
1474
+ return __async(this, null, function* () {
1475
+ var _a;
1476
+ try {
1477
+ const response = yield vercelClientInstance.get(
1478
+ `/v1/integrations/search-repo?provider=github${repositoryName ? "&query=" + repositoryName : ""}${namespaceId ? "&namespaceId=" + namespaceId : ""}`,
1479
+ getVercelClientConfig(authorization)
1480
+ );
1481
+ return {
1482
+ provider: response.data.gitAccount.provider,
1483
+ namespaceId: response.data.gitAccount.namespaceId,
1484
+ repos: response.data.repos
1485
+ };
1486
+ } catch (err) {
1487
+ const error = err;
1488
+ if (error.isAxiosError && ((_a = error.response) == null ? void 0 : _a.data.error.code) === "installation_not_found") {
1489
+ return {
1490
+ repos: []
1491
+ };
1492
+ }
1493
+ throw error;
1494
+ }
1495
+ });
1496
+ },
1497
+ isRepositoryAccessible(repositoryName, authorization) {
1498
+ return __async(this, null, function* () {
1499
+ var _a;
1500
+ try {
1501
+ const namespaces = yield this.getGitNamespaces(authorization);
1502
+ const accessibleNamespaceId = namespaces.length > 0 ? (yield Promise.all(
1503
+ namespaces.map(
1504
+ (namespace) => this.getGitRepos(repositoryName, namespace.id, authorization)
1505
+ )
1506
+ )).map(
1507
+ (repositories) => repositories.repos.length > 0 ? repositories.namespaceId : void 0
1508
+ )[0] : (_a = yield this.getGitRepos(repositoryName, void 0, authorization)) == null ? void 0 : _a.namespaceId;
1509
+ return {
1510
+ isAccessible: !!accessibleNamespaceId,
1511
+ installationId: accessibleNamespaceId
1512
+ };
1513
+ } catch (err) {
1514
+ return {
1515
+ isAccessible: false
1516
+ };
1517
+ }
1518
+ });
1519
+ },
1520
+ isUserConnectedToGitHub(authorization) {
1521
+ return __async(this, null, function* () {
1522
+ try {
1523
+ const { provider } = yield this.getGitRepos(
1524
+ void 0,
1525
+ void 0,
1526
+ authorization
1527
+ );
1528
+ return provider === "github";
1529
+ } catch (e) {
1530
+ return false;
1531
+ }
1532
+ });
1533
+ }
1534
+ };
1535
+
1536
+ // src/apis/integrations/vercel/project/api.ts
1537
+ var vercelProjectApi = {
1538
+ getProjects(authorization) {
1539
+ return __async(this, null, function* () {
1540
+ const response = yield vercelClientInstance.get(
1541
+ "/v9/projects",
1542
+ getVercelClientConfig(authorization)
1543
+ );
1544
+ return response.data;
1545
+ });
1546
+ },
1547
+ getProject(projectId, authorization) {
1548
+ return __async(this, null, function* () {
1549
+ const response = yield vercelClientInstance.get(
1550
+ `/v9/projects/${projectId}`,
1551
+ getVercelClientConfig(authorization)
1552
+ );
1553
+ return response.data;
1554
+ });
1555
+ },
1556
+ createProject(name, repositoryFullName, branch, authorization) {
1557
+ return __async(this, null, function* () {
1558
+ const response = yield vercelClientInstance.post(
1559
+ `/v9/projects`,
1560
+ {
1561
+ name,
1562
+ gitRepository: {
1563
+ type: "github",
1564
+ repo: repositoryFullName,
1565
+ sourceless: true
1566
+ },
1567
+ framework: "nextjs"
1568
+ },
1569
+ getVercelClientConfig(authorization)
1570
+ );
1571
+ return response.data;
1572
+ });
1573
+ },
1574
+ removeProject(projectId, authorization) {
1575
+ return __async(this, null, function* () {
1576
+ yield vercelClientInstance.delete(
1577
+ `/projects/${projectId}`,
1578
+ getVercelClientConfig(authorization)
1579
+ );
1580
+ });
1581
+ },
1582
+ getProjectEnvs(projectId, authorization) {
1583
+ return __async(this, null, function* () {
1584
+ const {
1585
+ data: { envs }
1586
+ } = yield vercelClientInstance.get(`/v9/projects/${projectId}/env`, getVercelClientConfig(authorization));
1587
+ return envs;
1588
+ });
1589
+ },
1590
+ getProjectEnv(projectId, envId, authorization) {
1591
+ return __async(this, null, function* () {
1592
+ const { data } = yield vercelClientInstance.get(
1593
+ `/v9/projects/${projectId}/env/${envId}`,
1594
+ getVercelClientConfig(authorization)
1595
+ );
1596
+ return data;
1597
+ });
1598
+ },
1599
+ getProjectEnvByKey(projectId, envKey, authorization) {
1600
+ return __async(this, null, function* () {
1601
+ const envs = yield this.getProjectEnvs(projectId, authorization);
1602
+ const env = envs.find((env2) => envKey === env2.key);
1603
+ if (!env) {
1604
+ return;
1605
+ }
1606
+ return yield this.getProjectEnv(projectId, env.id, authorization);
1607
+ });
1608
+ },
1609
+ createProjectEnv(projectId, key, value, envs, authorization) {
1610
+ return __async(this, null, function* () {
1611
+ if (!envs) {
1612
+ const response = yield vercelClientInstance.get(`/v9/projects/${projectId}/env`, getVercelClientConfig(authorization));
1613
+ envs = response.data.envs;
1614
+ }
1615
+ const existingEnv = envs.find((env) => env.key === key);
1616
+ if (existingEnv) {
1617
+ const { data: editedEnv } = yield vercelClientInstance.patch(
1618
+ `/v9/projects/${projectId}/env/${existingEnv == null ? void 0 : existingEnv.id}`,
1619
+ {
1620
+ key,
1621
+ value,
1622
+ type: "encrypted",
1623
+ target: ["production", "preview", "development"]
1624
+ },
1625
+ getVercelClientConfig(authorization)
1626
+ );
1627
+ return editedEnv;
1628
+ } else {
1629
+ const { data: createdEnv } = yield vercelClientInstance.post(
1630
+ `/v9/projects/${projectId}/env`,
1631
+ {
1632
+ key,
1633
+ value,
1634
+ type: "encrypted",
1635
+ target: ["production", "preview", "development"]
1636
+ },
1637
+ getVercelClientConfig(authorization)
1638
+ );
1639
+ return createdEnv;
1640
+ }
1641
+ });
1642
+ }
1643
+ };
1644
+
1645
+ // src/apis/integrations/vercel/api.ts
1646
+ var vercelApi = {
1647
+ project: vercelProjectApi,
1648
+ deploy: vercelDeployApi,
1649
+ integrations: vercelIntegrationApi,
1650
+ getToken(code, clientId, clientSecret, redirectUrl) {
1651
+ return __async(this, null, function* () {
1652
+ const data = new URLSearchParams({
1653
+ code,
1654
+ client_id: clientId,
1655
+ client_secret: clientSecret,
1656
+ redirect_uri: redirectUrl
1657
+ });
1658
+ const response = yield axios8.post(
1659
+ "https://api.vercel.com/v2/oauth/access_token",
1660
+ data,
1661
+ {
1662
+ headers: {
1663
+ "Content-Type": "application/x-www-form-urlencoded"
1664
+ }
1665
+ }
1666
+ );
1667
+ return {
1668
+ token: response.data.access_token,
1669
+ installationId: response.data.installation_id,
1670
+ userId: response.data.user_id,
1671
+ teamId: response.data.team_id
1672
+ };
1673
+ });
1674
+ }
1675
+ };
1676
+
1677
+ // src/apis/integrations/api.ts
1678
+ var integrationsApi = {
1679
+ github: gitHubApi,
1680
+ netlify: netlifyApi,
1681
+ vercel: vercelApi,
1682
+ planetscale: planetscaleApi,
1683
+ sentry: sentryApi
1684
+ };
1685
+
1686
+ // src/apis/products/livechat/instance.ts
1687
+ import axios9 from "axios";
1688
+ var REGION = {
1689
+ FRA: "fra",
1690
+ DAL: "dal",
1691
+ FRA_A: "fra-a",
1692
+ FRA_B: "fra-b"
1693
+ };
1694
+ var supportedRegions = Object.values(REGION);
1695
+ var getRegion = (token) => {
1696
+ const region = token.split(":")[0];
1697
+ if (supportedRegions.includes(region)) {
1698
+ return region;
1699
+ }
1700
+ return void 0;
1701
+ };
1702
+ var livechatClientInstance = axios9.create({
1703
+ baseURL: "https://api.labs.livechatinc.com"
1704
+ });
1705
+ function getLiveChatClientAuthorization(req) {
1706
+ return {
1707
+ token: req.headers["livechat-token"]
1708
+ };
1709
+ }
1710
+ function getLiveChatClientConfig(options = {}) {
1711
+ const defaultAuthorization = livechatClientInstance.defaults.headers["Authorization"];
1712
+ const headers = {
1713
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
1714
+ };
1715
+ return {
1716
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
1717
+ };
1718
+ }
1719
+ function initLiveChatClientInstance(baseUrl, token) {
1720
+ const region = token ? getRegion(token) : void 0;
1721
+ if (baseUrl) {
1722
+ livechatClientInstance.interceptors.request.use(
1723
+ (config) => __async(this, null, function* () {
1724
+ config.baseURL = baseUrl;
1725
+ return config;
1726
+ }),
1727
+ (error) => Promise.reject(error)
1728
+ );
1729
+ }
1730
+ if (region) {
1731
+ livechatClientInstance.defaults.headers["X-Region"] = region;
1732
+ }
1733
+ if (token) {
1734
+ livechatClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
1735
+ } else {
1736
+ delete livechatClientInstance.defaults.headers["Authorization"];
1737
+ }
1738
+ }
1739
+
1740
+ // src/apis/products/livechat/agents/api.ts
1741
+ var livechatAgentApi = {
1742
+ getUser() {
1743
+ return __async(this, null, function* () {
1744
+ try {
1745
+ const response = yield livechatClientInstance.get(
1746
+ `/agents/me`,
1747
+ {
1748
+ headers: {
1749
+ "X-API-Version": 2
1750
+ }
1751
+ }
1752
+ );
1753
+ return response.data;
1754
+ } catch (error) {
1755
+ if (error instanceof Error) {
1756
+ throw new Error(`User couldn't be fetched. [${error.message}]`);
1757
+ }
1758
+ throw error;
1759
+ }
1760
+ });
1761
+ }
1762
+ };
1763
+
1764
+ // src/constants/notifications.ts
1765
+ var API_NOTIFICATIONS = {
1766
+ BUILDING_BLOCKS: {
1767
+ SUCCESS: {
1768
+ CREATED: "Building block created successfully.",
1769
+ UPDATED: "Building block updated successfully.",
1770
+ DELETED: "Building block deleted successfully."
1771
+ },
1772
+ FAILURE: {
1773
+ CREATED: "Building block couldn't be created.",
1774
+ UPDATED: "Building block couldn't be updated.",
1775
+ DELETED: "Building block couldn't be deleted."
1776
+ }
1777
+ }
1778
+ };
1779
+
1780
+ // src/apis/products/livechat/configuration/properties/api.ts
1781
+ var livechatPropertyApi = {
1782
+ getProperties(clientId, isAgent) {
1783
+ return __async(this, null, function* () {
1784
+ if (isAgent) {
1785
+ return {
1786
+ data: {}
1787
+ };
1788
+ }
1789
+ try {
1790
+ const response = yield livechatClientInstance.post(
1791
+ `/v3.3/configuration/action/list_properties`,
1792
+ {
1793
+ owner_client_id: clientId
1794
+ }
1795
+ );
1796
+ return response;
1797
+ } catch (error) {
1798
+ if (error instanceof Error) {
1799
+ throw new Error(`Properties couldn't be fetched. [${error.message}]`);
1800
+ } else {
1801
+ throw error;
1802
+ }
1803
+ }
1804
+ });
1805
+ },
1806
+ registerProperty(property) {
1807
+ return __async(this, null, function* () {
1808
+ try {
1809
+ const response = yield livechatClientInstance.post(
1810
+ `/v3.3/configuration/action/register_property`,
1811
+ {
1812
+ name: property.name,
1813
+ owner_client_id: property.owner_client_id,
1814
+ type: property.type,
1815
+ access: property.access,
1816
+ description: property.description,
1817
+ domain: property.domain,
1818
+ range: property.range,
1819
+ default_value: property.default_value
1820
+ }
1821
+ );
1822
+ return response;
1823
+ } catch (error) {
1824
+ if (error instanceof Error) {
1825
+ throw new Error(`Property couldn't be created. [${error.message}]`);
1826
+ } else {
1827
+ throw error;
1828
+ }
1829
+ }
1830
+ });
1831
+ },
1832
+ unregisterProperty(propertyId, clientId, properties) {
1833
+ return __async(this, null, function* () {
1834
+ try {
1835
+ const response = yield livechatClientInstance.post(
1836
+ `/v3.3/configuration/action/unregister_property`,
1837
+ {
1838
+ name: propertyId,
1839
+ owner_client_id: clientId
1840
+ }
1841
+ );
1842
+ return response;
1843
+ } catch (error) {
1844
+ if (error instanceof Error) {
1845
+ if (properties) {
1846
+ throw new Error(
1847
+ `${properties.length > 1 ? "Property couldn't be deleted." : API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.DELETED} [${error.message}]`
1848
+ );
1849
+ } else {
1850
+ throw new Error(`Property couldn't be deleted. [${error.message}]`);
1851
+ }
1852
+ } else {
1853
+ throw error;
1854
+ }
1855
+ }
1856
+ });
1857
+ },
1858
+ publishProperty(propertyId, clientId, accessType) {
1859
+ return __async(this, null, function* () {
1860
+ try {
1861
+ const response = yield livechatClientInstance.post(
1862
+ `/v3.3/configuration/action/publish_property`,
1863
+ {
1864
+ name: propertyId,
1865
+ owner_client_id: clientId,
1866
+ access_type: accessType
1867
+ }
1868
+ );
1869
+ return response;
1870
+ } catch (error) {
1871
+ if (error instanceof Error) {
1872
+ throw new Error(`Property couldn't be published. [${error.message}]`);
1873
+ } else {
1874
+ throw error;
1875
+ }
1876
+ }
1877
+ });
1878
+ },
1879
+ publishProperties(properties) {
1880
+ return __async(this, null, function* () {
1881
+ try {
1882
+ const response = yield Promise.all(
1883
+ properties.filter((property) => property.public_access).map((property) => __async(this, null, function* () {
1884
+ return yield livechatClientInstance.post(
1885
+ `/v3.3/configuration/action/publish_property`,
1886
+ {
1887
+ name: property.name,
1888
+ owner_client_id: property.owner_client_id,
1889
+ access_type: property.public_access
1890
+ }
1891
+ );
1892
+ }))
1893
+ );
1894
+ return response;
1895
+ } catch (error) {
1896
+ if (error instanceof Error) {
1897
+ throw new Error(`Properties couldn't be published. [${error.message}]`);
1898
+ } else {
1899
+ throw error;
1900
+ }
1901
+ }
1902
+ });
1903
+ },
1904
+ registerProperties(properties) {
1905
+ return __async(this, null, function* () {
1906
+ try {
1907
+ const response = yield Promise.all(
1908
+ properties.map((property) => __async(this, null, function* () {
1909
+ return yield livechatClientInstance.post(
1910
+ `/v3.3/configuration/action/register_property`,
1911
+ {
1912
+ name: property.name,
1913
+ type: property.type,
1914
+ owner_client_id: property.owner_client_id,
1915
+ domain: property.domain,
1916
+ range: property.range,
1917
+ access: property.access,
1918
+ default_value: property.default_value
1919
+ }
1920
+ );
1921
+ }))
1922
+ );
1923
+ return response;
1924
+ } catch (error) {
1925
+ if (error instanceof Error) {
1926
+ throw new Error(`Properties couldn't be created. [${error.message}]`);
1927
+ } else {
1928
+ throw error;
1929
+ }
1930
+ }
1931
+ });
1932
+ },
1933
+ unregisterProperties(clientId) {
1934
+ return __async(this, null, function* () {
1935
+ const { data: properties } = yield this.getProperties(clientId);
1936
+ try {
1937
+ yield Promise.all(
1938
+ Object.keys(properties).map((property) => __async(this, null, function* () {
1939
+ if (Object.keys(properties[property]).indexOf("public_access") <= 0) {
1940
+ return yield livechatClientInstance.post(
1941
+ `/v3.3/configuration/action/unregister_property`,
1942
+ {
1943
+ name: property,
1944
+ owner_client_id: clientId
1945
+ }
1946
+ );
1947
+ }
1948
+ }))
1949
+ );
1950
+ } catch (error) {
1951
+ if (error instanceof Error) {
1952
+ throw new Error(`Properties couldn't be removed. [${error.message}]`);
1953
+ } else {
1954
+ throw error;
1955
+ }
1956
+ }
1957
+ });
1958
+ }
1959
+ };
1960
+
1961
+ // src/apis/products/livechat/configuration/webhooks/api.ts
1962
+ var livechatWebhookApi = {
1963
+ getWebhooks(clientId, isAgent) {
1964
+ return __async(this, null, function* () {
1965
+ if (isAgent) {
1966
+ return {
1967
+ data: []
1968
+ };
1969
+ }
1970
+ try {
1971
+ const response = yield livechatClientInstance.post(
1972
+ `/v3.5/configuration/action/list_webhooks`,
1973
+ {
1974
+ owner_client_id: clientId
1975
+ }
1976
+ );
1977
+ return response;
1978
+ } catch (error) {
1979
+ if (error instanceof Error) {
1980
+ throw new Error(
1981
+ `Registered Webhooks couldn't be fetched. [${error.message}]`
1982
+ );
1983
+ } else {
1984
+ throw error;
1985
+ }
1986
+ }
1987
+ });
1988
+ },
1989
+ unregisterWebhook(clientId, webhookId) {
1990
+ return __async(this, null, function* () {
1991
+ try {
1992
+ const response = yield livechatClientInstance.post(
1993
+ `/v3.5/configuration/action/unregister_webhook`,
1994
+ {
1995
+ id: webhookId,
1996
+ owner_client_id: clientId
1997
+ }
1998
+ );
1999
+ return response;
2000
+ } catch (error) {
2001
+ if (error instanceof Error) {
2002
+ throw new Error(
2003
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.DELETED} [${error.message}]`
2004
+ );
2005
+ } else {
2006
+ throw error;
2007
+ }
2008
+ }
2009
+ });
2010
+ },
2011
+ unregisterWebhooks(clientId) {
2012
+ return __async(this, null, function* () {
2013
+ try {
2014
+ const { data: webhooks } = yield this.getWebhooks(clientId);
2015
+ yield Promise.all(
2016
+ webhooks.map((webhook) => __async(this, null, function* () {
2017
+ return yield livechatClientInstance.post(
2018
+ `/v3.5/configuration/action/unregister_webhook`,
2019
+ {
2020
+ id: webhook.id,
2021
+ owner_client_id: clientId
2022
+ }
2023
+ );
2024
+ }))
2025
+ );
2026
+ } catch (error) {
2027
+ if (error instanceof Error) {
2028
+ throw new Error(
2029
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.DELETED} [${error.message}]`
2030
+ );
2031
+ } else {
2032
+ throw error;
2033
+ }
2034
+ }
2035
+ });
2036
+ },
2037
+ registerWebhooks(webhooks) {
2038
+ return __async(this, null, function* () {
2039
+ try {
2040
+ yield this.unregisterWebhooks(webhooks[0]["owner_client_id"]);
2041
+ yield Promise.all(
2042
+ webhooks.map((webhook) => __async(this, null, function* () {
2043
+ return yield livechatClientInstance.post(
2044
+ `/v${webhook.api_version || "3.5"}/configuration/action/register_webhook`,
2045
+ {
2046
+ url: webhook.url,
2047
+ action: webhook.action,
2048
+ secret_key: webhook.secret_key,
2049
+ owner_client_id: webhook.owner_client_id,
2050
+ type: webhook.type,
2051
+ description: webhook.description,
2052
+ filters: webhook.filters
2053
+ }
2054
+ );
2055
+ }))
2056
+ );
2057
+ } catch (error) {
2058
+ if (error instanceof Error) {
2059
+ throw new Error(
2060
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.CREATED} [${error.message}]`
2061
+ );
2062
+ } else {
2063
+ throw error;
2064
+ }
2065
+ }
2066
+ });
2067
+ },
2068
+ migrateWebhooks(webhooks, clientId) {
2069
+ return __async(this, null, function* () {
2070
+ try {
2071
+ const webhooksToCheck = webhooks.map((webhook) => {
2072
+ return {
2073
+ api_version: "3.2",
2074
+ action: webhook.action,
2075
+ filters: webhook.filters
2076
+ };
2077
+ });
2078
+ const { data: verifiedWebhooks } = yield livechatClientInstance.post(
2079
+ `/v3.3/configuration/action/check_webhooks_migration`,
2080
+ [...webhooksToCheck]
2081
+ );
2082
+ const updatedWebhooks = webhooks.map((webhook, index) => {
2083
+ return __spreadProps(__spreadValues({}, webhook), {
2084
+ action: verifiedWebhooks[index].action
2085
+ });
2086
+ });
2087
+ yield livechatClientInstance.post(
2088
+ `/v3.3/configuration/action/migrate_webhooks`,
2089
+ {
2090
+ owner_client_id: clientId,
2091
+ webhooks: updatedWebhooks
2092
+ }
2093
+ );
2094
+ } catch (error) {
2095
+ if (error instanceof Error) {
2096
+ throw new Error(
2097
+ `Migration failed. It looks like one of the webhooks you're trying to migrate doesn't exist in the new version or exists under a different name. Migrate the webhook manually via the Configuration API. `
2098
+ );
2099
+ } else {
2100
+ throw error;
2101
+ }
2102
+ }
2103
+ });
2104
+ },
2105
+ getLicenseWebhooksList(isAgent) {
2106
+ return __async(this, null, function* () {
2107
+ if (isAgent) {
2108
+ return {
2109
+ data: []
2110
+ };
2111
+ }
2112
+ try {
2113
+ const response = yield livechatClientInstance.post(
2114
+ `/v3.2/configuration/action/list_registered_webhooks`,
2115
+ {}
2116
+ );
2117
+ return response;
2118
+ } catch (error) {
2119
+ if (error instanceof Error) {
2120
+ throw new Error(
2121
+ `Registered Webhooks couldn't be fetched. [${error.message}]`
2122
+ );
2123
+ } else {
2124
+ throw error;
2125
+ }
2126
+ }
2127
+ });
2128
+ },
2129
+ deleteLicenseWebhook(id) {
2130
+ return __async(this, null, function* () {
2131
+ try {
2132
+ const response = yield livechatClientInstance.post(
2133
+ `/v3.2/configuration/action/unregister_webhook`,
2134
+ { webhook_id: id }
2135
+ );
2136
+ return response;
2137
+ } catch (error) {
2138
+ if (error instanceof Error) {
2139
+ throw new Error(
2140
+ `Registered Webhooks couldn't be deleted. [${error.message}]`
2141
+ );
2142
+ } else {
2143
+ throw error;
2144
+ }
2145
+ }
2146
+ });
2147
+ }
2148
+ };
2149
+
2150
+ // src/apis/products/livechat/configuration/api.ts
2151
+ var livechatConfigurationApi = {
2152
+ property: livechatPropertyApi,
2153
+ webhook: livechatWebhookApi
2154
+ };
2155
+
2156
+ // src/apis/products/livechat/api.ts
2157
+ var livechatApi = {
2158
+ agent: livechatAgentApi,
2159
+ configuration: livechatConfigurationApi
2160
+ };
2161
+
2162
+ // src/apis/products/api.ts
2163
+ var productsApi = {
2164
+ livechat: livechatApi
2165
+ };
2166
+
2167
+ // src/apis/platform/accounts/instance.ts
2168
+ import axios10 from "axios";
2169
+ var platformAccountsClientInstance = axios10.create({
2170
+ baseURL: "https://accounts.labs.livechatinc.com"
2171
+ });
2172
+ function getPlatformAccountsClientAuthorization(req) {
2173
+ return {
2174
+ token: req.headers["platform-accounts-token"]
2175
+ };
2176
+ }
2177
+ function getPlatformAccountsClientConfig(options = {}) {
2178
+ const defaultAuthorization = platformAccountsClientInstance.defaults.headers["Authorization"];
2179
+ const headers = {
2180
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2181
+ };
2182
+ return {
2183
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2184
+ };
2185
+ }
2186
+ function initPlatformAccountsClientInstance(baseUrl, token) {
2187
+ if (baseUrl) {
2188
+ platformAccountsClientInstance.interceptors.request.use(
2189
+ (config) => __async(this, null, function* () {
2190
+ config.baseURL = baseUrl;
2191
+ return config;
2192
+ }),
2193
+ (error) => Promise.reject(error)
2194
+ );
2195
+ }
2196
+ if (token) {
2197
+ platformAccountsClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
2198
+ } else {
2199
+ delete platformAccountsClientInstance.defaults.headers["Authorization"];
2200
+ }
2201
+ }
2202
+
2203
+ // src/apis/platform/accounts/client/api.ts
2204
+ var platformAccountsClientApi = {
2205
+ getClients(authorization) {
2206
+ return __async(this, null, function* () {
2207
+ try {
2208
+ return yield platformAccountsClientInstance.get(
2209
+ `/v2/clients`,
2210
+ getPlatformAccountsClientConfig(authorization)
2211
+ );
2212
+ } catch (error) {
2213
+ if (error instanceof Error) {
2214
+ throw new Error(`Clients couldn't be fetched. [${error.message}]`);
2215
+ } else {
2216
+ throw error;
2217
+ }
2218
+ }
2219
+ });
2220
+ },
2221
+ getClient(clientId, authorization) {
2222
+ return __async(this, null, function* () {
2223
+ try {
2224
+ return yield platformAccountsClientInstance.get(
2225
+ `/v2/clients/${clientId}`,
2226
+ getPlatformAccountsClientConfig(authorization)
2227
+ );
2228
+ } catch (error) {
2229
+ if (error instanceof Error) {
2230
+ throw new Error(`Client couldn't be fetched. [${error.message}]`);
2231
+ } else {
2232
+ throw error;
2233
+ }
2234
+ }
2235
+ });
2236
+ },
2237
+ createClient(payload, authorization) {
2238
+ return __async(this, null, function* () {
2239
+ try {
2240
+ return yield platformAccountsClientInstance.post(
2241
+ `/v2/clients`,
2242
+ payload,
2243
+ getPlatformAccountsClientConfig(authorization)
2244
+ );
2245
+ } catch (error) {
2246
+ if (error instanceof Error) {
2247
+ throw new Error(`Client couldn't be created. [${error.message}]`);
2248
+ } else {
2249
+ throw error;
2250
+ }
2251
+ }
2252
+ });
2253
+ },
2254
+ updateClient(clientId, payload, authorization) {
2255
+ return __async(this, null, function* () {
2256
+ try {
2257
+ return yield platformAccountsClientInstance.patch(
2258
+ `/v2/clients/${clientId}`,
2259
+ payload,
2260
+ getPlatformAccountsClientConfig(authorization)
2261
+ );
2262
+ } catch (error) {
2263
+ if (error instanceof Error) {
2264
+ throw new Error(`Client couldn't be updated. [${error.message}]`);
2265
+ } else {
2266
+ throw error;
2267
+ }
2268
+ }
2269
+ });
2270
+ },
2271
+ deleteClient(clientId, authorization) {
2272
+ return __async(this, null, function* () {
2273
+ try {
2274
+ return yield platformAccountsClientInstance.delete(
2275
+ `/v2/clients/${clientId}`,
2276
+ getPlatformAccountsClientConfig(authorization)
2277
+ );
2278
+ } catch (error) {
2279
+ if (error instanceof Error) {
2280
+ throw new Error(`Client couldn't be deleted. [${error.message}]`);
2281
+ } else {
2282
+ throw error;
2283
+ }
2284
+ }
2285
+ });
2286
+ },
2287
+ updateClientScopes(clientId, scopes, authorization) {
2288
+ return __async(this, null, function* () {
2289
+ try {
2290
+ return yield platformAccountsClientInstance.put(
2291
+ `/v2/clients/${clientId}/scopes`,
2292
+ scopes.map((scope) => ({
2293
+ scope: scope.scope,
2294
+ required: scope.required
2295
+ })),
2296
+ getPlatformAccountsClientConfig(authorization)
2297
+ );
2298
+ } catch (error) {
2299
+ if (error instanceof Error) {
2300
+ throw new Error(`Scopes couldn't be updated. [${error.message}]`);
2301
+ } else {
2302
+ throw error;
2303
+ }
2304
+ }
2305
+ });
2306
+ },
2307
+ deleteClientScopes(clientId, scopes, authorization) {
2308
+ return __async(this, null, function* () {
2309
+ try {
2310
+ return yield platformAccountsClientInstance.delete(
2311
+ `/v2/clients/${clientId}/scopes`,
2312
+ __spreadValues({
2313
+ data: scopes.map((scope) => ({
2314
+ scope: scope.scope,
2315
+ required: scope.required
2316
+ }))
2317
+ }, getPlatformAccountsClientConfig(authorization))
2318
+ );
2319
+ } catch (error) {
2320
+ if (error instanceof Error) {
2321
+ throw new Error(`Scopes couldn't be updated. [${error.message}]`);
2322
+ } else {
2323
+ throw error;
2324
+ }
2325
+ }
2326
+ });
2327
+ },
2328
+ getInfo(authorization) {
2329
+ return __async(this, null, function* () {
2330
+ try {
2331
+ return yield platformAccountsClientInstance.get(
2332
+ `/v2/info`,
2333
+ getPlatformAccountsClientConfig(authorization)
2334
+ );
2335
+ } catch (error) {
2336
+ if (error instanceof Error) {
2337
+ throw new Error(`Info couldn't be fetched. [${error.message}]`);
2338
+ } else {
2339
+ throw error;
2340
+ }
2341
+ }
2342
+ });
2343
+ }
2344
+ };
2345
+
2346
+ // src/apis/platform/accounts/pat/api.ts
2347
+ var platformAccountsPersonalAccessTokenApi = {
2348
+ getPersonalAccessTokens(authorization) {
2349
+ return __async(this, null, function* () {
2350
+ try {
2351
+ const response = yield platformAccountsClientInstance.get(
2352
+ `/v2/personal_token`
2353
+ );
2354
+ return response.data;
2355
+ } catch (error) {
2356
+ if (error instanceof Error) {
2357
+ throw new Error(
2358
+ `Personal Access Token couldn't be fetched. [${error.message}]`
2359
+ );
2360
+ } else {
2361
+ throw error;
2362
+ }
2363
+ }
2364
+ });
2365
+ },
2366
+ createPersonalAccessToken(name, scopes, authorization) {
2367
+ return __async(this, null, function* () {
2368
+ try {
2369
+ const response = yield platformAccountsClientInstance.post(
2370
+ `/v2/personal_token`,
2371
+ {
2372
+ name,
2373
+ scope: scopes && scopes.map((item) => item.name).filter((el) => el).join(",")
2374
+ }
2375
+ );
2376
+ return response.data;
2377
+ } catch (error) {
2378
+ if (error instanceof Error) {
2379
+ throw new Error(
2380
+ `Personal Access Token couldn't be created. [${error.message}]`
2381
+ );
2382
+ } else {
2383
+ throw error;
2384
+ }
2385
+ }
2386
+ });
2387
+ },
2388
+ deletePersonalAccessToken(id, authorization) {
2389
+ return __async(this, null, function* () {
2390
+ try {
2391
+ const response = yield platformAccountsClientInstance.delete(
2392
+ `/v2/personal_token/${id}`,
2393
+ getPlatformAccountsClientConfig(authorization)
2394
+ );
2395
+ return response.data;
2396
+ } catch (error) {
2397
+ if (error instanceof Error) {
2398
+ throw new Error(
2399
+ `Personal Access Token couldn't be deleted. [${error.message}]`
2400
+ );
2401
+ } else {
2402
+ throw error;
2403
+ }
2404
+ }
2405
+ });
2406
+ }
2407
+ };
2408
+
2409
+ // src/apis/platform/accounts/products/api.ts
2410
+ var platformAccountsProductsApi = {
2411
+ getOrganizationProducts(authorization) {
2412
+ return __async(this, null, function* () {
2413
+ try {
2414
+ const response = yield platformAccountsClientInstance.get(
2415
+ `/v2/organizations/my/products`,
2416
+ getPlatformAccountsClientConfig(authorization)
2417
+ );
2418
+ return response.data;
2419
+ } catch (error) {
2420
+ if (error instanceof Error) {
2421
+ throw new Error(`Products couldn't be fetched. [${error.message}]`);
2422
+ } else {
2423
+ throw error;
2424
+ }
2425
+ }
2426
+ });
2427
+ },
2428
+ updateOrganizationProducts(payload, authorization) {
2429
+ return __async(this, null, function* () {
2430
+ try {
2431
+ const response = yield platformAccountsClientInstance.post(
2432
+ `/v2/organizations/my/products`,
2433
+ payload,
2434
+ getPlatformAccountsClientConfig(authorization)
2435
+ );
2436
+ return response.data;
2437
+ } catch (error) {
2438
+ if (error instanceof Error) {
2439
+ throw new Error(`Products couldn't be updated. [${error.message}]`);
2440
+ } else {
2441
+ throw error;
2442
+ }
2443
+ }
2444
+ });
2445
+ }
2446
+ };
2447
+
2448
+ // src/apis/platform/accounts/scopes/api.ts
2449
+ var platformAccountsScopesApi = {
2450
+ getScopes(authorization) {
2451
+ return __async(this, null, function* () {
2452
+ try {
2453
+ const response = yield platformAccountsClientInstance.get(
2454
+ `/v2/scopes`,
2455
+ getPlatformAccountsClientConfig(authorization)
2456
+ );
2457
+ return response.data || [];
2458
+ } catch (error) {
2459
+ if (error instanceof Error) {
2460
+ throw new Error(`Scopes couldn't be fetched. [${error.message}]`);
2461
+ } else {
2462
+ throw error;
2463
+ }
2464
+ }
2465
+ });
2466
+ }
2467
+ };
2468
+
2469
+ // src/apis/platform/accounts/sessions/api.ts
2470
+ var platformAccountsSessionsApi = {
2471
+ deleteSessions(authorization) {
2472
+ return __async(this, null, function* () {
2473
+ try {
2474
+ return yield platformAccountsClientInstance.delete(
2475
+ `/v2/sessions`,
2476
+ getPlatformAccountsClientConfig(authorization)
2477
+ );
2478
+ } catch (error) {
2479
+ if (error instanceof Error) {
2480
+ throw new Error(`Sessions couldn't be deleted. [${error.message}]`);
2481
+ } else {
2482
+ throw error;
2483
+ }
2484
+ }
2485
+ });
2486
+ }
2487
+ };
2488
+
2489
+ // src/apis/platform/accounts/api.ts
2490
+ var platformAccountsApi = {
2491
+ client: platformAccountsClientApi,
2492
+ pat: platformAccountsPersonalAccessTokenApi,
2493
+ products: platformAccountsProductsApi,
2494
+ scopes: platformAccountsScopesApi,
2495
+ sessions: platformAccountsSessionsApi
2496
+ };
2497
+
2498
+ // src/apis/platform/dps/instance.ts
2499
+ import axios11 from "axios";
2500
+ var platformDpsClientInstance = axios11.create({
2501
+ baseURL: "https://dev-platform.labs.livechatinc.com"
2502
+ });
2503
+ function getPlatformDpsClientAuthorization(req) {
2504
+ var _a;
2505
+ return {
2506
+ token: (_a = req.headers["platform-dps-token"]) != null ? _a : req.headers["platform-token"],
2507
+ tokenType: "Bearer"
2508
+ };
2509
+ }
2510
+ function getPlatformDpsAdminClientAuthorization() {
2511
+ const token = process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB : process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB_LABS;
2512
+ return {
2513
+ token: btoa("apps@livechatinc.com:" + token),
2514
+ tokenType: "Basic"
2515
+ };
2516
+ }
2517
+ function getPlatformDpsClientConfig(options = {}) {
2518
+ const defaultAuthorization = platformDpsClientInstance.defaults.headers["Authorization"];
2519
+ const headers = {
2520
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2521
+ };
2522
+ return {
2523
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2524
+ };
2525
+ }
2526
+ function initPlatformDpsClientInstance(baseUrl, token) {
2527
+ if (baseUrl) {
2528
+ platformDpsClientInstance.interceptors.request.use(
2529
+ (config) => __async(this, null, function* () {
2530
+ config.baseURL = baseUrl;
2531
+ return config;
2532
+ }),
2533
+ (error) => Promise.reject(error)
2534
+ );
2535
+ }
2536
+ if (token) {
2537
+ platformDpsClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
2538
+ } else {
2539
+ delete platformDpsClientInstance.defaults.headers["Authorization"];
2540
+ }
2541
+ }
2542
+
2543
+ // src/apis/platform/dps/applications/application/authorization/api.ts
2544
+ var platformDpsApplicationAuthorizationApi = {
2545
+ createAuth(appId, payload, authorization) {
2546
+ return __async(this, null, function* () {
2547
+ try {
2548
+ yield platformDpsClientInstance.post(
2549
+ `/v2/applications/${appId}/authorization`,
2550
+ payload,
2551
+ getPlatformDpsClientConfig(authorization)
2552
+ );
2553
+ } catch (error) {
2554
+ if (error instanceof Error) {
2555
+ throw new Error(
2556
+ `Authorization couldn't be created. [${error.message}]`
2557
+ );
2558
+ }
2559
+ throw error;
2560
+ }
2561
+ });
2562
+ }
2563
+ };
2564
+
2565
+ // src/apis/platform/dps/applications/application/autoReview/_contracts/dtos/autoReview.ts
2566
+ var getEmptyAppAutoReview = () => ({
2567
+ isReviewed: false,
2568
+ recommendations: {
2569
+ listingDetails: {
2570
+ appName: "",
2571
+ shortDescription: "",
2572
+ longDescription: "",
2573
+ features: "",
2574
+ benefits: ""
2575
+ },
2576
+ auth: {
2577
+ hasZeroScopes: false
2578
+ }
2579
+ },
2580
+ errors: {
2581
+ listingDetails: {
2582
+ appName: "",
2583
+ shortDescription: "",
2584
+ longDescription: "",
2585
+ features: "",
2586
+ benefits: ""
2587
+ },
2588
+ auth: {
2589
+ hasAllScopes: false,
2590
+ isRedirectUriSafe: false
2591
+ },
2592
+ links: {
2593
+ tutorial: {
2594
+ returns200: false,
2595
+ isValid: false
2596
+ },
2597
+ privacyPolicy: {
2598
+ returns200: false,
2599
+ isValid: false
2600
+ }
2601
+ },
2602
+ images: {
2603
+ icon: {
2604
+ isNsfw: false,
2605
+ isRatioValid: false
2606
+ },
2607
+ screenshots: {
2608
+ areNsfw: false,
2609
+ areRatiosValid: false
2610
+ }
2611
+ }
2612
+ }
2613
+ });
2614
+
2615
+ // src/apis/platform/dps/applications/application/autoReview/_contracts/payloads/autoReview.ts
2616
+ var getAppAutoReviewPayload = (value) => {
2617
+ return {
2618
+ appName: value,
2619
+ shortDescription: value,
2620
+ longDescription: value,
2621
+ features: value,
2622
+ benefits: value,
2623
+ scopes: value,
2624
+ redirect: value,
2625
+ tutorial: value,
2626
+ privacyPolicy: value,
2627
+ icons: value,
2628
+ screenshots: value
2629
+ };
2630
+ };
2631
+
2632
+ // src/apis/platform/dps/applications/application/autoReview/api.ts
2633
+ var platformDpsApplicationAutoReviewApi = {
2634
+ getAutoReview(appId, authorization) {
2635
+ return __async(this, null, function* () {
2636
+ try {
2637
+ const response = yield platformDpsClientInstance.get(
2638
+ `/v2/applications/${appId}/auto-review`,
2639
+ getPlatformDpsClientConfig(authorization)
2640
+ );
2641
+ if (response.status === 204) {
2642
+ return getEmptyAppAutoReview();
2643
+ }
2644
+ return response.data;
2645
+ } catch (error) {
2646
+ if (error instanceof Error) {
2647
+ throw new Error(`The review couldn\u2019t be completed. [${error.message}]`);
2648
+ }
2649
+ throw error;
2650
+ }
2651
+ });
2652
+ },
2653
+ submitAutoReview(appId, payload, authorization) {
2654
+ return __async(this, null, function* () {
2655
+ try {
2656
+ yield platformDpsClientInstance.post(
2657
+ `/v2/applications/${appId}/auto-review`,
2658
+ payload,
2659
+ getPlatformDpsClientConfig(authorization)
2660
+ );
2661
+ } catch (error) {
2662
+ if (error instanceof Error) {
2663
+ throw new Error(`The review couldn\u2019t be requested. [${error.message}]`);
2664
+ }
2665
+ throw error;
2666
+ }
2667
+ });
2668
+ }
2669
+ };
2670
+
2671
+ // src/apis/platform/dps/applications/application/chatActions/api.ts
2672
+ var platformDpsApplicationChatActionsApi = {
2673
+ createChatAction(appId, payload, authorization) {
2674
+ return __async(this, null, function* () {
2675
+ try {
2676
+ yield platformDpsClientInstance.put(
2677
+ `/v2/applications/${appId}/chat-actions/${payload.id}`,
2678
+ payload,
2679
+ getPlatformDpsClientConfig(authorization)
2680
+ );
2681
+ } catch (error) {
2682
+ if (error instanceof Error) {
2683
+ throw new Error(
2684
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.CREATED} [${error.message}]`
2685
+ );
2686
+ }
2687
+ throw error;
2688
+ }
2689
+ });
2690
+ },
2691
+ updateChatAction(appId, payload, authorization) {
2692
+ return __async(this, null, function* () {
2693
+ try {
2694
+ yield platformDpsClientInstance.patch(
2695
+ `/v2/applications/${appId}/chat-actions/${payload.id}`,
2696
+ payload,
2697
+ getPlatformDpsClientConfig(authorization)
2698
+ );
2699
+ } catch (error) {
2700
+ if (error instanceof Error) {
2701
+ throw new Error(
2702
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.UPDATED} [${error.message}]`
2703
+ );
2704
+ }
2705
+ throw error;
2706
+ }
2707
+ });
2708
+ },
2709
+ deleteChatAction(appId, chatActionId, authorization) {
2710
+ return __async(this, null, function* () {
2711
+ try {
2712
+ yield platformDpsClientInstance.delete(
2713
+ `/v2/applications/${appId}/chat-actions/${chatActionId}`,
2714
+ __spreadValues({}, getPlatformDpsClientConfig(authorization))
2715
+ );
2716
+ } catch (error) {
2717
+ if (error instanceof Error) {
2718
+ throw new Error(
2719
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.DELETED} [${error.message}]`
2720
+ );
2721
+ }
2722
+ throw error;
2723
+ }
2724
+ });
2725
+ }
2726
+ };
2727
+
2728
+ // src/apis/platform/dps/applications/application/chatBoosters/api.ts
2729
+ var platformDpsApplicationChatBoostersApi = {
2730
+ createChatBooster(appId, chatBoosterId, payload, authorization) {
2731
+ try {
2732
+ return platformDpsClientInstance.put(
2733
+ `/v2/applications/${appId}/chat-boosters/${chatBoosterId}`,
2734
+ payload,
2735
+ getPlatformDpsClientConfig(authorization)
2736
+ );
2737
+ } catch (error) {
2738
+ if (error instanceof Error) {
2739
+ throw new Error(`Chat Booster couldn't be created. [${error.message}]`);
2740
+ }
2741
+ throw error;
2742
+ }
2743
+ },
2744
+ updateChatBooster(appId, chatBoosterId, payload, authorization) {
2745
+ return __async(this, null, function* () {
2746
+ try {
2747
+ return yield platformDpsClientInstance.put(
2748
+ `/v2/applications/${appId}/chat-boosters/${chatBoosterId}`,
2749
+ payload,
2750
+ getPlatformDpsClientConfig(authorization)
2751
+ );
2752
+ } catch (error) {
2753
+ if (error instanceof Error) {
2754
+ throw new Error(`Chat Booster couldn't be updated. [${error.message}]`);
2755
+ }
2756
+ throw error;
2757
+ }
2758
+ });
2759
+ }
2760
+ };
2761
+
2762
+ // src/apis/platform/dps/applications/application/display/api.ts
2763
+ var platformDpsApplicationDisplayApi = {
2764
+ updateVersionHistory(appId, payload, authorization) {
2765
+ return __async(this, null, function* () {
2766
+ try {
2767
+ const response = yield platformDpsClientInstance.put(
2768
+ `/v2/applications/${appId}/display/changelog`,
2769
+ payload,
2770
+ getPlatformDpsClientConfig(authorization)
2771
+ );
2772
+ return response.data;
2773
+ } catch (error) {
2774
+ if (error instanceof Error) {
2775
+ throw new Error(
2776
+ `Listing details couldn't be updated. [${error.message}]`
2777
+ );
2778
+ }
2779
+ throw error;
2780
+ }
2781
+ });
2782
+ },
2783
+ updateBasicDetails(appId, basicDetails, authorization) {
2784
+ return __async(this, null, function* () {
2785
+ try {
2786
+ yield platformDpsClientInstance.put(
2787
+ `/v2/applications/${appId}/display`,
2788
+ basicDetails,
2789
+ getPlatformDpsClientConfig(authorization)
2790
+ );
2791
+ } catch (error) {
2792
+ if (error instanceof Error) {
2793
+ throw new Error(
2794
+ `Listing details couldn't be updated. [${error.message}]`
2795
+ );
2796
+ }
2797
+ throw error;
2798
+ }
2799
+ });
2800
+ },
2801
+ updateOverview(appId, data, authorization) {
2802
+ return __async(this, null, function* () {
2803
+ try {
2804
+ yield platformDpsClientInstance.put(
2805
+ `/v2/applications/${appId}/listing/overview`,
2806
+ data,
2807
+ getPlatformDpsClientConfig(authorization)
2808
+ );
2809
+ } catch (error) {
2810
+ if (error instanceof Error) {
2811
+ throw new Error(
2812
+ `Listing details couldn't be updated. [${error.message}]`
2813
+ );
2814
+ }
2815
+ throw error;
2816
+ }
2817
+ });
2818
+ },
2819
+ updateTutorialAndSupport(appId, data, authorization) {
2820
+ return __async(this, null, function* () {
2821
+ try {
2822
+ yield platformDpsClientInstance.put(
2823
+ `/v2/applications/${appId}/listing/support`,
2824
+ data,
2825
+ getPlatformDpsClientConfig(authorization)
2826
+ );
2827
+ } catch (error) {
2828
+ if (error instanceof Error) {
2829
+ throw new Error(
2830
+ `Listing details couldn't be updated. [${error.message}]`
2831
+ );
2832
+ }
2833
+ throw error;
2834
+ }
2835
+ });
2836
+ },
2837
+ updateAppIcon(appId, payload, authorization) {
2838
+ return __async(this, null, function* () {
2839
+ try {
2840
+ yield platformDpsClientInstance.put(
2841
+ `/v2/applications/${appId}/display/icons`,
2842
+ payload,
2843
+ getPlatformDpsClientConfig(authorization)
2844
+ );
2845
+ } catch (error) {
2846
+ if (error instanceof Error) {
2847
+ throw new Error(
2848
+ `Listing details couldn't be updated. [${error.message}]`
2849
+ );
2850
+ }
2851
+ throw error;
2852
+ }
2853
+ });
2854
+ },
2855
+ updateDisplayImages(appId, screenshots, authorization) {
2856
+ return __async(this, null, function* () {
2857
+ try {
2858
+ yield platformDpsClientInstance.put(
2859
+ `/v2/applications/${appId}/screenshots/commit`,
2860
+ screenshots,
2861
+ getPlatformDpsClientConfig(authorization)
2862
+ );
2863
+ } catch (error) {
2864
+ if (error instanceof Error) {
2865
+ throw new Error(
2866
+ `Listing details couldn't be updated. [${error.message}]`
2867
+ );
2868
+ }
2869
+ throw error;
2870
+ }
2871
+ });
2872
+ },
2873
+ updateDisplayFeatures(appId, features, authorization) {
2874
+ return __async(this, null, function* () {
2875
+ try {
2876
+ yield platformDpsClientInstance.put(
2877
+ `/v2/applications/${appId}/features`,
2878
+ features,
2879
+ getPlatformDpsClientConfig(authorization)
2880
+ );
2881
+ } catch (error) {
2882
+ if (error instanceof Error) {
2883
+ throw new Error(
2884
+ `Listing details couldn't be updated. [${error.message}]`
2885
+ );
2886
+ }
2887
+ throw error;
2888
+ }
2889
+ });
2890
+ },
2891
+ updateDisplayBenefits(appId, benefits, authorization) {
2892
+ return __async(this, null, function* () {
2893
+ try {
2894
+ yield platformDpsClientInstance.put(
2895
+ `/v2/applications/${appId}/benefits`,
2896
+ benefits,
2897
+ getPlatformDpsClientConfig(authorization)
2898
+ );
2899
+ } catch (error) {
2900
+ if (error instanceof Error) {
2901
+ throw new Error(
2902
+ `Listing details couldn't be updated. [${error.message}]`
2903
+ );
2904
+ }
2905
+ throw error;
2906
+ }
2907
+ });
2908
+ }
2909
+ };
2910
+
2911
+ // src/apis/platform/dps/applications/application/events/api.ts
2912
+ var platformDpsApplicationEventApi = {
2913
+ getEvents(appId, authorization) {
2914
+ return __async(this, null, function* () {
2915
+ try {
2916
+ const response = yield platformDpsClientInstance.get(
2917
+ `/v2/applications/${appId}/events?limit=300`,
2918
+ getPlatformDpsClientConfig(authorization)
2919
+ );
2920
+ return response.data;
2921
+ } catch (error) {
2922
+ if (error instanceof Error) {
2923
+ throw new Error(`App Events couldn't be fetched. [${error.message}]`);
2924
+ }
2925
+ throw error;
2926
+ }
2927
+ });
2928
+ }
2929
+ };
2930
+
2931
+ // src/apis/platform/dps/applications/application/infrastructure/blocks/api.ts
2932
+ var platformDpsApplicationInfrastructureBlocksApi = {
2933
+ getBlocks(appId, authorization) {
2934
+ return __async(this, null, function* () {
2935
+ const response = yield platformDpsClientInstance.get(
2936
+ `/v2/applications/${appId}/infrastructure/blocks`,
2937
+ getPlatformDpsClientConfig(authorization)
2938
+ );
2939
+ return response.data;
2940
+ });
2941
+ },
2942
+ updateBlocks(appId, payload, authorization) {
2943
+ return __async(this, null, function* () {
2944
+ const response = yield platformDpsClientInstance.patch(
2945
+ `/v2/applications/${appId}/infrastructure/blocks`,
2946
+ payload,
2947
+ getPlatformDpsClientConfig(authorization)
2948
+ );
2949
+ return response.data;
2950
+ });
2951
+ },
2952
+ updateRepository(appId, payload, authorization) {
2953
+ return __async(this, null, function* () {
2954
+ const response = yield platformDpsClientInstance.patch(
2955
+ `/v2/applications/${appId}/infrastructure/blocks`,
2956
+ {
2957
+ appId,
2958
+ repository: {
2959
+ provider: payload.provider
2960
+ }
2961
+ },
2962
+ getPlatformDpsClientConfig(authorization)
2963
+ );
2964
+ return response.data;
2965
+ });
2966
+ },
2967
+ updateDeployment(appId, payload, authorization) {
2968
+ return __async(this, null, function* () {
2969
+ const config = payload.customUrl ? { custom: { url: payload.customUrl } } : { custom: null };
2970
+ const response = yield platformDpsClientInstance.patch(
2971
+ `/v2/applications/${appId}/infrastructure/blocks`,
2972
+ {
2973
+ appId,
2974
+ deployment: {
2975
+ mode: payload.mode,
2976
+ provider: payload.provider,
2977
+ config
2978
+ }
2979
+ },
2980
+ getPlatformDpsClientConfig(authorization)
2981
+ );
2982
+ return response.data;
2983
+ });
2984
+ },
2985
+ updateStorage(appId, payload, authorization) {
2986
+ return __async(this, null, function* () {
2987
+ const response = yield platformDpsClientInstance.patch(
2988
+ `/v2/applications/${appId}/infrastructure/blocks`,
2989
+ {
2990
+ appId,
2991
+ storage: {
2992
+ provider: payload.provider
2993
+ }
2994
+ },
2995
+ getPlatformDpsClientConfig(authorization)
2996
+ );
2997
+ return response.data;
2998
+ });
2999
+ },
3000
+ updateLogger(appId, payload, authorization) {
3001
+ return __async(this, null, function* () {
3002
+ const response = yield platformDpsClientInstance.post(
3003
+ `/v2/applications/${appId}/infrastructure/blocks`,
3004
+ {
3005
+ appId,
3006
+ logger: {
3007
+ provider: payload.provider
3008
+ }
3009
+ },
3010
+ getPlatformDpsClientConfig(authorization)
3011
+ );
3012
+ return response.data;
3013
+ });
3014
+ }
3015
+ };
3016
+
3017
+ // src/apis/platform/dps/applications/application/infrastructure/api.ts
3018
+ var platformDpsApplicationInfrastructureApi = {
3019
+ blocks: platformDpsApplicationInfrastructureBlocksApi
3020
+ };
3021
+
3022
+ // src/apis/platform/dps/applications/application/install/api.ts
3023
+ var platformDpsApplicationInstallApi = {
3024
+ updateDirectInstallationUrl(appId, payload, authorization) {
3025
+ return __async(this, null, function* () {
3026
+ try {
3027
+ yield platformDpsClientInstance.put(
3028
+ `/v2/applications/${appId}/install/direct`,
3029
+ payload,
3030
+ getPlatformDpsClientConfig(authorization)
3031
+ );
3032
+ } catch (error) {
3033
+ if (error instanceof Error) {
3034
+ throw new Error(
3035
+ `Direct installation URL couldn't be updated. [${error.message}]`
3036
+ );
3037
+ }
3038
+ throw error;
3039
+ }
3040
+ });
3041
+ }
3042
+ };
3043
+
3044
+ // src/apis/platform/dps/applications/application/onboarding/api.ts
3045
+ var platformDpsApplicationOnboardingApi = {
3046
+ updateOnboarding(appId, payload, authorization) {
3047
+ return __async(this, null, function* () {
3048
+ try {
3049
+ yield platformDpsClientInstance.put(
3050
+ `/v2/applications/${appId}/onboarding`,
3051
+ payload,
3052
+ getPlatformDpsClientConfig(authorization)
3053
+ );
3054
+ } catch (error) {
3055
+ if (error instanceof Error) {
3056
+ throw new Error(
3057
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.UPDATED} [${error.message}]`
3058
+ );
3059
+ }
3060
+ throw error;
3061
+ }
3062
+ });
3063
+ },
3064
+ deleteOnboarding(appId, authorization) {
3065
+ return __async(this, null, function* () {
3066
+ try {
3067
+ yield platformDpsClientInstance.delete(
3068
+ `/v2/applications/${appId}/onboarding`,
3069
+ __spreadValues({}, getPlatformDpsClientConfig(authorization))
3070
+ );
3071
+ } catch (error) {
3072
+ if (error instanceof Error) {
3073
+ throw new Error(
3074
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.DELETED} [${error.message}]`
3075
+ );
3076
+ }
3077
+ throw error;
3078
+ }
3079
+ });
3080
+ }
3081
+ };
3082
+
3083
+ // src/apis/platform/dps/applications/application/payment/api.ts
3084
+ var platformDpsApplicationPaymentApi = {
3085
+ updatePaymentBlock(appId, payment, authorization) {
3086
+ return __async(this, null, function* () {
3087
+ try {
3088
+ yield platformDpsClientInstance.put(
3089
+ `/v2/applications/${appId}/payment`,
3090
+ payment,
3091
+ getPlatformDpsClientConfig(authorization)
3092
+ );
3093
+ } catch (error) {
3094
+ if (error instanceof Error) {
3095
+ throw new Error(
3096
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.UPDATED} [${error.message}]`
3097
+ );
3098
+ }
3099
+ throw error;
3100
+ }
3101
+ });
3102
+ },
3103
+ deletePaymentBlock(appId, authorization) {
3104
+ return __async(this, null, function* () {
3105
+ try {
3106
+ yield platformDpsClientInstance.delete(
3107
+ `/v2/applications/${appId}/payment`,
3108
+ getPlatformDpsClientConfig(authorization)
3109
+ );
3110
+ } catch (error) {
3111
+ if (error instanceof Error) {
3112
+ throw new Error(
3113
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.DELETED} [${error.message}]`
3114
+ );
3115
+ }
3116
+ throw error;
3117
+ }
3118
+ });
3119
+ }
3120
+ };
3121
+
3122
+ // src/apis/platform/dps/applications/application/product/api.ts
3123
+ var platformDpsApplicationProductApi = {
3124
+ updateProduct(appId, payload, authorization) {
3125
+ return __async(this, null, function* () {
3126
+ try {
3127
+ yield platformDpsClientInstance.put(
3128
+ `/v2/applications/${appId}/product`,
3129
+ payload,
3130
+ getPlatformDpsClientConfig(authorization)
3131
+ );
3132
+ } catch (error) {
3133
+ if (error instanceof Error) {
3134
+ throw new Error(
3135
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.UPDATED} [${error.message}]`
3136
+ );
3137
+ }
3138
+ throw error;
3139
+ }
3140
+ });
3141
+ }
3142
+ };
3143
+
3144
+ // src/apis/platform/dps/applications/application/properties/api.ts
3145
+ var platformDpsApplicationCustomPropsApi = {
3146
+ createCustomProps(appId, property, authorization) {
3147
+ return __async(this, null, function* () {
3148
+ try {
3149
+ const response = yield platformDpsClientInstance.post(
3150
+ `/v2/applications/${appId}/property`,
3151
+ property,
3152
+ getPlatformDpsClientConfig(authorization)
3153
+ );
3154
+ return response.data;
3155
+ } catch (error) {
3156
+ if (error instanceof Error) {
3157
+ throw new Error(
3158
+ `Listing details couldn't be created. [${error.message}]`
3159
+ );
3160
+ }
3161
+ throw error;
3162
+ }
3163
+ });
3164
+ },
3165
+ updateCustomProps(appId, property, authorization) {
3166
+ return __async(this, null, function* () {
3167
+ try {
3168
+ const response = yield platformDpsClientInstance.put(
3169
+ `/v2/applications/${appId}/property`,
3170
+ property,
3171
+ getPlatformDpsClientConfig(authorization)
3172
+ );
3173
+ return response.data;
3174
+ } catch (error) {
3175
+ if (error instanceof Error) {
3176
+ throw new Error(
3177
+ `Listing details couldn't be updated. [${error.message}]`
3178
+ );
3179
+ }
3180
+ throw error;
3181
+ }
3182
+ });
3183
+ },
3184
+ deleteCustomProps(appId, property, authorization) {
3185
+ return __async(this, null, function* () {
3186
+ try {
3187
+ const response = yield platformDpsClientInstance.delete(
3188
+ `/v2/applications/${appId}/property`,
3189
+ __spreadValues({ data: property }, getPlatformDpsClientConfig(authorization))
3190
+ );
3191
+ return response.data;
3192
+ } catch (error) {
3193
+ if (error instanceof Error) {
3194
+ throw new Error(
3195
+ `Listing details couldn't be deleted. [${error.message}]`
3196
+ );
3197
+ }
3198
+ throw error;
3199
+ }
3200
+ });
3201
+ }
3202
+ };
3203
+
3204
+ // src/apis/platform/dps/applications/application/reporting/api.ts
3205
+ var platformDpsApplicationReportingApi = {
3206
+ sendEvent(appId, event, authorization) {
3207
+ return __async(this, null, function* () {
3208
+ yield platformDpsClientInstance.post(
3209
+ `/apps/${appId}/events`,
3210
+ event,
3211
+ getPlatformDpsClientConfig(authorization)
3212
+ );
3213
+ });
3214
+ }
3215
+ };
3216
+
3217
+ // src/apis/platform/dps/applications/application/resources/api.ts
3218
+ var platformDpsApplicationResourcesApi = {
3219
+ getAppUpgrades(appId, authorization) {
3220
+ return __async(this, null, function* () {
3221
+ try {
3222
+ return yield platformDpsClientInstance.get(
3223
+ `/v2/applications/${appId}/resources`,
3224
+ getPlatformDpsClientConfig(authorization)
3225
+ );
3226
+ } catch (error) {
3227
+ if (error instanceof Error) {
3228
+ throw new Error(`App Resources couldn't be loaded. [${error.message}]`);
3229
+ }
3230
+ throw error;
3231
+ }
3232
+ });
3233
+ },
3234
+ createAppUpgrade(appId, body, authorization) {
3235
+ return __async(this, null, function* () {
3236
+ try {
3237
+ return yield platformDpsClientInstance.put(
3238
+ `/v2/applications/${appId}/resources`,
3239
+ body,
3240
+ getPlatformDpsClientConfig(authorization)
3241
+ );
3242
+ } catch (error) {
3243
+ if (error instanceof Error) {
3244
+ throw new Error(
3245
+ `App Resources couldn't be created. [${error.message}]`
3246
+ );
3247
+ }
3248
+ throw error;
3249
+ }
3250
+ });
3251
+ },
3252
+ updateAppUpgrade(appId, body, authorization) {
3253
+ return __async(this, null, function* () {
3254
+ try {
3255
+ return yield platformDpsClientInstance.put(
3256
+ `/v2/applications/${appId}/resources`,
3257
+ body,
3258
+ getPlatformDpsClientConfig(authorization)
3259
+ );
3260
+ } catch (error) {
3261
+ if (error instanceof Error) {
3262
+ throw new Error(
3263
+ `App Resources couldn't be updated. [${error.message}]`
3264
+ );
3265
+ }
3266
+ throw error;
3267
+ }
3268
+ });
3269
+ },
3270
+ deleteAppUpgrade(appId, resourceId, authorization) {
3271
+ return __async(this, null, function* () {
3272
+ try {
3273
+ return yield platformDpsClientInstance.delete(
3274
+ `/v2/applications/${appId}/resources/${resourceId}`,
3275
+ getPlatformDpsClientConfig(authorization)
3276
+ );
3277
+ } catch (error) {
3278
+ if (error instanceof Error) {
3279
+ throw new Error(`App Resource couldn't be delete. [${error.message}]`);
3280
+ }
3281
+ throw error;
3282
+ }
3283
+ });
3284
+ },
3285
+ copyUpgrade(sourceAppId, destinationAppId, authorization) {
3286
+ return __async(this, null, function* () {
3287
+ try {
3288
+ return yield platformDpsClientInstance.put(
3289
+ `/v2/applications/${sourceAppId}/resources/copy?application=${destinationAppId}`,
3290
+ getPlatformDpsClientConfig(authorization)
3291
+ );
3292
+ } catch (error) {
3293
+ if (error instanceof Error) {
3294
+ throw new Error(`App Resources couldn't be copied. [${error.message}]`);
3295
+ }
3296
+ throw error;
3297
+ }
3298
+ });
3299
+ }
3300
+ };
3301
+
3302
+ // src/apis/platform/dps/applications/application/review/api.ts
3303
+ var platformDpsApplicationReviewApi = {
3304
+ createSubmission(appId, payload, authorization) {
3305
+ return __async(this, null, function* () {
3306
+ try {
3307
+ const response = yield platformDpsClientInstance.put(
3308
+ `/v2/applications/${appId}/review/submit`,
3309
+ payload,
3310
+ getPlatformDpsClientConfig(authorization)
3311
+ );
3312
+ return response.data;
3313
+ } catch (error) {
3314
+ if (error instanceof Error) {
3315
+ throw new Error(
3316
+ `App couldn't be submitted for review. [${error.message}]`
3317
+ );
3318
+ }
3319
+ throw error;
3320
+ }
3321
+ });
3322
+ },
3323
+ cancelSubmission(appId, authorization) {
3324
+ return __async(this, null, function* () {
3325
+ try {
3326
+ const response = yield platformDpsClientInstance.put(
3327
+ `/v2/applications/${appId}/review/cancel`,
3328
+ getPlatformDpsClientConfig(authorization)
3329
+ );
3330
+ return response.data;
3331
+ } catch (error) {
3332
+ if (error instanceof Error) {
3333
+ throw new Error(`App review couldn't be cancelled. [${error.message}]`);
3334
+ }
3335
+ throw error;
3336
+ }
3337
+ });
3338
+ }
3339
+ };
3340
+
3341
+ // src/apis/platform/dps/applications/application/webhooks/api.ts
3342
+ var platformDpsApplicationWebhooksApi = {
3343
+ updateAppWebhooks(appId, payload, authorization) {
3344
+ return __async(this, null, function* () {
3345
+ try {
3346
+ yield platformDpsClientInstance.put(
3347
+ `/v2/applications/${appId}/webhook`,
3348
+ payload,
3349
+ getPlatformDpsClientConfig(authorization)
3350
+ );
3351
+ } catch (error) {
3352
+ if (error instanceof Error) {
3353
+ throw new Error(
3354
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.UPDATED} [${error.message}]`
3355
+ );
3356
+ }
3357
+ throw error;
3358
+ }
3359
+ });
3360
+ },
3361
+ getChatWebhook(appId, authorization) {
3362
+ return __async(this, null, function* () {
3363
+ try {
3364
+ yield platformDpsClientInstance.get(
3365
+ `/v2/applications/${appId}/chat-webhooks`,
3366
+ getPlatformDpsClientConfig(authorization)
3367
+ );
3368
+ } catch (error) {
3369
+ if (error instanceof Error) {
3370
+ throw new Error(`Couldn't get the chat webhook. [${error.message}]`);
3371
+ }
3372
+ throw error;
3373
+ }
3374
+ });
3375
+ },
3376
+ updateChatWebhook(appId, payload, authorization) {
3377
+ return __async(this, null, function* () {
3378
+ try {
3379
+ yield platformDpsClientInstance.post(
3380
+ `/v2/applications/${appId}/chat-webhooks`,
3381
+ payload,
3382
+ getPlatformDpsClientConfig(authorization)
3383
+ );
3384
+ } catch (error) {
3385
+ if (error instanceof Error) {
3386
+ throw new Error(
3387
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.UPDATED} [${error.message}]`
3388
+ );
3389
+ }
3390
+ throw error;
3391
+ }
3392
+ });
3393
+ },
3394
+ deleteChatWebhook(appId, authorization) {
3395
+ return __async(this, null, function* () {
3396
+ try {
3397
+ yield platformDpsClientInstance.delete(
3398
+ `/v2/applications/${appId}/chat-webhooks`,
3399
+ __spreadValues({}, getPlatformDpsClientConfig(authorization))
3400
+ );
3401
+ } catch (error) {
3402
+ if (error instanceof Error) {
3403
+ throw new Error(
3404
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.DELETED} [${error.message}]`
3405
+ );
3406
+ }
3407
+ throw error;
3408
+ }
3409
+ });
3410
+ }
3411
+ };
3412
+
3413
+ // src/apis/platform/dps/applications/application/widgets/api.ts
3414
+ var platformDpsApplicationWidgetsApi = {
3415
+ createWidget(appId, widgetId, widget, authorization) {
3416
+ return __async(this, null, function* () {
3417
+ try {
3418
+ yield platformDpsClientInstance.put(
3419
+ `/v2/applications/${appId}/widgets/${widgetId}`,
3420
+ widget,
3421
+ getPlatformDpsClientConfig(authorization)
3422
+ );
3423
+ } catch (error) {
3424
+ if (error instanceof Error) {
3425
+ throw new Error(
3426
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.CREATED} [${error.message}]`
3427
+ );
3428
+ }
3429
+ throw error;
3430
+ }
3431
+ });
3432
+ },
3433
+ updateWidget(appId, widgetId, widget, authorization) {
3434
+ return __async(this, null, function* () {
3435
+ try {
3436
+ yield platformDpsClientInstance.patch(
3437
+ `/v2/applications/${appId}/widgets/${widgetId}`,
3438
+ widget,
3439
+ getPlatformDpsClientConfig(authorization)
3440
+ );
3441
+ } catch (error) {
3442
+ if (error instanceof Error) {
3443
+ throw new Error(
3444
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.UPDATED} [${error.message}]`
3445
+ );
3446
+ }
3447
+ throw error;
3448
+ }
3449
+ });
3450
+ },
3451
+ deleteWidget(appId, widgetId, authorization) {
3452
+ return __async(this, null, function* () {
3453
+ try {
3454
+ yield platformDpsClientInstance.delete(
3455
+ `/v2/applications/${appId}/widgets/${widgetId}`,
3456
+ __spreadValues({}, getPlatformDpsClientConfig(authorization))
3457
+ );
3458
+ } catch (error) {
3459
+ if (error instanceof Error) {
3460
+ throw new Error(
3461
+ `${API_NOTIFICATIONS.BUILDING_BLOCKS.FAILURE.DELETED} [${error.message}]`
3462
+ );
3463
+ }
3464
+ throw error;
3465
+ }
3466
+ });
3467
+ }
3468
+ };
3469
+
3470
+ // src/apis/platform/dps/applications/application/api.ts
3471
+ var platformDpsApplicationApi = {
3472
+ authorization: platformDpsApplicationAuthorizationApi,
3473
+ autoReview: platformDpsApplicationAutoReviewApi,
3474
+ chatActions: platformDpsApplicationChatActionsApi,
3475
+ chatBoosters: platformDpsApplicationChatBoostersApi,
3476
+ customProps: platformDpsApplicationCustomPropsApi,
3477
+ display: platformDpsApplicationDisplayApi,
3478
+ events: platformDpsApplicationEventApi,
3479
+ install: platformDpsApplicationInstallApi,
3480
+ infrastructure: platformDpsApplicationInfrastructureApi,
3481
+ onboarding: platformDpsApplicationOnboardingApi,
3482
+ payment: platformDpsApplicationPaymentApi,
3483
+ product: platformDpsApplicationProductApi,
3484
+ reporting: platformDpsApplicationReportingApi,
3485
+ resource: platformDpsApplicationResourcesApi,
3486
+ review: platformDpsApplicationReviewApi,
3487
+ webhooks: platformDpsApplicationWebhooksApi,
3488
+ widgets: platformDpsApplicationWidgetsApi,
3489
+ getApp(appId, authorization) {
3490
+ return __async(this, null, function* () {
3491
+ try {
3492
+ const response = yield platformDpsClientInstance.get(
3493
+ `/v2/applications/${appId}`,
3494
+ getPlatformDpsClientConfig(authorization)
3495
+ );
3496
+ return response.data;
3497
+ } catch (error) {
3498
+ if (error instanceof Error) {
3499
+ throw new Error(`App couldn't be fetched. [${error.message}]`);
3500
+ }
3501
+ throw error;
3502
+ }
3503
+ });
3504
+ },
3505
+ createApp(payload, authorization) {
3506
+ return __async(this, null, function* () {
3507
+ try {
3508
+ const response = yield platformDpsClientInstance.post(
3509
+ `/v2/applications`,
3510
+ payload,
3511
+ getPlatformDpsClientConfig(authorization)
3512
+ );
3513
+ return response.data;
3514
+ } catch (error) {
3515
+ if (error instanceof Error) {
3516
+ throw new Error(`App couldn't be created. [${error.message}]`);
3517
+ }
3518
+ throw error;
3519
+ }
3520
+ });
3521
+ },
3522
+ fork(appId, authorization) {
3523
+ return __async(this, null, function* () {
3524
+ try {
3525
+ return yield platformDpsClientInstance.post(
3526
+ `/v2/applications/${appId}/fork`,
3527
+ getPlatformDpsClientConfig(authorization)
3528
+ );
3529
+ } catch (error) {
3530
+ if (error instanceof Error) {
3531
+ throw new Error(`App couldn't be forked. [${error.message}]`);
3532
+ }
3533
+ throw error;
3534
+ }
3535
+ });
3536
+ },
3537
+ updateQL(appId) {
3538
+ return __async(this, null, function* () {
3539
+ try {
3540
+ yield platformDpsClientInstance.patch(
3541
+ `/v2/applications/${appId}/qualified-lead`
3542
+ );
3543
+ } catch (error) {
3544
+ if (error instanceof Error) {
3545
+ throw new Error(`QL couldn't be updated. [${error.message}]`);
3546
+ }
3547
+ throw error;
3548
+ }
3549
+ });
3550
+ },
3551
+ deleteApp(appId, authorization) {
3552
+ return __async(this, null, function* () {
3553
+ try {
3554
+ yield platformDpsClientInstance.delete(
3555
+ `/v2/applications/${appId}`,
3556
+ getPlatformDpsClientConfig(authorization)
3557
+ );
3558
+ } catch (error) {
3559
+ if (error instanceof Error) {
3560
+ throw new Error(`App couldn't be created. [${error.message}]`);
3561
+ }
3562
+ throw error;
3563
+ }
3564
+ });
3565
+ },
3566
+ createAiContent(appId, appName, appSummary) {
3567
+ return __async(this, null, function* () {
3568
+ try {
3569
+ const response = yield platformDpsClientInstance.post(
3570
+ `/v2/ai/application/${appId}/content`,
3571
+ {
3572
+ name: appName,
3573
+ summary: appSummary
3574
+ }
3575
+ );
3576
+ return response;
3577
+ } catch (error) {
3578
+ if (error instanceof Error) {
3579
+ throw new Error(`AI content couldn't be created. [${error.message}]`);
3580
+ }
3581
+ throw error;
3582
+ }
3583
+ });
3584
+ }
3585
+ };
3586
+
3587
+ // src/apis/platform/dps/applications/purchases/api.ts
3588
+ var platformDpsApplicationsPurchasesApi = {
3589
+ getPurchases(apps, options, authorization) {
3590
+ return __async(this, null, function* () {
3591
+ try {
3592
+ const { from, to, duration } = options;
3593
+ const response = apps.map((app) => __async(this, null, function* () {
3594
+ const params = `applications=${app.clientId}${from ? `&from=${from}` : ""}${to ? `&to=${to}` : ""}&duration=${duration}&by=supplier`;
3595
+ const singleResponse = yield platformDpsClientInstance.get(
3596
+ `/v2/applications/purchases?${params}`,
3597
+ getPlatformDpsClientConfig(authorization)
3598
+ );
3599
+ return {
3600
+ appId: app.appId,
3601
+ data: singleResponse.data
3602
+ };
3603
+ }));
3604
+ return Promise.all(response);
3605
+ } catch (error) {
3606
+ if (error instanceof Error) {
3607
+ throw new Error(
3608
+ `App purchases couldn't be fetched. [${error.message}]`
3609
+ );
3610
+ }
3611
+ throw error;
3612
+ }
3613
+ });
3614
+ },
3615
+ getSummaryPurchases(apps, options, authorization) {
3616
+ return __async(this, null, function* () {
3617
+ try {
3618
+ const { from, to, duration } = options;
3619
+ const clientIds = apps.map((app) => app.clientId);
3620
+ const params = `applications=${clientIds.join(",")}${from ? `&from=${from}` : ""}${to ? `&to=${to}` : ""}&duration=${duration}&by=supplier`;
3621
+ const response = yield platformDpsClientInstance.get(
3622
+ `/v2/applications/purchases?${params}`,
3623
+ getPlatformDpsClientConfig(authorization)
3624
+ );
3625
+ return [{ data: response.data, appId: "All apps" }];
3626
+ } catch (error) {
3627
+ if (error instanceof Error) {
3628
+ throw new Error(
3629
+ `App summary purchases couldn't be fetched. [${error.message}]`
3630
+ );
3631
+ }
3632
+ throw error;
3633
+ }
3634
+ });
3635
+ },
3636
+ getSummaryPurchasesHistory(apps, options, authorization) {
3637
+ return __async(this, null, function* () {
3638
+ try {
3639
+ const { from, to, duration } = options;
3640
+ const params = `applications=${apps.join(",")}${from ? `&from=${from}` : ""}${to ? `&to=${to}` : ""}&duration=${duration}`;
3641
+ const response = yield platformDpsClientInstance.get(
3642
+ `/v2/applications/purchases/history?${params}`,
3643
+ getPlatformDpsClientConfig(authorization)
3644
+ );
3645
+ return [{ data: response.data, appId: "All apps" }];
3646
+ } catch (error) {
3647
+ if (error instanceof Error) {
3648
+ throw new Error(
3649
+ `App summary purchases history couldn't be fetched. [${error.message}]`
3650
+ );
3651
+ }
3652
+ throw error;
3653
+ }
3654
+ });
3655
+ }
3656
+ };
3657
+
3658
+ // src/apis/platform/dps/applications/usage/api.ts
3659
+ var platformDpsApplicationsUsageApi = {
3660
+ getUsage(appId, options, authorization) {
3661
+ return __async(this, null, function* () {
3662
+ try {
3663
+ const { events = [], from, apps, to, duration } = options;
3664
+ const response = events.map((event) => __async(this, null, function* () {
3665
+ const applications = appId ? `applications=${appId}` : `applications=${apps.map((app) => app.id).join(",")}`;
3666
+ let params = `${applications}&event=${event}`;
3667
+ params += duration ? `&duration=${duration}` : "";
3668
+ params += from ? `&from=${from}` : "";
3669
+ params += to ? `&to=${to}` : "";
3670
+ const singleResponse = yield platformDpsClientInstance.get(
3671
+ `/v2/applications/usage/developer?${params}`,
3672
+ getPlatformDpsClientConfig(authorization)
3673
+ );
3674
+ return singleResponse.data;
3675
+ }));
3676
+ return Promise.all(response);
3677
+ } catch (error) {
3678
+ if (error instanceof Error) {
3679
+ throw new Error(`App usage couldn't be fetched. [${error.message}]`);
3680
+ }
3681
+ throw error;
3682
+ }
3683
+ });
3684
+ }
3685
+ };
3686
+
3687
+ // src/apis/platform/dps/applications/api.ts
3688
+ var platformDpsApplicationsApi = {
3689
+ application: platformDpsApplicationApi,
3690
+ usage: platformDpsApplicationsUsageApi,
3691
+ purchases: platformDpsApplicationsPurchasesApi,
3692
+ getApps() {
3693
+ return __async(this, arguments, function* ({ filter = "licensed" } = {}) {
3694
+ try {
3695
+ const params = `filter=${filter}`;
3696
+ const response = yield platformDpsClientInstance.get(`/v2/applications?${params}`);
3697
+ return response.data;
3698
+ } catch (error) {
3699
+ if (error instanceof Error) {
3700
+ throw new Error(`Apps couldn't be fetched. [${error.message}]`);
3701
+ }
3702
+ throw error;
3703
+ }
3704
+ });
3705
+ }
3706
+ };
3707
+
3708
+ // src/apis/platform/dps/categories/api.ts
3709
+ var platformDpsCategoriesApi = {
3710
+ getCategories(authorization) {
3711
+ return __async(this, null, function* () {
3712
+ try {
3713
+ const response = yield platformDpsClientInstance.get(
3714
+ `/v2/categories`,
3715
+ getPlatformDpsClientConfig(authorization)
3716
+ );
3717
+ return response.data;
3718
+ } catch (error) {
3719
+ if (error instanceof Error) {
3720
+ throw new Error(`Categories couldn't be fetched. [${error.message}]`);
3721
+ }
3722
+ throw error;
3723
+ }
3724
+ });
3725
+ }
3726
+ };
3727
+
3728
+ // src/apis/platform/dps/developers/developer/api.ts
3729
+ var platformDpsDeveloperApi = {
3730
+ getLedger(userId, options, authorization) {
3731
+ return __async(this, null, function* () {
3732
+ try {
3733
+ const { startAt, endAt, size, page } = options;
3734
+ const withRange = !!(startAt && endAt);
3735
+ const withPagination = !!(size && typeof page === "number");
3736
+ let params = withRange || withPagination ? `?` : "";
3737
+ if (withRange) {
3738
+ params += `from=${startAt}&to=${endAt}`;
3739
+ }
3740
+ if (withPagination) {
3741
+ if (withRange) {
3742
+ params += `&size=${size}&page=${page}`;
3743
+ } else {
3744
+ params += `size=${size}&page=${page}`;
3745
+ }
3746
+ }
3747
+ const response = yield platformDpsClientInstance.get(
3748
+ `/v2/developers/${userId}/account/ledger${params}`,
3749
+ getPlatformDpsClientConfig(authorization)
3750
+ );
3751
+ return response.data;
3752
+ } catch (error) {
3753
+ if (error instanceof Error) {
3754
+ throw new Error(`Ledger couldn't be fetched. [${error.message}]`);
3755
+ }
3756
+ throw error;
3757
+ }
3758
+ });
3759
+ },
3760
+ requestWithdrawal(_0, _1) {
3761
+ return __async(this, arguments, function* ({
3762
+ amount,
3763
+ note,
3764
+ userId
3765
+ }, authorization) {
3766
+ try {
3767
+ const response = yield platformDpsClientInstance.patch(
3768
+ `/v2/developers/${userId}/account/withdrawal/request`,
3769
+ { amount, note },
3770
+ getPlatformDpsClientConfig(authorization)
3771
+ );
3772
+ return response.data;
3773
+ } catch (error) {
3774
+ if (error instanceof Error) {
3775
+ throw new Error(`Withdrawal couldn't be requested. [${error.message}]`);
3776
+ }
3777
+ throw error;
3778
+ }
3779
+ });
3780
+ }
3781
+ };
3782
+
3783
+ // src/apis/platform/dps/developers/api.ts
3784
+ var platformDpsDevelopersApi = {
3785
+ developer: platformDpsDeveloperApi
3786
+ };
3787
+
3788
+ // src/apis/platform/dps/links/api.ts
3789
+ var platformDpsLinksApi = {
3790
+ updateShortcuts(links, authorization) {
3791
+ return __async(this, null, function* () {
3792
+ try {
3793
+ yield platformDpsClientInstance.put(
3794
+ `/v2/links`,
3795
+ links,
3796
+ getPlatformDpsClientConfig(authorization)
3797
+ );
3798
+ } catch (error) {
3799
+ if (error instanceof Error) {
3800
+ throw new Error(`Shortcuts couldn't be updated. [${error.message}]`);
3801
+ }
3802
+ throw error;
3803
+ }
3804
+ });
3805
+ }
3806
+ };
3807
+
3808
+ // src/apis/platform/dps/messaging/developer/api.ts
3809
+ var platformDpsMessagingDeveloperApi = {
3810
+ getMessages(authorization) {
3811
+ return __async(this, null, function* () {
3812
+ try {
3813
+ const response = yield platformDpsClientInstance.get(
3814
+ `/v2/messaging/developer/fetch`,
3815
+ getPlatformDpsClientConfig(authorization)
3816
+ );
3817
+ return response.data;
3818
+ } catch (error) {
3819
+ if (error instanceof Error) {
3820
+ throw new Error(`Messages couldn't be fetched. [${error.message}]`);
3821
+ }
3822
+ throw error;
3823
+ }
3824
+ });
3825
+ },
3826
+ createMessage(message, authorization) {
3827
+ return __async(this, null, function* () {
3828
+ try {
3829
+ const response = yield platformDpsClientInstance.post(
3830
+ `/v2/messaging/developer/create`,
3831
+ message,
3832
+ getPlatformDpsClientConfig(authorization)
3833
+ );
3834
+ return response;
3835
+ } catch (error) {
3836
+ if (error instanceof Error) {
3837
+ throw new Error(`Message couldn't be sent. [${error.message}]`);
3838
+ }
3839
+ throw error;
3840
+ }
3841
+ });
3842
+ }
3843
+ };
3844
+
3845
+ // src/apis/platform/dps/messaging/api.ts
3846
+ var platformDpsMessagingApi = {
3847
+ developer: platformDpsMessagingDeveloperApi
3848
+ };
3849
+
3850
+ // src/apis/platform/dps/research/customer/api.ts
3851
+ var dpsResearchCustomerApi = {
3852
+ getResearchCustomersLicenses(authorization) {
3853
+ return __async(this, null, function* () {
3854
+ try {
3855
+ const response = yield platformDpsClientInstance.get(
3856
+ `/v2/research/customers/licenses`,
3857
+ getPlatformDpsClientConfig(authorization)
3858
+ );
3859
+ return response.data;
3860
+ } catch (error) {
3861
+ if (error instanceof Error) {
3862
+ throw new Error(
3863
+ `We couldn't fetch the research toolkit data. [${error.message}]`
3864
+ );
3865
+ }
3866
+ throw error;
3867
+ }
3868
+ });
3869
+ },
3870
+ getResearchCustomersBusiness(authorization) {
3871
+ return __async(this, null, function* () {
3872
+ try {
3873
+ const response = yield platformDpsClientInstance.get(
3874
+ `/v2/research/customers/business`,
3875
+ getPlatformDpsClientConfig(authorization)
3876
+ );
3877
+ return response.data;
3878
+ } catch (error) {
3879
+ if (error instanceof Error) {
3880
+ throw new Error(
3881
+ `We couldn't fetch the research toolkit data. [${error.message}]`
3882
+ );
3883
+ }
3884
+ throw error;
3885
+ }
3886
+ });
3887
+ },
3888
+ getResearchCustomersLocation(authorization) {
3889
+ return __async(this, null, function* () {
3890
+ try {
3891
+ const response = yield platformDpsClientInstance.get(
3892
+ `/v2/research/customers/location`,
3893
+ getPlatformDpsClientConfig(authorization)
3894
+ );
3895
+ return response.data;
3896
+ } catch (error) {
3897
+ if (error instanceof Error) {
3898
+ throw new Error(
3899
+ `We couldn't fetch the research toolkit data. [${error.message}]`
3900
+ );
3901
+ }
3902
+ throw error;
3903
+ }
3904
+ });
3905
+ }
3906
+ };
3907
+
3908
+ // src/apis/platform/dps/research/dictionary/api.ts
3909
+ var dpsResearchDictionaryApi = {
3910
+ getResearchDictionary() {
3911
+ return __async(this, arguments, function* (options = {}, authorization) {
3912
+ try {
3913
+ const params = new URLSearchParams(options);
3914
+ const response = yield platformDpsClientInstance.get(
3915
+ `/v2/research/dictionary?${params}`,
3916
+ getPlatformDpsClientConfig(authorization)
3917
+ );
3918
+ return response.data;
3919
+ } catch (error) {
3920
+ if (error instanceof Error) {
3921
+ throw new Error(
3922
+ `We couldn't fetch the research toolkit data. [${error.message}]`
3923
+ );
3924
+ }
3925
+ throw error;
3926
+ }
3927
+ });
3928
+ }
3929
+ };
3930
+
3931
+ // src/apis/platform/dps/research/marketplace/api.ts
3932
+ var dpsResearchMarketplaceApi = {
3933
+ getResearchMarketplaceApps() {
3934
+ return __async(this, arguments, function* (options = {}, authorization) {
3935
+ try {
3936
+ const params = new URLSearchParams(options);
3937
+ const response = yield platformDpsClientInstance.get(
3938
+ `/v2/research/marketplace/apps?${params}`,
3939
+ getPlatformDpsClientConfig(authorization)
3940
+ );
3941
+ return response.data;
3942
+ } catch (error) {
3943
+ if (error instanceof Error) {
3944
+ throw new Error(
3945
+ `We couldn't fetch the research toolkit data. [${error.message}]`
3946
+ );
3947
+ }
3948
+ throw error;
3949
+ }
3950
+ });
3951
+ },
3952
+ getResearchMarketplaceViews() {
3953
+ return __async(this, arguments, function* (options = {}, authorization) {
3954
+ try {
3955
+ const params = new URLSearchParams(options);
3956
+ const response = yield platformDpsClientInstance.get(
3957
+ `/v2/research/marketplace/views?${params}`,
3958
+ getPlatformDpsClientConfig(authorization)
3959
+ );
3960
+ return response.data;
3961
+ } catch (error) {
3962
+ if (error instanceof Error) {
3963
+ throw new Error(
3964
+ `We couldn't fetch the research toolkit data. [${error.message}]`
3965
+ );
3966
+ }
3967
+ throw error;
3968
+ }
3969
+ });
3970
+ }
3971
+ };
3972
+
3973
+ // src/apis/platform/dps/research/traffic/api.ts
3974
+ var dpsResearchTrafficApi = {
3975
+ getResearchTrafficAgents() {
3976
+ return __async(this, arguments, function* (options = {}, authorization) {
3977
+ try {
3978
+ const params = new URLSearchParams(options);
3979
+ const response = yield platformDpsClientInstance.get(
3980
+ `/v2/research/traffic/agents?${params}`,
3981
+ getPlatformDpsClientConfig(authorization)
3982
+ );
3983
+ return response.data;
3984
+ } catch (error) {
3985
+ if (error instanceof Error) {
3986
+ throw new Error(
3987
+ `We couldn't fetch the research toolkit data. [${error.message}]`
3988
+ );
3989
+ }
3990
+ throw error;
3991
+ }
3992
+ });
3993
+ },
3994
+ getResearchTrafficChats() {
3995
+ return __async(this, arguments, function* (options = {}, authorization) {
3996
+ try {
3997
+ const params = new URLSearchParams(options);
3998
+ const response = yield platformDpsClientInstance.get(
3999
+ `/v2/research/traffic/chats?${params}`,
4000
+ getPlatformDpsClientConfig(authorization)
4001
+ );
4002
+ return response.data;
4003
+ } catch (error) {
4004
+ if (error instanceof Error) {
4005
+ throw new Error(
4006
+ `We couldn't fetch the research toolkit data. [${error.message}]`
4007
+ );
4008
+ }
4009
+ throw error;
4010
+ }
4011
+ });
4012
+ }
4013
+ };
4014
+
4015
+ // src/apis/platform/dps/research/api.ts
4016
+ var platformDpsResearchApi = {
4017
+ customer: dpsResearchCustomerApi,
4018
+ traffic: dpsResearchTrafficApi,
4019
+ marketplace: dpsResearchMarketplaceApi,
4020
+ dictionary: dpsResearchDictionaryApi
4021
+ };
4022
+
4023
+ // src/apis/platform/dps/user/api.ts
4024
+ var platformDpsUserApi = {
4025
+ getUser(authorization) {
4026
+ return __async(this, null, function* () {
4027
+ const response = yield platformDpsClientInstance.get(
4028
+ `/v2/me`,
4029
+ getPlatformDpsClientConfig(authorization)
4030
+ );
4031
+ return response.data;
4032
+ });
4033
+ },
4034
+ getUserIntegrations(authorization) {
4035
+ return __async(this, null, function* () {
4036
+ const response = yield platformDpsClientInstance.get(
4037
+ `/v2/me/integrations`,
4038
+ getPlatformDpsClientConfig(authorization)
4039
+ );
4040
+ return response.data;
4041
+ });
4042
+ },
4043
+ updateUser(user, authorization) {
4044
+ return __async(this, null, function* () {
4045
+ const { status } = yield platformDpsClientInstance.put(
4046
+ `/v2/me`,
4047
+ user,
4048
+ getPlatformDpsClientConfig(authorization)
4049
+ );
4050
+ return status;
4051
+ });
4052
+ },
4053
+ updateUserIntegrations(payload, authorization) {
4054
+ return __async(this, null, function* () {
4055
+ const response = yield platformDpsClientInstance.patch(
4056
+ `/v2/me/integrations`,
4057
+ payload,
4058
+ getPlatformDpsClientConfig(authorization)
4059
+ );
4060
+ return response.data;
4061
+ });
4062
+ },
4063
+ updateUserFeatures(payload, authorization) {
4064
+ return __async(this, null, function* () {
4065
+ const response = yield platformDpsClientInstance.put(
4066
+ "/v2/features",
4067
+ payload,
4068
+ getPlatformDpsClientConfig(authorization)
4069
+ );
4070
+ return response.data;
4071
+ });
4072
+ },
4073
+ removeUserGitHubIntegrationByInstallationId(installationId, authorization) {
4074
+ return __async(this, null, function* () {
4075
+ const response = yield platformDpsClientInstance.delete(
4076
+ `/v2/me/integrations/github`,
4077
+ __spreadProps(__spreadValues({}, getPlatformDpsClientConfig(authorization)), {
4078
+ data: {
4079
+ githubInstallationId: installationId
4080
+ }
4081
+ })
4082
+ );
4083
+ return response.data;
4084
+ });
4085
+ },
4086
+ updateUserNetlifyIntegration(userNetlifyIntegration, authorization) {
4087
+ return __async(this, null, function* () {
4088
+ const { status } = yield platformDpsClientInstance.patch(
4089
+ `/v2/me/integrations`,
4090
+ { netlify: userNetlifyIntegration },
4091
+ getPlatformDpsClientConfig(authorization)
4092
+ );
4093
+ return status;
4094
+ });
4095
+ }
4096
+ };
4097
+
4098
+ // src/apis/platform/dps/api.ts
4099
+ var platformDpsApi = {
4100
+ applications: platformDpsApplicationsApi,
4101
+ user: platformDpsUserApi,
4102
+ categories: platformDpsCategoriesApi,
4103
+ developers: platformDpsDevelopersApi,
4104
+ links: platformDpsLinksApi,
4105
+ messaging: platformDpsMessagingApi,
4106
+ research: platformDpsResearchApi
4107
+ };
4108
+
4109
+ // src/apis/platform/adapter/instance.ts
4110
+ import axios12 from "axios";
4111
+ function getPlatformAdapterClientAuthorization(req) {
4112
+ return {
4113
+ platform: {
4114
+ dps: req.headers["platform-dps-token"]
4115
+ },
4116
+ github: {
4117
+ app: req.headers["github-app-token"],
4118
+ oauth: req.headers["github-oauth-token"]
4119
+ },
4120
+ netlify: req.headers["netlify-token"],
4121
+ vercel: req.headers["vercel-token"],
4122
+ planetscale: req.headers["planetscale-token"],
4123
+ sentry: req.headers["sentry-token"]
4124
+ };
4125
+ }
4126
+ var platformAdapterClientInstance = axios12.create({
4127
+ baseURL: "https://platform.labs.text.com/console-adapter/api",
4128
+ headers: {
4129
+ "Content-Type": "application/json"
4130
+ }
4131
+ });
4132
+ platformAdapterClientInstance.interceptors.response.use(
4133
+ (r) => r,
4134
+ (error) => {
4135
+ var _a;
4136
+ if (axios12.isAxiosError(error)) {
4137
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401 && error.response.data.error.source) {
4138
+ error = new UnauthorizeApiError(error.response.data.error.source);
4139
+ }
4140
+ }
4141
+ throw error;
4142
+ }
4143
+ );
4144
+ function getPlatformAdapterClientConfig(options = {}) {
4145
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
4146
+ const headers = {
4147
+ platform: {
4148
+ dps: (_b = platformAdapterClientInstance.defaults.headers["platform-dps-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.dps
4149
+ },
4150
+ integrations: {
4151
+ github: {
4152
+ app: (_d = platformAdapterClientInstance.defaults.headers["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.app,
4153
+ oauth: (_f = platformAdapterClientInstance.defaults.headers["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauth
4154
+ },
4155
+ netlify: (_g = platformAdapterClientInstance.defaults.headers["netlify-token"]) != null ? _g : options.netlify,
4156
+ vercel: (_h = platformAdapterClientInstance.defaults.headers["vercel-token"]) != null ? _h : options.vercel,
4157
+ planetscale: (_i = platformAdapterClientInstance.defaults.headers["planetscale-token"]) != null ? _i : options.planetscale,
4158
+ sentry: (_j = platformAdapterClientInstance.defaults.headers["sentry-token"]) != null ? _j : options.sentry
4159
+ }
4160
+ };
4161
+ if (((_l = (_k = options.ensureAuthorizationToken) == null ? void 0 : _k.platform) == null ? void 0 : _l.dps) && !headers.platform.dps) {
4162
+ throw new UnauthorizeApiError("dps");
4163
+ }
4164
+ if (((_m = options.ensureAuthorizationToken) == null ? void 0 : _m.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
4165
+ throw new UnauthorizeApiError("github");
4166
+ }
4167
+ if (((_n = options.ensureAuthorizationToken) == null ? void 0 : _n.vercel) && !headers.integrations.vercel) {
4168
+ throw new UnauthorizeApiError("vercel");
4169
+ }
4170
+ if (((_o = options.ensureAuthorizationToken) == null ? void 0 : _o.netlify) && !headers.integrations.netlify) {
4171
+ throw new UnauthorizeApiError("netlify");
4172
+ }
4173
+ if (((_p = options.ensureAuthorizationToken) == null ? void 0 : _p.planetscale) && !headers.integrations.planetscale) {
4174
+ throw new UnauthorizeApiError("planetscale");
4175
+ }
4176
+ if (((_q = options.ensureAuthorizationToken) == null ? void 0 : _q.sentry) && !headers.integrations.sentry) {
4177
+ throw new UnauthorizeApiError("sentry");
4178
+ }
4179
+ return {
4180
+ headers: __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.sentry ? { "sentry-token": headers.integrations.sentry } : {})
4181
+ };
4182
+ }
4183
+ function initPlatformAdapterClientInstance(baseUrl, tokens) {
4184
+ if (baseUrl) {
4185
+ platformAdapterClientInstance.interceptors.request.use(
4186
+ (config) => __async(this, null, function* () {
4187
+ config.baseURL = baseUrl;
4188
+ return config;
4189
+ }),
4190
+ (error) => Promise.reject(error)
4191
+ );
4192
+ }
4193
+ if (tokens) {
4194
+ updatePlatformAdapterClientInstance(tokens);
4195
+ }
4196
+ }
4197
+ function updatePlatformAdapterClientInstance(tokens) {
4198
+ var _a;
4199
+ if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.dps) {
4200
+ platformAdapterClientInstance.defaults.headers["platform-dps-token"] = tokens.platform.dps;
4201
+ }
4202
+ if (tokens == null ? void 0 : tokens.github.app) {
4203
+ platformAdapterClientInstance.defaults.headers["github-app-token"] = tokens.github.app;
4204
+ }
4205
+ if (tokens == null ? void 0 : tokens.github.oauth) {
4206
+ platformAdapterClientInstance.defaults.headers["github-oauth-token"] = tokens.github.oauth;
4207
+ }
4208
+ if (tokens == null ? void 0 : tokens.netlify) {
4209
+ platformAdapterClientInstance.defaults.headers["netlify-token"] = tokens.netlify;
4210
+ }
4211
+ if (tokens == null ? void 0 : tokens.vercel) {
4212
+ platformAdapterClientInstance.defaults.headers["vercel-token"] = tokens.vercel;
4213
+ }
4214
+ if (tokens == null ? void 0 : tokens.planetscale) {
4215
+ platformAdapterClientInstance.defaults.headers["planetscale-token"] = tokens.planetscale;
4216
+ }
4217
+ if (tokens == null ? void 0 : tokens.sentry) {
4218
+ platformAdapterClientInstance.defaults.headers["sentry-token"] = tokens.sentry;
4219
+ }
4220
+ }
4221
+
4222
+ // src/apis/platform/adapter/app/blocks/deployment/api.ts
4223
+ var platformAdapterAppDeploymentApi = {
4224
+ get(appId, authorization) {
4225
+ return __async(this, null, function* () {
4226
+ const response = yield platformAdapterClientInstance.get(
4227
+ `/console/app/${appId}/blocks/deployment`,
4228
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4229
+ ensureAuthorizationToken: {
4230
+ platform: {
4231
+ dps: true
4232
+ }
4233
+ }
4234
+ }))
4235
+ );
4236
+ return response.data;
4237
+ });
4238
+ },
4239
+ link(payload, authorization) {
4240
+ return __async(this, null, function* () {
4241
+ yield platformAdapterClientInstance.post(
4242
+ `/console/app/${payload.appId}/blocks/deployment/link`,
4243
+ payload,
4244
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4245
+ ensureAuthorizationToken: {
4246
+ platform: {
4247
+ dps: true
4248
+ }
4249
+ }
4250
+ }))
4251
+ );
4252
+ });
4253
+ },
4254
+ unlink(payload, authorization) {
4255
+ return __async(this, null, function* () {
4256
+ const response = yield platformAdapterClientInstance.post(
4257
+ `/console/app/${payload.appId}/blocks/deployment/unlink`,
4258
+ payload,
4259
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4260
+ ensureAuthorizationToken: {
4261
+ platform: {
4262
+ dps: true
4263
+ }
4264
+ }
4265
+ }))
4266
+ );
4267
+ return response.data;
4268
+ });
4269
+ },
4270
+ installSentry(appId, authorization) {
4271
+ return __async(this, null, function* () {
4272
+ const response = yield platformAdapterClientInstance.post(
4273
+ `/console/app/${appId}/blocks/deployment/install/sentry`,
4274
+ {},
4275
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4276
+ ensureAuthorizationToken: {
4277
+ platform: {
4278
+ dps: true
4279
+ }
4280
+ }
4281
+ }))
4282
+ );
4283
+ return response.data;
4284
+ });
4285
+ }
4286
+ };
4287
+
4288
+ // src/apis/platform/adapter/app/blocks/logger/providers/sentry/api.ts
4289
+ var platformAdapterAppSentryLoggerApi = {
4290
+ get(projectSlug, authorization) {
4291
+ return __async(this, null, function* () {
4292
+ const response = yield platformAdapterClientInstance.get(
4293
+ `/console/app/blocks/logger/providers/sentry/get?projectSlug=${projectSlug}`,
4294
+ getPlatformAdapterClientConfig(authorization)
4295
+ );
4296
+ return response.data;
4297
+ });
4298
+ },
4299
+ link(payload, authorization) {
4300
+ return __async(this, null, function* () {
4301
+ const response = yield platformAdapterClientInstance.post(
4302
+ "/console/app/blocks/logger/providers/sentry/link",
4303
+ payload,
4304
+ getPlatformAdapterClientConfig(authorization)
4305
+ );
4306
+ return response.data;
4307
+ });
4308
+ },
4309
+ unlink(payload, authorization) {
4310
+ return __async(this, null, function* () {
4311
+ const response = yield platformAdapterClientInstance.post(
4312
+ "/console/app/blocks/logger/providers/sentry/unlink",
4313
+ payload,
4314
+ getPlatformAdapterClientConfig(authorization)
4315
+ );
4316
+ return response.data;
4317
+ });
4318
+ },
4319
+ reauthorizeSentryApp(userId, sentryInstallationId, sentryRefreshToken, authorization) {
4320
+ return __async(this, null, function* () {
4321
+ const response = yield platformAdapterClientInstance.post(
4322
+ "/integrations/sentry/refresh",
4323
+ {
4324
+ userId,
4325
+ sentryInstallationId,
4326
+ sentryRefreshToken
4327
+ },
4328
+ getPlatformAdapterClientConfig(authorization)
4329
+ );
4330
+ return response.data;
4331
+ });
4332
+ },
4333
+ requestSentryIssueSolution(stacktrace, authorization) {
4334
+ return __async(this, null, function* () {
4335
+ const response = yield platformAdapterClientInstance.post(
4336
+ "/integrations/openai/issues/solution",
4337
+ {
4338
+ stacktrace
4339
+ },
4340
+ getPlatformAdapterClientConfig(authorization)
4341
+ );
4342
+ return response.data;
4343
+ });
4344
+ }
4345
+ };
4346
+
4347
+ // src/apis/platform/adapter/app/blocks/logger/api.ts
4348
+ var platformAdapterAppLoggerApi = {
4349
+ providers: {
4350
+ sentry: platformAdapterAppSentryLoggerApi
4351
+ }
4352
+ };
4353
+
4354
+ // src/apis/platform/adapter/app/blocks/repository/api.ts
4355
+ var platformAdapterAppRepositoryApi = {
4356
+ get(appId, authorization) {
4357
+ return __async(this, null, function* () {
4358
+ const response = yield platformAdapterClientInstance.get(
4359
+ `/console/app/${appId}/blocks/repository`,
4360
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4361
+ ensureAuthorizationToken: {
4362
+ platform: {
4363
+ dps: true
4364
+ }
4365
+ }
4366
+ }))
4367
+ );
4368
+ return response.data;
4369
+ });
4370
+ },
4371
+ link(payload, authorization) {
4372
+ return __async(this, null, function* () {
4373
+ const response = yield platformAdapterClientInstance.post(
4374
+ `/console/app/${payload.appId}/blocks/repository/link`,
4375
+ payload,
4376
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4377
+ ensureAuthorizationToken: {
4378
+ platform: {
4379
+ dps: true
4380
+ }
4381
+ }
4382
+ }))
4383
+ );
4384
+ return response.data;
4385
+ });
4386
+ },
4387
+ unlink(payload, authorization) {
4388
+ return __async(this, null, function* () {
4389
+ const response = yield platformAdapterClientInstance.post(
4390
+ `/console/app/${payload.appId}/blocks/repository/unlink`,
4391
+ payload,
4392
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4393
+ ensureAuthorizationToken: {
4394
+ platform: {
4395
+ dps: true
4396
+ }
4397
+ }
4398
+ }))
4399
+ );
4400
+ return response.data;
4401
+ });
4402
+ },
4403
+ seed(payload, authorization) {
4404
+ return __async(this, null, function* () {
4405
+ const response = yield platformAdapterClientInstance.post(
4406
+ `/console/app/${payload.appId}/blocks/repository/seed`,
4407
+ payload,
4408
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4409
+ ensureAuthorizationToken: {
4410
+ platform: {
4411
+ dps: true
4412
+ }
4413
+ }
4414
+ }))
4415
+ );
4416
+ return response.data;
4417
+ });
4418
+ }
4419
+ };
4420
+
4421
+ // src/apis/platform/adapter/app/blocks/storage/api.ts
4422
+ var platformAdapterAppStorageApi = {
4423
+ get(appId, authorization) {
4424
+ return __async(this, null, function* () {
4425
+ const response = yield platformAdapterClientInstance.get(
4426
+ `/console/app/${appId}/blocks/storage`,
4427
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4428
+ ensureAuthorizationToken: {
4429
+ platform: {
4430
+ dps: true
4431
+ }
4432
+ }
4433
+ }))
4434
+ );
4435
+ return response.data;
4436
+ });
4437
+ },
4438
+ link(payload, authorization) {
4439
+ return __async(this, null, function* () {
4440
+ yield platformAdapterClientInstance.post(
4441
+ `/console/app/${payload.appId}/blocks/storage/link`,
4442
+ payload,
4443
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4444
+ ensureAuthorizationToken: {
4445
+ platform: {
4446
+ dps: true
4447
+ }
4448
+ }
4449
+ }))
4450
+ );
4451
+ });
4452
+ },
4453
+ unlink(payload, authorization) {
4454
+ return __async(this, null, function* () {
4455
+ const response = yield platformAdapterClientInstance.post(
4456
+ `/console/app/${payload.appId}/blocks/storage/unlink`,
4457
+ payload,
4458
+ getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
4459
+ ensureAuthorizationToken: {
4460
+ platform: {
4461
+ dps: true
4462
+ }
4463
+ }
4464
+ }))
4465
+ );
4466
+ return response.data;
4467
+ });
4468
+ }
4469
+ };
4470
+
4471
+ // src/apis/platform/adapter/app/blocks/api.ts
4472
+ var platformAdapterAppBlocksApi = {
4473
+ repository: platformAdapterAppRepositoryApi,
4474
+ deployment: platformAdapterAppDeploymentApi,
4475
+ storage: platformAdapterAppStorageApi,
4476
+ logger: platformAdapterAppLoggerApi
4477
+ };
4478
+
4479
+ // src/apis/platform/adapter/app/variables/api.ts
4480
+ var platformAdapterAppVariablesApi = {
4481
+ getVariables(appId, decrypted, authorization) {
4482
+ return __async(this, null, function* () {
4483
+ const response = yield platformAdapterClientInstance.get(
4484
+ `/console/app/${appId}/variables`,
4485
+ __spreadValues({
4486
+ params: {
4487
+ decrypted
4488
+ }
4489
+ }, getPlatformAdapterClientConfig(authorization))
4490
+ );
4491
+ return response.data;
4492
+ });
4493
+ },
4494
+ getVariable(appId, key, authorization) {
4495
+ return __async(this, null, function* () {
4496
+ const response = yield platformAdapterClientInstance.get(
4497
+ `/console/app/${appId}/variables/${key}`,
4498
+ getPlatformAdapterClientConfig(authorization)
4499
+ );
4500
+ return response.data;
4501
+ });
4502
+ },
4503
+ syncVariable(appId, key, payload, authorization) {
4504
+ return __async(this, null, function* () {
4505
+ const response = yield platformAdapterClientInstance.post(
4506
+ `/console/app/${appId}/variables/${key}/sync`,
4507
+ payload,
4508
+ getPlatformAdapterClientConfig(authorization)
4509
+ );
4510
+ return response.data;
4511
+ });
4512
+ }
4513
+ };
4514
+
4515
+ // src/apis/platform/adapter/app/api.ts
4516
+ var platformAdapterAppApi = {
4517
+ blocks: platformAdapterAppBlocksApi,
4518
+ variables: platformAdapterAppVariablesApi,
4519
+ create(payload, authorization) {
4520
+ return __async(this, null, function* () {
4521
+ const response = yield platformAdapterClientInstance.post(
4522
+ `/console/app/new`,
4523
+ payload,
4524
+ getPlatformAdapterClientConfig(authorization)
4525
+ );
4526
+ return response.data;
4527
+ });
4528
+ },
4529
+ createStatus(sagaId, authorization) {
4530
+ return __async(this, null, function* () {
4531
+ const response = yield platformAdapterClientInstance.get(
4532
+ `/console/app/new/status`,
4533
+ __spreadValues({
4534
+ params: {
4535
+ sagaId
4536
+ }
4537
+ }, getPlatformAdapterClientConfig(authorization))
4538
+ );
4539
+ return response.data;
4540
+ });
4541
+ }
4542
+ };
4543
+
4544
+ // src/apis/platform/adapter/api.ts
4545
+ var platformAdapterApi = {
4546
+ app: platformAdapterAppApi
4547
+ };
4548
+
4549
+ // src/apis/platform/api.ts
4550
+ var platformApi = {
4551
+ accounts: platformAccountsApi,
4552
+ adapter: platformAdapterApi,
4553
+ dps: platformDpsApi
4554
+ };
4555
+
4556
+ // src/apis/platform/dps/applications/application/reporting/_contracts/dtos/events/error.ts
4557
+ var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
4558
+ ErrorType2["4xx"] = "4xx";
4559
+ ErrorType2["5xx"] = "5xx";
4560
+ return ErrorType2;
4561
+ })(ErrorType || {});
4562
+
4563
+ // src/apis/api.ts
4564
+ var api = {
4565
+ platform: platformApi,
4566
+ products: productsApi,
4567
+ integrations: integrationsApi,
4568
+ isInitialized: false
4569
+ };
4570
+ function initApi(config, tokens) {
4571
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
4572
+ initPlatformAccountsClientInstance(
4573
+ (_a = config.urls.platform) == null ? void 0 : _a.accounts,
4574
+ (_b = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _b.dps
4575
+ );
4576
+ initPlatformDpsClientInstance(
4577
+ (_c = config.urls.platform) == null ? void 0 : _c.dps,
4578
+ (_d = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _d.dps
4579
+ );
4580
+ initPlatformAdapterClientInstance(
4581
+ (_e = config.urls.platform) == null ? void 0 : _e.adapter,
4582
+ tokens ? {
4583
+ platform: {
4584
+ dps: (_f = tokens.platform) == null ? void 0 : _f.dps
4585
+ },
4586
+ github: {
4587
+ app: (_g = tokens.github) == null ? void 0 : _g.apps,
4588
+ oauth: (_h = tokens.github) == null ? void 0 : _h.oauth
4589
+ },
4590
+ netlify: (_i = tokens.netlify) == null ? void 0 : _i.token,
4591
+ vercel: (_j = tokens.vercel) == null ? void 0 : _j.token,
4592
+ planetscale: (_k = tokens.planetscale) == null ? void 0 : _k.token,
4593
+ sentry: (_l = tokens.sentry) == null ? void 0 : _l.token
4594
+ } : void 0
4595
+ );
4596
+ initLiveChatClientInstance(
4597
+ (_m = config.urls.products) == null ? void 0 : _m.livechat,
4598
+ (_n = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _n.dps
4599
+ );
4600
+ initGithubClientInstance((_o = tokens == null ? void 0 : tokens.github) == null ? void 0 : _o.apps);
4601
+ initNetlifyClientInstance((_p = tokens == null ? void 0 : tokens.netlify) == null ? void 0 : _p.token);
4602
+ initVercelClientInstance((_q = tokens == null ? void 0 : tokens.vercel) == null ? void 0 : _q.token);
4603
+ initPlanetScaleClientInstance((_r = tokens == null ? void 0 : tokens.planetscale) == null ? void 0 : _r.token);
4604
+ initSentryClientInstance((_s = tokens == null ? void 0 : tokens.sentry) == null ? void 0 : _s.token);
4605
+ api.isInitialized = true;
4606
+ }
4607
+
4608
+ // src/utils/serializer.ts
4609
+ var serializerBase64 = {
4610
+ serialize(state) {
4611
+ return btoa(escape(JSON.stringify(state)));
4612
+ },
4613
+ deserialize(message) {
4614
+ try {
4615
+ return message ? JSON.parse(unescape(atob(unescape(message)))) : void 0;
4616
+ } catch (e) {
4617
+ }
4618
+ }
4619
+ };
4620
+ export {
4621
+ API_NOTIFICATIONS,
4622
+ ErrorType,
4623
+ UnauthorizeApiError,
4624
+ api,
4625
+ getAppAutoReviewPayload,
4626
+ getEmptyAppAutoReview,
4627
+ getGitHubClientAuthorization,
4628
+ getGithubClientRequestConfig,
4629
+ getLiveChatClientAuthorization,
4630
+ getLiveChatClientConfig,
4631
+ getNetlifyClientAuthorization,
4632
+ getNetlifyClientConfig,
4633
+ getPlanetScaleClientAuthorization,
4634
+ getPlanetScaleClientConfig,
4635
+ getPlatformAccountsClientAuthorization,
4636
+ getPlatformAccountsClientConfig,
4637
+ getPlatformAdapterClientAuthorization,
4638
+ getPlatformAdapterClientConfig,
4639
+ getPlatformDpsAdminClientAuthorization,
4640
+ getPlatformDpsClientAuthorization,
4641
+ getPlatformDpsClientConfig,
4642
+ getRegion,
4643
+ getSentryClientAuthorization,
4644
+ getSentryClientConfig,
4645
+ getVercelClientAuthorization,
4646
+ getVercelClientConfig,
4647
+ githubClientInstance,
4648
+ initApi,
4649
+ initGithubClientInstance,
4650
+ initLiveChatClientInstance,
4651
+ initNetlifyClientInstance,
4652
+ initPlanetScaleClientInstance,
4653
+ initPlatformAccountsClientInstance,
4654
+ initPlatformAdapterClientInstance,
4655
+ initPlatformDpsClientInstance,
4656
+ initSentryClientInstance,
4657
+ initVercelClientInstance,
4658
+ livechatClientInstance,
4659
+ netlifyClientInstance,
4660
+ planetScaleClientInstance,
4661
+ platformAccountsClientInstance,
4662
+ platformAdapterClientInstance,
4663
+ platformDpsClientInstance,
4664
+ sentryClientInstance,
4665
+ serializerBase64,
4666
+ updateGithubClientInstance,
4667
+ updateNetlifyClientInstance,
4668
+ updatePlanetScaleClientInstance,
4669
+ updatePlatformAdapterClientInstance,
4670
+ updateSentryClientInstance,
4671
+ updateVercelClientInstance,
4672
+ vercelClientInstance
4673
+ };