@backstage/integration 1.21.0-next.0 → 2.0.0-next.2

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/config.d.ts +3 -60
  3. package/dist/ScmIntegrations.cjs.js +1 -17
  4. package/dist/ScmIntegrations.cjs.js.map +1 -1
  5. package/dist/ScmIntegrations.esm.js +1 -17
  6. package/dist/ScmIntegrations.esm.js.map +1 -1
  7. package/dist/azure/config.cjs.js +14 -35
  8. package/dist/azure/config.cjs.js.map +1 -1
  9. package/dist/azure/config.esm.js +14 -35
  10. package/dist/azure/config.esm.js.map +1 -1
  11. package/dist/bitbucketCloud/core.cjs.js +3 -2
  12. package/dist/bitbucketCloud/core.cjs.js.map +1 -1
  13. package/dist/bitbucketCloud/core.esm.js +3 -2
  14. package/dist/bitbucketCloud/core.esm.js.map +1 -1
  15. package/dist/bitbucketServer/core.cjs.js +8 -2
  16. package/dist/bitbucketServer/core.cjs.js.map +1 -1
  17. package/dist/bitbucketServer/core.esm.js +8 -2
  18. package/dist/bitbucketServer/core.esm.js.map +1 -1
  19. package/dist/gerrit/core.cjs.js +6 -33
  20. package/dist/gerrit/core.cjs.js.map +1 -1
  21. package/dist/gerrit/core.esm.js +7 -32
  22. package/dist/gerrit/core.esm.js.map +1 -1
  23. package/dist/github/core.cjs.js +2 -17
  24. package/dist/github/core.cjs.js.map +1 -1
  25. package/dist/github/core.esm.js +3 -13
  26. package/dist/github/core.esm.js.map +1 -1
  27. package/dist/helpers.cjs.js +23 -1
  28. package/dist/helpers.cjs.js.map +1 -1
  29. package/dist/helpers.esm.js +23 -2
  30. package/dist/helpers.esm.js.map +1 -1
  31. package/dist/index.cjs.js +61 -76
  32. package/dist/index.cjs.js.map +1 -1
  33. package/dist/index.d.ts +2 -222
  34. package/dist/index.esm.js +2 -6
  35. package/dist/index.esm.js.map +1 -1
  36. package/package.json +2 -2
  37. package/dist/azure/deprecated.cjs.js +0 -26
  38. package/dist/azure/deprecated.cjs.js.map +0 -1
  39. package/dist/azure/deprecated.esm.js +0 -24
  40. package/dist/azure/deprecated.esm.js.map +0 -1
  41. package/dist/bitbucket/BitbucketIntegration.cjs.js +0 -65
  42. package/dist/bitbucket/BitbucketIntegration.cjs.js.map +0 -1
  43. package/dist/bitbucket/BitbucketIntegration.esm.js +0 -59
  44. package/dist/bitbucket/BitbucketIntegration.esm.js.map +0 -1
  45. package/dist/bitbucket/config.cjs.js +0 -48
  46. package/dist/bitbucket/config.cjs.js.map +0 -1
  47. package/dist/bitbucket/config.esm.js +0 -45
  48. package/dist/bitbucket/config.esm.js.map +0 -1
  49. package/dist/bitbucket/core.cjs.js +0 -95
  50. package/dist/bitbucket/core.cjs.js.map +0 -1
  51. package/dist/bitbucket/core.esm.js +0 -85
  52. package/dist/bitbucket/core.esm.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -351,22 +351,6 @@ type AzureIntegrationConfig = {
351
351
  * Currently only "dev.azure.com" is supported.
352
352
  */
353
353
  host: string;
354
- /**
355
- * The authorization token to use for requests.
356
- *
357
- * If no token is specified, anonymous access is used.
358
- *
359
- * @deprecated Use `credentials` instead.
360
- */
361
- token?: string;
362
- /**
363
- * The credential to use for requests.
364
- *
365
- * If no credential is specified anonymous access is used.
366
- *
367
- * @deprecated Use `credentials` instead.
368
- */
369
- credential?: AzureDevOpsCredential;
370
354
  /**
371
355
  * The credentials to use for requests. If multiple credentials are specified the first one that matches the organization is used.
372
356
  * If not organization matches the first credential without an organization is used.
@@ -584,87 +568,6 @@ declare class BitbucketCloudIntegration implements ScmIntegration {
584
568
  resolveEditUrl(url: string): string;
585
569
  }
586
570
 
587
- /**
588
- * The configuration parameters for a single Bitbucket API provider.
589
- *
590
- * @public
591
- * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.
592
- */
593
- type BitbucketIntegrationConfig = {
594
- /**
595
- * The host of the target that this matches on, e.g. "bitbucket.org"
596
- */
597
- host: string;
598
- /**
599
- * The base URL of the API of this provider, e.g. "https://api.bitbucket.org/2.0",
600
- * with no trailing slash.
601
- *
602
- * Values omitted at the optional property at the app-config will be deduced
603
- * from the "host" value.
604
- */
605
- apiBaseUrl: string;
606
- /**
607
- * The authorization token to use for requests to a Bitbucket Server provider.
608
- *
609
- * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html
610
- *
611
- * If no token is specified, anonymous access is used.
612
- */
613
- token?: string;
614
- /**
615
- * The username to use for requests to Bitbucket Cloud (bitbucket.org).
616
- */
617
- username?: string;
618
- /**
619
- * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.
620
- *
621
- * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/
622
- */
623
- appPassword?: string;
624
- /**
625
- * Signing key for commits
626
- */
627
- commitSigningKey?: string;
628
- };
629
- /**
630
- * Reads a single Bitbucket integration config.
631
- *
632
- * @param config - The config object of a single integration
633
- * @public
634
- * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.
635
- */
636
- declare function readBitbucketIntegrationConfig(config: Config): BitbucketIntegrationConfig;
637
- /**
638
- * Reads a set of Bitbucket integration configs, and inserts some defaults for
639
- * public Bitbucket if not specified.
640
- *
641
- * @param configs - All of the integration config objects
642
- * @public
643
- * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.
644
- */
645
- declare function readBitbucketIntegrationConfigs(configs: Config[]): BitbucketIntegrationConfig[];
646
-
647
- /**
648
- * A Bitbucket based integration.
649
- *
650
- * @public
651
- * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.
652
- */
653
- declare class BitbucketIntegration implements ScmIntegration {
654
- private readonly integrationConfig;
655
- static factory: ScmIntegrationsFactory<BitbucketIntegration>;
656
- constructor(integrationConfig: BitbucketIntegrationConfig);
657
- get type(): string;
658
- get title(): string;
659
- get config(): BitbucketIntegrationConfig;
660
- resolveUrl(options: {
661
- url: string;
662
- base: string;
663
- lineNumber?: number;
664
- }): string;
665
- resolveEditUrl(url: string): string;
666
- }
667
-
668
571
  /**
669
572
  * The configuration parameters for a single Bitbucket Server API provider.
670
573
  *
@@ -1185,10 +1088,6 @@ interface ScmIntegrationRegistry extends ScmIntegrationsGroup<ScmIntegration> {
1185
1088
  awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;
1186
1089
  azureBlobStorage: ScmIntegrationsGroup<AzureBlobStorageIntergation>;
1187
1090
  azure: ScmIntegrationsGroup<AzureIntegration>;
1188
- /**
1189
- * @deprecated in favor of `bitbucketCloud` and `bitbucketServer`
1190
- */
1191
- bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;
1192
1091
  bitbucketCloud: ScmIntegrationsGroup<BitbucketCloudIntegration>;
1193
1092
  bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;
1194
1093
  gerrit: ScmIntegrationsGroup<GerritIntegration>;
@@ -1328,64 +1227,6 @@ declare class DefaultAzureDevOpsCredentialsProvider implements AzureDevOpsCreden
1328
1227
  }): Promise<AzureDevOpsCredentials | undefined>;
1329
1228
  }
1330
1229
 
1331
- /**
1332
- * Gets the request options necessary to make requests to a given provider.
1333
- *
1334
- * @param config - The relevant provider config
1335
- * @param additionalHeaders - Additional headers for the request
1336
- * @public
1337
- * @deprecated Use {@link AzureDevOpsCredentialsProvider} instead.
1338
- */
1339
- declare function getAzureRequestOptions(config: AzureIntegrationConfig, additionalHeaders?: Record<string, string>): Promise<{
1340
- headers: Record<string, string>;
1341
- }>;
1342
-
1343
- /**
1344
- * Given a URL pointing to a path on a provider, returns the default branch.
1345
- *
1346
- * @param url - A URL pointing to a path
1347
- * @param config - The relevant provider config
1348
- * @public
1349
- * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.
1350
- */
1351
- declare function getBitbucketDefaultBranch(url: string, config: BitbucketIntegrationConfig): Promise<string>;
1352
- /**
1353
- * Given a URL pointing to a path on a provider, returns a URL that is suitable
1354
- * for downloading the subtree.
1355
- *
1356
- * @param url - A URL pointing to a path
1357
- * @param config - The relevant provider config
1358
- * @public
1359
- * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.
1360
- */
1361
- declare function getBitbucketDownloadUrl(url: string, config: BitbucketIntegrationConfig): Promise<string>;
1362
- /**
1363
- * Given a URL pointing to a file on a provider, returns a URL that is suitable
1364
- * for fetching the contents of the data.
1365
- *
1366
- * @remarks
1367
- *
1368
- * Converts
1369
- * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml
1370
- * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml
1371
- *
1372
- * @param url - A URL pointing to a file
1373
- * @param config - The relevant provider config
1374
- * @public
1375
- * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.
1376
- */
1377
- declare function getBitbucketFileFetchUrl(url: string, config: BitbucketIntegrationConfig): string;
1378
- /**
1379
- * Gets the request options necessary to make requests to a given provider.
1380
- *
1381
- * @param config - The relevant provider config
1382
- * @public
1383
- * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.
1384
- */
1385
- declare function getBitbucketRequestOptions(config: BitbucketIntegrationConfig): {
1386
- headers: Record<string, string>;
1387
- };
1388
-
1389
1230
  /**
1390
1231
  * Fetches an OAuth access token from Bitbucket Cloud using client credentials flow.
1391
1232
  * Tokens are cached with a 10-minute grace period to account for clock skew.
@@ -1482,37 +1323,6 @@ declare function getBitbucketServerRequestOptions(config: BitbucketServerIntegra
1482
1323
  headers: Record<string, string>;
1483
1324
  };
1484
1325
 
1485
- /**
1486
- * Parse a Gitiles URL and return branch, file path and project.
1487
- *
1488
- * @remarks
1489
- *
1490
- * Gerrit only handles code reviews so it does not have a native way to browse
1491
- * or showing the content of gits. Image if Github only had the "pull requests"
1492
- * tab.
1493
- *
1494
- * Any source code browsing is instead handled by optional services outside
1495
- * Gerrit. The url format chosen for the Gerrit url reader is the one used by
1496
- * the Gitiles project. Gerrit will work perfectly with Backstage without
1497
- * having Gitiles installed but there are some places in the Backstage GUI
1498
- * with links to the url used by the url reader. These will not work unless
1499
- * the urls point to an actual Gitiles installation.
1500
- *
1501
- * Gitiles url:
1502
- * https://g.com/optional_path/\{project\}/+/refs/heads/\{branch\}/\{filePath\}
1503
- * https://g.com/a/optional_path/\{project\}/+/refs/heads/\{branch\}/\{filePath\}
1504
- *
1505
- *
1506
- * @param url - An URL pointing to a file stored in git.
1507
- * @public
1508
- * @deprecated `parseGerritGitilesUrl` is deprecated. Use
1509
- * {@link parseGitilesUrlRef} instead.
1510
- */
1511
- declare function parseGerritGitilesUrl(config: GerritIntegrationConfig, url: string): {
1512
- branch: string;
1513
- filePath: string;
1514
- project: string;
1515
- };
1516
1326
  /**
1517
1327
  * Parses Gitiles urls and returns the following:
1518
1328
  *
@@ -1539,18 +1349,6 @@ declare function parseGitilesUrlRef(config: GerritIntegrationConfig, url: string
1539
1349
  refType: 'sha' | 'branch' | 'tag' | 'head';
1540
1350
  basePath: string;
1541
1351
  };
1542
- /**
1543
- * Build a Gerrit Gitiles archive url that targets a specific branch and path
1544
- *
1545
- * @param config - A Gerrit provider config.
1546
- * @param project - The name of the git project
1547
- * @param branch - The branch we will target.
1548
- * @param filePath - The absolute file path.
1549
- * @public
1550
- * @deprecated `buildGerritGitilesArchiveUrl` is deprecated. Use
1551
- * {@link buildGerritGitilesArchiveUrlFromLocation} instead.
1552
- */
1553
- declare function buildGerritGitilesArchiveUrl(config: GerritIntegrationConfig, project: string, branch: string, filePath: string): string;
1554
1352
  /**
1555
1353
  * Build a Gerrit Gitiles archive url from a Gitiles url.
1556
1354
  *
@@ -1755,16 +1553,6 @@ interface GithubCredentialsProvider {
1755
1553
  * @public
1756
1554
  */
1757
1555
  declare function getGithubFileFetchUrl(url: string, config: GithubIntegrationConfig, credentials: GithubCredentials): string;
1758
- /**
1759
- * Gets the request options necessary to make requests to a given provider.
1760
- *
1761
- * @deprecated This function is no longer used internally
1762
- * @param config - The relevant provider config
1763
- * @public
1764
- */
1765
- declare function getGitHubRequestOptions(config: GithubIntegrationConfig, credentials: GithubCredentials): {
1766
- headers: Record<string, string>;
1767
- };
1768
1556
 
1769
1557
  /**
1770
1558
  * Handles the creation and caching of credentials for GitHub integrations.
@@ -2060,10 +1848,6 @@ interface IntegrationsByType {
2060
1848
  awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;
2061
1849
  azureBlobStorage: ScmIntegrationsGroup<AzureBlobStorageIntergation>;
2062
1850
  azure: ScmIntegrationsGroup<AzureIntegration>;
2063
- /**
2064
- * @deprecated in favor of `bitbucketCloud` and `bitbucketServer`
2065
- */
2066
- bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;
2067
1851
  bitbucketCloud: ScmIntegrationsGroup<BitbucketCloudIntegration>;
2068
1852
  bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;
2069
1853
  gerrit: ScmIntegrationsGroup<GerritIntegration>;
@@ -2086,10 +1870,6 @@ declare class ScmIntegrations implements ScmIntegrationRegistry {
2086
1870
  get awsCodeCommit(): ScmIntegrationsGroup<AwsCodeCommitIntegration>;
2087
1871
  get azureBlobStorage(): ScmIntegrationsGroup<AzureBlobStorageIntergation>;
2088
1872
  get azure(): ScmIntegrationsGroup<AzureIntegration>;
2089
- /**
2090
- * @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`
2091
- */
2092
- get bitbucket(): ScmIntegrationsGroup<BitbucketIntegration>;
2093
1873
  get bitbucketCloud(): ScmIntegrationsGroup<BitbucketCloudIntegration>;
2094
1874
  get bitbucketServer(): ScmIntegrationsGroup<BitbucketServerIntegration>;
2095
1875
  get gerrit(): ScmIntegrationsGroup<GerritIntegration>;
@@ -2109,5 +1889,5 @@ declare class ScmIntegrations implements ScmIntegrationRegistry {
2109
1889
  resolveEditUrl(url: string): string;
2110
1890
  }
2111
1891
 
2112
- export { AwsCodeCommitIntegration, AwsS3Integration, AzureBlobStorageIntergation, AzureIntegration, BitbucketCloudIntegration, BitbucketIntegration, BitbucketServerIntegration, DefaultAzureCredentialsManager, DefaultAzureDevOpsCredentialsProvider, DefaultGithubCredentialsProvider, DefaultGitlabCredentialsProvider, GerritIntegration, GitLabIntegration, GiteaIntegration, GithubAppCredentialsMux, GithubIntegration, GoogleGcsIntegration, HarnessIntegration, ScmIntegrations, SingleInstanceGithubCredentialsProvider, buildGerritGitilesArchiveUrl, buildGerritGitilesArchiveUrlFromLocation, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudOAuthToken, getBitbucketCloudRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabIntegrationRelativePath, getGitLabRequestOptions, getGiteaArchiveUrl, getGiteaEditContentsUrl, getGiteaFileContentsUrl, getGiteaLatestCommitUrl, getGiteaRequestOptions, getGithubFileFetchUrl, getGitilesAuthenticationUrl, getHarnessArchiveUrl, getHarnessFileContentsUrl, getHarnessLatestCommitUrl, getHarnessRequestOptions, parseGerritGitilesUrl, parseGerritJsonResponse, parseGiteaUrl, parseGitilesUrlRef, parseHarnessUrl, readAwsCodeCommitIntegrationConfig, readAwsCodeCommitIntegrationConfigs, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureBlobStorageIntegrationConfig, readAzureBlobStorageIntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGiteaConfig, readGithubIntegrationConfig, readGithubIntegrationConfigs, readGoogleGcsIntegrationConfig, readHarnessConfig, replaceGitLabUrlType, replaceGithubUrlType };
2113
- export type { AwsCodeCommitIntegrationConfig, AwsS3IntegrationConfig, AzureBlobStorageIntegrationConfig, AzureClientSecretCredential, AzureCredentialBase, AzureCredentialsManager, AzureDevOpsCredential, AzureDevOpsCredentialKind, AzureDevOpsCredentialLike, AzureDevOpsCredentialType, AzureDevOpsCredentials, AzureDevOpsCredentialsProvider, AzureIntegrationConfig, AzureManagedIdentityClientAssertionCredential, AzureManagedIdentityCredential, BitbucketCloudIntegrationConfig, BitbucketIntegrationConfig, BitbucketServerIntegrationConfig, GerritIntegrationConfig, GitLabIntegrationConfig, GiteaIntegrationConfig, GithubAppConfig, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GithubIntegrationConfig, GitlabCredentials, GitlabCredentialsProvider, GoogleGcsIntegrationConfig, HarnessIntegrationConfig, IntegrationsByType, PersonalAccessTokenCredential, RateLimitInfo, ScmIntegration, ScmIntegrationRegistry, ScmIntegrationsFactory, ScmIntegrationsGroup };
1892
+ export { AwsCodeCommitIntegration, AwsS3Integration, AzureBlobStorageIntergation, AzureIntegration, BitbucketCloudIntegration, BitbucketServerIntegration, DefaultAzureCredentialsManager, DefaultAzureDevOpsCredentialsProvider, DefaultGithubCredentialsProvider, DefaultGitlabCredentialsProvider, GerritIntegration, GitLabIntegration, GiteaIntegration, GithubAppCredentialsMux, GithubIntegration, GoogleGcsIntegration, HarnessIntegration, ScmIntegrations, SingleInstanceGithubCredentialsProvider, buildGerritGitilesArchiveUrlFromLocation, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudOAuthToken, getBitbucketCloudRequestOptions, getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitLabFileFetchUrl, getGitLabIntegrationRelativePath, getGitLabRequestOptions, getGiteaArchiveUrl, getGiteaEditContentsUrl, getGiteaFileContentsUrl, getGiteaLatestCommitUrl, getGiteaRequestOptions, getGithubFileFetchUrl, getGitilesAuthenticationUrl, getHarnessArchiveUrl, getHarnessFileContentsUrl, getHarnessLatestCommitUrl, getHarnessRequestOptions, parseGerritJsonResponse, parseGiteaUrl, parseGitilesUrlRef, parseHarnessUrl, readAwsCodeCommitIntegrationConfig, readAwsCodeCommitIntegrationConfigs, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureBlobStorageIntegrationConfig, readAzureBlobStorageIntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGiteaConfig, readGithubIntegrationConfig, readGithubIntegrationConfigs, readGoogleGcsIntegrationConfig, readHarnessConfig, replaceGitLabUrlType, replaceGithubUrlType };
1893
+ export type { AwsCodeCommitIntegrationConfig, AwsS3IntegrationConfig, AzureBlobStorageIntegrationConfig, AzureClientSecretCredential, AzureCredentialBase, AzureCredentialsManager, AzureDevOpsCredential, AzureDevOpsCredentialKind, AzureDevOpsCredentialLike, AzureDevOpsCredentialType, AzureDevOpsCredentials, AzureDevOpsCredentialsProvider, AzureIntegrationConfig, AzureManagedIdentityClientAssertionCredential, AzureManagedIdentityCredential, BitbucketCloudIntegrationConfig, BitbucketServerIntegrationConfig, GerritIntegrationConfig, GitLabIntegrationConfig, GiteaIntegrationConfig, GithubAppConfig, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GithubIntegrationConfig, GitlabCredentials, GitlabCredentialsProvider, GoogleGcsIntegrationConfig, HarnessIntegrationConfig, IntegrationsByType, PersonalAccessTokenCredential, RateLimitInfo, ScmIntegration, ScmIntegrationRegistry, ScmIntegrationsFactory, ScmIntegrationsGroup };
package/dist/index.esm.js CHANGED
@@ -9,10 +9,6 @@ export { AzureIntegration } from './azure/AzureIntegration.esm.js';
9
9
  export { readAzureIntegrationConfig, readAzureIntegrationConfigs } from './azure/config.esm.js';
10
10
  export { getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl } from './azure/core.esm.js';
11
11
  export { DefaultAzureDevOpsCredentialsProvider } from './azure/DefaultAzureDevOpsCredentialsProvider.esm.js';
12
- export { getAzureRequestOptions } from './azure/deprecated.esm.js';
13
- export { BitbucketIntegration } from './bitbucket/BitbucketIntegration.esm.js';
14
- export { readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs } from './bitbucket/config.esm.js';
15
- export { getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions } from './bitbucket/core.esm.js';
16
12
  export { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegration.esm.js';
17
13
  export { readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs } from './bitbucketCloud/config.esm.js';
18
14
  export { getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudOAuthToken, getBitbucketCloudRequestOptions } from './bitbucketCloud/core.esm.js';
@@ -21,12 +17,12 @@ export { readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationCon
21
17
  export { getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions } from './bitbucketServer/core.esm.js';
22
18
  export { GerritIntegration } from './gerrit/GerritIntegration.esm.js';
23
19
  export { readGerritIntegrationConfig, readGerritIntegrationConfigs } from './gerrit/config.esm.js';
24
- export { buildGerritGitilesArchiveUrl, buildGerritGitilesArchiveUrlFromLocation, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitilesAuthenticationUrl, parseGerritGitilesUrl, parseGerritJsonResponse, parseGitilesUrlRef } from './gerrit/core.esm.js';
20
+ export { buildGerritGitilesArchiveUrlFromLocation, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitilesAuthenticationUrl, parseGerritJsonResponse, parseGitilesUrlRef } from './gerrit/core.esm.js';
25
21
  export { GiteaIntegration } from './gitea/GiteaIntegration.esm.js';
26
22
  export { getGiteaArchiveUrl, getGiteaEditContentsUrl, getGiteaFileContentsUrl, getGiteaLatestCommitUrl, getGiteaRequestOptions, parseGiteaUrl } from './gitea/core.esm.js';
27
23
  export { readGiteaConfig } from './gitea/config.esm.js';
28
24
  export { readGithubIntegrationConfig, readGithubIntegrationConfigs } from './github/config.esm.js';
29
- export { getGitHubRequestOptions, getGithubFileFetchUrl } from './github/core.esm.js';
25
+ export { getGithubFileFetchUrl } from './github/core.esm.js';
30
26
  export { DefaultGithubCredentialsProvider } from './github/DefaultGithubCredentialsProvider.esm.js';
31
27
  export { GithubAppCredentialsMux, SingleInstanceGithubCredentialsProvider } from './github/SingleInstanceGithubCredentialsProvider.esm.js';
32
28
  export { GithubIntegration, replaceGithubUrlType } from './github/GithubIntegration.esm.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/integration",
3
- "version": "1.21.0-next.0",
3
+ "version": "2.0.0-next.2",
4
4
  "description": "Helpers for managing integrations towards external systems",
5
5
  "backstage": {
6
6
  "role": "common-library"
@@ -50,7 +50,7 @@
50
50
  "p-throttle": "^4.1.1"
51
51
  },
52
52
  "devDependencies": {
53
- "@backstage/cli": "0.35.5-next.0",
53
+ "@backstage/cli": "0.36.0-next.2",
54
54
  "@backstage/config-loader": "1.10.9-next.0",
55
55
  "msw": "^1.0.0"
56
56
  },
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- var CachedAzureDevOpsCredentialsProvider = require('./CachedAzureDevOpsCredentialsProvider.cjs.js');
4
-
5
- async function getAzureRequestOptions(config, additionalHeaders) {
6
- const headers = additionalHeaders ? { ...additionalHeaders } : {};
7
- const credentialConfig = config.credentials?.filter(
8
- (credential) => credential.organizations === void 0 || credential.organizations.length === 0
9
- )[0];
10
- if (credentialConfig) {
11
- const credentialsProvider = CachedAzureDevOpsCredentialsProvider.CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(
12
- credentialConfig
13
- );
14
- const credentials = await credentialsProvider.getCredentials();
15
- return {
16
- headers: {
17
- ...credentials?.headers,
18
- ...headers
19
- }
20
- };
21
- }
22
- return { headers };
23
- }
24
-
25
- exports.getAzureRequestOptions = getAzureRequestOptions;
26
- //# sourceMappingURL=deprecated.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deprecated.cjs.js","sources":["../../src/azure/deprecated.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { AzureIntegrationConfig } from './config';\nimport { CachedAzureDevOpsCredentialsProvider } from './CachedAzureDevOpsCredentialsProvider';\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @param additionalHeaders - Additional headers for the request\n * @public\n * @deprecated Use {@link AzureDevOpsCredentialsProvider} instead.\n */\nexport async function getAzureRequestOptions(\n config: AzureIntegrationConfig,\n additionalHeaders?: Record<string, string>,\n): Promise<{ headers: Record<string, string> }> {\n const headers: Record<string, string> = additionalHeaders\n ? { ...additionalHeaders }\n : {};\n\n /*\n * Since we do not have a way to determine which organization the request is for,\n * we will use the first credential that does not have an organization specified.\n */\n const credentialConfig = config.credentials?.filter(\n credential =>\n credential.organizations === undefined ||\n credential.organizations.length === 0,\n )[0];\n\n if (credentialConfig) {\n const credentialsProvider =\n CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(\n credentialConfig,\n );\n const credentials = await credentialsProvider.getCredentials();\n\n return {\n headers: {\n ...credentials?.headers,\n ...headers,\n },\n };\n }\n\n return { headers };\n}\n"],"names":["CachedAzureDevOpsCredentialsProvider"],"mappings":";;;;AA0BA,eAAsB,sBAAA,CACpB,QACA,iBAAA,EAC8C;AAC9C,EAAA,MAAM,UAAkC,iBAAA,GACpC,EAAE,GAAG,iBAAA,KACL,EAAC;AAML,EAAA,MAAM,gBAAA,GAAmB,OAAO,WAAA,EAAa,MAAA;AAAA,IAC3C,gBACE,UAAA,CAAW,aAAA,KAAkB,MAAA,IAC7B,UAAA,CAAW,cAAc,MAAA,KAAW;AAAA,IACtC,CAAC,CAAA;AAEH,EAAA,IAAI,gBAAA,EAAkB;AACpB,IAAA,MAAM,sBACJA,yEAAA,CAAqC,yBAAA;AAAA,MACnC;AAAA,KACF;AACF,IAAA,MAAM,WAAA,GAAc,MAAM,mBAAA,CAAoB,cAAA,EAAe;AAE7D,IAAA,OAAO;AAAA,MACL,OAAA,EAAS;AAAA,QACP,GAAG,WAAA,EAAa,OAAA;AAAA,QAChB,GAAG;AAAA;AACL,KACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,OAAA,EAAQ;AACnB;;;;"}
@@ -1,24 +0,0 @@
1
- import { CachedAzureDevOpsCredentialsProvider } from './CachedAzureDevOpsCredentialsProvider.esm.js';
2
-
3
- async function getAzureRequestOptions(config, additionalHeaders) {
4
- const headers = additionalHeaders ? { ...additionalHeaders } : {};
5
- const credentialConfig = config.credentials?.filter(
6
- (credential) => credential.organizations === void 0 || credential.organizations.length === 0
7
- )[0];
8
- if (credentialConfig) {
9
- const credentialsProvider = CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(
10
- credentialConfig
11
- );
12
- const credentials = await credentialsProvider.getCredentials();
13
- return {
14
- headers: {
15
- ...credentials?.headers,
16
- ...headers
17
- }
18
- };
19
- }
20
- return { headers };
21
- }
22
-
23
- export { getAzureRequestOptions };
24
- //# sourceMappingURL=deprecated.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deprecated.esm.js","sources":["../../src/azure/deprecated.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { AzureIntegrationConfig } from './config';\nimport { CachedAzureDevOpsCredentialsProvider } from './CachedAzureDevOpsCredentialsProvider';\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @param additionalHeaders - Additional headers for the request\n * @public\n * @deprecated Use {@link AzureDevOpsCredentialsProvider} instead.\n */\nexport async function getAzureRequestOptions(\n config: AzureIntegrationConfig,\n additionalHeaders?: Record<string, string>,\n): Promise<{ headers: Record<string, string> }> {\n const headers: Record<string, string> = additionalHeaders\n ? { ...additionalHeaders }\n : {};\n\n /*\n * Since we do not have a way to determine which organization the request is for,\n * we will use the first credential that does not have an organization specified.\n */\n const credentialConfig = config.credentials?.filter(\n credential =>\n credential.organizations === undefined ||\n credential.organizations.length === 0,\n )[0];\n\n if (credentialConfig) {\n const credentialsProvider =\n CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(\n credentialConfig,\n );\n const credentials = await credentialsProvider.getCredentials();\n\n return {\n headers: {\n ...credentials?.headers,\n ...headers,\n },\n };\n }\n\n return { headers };\n}\n"],"names":[],"mappings":";;AA0BA,eAAsB,sBAAA,CACpB,QACA,iBAAA,EAC8C;AAC9C,EAAA,MAAM,UAAkC,iBAAA,GACpC,EAAE,GAAG,iBAAA,KACL,EAAC;AAML,EAAA,MAAM,gBAAA,GAAmB,OAAO,WAAA,EAAa,MAAA;AAAA,IAC3C,gBACE,UAAA,CAAW,aAAA,KAAkB,MAAA,IAC7B,UAAA,CAAW,cAAc,MAAA,KAAW;AAAA,IACtC,CAAC,CAAA;AAEH,EAAA,IAAI,gBAAA,EAAkB;AACpB,IAAA,MAAM,sBACJ,oCAAA,CAAqC,yBAAA;AAAA,MACnC;AAAA,KACF;AACF,IAAA,MAAM,WAAA,GAAc,MAAM,mBAAA,CAAoB,cAAA,EAAe;AAE7D,IAAA,OAAO;AAAA,MACL,OAAA,EAAS;AAAA,QACP,GAAG,WAAA,EAAa,OAAA;AAAA,QAChB,GAAG;AAAA;AACL,KACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,OAAA,EAAQ;AACnB;;;;"}
@@ -1,65 +0,0 @@
1
- 'use strict';
2
-
3
- var parseGitUrl = require('git-url-parse');
4
- var helpers = require('../helpers.cjs.js');
5
- var config = require('./config.cjs.js');
6
-
7
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
8
-
9
- var parseGitUrl__default = /*#__PURE__*/_interopDefaultCompat(parseGitUrl);
10
-
11
- class BitbucketIntegration {
12
- constructor(integrationConfig) {
13
- this.integrationConfig = integrationConfig;
14
- }
15
- static factory = ({
16
- config: config$1
17
- }) => {
18
- const configs = config.readBitbucketIntegrationConfigs(
19
- config$1.getOptionalConfigArray("integrations.bitbucket") ?? [
20
- // if integrations.bitbucket was not used assume the use was migrated to the new configs
21
- // and backport for the deprecated integration to be usable for other parts of the system
22
- // until these got migrated
23
- ...config$1.getOptionalConfigArray("integrations.bitbucketCloud") ?? [],
24
- ...config$1.getOptionalConfigArray("integrations.bitbucketServer") ?? []
25
- ]
26
- );
27
- return helpers.basicIntegrations(
28
- configs.map((c) => new BitbucketIntegration(c)),
29
- (i) => i.config.host
30
- );
31
- };
32
- get type() {
33
- return "bitbucket";
34
- }
35
- get title() {
36
- return this.integrationConfig.host;
37
- }
38
- get config() {
39
- return this.integrationConfig;
40
- }
41
- resolveUrl(options) {
42
- const resolved = helpers.defaultScmResolveUrl(options);
43
- if (!options.lineNumber) {
44
- return resolved;
45
- }
46
- const url = new URL(resolved);
47
- if (this.integrationConfig.host === "bitbucket.org") {
48
- url.hash = `lines-${options.lineNumber}`;
49
- } else {
50
- url.hash = `${options.lineNumber}`;
51
- }
52
- return url.toString();
53
- }
54
- resolveEditUrl(url) {
55
- const urlData = parseGitUrl__default.default(url);
56
- const editUrl = new URL(url);
57
- editUrl.searchParams.set("mode", "edit");
58
- editUrl.searchParams.set("spa", "0");
59
- editUrl.searchParams.set("at", urlData.ref);
60
- return editUrl.toString();
61
- }
62
- }
63
-
64
- exports.BitbucketIntegration = BitbucketIntegration;
65
- //# sourceMappingURL=BitbucketIntegration.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BitbucketIntegration.cjs.js","sources":["../../src/bitbucket/BitbucketIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketIntegrationConfig,\n readBitbucketIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket based integration.\n *\n * @public\n * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.\n */\nexport class BitbucketIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucket') ?? [\n // if integrations.bitbucket was not used assume the use was migrated to the new configs\n // and backport for the deprecated integration to be usable for other parts of the system\n // until these got migrated\n ...(config.getOptionalConfigArray('integrations.bitbucketCloud') ?? []),\n ...(config.getOptionalConfigArray('integrations.bitbucketServer') ??\n []),\n ],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: BitbucketIntegrationConfig) {}\n\n get type(): string {\n return 'bitbucket';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n if (!options.lineNumber) {\n return resolved;\n }\n\n const url = new URL(resolved);\n\n if (this.integrationConfig.host === 'bitbucket.org') {\n // Bitbucket Cloud uses the syntax #lines-{start}[:{end}][,...]\n url.hash = `lines-${options.lineNumber}`;\n } else {\n // Bitbucket Server uses the syntax #{start}[-{end}][,...]\n url.hash = `${options.lineNumber}`;\n }\n\n return url.toString();\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n // TODO: Not sure what spa=0 does, at least bitbucket.org doesn't support it\n // but this is taken over from the initial implementation.\n editUrl.searchParams.set('spa', '0');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":["config","readBitbucketIntegrationConfigs","basicIntegrations","defaultScmResolveUrl","parseGitUrl"],"mappings":";;;;;;;;;;AA8BO,MAAM,oBAAA,CAA+C;AAAA,EAoB1D,YAA6B,iBAAA,EAA+C;AAA/C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAAgD;AAAA,EAnB7E,OAAO,UAAwD,CAAC;AAAA,YAC9DA;AAAA,GACF,KAAM;AACJ,IAAA,MAAM,OAAA,GAAUC,sCAAA;AAAA,MACdD,QAAA,CAAO,sBAAA,CAAuB,wBAAwB,CAAA,IAAK;AAAA;AAAA;AAAA;AAAA,QAIzD,GAAIA,QAAA,CAAO,sBAAA,CAAuB,6BAA6B,KAAK,EAAC;AAAA,QACrE,GAAIA,QAAA,CAAO,sBAAA,CAAuB,8BAA8B,KAC9D;AAAC;AACL,KACF;AACA,IAAA,OAAOE,yBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,oBAAA,CAAqB,CAAC,CAAC,CAAA;AAAA,MAC5C,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAAA,EACF,CAAA;AAAA,EAIA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,WAAA;AAAA,EACT;AAAA,EAEA,IAAI,KAAA,GAAgB;AAClB,IAAA,OAAO,KAAK,iBAAA,CAAkB,IAAA;AAAA,EAChC;AAAA,EAEA,IAAI,MAAA,GAAqC;AACvC,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EACd;AAAA,EAEA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,QAAA,GAAWC,6BAAqB,OAAO,CAAA;AAC7C,IAAA,IAAI,CAAC,QAAQ,UAAA,EAAY;AACvB,MAAA,OAAO,QAAA;AAAA,IACT;AAEA,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAE5B,IAAA,IAAI,IAAA,CAAK,iBAAA,CAAkB,IAAA,KAAS,eAAA,EAAiB;AAEnD,MAAA,GAAA,CAAI,IAAA,GAAO,CAAA,MAAA,EAAS,OAAA,CAAQ,UAAU,CAAA,CAAA;AAAA,IACxC,CAAA,MAAO;AAEL,MAAA,GAAA,CAAI,IAAA,GAAO,CAAA,EAAG,OAAA,CAAQ,UAAU,CAAA,CAAA;AAAA,IAClC;AAEA,IAAA,OAAO,IAAI,QAAA,EAAS;AAAA,EACtB;AAAA,EAEA,eAAe,GAAA,EAAqB;AAClC,IAAA,MAAM,OAAA,GAAUC,6BAAY,GAAG,CAAA;AAC/B,IAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAM,CAAA;AAGvC,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA;AACnC,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,IAAA,EAAM,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAA,EAAS;AAAA,EAC1B;AACF;;;;"}
@@ -1,59 +0,0 @@
1
- import parseGitUrl from 'git-url-parse';
2
- import { basicIntegrations, defaultScmResolveUrl } from '../helpers.esm.js';
3
- import { readBitbucketIntegrationConfigs } from './config.esm.js';
4
-
5
- class BitbucketIntegration {
6
- constructor(integrationConfig) {
7
- this.integrationConfig = integrationConfig;
8
- }
9
- static factory = ({
10
- config
11
- }) => {
12
- const configs = readBitbucketIntegrationConfigs(
13
- config.getOptionalConfigArray("integrations.bitbucket") ?? [
14
- // if integrations.bitbucket was not used assume the use was migrated to the new configs
15
- // and backport for the deprecated integration to be usable for other parts of the system
16
- // until these got migrated
17
- ...config.getOptionalConfigArray("integrations.bitbucketCloud") ?? [],
18
- ...config.getOptionalConfigArray("integrations.bitbucketServer") ?? []
19
- ]
20
- );
21
- return basicIntegrations(
22
- configs.map((c) => new BitbucketIntegration(c)),
23
- (i) => i.config.host
24
- );
25
- };
26
- get type() {
27
- return "bitbucket";
28
- }
29
- get title() {
30
- return this.integrationConfig.host;
31
- }
32
- get config() {
33
- return this.integrationConfig;
34
- }
35
- resolveUrl(options) {
36
- const resolved = defaultScmResolveUrl(options);
37
- if (!options.lineNumber) {
38
- return resolved;
39
- }
40
- const url = new URL(resolved);
41
- if (this.integrationConfig.host === "bitbucket.org") {
42
- url.hash = `lines-${options.lineNumber}`;
43
- } else {
44
- url.hash = `${options.lineNumber}`;
45
- }
46
- return url.toString();
47
- }
48
- resolveEditUrl(url) {
49
- const urlData = parseGitUrl(url);
50
- const editUrl = new URL(url);
51
- editUrl.searchParams.set("mode", "edit");
52
- editUrl.searchParams.set("spa", "0");
53
- editUrl.searchParams.set("at", urlData.ref);
54
- return editUrl.toString();
55
- }
56
- }
57
-
58
- export { BitbucketIntegration };
59
- //# sourceMappingURL=BitbucketIntegration.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BitbucketIntegration.esm.js","sources":["../../src/bitbucket/BitbucketIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketIntegrationConfig,\n readBitbucketIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket based integration.\n *\n * @public\n * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.\n */\nexport class BitbucketIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucket') ?? [\n // if integrations.bitbucket was not used assume the use was migrated to the new configs\n // and backport for the deprecated integration to be usable for other parts of the system\n // until these got migrated\n ...(config.getOptionalConfigArray('integrations.bitbucketCloud') ?? []),\n ...(config.getOptionalConfigArray('integrations.bitbucketServer') ??\n []),\n ],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: BitbucketIntegrationConfig) {}\n\n get type(): string {\n return 'bitbucket';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n if (!options.lineNumber) {\n return resolved;\n }\n\n const url = new URL(resolved);\n\n if (this.integrationConfig.host === 'bitbucket.org') {\n // Bitbucket Cloud uses the syntax #lines-{start}[:{end}][,...]\n url.hash = `lines-${options.lineNumber}`;\n } else {\n // Bitbucket Server uses the syntax #{start}[-{end}][,...]\n url.hash = `${options.lineNumber}`;\n }\n\n return url.toString();\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n // TODO: Not sure what spa=0 does, at least bitbucket.org doesn't support it\n // but this is taken over from the initial implementation.\n editUrl.searchParams.set('spa', '0');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":[],"mappings":";;;;AA8BO,MAAM,oBAAA,CAA+C;AAAA,EAoB1D,YAA6B,iBAAA,EAA+C;AAA/C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAAgD;AAAA,EAnB7E,OAAO,UAAwD,CAAC;AAAA,IAC9D;AAAA,GACF,KAAM;AACJ,IAAA,MAAM,OAAA,GAAU,+BAAA;AAAA,MACd,MAAA,CAAO,sBAAA,CAAuB,wBAAwB,CAAA,IAAK;AAAA;AAAA;AAAA;AAAA,QAIzD,GAAI,MAAA,CAAO,sBAAA,CAAuB,6BAA6B,KAAK,EAAC;AAAA,QACrE,GAAI,MAAA,CAAO,sBAAA,CAAuB,8BAA8B,KAC9D;AAAC;AACL,KACF;AACA,IAAA,OAAO,iBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,oBAAA,CAAqB,CAAC,CAAC,CAAA;AAAA,MAC5C,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAAA,EACF,CAAA;AAAA,EAIA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,WAAA;AAAA,EACT;AAAA,EAEA,IAAI,KAAA,GAAgB;AAClB,IAAA,OAAO,KAAK,iBAAA,CAAkB,IAAA;AAAA,EAChC;AAAA,EAEA,IAAI,MAAA,GAAqC;AACvC,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EACd;AAAA,EAEA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,QAAA,GAAW,qBAAqB,OAAO,CAAA;AAC7C,IAAA,IAAI,CAAC,QAAQ,UAAA,EAAY;AACvB,MAAA,OAAO,QAAA;AAAA,IACT;AAEA,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAE5B,IAAA,IAAI,IAAA,CAAK,iBAAA,CAAkB,IAAA,KAAS,eAAA,EAAiB;AAEnD,MAAA,GAAA,CAAI,IAAA,GAAO,CAAA,MAAA,EAAS,OAAA,CAAQ,UAAU,CAAA,CAAA;AAAA,IACxC,CAAA,MAAO;AAEL,MAAA,GAAA,CAAI,IAAA,GAAO,CAAA,EAAG,OAAA,CAAQ,UAAU,CAAA,CAAA;AAAA,IAClC;AAEA,IAAA,OAAO,IAAI,QAAA,EAAS;AAAA,EACtB;AAAA,EAEA,eAAe,GAAA,EAAqB;AAClC,IAAA,MAAM,OAAA,GAAU,YAAY,GAAG,CAAA;AAC/B,IAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAM,CAAA;AAGvC,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA;AACnC,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,IAAA,EAAM,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAA,EAAS;AAAA,EAC1B;AACF;;;;"}
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- var lodash = require('lodash');
4
- var helpers = require('../helpers.cjs.js');
5
-
6
- const BITBUCKET_HOST = "bitbucket.org";
7
- const BITBUCKET_API_BASE_URL = "https://api.bitbucket.org/2.0";
8
- function readBitbucketIntegrationConfig(config) {
9
- const host = config.getOptionalString("host") ?? BITBUCKET_HOST;
10
- let apiBaseUrl = config.getOptionalString("apiBaseUrl");
11
- const token = config.getOptionalString("token")?.trim();
12
- const username = config.getOptionalString("username");
13
- const appPassword = config.getOptionalString("appPassword")?.trim();
14
- if (!helpers.isValidHost(host)) {
15
- throw new Error(
16
- `Invalid Bitbucket integration config, '${host}' is not a valid host`
17
- );
18
- }
19
- if (apiBaseUrl) {
20
- apiBaseUrl = lodash.trimEnd(apiBaseUrl, "/");
21
- } else if (host === BITBUCKET_HOST) {
22
- apiBaseUrl = BITBUCKET_API_BASE_URL;
23
- } else {
24
- apiBaseUrl = `https://${host}/rest/api/1.0`;
25
- }
26
- return {
27
- host,
28
- apiBaseUrl,
29
- token,
30
- username,
31
- appPassword,
32
- commitSigningKey: config.getOptionalString("commitSigningKey")
33
- };
34
- }
35
- function readBitbucketIntegrationConfigs(configs) {
36
- const result = configs.map(readBitbucketIntegrationConfig);
37
- if (!result.some((c) => c.host === BITBUCKET_HOST)) {
38
- result.push({
39
- host: BITBUCKET_HOST,
40
- apiBaseUrl: BITBUCKET_API_BASE_URL
41
- });
42
- }
43
- return result;
44
- }
45
-
46
- exports.readBitbucketIntegrationConfig = readBitbucketIntegrationConfig;
47
- exports.readBitbucketIntegrationConfigs = readBitbucketIntegrationConfigs;
48
- //# sourceMappingURL=config.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/bitbucket/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\nconst BITBUCKET_HOST = 'bitbucket.org';\nconst BITBUCKET_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket API provider.\n *\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport type BitbucketIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.org\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.bitbucket.org/2.0\",\n * with no trailing slash.\n *\n * Values omitted at the optional property at the app-config will be deduced\n * from the \"host\" value.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket integration config.\n *\n * @param config - The config object of a single integration\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfig(\n config: Config,\n): BitbucketIntegrationConfig {\n const host = config.getOptionalString('host') ?? BITBUCKET_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const appPassword = config.getOptionalString('appPassword')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === BITBUCKET_HOST) {\n apiBaseUrl = BITBUCKET_API_BASE_URL;\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n appPassword,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket integration configs, and inserts some defaults for\n * public Bitbucket if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfigs(\n configs: Config[],\n): BitbucketIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === BITBUCKET_HOST)) {\n result.push({\n host: BITBUCKET_HOST,\n apiBaseUrl: BITBUCKET_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":["isValidHost","trimEnd"],"mappings":";;;;;AAoBA,MAAM,cAAA,GAAiB,eAAA;AACvB,MAAM,sBAAA,GAAyB,+BAAA;AAyDxB,SAAS,+BACd,MAAA,EAC4B;AAC5B,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,iBAAA,CAAkB,MAAM,CAAA,IAAK,cAAA;AACjD,EAAA,IAAI,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AACtD,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,iBAAA,CAAkB,OAAO,GAAG,IAAA,EAAK;AACtD,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,iBAAA,CAAkB,aAAa,GAAG,IAAA,EAAK;AAElE,EAAA,IAAI,CAACA,mBAAA,CAAY,IAAI,CAAA,EAAG;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,0CAA0C,IAAI,CAAA,qBAAA;AAAA,KAChD;AAAA,EACF;AAEA,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,UAAA,GAAaC,cAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,EACtC,CAAA,MAAA,IAAW,SAAS,cAAA,EAAgB;AAClC,IAAA,UAAA,GAAa,sBAAA;AAAA,EACf,CAAA,MAAO;AACL,IAAA,UAAA,GAAa,WAAW,IAAI,CAAA,aAAA,CAAA;AAAA,EAC9B;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAA,CAAO,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AAUO,SAAS,gCACd,OAAA,EAC8B;AAE9B,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,8BAA8B,CAAA;AAIzD,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,cAAc,CAAA,EAAG;AAChD,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM,cAAA;AAAA,MACN,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,MAAA;AACT;;;;;"}