@backstage/integration 1.1.0-next.1 → 1.2.0-next.0
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 +63 -0
- package/config.d.ts +42 -1
- package/dist/index.cjs.js +361 -79
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +372 -78
- package/dist/index.esm.js +343 -80
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -5
package/dist/index.esm.js
CHANGED
|
@@ -59,6 +59,79 @@ function defaultScmResolveUrl(options) {
|
|
|
59
59
|
return updated.toString();
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
const AMAZON_AWS_HOST = "amazonaws.com";
|
|
63
|
+
function readAwsS3IntegrationConfig(config) {
|
|
64
|
+
var _a;
|
|
65
|
+
const endpoint = config.getOptionalString("endpoint");
|
|
66
|
+
const s3ForcePathStyle = (_a = config.getOptionalBoolean("s3ForcePathStyle")) != null ? _a : false;
|
|
67
|
+
let host;
|
|
68
|
+
let pathname;
|
|
69
|
+
if (endpoint) {
|
|
70
|
+
try {
|
|
71
|
+
const url = new URL(endpoint);
|
|
72
|
+
host = url.host;
|
|
73
|
+
pathname = url.pathname;
|
|
74
|
+
} catch {
|
|
75
|
+
throw new Error(`invalid awsS3 integration config, endpoint '${endpoint}' is not a valid URL`);
|
|
76
|
+
}
|
|
77
|
+
if (pathname !== "/") {
|
|
78
|
+
throw new Error(`invalid awsS3 integration config, endpoints cannot contain path, got '${endpoint}'`);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
host = AMAZON_AWS_HOST;
|
|
82
|
+
}
|
|
83
|
+
const accessKeyId = config.getOptionalString("accessKeyId");
|
|
84
|
+
const secretAccessKey = config.getOptionalString("secretAccessKey");
|
|
85
|
+
const roleArn = config.getOptionalString("roleArn");
|
|
86
|
+
const externalId = config.getOptionalString("externalId");
|
|
87
|
+
return {
|
|
88
|
+
host,
|
|
89
|
+
endpoint,
|
|
90
|
+
s3ForcePathStyle,
|
|
91
|
+
accessKeyId,
|
|
92
|
+
secretAccessKey,
|
|
93
|
+
roleArn,
|
|
94
|
+
externalId
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function readAwsS3IntegrationConfigs(configs) {
|
|
98
|
+
const result = configs.map(readAwsS3IntegrationConfig);
|
|
99
|
+
if (!result.some((c) => c.host === AMAZON_AWS_HOST)) {
|
|
100
|
+
result.push({
|
|
101
|
+
host: AMAZON_AWS_HOST
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const _AwsS3Integration = class {
|
|
108
|
+
constructor(integrationConfig) {
|
|
109
|
+
this.integrationConfig = integrationConfig;
|
|
110
|
+
}
|
|
111
|
+
get type() {
|
|
112
|
+
return "awsS3";
|
|
113
|
+
}
|
|
114
|
+
get title() {
|
|
115
|
+
return this.integrationConfig.host;
|
|
116
|
+
}
|
|
117
|
+
get config() {
|
|
118
|
+
return this.integrationConfig;
|
|
119
|
+
}
|
|
120
|
+
resolveUrl(options) {
|
|
121
|
+
const resolved = defaultScmResolveUrl(options);
|
|
122
|
+
return resolved;
|
|
123
|
+
}
|
|
124
|
+
resolveEditUrl(url) {
|
|
125
|
+
return url;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
let AwsS3Integration = _AwsS3Integration;
|
|
129
|
+
AwsS3Integration.factory = ({ config }) => {
|
|
130
|
+
var _a;
|
|
131
|
+
const configs = readAwsS3IntegrationConfigs((_a = config.getOptionalConfigArray("integrations.awsS3")) != null ? _a : []);
|
|
132
|
+
return basicIntegrations(configs.map((c) => new _AwsS3Integration(c)), (i) => i.config.host);
|
|
133
|
+
};
|
|
134
|
+
|
|
62
135
|
var __accessCheck = (obj, member, msg) => {
|
|
63
136
|
if (!member.has(obj))
|
|
64
137
|
throw TypeError("Cannot " + msg);
|
|
@@ -362,8 +435,11 @@ let BitbucketIntegration = _BitbucketIntegration;
|
|
|
362
435
|
BitbucketIntegration.factory = ({
|
|
363
436
|
config
|
|
364
437
|
}) => {
|
|
365
|
-
var _a;
|
|
366
|
-
const configs = readBitbucketIntegrationConfigs((
|
|
438
|
+
var _a, _b, _c;
|
|
439
|
+
const configs = readBitbucketIntegrationConfigs((_c = config.getOptionalConfigArray("integrations.bitbucket")) != null ? _c : [
|
|
440
|
+
...(_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : [],
|
|
441
|
+
...(_b = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _b : []
|
|
442
|
+
]);
|
|
367
443
|
return basicIntegrations(configs.map((c) => new _BitbucketIntegration(c)), (i) => i.config.host);
|
|
368
444
|
};
|
|
369
445
|
|
|
@@ -442,9 +518,242 @@ function getBitbucketRequestOptions(config) {
|
|
|
442
518
|
};
|
|
443
519
|
}
|
|
444
520
|
|
|
521
|
+
const BITBUCKET_CLOUD_HOST = "bitbucket.org";
|
|
522
|
+
const BITBUCKET_CLOUD_API_BASE_URL = "https://api.bitbucket.org/2.0";
|
|
523
|
+
function readBitbucketCloudIntegrationConfig(config) {
|
|
524
|
+
const host = BITBUCKET_CLOUD_HOST;
|
|
525
|
+
const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;
|
|
526
|
+
const username = config.getString("username");
|
|
527
|
+
const appPassword = config.getString("appPassword");
|
|
528
|
+
return {
|
|
529
|
+
host,
|
|
530
|
+
apiBaseUrl,
|
|
531
|
+
username,
|
|
532
|
+
appPassword
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
function readBitbucketCloudIntegrationConfigs(configs) {
|
|
536
|
+
const result = configs.map(readBitbucketCloudIntegrationConfig);
|
|
537
|
+
if (result.length === 0) {
|
|
538
|
+
result.push({
|
|
539
|
+
host: BITBUCKET_CLOUD_HOST,
|
|
540
|
+
apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
return result;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
const _BitbucketCloudIntegration = class {
|
|
547
|
+
constructor(integrationConfig) {
|
|
548
|
+
this.integrationConfig = integrationConfig;
|
|
549
|
+
}
|
|
550
|
+
get type() {
|
|
551
|
+
return "bitbucketCloud";
|
|
552
|
+
}
|
|
553
|
+
get title() {
|
|
554
|
+
return this.integrationConfig.host;
|
|
555
|
+
}
|
|
556
|
+
get config() {
|
|
557
|
+
return this.integrationConfig;
|
|
558
|
+
}
|
|
559
|
+
resolveUrl(options) {
|
|
560
|
+
const resolved = defaultScmResolveUrl(options);
|
|
561
|
+
if (options.lineNumber) {
|
|
562
|
+
const url = new URL(resolved);
|
|
563
|
+
url.hash = `lines-${options.lineNumber}`;
|
|
564
|
+
return url.toString();
|
|
565
|
+
}
|
|
566
|
+
return resolved;
|
|
567
|
+
}
|
|
568
|
+
resolveEditUrl(url) {
|
|
569
|
+
const urlData = parseGitUrl(url);
|
|
570
|
+
const editUrl = new URL(url);
|
|
571
|
+
editUrl.searchParams.set("mode", "edit");
|
|
572
|
+
editUrl.searchParams.set("at", urlData.ref);
|
|
573
|
+
return editUrl.toString();
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
let BitbucketCloudIntegration = _BitbucketCloudIntegration;
|
|
577
|
+
BitbucketCloudIntegration.factory = ({
|
|
578
|
+
config
|
|
579
|
+
}) => {
|
|
580
|
+
var _a;
|
|
581
|
+
const configs = readBitbucketCloudIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : []);
|
|
582
|
+
return basicIntegrations(configs.map((c) => new _BitbucketCloudIntegration(c)), (i) => i.config.host);
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
async function getBitbucketCloudDefaultBranch(url, config) {
|
|
586
|
+
const { name: repoName, owner: project } = parseGitUrl(url);
|
|
587
|
+
const branchUrl = `${config.apiBaseUrl}/repositories/${project}/${repoName}`;
|
|
588
|
+
const response = await fetch(branchUrl, getBitbucketCloudRequestOptions(config));
|
|
589
|
+
if (!response.ok) {
|
|
590
|
+
const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;
|
|
591
|
+
throw new Error(message);
|
|
592
|
+
}
|
|
593
|
+
const repoInfo = await response.json();
|
|
594
|
+
const defaultBranch = repoInfo.mainbranch.name;
|
|
595
|
+
if (!defaultBranch) {
|
|
596
|
+
throw new Error(`Failed to read default branch from ${branchUrl}. Response ${response.status} ${response.json()}`);
|
|
597
|
+
}
|
|
598
|
+
return defaultBranch;
|
|
599
|
+
}
|
|
600
|
+
async function getBitbucketCloudDownloadUrl(url, config) {
|
|
601
|
+
const {
|
|
602
|
+
name: repoName,
|
|
603
|
+
owner: project,
|
|
604
|
+
ref,
|
|
605
|
+
protocol,
|
|
606
|
+
resource
|
|
607
|
+
} = parseGitUrl(url);
|
|
608
|
+
let branch = ref;
|
|
609
|
+
if (!branch) {
|
|
610
|
+
branch = await getBitbucketCloudDefaultBranch(url, config);
|
|
611
|
+
}
|
|
612
|
+
return `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`;
|
|
613
|
+
}
|
|
614
|
+
function getBitbucketCloudFileFetchUrl(url, config) {
|
|
615
|
+
try {
|
|
616
|
+
const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);
|
|
617
|
+
if (!owner || !name || filepathtype !== "src" && filepathtype !== "raw") {
|
|
618
|
+
throw new Error("Invalid Bitbucket Cloud URL or file path");
|
|
619
|
+
}
|
|
620
|
+
const pathWithoutSlash = filepath.replace(/^\//, "");
|
|
621
|
+
if (!ref) {
|
|
622
|
+
throw new Error("Invalid Bitbucket Cloud URL or file path");
|
|
623
|
+
}
|
|
624
|
+
return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;
|
|
625
|
+
} catch (e) {
|
|
626
|
+
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
function getBitbucketCloudRequestOptions(config) {
|
|
630
|
+
const headers = {};
|
|
631
|
+
if (config.username && config.appPassword) {
|
|
632
|
+
const buffer = Buffer.from(`${config.username}:${config.appPassword}`, "utf8");
|
|
633
|
+
headers.Authorization = `Basic ${buffer.toString("base64")}`;
|
|
634
|
+
}
|
|
635
|
+
return {
|
|
636
|
+
headers
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function readBitbucketServerIntegrationConfig(config) {
|
|
641
|
+
const host = config.getString("host");
|
|
642
|
+
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
643
|
+
const token = config.getOptionalString("token");
|
|
644
|
+
if (!isValidHost(host)) {
|
|
645
|
+
throw new Error(`Invalid Bitbucket Server integration config, '${host}' is not a valid host`);
|
|
646
|
+
}
|
|
647
|
+
if (apiBaseUrl) {
|
|
648
|
+
apiBaseUrl = trimEnd(apiBaseUrl, "/");
|
|
649
|
+
} else {
|
|
650
|
+
apiBaseUrl = `https://${host}/rest/api/1.0`;
|
|
651
|
+
}
|
|
652
|
+
return {
|
|
653
|
+
host,
|
|
654
|
+
apiBaseUrl,
|
|
655
|
+
token
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
function readBitbucketServerIntegrationConfigs(configs) {
|
|
659
|
+
return configs.map(readBitbucketServerIntegrationConfig);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
const _BitbucketServerIntegration = class {
|
|
663
|
+
constructor(integrationConfig) {
|
|
664
|
+
this.integrationConfig = integrationConfig;
|
|
665
|
+
}
|
|
666
|
+
get type() {
|
|
667
|
+
return "bitbucketServer";
|
|
668
|
+
}
|
|
669
|
+
get title() {
|
|
670
|
+
return this.integrationConfig.host;
|
|
671
|
+
}
|
|
672
|
+
get config() {
|
|
673
|
+
return this.integrationConfig;
|
|
674
|
+
}
|
|
675
|
+
resolveUrl(options) {
|
|
676
|
+
const resolved = defaultScmResolveUrl(options);
|
|
677
|
+
if (options.lineNumber) {
|
|
678
|
+
const url = new URL(resolved);
|
|
679
|
+
const filename = url.pathname.split("/").slice(-1)[0];
|
|
680
|
+
url.hash = `${filename}-${options.lineNumber}`;
|
|
681
|
+
return url.toString();
|
|
682
|
+
}
|
|
683
|
+
return resolved;
|
|
684
|
+
}
|
|
685
|
+
resolveEditUrl(url) {
|
|
686
|
+
const urlData = parseGitUrl(url);
|
|
687
|
+
const editUrl = new URL(url);
|
|
688
|
+
editUrl.searchParams.set("mode", "edit");
|
|
689
|
+
editUrl.searchParams.set("spa", "0");
|
|
690
|
+
editUrl.searchParams.set("at", urlData.ref);
|
|
691
|
+
return editUrl.toString();
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
let BitbucketServerIntegration = _BitbucketServerIntegration;
|
|
695
|
+
BitbucketServerIntegration.factory = ({
|
|
696
|
+
config
|
|
697
|
+
}) => {
|
|
698
|
+
var _a;
|
|
699
|
+
const configs = readBitbucketServerIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _a : []);
|
|
700
|
+
return basicIntegrations(configs.map((c) => new _BitbucketServerIntegration(c)), (i) => i.config.host);
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
async function getBitbucketServerDefaultBranch(url, config) {
|
|
704
|
+
const { name: repoName, owner: project } = parseGitUrl(url);
|
|
705
|
+
let branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;
|
|
706
|
+
let response = await fetch(branchUrl, getBitbucketServerRequestOptions(config));
|
|
707
|
+
if (response.status === 404) {
|
|
708
|
+
branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;
|
|
709
|
+
response = await fetch(branchUrl, getBitbucketServerRequestOptions(config));
|
|
710
|
+
}
|
|
711
|
+
if (!response.ok) {
|
|
712
|
+
const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;
|
|
713
|
+
throw new Error(message);
|
|
714
|
+
}
|
|
715
|
+
const { displayId } = await response.json();
|
|
716
|
+
const defaultBranch = displayId;
|
|
717
|
+
if (!defaultBranch) {
|
|
718
|
+
throw new Error(`Failed to read default branch from ${branchUrl}. Response ${response.status} ${response.json()}`);
|
|
719
|
+
}
|
|
720
|
+
return defaultBranch;
|
|
721
|
+
}
|
|
722
|
+
async function getBitbucketServerDownloadUrl(url, config) {
|
|
723
|
+
const { name: repoName, owner: project, ref, filepath } = parseGitUrl(url);
|
|
724
|
+
let branch = ref;
|
|
725
|
+
if (!branch) {
|
|
726
|
+
branch = await getBitbucketServerDefaultBranch(url, config);
|
|
727
|
+
}
|
|
728
|
+
const path = filepath ? `&path=${encodeURIComponent(filepath)}` : "";
|
|
729
|
+
return `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;
|
|
730
|
+
}
|
|
731
|
+
function getBitbucketServerFileFetchUrl(url, config) {
|
|
732
|
+
try {
|
|
733
|
+
const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);
|
|
734
|
+
if (!owner || !name || filepathtype !== "browse" && filepathtype !== "raw" && filepathtype !== "src") {
|
|
735
|
+
throw new Error("Invalid Bitbucket Server URL or file path");
|
|
736
|
+
}
|
|
737
|
+
const pathWithoutSlash = filepath.replace(/^\//, "");
|
|
738
|
+
return `${config.apiBaseUrl}/projects/${owner}/repos/${name}/raw/${pathWithoutSlash}?at=${ref}`;
|
|
739
|
+
} catch (e) {
|
|
740
|
+
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
function getBitbucketServerRequestOptions(config) {
|
|
744
|
+
const headers = {};
|
|
745
|
+
if (config.token) {
|
|
746
|
+
headers.Authorization = `Bearer ${config.token}`;
|
|
747
|
+
}
|
|
748
|
+
return {
|
|
749
|
+
headers
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
445
753
|
function readGerritIntegrationConfig(config) {
|
|
446
754
|
const host = config.getString("host");
|
|
447
755
|
let baseUrl = config.getOptionalString("baseUrl");
|
|
756
|
+
let cloneUrl = config.getOptionalString("cloneUrl");
|
|
448
757
|
let gitilesBaseUrl = config.getOptionalString("gitilesBaseUrl");
|
|
449
758
|
const username = config.getOptionalString("username");
|
|
450
759
|
const password = config.getOptionalString("password");
|
|
@@ -452,6 +761,8 @@ function readGerritIntegrationConfig(config) {
|
|
|
452
761
|
throw new Error(`Invalid Gerrit integration config, '${host}' is not a valid host`);
|
|
453
762
|
} else if (baseUrl && !isValidUrl(baseUrl)) {
|
|
454
763
|
throw new Error(`Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`);
|
|
764
|
+
} else if (cloneUrl && !isValidUrl(cloneUrl)) {
|
|
765
|
+
throw new Error(`Invalid Gerrit integration config, '${cloneUrl}' is not a valid cloneUrl`);
|
|
455
766
|
} else if (gitilesBaseUrl && !isValidUrl(gitilesBaseUrl)) {
|
|
456
767
|
throw new Error(`Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`);
|
|
457
768
|
}
|
|
@@ -465,9 +776,15 @@ function readGerritIntegrationConfig(config) {
|
|
|
465
776
|
} else {
|
|
466
777
|
gitilesBaseUrl = `https://${host}`;
|
|
467
778
|
}
|
|
779
|
+
if (cloneUrl) {
|
|
780
|
+
cloneUrl = trimEnd(cloneUrl, "/");
|
|
781
|
+
} else {
|
|
782
|
+
cloneUrl = baseUrl;
|
|
783
|
+
}
|
|
468
784
|
return {
|
|
469
785
|
host,
|
|
470
786
|
baseUrl,
|
|
787
|
+
cloneUrl,
|
|
471
788
|
gitilesBaseUrl,
|
|
472
789
|
username,
|
|
473
790
|
password
|
|
@@ -515,7 +832,7 @@ GerritIntegration.factory = ({ config }) => {
|
|
|
515
832
|
};
|
|
516
833
|
|
|
517
834
|
const GERRIT_BODY_PREFIX = ")]}'";
|
|
518
|
-
function
|
|
835
|
+
function parseGerritGitilesUrl(config, url) {
|
|
519
836
|
const urlPath = url.replace(config.gitilesBaseUrl, "");
|
|
520
837
|
const parts = urlPath.split("/").filter((p) => !!p);
|
|
521
838
|
const projectEndIndex = parts.indexOf("+");
|
|
@@ -538,10 +855,21 @@ function parseGitilesUrl(config, url) {
|
|
|
538
855
|
function getAuthenticationPrefix(config) {
|
|
539
856
|
return config.password ? "/a/" : "/";
|
|
540
857
|
}
|
|
858
|
+
function getGerritBranchApiUrl(config, url) {
|
|
859
|
+
const { branch, project } = parseGerritGitilesUrl(config, url);
|
|
860
|
+
return `${config.baseUrl}${getAuthenticationPrefix(config)}projects/${encodeURIComponent(project)}/branches/${branch}`;
|
|
861
|
+
}
|
|
862
|
+
function getGerritCloneRepoUrl(config, url) {
|
|
863
|
+
const { project } = parseGerritGitilesUrl(config, url);
|
|
864
|
+
return `${config.cloneUrl}${getAuthenticationPrefix(config)}${project}`;
|
|
865
|
+
}
|
|
541
866
|
function getGerritFileContentsApiUrl(config, url) {
|
|
542
|
-
const { branch, filePath, project } =
|
|
867
|
+
const { branch, filePath, project } = parseGerritGitilesUrl(config, url);
|
|
543
868
|
return `${config.baseUrl}${getAuthenticationPrefix(config)}projects/${encodeURIComponent(project)}/branches/${branch}/files/${encodeURIComponent(filePath)}/content`;
|
|
544
869
|
}
|
|
870
|
+
function getGerritProjectsApiUrl(config) {
|
|
871
|
+
return `${config.baseUrl}${getAuthenticationPrefix(config)}projects/`;
|
|
872
|
+
}
|
|
545
873
|
function getGerritRequestOptions(config) {
|
|
546
874
|
const headers = {};
|
|
547
875
|
if (!config.password) {
|
|
@@ -961,7 +1289,7 @@ const _GitLabIntegration = class {
|
|
|
961
1289
|
return defaultScmResolveUrl(options);
|
|
962
1290
|
}
|
|
963
1291
|
resolveEditUrl(url) {
|
|
964
|
-
return
|
|
1292
|
+
return replaceGitLabUrlType(url, "edit");
|
|
965
1293
|
}
|
|
966
1294
|
};
|
|
967
1295
|
let GitLabIntegration = _GitLabIntegration;
|
|
@@ -970,7 +1298,7 @@ GitLabIntegration.factory = ({ config }) => {
|
|
|
970
1298
|
const configs = readGitLabIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gitlab")) != null ? _a : []);
|
|
971
1299
|
return basicIntegrations(configs.map((c) => new _GitLabIntegration(c)), (i) => i.config.host);
|
|
972
1300
|
};
|
|
973
|
-
function
|
|
1301
|
+
function replaceGitLabUrlType(url, type) {
|
|
974
1302
|
return url.replace(/\/\-\/(blob|tree|edit)\//, `/-/${type}/`);
|
|
975
1303
|
}
|
|
976
1304
|
|
|
@@ -986,85 +1314,14 @@ function readGoogleGcsIntegrationConfig(config) {
|
|
|
986
1314
|
return { clientEmail, privateKey };
|
|
987
1315
|
}
|
|
988
1316
|
|
|
989
|
-
const AMAZON_AWS_HOST = "amazonaws.com";
|
|
990
|
-
function readAwsS3IntegrationConfig(config) {
|
|
991
|
-
var _a;
|
|
992
|
-
const endpoint = config.getOptionalString("endpoint");
|
|
993
|
-
const s3ForcePathStyle = (_a = config.getOptionalBoolean("s3ForcePathStyle")) != null ? _a : false;
|
|
994
|
-
let host;
|
|
995
|
-
let pathname;
|
|
996
|
-
if (endpoint) {
|
|
997
|
-
try {
|
|
998
|
-
const url = new URL(endpoint);
|
|
999
|
-
host = url.host;
|
|
1000
|
-
pathname = url.pathname;
|
|
1001
|
-
} catch {
|
|
1002
|
-
throw new Error(`invalid awsS3 integration config, endpoint '${endpoint}' is not a valid URL`);
|
|
1003
|
-
}
|
|
1004
|
-
if (pathname !== "/") {
|
|
1005
|
-
throw new Error(`invalid awsS3 integration config, endpoints cannot contain path, got '${endpoint}'`);
|
|
1006
|
-
}
|
|
1007
|
-
} else {
|
|
1008
|
-
host = AMAZON_AWS_HOST;
|
|
1009
|
-
}
|
|
1010
|
-
const accessKeyId = config.getOptionalString("accessKeyId");
|
|
1011
|
-
const secretAccessKey = config.getOptionalString("secretAccessKey");
|
|
1012
|
-
const roleArn = config.getOptionalString("roleArn");
|
|
1013
|
-
const externalId = config.getOptionalString("externalId");
|
|
1014
|
-
return {
|
|
1015
|
-
host,
|
|
1016
|
-
endpoint,
|
|
1017
|
-
s3ForcePathStyle,
|
|
1018
|
-
accessKeyId,
|
|
1019
|
-
secretAccessKey,
|
|
1020
|
-
roleArn,
|
|
1021
|
-
externalId
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
|
-
function readAwsS3IntegrationConfigs(configs) {
|
|
1025
|
-
const result = configs.map(readAwsS3IntegrationConfig);
|
|
1026
|
-
if (!result.some((c) => c.host === AMAZON_AWS_HOST)) {
|
|
1027
|
-
result.push({
|
|
1028
|
-
host: AMAZON_AWS_HOST
|
|
1029
|
-
});
|
|
1030
|
-
}
|
|
1031
|
-
return result;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
const _AwsS3Integration = class {
|
|
1035
|
-
constructor(integrationConfig) {
|
|
1036
|
-
this.integrationConfig = integrationConfig;
|
|
1037
|
-
}
|
|
1038
|
-
get type() {
|
|
1039
|
-
return "awsS3";
|
|
1040
|
-
}
|
|
1041
|
-
get title() {
|
|
1042
|
-
return this.integrationConfig.host;
|
|
1043
|
-
}
|
|
1044
|
-
get config() {
|
|
1045
|
-
return this.integrationConfig;
|
|
1046
|
-
}
|
|
1047
|
-
resolveUrl(options) {
|
|
1048
|
-
const resolved = defaultScmResolveUrl(options);
|
|
1049
|
-
return resolved;
|
|
1050
|
-
}
|
|
1051
|
-
resolveEditUrl(url) {
|
|
1052
|
-
return url;
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
let AwsS3Integration = _AwsS3Integration;
|
|
1056
|
-
AwsS3Integration.factory = ({ config }) => {
|
|
1057
|
-
var _a;
|
|
1058
|
-
const configs = readAwsS3IntegrationConfigs((_a = config.getOptionalConfigArray("integrations.awsS3")) != null ? _a : []);
|
|
1059
|
-
return basicIntegrations(configs.map((c) => new _AwsS3Integration(c)), (i) => i.config.host);
|
|
1060
|
-
};
|
|
1061
|
-
|
|
1062
1317
|
class ScmIntegrations {
|
|
1063
1318
|
static fromConfig(config) {
|
|
1064
1319
|
return new ScmIntegrations({
|
|
1065
1320
|
awsS3: AwsS3Integration.factory({ config }),
|
|
1066
1321
|
azure: AzureIntegration.factory({ config }),
|
|
1067
1322
|
bitbucket: BitbucketIntegration.factory({ config }),
|
|
1323
|
+
bitbucketCloud: BitbucketCloudIntegration.factory({ config }),
|
|
1324
|
+
bitbucketServer: BitbucketServerIntegration.factory({ config }),
|
|
1068
1325
|
gerrit: GerritIntegration.factory({ config }),
|
|
1069
1326
|
github: GitHubIntegration.factory({ config }),
|
|
1070
1327
|
gitlab: GitLabIntegration.factory({ config })
|
|
@@ -1082,6 +1339,12 @@ class ScmIntegrations {
|
|
|
1082
1339
|
get bitbucket() {
|
|
1083
1340
|
return this.byType.bitbucket;
|
|
1084
1341
|
}
|
|
1342
|
+
get bitbucketCloud() {
|
|
1343
|
+
return this.byType.bitbucketCloud;
|
|
1344
|
+
}
|
|
1345
|
+
get bitbucketServer() {
|
|
1346
|
+
return this.byType.bitbucketServer;
|
|
1347
|
+
}
|
|
1085
1348
|
get gerrit() {
|
|
1086
1349
|
return this.byType.gerrit;
|
|
1087
1350
|
}
|
|
@@ -1116,5 +1379,5 @@ class ScmIntegrations {
|
|
|
1116
1379
|
}
|
|
1117
1380
|
}
|
|
1118
1381
|
|
|
1119
|
-
export { AwsS3Integration, AzureIntegration, BitbucketIntegration, DefaultGithubCredentialsProvider, GerritIntegration, GitHubIntegration, GitLabIntegration, GithubAppCredentialsMux, ScmIntegrations, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getGerritFileContentsApiUrl, getGerritRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, parseGerritJsonResponse, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType };
|
|
1382
|
+
export { AwsS3Integration, AzureIntegration, BitbucketCloudIntegration, BitbucketIntegration, BitbucketServerIntegration, DefaultGithubCredentialsProvider, GerritIntegration, GitHubIntegration, GitLabIntegration, GithubAppCredentialsMux, ScmIntegrations, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, parseGerritGitilesUrl, parseGerritJsonResponse, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType, replaceGitLabUrlType };
|
|
1120
1383
|
//# sourceMappingURL=index.esm.js.map
|