@backstage/integration 0.8.0 → 1.0.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 +12 -0
- package/config.d.ts +25 -0
- package/dist/index.cjs.js +70 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +68 -1
- package/dist/index.esm.js +68 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -296,6 +296,70 @@ declare function getBitbucketRequestOptions(config: BitbucketIntegrationConfig):
|
|
|
296
296
|
headers: Record<string, string>;
|
|
297
297
|
};
|
|
298
298
|
|
|
299
|
+
/**
|
|
300
|
+
* The configuration parameters for a single Gerrit API provider.
|
|
301
|
+
*
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
304
|
+
declare type GerritIntegrationConfig = {
|
|
305
|
+
/**
|
|
306
|
+
* The host of the target that this matches on, e.g. "gerrit-review.com"
|
|
307
|
+
*/
|
|
308
|
+
host: string;
|
|
309
|
+
/**
|
|
310
|
+
* The optional base URL of the Gerrit instance. It is assumed that https
|
|
311
|
+
* is used and that the base path is "/" on the host. If that is not the
|
|
312
|
+
* case set the complete base url to the gerrit instance, e.g.
|
|
313
|
+
* "https://gerrit-review.com/gerrit". This is the url that you would open
|
|
314
|
+
* in a browser.
|
|
315
|
+
*/
|
|
316
|
+
baseUrl?: string;
|
|
317
|
+
/**
|
|
318
|
+
* The username to use for requests to gerrit.
|
|
319
|
+
*/
|
|
320
|
+
username?: string;
|
|
321
|
+
/**
|
|
322
|
+
* The password or http token to use for authentication.
|
|
323
|
+
*/
|
|
324
|
+
password?: string;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Reads a single Gerrit integration config.
|
|
328
|
+
*
|
|
329
|
+
* @param config - The config object of a single integration
|
|
330
|
+
*
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
declare function readGerritIntegrationConfig(config: Config): GerritIntegrationConfig;
|
|
334
|
+
/**
|
|
335
|
+
* Reads a set of Gerrit integration configs.
|
|
336
|
+
*
|
|
337
|
+
* @param configs - All of the integration config objects
|
|
338
|
+
*
|
|
339
|
+
* @public
|
|
340
|
+
*/
|
|
341
|
+
declare function readGerritIntegrationConfigs(configs: Config[]): GerritIntegrationConfig[];
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* A Gerrit based integration.
|
|
345
|
+
*
|
|
346
|
+
* @public
|
|
347
|
+
*/
|
|
348
|
+
declare class GerritIntegration implements ScmIntegration {
|
|
349
|
+
private readonly integrationConfig;
|
|
350
|
+
static factory: ScmIntegrationsFactory<GerritIntegration>;
|
|
351
|
+
constructor(integrationConfig: GerritIntegrationConfig);
|
|
352
|
+
get type(): string;
|
|
353
|
+
get title(): string;
|
|
354
|
+
get config(): GerritIntegrationConfig;
|
|
355
|
+
resolveUrl(options: {
|
|
356
|
+
url: string;
|
|
357
|
+
base: string;
|
|
358
|
+
lineNumber?: number;
|
|
359
|
+
}): string;
|
|
360
|
+
resolveEditUrl(url: string): string;
|
|
361
|
+
}
|
|
362
|
+
|
|
299
363
|
/**
|
|
300
364
|
* The configuration parameters for a single GitHub integration.
|
|
301
365
|
*
|
|
@@ -629,6 +693,7 @@ interface ScmIntegrationRegistry extends ScmIntegrationsGroup<ScmIntegration> {
|
|
|
629
693
|
awsS3: ScmIntegrationsGroup<AwsS3Integration>;
|
|
630
694
|
azure: ScmIntegrationsGroup<AzureIntegration>;
|
|
631
695
|
bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;
|
|
696
|
+
gerrit: ScmIntegrationsGroup<GerritIntegration>;
|
|
632
697
|
github: ScmIntegrationsGroup<GitHubIntegration>;
|
|
633
698
|
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
|
634
699
|
/**
|
|
@@ -833,6 +898,7 @@ interface IntegrationsByType {
|
|
|
833
898
|
awsS3: ScmIntegrationsGroup<AwsS3Integration>;
|
|
834
899
|
azure: ScmIntegrationsGroup<AzureIntegration>;
|
|
835
900
|
bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;
|
|
901
|
+
gerrit: ScmIntegrationsGroup<GerritIntegration>;
|
|
836
902
|
github: ScmIntegrationsGroup<GitHubIntegration>;
|
|
837
903
|
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
|
838
904
|
}
|
|
@@ -848,6 +914,7 @@ declare class ScmIntegrations implements ScmIntegrationRegistry {
|
|
|
848
914
|
get awsS3(): ScmIntegrationsGroup<AwsS3Integration>;
|
|
849
915
|
get azure(): ScmIntegrationsGroup<AzureIntegration>;
|
|
850
916
|
get bitbucket(): ScmIntegrationsGroup<BitbucketIntegration>;
|
|
917
|
+
get gerrit(): ScmIntegrationsGroup<GerritIntegration>;
|
|
851
918
|
get github(): ScmIntegrationsGroup<GitHubIntegration>;
|
|
852
919
|
get gitlab(): ScmIntegrationsGroup<GitLabIntegration>;
|
|
853
920
|
list(): ScmIntegration[];
|
|
@@ -861,4 +928,4 @@ declare class ScmIntegrations implements ScmIntegrationRegistry {
|
|
|
861
928
|
resolveEditUrl(url: string): string;
|
|
862
929
|
}
|
|
863
930
|
|
|
864
|
-
export { AwsS3Integration, AwsS3IntegrationConfig, AzureIntegration, AzureIntegrationConfig, BitbucketIntegration, BitbucketIntegrationConfig, DefaultGithubCredentialsProvider, GitHubIntegration, GitHubIntegrationConfig, GitLabIntegration, GitLabIntegrationConfig, GithubAppConfig, GithubAppCredentialsMux, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GoogleGcsIntegrationConfig, IntegrationsByType, ScmIntegration, ScmIntegrationRegistry, ScmIntegrations, ScmIntegrationsFactory, ScmIntegrationsGroup, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType };
|
|
931
|
+
export { AwsS3Integration, AwsS3IntegrationConfig, AzureIntegration, AzureIntegrationConfig, BitbucketIntegration, BitbucketIntegrationConfig, DefaultGithubCredentialsProvider, GerritIntegration, GerritIntegrationConfig, GitHubIntegration, GitHubIntegrationConfig, GitLabIntegration, GitLabIntegrationConfig, GithubAppConfig, GithubAppCredentialsMux, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GoogleGcsIntegrationConfig, IntegrationsByType, ScmIntegration, ScmIntegrationRegistry, ScmIntegrations, ScmIntegrationsFactory, ScmIntegrationsGroup, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType };
|
package/dist/index.esm.js
CHANGED
|
@@ -442,6 +442,69 @@ function getBitbucketRequestOptions(config) {
|
|
|
442
442
|
};
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
+
function readGerritIntegrationConfig(config) {
|
|
446
|
+
const host = config.getString("host");
|
|
447
|
+
let baseUrl = config.getOptionalString("baseUrl");
|
|
448
|
+
const username = config.getOptionalString("username");
|
|
449
|
+
const password = config.getOptionalString("password");
|
|
450
|
+
if (!isValidHost(host)) {
|
|
451
|
+
throw new Error(`Invalid Gerrit integration config, '${host}' is not a valid host`);
|
|
452
|
+
} else if (baseUrl && !isValidUrl(baseUrl)) {
|
|
453
|
+
throw new Error(`Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`);
|
|
454
|
+
}
|
|
455
|
+
if (baseUrl) {
|
|
456
|
+
baseUrl = trimEnd(baseUrl, "/");
|
|
457
|
+
} else {
|
|
458
|
+
baseUrl = `https://${host}`;
|
|
459
|
+
}
|
|
460
|
+
return {
|
|
461
|
+
host,
|
|
462
|
+
baseUrl,
|
|
463
|
+
username,
|
|
464
|
+
password
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function readGerritIntegrationConfigs(configs) {
|
|
468
|
+
return configs.map(readGerritIntegrationConfig);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const _GerritIntegration = class {
|
|
472
|
+
constructor(integrationConfig) {
|
|
473
|
+
this.integrationConfig = integrationConfig;
|
|
474
|
+
}
|
|
475
|
+
get type() {
|
|
476
|
+
return "gerrit";
|
|
477
|
+
}
|
|
478
|
+
get title() {
|
|
479
|
+
return this.integrationConfig.host;
|
|
480
|
+
}
|
|
481
|
+
get config() {
|
|
482
|
+
return this.integrationConfig;
|
|
483
|
+
}
|
|
484
|
+
resolveUrl(options) {
|
|
485
|
+
const { url, base, lineNumber } = options;
|
|
486
|
+
let updated;
|
|
487
|
+
if (url) {
|
|
488
|
+
updated = new URL(url, base);
|
|
489
|
+
} else {
|
|
490
|
+
updated = new URL(base);
|
|
491
|
+
}
|
|
492
|
+
if (lineNumber) {
|
|
493
|
+
updated.hash = lineNumber.toString();
|
|
494
|
+
}
|
|
495
|
+
return updated.toString();
|
|
496
|
+
}
|
|
497
|
+
resolveEditUrl(url) {
|
|
498
|
+
return url;
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
let GerritIntegration = _GerritIntegration;
|
|
502
|
+
GerritIntegration.factory = ({ config }) => {
|
|
503
|
+
var _a;
|
|
504
|
+
const configs = readGerritIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []);
|
|
505
|
+
return basicIntegrations(configs.map((c) => new _GerritIntegration(c)), (i) => i.config.host);
|
|
506
|
+
};
|
|
507
|
+
|
|
445
508
|
const GITHUB_HOST = "github.com";
|
|
446
509
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
447
510
|
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|
|
@@ -940,6 +1003,7 @@ class ScmIntegrations {
|
|
|
940
1003
|
awsS3: AwsS3Integration.factory({ config }),
|
|
941
1004
|
azure: AzureIntegration.factory({ config }),
|
|
942
1005
|
bitbucket: BitbucketIntegration.factory({ config }),
|
|
1006
|
+
gerrit: GerritIntegration.factory({ config }),
|
|
943
1007
|
github: GitHubIntegration.factory({ config }),
|
|
944
1008
|
gitlab: GitLabIntegration.factory({ config })
|
|
945
1009
|
});
|
|
@@ -956,6 +1020,9 @@ class ScmIntegrations {
|
|
|
956
1020
|
get bitbucket() {
|
|
957
1021
|
return this.byType.bitbucket;
|
|
958
1022
|
}
|
|
1023
|
+
get gerrit() {
|
|
1024
|
+
return this.byType.gerrit;
|
|
1025
|
+
}
|
|
959
1026
|
get github() {
|
|
960
1027
|
return this.byType.github;
|
|
961
1028
|
}
|
|
@@ -987,5 +1054,5 @@ class ScmIntegrations {
|
|
|
987
1054
|
}
|
|
988
1055
|
}
|
|
989
1056
|
|
|
990
|
-
export { AwsS3Integration, AzureIntegration, BitbucketIntegration, DefaultGithubCredentialsProvider, GitHubIntegration, GitLabIntegration, GithubAppCredentialsMux, ScmIntegrations, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType };
|
|
1057
|
+
export { AwsS3Integration, AzureIntegration, BitbucketIntegration, DefaultGithubCredentialsProvider, GerritIntegration, GitHubIntegration, GitLabIntegration, GithubAppCredentialsMux, ScmIntegrations, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType };
|
|
991
1058
|
//# sourceMappingURL=index.esm.js.map
|