@livechat/developer-studio-api 3.0.0-beta.2 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +48 -130
- package/dist/index.mjs +15 -97
- package/package.json +4 -5
package/dist/index.d.mts
CHANGED
|
@@ -922,10 +922,10 @@ interface AppAuthorizationData {
|
|
|
922
922
|
|
|
923
923
|
type AddAppAuthorizationPayload = {
|
|
924
924
|
appId: string;
|
|
925
|
-
|
|
926
|
-
} & AppAuthorizationData;
|
|
925
|
+
} & Omit<AppAuthorizationData, "clientId">;
|
|
927
926
|
interface AddAppAuthorizationResult {
|
|
928
927
|
clientId: string;
|
|
928
|
+
clientSecret: string;
|
|
929
929
|
}
|
|
930
930
|
|
|
931
931
|
type UpdateAppAuthorizationPayload = {
|
|
@@ -2626,17 +2626,19 @@ declare const api: {
|
|
|
2626
2626
|
integrations: {
|
|
2627
2627
|
github: {
|
|
2628
2628
|
installation: {
|
|
2629
|
-
getInstallation(account?: string | undefined, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubInstallation | undefined>;
|
|
2629
|
+
getInstallation(appId: number, account?: string | undefined, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubInstallation | undefined>;
|
|
2630
2630
|
getInstallations(authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubInstallation[]>;
|
|
2631
2631
|
getInstallationRepositories(installationId: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepository[]>;
|
|
2632
2632
|
};
|
|
2633
2633
|
repository: {
|
|
2634
|
-
getRepository(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepository
|
|
2634
|
+
getRepository(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepository>;
|
|
2635
2635
|
getRepositoryBranches(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositoryBranch[]>;
|
|
2636
|
-
getRepositoryBranch(repositoryName: string, repositoryBranch: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositoryBranch
|
|
2636
|
+
getRepositoryBranch(repositoryName: string, repositoryBranch: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositoryBranch>;
|
|
2637
2637
|
getRepositorySeed(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositorySeed | undefined>;
|
|
2638
2638
|
createRepository(name: string, hasInstallation: boolean, template?: string | undefined, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepository>;
|
|
2639
|
-
seedRepository(repositoryName: string,
|
|
2639
|
+
seedRepository(repositoryName: string, manifest: AppManifest | {
|
|
2640
|
+
id: string;
|
|
2641
|
+
}, isForLabs?: boolean | undefined, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositorySeed>;
|
|
2640
2642
|
deleteRepository(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<axios.AxiosResponse<any, any>>;
|
|
2641
2643
|
createRepositoryDeployKey(repositoryName: string, deployKey: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<{
|
|
2642
2644
|
keys: GitHubRepositoryKey[];
|
package/dist/index.d.ts
CHANGED
|
@@ -922,10 +922,10 @@ interface AppAuthorizationData {
|
|
|
922
922
|
|
|
923
923
|
type AddAppAuthorizationPayload = {
|
|
924
924
|
appId: string;
|
|
925
|
-
|
|
926
|
-
} & AppAuthorizationData;
|
|
925
|
+
} & Omit<AppAuthorizationData, "clientId">;
|
|
927
926
|
interface AddAppAuthorizationResult {
|
|
928
927
|
clientId: string;
|
|
928
|
+
clientSecret: string;
|
|
929
929
|
}
|
|
930
930
|
|
|
931
931
|
type UpdateAppAuthorizationPayload = {
|
|
@@ -2626,17 +2626,19 @@ declare const api: {
|
|
|
2626
2626
|
integrations: {
|
|
2627
2627
|
github: {
|
|
2628
2628
|
installation: {
|
|
2629
|
-
getInstallation(account?: string | undefined, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubInstallation | undefined>;
|
|
2629
|
+
getInstallation(appId: number, account?: string | undefined, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubInstallation | undefined>;
|
|
2630
2630
|
getInstallations(authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubInstallation[]>;
|
|
2631
2631
|
getInstallationRepositories(installationId: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepository[]>;
|
|
2632
2632
|
};
|
|
2633
2633
|
repository: {
|
|
2634
|
-
getRepository(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepository
|
|
2634
|
+
getRepository(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepository>;
|
|
2635
2635
|
getRepositoryBranches(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositoryBranch[]>;
|
|
2636
|
-
getRepositoryBranch(repositoryName: string, repositoryBranch: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositoryBranch
|
|
2636
|
+
getRepositoryBranch(repositoryName: string, repositoryBranch: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositoryBranch>;
|
|
2637
2637
|
getRepositorySeed(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositorySeed | undefined>;
|
|
2638
2638
|
createRepository(name: string, hasInstallation: boolean, template?: string | undefined, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepository>;
|
|
2639
|
-
seedRepository(repositoryName: string,
|
|
2639
|
+
seedRepository(repositoryName: string, manifest: AppManifest | {
|
|
2640
|
+
id: string;
|
|
2641
|
+
}, isForLabs?: boolean | undefined, authorization?: GithubClientInstanceAuthorization | undefined): Promise<GitHubRepositorySeed>;
|
|
2640
2642
|
deleteRepository(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<axios.AxiosResponse<any, any>>;
|
|
2641
2643
|
createRepositoryDeployKey(repositoryName: string, deployKey: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<{
|
|
2642
2644
|
keys: GitHubRepositoryKey[];
|
package/dist/index.js
CHANGED
|
@@ -140,88 +140,7 @@ __export(src_exports, {
|
|
|
140
140
|
module.exports = __toCommonJS(src_exports);
|
|
141
141
|
|
|
142
142
|
// src/apis/integrations/github/api.ts
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
// ../../private/config/src/integrations/github.ts
|
|
146
|
-
var GITHUB_CONFIG = {
|
|
147
|
-
url: "https://github.com/login/oauth/authorize",
|
|
148
|
-
app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
149
|
-
id: 265597,
|
|
150
|
-
client_name: "text-platform-developer-console",
|
|
151
|
-
client_id: "Iv1.c582ec1de0bf8428",
|
|
152
|
-
client_secret: process.env.GITHUB_APP_CLIENT_SECRET,
|
|
153
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/github/callbacks/app"
|
|
154
|
-
} : {
|
|
155
|
-
id: 319969,
|
|
156
|
-
client_name: "text-platform-labs",
|
|
157
|
-
client_id: "Iv1.e631130cf8ac91d7",
|
|
158
|
-
client_secret: process.env.GITHUB_APP_CLIENT_SECRET_LABS,
|
|
159
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/github/callbacks/app"
|
|
160
|
-
},
|
|
161
|
-
oauth: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
162
|
-
client_id: "ebbb08fa2c26d3e7911d",
|
|
163
|
-
client_secret: process.env.GITHUB_OAUTH_CLIENT_SECRET,
|
|
164
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/github/callbacks/oauth"
|
|
165
|
-
} : {
|
|
166
|
-
client_id: "bcffd61bd0edd23bca45",
|
|
167
|
-
client_secret: process.env.GITHUB_OAUTH_CLIENT_SECRET_LABS,
|
|
168
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/github/callbacks/oauth"
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// ../../private/config/src/integrations/netlify.ts
|
|
173
|
-
var NETLIFY_CONFIG = {
|
|
174
|
-
url: "https://app.netlify.com/authorize",
|
|
175
|
-
github_app_client_name: "netlify",
|
|
176
|
-
app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
177
|
-
client_id: "qUoHYb2DdVwKxot9Gc7URTdsZQYHYaumykjkv5K3_Mw",
|
|
178
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/netlify/callbacks/oauth",
|
|
179
|
-
client_secret: process.env.NETLIFY_CLIENT_SECRET
|
|
180
|
-
} : {
|
|
181
|
-
client_id: "vDmNXNN9rTkZJtCwOHot2IKOherrm8t7gGA5kStotlo",
|
|
182
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/netlify/callbacks/oauth",
|
|
183
|
-
client_secret: process.env.NETLIFY_CLIENT_SECRET_LABS
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// ../../private/config/src/integrations/planetscale.ts
|
|
188
|
-
var PLANETSCALE_CONFIG = {
|
|
189
|
-
url: "http://app.planetscale.com/oauth/authorize",
|
|
190
|
-
github_app_client_name: "planetscale",
|
|
191
|
-
app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
192
|
-
organization: "livechat",
|
|
193
|
-
appId: "bw2hi8knpzbl",
|
|
194
|
-
client_id: "pscale_app_b0aa82ae3d32f32010d7352d88f22fb2",
|
|
195
|
-
service_token_id: "be5l1vy34g6h",
|
|
196
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/planetscale/callbacks/oauth",
|
|
197
|
-
client_secret: process.env.PLANETSCALE_CLIENT_SECRET,
|
|
198
|
-
service_token: process.env.PLANETSCALE_SERVICE_TOKEN
|
|
199
|
-
} : {
|
|
200
|
-
organization: "livechat",
|
|
201
|
-
appId: "oz4pafhcyshn",
|
|
202
|
-
client_id: "pscale_app_54606de46e127f664df359639baf6b66",
|
|
203
|
-
service_token_id: "qdpgtmrqpdsm",
|
|
204
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/planetscale/callbacks/oauth",
|
|
205
|
-
client_secret: process.env.PLANETSCALE_CLIENT_SECRET_LABS,
|
|
206
|
-
service_token: process.env.PLANETSCALE_SERVICE_TOKEN_LABS
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
// ../../private/config/src/integrations/vercel.ts
|
|
211
|
-
var VERCEL_CONFIG = {
|
|
212
|
-
github_app_client_name: "vercel",
|
|
213
|
-
app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
214
|
-
client_name: "text-platform-developer-console",
|
|
215
|
-
client_id: "oac_0nV7q5jDmCQKqpwEdGljaaLp",
|
|
216
|
-
client_secret: process.env.VERCEL_CLIENT_SECRET,
|
|
217
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/vercel/callbacks/oauth"
|
|
218
|
-
} : {
|
|
219
|
-
client_name: "text-platform-labs",
|
|
220
|
-
client_id: "oac_bgwv72AO8fJWj8I9qIROY7wI",
|
|
221
|
-
client_secret: process.env.VERCEL_CLIENT_SECRET_LABS,
|
|
222
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/vercel/callbacks/oauth"
|
|
223
|
-
}
|
|
224
|
-
};
|
|
143
|
+
var import_axios3 = __toESM(require("axios"));
|
|
225
144
|
|
|
226
145
|
// src/apis/integrations/github/instance.ts
|
|
227
146
|
var import_axios = __toESM(require("axios"));
|
|
@@ -306,11 +225,11 @@ function updateGithubClientInstance(token) {
|
|
|
306
225
|
|
|
307
226
|
// src/apis/integrations/github/installation/api.ts
|
|
308
227
|
var gitHubInstallationApi = {
|
|
309
|
-
getInstallation(account, authorization) {
|
|
228
|
+
getInstallation(appId, account, authorization) {
|
|
310
229
|
return __async(this, null, function* () {
|
|
311
230
|
const installations = yield this.getInstallations(authorization);
|
|
312
231
|
return installations.find(
|
|
313
|
-
(installation) => installation.app_id ===
|
|
232
|
+
(installation) => installation.app_id === appId && account ? installation.account.login === account : installation.target_type === "User"
|
|
314
233
|
);
|
|
315
234
|
});
|
|
316
235
|
},
|
|
@@ -343,6 +262,7 @@ var gitHubInstallationApi = {
|
|
|
343
262
|
};
|
|
344
263
|
|
|
345
264
|
// src/apis/integrations/github/repository/api.ts
|
|
265
|
+
var import_axios2 = require("axios");
|
|
346
266
|
var gitHubRepositoryApi = {
|
|
347
267
|
getRepository(repositoryName, authorization) {
|
|
348
268
|
return __async(this, null, function* () {
|
|
@@ -380,9 +300,13 @@ var gitHubRepositoryApi = {
|
|
|
380
300
|
ensureAuthorizationToken: true
|
|
381
301
|
})
|
|
382
302
|
);
|
|
383
|
-
|
|
303
|
+
const branch = response.data.find(
|
|
384
304
|
(innerBranch) => innerBranch.name === repositoryBranch
|
|
385
305
|
);
|
|
306
|
+
if (!branch) {
|
|
307
|
+
throw new import_axios2.AxiosError("Repository branch cannot be found", "404");
|
|
308
|
+
}
|
|
309
|
+
return branch;
|
|
386
310
|
});
|
|
387
311
|
},
|
|
388
312
|
getRepositorySeed(repositoryName, authorization) {
|
|
@@ -464,7 +388,7 @@ var gitHubRepositoryApi = {
|
|
|
464
388
|
return response.data;
|
|
465
389
|
});
|
|
466
390
|
},
|
|
467
|
-
seedRepository(repositoryName,
|
|
391
|
+
seedRepository(repositoryName, manifest, isForLabs, authorization) {
|
|
468
392
|
return __async(this, null, function* () {
|
|
469
393
|
const upsert = (sha) => __async(this, null, function* () {
|
|
470
394
|
var _a;
|
|
@@ -475,12 +399,7 @@ var gitHubRepositoryApi = {
|
|
|
475
399
|
sha,
|
|
476
400
|
content: btoa(
|
|
477
401
|
JSON.stringify(
|
|
478
|
-
__spreadValues({
|
|
479
|
-
appId,
|
|
480
|
-
auth: {
|
|
481
|
-
clientId
|
|
482
|
-
}
|
|
483
|
-
}, isForLabs ? {
|
|
402
|
+
__spreadValues(__spreadValues({}, manifest), isForLabs ? {
|
|
484
403
|
stage: "labs"
|
|
485
404
|
} : {}),
|
|
486
405
|
null,
|
|
@@ -673,7 +592,7 @@ var gitHubApi = {
|
|
|
673
592
|
client_secret: clientSecret,
|
|
674
593
|
redirect_uri: redirectUrl
|
|
675
594
|
});
|
|
676
|
-
const response = yield
|
|
595
|
+
const response = yield import_axios3.default.post(
|
|
677
596
|
"https://github.com/login/oauth/access_token",
|
|
678
597
|
data,
|
|
679
598
|
{
|
|
@@ -689,8 +608,8 @@ var gitHubApi = {
|
|
|
689
608
|
};
|
|
690
609
|
|
|
691
610
|
// src/apis/integrations/netlify/instance.ts
|
|
692
|
-
var
|
|
693
|
-
var netlifyClientInstance =
|
|
611
|
+
var import_axios4 = __toESM(require("axios"));
|
|
612
|
+
var netlifyClientInstance = import_axios4.default.create({
|
|
694
613
|
baseURL: "https://api.netlify.com/api/v1",
|
|
695
614
|
headers: {
|
|
696
615
|
"Content-Type": "application/json"
|
|
@@ -700,7 +619,7 @@ netlifyClientInstance.interceptors.response.use(
|
|
|
700
619
|
(r) => r,
|
|
701
620
|
(error) => {
|
|
702
621
|
var _a;
|
|
703
|
-
if (
|
|
622
|
+
if (import_axios4.default.isAxiosError(error)) {
|
|
704
623
|
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
705
624
|
throw new UnauthorizeApiError("netlify");
|
|
706
625
|
}
|
|
@@ -869,7 +788,7 @@ var netlifyHookApi = {
|
|
|
869
788
|
event: "deploy_created",
|
|
870
789
|
type: "url",
|
|
871
790
|
data: {
|
|
872
|
-
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}
|
|
791
|
+
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}/api/integrations/netlify/webhook`
|
|
873
792
|
}
|
|
874
793
|
},
|
|
875
794
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -886,7 +805,7 @@ var netlifyHookApi = {
|
|
|
886
805
|
event: "deploy_failed",
|
|
887
806
|
type: "url",
|
|
888
807
|
data: {
|
|
889
|
-
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}
|
|
808
|
+
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}/api/integrations/netlify/webhook`
|
|
890
809
|
}
|
|
891
810
|
},
|
|
892
811
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -903,7 +822,7 @@ var netlifyHookApi = {
|
|
|
903
822
|
event: "deploy_building",
|
|
904
823
|
type: "url",
|
|
905
824
|
data: {
|
|
906
|
-
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}
|
|
825
|
+
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}/api/integrations/netlify/webhook`
|
|
907
826
|
}
|
|
908
827
|
},
|
|
909
828
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -1145,18 +1064,18 @@ var netlifyApi = {
|
|
|
1145
1064
|
};
|
|
1146
1065
|
|
|
1147
1066
|
// src/apis/integrations/planetscale/api.ts
|
|
1148
|
-
var
|
|
1067
|
+
var import_axios6 = __toESM(require("axios"));
|
|
1149
1068
|
|
|
1150
1069
|
// src/apis/integrations/planetscale/instance.ts
|
|
1151
|
-
var
|
|
1152
|
-
var planetScaleClientInstance =
|
|
1070
|
+
var import_axios5 = __toESM(require("axios"));
|
|
1071
|
+
var planetScaleClientInstance = import_axios5.default.create({
|
|
1153
1072
|
baseURL: "https://api.planetscale.com"
|
|
1154
1073
|
});
|
|
1155
1074
|
planetScaleClientInstance.interceptors.response.use(
|
|
1156
1075
|
(r) => r,
|
|
1157
1076
|
(error) => {
|
|
1158
1077
|
var _a;
|
|
1159
|
-
if (
|
|
1078
|
+
if (import_axios5.default.isAxiosError(error)) {
|
|
1160
1079
|
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
1161
1080
|
throw new UnauthorizeApiError("planetscale");
|
|
1162
1081
|
}
|
|
@@ -1352,7 +1271,7 @@ var planetscaleApi = {
|
|
|
1352
1271
|
redirect_uri: redirectUrl,
|
|
1353
1272
|
grant_type: "authorization_code"
|
|
1354
1273
|
});
|
|
1355
|
-
const response = yield
|
|
1274
|
+
const response = yield import_axios6.default.post(
|
|
1356
1275
|
`https://api.planetscale.com/v1/organizations/${organization}/oauth-applications/${applicationId}/token`,
|
|
1357
1276
|
data,
|
|
1358
1277
|
{
|
|
@@ -1372,8 +1291,8 @@ var planetscaleApi = {
|
|
|
1372
1291
|
};
|
|
1373
1292
|
|
|
1374
1293
|
// src/apis/integrations/text/instance.ts
|
|
1375
|
-
var
|
|
1376
|
-
var textClientInstance =
|
|
1294
|
+
var import_axios7 = __toESM(require("axios"));
|
|
1295
|
+
var textClientInstance = import_axios7.default.create({
|
|
1377
1296
|
baseURL: "https://api.labs.text.com"
|
|
1378
1297
|
});
|
|
1379
1298
|
function getTextClientAuthorization(req) {
|
|
@@ -1776,18 +1695,18 @@ var textApi = {
|
|
|
1776
1695
|
};
|
|
1777
1696
|
|
|
1778
1697
|
// src/apis/integrations/vercel/api.ts
|
|
1779
|
-
var
|
|
1698
|
+
var import_axios9 = __toESM(require("axios"));
|
|
1780
1699
|
|
|
1781
1700
|
// src/apis/integrations/vercel/instance.ts
|
|
1782
|
-
var
|
|
1783
|
-
var vercelClientInstance =
|
|
1701
|
+
var import_axios8 = __toESM(require("axios"));
|
|
1702
|
+
var vercelClientInstance = import_axios8.default.create({
|
|
1784
1703
|
baseURL: "https://api.vercel.com"
|
|
1785
1704
|
});
|
|
1786
1705
|
vercelClientInstance.interceptors.response.use(
|
|
1787
1706
|
(r) => r,
|
|
1788
1707
|
(error) => {
|
|
1789
1708
|
var _a, _b;
|
|
1790
|
-
if (
|
|
1709
|
+
if (import_axios8.default.isAxiosError(error)) {
|
|
1791
1710
|
if (((_a = error.response) == null ? void 0 : _a.status) === 401 || ((_b = error.response) == null ? void 0 : _b.status) === 403) {
|
|
1792
1711
|
throw new UnauthorizeApiError("vercel");
|
|
1793
1712
|
}
|
|
@@ -2076,7 +1995,7 @@ var vercelApi = {
|
|
|
2076
1995
|
client_secret: clientSecret,
|
|
2077
1996
|
redirect_uri: redirectUrl
|
|
2078
1997
|
});
|
|
2079
|
-
const response = yield
|
|
1998
|
+
const response = yield import_axios9.default.post("https://api.vercel.com/v2/oauth/access_token", data, {
|
|
2080
1999
|
headers: {
|
|
2081
2000
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2082
2001
|
}
|
|
@@ -2092,18 +2011,18 @@ var vercelApi = {
|
|
|
2092
2011
|
};
|
|
2093
2012
|
|
|
2094
2013
|
// src/apis/integrations/neon/api.ts
|
|
2095
|
-
var
|
|
2014
|
+
var import_axios11 = __toESM(require("axios"));
|
|
2096
2015
|
|
|
2097
2016
|
// src/apis/integrations/neon/instance.ts
|
|
2098
|
-
var
|
|
2099
|
-
var neonClientInstance =
|
|
2017
|
+
var import_axios10 = __toESM(require("axios"));
|
|
2018
|
+
var neonClientInstance = import_axios10.default.create({
|
|
2100
2019
|
baseURL: "https://console.neon.tech/api/v2/"
|
|
2101
2020
|
});
|
|
2102
2021
|
neonClientInstance.interceptors.response.use(
|
|
2103
2022
|
(r) => r,
|
|
2104
2023
|
(error) => {
|
|
2105
2024
|
var _a;
|
|
2106
|
-
if (
|
|
2025
|
+
if (import_axios10.default.isAxiosError(error)) {
|
|
2107
2026
|
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
2108
2027
|
throw new UnauthorizeApiError("neon");
|
|
2109
2028
|
}
|
|
@@ -2316,7 +2235,7 @@ var neonApi = {
|
|
|
2316
2235
|
redirect_uri: redirectUri,
|
|
2317
2236
|
grant_type: "authorization_code"
|
|
2318
2237
|
});
|
|
2319
|
-
const response = yield
|
|
2238
|
+
const response = yield import_axios11.default.post(
|
|
2320
2239
|
"https://oauth2.neon.tech/oauth2/token",
|
|
2321
2240
|
data,
|
|
2322
2241
|
{
|
|
@@ -2341,7 +2260,7 @@ var neonApi = {
|
|
|
2341
2260
|
client_secret: clientSecret,
|
|
2342
2261
|
grant_type: "refresh_token"
|
|
2343
2262
|
});
|
|
2344
|
-
const response = yield
|
|
2263
|
+
const response = yield import_axios11.default.post("https://oauth2.neon.tech/oauth2/token", data, {
|
|
2345
2264
|
headers: {
|
|
2346
2265
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2347
2266
|
}
|
|
@@ -2366,7 +2285,7 @@ var integrationsApi = {
|
|
|
2366
2285
|
};
|
|
2367
2286
|
|
|
2368
2287
|
// src/apis/products/livechat/instance.ts
|
|
2369
|
-
var
|
|
2288
|
+
var import_axios12 = __toESM(require("axios"));
|
|
2370
2289
|
var REGION = {
|
|
2371
2290
|
FRA: "fra",
|
|
2372
2291
|
DAL: "dal",
|
|
@@ -2380,7 +2299,7 @@ var getRegion = (token) => {
|
|
|
2380
2299
|
return region;
|
|
2381
2300
|
}
|
|
2382
2301
|
};
|
|
2383
|
-
var livechatClientInstance =
|
|
2302
|
+
var livechatClientInstance = import_axios12.default.create({
|
|
2384
2303
|
baseURL: "https://api.labs.livechatinc.com"
|
|
2385
2304
|
});
|
|
2386
2305
|
function getLiveChatClientAuthorization(req) {
|
|
@@ -2878,14 +2797,14 @@ var productsApi = {
|
|
|
2878
2797
|
};
|
|
2879
2798
|
|
|
2880
2799
|
// src/apis/platform/accounts/instance.ts
|
|
2881
|
-
var
|
|
2800
|
+
var import_axios13 = __toESM(require("axios"));
|
|
2882
2801
|
var AccountsApiError = class extends ApiErrorBase {
|
|
2883
2802
|
constructor() {
|
|
2884
2803
|
super(...arguments);
|
|
2885
2804
|
this.name = "accounts";
|
|
2886
2805
|
}
|
|
2887
2806
|
};
|
|
2888
|
-
var platformAccountsClientInstance =
|
|
2807
|
+
var platformAccountsClientInstance = import_axios13.default.create({
|
|
2889
2808
|
baseURL: "https://accounts.labs.livechatinc.com"
|
|
2890
2809
|
});
|
|
2891
2810
|
platformAccountsClientInstance.interceptors.response.use(
|
|
@@ -3214,14 +3133,14 @@ var platformAccountsApi = {
|
|
|
3214
3133
|
};
|
|
3215
3134
|
|
|
3216
3135
|
// src/apis/platform/dps/instance.ts
|
|
3217
|
-
var
|
|
3136
|
+
var import_axios14 = __toESM(require("axios"));
|
|
3218
3137
|
var DpsApiError = class extends ApiErrorBase {
|
|
3219
3138
|
constructor() {
|
|
3220
3139
|
super(...arguments);
|
|
3221
3140
|
this.name = "dps";
|
|
3222
3141
|
}
|
|
3223
3142
|
};
|
|
3224
|
-
var platformDpsClientInstance =
|
|
3143
|
+
var platformDpsClientInstance = import_axios14.default.create({
|
|
3225
3144
|
baseURL: "https://dev-platform.labs.livechatinc.com"
|
|
3226
3145
|
});
|
|
3227
3146
|
platformDpsClientInstance.interceptors.response.use(
|
|
@@ -3248,8 +3167,7 @@ function getPlatformDpsClientAuthorization(req) {
|
|
|
3248
3167
|
};
|
|
3249
3168
|
}
|
|
3250
3169
|
function getPlatformDpsAdminClientAuthorization() {
|
|
3251
|
-
|
|
3252
|
-
const token = process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? (_a = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB) != null ? _a : "" : (_b = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB_LABS) != null ? _b : "";
|
|
3170
|
+
const token = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB;
|
|
3253
3171
|
return {
|
|
3254
3172
|
token: btoa(`apps@livechatinc.com:${token}`),
|
|
3255
3173
|
tokenType: "Basic"
|
|
@@ -3574,7 +3492,7 @@ var appTemplates = {
|
|
|
3574
3492
|
}
|
|
3575
3493
|
],
|
|
3576
3494
|
type: "javascript_app",
|
|
3577
|
-
redirectUri: "
|
|
3495
|
+
redirectUri: ""
|
|
3578
3496
|
},
|
|
3579
3497
|
widgets: {
|
|
3580
3498
|
"chat-details": {
|
|
@@ -5119,7 +5037,7 @@ var platformDpsApi = {
|
|
|
5119
5037
|
};
|
|
5120
5038
|
|
|
5121
5039
|
// src/apis/platform/adapter/instance.ts
|
|
5122
|
-
var
|
|
5040
|
+
var import_axios15 = __toESM(require("axios"));
|
|
5123
5041
|
var REGION2 = {
|
|
5124
5042
|
FRA: "fra",
|
|
5125
5043
|
DAL: "dal",
|
|
@@ -5155,7 +5073,7 @@ function getPlatformAdapterClientAuthorization(req) {
|
|
|
5155
5073
|
openai: req.headers["openai-token"]
|
|
5156
5074
|
};
|
|
5157
5075
|
}
|
|
5158
|
-
var platformAdapterClientInstance =
|
|
5076
|
+
var platformAdapterClientInstance = import_axios15.default.create({
|
|
5159
5077
|
baseURL: "https://platform.labs.text.com/console-adapter/api",
|
|
5160
5078
|
headers: {
|
|
5161
5079
|
"Content-Type": "application/json"
|
|
@@ -5783,8 +5701,8 @@ var platformAdapterConductorApi = {
|
|
|
5783
5701
|
};
|
|
5784
5702
|
|
|
5785
5703
|
// src/apis/platform/billing/instance.ts
|
|
5786
|
-
var
|
|
5787
|
-
var platformBillingClientInstance =
|
|
5704
|
+
var import_axios16 = __toESM(require("axios"));
|
|
5705
|
+
var platformBillingClientInstance = import_axios16.default.create({
|
|
5788
5706
|
baseURL: "https://billing.labs.livechatinc.com"
|
|
5789
5707
|
});
|
|
5790
5708
|
function getPlatformBillingClientAuthorization(req) {
|
package/dist/index.mjs
CHANGED
|
@@ -41,87 +41,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41
41
|
// src/apis/integrations/github/api.ts
|
|
42
42
|
import axios2 from "axios";
|
|
43
43
|
|
|
44
|
-
// ../../private/config/src/integrations/github.ts
|
|
45
|
-
var GITHUB_CONFIG = {
|
|
46
|
-
url: "https://github.com/login/oauth/authorize",
|
|
47
|
-
app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
48
|
-
id: 265597,
|
|
49
|
-
client_name: "text-platform-developer-console",
|
|
50
|
-
client_id: "Iv1.c582ec1de0bf8428",
|
|
51
|
-
client_secret: process.env.GITHUB_APP_CLIENT_SECRET,
|
|
52
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/github/callbacks/app"
|
|
53
|
-
} : {
|
|
54
|
-
id: 319969,
|
|
55
|
-
client_name: "text-platform-labs",
|
|
56
|
-
client_id: "Iv1.e631130cf8ac91d7",
|
|
57
|
-
client_secret: process.env.GITHUB_APP_CLIENT_SECRET_LABS,
|
|
58
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/github/callbacks/app"
|
|
59
|
-
},
|
|
60
|
-
oauth: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
61
|
-
client_id: "ebbb08fa2c26d3e7911d",
|
|
62
|
-
client_secret: process.env.GITHUB_OAUTH_CLIENT_SECRET,
|
|
63
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/github/callbacks/oauth"
|
|
64
|
-
} : {
|
|
65
|
-
client_id: "bcffd61bd0edd23bca45",
|
|
66
|
-
client_secret: process.env.GITHUB_OAUTH_CLIENT_SECRET_LABS,
|
|
67
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/github/callbacks/oauth"
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// ../../private/config/src/integrations/netlify.ts
|
|
72
|
-
var NETLIFY_CONFIG = {
|
|
73
|
-
url: "https://app.netlify.com/authorize",
|
|
74
|
-
github_app_client_name: "netlify",
|
|
75
|
-
app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
76
|
-
client_id: "qUoHYb2DdVwKxot9Gc7URTdsZQYHYaumykjkv5K3_Mw",
|
|
77
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/netlify/callbacks/oauth",
|
|
78
|
-
client_secret: process.env.NETLIFY_CLIENT_SECRET
|
|
79
|
-
} : {
|
|
80
|
-
client_id: "vDmNXNN9rTkZJtCwOHot2IKOherrm8t7gGA5kStotlo",
|
|
81
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/netlify/callbacks/oauth",
|
|
82
|
-
client_secret: process.env.NETLIFY_CLIENT_SECRET_LABS
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// ../../private/config/src/integrations/planetscale.ts
|
|
87
|
-
var PLANETSCALE_CONFIG = {
|
|
88
|
-
url: "http://app.planetscale.com/oauth/authorize",
|
|
89
|
-
github_app_client_name: "planetscale",
|
|
90
|
-
app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
91
|
-
organization: "livechat",
|
|
92
|
-
appId: "bw2hi8knpzbl",
|
|
93
|
-
client_id: "pscale_app_b0aa82ae3d32f32010d7352d88f22fb2",
|
|
94
|
-
service_token_id: "be5l1vy34g6h",
|
|
95
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/planetscale/callbacks/oauth",
|
|
96
|
-
client_secret: process.env.PLANETSCALE_CLIENT_SECRET,
|
|
97
|
-
service_token: process.env.PLANETSCALE_SERVICE_TOKEN
|
|
98
|
-
} : {
|
|
99
|
-
organization: "livechat",
|
|
100
|
-
appId: "oz4pafhcyshn",
|
|
101
|
-
client_id: "pscale_app_54606de46e127f664df359639baf6b66",
|
|
102
|
-
service_token_id: "qdpgtmrqpdsm",
|
|
103
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/planetscale/callbacks/oauth",
|
|
104
|
-
client_secret: process.env.PLANETSCALE_CLIENT_SECRET_LABS,
|
|
105
|
-
service_token: process.env.PLANETSCALE_SERVICE_TOKEN_LABS
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// ../../private/config/src/integrations/vercel.ts
|
|
110
|
-
var VERCEL_CONFIG = {
|
|
111
|
-
github_app_client_name: "vercel",
|
|
112
|
-
app: process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? {
|
|
113
|
-
client_name: "text-platform-developer-console",
|
|
114
|
-
client_id: "oac_0nV7q5jDmCQKqpwEdGljaaLp",
|
|
115
|
-
client_secret: process.env.VERCEL_CLIENT_SECRET,
|
|
116
|
-
redirect_uri: "https://platform.text.com/console-adapter/integrations/vercel/callbacks/oauth"
|
|
117
|
-
} : {
|
|
118
|
-
client_name: "text-platform-labs",
|
|
119
|
-
client_id: "oac_bgwv72AO8fJWj8I9qIROY7wI",
|
|
120
|
-
client_secret: process.env.VERCEL_CLIENT_SECRET_LABS,
|
|
121
|
-
redirect_uri: "https://platform.labs.text.com/console-adapter/integrations/vercel/callbacks/oauth"
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
44
|
// src/apis/integrations/github/instance.ts
|
|
126
45
|
import axios from "axios";
|
|
127
46
|
|
|
@@ -205,11 +124,11 @@ function updateGithubClientInstance(token) {
|
|
|
205
124
|
|
|
206
125
|
// src/apis/integrations/github/installation/api.ts
|
|
207
126
|
var gitHubInstallationApi = {
|
|
208
|
-
getInstallation(account, authorization) {
|
|
127
|
+
getInstallation(appId, account, authorization) {
|
|
209
128
|
return __async(this, null, function* () {
|
|
210
129
|
const installations = yield this.getInstallations(authorization);
|
|
211
130
|
return installations.find(
|
|
212
|
-
(installation) => installation.app_id ===
|
|
131
|
+
(installation) => installation.app_id === appId && account ? installation.account.login === account : installation.target_type === "User"
|
|
213
132
|
);
|
|
214
133
|
});
|
|
215
134
|
},
|
|
@@ -242,6 +161,7 @@ var gitHubInstallationApi = {
|
|
|
242
161
|
};
|
|
243
162
|
|
|
244
163
|
// src/apis/integrations/github/repository/api.ts
|
|
164
|
+
import { AxiosError } from "axios";
|
|
245
165
|
var gitHubRepositoryApi = {
|
|
246
166
|
getRepository(repositoryName, authorization) {
|
|
247
167
|
return __async(this, null, function* () {
|
|
@@ -279,9 +199,13 @@ var gitHubRepositoryApi = {
|
|
|
279
199
|
ensureAuthorizationToken: true
|
|
280
200
|
})
|
|
281
201
|
);
|
|
282
|
-
|
|
202
|
+
const branch = response.data.find(
|
|
283
203
|
(innerBranch) => innerBranch.name === repositoryBranch
|
|
284
204
|
);
|
|
205
|
+
if (!branch) {
|
|
206
|
+
throw new AxiosError("Repository branch cannot be found", "404");
|
|
207
|
+
}
|
|
208
|
+
return branch;
|
|
285
209
|
});
|
|
286
210
|
},
|
|
287
211
|
getRepositorySeed(repositoryName, authorization) {
|
|
@@ -363,7 +287,7 @@ var gitHubRepositoryApi = {
|
|
|
363
287
|
return response.data;
|
|
364
288
|
});
|
|
365
289
|
},
|
|
366
|
-
seedRepository(repositoryName,
|
|
290
|
+
seedRepository(repositoryName, manifest, isForLabs, authorization) {
|
|
367
291
|
return __async(this, null, function* () {
|
|
368
292
|
const upsert = (sha) => __async(this, null, function* () {
|
|
369
293
|
var _a;
|
|
@@ -374,12 +298,7 @@ var gitHubRepositoryApi = {
|
|
|
374
298
|
sha,
|
|
375
299
|
content: btoa(
|
|
376
300
|
JSON.stringify(
|
|
377
|
-
__spreadValues({
|
|
378
|
-
appId,
|
|
379
|
-
auth: {
|
|
380
|
-
clientId
|
|
381
|
-
}
|
|
382
|
-
}, isForLabs ? {
|
|
301
|
+
__spreadValues(__spreadValues({}, manifest), isForLabs ? {
|
|
383
302
|
stage: "labs"
|
|
384
303
|
} : {}),
|
|
385
304
|
null,
|
|
@@ -768,7 +687,7 @@ var netlifyHookApi = {
|
|
|
768
687
|
event: "deploy_created",
|
|
769
688
|
type: "url",
|
|
770
689
|
data: {
|
|
771
|
-
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}
|
|
690
|
+
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}/api/integrations/netlify/webhook`
|
|
772
691
|
}
|
|
773
692
|
},
|
|
774
693
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -785,7 +704,7 @@ var netlifyHookApi = {
|
|
|
785
704
|
event: "deploy_failed",
|
|
786
705
|
type: "url",
|
|
787
706
|
data: {
|
|
788
|
-
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}
|
|
707
|
+
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}/api/integrations/netlify/webhook`
|
|
789
708
|
}
|
|
790
709
|
},
|
|
791
710
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -802,7 +721,7 @@ var netlifyHookApi = {
|
|
|
802
721
|
event: "deploy_building",
|
|
803
722
|
type: "url",
|
|
804
723
|
data: {
|
|
805
|
-
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}
|
|
724
|
+
url: `${process.env.NEXT_PUBLIC_PLATFORM_DEVELOPER_CONSOLE_ADAPTER_APP_URL}/api/integrations/netlify/webhook`
|
|
806
725
|
}
|
|
807
726
|
},
|
|
808
727
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -3147,8 +3066,7 @@ function getPlatformDpsClientAuthorization(req) {
|
|
|
3147
3066
|
};
|
|
3148
3067
|
}
|
|
3149
3068
|
function getPlatformDpsAdminClientAuthorization() {
|
|
3150
|
-
|
|
3151
|
-
const token = process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? (_a = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB) != null ? _a : "" : (_b = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB_LABS) != null ? _b : "";
|
|
3069
|
+
const token = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB;
|
|
3152
3070
|
return {
|
|
3153
3071
|
token: btoa(`apps@livechatinc.com:${token}`),
|
|
3154
3072
|
tokenType: "Basic"
|
|
@@ -3473,7 +3391,7 @@ var appTemplates = {
|
|
|
3473
3391
|
}
|
|
3474
3392
|
],
|
|
3475
3393
|
type: "javascript_app",
|
|
3476
|
-
redirectUri: "
|
|
3394
|
+
redirectUri: ""
|
|
3477
3395
|
},
|
|
3478
3396
|
widgets: {
|
|
3479
3397
|
"chat-details": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livechat/developer-studio-api",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "This project is API for LiveChat Developer Studio.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,15 +11,14 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"axios": "
|
|
14
|
+
"axios": "1.6.5"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/node": "^17.0.12",
|
|
18
18
|
"tsup": "^7.1.0",
|
|
19
19
|
"typescript": "^5.1.6",
|
|
20
|
-
"
|
|
21
|
-
"config": "0.0.
|
|
22
|
-
"tsconfig": "0.0.1"
|
|
20
|
+
"tsconfig": "0.0.1",
|
|
21
|
+
"eslint-config-custom": "0.0.5"
|
|
23
22
|
},
|
|
24
23
|
"scripts": {
|
|
25
24
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|