@livechat/developer-studio-api 2.2.1 → 2.3.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.d.mts +282 -271
- package/dist/index.d.ts +282 -271
- package/dist/index.js +526 -315
- package/dist/index.mjs +526 -314
- package/package.json +4 -5
package/dist/index.mjs
CHANGED
|
@@ -41,70 +41,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41
41
|
// src/apis/integrations/github/api.ts
|
|
42
42
|
import axios2 from "axios";
|
|
43
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
|
-
if (options.ensureAuthorizationToken && !headers.authorization) {
|
|
89
|
-
throw new UnauthorizeApiError("github");
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function initGithubClientInstance(token) {
|
|
96
|
-
if (token) {
|
|
97
|
-
updateGithubClientInstance(token);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function updateGithubClientInstance(token) {
|
|
101
|
-
if (token) {
|
|
102
|
-
githubClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
|
|
103
|
-
} else {
|
|
104
|
-
delete githubClientInstance.defaults.headers["Authorization"];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
44
|
// ../../private/config/src/integrations/github.ts
|
|
109
45
|
var GITHUB_CONFIG = {
|
|
110
46
|
url: "https://github.com/login/oauth/authorize",
|
|
@@ -200,6 +136,72 @@ var VERCEL_CONFIG = {
|
|
|
200
136
|
}
|
|
201
137
|
};
|
|
202
138
|
|
|
139
|
+
// src/apis/integrations/github/instance.ts
|
|
140
|
+
import axios from "axios";
|
|
141
|
+
|
|
142
|
+
// src/types/errors/api.ts
|
|
143
|
+
var UnauthorizeApiError = class extends Error {
|
|
144
|
+
constructor(source) {
|
|
145
|
+
super("Unauthorized API call");
|
|
146
|
+
this.source = source;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// src/apis/integrations/github/instance.ts
|
|
151
|
+
var githubClientInstance = axios.create({
|
|
152
|
+
baseURL: "https://api.github.com",
|
|
153
|
+
headers: {
|
|
154
|
+
Accept: "application/vnd.github+json",
|
|
155
|
+
"Content-Type": "application/json"
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
githubClientInstance.interceptors.response.use(
|
|
159
|
+
(r) => r,
|
|
160
|
+
(error) => {
|
|
161
|
+
var _a;
|
|
162
|
+
if (axios.isAxiosError(error)) {
|
|
163
|
+
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
164
|
+
throw new UnauthorizeApiError("github");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
function getGitHubClientAuthorization(req) {
|
|
171
|
+
return {
|
|
172
|
+
tokens: {
|
|
173
|
+
app: req.headers["github-app-token"],
|
|
174
|
+
oauth: req.headers["github-oauth-token"]
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function getGithubClientRequestConfig(options = {}) {
|
|
179
|
+
const currentHeaders = githubClientInstance.defaults.headers;
|
|
180
|
+
const defaultAuthorization = currentHeaders.Authorization;
|
|
181
|
+
const headers = {
|
|
182
|
+
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
183
|
+
};
|
|
184
|
+
if (options.ensureAuthorizationToken && !headers.authorization) {
|
|
185
|
+
throw new UnauthorizeApiError("github");
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function initGithubClientInstance(token) {
|
|
192
|
+
if (token) {
|
|
193
|
+
updateGithubClientInstance(token);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function updateGithubClientInstance(token) {
|
|
197
|
+
const headers = githubClientInstance.defaults.headers;
|
|
198
|
+
if (token) {
|
|
199
|
+
headers.Authorization = `Bearer ${token}`;
|
|
200
|
+
} else {
|
|
201
|
+
delete headers.Authorization;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
203
205
|
// src/apis/integrations/github/installation/api.ts
|
|
204
206
|
var gitHubInstallationApi = {
|
|
205
207
|
getInstallation(account, authorization) {
|
|
@@ -277,7 +279,7 @@ var gitHubRepositoryApi = {
|
|
|
277
279
|
})
|
|
278
280
|
);
|
|
279
281
|
const branch = response.data.find(
|
|
280
|
-
(
|
|
282
|
+
(innerBranch) => innerBranch.name === repositoryBranch
|
|
281
283
|
);
|
|
282
284
|
if (!branch) {
|
|
283
285
|
throw new Error("Branch not found");
|
|
@@ -393,18 +395,18 @@ var gitHubRepositoryApi = {
|
|
|
393
395
|
);
|
|
394
396
|
return response.data.content;
|
|
395
397
|
});
|
|
396
|
-
let seed
|
|
398
|
+
let seed;
|
|
397
399
|
try {
|
|
398
400
|
seed = yield this.getRepositorySeed(repositoryName, authorization);
|
|
399
401
|
} catch (e) {
|
|
400
402
|
}
|
|
401
|
-
return
|
|
403
|
+
return upsert(seed == null ? void 0 : seed.sha);
|
|
402
404
|
});
|
|
403
405
|
},
|
|
404
406
|
deleteRepository(repositoryName, authorization) {
|
|
405
407
|
return __async(this, null, function* () {
|
|
406
408
|
var _a;
|
|
407
|
-
return
|
|
409
|
+
return githubClientInstance.delete(
|
|
408
410
|
`/repos/${repositoryName}`,
|
|
409
411
|
getGithubClientRequestConfig({
|
|
410
412
|
token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
|
|
@@ -580,7 +582,7 @@ var gitHubApi = {
|
|
|
580
582
|
}
|
|
581
583
|
}
|
|
582
584
|
);
|
|
583
|
-
|
|
585
|
+
const params = new URLSearchParams(response.data);
|
|
584
586
|
return (_a = params.get("access_token")) != null ? _a : "";
|
|
585
587
|
});
|
|
586
588
|
}
|
|
@@ -591,7 +593,7 @@ import axios3 from "axios";
|
|
|
591
593
|
var netlifyClientInstance = axios3.create({
|
|
592
594
|
baseURL: "https://api.netlify.com/api/v1",
|
|
593
595
|
headers: {
|
|
594
|
-
|
|
596
|
+
"Content-Type": "application/json"
|
|
595
597
|
}
|
|
596
598
|
});
|
|
597
599
|
netlifyClientInstance.interceptors.response.use(
|
|
@@ -600,7 +602,7 @@ netlifyClientInstance.interceptors.response.use(
|
|
|
600
602
|
var _a;
|
|
601
603
|
if (axios3.isAxiosError(error)) {
|
|
602
604
|
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
603
|
-
|
|
605
|
+
throw new UnauthorizeApiError("netlify");
|
|
604
606
|
}
|
|
605
607
|
}
|
|
606
608
|
throw error;
|
|
@@ -612,7 +614,8 @@ function getNetlifyClientAuthorization(req) {
|
|
|
612
614
|
};
|
|
613
615
|
}
|
|
614
616
|
function getNetlifyClientConfig(options = {}) {
|
|
615
|
-
const
|
|
617
|
+
const currentHeaders = netlifyClientInstance.defaults.headers;
|
|
618
|
+
const defaultAuthorization = currentHeaders.Authorization;
|
|
616
619
|
const headers = {
|
|
617
620
|
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
618
621
|
};
|
|
@@ -629,10 +632,11 @@ function initNetlifyClientInstance(token) {
|
|
|
629
632
|
}
|
|
630
633
|
}
|
|
631
634
|
function updateNetlifyClientInstance(token) {
|
|
635
|
+
const headers = netlifyClientInstance.defaults.headers;
|
|
632
636
|
if (token) {
|
|
633
|
-
|
|
637
|
+
headers.Authorization = `Bearer ${token}`;
|
|
634
638
|
} else {
|
|
635
|
-
delete
|
|
639
|
+
delete headers.Authorization;
|
|
636
640
|
}
|
|
637
641
|
}
|
|
638
642
|
|
|
@@ -651,14 +655,15 @@ var netlifyAccountApi = {
|
|
|
651
655
|
},
|
|
652
656
|
getAccountEnvs(accountId, siteId, authorization) {
|
|
653
657
|
return __async(this, null, function* () {
|
|
654
|
-
|
|
655
|
-
|
|
658
|
+
let targetAccountId = accountId;
|
|
659
|
+
if (!targetAccountId) {
|
|
660
|
+
targetAccountId = yield this.getAccount(authorization);
|
|
656
661
|
}
|
|
657
|
-
if (!
|
|
662
|
+
if (!targetAccountId) {
|
|
658
663
|
throw new Error("No account");
|
|
659
664
|
}
|
|
660
665
|
const { data: envs } = yield netlifyClientInstance.get(
|
|
661
|
-
`/accounts/${
|
|
666
|
+
`/accounts/${targetAccountId}/env?site_id=${siteId}&scope=all&context=all&level=all`,
|
|
662
667
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
663
668
|
ensureAuthorizationToken: true
|
|
664
669
|
}))
|
|
@@ -668,14 +673,15 @@ var netlifyAccountApi = {
|
|
|
668
673
|
},
|
|
669
674
|
getAccountEnv(accountId, siteId, envKey, authorization) {
|
|
670
675
|
return __async(this, null, function* () {
|
|
671
|
-
|
|
672
|
-
|
|
676
|
+
let targetAccountId = accountId;
|
|
677
|
+
if (!targetAccountId) {
|
|
678
|
+
targetAccountId = yield this.getAccount(authorization);
|
|
673
679
|
}
|
|
674
|
-
if (!
|
|
680
|
+
if (!targetAccountId) {
|
|
675
681
|
throw new Error("No account");
|
|
676
682
|
}
|
|
677
683
|
const { data: envs } = yield netlifyClientInstance.get(
|
|
678
|
-
`/accounts/${
|
|
684
|
+
`/accounts/${targetAccountId}/env/${envKey}?site_id=${siteId}`,
|
|
679
685
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
680
686
|
ensureAuthorizationToken: true
|
|
681
687
|
}))
|
|
@@ -685,25 +691,27 @@ var netlifyAccountApi = {
|
|
|
685
691
|
},
|
|
686
692
|
createAccountEnv(accountId, siteId, envName, envValue, envs, authorization) {
|
|
687
693
|
return __async(this, null, function* () {
|
|
688
|
-
|
|
689
|
-
|
|
694
|
+
let targetAccountId = accountId;
|
|
695
|
+
let targetEnvs = envs;
|
|
696
|
+
if (!targetAccountId) {
|
|
697
|
+
targetAccountId = yield this.getAccount(authorization);
|
|
690
698
|
}
|
|
691
|
-
if (!
|
|
699
|
+
if (!targetAccountId) {
|
|
692
700
|
throw new Error("No account");
|
|
693
701
|
}
|
|
694
|
-
if (!
|
|
702
|
+
if (!targetEnvs) {
|
|
695
703
|
const response = yield netlifyClientInstance.get(
|
|
696
|
-
`/accounts/${
|
|
704
|
+
`/accounts/${targetAccountId}/env?site_id=${siteId}&scope=all&context=all&level=all`,
|
|
697
705
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
698
706
|
ensureAuthorizationToken: true
|
|
699
707
|
}))
|
|
700
708
|
);
|
|
701
|
-
|
|
709
|
+
targetEnvs = response.data;
|
|
702
710
|
}
|
|
703
|
-
const existingEnv =
|
|
711
|
+
const existingEnv = targetEnvs.find((env) => env.key === envName);
|
|
704
712
|
if (existingEnv) {
|
|
705
713
|
yield netlifyClientInstance.put(
|
|
706
|
-
`/accounts/${
|
|
714
|
+
`/accounts/${targetAccountId}/env/${existingEnv.key}?site_id=${siteId}`,
|
|
707
715
|
{
|
|
708
716
|
key: existingEnv.key,
|
|
709
717
|
scopes: ["builds", "functions", "runtime", "post_processing"],
|
|
@@ -715,7 +723,7 @@ var netlifyAccountApi = {
|
|
|
715
723
|
);
|
|
716
724
|
} else {
|
|
717
725
|
yield netlifyClientInstance.post(
|
|
718
|
-
`/accounts/${
|
|
726
|
+
`/accounts/${targetAccountId}/env?site_id=${siteId}`,
|
|
719
727
|
[
|
|
720
728
|
{
|
|
721
729
|
key: envName,
|
|
@@ -751,19 +759,19 @@ var netlifyAccountApi = {
|
|
|
751
759
|
},
|
|
752
760
|
removeAccountEnv(accountId, siteId, envKey, authorization) {
|
|
753
761
|
return __async(this, null, function* () {
|
|
754
|
-
|
|
755
|
-
|
|
762
|
+
let targetAccountId = accountId;
|
|
763
|
+
if (!targetAccountId) {
|
|
764
|
+
targetAccountId = yield this.getAccount(authorization);
|
|
756
765
|
}
|
|
757
766
|
if (!accountId) {
|
|
758
767
|
throw new Error("No account");
|
|
759
768
|
}
|
|
760
|
-
|
|
761
|
-
`/accounts/${
|
|
769
|
+
yield netlifyClientInstance.delete(
|
|
770
|
+
`/accounts/${targetAccountId}/env/${envKey}?site_id=${siteId}`,
|
|
762
771
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
763
772
|
ensureAuthorizationToken: true
|
|
764
773
|
}))
|
|
765
774
|
);
|
|
766
|
-
return response.data;
|
|
767
775
|
});
|
|
768
776
|
}
|
|
769
777
|
};
|
|
@@ -773,7 +781,7 @@ var netlifyHookApi = {
|
|
|
773
781
|
addBuildHooks(siteId, authorization) {
|
|
774
782
|
return __async(this, null, function* () {
|
|
775
783
|
try {
|
|
776
|
-
netlifyClientInstance.post(
|
|
784
|
+
yield netlifyClientInstance.post(
|
|
777
785
|
"/hooks",
|
|
778
786
|
{
|
|
779
787
|
site_id: siteId,
|
|
@@ -790,7 +798,7 @@ var netlifyHookApi = {
|
|
|
790
798
|
} catch (e) {
|
|
791
799
|
}
|
|
792
800
|
try {
|
|
793
|
-
netlifyClientInstance.post(
|
|
801
|
+
yield netlifyClientInstance.post(
|
|
794
802
|
"/hooks",
|
|
795
803
|
{
|
|
796
804
|
site_id: siteId,
|
|
@@ -807,7 +815,7 @@ var netlifyHookApi = {
|
|
|
807
815
|
} catch (e) {
|
|
808
816
|
}
|
|
809
817
|
try {
|
|
810
|
-
netlifyClientInstance.post(
|
|
818
|
+
yield netlifyClientInstance.post(
|
|
811
819
|
"/hooks",
|
|
812
820
|
{
|
|
813
821
|
site_id: siteId,
|
|
@@ -876,7 +884,7 @@ var netlifySiteApi = {
|
|
|
876
884
|
}))
|
|
877
885
|
);
|
|
878
886
|
const deploy = deploys.filter(
|
|
879
|
-
(
|
|
887
|
+
(innerDeploy) => innerDeploy.context === "production"
|
|
880
888
|
)[0];
|
|
881
889
|
const { data: pluginRuns } = yield netlifyClientInstance.get(
|
|
882
890
|
`/deploys/${deploy.id}/plugin_runs`,
|
|
@@ -912,20 +920,23 @@ var netlifySiteApi = {
|
|
|
912
920
|
},
|
|
913
921
|
createSiteByInstallationId(name, repositoryFullName, target, installationId, branch, authorization) {
|
|
914
922
|
return __async(this, null, function* () {
|
|
915
|
-
const config =
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
923
|
+
const config = (
|
|
924
|
+
// eslint-disable-next-line no-nested-ternary -- fix me
|
|
925
|
+
target === "nextjs" ? {
|
|
926
|
+
plugins: ["@netlify/plugin-nextjs"],
|
|
927
|
+
packages: [{ package: "@netlify/plugin-nextjs" }],
|
|
928
|
+
dir: ".next",
|
|
929
|
+
cmd: "npm run build"
|
|
930
|
+
} : target === "node" ? {
|
|
931
|
+
plugins: [],
|
|
932
|
+
dir: "dist",
|
|
933
|
+
cmd: "npm run build"
|
|
934
|
+
} : {
|
|
935
|
+
plugin: [],
|
|
936
|
+
dir: ".",
|
|
937
|
+
cmd: ""
|
|
938
|
+
}
|
|
939
|
+
);
|
|
929
940
|
const response = yield netlifyClientInstance.post(
|
|
930
941
|
`/sites`,
|
|
931
942
|
{
|
|
@@ -956,19 +967,22 @@ var netlifySiteApi = {
|
|
|
956
967
|
},
|
|
957
968
|
createSiteByDeployKey(name, repositoryFullName, target, deployKeyId, branch, authorization) {
|
|
958
969
|
return __async(this, null, function* () {
|
|
959
|
-
const config =
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
970
|
+
const config = (
|
|
971
|
+
// eslint-disable-next-line no-nested-ternary -- fix me
|
|
972
|
+
target === "nextjs" ? {
|
|
973
|
+
packages: [{ package: "@netlify/plugin-nextjs" }],
|
|
974
|
+
dir: ".next",
|
|
975
|
+
cmd: "npm run build"
|
|
976
|
+
} : target === "node" ? {
|
|
977
|
+
packages: [],
|
|
978
|
+
dir: "dist",
|
|
979
|
+
cmd: "npm run build"
|
|
980
|
+
} : {
|
|
981
|
+
packages: [],
|
|
982
|
+
dir: ".",
|
|
983
|
+
cmd: ""
|
|
984
|
+
}
|
|
985
|
+
);
|
|
972
986
|
const response = yield netlifyClientInstance.post(
|
|
973
987
|
`/sites`,
|
|
974
988
|
{
|
|
@@ -997,13 +1011,12 @@ var netlifySiteApi = {
|
|
|
997
1011
|
},
|
|
998
1012
|
removeSite(siteId, authorization) {
|
|
999
1013
|
return __async(this, null, function* () {
|
|
1000
|
-
|
|
1014
|
+
yield netlifyClientInstance.delete(
|
|
1001
1015
|
`/sites/${siteId}`,
|
|
1002
1016
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
1003
1017
|
ensureAuthorizationToken: true
|
|
1004
1018
|
}))
|
|
1005
1019
|
);
|
|
1006
|
-
return response.data;
|
|
1007
1020
|
});
|
|
1008
1021
|
},
|
|
1009
1022
|
triggerSiteBuild(siteId, authorization) {
|
|
@@ -1116,14 +1129,12 @@ var netlifySiteApi = {
|
|
|
1116
1129
|
{
|
|
1117
1130
|
general_position: "footer",
|
|
1118
1131
|
title: "sentry",
|
|
1119
|
-
// eslint-disable-next-line no-useless-escape
|
|
1120
1132
|
general: `<script src='https://js.sentry-cdn.com/${projectKey}.min.js' crossorigin="anonymous"></script>`
|
|
1121
1133
|
},
|
|
1122
1134
|
getNetlifyClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
1123
1135
|
ensureAuthorizationToken: true
|
|
1124
1136
|
}))
|
|
1125
1137
|
);
|
|
1126
|
-
return;
|
|
1127
1138
|
});
|
|
1128
1139
|
}
|
|
1129
1140
|
};
|
|
@@ -1150,7 +1161,7 @@ planetScaleClientInstance.interceptors.response.use(
|
|
|
1150
1161
|
var _a;
|
|
1151
1162
|
if (axios4.isAxiosError(error)) {
|
|
1152
1163
|
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
1153
|
-
|
|
1164
|
+
throw new UnauthorizeApiError("planetscale");
|
|
1154
1165
|
}
|
|
1155
1166
|
}
|
|
1156
1167
|
throw error;
|
|
@@ -1162,7 +1173,8 @@ function getPlanetScaleClientAuthorization(req) {
|
|
|
1162
1173
|
};
|
|
1163
1174
|
}
|
|
1164
1175
|
function getPlanetScaleClientConfig(options = {}) {
|
|
1165
|
-
const
|
|
1176
|
+
const currentHeaders = planetScaleClientInstance.defaults.headers;
|
|
1177
|
+
const defaultAuthorization = currentHeaders.Authorization;
|
|
1166
1178
|
const headers = {
|
|
1167
1179
|
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `${options.token}` : void 0
|
|
1168
1180
|
};
|
|
@@ -1179,10 +1191,11 @@ function initPlanetScaleClientInstance(token) {
|
|
|
1179
1191
|
}
|
|
1180
1192
|
}
|
|
1181
1193
|
function updatePlanetScaleClientInstance(token) {
|
|
1194
|
+
const headers = planetScaleClientInstance.defaults.headers;
|
|
1182
1195
|
if (token) {
|
|
1183
|
-
|
|
1196
|
+
headers.Authorization = `${token}`;
|
|
1184
1197
|
} else {
|
|
1185
|
-
delete
|
|
1198
|
+
delete headers.Authorization;
|
|
1186
1199
|
}
|
|
1187
1200
|
}
|
|
1188
1201
|
|
|
@@ -1366,7 +1379,7 @@ import axios6 from "axios";
|
|
|
1366
1379
|
var sentryClientInstance = axios6.create({
|
|
1367
1380
|
baseURL: "https://sentry.io/api/0/",
|
|
1368
1381
|
headers: {
|
|
1369
|
-
|
|
1382
|
+
"Content-Type": "application/json"
|
|
1370
1383
|
}
|
|
1371
1384
|
});
|
|
1372
1385
|
sentryClientInstance.interceptors.response.use(
|
|
@@ -1375,7 +1388,7 @@ sentryClientInstance.interceptors.response.use(
|
|
|
1375
1388
|
var _a;
|
|
1376
1389
|
if (axios6.isAxiosError(error)) {
|
|
1377
1390
|
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
1378
|
-
|
|
1391
|
+
throw new UnauthorizeApiError("sentry");
|
|
1379
1392
|
}
|
|
1380
1393
|
}
|
|
1381
1394
|
throw error;
|
|
@@ -1387,7 +1400,8 @@ function getSentryClientAuthorization(req) {
|
|
|
1387
1400
|
};
|
|
1388
1401
|
}
|
|
1389
1402
|
function getSentryClientConfig(options = {}) {
|
|
1390
|
-
const
|
|
1403
|
+
const currentHeaders = sentryClientInstance.defaults.headers;
|
|
1404
|
+
const defaultAuthorization = currentHeaders.Authorization;
|
|
1391
1405
|
const headers = {
|
|
1392
1406
|
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
1393
1407
|
};
|
|
@@ -1405,10 +1419,11 @@ function initSentryClientInstance(token) {
|
|
|
1405
1419
|
}
|
|
1406
1420
|
}
|
|
1407
1421
|
function updateSentryClientInstance(token) {
|
|
1422
|
+
const headers = sentryClientInstance.defaults.headers;
|
|
1408
1423
|
if (token) {
|
|
1409
|
-
|
|
1424
|
+
headers.Authorization = `Bearer ${token}`;
|
|
1410
1425
|
} else {
|
|
1411
|
-
delete
|
|
1426
|
+
delete headers.Authorization;
|
|
1412
1427
|
}
|
|
1413
1428
|
}
|
|
1414
1429
|
|
|
@@ -1541,7 +1556,7 @@ var sentryApi = {
|
|
|
1541
1556
|
},
|
|
1542
1557
|
createRepo(organizationSlug, projectId, repositoryFullName, repositoryBranch, githubIntegrationId, authorization) {
|
|
1543
1558
|
return __async(this, null, function* () {
|
|
1544
|
-
var _a, _b
|
|
1559
|
+
var _a, _b;
|
|
1545
1560
|
let repository;
|
|
1546
1561
|
try {
|
|
1547
1562
|
const response = yield sentryClientInstance.post(
|
|
@@ -1558,7 +1573,7 @@ var sentryApi = {
|
|
|
1558
1573
|
repository = response.data;
|
|
1559
1574
|
} catch (err) {
|
|
1560
1575
|
const error = err;
|
|
1561
|
-
if (((
|
|
1576
|
+
if (((_a = error.response) == null ? void 0 : _a.data.error_type) === "validation" || ((_b = error.response) == null ? void 0 : _b.data.error_type) === "unknown") {
|
|
1562
1577
|
throw error;
|
|
1563
1578
|
}
|
|
1564
1579
|
const response = yield sentryClientInstance.get(
|
|
@@ -1618,10 +1633,7 @@ var sentryApi = {
|
|
|
1618
1633
|
);
|
|
1619
1634
|
} catch (error) {
|
|
1620
1635
|
if (((_a = error.response) == null ? void 0 : _a.status) === 409) {
|
|
1621
|
-
return
|
|
1622
|
-
`${organizationSlug}/${name}`,
|
|
1623
|
-
authorization
|
|
1624
|
-
);
|
|
1636
|
+
return this.getProject(`${organizationSlug}/${name}`, authorization);
|
|
1625
1637
|
}
|
|
1626
1638
|
throw error;
|
|
1627
1639
|
}
|
|
@@ -1629,13 +1641,12 @@ var sentryApi = {
|
|
|
1629
1641
|
},
|
|
1630
1642
|
deleteProject(projectFullName, authorization) {
|
|
1631
1643
|
return __async(this, null, function* () {
|
|
1632
|
-
|
|
1644
|
+
yield sentryClientInstance.delete(
|
|
1633
1645
|
`/projects/${projectFullName}/`,
|
|
1634
1646
|
getSentryClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
1635
1647
|
ensureAuthorizationToken: true
|
|
1636
1648
|
}))
|
|
1637
1649
|
);
|
|
1638
|
-
return response.data;
|
|
1639
1650
|
});
|
|
1640
1651
|
}
|
|
1641
1652
|
};
|
|
@@ -1652,7 +1663,8 @@ function getTextClientAuthorization(req) {
|
|
|
1652
1663
|
};
|
|
1653
1664
|
}
|
|
1654
1665
|
function getTextClientConfig(option = {}) {
|
|
1655
|
-
const
|
|
1666
|
+
const currentHeaders = textClientInstance.defaults.headers;
|
|
1667
|
+
const defaultAuthorization = currentHeaders.Authorization;
|
|
1656
1668
|
const headers = {
|
|
1657
1669
|
authorization: defaultAuthorization != null ? defaultAuthorization : option.token ? `Bearer ${option.token}` : void 0
|
|
1658
1670
|
};
|
|
@@ -1661,29 +1673,145 @@ function getTextClientConfig(option = {}) {
|
|
|
1661
1673
|
};
|
|
1662
1674
|
}
|
|
1663
1675
|
function initTextClientInstance(baseUrl, token) {
|
|
1676
|
+
const headers = textClientInstance.defaults.headers;
|
|
1664
1677
|
if (baseUrl) {
|
|
1665
1678
|
textClientInstance.interceptors.request.use(
|
|
1666
|
-
(config) =>
|
|
1679
|
+
(config) => {
|
|
1667
1680
|
config.baseURL = baseUrl;
|
|
1668
1681
|
return config;
|
|
1669
|
-
}
|
|
1682
|
+
},
|
|
1670
1683
|
(error) => Promise.reject(error)
|
|
1671
1684
|
);
|
|
1672
1685
|
}
|
|
1673
1686
|
if (token) {
|
|
1674
|
-
|
|
1687
|
+
headers.Authorization = `Bearer ${token}`;
|
|
1675
1688
|
} else {
|
|
1676
|
-
delete
|
|
1689
|
+
delete headers.Authorization;
|
|
1677
1690
|
}
|
|
1678
1691
|
}
|
|
1679
1692
|
|
|
1680
|
-
// src/apis/integrations/text/
|
|
1681
|
-
var
|
|
1682
|
-
|
|
1693
|
+
// src/apis/integrations/text/app/monitoring/events/api.ts
|
|
1694
|
+
var textAppMonitoringEventsApi = {
|
|
1695
|
+
getEvent(appId, eventKey, authorization) {
|
|
1696
|
+
return __async(this, null, function* () {
|
|
1697
|
+
try {
|
|
1698
|
+
const response = yield textClientInstance.get(
|
|
1699
|
+
`/app_monitoring/${appId}/events/${eventKey}`,
|
|
1700
|
+
getTextClientConfig(authorization)
|
|
1701
|
+
);
|
|
1702
|
+
return response.data;
|
|
1703
|
+
} catch (error) {
|
|
1704
|
+
if (error instanceof Error) {
|
|
1705
|
+
throw new Error(`Couldn't load event. [${error.message}]`);
|
|
1706
|
+
}
|
|
1707
|
+
throw error;
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
},
|
|
1711
|
+
getEvents(appId, authorization) {
|
|
1712
|
+
return __async(this, null, function* () {
|
|
1713
|
+
try {
|
|
1714
|
+
const response = yield textClientInstance.get(
|
|
1715
|
+
`/app_monitoring/${appId}/events`,
|
|
1716
|
+
getTextClientConfig(authorization)
|
|
1717
|
+
);
|
|
1718
|
+
return response.data;
|
|
1719
|
+
} catch (error) {
|
|
1720
|
+
if (error instanceof Error) {
|
|
1721
|
+
throw new Error(`Couldn't load events. [${error.message}]`);
|
|
1722
|
+
}
|
|
1723
|
+
throw error;
|
|
1724
|
+
}
|
|
1725
|
+
});
|
|
1726
|
+
},
|
|
1727
|
+
upsertEvent(appId, event, authorization) {
|
|
1728
|
+
return __async(this, null, function* () {
|
|
1729
|
+
try {
|
|
1730
|
+
yield textClientInstance.post(
|
|
1731
|
+
`/app_monitoring/${appId}/events/${event.key}`,
|
|
1732
|
+
event,
|
|
1733
|
+
getTextClientConfig(authorization)
|
|
1734
|
+
);
|
|
1735
|
+
} catch (error) {
|
|
1736
|
+
if (error instanceof Error) {
|
|
1737
|
+
throw new Error(`Couldn't upsert event. [${error.message}]`);
|
|
1738
|
+
}
|
|
1739
|
+
throw error;
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
},
|
|
1743
|
+
deleteEvent(appId, eventKey, authorization) {
|
|
1744
|
+
return __async(this, null, function* () {
|
|
1745
|
+
try {
|
|
1746
|
+
yield textClientInstance.delete(
|
|
1747
|
+
`/app_monitoring/${appId}/events/${eventKey}`,
|
|
1748
|
+
getTextClientConfig(authorization)
|
|
1749
|
+
);
|
|
1750
|
+
} catch (error) {
|
|
1751
|
+
if (error instanceof Error) {
|
|
1752
|
+
throw new Error(`Couldn't delete event. [${error.message}]`);
|
|
1753
|
+
}
|
|
1754
|
+
throw error;
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
},
|
|
1758
|
+
sendEvent(appId, data, authorization) {
|
|
1759
|
+
return __async(this, null, function* () {
|
|
1760
|
+
try {
|
|
1761
|
+
yield textClientInstance.post(
|
|
1762
|
+
`/app_monitoring/${appId}/events`,
|
|
1763
|
+
data,
|
|
1764
|
+
getTextClientConfig(authorization)
|
|
1765
|
+
);
|
|
1766
|
+
} catch (error) {
|
|
1767
|
+
if (error instanceof Error) {
|
|
1768
|
+
throw new Error(`Couldn't send events. [${error.message}]`);
|
|
1769
|
+
}
|
|
1770
|
+
throw error;
|
|
1771
|
+
}
|
|
1772
|
+
});
|
|
1773
|
+
},
|
|
1774
|
+
getEventsLog(appId, payload, authorization) {
|
|
1775
|
+
return __async(this, null, function* () {
|
|
1776
|
+
var _a, _b;
|
|
1777
|
+
try {
|
|
1778
|
+
const searchParams = new URLSearchParams({
|
|
1779
|
+
from: (_a = payload.from) != null ? _a : "",
|
|
1780
|
+
search: (_b = payload.search) != null ? _b : ""
|
|
1781
|
+
});
|
|
1782
|
+
if (payload.type) {
|
|
1783
|
+
payload.type.forEach((type) => {
|
|
1784
|
+
searchParams.append("type[]", type);
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
const response = yield textClientInstance.get(
|
|
1788
|
+
`/app_monitoring/${appId}/events?${searchParams.toString()}`,
|
|
1789
|
+
// v1
|
|
1790
|
+
// `/app_monitoring/${appId}/events/logs?${searchParams.toString()}`, // v2
|
|
1791
|
+
getTextClientConfig(authorization)
|
|
1792
|
+
);
|
|
1793
|
+
return response.data;
|
|
1794
|
+
} catch (error) {
|
|
1795
|
+
if (error instanceof Error) {
|
|
1796
|
+
throw new Error(`Couldn't load events log. [${error.message}]`);
|
|
1797
|
+
}
|
|
1798
|
+
throw error;
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
};
|
|
1803
|
+
|
|
1804
|
+
// src/apis/integrations/text/app/monitoring/reports/api.ts
|
|
1805
|
+
var textAppMonitoringReportsApi = {
|
|
1806
|
+
getUptimeReports(appId, payload, authorization) {
|
|
1683
1807
|
return __async(this, null, function* () {
|
|
1684
1808
|
try {
|
|
1685
1809
|
const response = yield textClientInstance.get(
|
|
1686
|
-
`/app_monitoring/${appId}/reports/uptime
|
|
1810
|
+
`/app_monitoring/${appId}/reports/uptime?${new URLSearchParams({
|
|
1811
|
+
from: payload.from,
|
|
1812
|
+
to: payload.to,
|
|
1813
|
+
resolution: payload.resolution
|
|
1814
|
+
}).toString()}`,
|
|
1687
1815
|
getTextClientConfig(authorization)
|
|
1688
1816
|
);
|
|
1689
1817
|
return response.data;
|
|
@@ -1694,12 +1822,138 @@ var textUptimeApi = {
|
|
|
1694
1822
|
throw error;
|
|
1695
1823
|
}
|
|
1696
1824
|
});
|
|
1825
|
+
},
|
|
1826
|
+
getEventReports(appId, payload, authorization) {
|
|
1827
|
+
return __async(this, null, function* () {
|
|
1828
|
+
try {
|
|
1829
|
+
const response = yield textClientInstance.get(
|
|
1830
|
+
`/app_monitoring/${appId}/reports/events?${new URLSearchParams({
|
|
1831
|
+
from: payload.from,
|
|
1832
|
+
to: payload.to,
|
|
1833
|
+
resolution: payload.resolution
|
|
1834
|
+
}).toString()}`,
|
|
1835
|
+
getTextClientConfig(authorization)
|
|
1836
|
+
);
|
|
1837
|
+
return response.data;
|
|
1838
|
+
} catch (error) {
|
|
1839
|
+
if (error instanceof Error) {
|
|
1840
|
+
throw new Error(`Couldn't load event reports. [${error.message}]`);
|
|
1841
|
+
}
|
|
1842
|
+
throw error;
|
|
1843
|
+
}
|
|
1844
|
+
});
|
|
1845
|
+
},
|
|
1846
|
+
getCustomReport(appId, customReportId, authorization) {
|
|
1847
|
+
return __async(this, null, function* () {
|
|
1848
|
+
try {
|
|
1849
|
+
const response = yield textClientInstance.get(
|
|
1850
|
+
`/app_monitoring/${appId}/reports/custom/${customReportId}`,
|
|
1851
|
+
getTextClientConfig(authorization)
|
|
1852
|
+
);
|
|
1853
|
+
return response.data;
|
|
1854
|
+
} catch (error) {
|
|
1855
|
+
if (error instanceof Error) {
|
|
1856
|
+
throw new Error(`Couldn't load custom report. [${error.message}]`);
|
|
1857
|
+
}
|
|
1858
|
+
throw error;
|
|
1859
|
+
}
|
|
1860
|
+
});
|
|
1861
|
+
},
|
|
1862
|
+
getCustomReportData(appId, customReportId, authorization) {
|
|
1863
|
+
return __async(this, null, function* () {
|
|
1864
|
+
try {
|
|
1865
|
+
const response = yield textClientInstance.get(
|
|
1866
|
+
`/app_monitoring/${appId}/reports/custom/${customReportId}/data`,
|
|
1867
|
+
getTextClientConfig(authorization)
|
|
1868
|
+
);
|
|
1869
|
+
return response.data;
|
|
1870
|
+
} catch (error) {
|
|
1871
|
+
if (error instanceof Error) {
|
|
1872
|
+
throw new Error(`Couldn't load custom report data. [${error.message}]`);
|
|
1873
|
+
}
|
|
1874
|
+
throw error;
|
|
1875
|
+
}
|
|
1876
|
+
});
|
|
1877
|
+
},
|
|
1878
|
+
getCustomReports(appId, authorization) {
|
|
1879
|
+
return __async(this, null, function* () {
|
|
1880
|
+
try {
|
|
1881
|
+
const response = yield textClientInstance.get(
|
|
1882
|
+
`/app_monitoring/${appId}/reports/custom`,
|
|
1883
|
+
getTextClientConfig(authorization)
|
|
1884
|
+
);
|
|
1885
|
+
return response.data;
|
|
1886
|
+
} catch (error) {
|
|
1887
|
+
if (error instanceof Error) {
|
|
1888
|
+
throw new Error(`Couldn't load custom reports. [${error.message}]`);
|
|
1889
|
+
}
|
|
1890
|
+
throw error;
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
},
|
|
1894
|
+
createCustomReport(appId, customReport, authorization) {
|
|
1895
|
+
return __async(this, null, function* () {
|
|
1896
|
+
try {
|
|
1897
|
+
yield textClientInstance.post(
|
|
1898
|
+
`/app_monitoring/${appId}/reports/custom`,
|
|
1899
|
+
customReport,
|
|
1900
|
+
getTextClientConfig(authorization)
|
|
1901
|
+
);
|
|
1902
|
+
} catch (error) {
|
|
1903
|
+
if (error instanceof Error) {
|
|
1904
|
+
throw new Error(`Couldn't create custom report. [${error.message}]`);
|
|
1905
|
+
}
|
|
1906
|
+
throw error;
|
|
1907
|
+
}
|
|
1908
|
+
});
|
|
1909
|
+
},
|
|
1910
|
+
updateCustomReport(appId, customReport, authorization) {
|
|
1911
|
+
return __async(this, null, function* () {
|
|
1912
|
+
try {
|
|
1913
|
+
yield textClientInstance.post(
|
|
1914
|
+
`/app_monitoring/${appId}/reports/custom/${customReport.id}`,
|
|
1915
|
+
customReport,
|
|
1916
|
+
getTextClientConfig(authorization)
|
|
1917
|
+
);
|
|
1918
|
+
} catch (error) {
|
|
1919
|
+
if (error instanceof Error) {
|
|
1920
|
+
throw new Error(`Couldn't update custom report. [${error.message}]`);
|
|
1921
|
+
}
|
|
1922
|
+
throw error;
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
},
|
|
1926
|
+
deleteCustomReport(appId, customReportId, authorization) {
|
|
1927
|
+
return __async(this, null, function* () {
|
|
1928
|
+
try {
|
|
1929
|
+
yield textClientInstance.delete(
|
|
1930
|
+
`/app_monitoring/${appId}/reports/custom/${customReportId}`,
|
|
1931
|
+
getTextClientConfig(authorization)
|
|
1932
|
+
);
|
|
1933
|
+
} catch (error) {
|
|
1934
|
+
if (error instanceof Error) {
|
|
1935
|
+
throw new Error(`Couldn't delete custom report. [${error.message}]`);
|
|
1936
|
+
}
|
|
1937
|
+
throw error;
|
|
1938
|
+
}
|
|
1939
|
+
});
|
|
1697
1940
|
}
|
|
1698
1941
|
};
|
|
1699
1942
|
|
|
1943
|
+
// src/apis/integrations/text/app/monitoring/api.ts
|
|
1944
|
+
var textAppMonitoringApi = {
|
|
1945
|
+
events: textAppMonitoringEventsApi,
|
|
1946
|
+
reports: textAppMonitoringReportsApi
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
// src/apis/integrations/text/app/api.ts
|
|
1950
|
+
var textAppApi = {
|
|
1951
|
+
monitoring: textAppMonitoringApi
|
|
1952
|
+
};
|
|
1953
|
+
|
|
1700
1954
|
// src/apis/integrations/text/api.ts
|
|
1701
1955
|
var textApi = {
|
|
1702
|
-
|
|
1956
|
+
app: textAppApi
|
|
1703
1957
|
};
|
|
1704
1958
|
|
|
1705
1959
|
// src/apis/integrations/vercel/api.ts
|
|
@@ -1716,7 +1970,7 @@ vercelClientInstance.interceptors.response.use(
|
|
|
1716
1970
|
var _a;
|
|
1717
1971
|
if (axios8.isAxiosError(error)) {
|
|
1718
1972
|
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
1719
|
-
|
|
1973
|
+
throw new UnauthorizeApiError("vercel");
|
|
1720
1974
|
}
|
|
1721
1975
|
}
|
|
1722
1976
|
throw error;
|
|
@@ -1728,7 +1982,8 @@ function getVercelClientAuthorization(req) {
|
|
|
1728
1982
|
};
|
|
1729
1983
|
}
|
|
1730
1984
|
function getVercelClientConfig(options = {}) {
|
|
1731
|
-
const
|
|
1985
|
+
const currentHeaders = vercelClientInstance.defaults.headers;
|
|
1986
|
+
const defaultAuthorization = currentHeaders.Authorization;
|
|
1732
1987
|
const headers = {
|
|
1733
1988
|
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
1734
1989
|
};
|
|
@@ -1745,10 +2000,11 @@ function initVercelClientInstance(token) {
|
|
|
1745
2000
|
}
|
|
1746
2001
|
}
|
|
1747
2002
|
function updateVercelClientInstance(token) {
|
|
2003
|
+
const headers = vercelClientInstance.defaults.headers;
|
|
1748
2004
|
if (token) {
|
|
1749
|
-
|
|
2005
|
+
headers.Authorization = `Bearer ${token}`;
|
|
1750
2006
|
} else {
|
|
1751
|
-
delete
|
|
2007
|
+
delete headers.Authorization;
|
|
1752
2008
|
}
|
|
1753
2009
|
}
|
|
1754
2010
|
|
|
@@ -1791,7 +2047,7 @@ var vercelIntegrationApi = {
|
|
|
1791
2047
|
var _a;
|
|
1792
2048
|
try {
|
|
1793
2049
|
const response = yield vercelClientInstance.get(
|
|
1794
|
-
`/v1/integrations/search-repo?provider=github${repositoryName ?
|
|
2050
|
+
`/v1/integrations/search-repo?provider=github${repositoryName ? `&query=${repositoryName}` : ""}${namespaceId ? `&namespaceId=${namespaceId}` : ""}`,
|
|
1795
2051
|
getVercelClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
1796
2052
|
ensureAuthorizationToken: true
|
|
1797
2053
|
}))
|
|
@@ -1814,7 +2070,6 @@ var vercelIntegrationApi = {
|
|
|
1814
2070
|
},
|
|
1815
2071
|
isRepositoryAccessible(repositoryName, authorization) {
|
|
1816
2072
|
return __async(this, null, function* () {
|
|
1817
|
-
var _a;
|
|
1818
2073
|
try {
|
|
1819
2074
|
const namespaces = yield this.getGitNamespaces(authorization);
|
|
1820
2075
|
const accessibleNamespaceId = namespaces.length > 0 ? (yield Promise.all(
|
|
@@ -1823,9 +2078,9 @@ var vercelIntegrationApi = {
|
|
|
1823
2078
|
)
|
|
1824
2079
|
)).map(
|
|
1825
2080
|
(repositories) => repositories.repos.length > 0 ? repositories.namespaceId : void 0
|
|
1826
|
-
)[0] : (
|
|
2081
|
+
)[0] : (yield this.getGitRepos(repositoryName, void 0, authorization)).namespaceId;
|
|
1827
2082
|
return {
|
|
1828
|
-
isAccessible:
|
|
2083
|
+
isAccessible: Boolean(accessibleNamespaceId),
|
|
1829
2084
|
installationId: accessibleNamespaceId
|
|
1830
2085
|
};
|
|
1831
2086
|
} catch (err) {
|
|
@@ -1932,15 +2187,16 @@ var vercelProjectApi = {
|
|
|
1932
2187
|
getProjectEnvByKey(projectId, envKey, authorization) {
|
|
1933
2188
|
return __async(this, null, function* () {
|
|
1934
2189
|
const envs = yield this.getProjectEnvs(projectId, authorization);
|
|
1935
|
-
const env = envs.find((
|
|
2190
|
+
const env = envs.find((innerEnv) => envKey === innerEnv.key);
|
|
1936
2191
|
if (!env) {
|
|
1937
2192
|
return;
|
|
1938
2193
|
}
|
|
1939
|
-
return
|
|
2194
|
+
return this.getProjectEnv(projectId, env.id, authorization);
|
|
1940
2195
|
});
|
|
1941
2196
|
},
|
|
1942
|
-
createProjectEnv(projectId, key, value,
|
|
2197
|
+
createProjectEnv(projectId, key, value, projectEnvs, authorization) {
|
|
1943
2198
|
return __async(this, null, function* () {
|
|
2199
|
+
let envs = projectEnvs;
|
|
1944
2200
|
if (!envs) {
|
|
1945
2201
|
const response = yield vercelClientInstance.get(`/v9/projects/${projectId}/env`, getVercelClientConfig(authorization));
|
|
1946
2202
|
envs = response.data.envs;
|
|
@@ -1948,7 +2204,7 @@ var vercelProjectApi = {
|
|
|
1948
2204
|
const existingEnv = envs.find((env) => env.key === key);
|
|
1949
2205
|
if (existingEnv) {
|
|
1950
2206
|
const { data: editedEnv } = yield vercelClientInstance.patch(
|
|
1951
|
-
`/v9/projects/${projectId}/env/${existingEnv
|
|
2207
|
+
`/v9/projects/${projectId}/env/${existingEnv.id}`,
|
|
1952
2208
|
{
|
|
1953
2209
|
key,
|
|
1954
2210
|
value,
|
|
@@ -1960,32 +2216,30 @@ var vercelProjectApi = {
|
|
|
1960
2216
|
}))
|
|
1961
2217
|
);
|
|
1962
2218
|
return editedEnv;
|
|
1963
|
-
} else {
|
|
1964
|
-
const { data: createdEnv } = yield vercelClientInstance.post(
|
|
1965
|
-
`/v9/projects/${projectId}/env`,
|
|
1966
|
-
{
|
|
1967
|
-
key,
|
|
1968
|
-
value,
|
|
1969
|
-
type: "encrypted",
|
|
1970
|
-
target: ["production", "preview", "development"]
|
|
1971
|
-
},
|
|
1972
|
-
getVercelClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
1973
|
-
ensureAuthorizationToken: true
|
|
1974
|
-
}))
|
|
1975
|
-
);
|
|
1976
|
-
return createdEnv;
|
|
1977
2219
|
}
|
|
2220
|
+
const { data: createdEnv } = yield vercelClientInstance.post(
|
|
2221
|
+
`/v9/projects/${projectId}/env`,
|
|
2222
|
+
{
|
|
2223
|
+
key,
|
|
2224
|
+
value,
|
|
2225
|
+
type: "encrypted",
|
|
2226
|
+
target: ["production", "preview", "development"]
|
|
2227
|
+
},
|
|
2228
|
+
getVercelClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
2229
|
+
ensureAuthorizationToken: true
|
|
2230
|
+
}))
|
|
2231
|
+
);
|
|
2232
|
+
return createdEnv;
|
|
1978
2233
|
});
|
|
1979
2234
|
},
|
|
1980
2235
|
removeProjectEnv(projectId, envId, authorization) {
|
|
1981
2236
|
return __async(this, null, function* () {
|
|
1982
|
-
|
|
2237
|
+
yield vercelClientInstance.delete(
|
|
1983
2238
|
`/v9/projects/${projectId}/env/${envId}`,
|
|
1984
2239
|
getVercelClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
1985
2240
|
ensureAuthorizationToken: true
|
|
1986
2241
|
}))
|
|
1987
2242
|
);
|
|
1988
|
-
return response.data;
|
|
1989
2243
|
});
|
|
1990
2244
|
}
|
|
1991
2245
|
};
|
|
@@ -2003,15 +2257,11 @@ var vercelApi = {
|
|
|
2003
2257
|
client_secret: clientSecret,
|
|
2004
2258
|
redirect_uri: redirectUrl
|
|
2005
2259
|
});
|
|
2006
|
-
const response = yield axios9.post(
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
{
|
|
2010
|
-
headers: {
|
|
2011
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
2012
|
-
}
|
|
2260
|
+
const response = yield axios9.post("https://api.vercel.com/v2/oauth/access_token", data, {
|
|
2261
|
+
headers: {
|
|
2262
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
2013
2263
|
}
|
|
2014
|
-
);
|
|
2264
|
+
});
|
|
2015
2265
|
return {
|
|
2016
2266
|
token: response.data.access_token,
|
|
2017
2267
|
installationId: response.data.installation_id,
|
|
@@ -2046,7 +2296,6 @@ var getRegion = (token) => {
|
|
|
2046
2296
|
if (supportedRegions.includes(region)) {
|
|
2047
2297
|
return region;
|
|
2048
2298
|
}
|
|
2049
|
-
return void 0;
|
|
2050
2299
|
};
|
|
2051
2300
|
var livechatClientInstance = axios10.create({
|
|
2052
2301
|
baseURL: "https://api.labs.livechatinc.com"
|
|
@@ -2057,7 +2306,8 @@ function getLiveChatClientAuthorization(req) {
|
|
|
2057
2306
|
};
|
|
2058
2307
|
}
|
|
2059
2308
|
function getLiveChatClientConfig(options = {}) {
|
|
2060
|
-
const
|
|
2309
|
+
const currentHeaders = livechatClientInstance.defaults.headers;
|
|
2310
|
+
const defaultAuthorization = currentHeaders.Authorization;
|
|
2061
2311
|
const headers = {
|
|
2062
2312
|
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
2063
2313
|
};
|
|
@@ -2067,22 +2317,23 @@ function getLiveChatClientConfig(options = {}) {
|
|
|
2067
2317
|
}
|
|
2068
2318
|
function initLiveChatClientInstance(baseUrl, token) {
|
|
2069
2319
|
const region = token ? getRegion(token) : void 0;
|
|
2320
|
+
const headers = livechatClientInstance.defaults.headers;
|
|
2070
2321
|
if (baseUrl) {
|
|
2071
2322
|
livechatClientInstance.interceptors.request.use(
|
|
2072
|
-
(config) =>
|
|
2323
|
+
(config) => {
|
|
2073
2324
|
config.baseURL = baseUrl;
|
|
2074
2325
|
return config;
|
|
2075
|
-
}
|
|
2326
|
+
},
|
|
2076
2327
|
(error) => Promise.reject(error)
|
|
2077
2328
|
);
|
|
2078
2329
|
}
|
|
2079
2330
|
if (region) {
|
|
2080
|
-
|
|
2331
|
+
headers["X-Region"] = region;
|
|
2081
2332
|
}
|
|
2082
2333
|
if (token) {
|
|
2083
|
-
|
|
2334
|
+
headers.Authorization = `Bearer ${token}`;
|
|
2084
2335
|
} else {
|
|
2085
|
-
delete
|
|
2336
|
+
delete headers.Authorization;
|
|
2086
2337
|
}
|
|
2087
2338
|
}
|
|
2088
2339
|
|
|
@@ -2230,7 +2481,7 @@ var livechatPropertyApi = {
|
|
|
2230
2481
|
try {
|
|
2231
2482
|
const response = yield Promise.all(
|
|
2232
2483
|
properties.filter((property) => property.public_access).map((property) => __async(this, null, function* () {
|
|
2233
|
-
return
|
|
2484
|
+
return livechatClientInstance.post(
|
|
2234
2485
|
`/v3.3/configuration/action/publish_property`,
|
|
2235
2486
|
{
|
|
2236
2487
|
name: property.name,
|
|
@@ -2255,7 +2506,7 @@ var livechatPropertyApi = {
|
|
|
2255
2506
|
try {
|
|
2256
2507
|
const response = yield Promise.all(
|
|
2257
2508
|
properties.map((property) => __async(this, null, function* () {
|
|
2258
|
-
return
|
|
2509
|
+
return livechatClientInstance.post(
|
|
2259
2510
|
`/v3.3/configuration/action/register_property`,
|
|
2260
2511
|
{
|
|
2261
2512
|
name: property.name,
|
|
@@ -2286,7 +2537,7 @@ var livechatPropertyApi = {
|
|
|
2286
2537
|
yield Promise.all(
|
|
2287
2538
|
Object.keys(properties).map((property) => __async(this, null, function* () {
|
|
2288
2539
|
if (Object.keys(properties[property]).indexOf("public_access") <= 0) {
|
|
2289
|
-
return
|
|
2540
|
+
return livechatClientInstance.post(
|
|
2290
2541
|
`/v3.3/configuration/action/unregister_property`,
|
|
2291
2542
|
{
|
|
2292
2543
|
name: property,
|
|
@@ -2363,7 +2614,7 @@ var livechatWebhookApi = {
|
|
|
2363
2614
|
const { data: webhooks } = yield this.getWebhooks(clientId);
|
|
2364
2615
|
yield Promise.all(
|
|
2365
2616
|
webhooks.map((webhook) => __async(this, null, function* () {
|
|
2366
|
-
return
|
|
2617
|
+
return livechatClientInstance.post(
|
|
2367
2618
|
`/v3.5/configuration/action/unregister_webhook`,
|
|
2368
2619
|
{
|
|
2369
2620
|
id: webhook.id,
|
|
@@ -2386,10 +2637,10 @@ var livechatWebhookApi = {
|
|
|
2386
2637
|
registerWebhooks(webhooks) {
|
|
2387
2638
|
return __async(this, null, function* () {
|
|
2388
2639
|
try {
|
|
2389
|
-
yield this.unregisterWebhooks(webhooks[0]
|
|
2640
|
+
yield this.unregisterWebhooks(webhooks[0].owner_client_id);
|
|
2390
2641
|
yield Promise.all(
|
|
2391
2642
|
webhooks.map((webhook) => __async(this, null, function* () {
|
|
2392
|
-
return
|
|
2643
|
+
return livechatClientInstance.post(
|
|
2393
2644
|
`/v${webhook.api_version || "3.5"}/configuration/action/register_webhook`,
|
|
2394
2645
|
{
|
|
2395
2646
|
url: webhook.url,
|
|
@@ -2424,10 +2675,9 @@ var livechatWebhookApi = {
|
|
|
2424
2675
|
filters: webhook.filters
|
|
2425
2676
|
};
|
|
2426
2677
|
});
|
|
2427
|
-
const { data: verifiedWebhooks } = yield livechatClientInstance.post(
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
);
|
|
2678
|
+
const { data: verifiedWebhooks } = yield livechatClientInstance.post(`/v3.3/configuration/action/check_webhooks_migration`, [
|
|
2679
|
+
...webhooksToCheck
|
|
2680
|
+
]);
|
|
2431
2681
|
const updatedWebhooks = webhooks.map((webhook, index) => {
|
|
2432
2682
|
return __spreadProps(__spreadValues({}, webhook), {
|
|
2433
2683
|
action: verifiedWebhooks[index].action
|
|
@@ -2857,14 +3107,16 @@ function getPlatformDpsClientAuthorization(req) {
|
|
|
2857
3107
|
};
|
|
2858
3108
|
}
|
|
2859
3109
|
function getPlatformDpsAdminClientAuthorization() {
|
|
2860
|
-
|
|
3110
|
+
var _a, _b;
|
|
3111
|
+
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 : "";
|
|
2861
3112
|
return {
|
|
2862
|
-
token: btoa(
|
|
3113
|
+
token: btoa(`apps@livechatinc.com:${token}`),
|
|
2863
3114
|
tokenType: "Basic"
|
|
2864
3115
|
};
|
|
2865
3116
|
}
|
|
2866
3117
|
function getPlatformDpsClientConfig(options = {}) {
|
|
2867
|
-
const
|
|
3118
|
+
const currentHeaders = platformDpsClientInstance.defaults.headers;
|
|
3119
|
+
const defaultAuthorization = currentHeaders.Authorization;
|
|
2868
3120
|
const headers = {
|
|
2869
3121
|
authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
|
|
2870
3122
|
};
|
|
@@ -2873,19 +3125,20 @@ function getPlatformDpsClientConfig(options = {}) {
|
|
|
2873
3125
|
};
|
|
2874
3126
|
}
|
|
2875
3127
|
function initPlatformDpsClientInstance(baseUrl, token) {
|
|
3128
|
+
const headers = platformDpsClientInstance.defaults.headers;
|
|
2876
3129
|
if (baseUrl) {
|
|
2877
3130
|
platformDpsClientInstance.interceptors.request.use(
|
|
2878
|
-
(config) =>
|
|
3131
|
+
(config) => {
|
|
2879
3132
|
config.baseURL = baseUrl;
|
|
2880
3133
|
return config;
|
|
2881
|
-
}
|
|
3134
|
+
},
|
|
2882
3135
|
(error) => Promise.reject(error)
|
|
2883
3136
|
);
|
|
2884
3137
|
}
|
|
2885
3138
|
if (token) {
|
|
2886
|
-
|
|
3139
|
+
headers.Authorization = `Bearer ${token}`;
|
|
2887
3140
|
} else {
|
|
2888
|
-
delete
|
|
3141
|
+
delete headers.Authorization;
|
|
2889
3142
|
}
|
|
2890
3143
|
}
|
|
2891
3144
|
|
|
@@ -3290,17 +3543,16 @@ var platformDpsApplicationInfrastructureBlocksApi = {
|
|
|
3290
3543
|
},
|
|
3291
3544
|
updateBlocks(appId, payload, authorization) {
|
|
3292
3545
|
return __async(this, null, function* () {
|
|
3293
|
-
|
|
3546
|
+
yield platformDpsClientInstance.patch(
|
|
3294
3547
|
`/v2/applications/${appId}/infrastructure/blocks`,
|
|
3295
3548
|
payload,
|
|
3296
3549
|
getPlatformDpsClientConfig(authorization)
|
|
3297
3550
|
);
|
|
3298
|
-
return response.data;
|
|
3299
3551
|
});
|
|
3300
3552
|
},
|
|
3301
3553
|
updateRepository(appId, payload, authorization) {
|
|
3302
3554
|
return __async(this, null, function* () {
|
|
3303
|
-
|
|
3555
|
+
yield platformDpsClientInstance.patch(
|
|
3304
3556
|
`/v2/applications/${appId}/infrastructure/blocks`,
|
|
3305
3557
|
{
|
|
3306
3558
|
appId,
|
|
@@ -3310,13 +3562,12 @@ var platformDpsApplicationInfrastructureBlocksApi = {
|
|
|
3310
3562
|
},
|
|
3311
3563
|
getPlatformDpsClientConfig(authorization)
|
|
3312
3564
|
);
|
|
3313
|
-
return response.data;
|
|
3314
3565
|
});
|
|
3315
3566
|
},
|
|
3316
3567
|
updateDeployment(appId, payload, authorization) {
|
|
3317
3568
|
return __async(this, null, function* () {
|
|
3318
3569
|
const config = payload.customUrl ? { custom: { url: payload.customUrl } } : { custom: null };
|
|
3319
|
-
|
|
3570
|
+
yield platformDpsClientInstance.patch(
|
|
3320
3571
|
`/v2/applications/${appId}/infrastructure/blocks`,
|
|
3321
3572
|
{
|
|
3322
3573
|
appId,
|
|
@@ -3328,12 +3579,11 @@ var platformDpsApplicationInfrastructureBlocksApi = {
|
|
|
3328
3579
|
},
|
|
3329
3580
|
getPlatformDpsClientConfig(authorization)
|
|
3330
3581
|
);
|
|
3331
|
-
return response.data;
|
|
3332
3582
|
});
|
|
3333
3583
|
},
|
|
3334
3584
|
updateStorage(appId, payload, authorization) {
|
|
3335
3585
|
return __async(this, null, function* () {
|
|
3336
|
-
|
|
3586
|
+
yield platformDpsClientInstance.patch(
|
|
3337
3587
|
`/v2/applications/${appId}/infrastructure/blocks`,
|
|
3338
3588
|
{
|
|
3339
3589
|
appId,
|
|
@@ -3343,12 +3593,11 @@ var platformDpsApplicationInfrastructureBlocksApi = {
|
|
|
3343
3593
|
},
|
|
3344
3594
|
getPlatformDpsClientConfig(authorization)
|
|
3345
3595
|
);
|
|
3346
|
-
return response.data;
|
|
3347
3596
|
});
|
|
3348
3597
|
},
|
|
3349
3598
|
updateLogger(appId, payload, authorization) {
|
|
3350
3599
|
return __async(this, null, function* () {
|
|
3351
|
-
|
|
3600
|
+
yield platformDpsClientInstance.post(
|
|
3352
3601
|
`/v2/applications/${appId}/infrastructure/blocks`,
|
|
3353
3602
|
{
|
|
3354
3603
|
appId,
|
|
@@ -3358,7 +3607,6 @@ var platformDpsApplicationInfrastructureBlocksApi = {
|
|
|
3358
3607
|
},
|
|
3359
3608
|
getPlatformDpsClientConfig(authorization)
|
|
3360
3609
|
);
|
|
3361
|
-
return response.data;
|
|
3362
3610
|
});
|
|
3363
3611
|
}
|
|
3364
3612
|
};
|
|
@@ -3550,19 +3798,6 @@ var platformDpsApplicationCustomPropsApi = {
|
|
|
3550
3798
|
}
|
|
3551
3799
|
};
|
|
3552
3800
|
|
|
3553
|
-
// src/apis/platform/dps/applications/application/reporting/api.ts
|
|
3554
|
-
var platformDpsApplicationReportingApi = {
|
|
3555
|
-
sendEvent(appId, event, authorization) {
|
|
3556
|
-
return __async(this, null, function* () {
|
|
3557
|
-
yield platformDpsClientInstance.post(
|
|
3558
|
-
`/apps/${appId}/events`,
|
|
3559
|
-
event,
|
|
3560
|
-
getPlatformDpsClientConfig(authorization)
|
|
3561
|
-
);
|
|
3562
|
-
});
|
|
3563
|
-
}
|
|
3564
|
-
};
|
|
3565
|
-
|
|
3566
3801
|
// src/apis/platform/dps/applications/application/resources/api.ts
|
|
3567
3802
|
var platformDpsApplicationResourcesApi = {
|
|
3568
3803
|
getAppUpgrades(appId, authorization) {
|
|
@@ -3830,7 +4065,6 @@ var platformDpsApplicationApi = {
|
|
|
3830
4065
|
onboarding: platformDpsApplicationOnboardingApi,
|
|
3831
4066
|
payment: platformDpsApplicationPaymentApi,
|
|
3832
4067
|
product: platformDpsApplicationProductApi,
|
|
3833
|
-
reporting: platformDpsApplicationReportingApi,
|
|
3834
4068
|
resource: platformDpsApplicationResourcesApi,
|
|
3835
4069
|
review: platformDpsApplicationReviewApi,
|
|
3836
4070
|
webhooks: platformDpsApplicationWebhooksApi,
|
|
@@ -4080,8 +4314,8 @@ var platformDpsDeveloperApi = {
|
|
|
4080
4314
|
return __async(this, null, function* () {
|
|
4081
4315
|
try {
|
|
4082
4316
|
const { startAt, endAt, size, page } = options;
|
|
4083
|
-
const withRange =
|
|
4084
|
-
const withPagination =
|
|
4317
|
+
const withRange = Boolean(startAt && endAt);
|
|
4318
|
+
const withPagination = Boolean(size && typeof page === "number");
|
|
4085
4319
|
let params = withRange || withPagination ? `?` : "";
|
|
4086
4320
|
if (withRange) {
|
|
4087
4321
|
params += `from=${startAt}&to=${endAt}`;
|
|
@@ -4261,7 +4495,7 @@ var dpsResearchDictionaryApi = {
|
|
|
4261
4495
|
try {
|
|
4262
4496
|
const params = new URLSearchParams(options);
|
|
4263
4497
|
const response = yield platformDpsClientInstance.get(
|
|
4264
|
-
`/v2/research/dictionary?${params}`,
|
|
4498
|
+
`/v2/research/dictionary?${params.toString()}`,
|
|
4265
4499
|
getPlatformDpsClientConfig(authorization)
|
|
4266
4500
|
);
|
|
4267
4501
|
return response.data;
|
|
@@ -4284,7 +4518,7 @@ var dpsResearchMarketplaceApi = {
|
|
|
4284
4518
|
try {
|
|
4285
4519
|
const params = new URLSearchParams(options);
|
|
4286
4520
|
const response = yield platformDpsClientInstance.get(
|
|
4287
|
-
`/v2/research/marketplace/apps?${params}`,
|
|
4521
|
+
`/v2/research/marketplace/apps?${params.toString()}`,
|
|
4288
4522
|
getPlatformDpsClientConfig(authorization)
|
|
4289
4523
|
);
|
|
4290
4524
|
return response.data;
|
|
@@ -4303,7 +4537,7 @@ var dpsResearchMarketplaceApi = {
|
|
|
4303
4537
|
try {
|
|
4304
4538
|
const params = new URLSearchParams(options);
|
|
4305
4539
|
const response = yield platformDpsClientInstance.get(
|
|
4306
|
-
`/v2/research/marketplace/views?${params}`,
|
|
4540
|
+
`/v2/research/marketplace/views?${params.toString()}`,
|
|
4307
4541
|
getPlatformDpsClientConfig(authorization)
|
|
4308
4542
|
);
|
|
4309
4543
|
return response.data;
|
|
@@ -4326,7 +4560,7 @@ var dpsResearchTrafficApi = {
|
|
|
4326
4560
|
try {
|
|
4327
4561
|
const params = new URLSearchParams(options);
|
|
4328
4562
|
const response = yield platformDpsClientInstance.get(
|
|
4329
|
-
`/v2/research/traffic/agents?${params}`,
|
|
4563
|
+
`/v2/research/traffic/agents?${params.toString()}`,
|
|
4330
4564
|
getPlatformDpsClientConfig(authorization)
|
|
4331
4565
|
);
|
|
4332
4566
|
return response.data;
|
|
@@ -4345,7 +4579,7 @@ var dpsResearchTrafficApi = {
|
|
|
4345
4579
|
try {
|
|
4346
4580
|
const params = new URLSearchParams(options);
|
|
4347
4581
|
const response = yield platformDpsClientInstance.get(
|
|
4348
|
-
`/v2/research/traffic/chats?${params}`,
|
|
4582
|
+
`/v2/research/traffic/chats?${params.toString()}`,
|
|
4349
4583
|
getPlatformDpsClientConfig(authorization)
|
|
4350
4584
|
);
|
|
4351
4585
|
return response.data;
|
|
@@ -4401,35 +4635,29 @@ var platformDpsUserApi = {
|
|
|
4401
4635
|
},
|
|
4402
4636
|
updateUserIntegrations(payload, authorization) {
|
|
4403
4637
|
return __async(this, null, function* () {
|
|
4404
|
-
|
|
4638
|
+
yield platformDpsClientInstance.patch(
|
|
4405
4639
|
`/v2/me/integrations`,
|
|
4406
4640
|
payload,
|
|
4407
4641
|
getPlatformDpsClientConfig(authorization)
|
|
4408
4642
|
);
|
|
4409
|
-
return response.data;
|
|
4410
4643
|
});
|
|
4411
4644
|
},
|
|
4412
4645
|
updateUserFeatures(payload, authorization) {
|
|
4413
4646
|
return __async(this, null, function* () {
|
|
4414
|
-
|
|
4647
|
+
yield platformDpsClientInstance.put(
|
|
4415
4648
|
"/v2/features",
|
|
4416
4649
|
payload,
|
|
4417
4650
|
getPlatformDpsClientConfig(authorization)
|
|
4418
4651
|
);
|
|
4419
|
-
return response.data;
|
|
4420
4652
|
});
|
|
4421
4653
|
},
|
|
4422
4654
|
removeUserGitHubIntegrationByInstallationId(installationId, authorization) {
|
|
4423
4655
|
return __async(this, null, function* () {
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
}
|
|
4430
|
-
})
|
|
4431
|
-
);
|
|
4432
|
-
return response.data;
|
|
4656
|
+
yield platformDpsClientInstance.delete(`/v2/me/integrations/github`, __spreadProps(__spreadValues({}, getPlatformDpsClientConfig(authorization)), {
|
|
4657
|
+
data: {
|
|
4658
|
+
githubInstallationId: installationId
|
|
4659
|
+
}
|
|
4660
|
+
}));
|
|
4433
4661
|
});
|
|
4434
4662
|
},
|
|
4435
4663
|
updateUserNetlifyIntegration(userNetlifyIntegration, authorization) {
|
|
@@ -4483,8 +4711,11 @@ platformAdapterClientInstance.interceptors.response.use(
|
|
|
4483
4711
|
(error) => {
|
|
4484
4712
|
var _a;
|
|
4485
4713
|
if (axios13.isAxiosError(error)) {
|
|
4486
|
-
if (((_a = error.response) == null ? void 0 : _a.status) === 401
|
|
4487
|
-
|
|
4714
|
+
if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
|
|
4715
|
+
const source = error.response.data.error.source;
|
|
4716
|
+
if (source) {
|
|
4717
|
+
throw new UnauthorizeApiError(source);
|
|
4718
|
+
}
|
|
4488
4719
|
}
|
|
4489
4720
|
}
|
|
4490
4721
|
throw error;
|
|
@@ -4492,19 +4723,20 @@ platformAdapterClientInstance.interceptors.response.use(
|
|
|
4492
4723
|
);
|
|
4493
4724
|
function getPlatformAdapterClientConfig(options = {}) {
|
|
4494
4725
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
4726
|
+
const currentHeaders = platformAdapterClientInstance.defaults.headers;
|
|
4495
4727
|
const headers = {
|
|
4496
4728
|
platform: {
|
|
4497
|
-
dps: (_b =
|
|
4729
|
+
dps: (_b = currentHeaders["platform-dps-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.dps
|
|
4498
4730
|
},
|
|
4499
4731
|
integrations: {
|
|
4500
4732
|
github: {
|
|
4501
|
-
app: (_d =
|
|
4502
|
-
oauth: (_f =
|
|
4733
|
+
app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.app,
|
|
4734
|
+
oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauth
|
|
4503
4735
|
},
|
|
4504
|
-
netlify: (_g =
|
|
4505
|
-
vercel: (_h =
|
|
4506
|
-
planetscale: (_i =
|
|
4507
|
-
sentry: (_j =
|
|
4736
|
+
netlify: (_g = currentHeaders["netlify-token"]) != null ? _g : options.netlify,
|
|
4737
|
+
vercel: (_h = currentHeaders["vercel-token"]) != null ? _h : options.vercel,
|
|
4738
|
+
planetscale: (_i = currentHeaders["planetscale-token"]) != null ? _i : options.planetscale,
|
|
4739
|
+
sentry: (_j = currentHeaders["sentry-token"]) != null ? _j : options.sentry
|
|
4508
4740
|
}
|
|
4509
4741
|
};
|
|
4510
4742
|
if (((_l = (_k = options.ensureAuthorizationToken) == null ? void 0 : _k.platform) == null ? void 0 : _l.dps) && !headers.platform.dps) {
|
|
@@ -4532,10 +4764,10 @@ function getPlatformAdapterClientConfig(options = {}) {
|
|
|
4532
4764
|
function initPlatformAdapterClientInstance(baseUrl, tokens) {
|
|
4533
4765
|
if (baseUrl) {
|
|
4534
4766
|
platformAdapterClientInstance.interceptors.request.use(
|
|
4535
|
-
(config) =>
|
|
4767
|
+
(config) => {
|
|
4536
4768
|
config.baseURL = baseUrl;
|
|
4537
4769
|
return config;
|
|
4538
|
-
}
|
|
4770
|
+
},
|
|
4539
4771
|
(error) => Promise.reject(error)
|
|
4540
4772
|
);
|
|
4541
4773
|
}
|
|
@@ -4545,26 +4777,27 @@ function initPlatformAdapterClientInstance(baseUrl, tokens) {
|
|
|
4545
4777
|
}
|
|
4546
4778
|
function updatePlatformAdapterClientInstance(tokens) {
|
|
4547
4779
|
var _a;
|
|
4780
|
+
const headers = platformAdapterClientInstance.defaults.headers;
|
|
4548
4781
|
if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.dps) {
|
|
4549
|
-
|
|
4782
|
+
headers["platform-dps-token"] = tokens.platform.dps;
|
|
4550
4783
|
}
|
|
4551
4784
|
if (tokens == null ? void 0 : tokens.github.app) {
|
|
4552
|
-
|
|
4785
|
+
headers["github-app-token"] = tokens.github.app;
|
|
4553
4786
|
}
|
|
4554
4787
|
if (tokens == null ? void 0 : tokens.github.oauth) {
|
|
4555
|
-
|
|
4788
|
+
headers["github-oauth-token"] = tokens.github.oauth;
|
|
4556
4789
|
}
|
|
4557
4790
|
if (tokens == null ? void 0 : tokens.netlify) {
|
|
4558
|
-
|
|
4791
|
+
headers["netlify-token"] = tokens.netlify;
|
|
4559
4792
|
}
|
|
4560
4793
|
if (tokens == null ? void 0 : tokens.vercel) {
|
|
4561
|
-
|
|
4794
|
+
headers["vercel-token"] = tokens.vercel;
|
|
4562
4795
|
}
|
|
4563
4796
|
if (tokens == null ? void 0 : tokens.planetscale) {
|
|
4564
|
-
|
|
4797
|
+
headers["planetscale-token"] = tokens.planetscale;
|
|
4565
4798
|
}
|
|
4566
4799
|
if (tokens == null ? void 0 : tokens.sentry) {
|
|
4567
|
-
|
|
4800
|
+
headers["sentry-token"] = tokens.sentry;
|
|
4568
4801
|
}
|
|
4569
4802
|
}
|
|
4570
4803
|
|
|
@@ -4603,7 +4836,7 @@ var platformAdapterAppDeploymentApi = {
|
|
|
4603
4836
|
},
|
|
4604
4837
|
unlink(payload, authorization) {
|
|
4605
4838
|
return __async(this, null, function* () {
|
|
4606
|
-
|
|
4839
|
+
yield platformAdapterClientInstance.post(
|
|
4607
4840
|
`/console/app/${payload.appId}/blocks/deployment/unlink`,
|
|
4608
4841
|
payload,
|
|
4609
4842
|
getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -4614,12 +4847,11 @@ var platformAdapterAppDeploymentApi = {
|
|
|
4614
4847
|
}
|
|
4615
4848
|
}))
|
|
4616
4849
|
);
|
|
4617
|
-
return response.data;
|
|
4618
4850
|
});
|
|
4619
4851
|
},
|
|
4620
4852
|
installSentry(appId, authorization) {
|
|
4621
4853
|
return __async(this, null, function* () {
|
|
4622
|
-
|
|
4854
|
+
yield platformAdapterClientInstance.post(
|
|
4623
4855
|
`/console/app/${appId}/blocks/deployment/install/sentry`,
|
|
4624
4856
|
{},
|
|
4625
4857
|
getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -4630,7 +4862,6 @@ var platformAdapterAppDeploymentApi = {
|
|
|
4630
4862
|
}
|
|
4631
4863
|
}))
|
|
4632
4864
|
);
|
|
4633
|
-
return response.data;
|
|
4634
4865
|
});
|
|
4635
4866
|
}
|
|
4636
4867
|
};
|
|
@@ -4648,22 +4879,20 @@ var platformAdapterAppSentryLoggerApi = {
|
|
|
4648
4879
|
},
|
|
4649
4880
|
link(payload, authorization) {
|
|
4650
4881
|
return __async(this, null, function* () {
|
|
4651
|
-
|
|
4882
|
+
yield platformAdapterClientInstance.post(
|
|
4652
4883
|
"/console/app/blocks/logger/providers/sentry/link",
|
|
4653
4884
|
payload,
|
|
4654
4885
|
getPlatformAdapterClientConfig(authorization)
|
|
4655
4886
|
);
|
|
4656
|
-
return response.data;
|
|
4657
4887
|
});
|
|
4658
4888
|
},
|
|
4659
4889
|
unlink(payload, authorization) {
|
|
4660
4890
|
return __async(this, null, function* () {
|
|
4661
|
-
|
|
4891
|
+
yield platformAdapterClientInstance.post(
|
|
4662
4892
|
"/console/app/blocks/logger/providers/sentry/unlink",
|
|
4663
4893
|
payload,
|
|
4664
4894
|
getPlatformAdapterClientConfig(authorization)
|
|
4665
4895
|
);
|
|
4666
|
-
return response.data;
|
|
4667
4896
|
});
|
|
4668
4897
|
},
|
|
4669
4898
|
reauthorizeSentryApp(userId, sentryInstallationId, sentryRefreshToken, authorization) {
|
|
@@ -4736,7 +4965,7 @@ var platformAdapterAppRepositoryApi = {
|
|
|
4736
4965
|
},
|
|
4737
4966
|
unlink(payload, authorization) {
|
|
4738
4967
|
return __async(this, null, function* () {
|
|
4739
|
-
|
|
4968
|
+
yield platformAdapterClientInstance.post(
|
|
4740
4969
|
`/console/app/${payload.appId}/blocks/repository/unlink`,
|
|
4741
4970
|
payload,
|
|
4742
4971
|
getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -4747,7 +4976,6 @@ var platformAdapterAppRepositoryApi = {
|
|
|
4747
4976
|
}
|
|
4748
4977
|
}))
|
|
4749
4978
|
);
|
|
4750
|
-
return response.data;
|
|
4751
4979
|
});
|
|
4752
4980
|
},
|
|
4753
4981
|
seed(payload, authorization) {
|
|
@@ -4802,7 +5030,7 @@ var platformAdapterAppStorageApi = {
|
|
|
4802
5030
|
},
|
|
4803
5031
|
unlink(payload, authorization) {
|
|
4804
5032
|
return __async(this, null, function* () {
|
|
4805
|
-
|
|
5033
|
+
yield platformAdapterClientInstance.post(
|
|
4806
5034
|
`/console/app/${payload.appId}/blocks/storage/unlink`,
|
|
4807
5035
|
payload,
|
|
4808
5036
|
getPlatformAdapterClientConfig(__spreadProps(__spreadValues({}, authorization), {
|
|
@@ -4813,7 +5041,6 @@ var platformAdapterAppStorageApi = {
|
|
|
4813
5041
|
}
|
|
4814
5042
|
}))
|
|
4815
5043
|
);
|
|
4816
|
-
return response.data;
|
|
4817
5044
|
});
|
|
4818
5045
|
}
|
|
4819
5046
|
};
|
|
@@ -4852,40 +5079,36 @@ var platformAdapterAppVariablesApi = {
|
|
|
4852
5079
|
},
|
|
4853
5080
|
syncVariable(appId, key, payload, authorization) {
|
|
4854
5081
|
return __async(this, null, function* () {
|
|
4855
|
-
|
|
5082
|
+
yield platformAdapterClientInstance.post(
|
|
4856
5083
|
`/console/app/${appId}/variables/${key}/sync`,
|
|
4857
5084
|
payload,
|
|
4858
5085
|
getPlatformAdapterClientConfig(authorization)
|
|
4859
5086
|
);
|
|
4860
|
-
return response.data;
|
|
4861
5087
|
});
|
|
4862
5088
|
},
|
|
4863
5089
|
createVariable(appId, data, authorization) {
|
|
4864
5090
|
return __async(this, null, function* () {
|
|
4865
|
-
|
|
5091
|
+
yield platformAdapterClientInstance.post(
|
|
4866
5092
|
`/console/app/${appId}/variables/${data.key}`,
|
|
4867
5093
|
data,
|
|
4868
5094
|
getPlatformAdapterClientConfig(authorization)
|
|
4869
5095
|
);
|
|
4870
|
-
return response.data;
|
|
4871
5096
|
});
|
|
4872
5097
|
},
|
|
4873
5098
|
editVariable(appId, data, authorization) {
|
|
4874
5099
|
return __async(this, null, function* () {
|
|
4875
|
-
|
|
5100
|
+
yield platformAdapterClientInstance.post(
|
|
4876
5101
|
`/console/app/${appId}/variables/${data.key}/edit`,
|
|
4877
5102
|
data,
|
|
4878
5103
|
getPlatformAdapterClientConfig(authorization)
|
|
4879
5104
|
);
|
|
4880
|
-
return response.data;
|
|
4881
5105
|
});
|
|
4882
5106
|
},
|
|
4883
5107
|
deleteVariable(data) {
|
|
4884
5108
|
return __async(this, null, function* () {
|
|
4885
|
-
|
|
5109
|
+
yield platformAdapterClientInstance.delete(
|
|
4886
5110
|
`/console/app/${data.appId}/variables/${data.key}`
|
|
4887
5111
|
);
|
|
4888
|
-
return response.data;
|
|
4889
5112
|
});
|
|
4890
5113
|
}
|
|
4891
5114
|
};
|
|
@@ -4931,13 +5154,6 @@ var platformApi = {
|
|
|
4931
5154
|
dps: platformDpsApi
|
|
4932
5155
|
};
|
|
4933
5156
|
|
|
4934
|
-
// src/apis/platform/dps/applications/application/reporting/_contracts/dtos/events/error.ts
|
|
4935
|
-
var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
|
|
4936
|
-
ErrorType2["4xx"] = "4xx";
|
|
4937
|
-
ErrorType2["5xx"] = "5xx";
|
|
4938
|
-
return ErrorType2;
|
|
4939
|
-
})(ErrorType || {});
|
|
4940
|
-
|
|
4941
5157
|
// src/apis/api.ts
|
|
4942
5158
|
var api = {
|
|
4943
5159
|
platform: platformApi,
|
|
@@ -4971,14 +5187,11 @@ function initApi(config, tokens) {
|
|
|
4971
5187
|
sentry: (_l = tokens.sentry) == null ? void 0 : _l.token
|
|
4972
5188
|
} : void 0
|
|
4973
5189
|
);
|
|
4974
|
-
initTextClientInstance(
|
|
4975
|
-
(_m = config.urls.platform) == null ? void 0 : _m.text,
|
|
4976
|
-
(_n = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _n.dps
|
|
4977
|
-
);
|
|
4978
5190
|
initLiveChatClientInstance(
|
|
4979
|
-
(
|
|
4980
|
-
(
|
|
5191
|
+
(_m = config.urls.products) == null ? void 0 : _m.livechat,
|
|
5192
|
+
(_n = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _n.dps
|
|
4981
5193
|
);
|
|
5194
|
+
initTextClientInstance((_o = config.urls.integrations) == null ? void 0 : _o.text, (_p = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _p.dps);
|
|
4982
5195
|
initGithubClientInstance((_q = tokens == null ? void 0 : tokens.github) == null ? void 0 : _q.apps);
|
|
4983
5196
|
initNetlifyClientInstance((_r = tokens == null ? void 0 : tokens.netlify) == null ? void 0 : _r.token);
|
|
4984
5197
|
initVercelClientInstance((_s = tokens == null ? void 0 : tokens.vercel) == null ? void 0 : _s.token);
|
|
@@ -5001,7 +5214,6 @@ var serializerBase64 = {
|
|
|
5001
5214
|
};
|
|
5002
5215
|
export {
|
|
5003
5216
|
API_NOTIFICATIONS,
|
|
5004
|
-
ErrorType,
|
|
5005
5217
|
UnauthorizeApiError,
|
|
5006
5218
|
api,
|
|
5007
5219
|
getAppAutoReviewPayload,
|