@backstage/integration 1.11.0 → 1.12.0-next.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/CHANGELOG.md +32 -0
- package/dist/ScmIntegrations.esm.js +4 -10
- package/dist/ScmIntegrations.esm.js.map +1 -1
- package/dist/awsCodeCommit/AwsCodeCommitIntegration.esm.js +13 -21
- package/dist/awsCodeCommit/AwsCodeCommitIntegration.esm.js.map +1 -1
- package/dist/awsCodeCommit/config.esm.js +6 -11
- package/dist/awsCodeCommit/config.esm.js.map +1 -1
- package/dist/awsS3/AwsS3Integration.esm.js +11 -19
- package/dist/awsS3/AwsS3Integration.esm.js.map +1 -1
- package/dist/awsS3/config.esm.js +2 -3
- package/dist/awsS3/config.esm.js.map +1 -1
- package/dist/azure/AzureIntegration.esm.js +12 -21
- package/dist/azure/AzureIntegration.esm.js.map +1 -1
- package/dist/azure/AzureUrl.esm.js +72 -76
- package/dist/azure/AzureUrl.esm.js.map +1 -1
- package/dist/azure/CachedAzureDevOpsCredentialsProvider.esm.js +2 -8
- package/dist/azure/CachedAzureDevOpsCredentialsProvider.esm.js.map +1 -1
- package/dist/azure/DefaultAzureDevOpsCredentialsProvider.esm.js +3 -6
- package/dist/azure/DefaultAzureDevOpsCredentialsProvider.esm.js.map +1 -1
- package/dist/azure/config.esm.js +12 -15
- package/dist/azure/config.esm.js.map +1 -1
- package/dist/azure/deprecated.esm.js +2 -3
- package/dist/azure/deprecated.esm.js.map +1 -1
- package/dist/bitbucket/BitbucketIntegration.esm.js +19 -27
- package/dist/bitbucket/BitbucketIntegration.esm.js.map +1 -1
- package/dist/bitbucket/config.esm.js +3 -4
- package/dist/bitbucket/config.esm.js.map +1 -1
- package/dist/bitbucketCloud/BitbucketCloudIntegration.esm.js +13 -21
- package/dist/bitbucketCloud/BitbucketCloudIntegration.esm.js.map +1 -1
- package/dist/bitbucketCloud/config.esm.js +1 -2
- package/dist/bitbucketCloud/config.esm.js.map +1 -1
- package/dist/bitbucketServer/BitbucketServerIntegration.esm.js +13 -21
- package/dist/bitbucketServer/BitbucketServerIntegration.esm.js.map +1 -1
- package/dist/bitbucketServer/config.esm.js +1 -2
- package/dist/bitbucketServer/config.esm.js.map +1 -1
- package/dist/gerrit/GerritIntegration.esm.js +11 -19
- package/dist/gerrit/GerritIntegration.esm.js.map +1 -1
- package/dist/gerrit/config.esm.js +1 -2
- package/dist/gerrit/config.esm.js.map +1 -1
- package/dist/gitea/GiteaIntegration.esm.js +10 -18
- package/dist/gitea/GiteaIntegration.esm.js.map +1 -1
- package/dist/gitea/config.esm.js +1 -2
- package/dist/gitea/config.esm.js.map +1 -1
- package/dist/gitea/core.esm.js +1 -2
- package/dist/gitea/core.esm.js.map +1 -1
- package/dist/github/GithubIntegration.esm.js +11 -19
- package/dist/github/GithubIntegration.esm.js.map +1 -1
- package/dist/github/SingleInstanceGithubCredentialsProvider.esm.js +22 -40
- package/dist/github/SingleInstanceGithubCredentialsProvider.esm.js.map +1 -1
- package/dist/github/config.esm.js +3 -4
- package/dist/github/config.esm.js.map +1 -1
- package/dist/gitlab/GitLabIntegration.esm.js +11 -19
- package/dist/gitlab/GitLabIntegration.esm.js.map +1 -1
- package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.esm.js +5 -12
- package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.esm.js.map +1 -1
- package/dist/gitlab/config.esm.js +1 -2
- package/dist/gitlab/config.esm.js.map +1 -1
- package/dist/harness/HarnessIntegration.esm.js +10 -18
- package/dist/harness/HarnessIntegration.esm.js.map +1 -1
- package/dist/harness/core.esm.js +48 -46
- package/dist/harness/core.esm.js.map +1 -1
- package/dist/index.cjs.js +327 -498
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +54 -37
- package/dist/index.esm.js +1 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
- package/dist/github/deprecated.esm.js +0 -26
- package/dist/github/deprecated.esm.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -72,9 +72,8 @@ function defaultScmResolveUrl(options) {
|
|
|
72
72
|
|
|
73
73
|
const AMAZON_AWS_HOST = "amazonaws.com";
|
|
74
74
|
function readAwsS3IntegrationConfig(config) {
|
|
75
|
-
var _a, _b;
|
|
76
75
|
const endpoint = config.getOptionalString("endpoint");
|
|
77
|
-
const s3ForcePathStyle =
|
|
76
|
+
const s3ForcePathStyle = config.getOptionalBoolean("s3ForcePathStyle") ?? false;
|
|
78
77
|
let host;
|
|
79
78
|
let pathname;
|
|
80
79
|
if (endpoint) {
|
|
@@ -96,7 +95,7 @@ function readAwsS3IntegrationConfig(config) {
|
|
|
96
95
|
host = AMAZON_AWS_HOST;
|
|
97
96
|
}
|
|
98
97
|
const accessKeyId = config.getOptionalString("accessKeyId");
|
|
99
|
-
const secretAccessKey =
|
|
98
|
+
const secretAccessKey = config.getOptionalString("secretAccessKey")?.trim();
|
|
100
99
|
const roleArn = config.getOptionalString("roleArn");
|
|
101
100
|
const externalId = config.getOptionalString("externalId");
|
|
102
101
|
return {
|
|
@@ -119,16 +118,19 @@ function readAwsS3IntegrationConfigs(configs) {
|
|
|
119
118
|
return result;
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
124
|
-
var __publicField$f = (obj, key, value) => {
|
|
125
|
-
__defNormalProp$f(obj, key + "" , value);
|
|
126
|
-
return value;
|
|
127
|
-
};
|
|
128
|
-
const _AwsS3Integration = class _AwsS3Integration {
|
|
121
|
+
class AwsS3Integration {
|
|
129
122
|
constructor(integrationConfig) {
|
|
130
123
|
this.integrationConfig = integrationConfig;
|
|
131
124
|
}
|
|
125
|
+
static factory = ({ config }) => {
|
|
126
|
+
const configs = readAwsS3IntegrationConfigs(
|
|
127
|
+
config.getOptionalConfigArray("integrations.awsS3") ?? []
|
|
128
|
+
);
|
|
129
|
+
return basicIntegrations(
|
|
130
|
+
configs.map((c) => new AwsS3Integration(c)),
|
|
131
|
+
(i) => i.config.host
|
|
132
|
+
);
|
|
133
|
+
};
|
|
132
134
|
get type() {
|
|
133
135
|
return "awsS3";
|
|
134
136
|
}
|
|
@@ -145,55 +147,44 @@ const _AwsS3Integration = class _AwsS3Integration {
|
|
|
145
147
|
resolveEditUrl(url) {
|
|
146
148
|
return url;
|
|
147
149
|
}
|
|
148
|
-
}
|
|
149
|
-
__publicField$f(_AwsS3Integration, "factory", ({ config }) => {
|
|
150
|
-
var _a;
|
|
151
|
-
const configs = readAwsS3IntegrationConfigs(
|
|
152
|
-
(_a = config.getOptionalConfigArray("integrations.awsS3")) != null ? _a : []
|
|
153
|
-
);
|
|
154
|
-
return basicIntegrations(
|
|
155
|
-
configs.map((c) => new _AwsS3Integration(c)),
|
|
156
|
-
(i) => i.config.host
|
|
157
|
-
);
|
|
158
|
-
});
|
|
159
|
-
let AwsS3Integration = _AwsS3Integration;
|
|
150
|
+
}
|
|
160
151
|
|
|
161
152
|
const AMAZON_AWS_CODECOMMIT_HOST = "console.aws.amazon.com";
|
|
162
153
|
function readAwsCodeCommitIntegrationConfig(config) {
|
|
163
|
-
var _a;
|
|
164
154
|
const accessKeyId = config.getOptionalString("accessKeyId");
|
|
165
|
-
const secretAccessKey =
|
|
155
|
+
const secretAccessKey = config.getOptionalString("secretAccessKey")?.trim();
|
|
166
156
|
const roleArn = config.getOptionalString("roleArn");
|
|
167
157
|
const externalId = config.getOptionalString("externalId");
|
|
168
|
-
const
|
|
158
|
+
const region = config.getString("region");
|
|
159
|
+
const host = config.getOptionalString("host") || `${region}.${AMAZON_AWS_CODECOMMIT_HOST}`;
|
|
169
160
|
return {
|
|
170
161
|
host,
|
|
171
162
|
accessKeyId,
|
|
172
163
|
secretAccessKey,
|
|
173
164
|
roleArn,
|
|
174
|
-
externalId
|
|
165
|
+
externalId,
|
|
166
|
+
region
|
|
175
167
|
};
|
|
176
168
|
}
|
|
177
169
|
function readAwsCodeCommitIntegrationConfigs(configs) {
|
|
178
|
-
|
|
179
|
-
if (!result.some((c) => c.host === AMAZON_AWS_CODECOMMIT_HOST)) {
|
|
180
|
-
result.push({
|
|
181
|
-
host: AMAZON_AWS_CODECOMMIT_HOST
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
return result;
|
|
170
|
+
return configs.map(readAwsCodeCommitIntegrationConfig);
|
|
185
171
|
}
|
|
186
172
|
|
|
187
|
-
|
|
188
|
-
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
189
|
-
var __publicField$e = (obj, key, value) => {
|
|
190
|
-
__defNormalProp$e(obj, key + "" , value);
|
|
191
|
-
return value;
|
|
192
|
-
};
|
|
193
|
-
const _AwsCodeCommitIntegration = class _AwsCodeCommitIntegration {
|
|
173
|
+
class AwsCodeCommitIntegration {
|
|
194
174
|
constructor(integrationConfig) {
|
|
195
175
|
this.integrationConfig = integrationConfig;
|
|
196
176
|
}
|
|
177
|
+
static factory = ({
|
|
178
|
+
config
|
|
179
|
+
}) => {
|
|
180
|
+
const configs = readAwsCodeCommitIntegrationConfigs(
|
|
181
|
+
config.getOptionalConfigArray("integrations.awsCodeCommit") ?? []
|
|
182
|
+
);
|
|
183
|
+
return basicIntegrations(
|
|
184
|
+
configs.map((c) => new AwsCodeCommitIntegration(c)),
|
|
185
|
+
(i) => i.config.host
|
|
186
|
+
);
|
|
187
|
+
};
|
|
197
188
|
get type() {
|
|
198
189
|
return "awsCodeCommit";
|
|
199
190
|
}
|
|
@@ -218,20 +209,7 @@ const _AwsCodeCommitIntegration = class _AwsCodeCommitIntegration {
|
|
|
218
209
|
const [, repositoryName] = pathMatch;
|
|
219
210
|
return replaceCodeCommitUrlType(url, repositoryName);
|
|
220
211
|
}
|
|
221
|
-
}
|
|
222
|
-
__publicField$e(_AwsCodeCommitIntegration, "factory", ({
|
|
223
|
-
config
|
|
224
|
-
}) => {
|
|
225
|
-
var _a;
|
|
226
|
-
const configs = readAwsCodeCommitIntegrationConfigs(
|
|
227
|
-
(_a = config.getOptionalConfigArray("integrations.awsCodeCommit")) != null ? _a : []
|
|
228
|
-
);
|
|
229
|
-
return basicIntegrations(
|
|
230
|
-
configs.map((c) => new _AwsCodeCommitIntegration(c)),
|
|
231
|
-
(i) => i.config.host
|
|
232
|
-
);
|
|
233
|
-
});
|
|
234
|
-
let AwsCodeCommitIntegration = _AwsCodeCommitIntegration;
|
|
212
|
+
}
|
|
235
213
|
function replaceCodeCommitUrlType(url, repositoryName, type) {
|
|
236
214
|
const newString = `files/edit` ;
|
|
237
215
|
return url.replace(
|
|
@@ -242,53 +220,14 @@ function replaceCodeCommitUrlType(url, repositoryName, type) {
|
|
|
242
220
|
);
|
|
243
221
|
}
|
|
244
222
|
|
|
245
|
-
var __accessCheck = (obj, member, msg) => {
|
|
246
|
-
if (!member.has(obj))
|
|
247
|
-
throw TypeError("Cannot " + msg);
|
|
248
|
-
};
|
|
249
|
-
var __privateGet = (obj, member, getter) => {
|
|
250
|
-
__accessCheck(obj, member, "read from private field");
|
|
251
|
-
return member.get(obj);
|
|
252
|
-
};
|
|
253
|
-
var __privateAdd = (obj, member, value) => {
|
|
254
|
-
if (member.has(obj))
|
|
255
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
256
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
257
|
-
};
|
|
258
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
259
|
-
__accessCheck(obj, member, "write to private field");
|
|
260
|
-
member.set(obj, value);
|
|
261
|
-
return value;
|
|
262
|
-
};
|
|
263
|
-
var _origin, _owner, _project, _repo, _path, _ref, _baseUrl;
|
|
264
223
|
const VERSION_PREFIX_GIT_BRANCH = "GB";
|
|
265
|
-
|
|
266
|
-
constructor(origin, owner, project, repo, path, ref) {
|
|
267
|
-
__privateAdd(this, _origin, void 0);
|
|
268
|
-
__privateAdd(this, _owner, void 0);
|
|
269
|
-
__privateAdd(this, _project, void 0);
|
|
270
|
-
__privateAdd(this, _repo, void 0);
|
|
271
|
-
__privateAdd(this, _path, void 0);
|
|
272
|
-
__privateAdd(this, _ref, void 0);
|
|
273
|
-
__privateAdd(this, _baseUrl, (...parts) => {
|
|
274
|
-
const url = new URL(__privateGet(this, _origin));
|
|
275
|
-
url.pathname = parts.map((part) => encodeURIComponent(part)).join("/");
|
|
276
|
-
return url;
|
|
277
|
-
});
|
|
278
|
-
__privateSet(this, _origin, origin);
|
|
279
|
-
__privateSet(this, _owner, owner);
|
|
280
|
-
__privateSet(this, _project, project);
|
|
281
|
-
__privateSet(this, _repo, repo);
|
|
282
|
-
__privateSet(this, _path, path);
|
|
283
|
-
__privateSet(this, _ref, ref);
|
|
284
|
-
}
|
|
224
|
+
class AzureUrl {
|
|
285
225
|
/**
|
|
286
226
|
* Parses an azure URL as copied from the browser address bar.
|
|
287
227
|
*
|
|
288
228
|
* Throws an error if the URL is not a valid azure repo URL.
|
|
289
229
|
*/
|
|
290
230
|
static fromRepoUrl(repoUrl) {
|
|
291
|
-
var _a;
|
|
292
231
|
const url = new URL(repoUrl);
|
|
293
232
|
let owner;
|
|
294
233
|
let project;
|
|
@@ -309,7 +248,7 @@ const _AzureUrl = class _AzureUrl {
|
|
|
309
248
|
if (!owner || !project || !repo) {
|
|
310
249
|
throw new Error("Azure URL must point to a git repository");
|
|
311
250
|
}
|
|
312
|
-
const path =
|
|
251
|
+
const path = url.searchParams.get("path") ?? void 0;
|
|
313
252
|
let ref;
|
|
314
253
|
const version = url.searchParams.get("version");
|
|
315
254
|
if (version) {
|
|
@@ -319,8 +258,27 @@ const _AzureUrl = class _AzureUrl {
|
|
|
319
258
|
}
|
|
320
259
|
ref = version.slice(2);
|
|
321
260
|
}
|
|
322
|
-
return new
|
|
323
|
-
}
|
|
261
|
+
return new AzureUrl(url.origin, owner, project, repo, path, ref);
|
|
262
|
+
}
|
|
263
|
+
#origin;
|
|
264
|
+
#owner;
|
|
265
|
+
#project;
|
|
266
|
+
#repo;
|
|
267
|
+
#path;
|
|
268
|
+
#ref;
|
|
269
|
+
constructor(origin, owner, project, repo, path, ref) {
|
|
270
|
+
this.#origin = origin;
|
|
271
|
+
this.#owner = owner;
|
|
272
|
+
this.#project = project;
|
|
273
|
+
this.#repo = repo;
|
|
274
|
+
this.#path = path;
|
|
275
|
+
this.#ref = ref;
|
|
276
|
+
}
|
|
277
|
+
#baseUrl = (...parts) => {
|
|
278
|
+
const url = new URL(this.#origin);
|
|
279
|
+
url.pathname = parts.map((part) => encodeURIComponent(part)).join("/");
|
|
280
|
+
return url;
|
|
281
|
+
};
|
|
324
282
|
/**
|
|
325
283
|
* Returns a repo URL that can be used to navigate to the resource in azure.
|
|
326
284
|
*
|
|
@@ -328,16 +286,16 @@ const _AzureUrl = class _AzureUrl {
|
|
|
328
286
|
*/
|
|
329
287
|
toRepoUrl() {
|
|
330
288
|
let url;
|
|
331
|
-
if (
|
|
332
|
-
url =
|
|
289
|
+
if (this.#project === this.#repo) {
|
|
290
|
+
url = this.#baseUrl(this.#owner, "_git", this.#repo);
|
|
333
291
|
} else {
|
|
334
|
-
url =
|
|
292
|
+
url = this.#baseUrl(this.#owner, this.#project, "_git", this.#repo);
|
|
335
293
|
}
|
|
336
|
-
if (
|
|
337
|
-
url.searchParams.set("path",
|
|
294
|
+
if (this.#path) {
|
|
295
|
+
url.searchParams.set("path", this.#path);
|
|
338
296
|
}
|
|
339
|
-
if (
|
|
340
|
-
url.searchParams.set("version", VERSION_PREFIX_GIT_BRANCH +
|
|
297
|
+
if (this.#ref) {
|
|
298
|
+
url.searchParams.set("version", VERSION_PREFIX_GIT_BRANCH + this.#ref);
|
|
341
299
|
}
|
|
342
300
|
return url.toString();
|
|
343
301
|
}
|
|
@@ -347,16 +305,24 @@ const _AzureUrl = class _AzureUrl {
|
|
|
347
305
|
* Throws an error if the URL does not point to a file.
|
|
348
306
|
*/
|
|
349
307
|
toFileUrl() {
|
|
350
|
-
if (!
|
|
308
|
+
if (!this.#path) {
|
|
351
309
|
throw new Error(
|
|
352
310
|
"Azure URL must point to a specific path to be able to download a file"
|
|
353
311
|
);
|
|
354
312
|
}
|
|
355
|
-
const url =
|
|
313
|
+
const url = this.#baseUrl(
|
|
314
|
+
this.#owner,
|
|
315
|
+
this.#project,
|
|
316
|
+
"_apis",
|
|
317
|
+
"git",
|
|
318
|
+
"repositories",
|
|
319
|
+
this.#repo,
|
|
320
|
+
"items"
|
|
321
|
+
);
|
|
356
322
|
url.searchParams.set("api-version", "6.0");
|
|
357
|
-
url.searchParams.set("path",
|
|
358
|
-
if (
|
|
359
|
-
url.searchParams.set("version",
|
|
323
|
+
url.searchParams.set("path", this.#path);
|
|
324
|
+
if (this.#ref) {
|
|
325
|
+
url.searchParams.set("version", this.#ref);
|
|
360
326
|
}
|
|
361
327
|
return url.toString();
|
|
362
328
|
}
|
|
@@ -366,15 +332,23 @@ const _AzureUrl = class _AzureUrl {
|
|
|
366
332
|
* Throws an error if the URL does not point to a repo.
|
|
367
333
|
*/
|
|
368
334
|
toArchiveUrl() {
|
|
369
|
-
const url =
|
|
335
|
+
const url = this.#baseUrl(
|
|
336
|
+
this.#owner,
|
|
337
|
+
this.#project,
|
|
338
|
+
"_apis",
|
|
339
|
+
"git",
|
|
340
|
+
"repositories",
|
|
341
|
+
this.#repo,
|
|
342
|
+
"items"
|
|
343
|
+
);
|
|
370
344
|
url.searchParams.set("recursionLevel", "full");
|
|
371
345
|
url.searchParams.set("download", "true");
|
|
372
346
|
url.searchParams.set("api-version", "6.0");
|
|
373
|
-
if (
|
|
374
|
-
url.searchParams.set("scopePath",
|
|
347
|
+
if (this.#path) {
|
|
348
|
+
url.searchParams.set("scopePath", this.#path);
|
|
375
349
|
}
|
|
376
|
-
if (
|
|
377
|
-
url.searchParams.set("version",
|
|
350
|
+
if (this.#ref) {
|
|
351
|
+
url.searchParams.set("version", this.#ref);
|
|
378
352
|
}
|
|
379
353
|
return url.toString();
|
|
380
354
|
}
|
|
@@ -384,10 +358,18 @@ const _AzureUrl = class _AzureUrl {
|
|
|
384
358
|
* Throws an error if the URL does not point to a commit.
|
|
385
359
|
*/
|
|
386
360
|
toCommitsUrl() {
|
|
387
|
-
const url =
|
|
361
|
+
const url = this.#baseUrl(
|
|
362
|
+
this.#owner,
|
|
363
|
+
this.#project,
|
|
364
|
+
"_apis",
|
|
365
|
+
"git",
|
|
366
|
+
"repositories",
|
|
367
|
+
this.#repo,
|
|
368
|
+
"commits"
|
|
369
|
+
);
|
|
388
370
|
url.searchParams.set("api-version", "6.0");
|
|
389
|
-
if (
|
|
390
|
-
url.searchParams.set("searchCriteria.itemVersion.version",
|
|
371
|
+
if (this.#ref) {
|
|
372
|
+
url.searchParams.set("searchCriteria.itemVersion.version", this.#ref);
|
|
391
373
|
}
|
|
392
374
|
return url.toString();
|
|
393
375
|
}
|
|
@@ -395,41 +377,33 @@ const _AzureUrl = class _AzureUrl {
|
|
|
395
377
|
* Returns the name of the owner, a user or an organization.
|
|
396
378
|
*/
|
|
397
379
|
getOwner() {
|
|
398
|
-
return
|
|
380
|
+
return this.#owner;
|
|
399
381
|
}
|
|
400
382
|
/**
|
|
401
383
|
* Returns the name of the project.
|
|
402
384
|
*/
|
|
403
385
|
getProject() {
|
|
404
|
-
return
|
|
386
|
+
return this.#project;
|
|
405
387
|
}
|
|
406
388
|
/**
|
|
407
389
|
* Returns the name of the repo.
|
|
408
390
|
*/
|
|
409
391
|
getRepo() {
|
|
410
|
-
return
|
|
392
|
+
return this.#repo;
|
|
411
393
|
}
|
|
412
394
|
/**
|
|
413
395
|
* Returns the file path within the repo if the URL contains one.
|
|
414
396
|
*/
|
|
415
397
|
getPath() {
|
|
416
|
-
return
|
|
398
|
+
return this.#path;
|
|
417
399
|
}
|
|
418
400
|
/**
|
|
419
401
|
* Returns the git ref in the repo if the URL contains one.
|
|
420
402
|
*/
|
|
421
403
|
getRef() {
|
|
422
|
-
return
|
|
404
|
+
return this.#ref;
|
|
423
405
|
}
|
|
424
|
-
}
|
|
425
|
-
_origin = new WeakMap();
|
|
426
|
-
_owner = new WeakMap();
|
|
427
|
-
_project = new WeakMap();
|
|
428
|
-
_repo = new WeakMap();
|
|
429
|
-
_path = new WeakMap();
|
|
430
|
-
_ref = new WeakMap();
|
|
431
|
-
_baseUrl = new WeakMap();
|
|
432
|
-
let AzureUrl = _AzureUrl;
|
|
406
|
+
}
|
|
433
407
|
|
|
434
408
|
const AZURE_HOST = "dev.azure.com";
|
|
435
409
|
const AzureDevOpsCredentialFields = [
|
|
@@ -463,20 +437,18 @@ function asAzureDevOpsCredential(credential) {
|
|
|
463
437
|
throw new Error("is not a valid credential");
|
|
464
438
|
}
|
|
465
439
|
function readAzureIntegrationConfig(config) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
let credentialConfigs = (_b = config.getOptionalConfigArray("credentials")) == null ? void 0 : _b.map((credential) => {
|
|
469
|
-
var _a2, _b2;
|
|
440
|
+
const host = config.getOptionalString("host") ?? AZURE_HOST;
|
|
441
|
+
let credentialConfigs = config.getOptionalConfigArray("credentials")?.map((credential) => {
|
|
470
442
|
const result = {
|
|
471
443
|
organizations: credential.getOptionalStringArray("organizations"),
|
|
472
|
-
personalAccessToken:
|
|
444
|
+
personalAccessToken: credential.getOptionalString("personalAccessToken")?.trim(),
|
|
473
445
|
tenantId: credential.getOptionalString("tenantId"),
|
|
474
446
|
clientId: credential.getOptionalString("clientId"),
|
|
475
|
-
clientSecret:
|
|
447
|
+
clientSecret: credential.getOptionalString("clientSecret")?.trim()
|
|
476
448
|
};
|
|
477
449
|
return result;
|
|
478
450
|
});
|
|
479
|
-
const token =
|
|
451
|
+
const token = config.getOptionalString("token")?.trim();
|
|
480
452
|
if (config.getOptional("credential") !== void 0 && config.getOptional("credentials") !== void 0) {
|
|
481
453
|
throw new Error(
|
|
482
454
|
`Invalid Azure integration config, 'credential' and 'credentials' cannot be used together. Use 'credentials' instead.`
|
|
@@ -489,7 +461,7 @@ function readAzureIntegrationConfig(config) {
|
|
|
489
461
|
}
|
|
490
462
|
if (token !== void 0) {
|
|
491
463
|
const mapped = [{ personalAccessToken: token }];
|
|
492
|
-
credentialConfigs =
|
|
464
|
+
credentialConfigs = credentialConfigs?.concat(mapped) ?? mapped;
|
|
493
465
|
}
|
|
494
466
|
if (config.getOptional("credential") !== void 0) {
|
|
495
467
|
const mapped = [
|
|
@@ -497,13 +469,13 @@ function readAzureIntegrationConfig(config) {
|
|
|
497
469
|
organizations: config.getOptionalStringArray(
|
|
498
470
|
"credential.organizations"
|
|
499
471
|
),
|
|
500
|
-
token:
|
|
472
|
+
token: config.getOptionalString("credential.token")?.trim(),
|
|
501
473
|
tenantId: config.getOptionalString("credential.tenantId"),
|
|
502
474
|
clientId: config.getOptionalString("credential.clientId"),
|
|
503
|
-
clientSecret:
|
|
475
|
+
clientSecret: config.getOptionalString("credential.clientSecret")?.trim()
|
|
504
476
|
}
|
|
505
477
|
];
|
|
506
|
-
credentialConfigs =
|
|
478
|
+
credentialConfigs = credentialConfigs?.concat(mapped) ?? mapped;
|
|
507
479
|
}
|
|
508
480
|
if (!isValidHost(host)) {
|
|
509
481
|
throw new Error(
|
|
@@ -512,7 +484,7 @@ function readAzureIntegrationConfig(config) {
|
|
|
512
484
|
}
|
|
513
485
|
let credentials = void 0;
|
|
514
486
|
if (credentialConfigs !== void 0) {
|
|
515
|
-
const errors = credentialConfigs
|
|
487
|
+
const errors = credentialConfigs?.reduce((acc, credentialConfig, index) => {
|
|
516
488
|
let error = void 0;
|
|
517
489
|
try {
|
|
518
490
|
asAzureDevOpsCredential(credentialConfig);
|
|
@@ -528,8 +500,7 @@ function readAzureIntegrationConfig(config) {
|
|
|
528
500
|
credentialConfigs.filter(
|
|
529
501
|
(credential) => credential.organizations !== void 0 && credential.organizations.length > 0
|
|
530
502
|
).reduce((acc, credential, index) => {
|
|
531
|
-
|
|
532
|
-
(_a2 = credential.organizations) == null ? void 0 : _a2.forEach((organization) => {
|
|
503
|
+
credential.organizations?.forEach((organization) => {
|
|
533
504
|
if (!acc[organization]) {
|
|
534
505
|
acc[organization] = [];
|
|
535
506
|
}
|
|
@@ -544,7 +515,7 @@ function readAzureIntegrationConfig(config) {
|
|
|
544
515
|
return acc;
|
|
545
516
|
}, Array.of())
|
|
546
517
|
);
|
|
547
|
-
if (
|
|
518
|
+
if (errors?.length > 0) {
|
|
548
519
|
throw new Error(
|
|
549
520
|
`Invalid Azure integration config for ${host}: ${errors.join("; ")}`
|
|
550
521
|
);
|
|
@@ -580,16 +551,19 @@ function readAzureIntegrationConfigs(configs) {
|
|
|
580
551
|
return result;
|
|
581
552
|
}
|
|
582
553
|
|
|
583
|
-
|
|
584
|
-
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
585
|
-
var __publicField$d = (obj, key, value) => {
|
|
586
|
-
__defNormalProp$d(obj, key + "" , value);
|
|
587
|
-
return value;
|
|
588
|
-
};
|
|
589
|
-
const _AzureIntegration = class _AzureIntegration {
|
|
554
|
+
class AzureIntegration {
|
|
590
555
|
constructor(integrationConfig) {
|
|
591
556
|
this.integrationConfig = integrationConfig;
|
|
592
557
|
}
|
|
558
|
+
static factory = ({ config }) => {
|
|
559
|
+
const configs = readAzureIntegrationConfigs(
|
|
560
|
+
config.getOptionalConfigArray("integrations.azure") ?? []
|
|
561
|
+
);
|
|
562
|
+
return basicIntegrations(
|
|
563
|
+
configs.map((c) => new AzureIntegration(c)),
|
|
564
|
+
(i) => i.config.host
|
|
565
|
+
);
|
|
566
|
+
};
|
|
593
567
|
get type() {
|
|
594
568
|
return "azure";
|
|
595
569
|
}
|
|
@@ -605,7 +579,6 @@ const _AzureIntegration = class _AzureIntegration {
|
|
|
605
579
|
* Example base URL: https://dev.azure.com/organization/project/_git/repository?path=%2Fcatalog-info.yaml
|
|
606
580
|
*/
|
|
607
581
|
resolveUrl(options) {
|
|
608
|
-
var _a;
|
|
609
582
|
const { url, base } = options;
|
|
610
583
|
if (isValidUrl(url)) {
|
|
611
584
|
return url;
|
|
@@ -613,7 +586,7 @@ const _AzureIntegration = class _AzureIntegration {
|
|
|
613
586
|
try {
|
|
614
587
|
const azureUrl = AzureUrl.fromRepoUrl(base);
|
|
615
588
|
const newUrl = new URL(base);
|
|
616
|
-
const mockBaseUrl = new URL(`https://a.com${
|
|
589
|
+
const mockBaseUrl = new URL(`https://a.com${azureUrl.getPath() ?? ""}`);
|
|
617
590
|
const updatedPath = new URL(url, mockBaseUrl).pathname;
|
|
618
591
|
newUrl.searchParams.set("path", updatedPath);
|
|
619
592
|
if (options.lineNumber) {
|
|
@@ -630,18 +603,7 @@ const _AzureIntegration = class _AzureIntegration {
|
|
|
630
603
|
resolveEditUrl(url) {
|
|
631
604
|
return url;
|
|
632
605
|
}
|
|
633
|
-
}
|
|
634
|
-
__publicField$d(_AzureIntegration, "factory", ({ config }) => {
|
|
635
|
-
var _a;
|
|
636
|
-
const configs = readAzureIntegrationConfigs(
|
|
637
|
-
(_a = config.getOptionalConfigArray("integrations.azure")) != null ? _a : []
|
|
638
|
-
);
|
|
639
|
-
return basicIntegrations(
|
|
640
|
-
configs.map((c) => new _AzureIntegration(c)),
|
|
641
|
-
(i) => i.config.host
|
|
642
|
-
);
|
|
643
|
-
});
|
|
644
|
-
let AzureIntegration = _AzureIntegration;
|
|
606
|
+
}
|
|
645
607
|
|
|
646
608
|
function getAzureFileFetchUrl(url) {
|
|
647
609
|
return AzureUrl.fromRepoUrl(url).toFileUrl();
|
|
@@ -653,19 +615,13 @@ function getAzureCommitsUrl(url) {
|
|
|
653
615
|
return AzureUrl.fromRepoUrl(url).toCommitsUrl();
|
|
654
616
|
}
|
|
655
617
|
|
|
656
|
-
var __defProp$c = Object.defineProperty;
|
|
657
|
-
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
658
|
-
var __publicField$c = (obj, key, value) => {
|
|
659
|
-
__defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
660
|
-
return value;
|
|
661
|
-
};
|
|
662
618
|
const tenMinutes = 1e3 * 60 * 10;
|
|
663
619
|
class CachedAzureDevOpsCredentialsProvider {
|
|
664
620
|
constructor(credential) {
|
|
665
621
|
this.credential = credential;
|
|
666
|
-
__publicField$c(this, "azureDevOpsScope", "499b84ac-1321-427f-aa17-267ca6975798/.default");
|
|
667
|
-
__publicField$c(this, "cached");
|
|
668
622
|
}
|
|
623
|
+
azureDevOpsScope = "499b84ac-1321-427f-aa17-267ca6975798/.default";
|
|
624
|
+
cached;
|
|
669
625
|
static fromAzureDevOpsCredential(credential) {
|
|
670
626
|
switch (credential.kind) {
|
|
671
627
|
case "PersonalAccessToken":
|
|
@@ -735,9 +691,7 @@ class DefaultAzureDevOpsCredentialsProvider {
|
|
|
735
691
|
}
|
|
736
692
|
static fromIntegrations(integrations) {
|
|
737
693
|
const providers = integrations.azure.list().reduce((acc, integration) => {
|
|
738
|
-
|
|
739
|
-
(_a = integration.config.credentials) == null ? void 0 : _a.forEach((credential) => {
|
|
740
|
-
var _a2;
|
|
694
|
+
integration.config.credentials?.forEach((credential) => {
|
|
741
695
|
if (credential.organizations === void 0 || credential.organizations.length === 0) {
|
|
742
696
|
if (acc.get(integration.config.host) === void 0) {
|
|
743
697
|
acc.set(
|
|
@@ -751,7 +705,7 @@ class DefaultAzureDevOpsCredentialsProvider {
|
|
|
751
705
|
const provider = CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(
|
|
752
706
|
credential
|
|
753
707
|
);
|
|
754
|
-
|
|
708
|
+
credential.organizations?.forEach((organization) => {
|
|
755
709
|
acc.set(`${integration.config.host}/${organization}`, provider);
|
|
756
710
|
});
|
|
757
711
|
}
|
|
@@ -790,9 +744,8 @@ class DefaultAzureDevOpsCredentialsProvider {
|
|
|
790
744
|
return this.providers.get(url.host);
|
|
791
745
|
}
|
|
792
746
|
async getCredentials(opts) {
|
|
793
|
-
var _a, _b;
|
|
794
747
|
const url = new URL(opts.url);
|
|
795
|
-
const provider =
|
|
748
|
+
const provider = this.forAzureDevOpsOrganization(url) ?? this.forAzureDevOpsServerOrganization(url) ?? this.forHost(url);
|
|
796
749
|
if (provider === void 0) {
|
|
797
750
|
return void 0;
|
|
798
751
|
}
|
|
@@ -801,9 +754,8 @@ class DefaultAzureDevOpsCredentialsProvider {
|
|
|
801
754
|
}
|
|
802
755
|
|
|
803
756
|
async function getAzureRequestOptions(config, additionalHeaders) {
|
|
804
|
-
var _a;
|
|
805
757
|
const headers = additionalHeaders ? { ...additionalHeaders } : {};
|
|
806
|
-
const credentialConfig =
|
|
758
|
+
const credentialConfig = config.credentials?.filter(
|
|
807
759
|
(credential) => credential.organizations === void 0 || credential.organizations.length === 0
|
|
808
760
|
)[0];
|
|
809
761
|
if (credentialConfig) {
|
|
@@ -813,7 +765,7 @@ async function getAzureRequestOptions(config, additionalHeaders) {
|
|
|
813
765
|
const credentials = await credentialsProvider.getCredentials();
|
|
814
766
|
return {
|
|
815
767
|
headers: {
|
|
816
|
-
...credentials
|
|
768
|
+
...credentials?.headers,
|
|
817
769
|
...headers
|
|
818
770
|
}
|
|
819
771
|
};
|
|
@@ -824,12 +776,11 @@ async function getAzureRequestOptions(config, additionalHeaders) {
|
|
|
824
776
|
const BITBUCKET_HOST = "bitbucket.org";
|
|
825
777
|
const BITBUCKET_API_BASE_URL = "https://api.bitbucket.org/2.0";
|
|
826
778
|
function readBitbucketIntegrationConfig(config) {
|
|
827
|
-
|
|
828
|
-
const host = (_a = config.getOptionalString("host")) != null ? _a : BITBUCKET_HOST;
|
|
779
|
+
const host = config.getOptionalString("host") ?? BITBUCKET_HOST;
|
|
829
780
|
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
830
|
-
const token =
|
|
781
|
+
const token = config.getOptionalString("token")?.trim();
|
|
831
782
|
const username = config.getOptionalString("username");
|
|
832
|
-
const appPassword =
|
|
783
|
+
const appPassword = config.getOptionalString("appPassword")?.trim();
|
|
833
784
|
if (!isValidHost(host)) {
|
|
834
785
|
throw new Error(
|
|
835
786
|
`Invalid Bitbucket integration config, '${host}' is not a valid host`
|
|
@@ -861,16 +812,27 @@ function readBitbucketIntegrationConfigs(configs) {
|
|
|
861
812
|
return result;
|
|
862
813
|
}
|
|
863
814
|
|
|
864
|
-
|
|
865
|
-
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
866
|
-
var __publicField$b = (obj, key, value) => {
|
|
867
|
-
__defNormalProp$b(obj, key + "" , value);
|
|
868
|
-
return value;
|
|
869
|
-
};
|
|
870
|
-
const _BitbucketIntegration = class _BitbucketIntegration {
|
|
815
|
+
class BitbucketIntegration {
|
|
871
816
|
constructor(integrationConfig) {
|
|
872
817
|
this.integrationConfig = integrationConfig;
|
|
873
818
|
}
|
|
819
|
+
static factory = ({
|
|
820
|
+
config
|
|
821
|
+
}) => {
|
|
822
|
+
const configs = readBitbucketIntegrationConfigs(
|
|
823
|
+
config.getOptionalConfigArray("integrations.bitbucket") ?? [
|
|
824
|
+
// if integrations.bitbucket was not used assume the use was migrated to the new configs
|
|
825
|
+
// and backport for the deprecated integration to be usable for other parts of the system
|
|
826
|
+
// until these got migrated
|
|
827
|
+
...config.getOptionalConfigArray("integrations.bitbucketCloud") ?? [],
|
|
828
|
+
...config.getOptionalConfigArray("integrations.bitbucketServer") ?? []
|
|
829
|
+
]
|
|
830
|
+
);
|
|
831
|
+
return basicIntegrations(
|
|
832
|
+
configs.map((c) => new BitbucketIntegration(c)),
|
|
833
|
+
(i) => i.config.host
|
|
834
|
+
);
|
|
835
|
+
};
|
|
874
836
|
get type() {
|
|
875
837
|
return "bitbucket";
|
|
876
838
|
}
|
|
@@ -901,26 +863,7 @@ const _BitbucketIntegration = class _BitbucketIntegration {
|
|
|
901
863
|
editUrl.searchParams.set("at", urlData.ref);
|
|
902
864
|
return editUrl.toString();
|
|
903
865
|
}
|
|
904
|
-
}
|
|
905
|
-
__publicField$b(_BitbucketIntegration, "factory", ({
|
|
906
|
-
config
|
|
907
|
-
}) => {
|
|
908
|
-
var _a, _b, _c;
|
|
909
|
-
const configs = readBitbucketIntegrationConfigs(
|
|
910
|
-
(_c = config.getOptionalConfigArray("integrations.bitbucket")) != null ? _c : [
|
|
911
|
-
// if integrations.bitbucket was not used assume the use was migrated to the new configs
|
|
912
|
-
// and backport for the deprecated integration to be usable for other parts of the system
|
|
913
|
-
// until these got migrated
|
|
914
|
-
...(_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : [],
|
|
915
|
-
...(_b = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _b : []
|
|
916
|
-
]
|
|
917
|
-
);
|
|
918
|
-
return basicIntegrations(
|
|
919
|
-
configs.map((c) => new _BitbucketIntegration(c)),
|
|
920
|
-
(i) => i.config.host
|
|
921
|
-
);
|
|
922
|
-
});
|
|
923
|
-
let BitbucketIntegration = _BitbucketIntegration;
|
|
866
|
+
}
|
|
924
867
|
|
|
925
868
|
async function getBitbucketDefaultBranch(url, config) {
|
|
926
869
|
const { name: repoName, owner: project, resource } = parseGitUrl__default.default(url);
|
|
@@ -1005,11 +948,10 @@ function getBitbucketRequestOptions(config) {
|
|
|
1005
948
|
const BITBUCKET_CLOUD_HOST = "bitbucket.org";
|
|
1006
949
|
const BITBUCKET_CLOUD_API_BASE_URL = "https://api.bitbucket.org/2.0";
|
|
1007
950
|
function readBitbucketCloudIntegrationConfig(config) {
|
|
1008
|
-
var _a;
|
|
1009
951
|
const host = BITBUCKET_CLOUD_HOST;
|
|
1010
952
|
const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;
|
|
1011
953
|
const username = config.getString("username");
|
|
1012
|
-
const appPassword =
|
|
954
|
+
const appPassword = config.getString("appPassword")?.trim();
|
|
1013
955
|
return {
|
|
1014
956
|
host,
|
|
1015
957
|
apiBaseUrl,
|
|
@@ -1028,16 +970,21 @@ function readBitbucketCloudIntegrationConfigs(configs) {
|
|
|
1028
970
|
return result;
|
|
1029
971
|
}
|
|
1030
972
|
|
|
1031
|
-
|
|
1032
|
-
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1033
|
-
var __publicField$a = (obj, key, value) => {
|
|
1034
|
-
__defNormalProp$a(obj, key + "" , value);
|
|
1035
|
-
return value;
|
|
1036
|
-
};
|
|
1037
|
-
const _BitbucketCloudIntegration = class _BitbucketCloudIntegration {
|
|
973
|
+
class BitbucketCloudIntegration {
|
|
1038
974
|
constructor(integrationConfig) {
|
|
1039
975
|
this.integrationConfig = integrationConfig;
|
|
1040
976
|
}
|
|
977
|
+
static factory = ({
|
|
978
|
+
config
|
|
979
|
+
}) => {
|
|
980
|
+
const configs = readBitbucketCloudIntegrationConfigs(
|
|
981
|
+
config.getOptionalConfigArray("integrations.bitbucketCloud") ?? []
|
|
982
|
+
);
|
|
983
|
+
return basicIntegrations(
|
|
984
|
+
configs.map((c) => new BitbucketCloudIntegration(c)),
|
|
985
|
+
(i) => i.config.host
|
|
986
|
+
);
|
|
987
|
+
};
|
|
1041
988
|
get type() {
|
|
1042
989
|
return "bitbucketCloud";
|
|
1043
990
|
}
|
|
@@ -1063,20 +1010,7 @@ const _BitbucketCloudIntegration = class _BitbucketCloudIntegration {
|
|
|
1063
1010
|
editUrl.searchParams.set("at", urlData.ref);
|
|
1064
1011
|
return editUrl.toString();
|
|
1065
1012
|
}
|
|
1066
|
-
}
|
|
1067
|
-
__publicField$a(_BitbucketCloudIntegration, "factory", ({
|
|
1068
|
-
config
|
|
1069
|
-
}) => {
|
|
1070
|
-
var _a;
|
|
1071
|
-
const configs = readBitbucketCloudIntegrationConfigs(
|
|
1072
|
-
(_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : []
|
|
1073
|
-
);
|
|
1074
|
-
return basicIntegrations(
|
|
1075
|
-
configs.map((c) => new _BitbucketCloudIntegration(c)),
|
|
1076
|
-
(i) => i.config.host
|
|
1077
|
-
);
|
|
1078
|
-
});
|
|
1079
|
-
let BitbucketCloudIntegration = _BitbucketCloudIntegration;
|
|
1013
|
+
}
|
|
1080
1014
|
|
|
1081
1015
|
async function getBitbucketCloudDefaultBranch(url, config) {
|
|
1082
1016
|
const { name: repoName, owner: project } = parseGitUrl__default.default(url);
|
|
@@ -1142,10 +1076,9 @@ function getBitbucketCloudRequestOptions(config) {
|
|
|
1142
1076
|
}
|
|
1143
1077
|
|
|
1144
1078
|
function readBitbucketServerIntegrationConfig(config) {
|
|
1145
|
-
var _a;
|
|
1146
1079
|
const host = config.getString("host");
|
|
1147
1080
|
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
1148
|
-
const token =
|
|
1081
|
+
const token = config.getOptionalString("token")?.trim();
|
|
1149
1082
|
const username = config.getOptionalString("username");
|
|
1150
1083
|
const password = config.getOptionalString("password");
|
|
1151
1084
|
if (!isValidHost(host)) {
|
|
@@ -1170,16 +1103,21 @@ function readBitbucketServerIntegrationConfigs(configs) {
|
|
|
1170
1103
|
return configs.map(readBitbucketServerIntegrationConfig);
|
|
1171
1104
|
}
|
|
1172
1105
|
|
|
1173
|
-
|
|
1174
|
-
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1175
|
-
var __publicField$9 = (obj, key, value) => {
|
|
1176
|
-
__defNormalProp$9(obj, key + "" , value);
|
|
1177
|
-
return value;
|
|
1178
|
-
};
|
|
1179
|
-
const _BitbucketServerIntegration = class _BitbucketServerIntegration {
|
|
1106
|
+
class BitbucketServerIntegration {
|
|
1180
1107
|
constructor(integrationConfig) {
|
|
1181
1108
|
this.integrationConfig = integrationConfig;
|
|
1182
1109
|
}
|
|
1110
|
+
static factory = ({
|
|
1111
|
+
config
|
|
1112
|
+
}) => {
|
|
1113
|
+
const configs = readBitbucketServerIntegrationConfigs(
|
|
1114
|
+
config.getOptionalConfigArray("integrations.bitbucketServer") ?? []
|
|
1115
|
+
);
|
|
1116
|
+
return basicIntegrations(
|
|
1117
|
+
configs.map((c) => new BitbucketServerIntegration(c)),
|
|
1118
|
+
(i) => i.config.host
|
|
1119
|
+
);
|
|
1120
|
+
};
|
|
1183
1121
|
get type() {
|
|
1184
1122
|
return "bitbucketServer";
|
|
1185
1123
|
}
|
|
@@ -1204,20 +1142,7 @@ const _BitbucketServerIntegration = class _BitbucketServerIntegration {
|
|
|
1204
1142
|
}
|
|
1205
1143
|
return url;
|
|
1206
1144
|
}
|
|
1207
|
-
}
|
|
1208
|
-
__publicField$9(_BitbucketServerIntegration, "factory", ({
|
|
1209
|
-
config
|
|
1210
|
-
}) => {
|
|
1211
|
-
var _a;
|
|
1212
|
-
const configs = readBitbucketServerIntegrationConfigs(
|
|
1213
|
-
(_a = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _a : []
|
|
1214
|
-
);
|
|
1215
|
-
return basicIntegrations(
|
|
1216
|
-
configs.map((c) => new _BitbucketServerIntegration(c)),
|
|
1217
|
-
(i) => i.config.host
|
|
1218
|
-
);
|
|
1219
|
-
});
|
|
1220
|
-
let BitbucketServerIntegration = _BitbucketServerIntegration;
|
|
1145
|
+
}
|
|
1221
1146
|
|
|
1222
1147
|
async function getBitbucketServerDefaultBranch(url, config) {
|
|
1223
1148
|
const { name: repoName, owner: project } = parseGitUrl__default.default(url);
|
|
@@ -1278,13 +1203,12 @@ function getBitbucketServerRequestOptions(config) {
|
|
|
1278
1203
|
}
|
|
1279
1204
|
|
|
1280
1205
|
function readGerritIntegrationConfig(config) {
|
|
1281
|
-
var _a;
|
|
1282
1206
|
const host = config.getString("host");
|
|
1283
1207
|
let baseUrl = config.getOptionalString("baseUrl");
|
|
1284
1208
|
let cloneUrl = config.getOptionalString("cloneUrl");
|
|
1285
1209
|
let gitilesBaseUrl = config.getOptionalString("gitilesBaseUrl");
|
|
1286
1210
|
const username = config.getOptionalString("username");
|
|
1287
|
-
const password =
|
|
1211
|
+
const password = config.getOptionalString("password")?.trim();
|
|
1288
1212
|
if (!isValidHost(host)) {
|
|
1289
1213
|
throw new Error(
|
|
1290
1214
|
`Invalid Gerrit integration config, '${host}' is not a valid host`
|
|
@@ -1432,16 +1356,19 @@ async function parseGerritJsonResponse(response) {
|
|
|
1432
1356
|
);
|
|
1433
1357
|
}
|
|
1434
1358
|
|
|
1435
|
-
|
|
1436
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1437
|
-
var __publicField$8 = (obj, key, value) => {
|
|
1438
|
-
__defNormalProp$8(obj, key + "" , value);
|
|
1439
|
-
return value;
|
|
1440
|
-
};
|
|
1441
|
-
const _GerritIntegration = class _GerritIntegration {
|
|
1359
|
+
class GerritIntegration {
|
|
1442
1360
|
constructor(integrationConfig) {
|
|
1443
1361
|
this.integrationConfig = integrationConfig;
|
|
1444
1362
|
}
|
|
1363
|
+
static factory = ({ config }) => {
|
|
1364
|
+
const configs = readGerritIntegrationConfigs(
|
|
1365
|
+
config.getOptionalConfigArray("integrations.gerrit") ?? []
|
|
1366
|
+
);
|
|
1367
|
+
return basicIntegrations(
|
|
1368
|
+
configs.map((c) => new GerritIntegration(c)),
|
|
1369
|
+
(i) => i.config.host
|
|
1370
|
+
);
|
|
1371
|
+
};
|
|
1445
1372
|
get type() {
|
|
1446
1373
|
return "gerrit";
|
|
1447
1374
|
}
|
|
@@ -1471,25 +1398,13 @@ const _GerritIntegration = class _GerritIntegration {
|
|
|
1471
1398
|
resolveEditUrl(url) {
|
|
1472
1399
|
return url;
|
|
1473
1400
|
}
|
|
1474
|
-
}
|
|
1475
|
-
__publicField$8(_GerritIntegration, "factory", ({ config }) => {
|
|
1476
|
-
var _a;
|
|
1477
|
-
const configs = readGerritIntegrationConfigs(
|
|
1478
|
-
(_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []
|
|
1479
|
-
);
|
|
1480
|
-
return basicIntegrations(
|
|
1481
|
-
configs.map((c) => new _GerritIntegration(c)),
|
|
1482
|
-
(i) => i.config.host
|
|
1483
|
-
);
|
|
1484
|
-
});
|
|
1485
|
-
let GerritIntegration = _GerritIntegration;
|
|
1401
|
+
}
|
|
1486
1402
|
|
|
1487
1403
|
function readGiteaConfig(config) {
|
|
1488
|
-
var _a;
|
|
1489
1404
|
const host = config.getString("host");
|
|
1490
1405
|
let baseUrl = config.getOptionalString("baseUrl");
|
|
1491
1406
|
const username = config.getOptionalString("username");
|
|
1492
|
-
const password =
|
|
1407
|
+
const password = config.getOptionalString("password")?.trim();
|
|
1493
1408
|
if (!isValidHost(host)) {
|
|
1494
1409
|
throw new Error(
|
|
1495
1410
|
`Invalid Gitea integration config, '${host}' is not a valid host`
|
|
@@ -1546,8 +1461,7 @@ function getGiteaRequestOptions(config) {
|
|
|
1546
1461
|
};
|
|
1547
1462
|
}
|
|
1548
1463
|
function parseGiteaUrl(config, url) {
|
|
1549
|
-
|
|
1550
|
-
const baseUrl = (_a = config.baseUrl) != null ? _a : `https://${config.host}`;
|
|
1464
|
+
const baseUrl = config.baseUrl ?? `https://${config.host}`;
|
|
1551
1465
|
try {
|
|
1552
1466
|
const [_blank, owner, name, _src, _branch, ref, ...path] = url.replace(baseUrl, "").split("/");
|
|
1553
1467
|
const pathWithoutSlash = path.join("/").replace(/^\//, "");
|
|
@@ -1563,16 +1477,18 @@ function parseGiteaUrl(config, url) {
|
|
|
1563
1477
|
}
|
|
1564
1478
|
}
|
|
1565
1479
|
|
|
1566
|
-
|
|
1567
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1568
|
-
var __publicField$7 = (obj, key, value) => {
|
|
1569
|
-
__defNormalProp$7(obj, key + "" , value);
|
|
1570
|
-
return value;
|
|
1571
|
-
};
|
|
1572
|
-
const _GiteaIntegration = class _GiteaIntegration {
|
|
1480
|
+
class GiteaIntegration {
|
|
1573
1481
|
constructor(config) {
|
|
1574
1482
|
this.config = config;
|
|
1575
1483
|
}
|
|
1484
|
+
static factory = ({ config }) => {
|
|
1485
|
+
const configs = config.getOptionalConfigArray("integrations.gitea") ?? [];
|
|
1486
|
+
const giteaConfigs = configs.map((c) => readGiteaConfig(c));
|
|
1487
|
+
return basicIntegrations(
|
|
1488
|
+
giteaConfigs.map((c) => new GiteaIntegration(c)),
|
|
1489
|
+
(gitea) => gitea.config.host
|
|
1490
|
+
);
|
|
1491
|
+
};
|
|
1576
1492
|
get type() {
|
|
1577
1493
|
return "gitea";
|
|
1578
1494
|
}
|
|
@@ -1585,28 +1501,17 @@ const _GiteaIntegration = class _GiteaIntegration {
|
|
|
1585
1501
|
resolveEditUrl(url) {
|
|
1586
1502
|
return getGiteaEditContentsUrl(this.config, url);
|
|
1587
1503
|
}
|
|
1588
|
-
}
|
|
1589
|
-
__publicField$7(_GiteaIntegration, "factory", ({ config }) => {
|
|
1590
|
-
var _a;
|
|
1591
|
-
const configs = (_a = config.getOptionalConfigArray("integrations.gitea")) != null ? _a : [];
|
|
1592
|
-
const giteaConfigs = configs.map((c) => readGiteaConfig(c));
|
|
1593
|
-
return basicIntegrations(
|
|
1594
|
-
giteaConfigs.map((c) => new _GiteaIntegration(c)),
|
|
1595
|
-
(gitea) => gitea.config.host
|
|
1596
|
-
);
|
|
1597
|
-
});
|
|
1598
|
-
let GiteaIntegration = _GiteaIntegration;
|
|
1504
|
+
}
|
|
1599
1505
|
|
|
1600
1506
|
const GITHUB_HOST = "github.com";
|
|
1601
1507
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
1602
1508
|
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|
|
1603
1509
|
function readGithubIntegrationConfig(config) {
|
|
1604
|
-
|
|
1605
|
-
const host = (_a = config.getOptionalString("host")) != null ? _a : GITHUB_HOST;
|
|
1510
|
+
const host = config.getOptionalString("host") ?? GITHUB_HOST;
|
|
1606
1511
|
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
1607
1512
|
let rawBaseUrl = config.getOptionalString("rawBaseUrl");
|
|
1608
|
-
const token =
|
|
1609
|
-
const apps =
|
|
1513
|
+
const token = config.getOptionalString("token")?.trim();
|
|
1514
|
+
const apps = config.getOptionalConfigArray("apps")?.map((c) => ({
|
|
1610
1515
|
appId: c.getNumber("appId"),
|
|
1611
1516
|
clientId: c.getString("clientId"),
|
|
1612
1517
|
clientSecret: c.getString("clientSecret"),
|
|
@@ -1679,17 +1584,8 @@ function chooseEndpoint(config, credentials) {
|
|
|
1679
1584
|
return "raw";
|
|
1680
1585
|
}
|
|
1681
1586
|
|
|
1682
|
-
var __defProp$6 = Object.defineProperty;
|
|
1683
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1684
|
-
var __publicField$6 = (obj, key, value) => {
|
|
1685
|
-
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1686
|
-
return value;
|
|
1687
|
-
};
|
|
1688
1587
|
class Cache {
|
|
1689
|
-
|
|
1690
|
-
__publicField$6(this, "tokenCache", /* @__PURE__ */ new Map());
|
|
1691
|
-
__publicField$6(this, "isExpired", (date) => luxon.DateTime.local() > date);
|
|
1692
|
-
}
|
|
1588
|
+
tokenCache = /* @__PURE__ */ new Map();
|
|
1693
1589
|
async getOrCreateToken(owner, repo, supplier) {
|
|
1694
1590
|
let existingInstallationData = this.tokenCache.get(owner);
|
|
1695
1591
|
if (!existingInstallationData || this.isExpired(existingInstallationData.expiresAt)) {
|
|
@@ -1704,6 +1600,7 @@ class Cache {
|
|
|
1704
1600
|
}
|
|
1705
1601
|
return { accessToken: existingInstallationData.token };
|
|
1706
1602
|
}
|
|
1603
|
+
isExpired = (date) => luxon.DateTime.local() > date;
|
|
1707
1604
|
appliesToRepo(tokenData, repo) {
|
|
1708
1605
|
if (repo === void 0) {
|
|
1709
1606
|
return true;
|
|
@@ -1718,13 +1615,13 @@ const HEADERS = {
|
|
|
1718
1615
|
Accept: "application/vnd.github.machine-man-preview+json"
|
|
1719
1616
|
};
|
|
1720
1617
|
class GithubAppManager {
|
|
1618
|
+
appClient;
|
|
1619
|
+
baseUrl;
|
|
1620
|
+
baseAuthConfig;
|
|
1621
|
+
cache = new Cache();
|
|
1622
|
+
allowedInstallationOwners;
|
|
1721
1623
|
// undefined allows all installations
|
|
1722
1624
|
constructor(config, baseUrl) {
|
|
1723
|
-
__publicField$6(this, "appClient");
|
|
1724
|
-
__publicField$6(this, "baseUrl");
|
|
1725
|
-
__publicField$6(this, "baseAuthConfig");
|
|
1726
|
-
__publicField$6(this, "cache", new Cache());
|
|
1727
|
-
__publicField$6(this, "allowedInstallationOwners");
|
|
1728
1625
|
this.allowedInstallationOwners = config.allowedInstallationOwners;
|
|
1729
1626
|
this.baseUrl = baseUrl;
|
|
1730
1627
|
this.baseAuthConfig = {
|
|
@@ -1739,14 +1636,12 @@ class GithubAppManager {
|
|
|
1739
1636
|
});
|
|
1740
1637
|
}
|
|
1741
1638
|
async getInstallationCredentials(owner, repo) {
|
|
1742
|
-
var _a;
|
|
1743
1639
|
if (this.allowedInstallationOwners) {
|
|
1744
|
-
if (!
|
|
1640
|
+
if (!this.allowedInstallationOwners?.includes(owner)) {
|
|
1745
1641
|
return { accessToken: void 0 };
|
|
1746
1642
|
}
|
|
1747
1643
|
}
|
|
1748
1644
|
return this.cache.getOrCreateToken(owner, repo, async () => {
|
|
1749
|
-
var _a2;
|
|
1750
1645
|
const { installationId, suspended } = await this.getInstallationData(
|
|
1751
1646
|
owner
|
|
1752
1647
|
);
|
|
@@ -1766,7 +1661,7 @@ class GithubAppManager {
|
|
|
1766
1661
|
const repos = await installationClient.paginate(
|
|
1767
1662
|
installationClient.apps.listReposAccessibleToInstallation
|
|
1768
1663
|
);
|
|
1769
|
-
const repositories =
|
|
1664
|
+
const repositories = repos.repositories ?? repos;
|
|
1770
1665
|
repositoryNames = repositories.map((repository) => repository.name);
|
|
1771
1666
|
}
|
|
1772
1667
|
return {
|
|
@@ -1782,10 +1677,7 @@ class GithubAppManager {
|
|
|
1782
1677
|
async getInstallationData(owner) {
|
|
1783
1678
|
const allInstallations = await this.getInstallations();
|
|
1784
1679
|
const installation = allInstallations.find(
|
|
1785
|
-
(inst) =>
|
|
1786
|
-
var _a;
|
|
1787
|
-
return inst.account && "login" in inst.account && ((_a = inst.account.login) == null ? void 0 : _a.toLocaleLowerCase("en-US")) === owner.toLocaleLowerCase("en-US");
|
|
1788
|
-
}
|
|
1680
|
+
(inst) => inst.account && "login" in inst.account && inst.account.login?.toLocaleLowerCase("en-US") === owner.toLocaleLowerCase("en-US")
|
|
1789
1681
|
);
|
|
1790
1682
|
if (installation) {
|
|
1791
1683
|
return {
|
|
@@ -1801,10 +1693,9 @@ class GithubAppManager {
|
|
|
1801
1693
|
}
|
|
1802
1694
|
}
|
|
1803
1695
|
class GithubAppCredentialsMux {
|
|
1696
|
+
apps;
|
|
1804
1697
|
constructor(config) {
|
|
1805
|
-
|
|
1806
|
-
var _a, _b;
|
|
1807
|
-
this.apps = (_b = (_a = config.apps) == null ? void 0 : _a.map((ac) => new GithubAppManager(ac, config.apiBaseUrl))) != null ? _b : [];
|
|
1698
|
+
this.apps = config.apps?.map((ac) => new GithubAppManager(ac, config.apiBaseUrl)) ?? [];
|
|
1808
1699
|
}
|
|
1809
1700
|
async getAllInstallations() {
|
|
1810
1701
|
if (!this.apps.length) {
|
|
@@ -1828,27 +1719,30 @@ class GithubAppCredentialsMux {
|
|
|
1828
1719
|
)
|
|
1829
1720
|
);
|
|
1830
1721
|
const result = results.find(
|
|
1831
|
-
(resultItem) =>
|
|
1832
|
-
var _a;
|
|
1833
|
-
return (_a = resultItem.credentials) == null ? void 0 : _a.accessToken;
|
|
1834
|
-
}
|
|
1722
|
+
(resultItem) => resultItem.credentials?.accessToken
|
|
1835
1723
|
);
|
|
1836
1724
|
if (result) {
|
|
1837
1725
|
return result.credentials.accessToken;
|
|
1838
1726
|
}
|
|
1839
1727
|
const errors = results.map((r) => r.error);
|
|
1840
|
-
const notNotFoundError = errors.find((err) =>
|
|
1728
|
+
const notNotFoundError = errors.find((err) => err?.name !== "NotFoundError");
|
|
1841
1729
|
if (notNotFoundError) {
|
|
1842
1730
|
throw notNotFoundError;
|
|
1843
1731
|
}
|
|
1844
1732
|
return void 0;
|
|
1845
1733
|
}
|
|
1846
1734
|
}
|
|
1847
|
-
|
|
1735
|
+
class SingleInstanceGithubCredentialsProvider {
|
|
1848
1736
|
constructor(githubAppCredentialsMux, token) {
|
|
1849
1737
|
this.githubAppCredentialsMux = githubAppCredentialsMux;
|
|
1850
1738
|
this.token = token;
|
|
1851
1739
|
}
|
|
1740
|
+
static create = (config) => {
|
|
1741
|
+
return new SingleInstanceGithubCredentialsProvider(
|
|
1742
|
+
new GithubAppCredentialsMux(config),
|
|
1743
|
+
config.token
|
|
1744
|
+
);
|
|
1745
|
+
};
|
|
1852
1746
|
/**
|
|
1853
1747
|
* Returns {@link GithubCredentials} for a given URL.
|
|
1854
1748
|
*
|
|
@@ -1885,14 +1779,7 @@ const _SingleInstanceGithubCredentialsProvider = class _SingleInstanceGithubCred
|
|
|
1885
1779
|
type
|
|
1886
1780
|
};
|
|
1887
1781
|
}
|
|
1888
|
-
}
|
|
1889
|
-
__publicField$6(_SingleInstanceGithubCredentialsProvider, "create", (config) => {
|
|
1890
|
-
return new _SingleInstanceGithubCredentialsProvider(
|
|
1891
|
-
new GithubAppCredentialsMux(config),
|
|
1892
|
-
config.token
|
|
1893
|
-
);
|
|
1894
|
-
});
|
|
1895
|
-
let SingleInstanceGithubCredentialsProvider = _SingleInstanceGithubCredentialsProvider;
|
|
1782
|
+
}
|
|
1896
1783
|
|
|
1897
1784
|
class DefaultGithubCredentialsProvider {
|
|
1898
1785
|
constructor(providers) {
|
|
@@ -1942,16 +1829,19 @@ class DefaultGithubCredentialsProvider {
|
|
|
1942
1829
|
}
|
|
1943
1830
|
}
|
|
1944
1831
|
|
|
1945
|
-
|
|
1946
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1947
|
-
var __publicField$5 = (obj, key, value) => {
|
|
1948
|
-
__defNormalProp$5(obj, key + "" , value);
|
|
1949
|
-
return value;
|
|
1950
|
-
};
|
|
1951
|
-
const _GithubIntegration = class _GithubIntegration {
|
|
1832
|
+
class GithubIntegration {
|
|
1952
1833
|
constructor(integrationConfig) {
|
|
1953
1834
|
this.integrationConfig = integrationConfig;
|
|
1954
1835
|
}
|
|
1836
|
+
static factory = ({ config }) => {
|
|
1837
|
+
const configs = readGithubIntegrationConfigs(
|
|
1838
|
+
config.getOptionalConfigArray("integrations.github") ?? []
|
|
1839
|
+
);
|
|
1840
|
+
return basicIntegrations(
|
|
1841
|
+
configs.map((c) => new GithubIntegration(c)),
|
|
1842
|
+
(i) => i.config.host
|
|
1843
|
+
);
|
|
1844
|
+
};
|
|
1955
1845
|
get type() {
|
|
1956
1846
|
return "github";
|
|
1957
1847
|
}
|
|
@@ -1972,18 +1862,7 @@ const _GithubIntegration = class _GithubIntegration {
|
|
|
1972
1862
|
isRateLimited: response.status === 429 || response.status === 403 && response.headers.get("x-ratelimit-remaining") === "0"
|
|
1973
1863
|
};
|
|
1974
1864
|
}
|
|
1975
|
-
}
|
|
1976
|
-
__publicField$5(_GithubIntegration, "factory", ({ config }) => {
|
|
1977
|
-
var _a;
|
|
1978
|
-
const configs = readGithubIntegrationConfigs(
|
|
1979
|
-
(_a = config.getOptionalConfigArray("integrations.github")) != null ? _a : []
|
|
1980
|
-
);
|
|
1981
|
-
return basicIntegrations(
|
|
1982
|
-
configs.map((c) => new _GithubIntegration(c)),
|
|
1983
|
-
(i) => i.config.host
|
|
1984
|
-
);
|
|
1985
|
-
});
|
|
1986
|
-
let GithubIntegration = _GithubIntegration;
|
|
1865
|
+
}
|
|
1987
1866
|
function replaceGithubUrlType(url, type) {
|
|
1988
1867
|
return url.replace(
|
|
1989
1868
|
/\/\/([^/]+)\/([^/]+)\/([^/]+)\/(blob|tree|edit)\//,
|
|
@@ -1993,33 +1872,12 @@ function replaceGithubUrlType(url, type) {
|
|
|
1993
1872
|
);
|
|
1994
1873
|
}
|
|
1995
1874
|
|
|
1996
|
-
var __defProp$4 = Object.defineProperty;
|
|
1997
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1998
|
-
var __publicField$4 = (obj, key, value) => {
|
|
1999
|
-
__defNormalProp$4(obj, key + "" , value);
|
|
2000
|
-
return value;
|
|
2001
|
-
};
|
|
2002
|
-
const getGitHubFileFetchUrl = getGithubFileFetchUrl;
|
|
2003
|
-
class GitHubIntegration extends GithubIntegration {
|
|
2004
|
-
constructor(integrationConfig) {
|
|
2005
|
-
super(integrationConfig);
|
|
2006
|
-
}
|
|
2007
|
-
get config() {
|
|
2008
|
-
return super.config;
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
__publicField$4(GitHubIntegration, "factory", GithubIntegration.factory);
|
|
2012
|
-
const readGitHubIntegrationConfig = readGithubIntegrationConfig;
|
|
2013
|
-
const readGitHubIntegrationConfigs = readGithubIntegrationConfigs;
|
|
2014
|
-
const replaceGitHubUrlType = replaceGithubUrlType;
|
|
2015
|
-
|
|
2016
1875
|
const GITLAB_HOST = "gitlab.com";
|
|
2017
1876
|
const GITLAB_API_BASE_URL = "https://gitlab.com/api/v4";
|
|
2018
1877
|
function readGitLabIntegrationConfig(config) {
|
|
2019
|
-
var _a;
|
|
2020
1878
|
const host = config.getString("host");
|
|
2021
1879
|
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
2022
|
-
const token =
|
|
1880
|
+
const token = config.getOptionalString("token")?.trim();
|
|
2023
1881
|
let baseUrl = config.getOptionalString("baseUrl");
|
|
2024
1882
|
if (apiBaseUrl) {
|
|
2025
1883
|
apiBaseUrl = lodash.trimEnd(apiBaseUrl, "/");
|
|
@@ -2129,16 +1987,19 @@ async function getProjectId(target, config) {
|
|
|
2129
1987
|
}
|
|
2130
1988
|
}
|
|
2131
1989
|
|
|
2132
|
-
|
|
2133
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2134
|
-
var __publicField$3 = (obj, key, value) => {
|
|
2135
|
-
__defNormalProp$3(obj, key + "" , value);
|
|
2136
|
-
return value;
|
|
2137
|
-
};
|
|
2138
|
-
const _GitLabIntegration = class _GitLabIntegration {
|
|
1990
|
+
class GitLabIntegration {
|
|
2139
1991
|
constructor(integrationConfig) {
|
|
2140
1992
|
this.integrationConfig = integrationConfig;
|
|
2141
1993
|
}
|
|
1994
|
+
static factory = ({ config }) => {
|
|
1995
|
+
const configs = readGitLabIntegrationConfigs(
|
|
1996
|
+
config.getOptionalConfigArray("integrations.gitlab") ?? []
|
|
1997
|
+
);
|
|
1998
|
+
return basicIntegrations(
|
|
1999
|
+
configs.map((c) => new GitLabIntegration(c)),
|
|
2000
|
+
(i) => i.config.host
|
|
2001
|
+
);
|
|
2002
|
+
};
|
|
2142
2003
|
get type() {
|
|
2143
2004
|
return "gitlab";
|
|
2144
2005
|
}
|
|
@@ -2154,32 +2015,18 @@ const _GitLabIntegration = class _GitLabIntegration {
|
|
|
2154
2015
|
resolveEditUrl(url) {
|
|
2155
2016
|
return replaceGitLabUrlType(url, "edit");
|
|
2156
2017
|
}
|
|
2157
|
-
}
|
|
2158
|
-
__publicField$3(_GitLabIntegration, "factory", ({ config }) => {
|
|
2159
|
-
var _a;
|
|
2160
|
-
const configs = readGitLabIntegrationConfigs(
|
|
2161
|
-
(_a = config.getOptionalConfigArray("integrations.gitlab")) != null ? _a : []
|
|
2162
|
-
);
|
|
2163
|
-
return basicIntegrations(
|
|
2164
|
-
configs.map((c) => new _GitLabIntegration(c)),
|
|
2165
|
-
(i) => i.config.host
|
|
2166
|
-
);
|
|
2167
|
-
});
|
|
2168
|
-
let GitLabIntegration = _GitLabIntegration;
|
|
2018
|
+
}
|
|
2169
2019
|
function replaceGitLabUrlType(url, type) {
|
|
2170
2020
|
return url.replace(/\/\-\/(blob|tree|edit)\//, `/-/${type}/`);
|
|
2171
2021
|
}
|
|
2172
2022
|
|
|
2173
|
-
|
|
2174
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2175
|
-
var __publicField$2 = (obj, key, value) => {
|
|
2176
|
-
__defNormalProp$2(obj, key + "" , value);
|
|
2177
|
-
return value;
|
|
2178
|
-
};
|
|
2179
|
-
const _SingleInstanceGitlabCredentialsProvider = class _SingleInstanceGitlabCredentialsProvider {
|
|
2023
|
+
class SingleInstanceGitlabCredentialsProvider {
|
|
2180
2024
|
constructor(token) {
|
|
2181
2025
|
this.token = token;
|
|
2182
2026
|
}
|
|
2027
|
+
static create = (config) => {
|
|
2028
|
+
return new SingleInstanceGitlabCredentialsProvider(config.token);
|
|
2029
|
+
};
|
|
2183
2030
|
async getCredentials(_opts) {
|
|
2184
2031
|
if (!this.token) {
|
|
2185
2032
|
return {};
|
|
@@ -2191,11 +2038,7 @@ const _SingleInstanceGitlabCredentialsProvider = class _SingleInstanceGitlabCred
|
|
|
2191
2038
|
token: this.token
|
|
2192
2039
|
};
|
|
2193
2040
|
}
|
|
2194
|
-
}
|
|
2195
|
-
__publicField$2(_SingleInstanceGitlabCredentialsProvider, "create", (config) => {
|
|
2196
|
-
return new _SingleInstanceGitlabCredentialsProvider(config.token);
|
|
2197
|
-
});
|
|
2198
|
-
let SingleInstanceGitlabCredentialsProvider = _SingleInstanceGitlabCredentialsProvider;
|
|
2041
|
+
}
|
|
2199
2042
|
|
|
2200
2043
|
class DefaultGitlabCredentialsProvider {
|
|
2201
2044
|
constructor(providers) {
|
|
@@ -2250,10 +2093,40 @@ function readHarnessConfig(config) {
|
|
|
2250
2093
|
}
|
|
2251
2094
|
|
|
2252
2095
|
function getHarnessEditContentsUrl(config, url) {
|
|
2096
|
+
const parsedUrl = parseHarnessUrl(config, url);
|
|
2097
|
+
return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code/orgs/${parsedUrl.orgName}/projects/${parsedUrl.projectName}/${parsedUrl.repoName}/files/${parsedUrl.branch}/~/${parsedUrl.path}`;
|
|
2098
|
+
}
|
|
2099
|
+
function getHarnessFileContentsUrl(config, url) {
|
|
2100
|
+
const parsedUrl = parseHarnessUrl(config, url);
|
|
2101
|
+
return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/raw/${parsedUrl.path}?routingId=${parsedUrl.accountId}&git_ref=refs/heads/${parsedUrl.refString}`;
|
|
2102
|
+
}
|
|
2103
|
+
function getHarnessArchiveUrl(config, url) {
|
|
2104
|
+
const parsedUrl = parseHarnessUrl(config, url);
|
|
2105
|
+
return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/archive/${parsedUrl.branch}.zip?routingId=${parsedUrl.accountId}`;
|
|
2106
|
+
}
|
|
2107
|
+
function getHarnessLatestCommitUrl(config, url) {
|
|
2108
|
+
const parsedUrl = parseHarnessUrl(config, url);
|
|
2109
|
+
return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/content?routingId=${parsedUrl.accountId}&include_commit=true&git_ref=refs/heads/${parsedUrl.branch}`;
|
|
2110
|
+
}
|
|
2111
|
+
function getHarnessRequestOptions(config) {
|
|
2112
|
+
const headers = {};
|
|
2113
|
+
const { token, apiKey } = config;
|
|
2114
|
+
if (apiKey) {
|
|
2115
|
+
headers["x-api-key"] = apiKey;
|
|
2116
|
+
} else if (token) {
|
|
2117
|
+
headers.Authorization = `Bearer ${token}`;
|
|
2118
|
+
}
|
|
2119
|
+
return {
|
|
2120
|
+
headers
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
function parseHarnessUrl(config, url) {
|
|
2124
|
+
const baseUrl = `https://${config.host}`;
|
|
2253
2125
|
try {
|
|
2254
|
-
const
|
|
2126
|
+
const pathUrl = new URL(url);
|
|
2127
|
+
const pathSegments = pathUrl.pathname.split("/").filter((segment) => segment !== "");
|
|
2128
|
+
const urlParts = pathUrl.pathname.split("/");
|
|
2255
2129
|
const [
|
|
2256
|
-
_blank,
|
|
2257
2130
|
_ng,
|
|
2258
2131
|
_account,
|
|
2259
2132
|
accountId,
|
|
@@ -2268,68 +2141,42 @@ function getHarnessEditContentsUrl(config, url) {
|
|
|
2268
2141
|
_files,
|
|
2269
2142
|
_ref,
|
|
2270
2143
|
_branch,
|
|
2271
|
-
...
|
|
2272
|
-
] =
|
|
2273
|
-
const
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
const baseUrl = `https://${config.host}`;
|
|
2282
|
-
const [
|
|
2283
|
-
_blank,
|
|
2284
|
-
_ng,
|
|
2285
|
-
_account,
|
|
2144
|
+
..._path
|
|
2145
|
+
] = pathSegments;
|
|
2146
|
+
const refAndPath = urlParts.slice(
|
|
2147
|
+
urlParts.findIndex((i) => i === "files" || i === "edit") + 1
|
|
2148
|
+
);
|
|
2149
|
+
const refIndex = refAndPath.findIndex((item) => item === "~");
|
|
2150
|
+
const refString = refAndPath.slice(0, refIndex).join("/");
|
|
2151
|
+
const pathWithoutSlash = refIndex !== -1 ? refAndPath.slice(refIndex + 1).join("/").replace(/^\//, "") : "";
|
|
2152
|
+
return {
|
|
2153
|
+
baseUrl,
|
|
2286
2154
|
accountId,
|
|
2287
|
-
_module,
|
|
2288
|
-
_moduleName,
|
|
2289
|
-
_org,
|
|
2290
2155
|
orgName,
|
|
2291
|
-
_projects,
|
|
2292
2156
|
projectName,
|
|
2293
|
-
|
|
2157
|
+
refString,
|
|
2158
|
+
path: pathWithoutSlash,
|
|
2294
2159
|
repoName,
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
...path
|
|
2299
|
-
] = url.replace(baseUrl, "").split("/");
|
|
2300
|
-
const urlParts = url.replace(baseUrl, "").split("/");
|
|
2301
|
-
const refAndPath = urlParts.slice(13);
|
|
2302
|
-
const refIndex = refAndPath.findIndex((item) => item === "~");
|
|
2303
|
-
const refString = refAndPath.slice(0, refIndex);
|
|
2304
|
-
const pathWithoutSlash = path.join("/").replace(/^\//, "");
|
|
2305
|
-
return `${baseUrl}/gateway/code/api/v1/repos/${accountId}/${orgName}/${projectName}/${repoName}/+/raw/${pathWithoutSlash}?routingId=${accountId}&git_ref=${refString}`;
|
|
2160
|
+
refDashStr: refAndPath.slice(0, refIndex).join("-"),
|
|
2161
|
+
branch: refIndex !== -1 ? refAndPath.slice(0, refIndex).join("/") : refAndPath.join("/")
|
|
2162
|
+
};
|
|
2306
2163
|
} catch (e) {
|
|
2307
2164
|
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
2308
2165
|
}
|
|
2309
2166
|
}
|
|
2310
|
-
function getHarnessRequestOptions(config) {
|
|
2311
|
-
const headers = {};
|
|
2312
|
-
const { token, apiKey } = config;
|
|
2313
|
-
if (apiKey) {
|
|
2314
|
-
headers["x-api-key"] = apiKey;
|
|
2315
|
-
} else if (token) {
|
|
2316
|
-
headers.Authorization = `Bearer ${token}`;
|
|
2317
|
-
}
|
|
2318
|
-
return {
|
|
2319
|
-
headers
|
|
2320
|
-
};
|
|
2321
|
-
}
|
|
2322
2167
|
|
|
2323
|
-
|
|
2324
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2325
|
-
var __publicField$1 = (obj, key, value) => {
|
|
2326
|
-
__defNormalProp$1(obj, key + "" , value);
|
|
2327
|
-
return value;
|
|
2328
|
-
};
|
|
2329
|
-
const _HarnessIntegration = class _HarnessIntegration {
|
|
2168
|
+
class HarnessIntegration {
|
|
2330
2169
|
constructor(config) {
|
|
2331
2170
|
this.config = config;
|
|
2332
2171
|
}
|
|
2172
|
+
static factory = ({ config }) => {
|
|
2173
|
+
const configs = config.getOptionalConfigArray("integrations.harness") ?? [];
|
|
2174
|
+
const harnessConfigs = configs.map((c) => readHarnessConfig(c));
|
|
2175
|
+
return basicIntegrations(
|
|
2176
|
+
harnessConfigs.map((c) => new HarnessIntegration(c)),
|
|
2177
|
+
(harness) => harness.config.host
|
|
2178
|
+
);
|
|
2179
|
+
};
|
|
2333
2180
|
get type() {
|
|
2334
2181
|
return "harness";
|
|
2335
2182
|
}
|
|
@@ -2342,29 +2189,10 @@ const _HarnessIntegration = class _HarnessIntegration {
|
|
|
2342
2189
|
resolveEditUrl(url) {
|
|
2343
2190
|
return getHarnessEditContentsUrl(this.config, url);
|
|
2344
2191
|
}
|
|
2345
|
-
}
|
|
2346
|
-
__publicField$1(_HarnessIntegration, "factory", ({ config }) => {
|
|
2347
|
-
var _a;
|
|
2348
|
-
const configs = (_a = config.getOptionalConfigArray("integrations.harness")) != null ? _a : [];
|
|
2349
|
-
const harnessConfigs = configs.map((c) => readHarnessConfig(c));
|
|
2350
|
-
return basicIntegrations(
|
|
2351
|
-
harnessConfigs.map((c) => new _HarnessIntegration(c)),
|
|
2352
|
-
(harness) => harness.config.host
|
|
2353
|
-
);
|
|
2354
|
-
});
|
|
2355
|
-
let HarnessIntegration = _HarnessIntegration;
|
|
2192
|
+
}
|
|
2356
2193
|
|
|
2357
|
-
var __defProp = Object.defineProperty;
|
|
2358
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2359
|
-
var __publicField = (obj, key, value) => {
|
|
2360
|
-
__defNormalProp(obj, key + "" , value);
|
|
2361
|
-
return value;
|
|
2362
|
-
};
|
|
2363
2194
|
class ScmIntegrations {
|
|
2364
|
-
|
|
2365
|
-
__publicField(this, "byType");
|
|
2366
|
-
this.byType = integrationsByType;
|
|
2367
|
-
}
|
|
2195
|
+
byType;
|
|
2368
2196
|
static fromConfig(config) {
|
|
2369
2197
|
return new ScmIntegrations({
|
|
2370
2198
|
awsS3: AwsS3Integration.factory({ config }),
|
|
@@ -2380,6 +2208,9 @@ class ScmIntegrations {
|
|
|
2380
2208
|
harness: HarnessIntegration.factory({ config })
|
|
2381
2209
|
});
|
|
2382
2210
|
}
|
|
2211
|
+
constructor(integrationsByType) {
|
|
2212
|
+
this.byType = integrationsByType;
|
|
2213
|
+
}
|
|
2383
2214
|
get awsS3() {
|
|
2384
2215
|
return this.byType.awsS3;
|
|
2385
2216
|
}
|
|
@@ -2462,7 +2293,6 @@ exports.DefaultAzureDevOpsCredentialsProvider = DefaultAzureDevOpsCredentialsPro
|
|
|
2462
2293
|
exports.DefaultGithubCredentialsProvider = DefaultGithubCredentialsProvider;
|
|
2463
2294
|
exports.DefaultGitlabCredentialsProvider = DefaultGitlabCredentialsProvider;
|
|
2464
2295
|
exports.GerritIntegration = GerritIntegration;
|
|
2465
|
-
exports.GitHubIntegration = GitHubIntegration;
|
|
2466
2296
|
exports.GitLabIntegration = GitLabIntegration;
|
|
2467
2297
|
exports.GiteaIntegration = GiteaIntegration;
|
|
2468
2298
|
exports.GithubAppCredentialsMux = GithubAppCredentialsMux;
|
|
@@ -2493,7 +2323,6 @@ exports.getGerritCloneRepoUrl = getGerritCloneRepoUrl;
|
|
|
2493
2323
|
exports.getGerritFileContentsApiUrl = getGerritFileContentsApiUrl;
|
|
2494
2324
|
exports.getGerritProjectsApiUrl = getGerritProjectsApiUrl;
|
|
2495
2325
|
exports.getGerritRequestOptions = getGerritRequestOptions;
|
|
2496
|
-
exports.getGitHubFileFetchUrl = getGitHubFileFetchUrl;
|
|
2497
2326
|
exports.getGitHubRequestOptions = getGitHubRequestOptions;
|
|
2498
2327
|
exports.getGitLabFileFetchUrl = getGitLabFileFetchUrl;
|
|
2499
2328
|
exports.getGitLabIntegrationRelativePath = getGitLabIntegrationRelativePath;
|
|
@@ -2504,11 +2333,14 @@ exports.getGiteaFileContentsUrl = getGiteaFileContentsUrl;
|
|
|
2504
2333
|
exports.getGiteaLatestCommitUrl = getGiteaLatestCommitUrl;
|
|
2505
2334
|
exports.getGiteaRequestOptions = getGiteaRequestOptions;
|
|
2506
2335
|
exports.getGithubFileFetchUrl = getGithubFileFetchUrl;
|
|
2336
|
+
exports.getHarnessArchiveUrl = getHarnessArchiveUrl;
|
|
2507
2337
|
exports.getHarnessFileContentsUrl = getHarnessFileContentsUrl;
|
|
2338
|
+
exports.getHarnessLatestCommitUrl = getHarnessLatestCommitUrl;
|
|
2508
2339
|
exports.getHarnessRequestOptions = getHarnessRequestOptions;
|
|
2509
2340
|
exports.parseGerritGitilesUrl = parseGerritGitilesUrl;
|
|
2510
2341
|
exports.parseGerritJsonResponse = parseGerritJsonResponse;
|
|
2511
2342
|
exports.parseGiteaUrl = parseGiteaUrl;
|
|
2343
|
+
exports.parseHarnessUrl = parseHarnessUrl;
|
|
2512
2344
|
exports.readAwsCodeCommitIntegrationConfig = readAwsCodeCommitIntegrationConfig;
|
|
2513
2345
|
exports.readAwsCodeCommitIntegrationConfigs = readAwsCodeCommitIntegrationConfigs;
|
|
2514
2346
|
exports.readAwsS3IntegrationConfig = readAwsS3IntegrationConfig;
|
|
@@ -2523,8 +2355,6 @@ exports.readBitbucketServerIntegrationConfig = readBitbucketServerIntegrationCon
|
|
|
2523
2355
|
exports.readBitbucketServerIntegrationConfigs = readBitbucketServerIntegrationConfigs;
|
|
2524
2356
|
exports.readGerritIntegrationConfig = readGerritIntegrationConfig;
|
|
2525
2357
|
exports.readGerritIntegrationConfigs = readGerritIntegrationConfigs;
|
|
2526
|
-
exports.readGitHubIntegrationConfig = readGitHubIntegrationConfig;
|
|
2527
|
-
exports.readGitHubIntegrationConfigs = readGitHubIntegrationConfigs;
|
|
2528
2358
|
exports.readGitLabIntegrationConfig = readGitLabIntegrationConfig;
|
|
2529
2359
|
exports.readGitLabIntegrationConfigs = readGitLabIntegrationConfigs;
|
|
2530
2360
|
exports.readGiteaConfig = readGiteaConfig;
|
|
@@ -2532,7 +2362,6 @@ exports.readGithubIntegrationConfig = readGithubIntegrationConfig;
|
|
|
2532
2362
|
exports.readGithubIntegrationConfigs = readGithubIntegrationConfigs;
|
|
2533
2363
|
exports.readGoogleGcsIntegrationConfig = readGoogleGcsIntegrationConfig;
|
|
2534
2364
|
exports.readHarnessConfig = readHarnessConfig;
|
|
2535
|
-
exports.replaceGitHubUrlType = replaceGitHubUrlType;
|
|
2536
2365
|
exports.replaceGitLabUrlType = replaceGitLabUrlType;
|
|
2537
2366
|
exports.replaceGithubUrlType = replaceGithubUrlType;
|
|
2538
2367
|
//# sourceMappingURL=index.cjs.js.map
|