@backstage/integration 1.17.1 → 1.18.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/ScmIntegrations.cjs.js.map +1 -1
  3. package/dist/ScmIntegrations.esm.js.map +1 -1
  4. package/dist/awsCodeCommit/AwsCodeCommitIntegration.cjs.js.map +1 -1
  5. package/dist/awsCodeCommit/AwsCodeCommitIntegration.esm.js.map +1 -1
  6. package/dist/awsCodeCommit/config.cjs.js.map +1 -1
  7. package/dist/awsCodeCommit/config.esm.js.map +1 -1
  8. package/dist/awsS3/AwsS3Integration.cjs.js.map +1 -1
  9. package/dist/awsS3/AwsS3Integration.esm.js.map +1 -1
  10. package/dist/awsS3/config.cjs.js.map +1 -1
  11. package/dist/awsS3/config.esm.js.map +1 -1
  12. package/dist/azure/AzureIntegration.cjs.js.map +1 -1
  13. package/dist/azure/AzureIntegration.esm.js.map +1 -1
  14. package/dist/azure/AzureUrl.cjs.js.map +1 -1
  15. package/dist/azure/AzureUrl.esm.js.map +1 -1
  16. package/dist/azure/CachedAzureDevOpsCredentialsProvider.cjs.js.map +1 -1
  17. package/dist/azure/CachedAzureDevOpsCredentialsProvider.esm.js.map +1 -1
  18. package/dist/azure/DefaultAzureDevOpsCredentialsProvider.cjs.js.map +1 -1
  19. package/dist/azure/DefaultAzureDevOpsCredentialsProvider.esm.js.map +1 -1
  20. package/dist/azure/ManagedIdentityClientAssertion.cjs.js.map +1 -1
  21. package/dist/azure/ManagedIdentityClientAssertion.esm.js.map +1 -1
  22. package/dist/azure/config.cjs.js.map +1 -1
  23. package/dist/azure/config.esm.js.map +1 -1
  24. package/dist/azure/core.cjs.js.map +1 -1
  25. package/dist/azure/core.esm.js.map +1 -1
  26. package/dist/azure/deprecated.cjs.js.map +1 -1
  27. package/dist/azure/deprecated.esm.js.map +1 -1
  28. package/dist/azureBlobStorage/AzureBlobStorageIntegration.cjs.js.map +1 -1
  29. package/dist/azureBlobStorage/AzureBlobStorageIntegration.esm.js.map +1 -1
  30. package/dist/azureBlobStorage/DefaultAzureCredentialsProvider.cjs.js.map +1 -1
  31. package/dist/azureBlobStorage/DefaultAzureCredentialsProvider.esm.js.map +1 -1
  32. package/dist/azureBlobStorage/config.cjs.js.map +1 -1
  33. package/dist/azureBlobStorage/config.esm.js.map +1 -1
  34. package/dist/bitbucket/BitbucketIntegration.cjs.js.map +1 -1
  35. package/dist/bitbucket/BitbucketIntegration.esm.js.map +1 -1
  36. package/dist/bitbucket/config.cjs.js.map +1 -1
  37. package/dist/bitbucket/config.esm.js.map +1 -1
  38. package/dist/bitbucket/core.cjs.js.map +1 -1
  39. package/dist/bitbucket/core.esm.js.map +1 -1
  40. package/dist/bitbucketCloud/BitbucketCloudIntegration.cjs.js.map +1 -1
  41. package/dist/bitbucketCloud/BitbucketCloudIntegration.esm.js.map +1 -1
  42. package/dist/bitbucketCloud/config.cjs.js.map +1 -1
  43. package/dist/bitbucketCloud/config.esm.js.map +1 -1
  44. package/dist/bitbucketCloud/core.cjs.js.map +1 -1
  45. package/dist/bitbucketCloud/core.esm.js.map +1 -1
  46. package/dist/bitbucketServer/BitbucketServerIntegration.cjs.js.map +1 -1
  47. package/dist/bitbucketServer/BitbucketServerIntegration.esm.js.map +1 -1
  48. package/dist/bitbucketServer/config.cjs.js.map +1 -1
  49. package/dist/bitbucketServer/config.esm.js.map +1 -1
  50. package/dist/bitbucketServer/core.cjs.js.map +1 -1
  51. package/dist/bitbucketServer/core.esm.js.map +1 -1
  52. package/dist/gerrit/GerritIntegration.cjs.js.map +1 -1
  53. package/dist/gerrit/GerritIntegration.esm.js.map +1 -1
  54. package/dist/gerrit/config.cjs.js.map +1 -1
  55. package/dist/gerrit/config.esm.js.map +1 -1
  56. package/dist/gerrit/core.cjs.js.map +1 -1
  57. package/dist/gerrit/core.esm.js.map +1 -1
  58. package/dist/gitea/GiteaIntegration.cjs.js.map +1 -1
  59. package/dist/gitea/GiteaIntegration.esm.js.map +1 -1
  60. package/dist/gitea/config.cjs.js.map +1 -1
  61. package/dist/gitea/config.esm.js.map +1 -1
  62. package/dist/gitea/core.cjs.js.map +1 -1
  63. package/dist/gitea/core.esm.js.map +1 -1
  64. package/dist/github/DefaultGithubCredentialsProvider.cjs.js.map +1 -1
  65. package/dist/github/DefaultGithubCredentialsProvider.esm.js.map +1 -1
  66. package/dist/github/GithubIntegration.cjs.js.map +1 -1
  67. package/dist/github/GithubIntegration.esm.js.map +1 -1
  68. package/dist/github/SingleInstanceGithubCredentialsProvider.cjs.js +8 -4
  69. package/dist/github/SingleInstanceGithubCredentialsProvider.cjs.js.map +1 -1
  70. package/dist/github/SingleInstanceGithubCredentialsProvider.esm.js +8 -4
  71. package/dist/github/SingleInstanceGithubCredentialsProvider.esm.js.map +1 -1
  72. package/dist/github/config.cjs.js.map +1 -1
  73. package/dist/github/config.esm.js.map +1 -1
  74. package/dist/github/core.cjs.js.map +1 -1
  75. package/dist/github/core.esm.js.map +1 -1
  76. package/dist/gitlab/DefaultGitlabCredentialsProvider.cjs.js.map +1 -1
  77. package/dist/gitlab/DefaultGitlabCredentialsProvider.esm.js.map +1 -1
  78. package/dist/gitlab/GitLabIntegration.cjs.js.map +1 -1
  79. package/dist/gitlab/GitLabIntegration.esm.js.map +1 -1
  80. package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.cjs.js.map +1 -1
  81. package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.esm.js.map +1 -1
  82. package/dist/gitlab/config.cjs.js.map +1 -1
  83. package/dist/gitlab/config.esm.js.map +1 -1
  84. package/dist/gitlab/core.cjs.js.map +1 -1
  85. package/dist/gitlab/core.esm.js.map +1 -1
  86. package/dist/googleGcs/config.cjs.js.map +1 -1
  87. package/dist/googleGcs/config.esm.js.map +1 -1
  88. package/dist/harness/HarnessIntegration.cjs.js.map +1 -1
  89. package/dist/harness/HarnessIntegration.esm.js.map +1 -1
  90. package/dist/harness/config.cjs.js.map +1 -1
  91. package/dist/harness/config.esm.js.map +1 -1
  92. package/dist/harness/core.cjs.js.map +1 -1
  93. package/dist/harness/core.esm.js.map +1 -1
  94. package/dist/helpers.cjs.js.map +1 -1
  95. package/dist/helpers.esm.js.map +1 -1
  96. package/dist/index.d.ts +1 -1
  97. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @backstage/integration
2
2
 
3
+ ## 1.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 03bdc68: Added support for limiting GithubAppCredentialsMux to specific apps
8
+
9
+ ### Patch Changes
10
+
11
+ - 56897d7: Fixes issue with Github credentials provider which fails to match organization name if using allowedInstallationOwners
12
+
13
+ ## 1.18.0-next.0
14
+
15
+ ### Minor Changes
16
+
17
+ - 03bdc68: Added support for limiting GithubAppCredentialsMux to specific apps
18
+
3
19
  ## 1.17.1
4
20
 
5
21
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"ScmIntegrations.cjs.js","sources":["../src/ScmIntegrations.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 { AwsS3Integration } from './awsS3/AwsS3Integration';\nimport { AwsCodeCommitIntegration } from './awsCodeCommit/AwsCodeCommitIntegration';\nimport { AzureIntegration } from './azure/AzureIntegration';\nimport { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegration';\nimport { BitbucketIntegration } from './bitbucket/BitbucketIntegration';\nimport { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration';\nimport { GerritIntegration } from './gerrit/GerritIntegration';\nimport { GithubIntegration } from './github/GithubIntegration';\nimport { GitLabIntegration } from './gitlab/GitLabIntegration';\nimport { defaultScmResolveUrl } from './helpers';\nimport { ScmIntegration, ScmIntegrationsGroup } from './types';\nimport { ScmIntegrationRegistry } from './registry';\nimport { GiteaIntegration } from './gitea';\nimport { HarnessIntegration } from './harness/HarnessIntegration';\nimport { AzureBlobStorageIntergation } from './azureBlobStorage';\n\n/**\n * The set of supported integrations.\n *\n * @public\n */\nexport interface IntegrationsByType {\n awsS3: ScmIntegrationsGroup<AwsS3Integration>;\n awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;\n azureBlobStorage: ScmIntegrationsGroup<AzureBlobStorageIntergation>;\n azure: ScmIntegrationsGroup<AzureIntegration>;\n /**\n * @deprecated in favor of `bitbucketCloud` and `bitbucketServer`\n */\n bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;\n bitbucketCloud: ScmIntegrationsGroup<BitbucketCloudIntegration>;\n bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;\n gerrit: ScmIntegrationsGroup<GerritIntegration>;\n github: ScmIntegrationsGroup<GithubIntegration>;\n gitlab: ScmIntegrationsGroup<GitLabIntegration>;\n gitea: ScmIntegrationsGroup<GiteaIntegration>;\n harness: ScmIntegrationsGroup<HarnessIntegration>;\n}\n\n/**\n * Exposes the set of supported integrations.\n *\n * @public\n */\nexport class ScmIntegrations implements ScmIntegrationRegistry {\n private readonly byType: IntegrationsByType;\n\n static fromConfig(config: Config): ScmIntegrations {\n return new ScmIntegrations({\n awsS3: AwsS3Integration.factory({ config }),\n awsCodeCommit: AwsCodeCommitIntegration.factory({ config }),\n azureBlobStorage: AzureBlobStorageIntergation.factory({ config }),\n azure: AzureIntegration.factory({ config }),\n bitbucket: BitbucketIntegration.factory({ config }),\n bitbucketCloud: BitbucketCloudIntegration.factory({ config }),\n bitbucketServer: BitbucketServerIntegration.factory({ config }),\n gerrit: GerritIntegration.factory({ config }),\n github: GithubIntegration.factory({ config }),\n gitlab: GitLabIntegration.factory({ config }),\n gitea: GiteaIntegration.factory({ config }),\n harness: HarnessIntegration.factory({ config }),\n });\n }\n\n constructor(integrationsByType: IntegrationsByType) {\n this.byType = integrationsByType;\n }\n\n get awsS3(): ScmIntegrationsGroup<AwsS3Integration> {\n return this.byType.awsS3;\n }\n\n get awsCodeCommit(): ScmIntegrationsGroup<AwsCodeCommitIntegration> {\n return this.byType.awsCodeCommit;\n }\n\n get azureBlobStorage(): ScmIntegrationsGroup<AzureBlobStorageIntergation> {\n return this.byType.azureBlobStorage;\n }\n\n get azure(): ScmIntegrationsGroup<AzureIntegration> {\n return this.byType.azure;\n }\n\n /**\n * @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`\n */\n get bitbucket(): ScmIntegrationsGroup<BitbucketIntegration> {\n return this.byType.bitbucket;\n }\n\n get bitbucketCloud(): ScmIntegrationsGroup<BitbucketCloudIntegration> {\n return this.byType.bitbucketCloud;\n }\n\n get bitbucketServer(): ScmIntegrationsGroup<BitbucketServerIntegration> {\n return this.byType.bitbucketServer;\n }\n\n get gerrit(): ScmIntegrationsGroup<GerritIntegration> {\n return this.byType.gerrit;\n }\n\n get github(): ScmIntegrationsGroup<GithubIntegration> {\n return this.byType.github;\n }\n\n get gitlab(): ScmIntegrationsGroup<GitLabIntegration> {\n return this.byType.gitlab;\n }\n\n get gitea(): ScmIntegrationsGroup<GiteaIntegration> {\n return this.byType.gitea;\n }\n\n get harness(): ScmIntegrationsGroup<HarnessIntegration> {\n return this.byType.harness;\n }\n\n list(): ScmIntegration[] {\n return Object.values(this.byType).flatMap(\n i => i.list() as ScmIntegration[],\n );\n }\n\n byUrl(url: string | URL): ScmIntegration | undefined {\n let candidates = Object.values(this.byType)\n .map(i => i.byUrl(url))\n .filter(Boolean);\n\n // Do not return deprecated integrations if there are other options\n if (candidates.length > 1) {\n const filteredCandidates = candidates.filter(\n x => !(x instanceof BitbucketIntegration),\n );\n if (filteredCandidates.length !== 0) {\n candidates = filteredCandidates;\n }\n }\n\n return candidates[0];\n }\n\n byHost(host: string): ScmIntegration | undefined {\n return Object.values(this.byType)\n .map(i => i.byHost(host))\n .find(Boolean);\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const integration = this.byUrl(options.base);\n if (!integration) {\n return defaultScmResolveUrl(options);\n }\n\n return integration.resolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n const integration = this.byUrl(url);\n if (!integration) {\n return url;\n }\n\n return integration.resolveEditUrl(url);\n }\n}\n"],"names":["AwsS3Integration","AwsCodeCommitIntegration","AzureBlobStorageIntergation","AzureIntegration","BitbucketIntegration","BitbucketCloudIntegration","BitbucketServerIntegration","GerritIntegration","GithubIntegration","GitLabIntegration","GiteaIntegration","HarnessIntegration","defaultScmResolveUrl"],"mappings":";;;;;;;;;;;;;;;;;;AA6DO,MAAM,eAAkD,CAAA;AAAA,EAC5C,MAAA;AAAA,EAEjB,OAAO,WAAW,MAAiC,EAAA;AACjD,IAAA,OAAO,IAAI,eAAgB,CAAA;AAAA,MACzB,KAAO,EAAAA,iCAAA,CAAiB,OAAQ,CAAA,EAAE,QAAQ,CAAA;AAAA,MAC1C,aAAe,EAAAC,iDAAA,CAAyB,OAAQ,CAAA,EAAE,QAAQ,CAAA;AAAA,MAC1D,gBAAkB,EAAAC,uDAAA,CAA4B,OAAQ,CAAA,EAAE,QAAQ,CAAA;AAAA,MAChE,KAAO,EAAAC,iCAAA,CAAiB,OAAQ,CAAA,EAAE,QAAQ,CAAA;AAAA,MAC1C,SAAW,EAAAC,yCAAA,CAAqB,OAAQ,CAAA,EAAE,QAAQ,CAAA;AAAA,MAClD,cAAgB,EAAAC,mDAAA,CAA0B,OAAQ,CAAA,EAAE,QAAQ,CAAA;AAAA,MAC5D,eAAiB,EAAAC,qDAAA,CAA2B,OAAQ,CAAA,EAAE,QAAQ,CAAA;AAAA,MAC9D,MAAQ,EAAAC,mCAAA,C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O,CAAA;AAAA;AAGrC,IAAO,OAAA,WAAA,CAAY,WAAW,OAAO,CAAA;AAAA;AACvC,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAM,MAAA,WAAA,GAAc,IAAK,CAAA,KAAA,CAAM,GAAG,CAAA;AAClC,IAAA,IAAI,CAAC,WAAa,EAAA;AAChB,MAAO,OAAA,GAAA;AAAA;AAGT,IAAO,OAAA,WAAA,CAAY,eAAe,GAAG,CAAA;AAAA;AAEzC;;;;"}
1
+ {"version":3,"file":"ScmIntegrations.cjs.js","sources":["../src/ScmIntegrations.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 { AwsS3Integration } from './awsS3/AwsS3Integration';\nimport { AwsCodeCommitIntegration } from './awsCodeCommit/AwsCodeCommitIntegration';\nimport { AzureIntegration } from './azure/AzureIntegration';\nimport { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegration';\nimport { BitbucketIntegration } from './bitbucket/BitbucketIntegration';\nimport { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration';\nimport { GerritIntegration } from './gerrit/GerritIntegration';\nimport { GithubIntegration } from './github/GithubIntegration';\nimport { GitLabIntegration } from './gitlab/GitLabIntegration';\nimport { defaultScmResolveUrl } from './helpers';\nimport { ScmIntegration, ScmIntegrationsGroup } from './types';\nimport { ScmIntegrationRegistry } from './registry';\nimport { GiteaIntegration } from './gitea';\nimport { HarnessIntegration } from './harness/HarnessIntegration';\nimport { AzureBlobStorageIntergation } from './azureBlobStorage';\n\n/**\n * The set of supported integrations.\n *\n * @public\n */\nexport interface IntegrationsByType {\n awsS3: ScmIntegrationsGroup<AwsS3Integration>;\n awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;\n azureBlobStorage: ScmIntegrationsGroup<AzureBlobStorageIntergation>;\n azure: ScmIntegrationsGroup<AzureIntegration>;\n /**\n * @deprecated in favor of `bitbucketCloud` and `bitbucketServer`\n */\n bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;\n bitbucketCloud: ScmIntegrationsGroup<BitbucketCloudIntegration>;\n bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;\n gerrit: ScmIntegrationsGroup<GerritIntegration>;\n github: ScmIntegrationsGroup<GithubIntegration>;\n gitlab: ScmIntegrationsGroup<GitLabIntegration>;\n gitea: ScmIntegrationsGroup<GiteaIntegration>;\n harness: ScmIntegrationsGroup<HarnessIntegration>;\n}\n\n/**\n * Exposes the set of supported integrations.\n *\n * @public\n */\nexport class ScmIntegrations implements ScmIntegrationRegistry {\n private readonly byType: IntegrationsByType;\n\n static fromConfig(config: Config): ScmIntegrations {\n return new ScmIntegrations({\n awsS3: AwsS3Integration.factory({ config }),\n awsCodeCommit: AwsCodeCommitIntegration.factory({ config }),\n azureBlobStorage: AzureBlobStorageIntergation.factory({ config }),\n azure: AzureIntegration.factory({ config }),\n bitbucket: BitbucketIntegration.factory({ config }),\n bitbucketCloud: BitbucketCloudIntegration.factory({ config }),\n bitbucketServer: BitbucketServerIntegration.factory({ config }),\n gerrit: GerritIntegration.factory({ config }),\n github: GithubIntegration.factory({ config }),\n gitlab: GitLabIntegration.factory({ config }),\n gitea: GiteaIntegration.factory({ config }),\n harness: HarnessIntegration.factory({ config }),\n });\n }\n\n constructor(integrationsByType: IntegrationsByType) {\n this.byType = integrationsByType;\n }\n\n get awsS3(): ScmIntegrationsGroup<AwsS3Integration> {\n return this.byType.awsS3;\n }\n\n get awsCodeCommit(): ScmIntegrationsGroup<AwsCodeCommitIntegration> {\n return this.byType.awsCodeCommit;\n }\n\n get azureBlobStorage(): ScmIntegrationsGroup<AzureBlobStorageIntergation> {\n return this.byType.azureBlobStorage;\n }\n\n get azure(): ScmIntegrationsGroup<AzureIntegration> {\n return this.byType.azure;\n }\n\n /**\n * @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`\n */\n get bitbucket(): ScmIntegrationsGroup<BitbucketIntegration> {\n return this.byType.bitbucket;\n }\n\n get bitbucketCloud(): ScmIntegrationsGroup<BitbucketCloudIntegration> {\n return this.byType.bitbucketCloud;\n }\n\n get bitbucketServer(): ScmIntegrationsGroup<BitbucketServerIntegration> {\n return this.byType.bitbucketServer;\n }\n\n get gerrit(): ScmIntegrationsGroup<GerritIntegration> {\n return this.byType.gerrit;\n }\n\n get github(): ScmIntegrationsGroup<GithubIntegration> {\n return this.byType.github;\n }\n\n get gitlab(): ScmIntegrationsGroup<GitLabIntegration> {\n return this.byType.gitlab;\n }\n\n get gitea(): ScmIntegrationsGroup<GiteaIntegration> {\n return this.byType.gitea;\n }\n\n get harness(): ScmIntegrationsGroup<HarnessIntegration> {\n return this.byType.harness;\n }\n\n list(): ScmIntegration[] {\n return Object.values(this.byType).flatMap(\n i => i.list() as ScmIntegration[],\n );\n }\n\n byUrl(url: string | URL): ScmIntegration | undefined {\n let candidates = Object.values(this.byType)\n .map(i => i.byUrl(url))\n .filter(Boolean);\n\n // Do not return deprecated integrations if there are other options\n if (candidates.length > 1) {\n const filteredCandidates = candidates.filter(\n x => !(x instanceof BitbucketIntegration),\n );\n if (filteredCandidates.length !== 0) {\n candidates = filteredCandidates;\n }\n }\n\n return candidates[0];\n }\n\n byHost(host: string): ScmIntegration | undefined {\n return Object.values(this.byType)\n .map(i => i.byHost(host))\n .find(Boolean);\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const integration = this.byUrl(options.base);\n if (!integration) {\n return defaultScmResolveUrl(options);\n }\n\n return integration.resolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n const integration = this.byUrl(url);\n if (!integration) {\n return url;\n }\n\n return integration.resolveEditUrl(url);\n }\n}\n"],"names":["AwsS3Integration","AwsCodeCommitIntegration","AzureBlobStorageIntergation","AzureIntegration","BitbucketIntegration","BitbucketCloudIntegration","BitbucketServerIntegration","GerritIntegration","GithubIntegration","GitLabIntegration","GiteaIntegration","HarnessIntegration","defaultScmResolveUrl"],"mappings":";;;;;;;;;;;;;;;;;;AA6DO,MAAM,eAAA,CAAkD;AAAA,EAC5C,MAAA;AAAA,EAEjB,OAAO,WAAW,MAAA,EAAiC;AACjD,IAAA,OAAO,IAAI,eAAA,CAAgB;AAAA,MACzB,KAAA,EAAOA,iCAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,aAAA,EAAeC,iDAAA,CAAyB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1D,gBAAA,EAAkBC,uDAAA,CAA4B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAChE,KAAA,EAAOC,iCAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,SAAA,EAAWC,yCAAA,CAAqB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAClD,cAAA,EAAgBC,mDAAA,CAA0B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC5D,eAAA,EAAiBC,qDAAA,CAA2B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC9D,MAAA,EAAQC,mCAAA,CAAkB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC5C,MAAA,EAAQC,mCAAA,CAAkB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC5C,MAAA,EAAQC,mCAAA,CAAkB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC5C,KAAA,EAAOC,iCAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,OAAA,EAASC,qCAA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AClC,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,OAAO,GAAA;AAAA,IACT;AAEA,IAAA,OAAO,WAAA,CAAY,eAAe,GAAG,CAAA;AAAA,EACvC;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ScmIntegrations.esm.js","sources":["../src/ScmIntegrations.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 { AwsS3Integration } from './awsS3/AwsS3Integration';\nimport { AwsCodeCommitIntegration } from './awsCodeCommit/AwsCodeCommitIntegration';\nimport { AzureIntegration } from './azure/AzureIntegration';\nimport { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegration';\nimport { BitbucketIntegration } from './bitbucket/BitbucketIntegration';\nimport { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration';\nimport { GerritIntegration } from './gerrit/GerritIntegration';\nimport { GithubIntegration } from './github/GithubIntegration';\nimport { GitLabIntegration } from './gitlab/GitLabIntegration';\nimport { defaultScmResolveUrl } from './helpers';\nimport { ScmIntegration, ScmIntegrationsGroup } from './types';\nimport { ScmIntegrationRegistry } from './registry';\nimport { GiteaIntegration } from './gitea';\nimport { HarnessIntegration } from './harness/HarnessIntegration';\nimport { AzureBlobStorageIntergation } from './azureBlobStorage';\n\n/**\n * The set of supported integrations.\n *\n * @public\n */\nexport interface IntegrationsByType {\n awsS3: ScmIntegrationsGroup<AwsS3Integration>;\n awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;\n azureBlobStorage: ScmIntegrationsGroup<AzureBlobStorageIntergation>;\n azure: ScmIntegrationsGroup<AzureIntegration>;\n /**\n * @deprecated in favor of `bitbucketCloud` and `bitbucketServer`\n */\n bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;\n bitbucketCloud: ScmIntegrationsGroup<BitbucketCloudIntegration>;\n bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;\n gerrit: ScmIntegrationsGroup<GerritIntegration>;\n github: ScmIntegrationsGroup<GithubIntegration>;\n gitlab: ScmIntegrationsGroup<GitLabIntegration>;\n gitea: ScmIntegrationsGroup<GiteaIntegration>;\n harness: ScmIntegrationsGroup<HarnessIntegration>;\n}\n\n/**\n * Exposes the set of supported integrations.\n *\n * @public\n */\nexport class ScmIntegrations implements ScmIntegrationRegistry {\n private readonly byType: IntegrationsByType;\n\n static fromConfig(config: Config): ScmIntegrations {\n return new ScmIntegrations({\n awsS3: AwsS3Integration.factory({ config }),\n awsCodeCommit: AwsCodeCommitIntegration.factory({ config }),\n azureBlobStorage: AzureBlobStorageIntergation.factory({ config }),\n azure: AzureIntegration.factory({ config }),\n bitbucket: BitbucketIntegration.factory({ config }),\n bitbucketCloud: BitbucketCloudIntegration.factory({ config }),\n bitbucketServer: BitbucketServerIntegration.factory({ config }),\n gerrit: GerritIntegration.factory({ config }),\n github: GithubIntegration.factory({ config }),\n gitlab: GitLabIntegration.factory({ config }),\n gitea: GiteaIntegration.factory({ config }),\n harness: HarnessIntegration.factory({ config }),\n });\n }\n\n constructor(integrationsByType: IntegrationsByType) {\n this.byType = integrationsByType;\n }\n\n get awsS3(): ScmIntegrationsGroup<AwsS3Integration> {\n return this.byType.awsS3;\n }\n\n get awsCodeCommit(): ScmIntegrationsGroup<AwsCodeCommitIntegration> {\n return this.byType.awsCodeCommit;\n }\n\n get azureBlobStorage(): ScmIntegrationsGroup<AzureBlobStorageIntergation> {\n return this.byType.azureBlobStorage;\n }\n\n get azure(): ScmIntegrationsGroup<AzureIntegration> {\n return this.byType.azure;\n }\n\n /**\n * @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`\n */\n get bitbucket(): ScmIntegrationsGroup<BitbucketIntegration> {\n return this.byType.bitbucket;\n }\n\n get bitbucketCloud(): ScmIntegrationsGroup<BitbucketCloudIntegration> {\n return this.byType.bitbucketCloud;\n }\n\n get bitbucketServer(): ScmIntegrationsGroup<BitbucketServerIntegration> {\n return this.byType.bitbucketServer;\n }\n\n get gerrit(): ScmIntegrationsGroup<GerritIntegration> {\n return this.byType.gerrit;\n }\n\n get github(): ScmIntegrationsGroup<GithubIntegration> {\n return this.byType.github;\n }\n\n get gitlab(): ScmIntegrationsGroup<GitLabIntegration> {\n return this.byType.gitlab;\n }\n\n get gitea(): ScmIntegrationsGroup<GiteaIntegration> {\n return this.byType.gitea;\n }\n\n get harness(): ScmIntegrationsGroup<HarnessIntegration> {\n return this.byType.harness;\n }\n\n list(): ScmIntegration[] {\n return Object.values(this.byType).flatMap(\n i => i.list() as ScmIntegration[],\n );\n }\n\n byUrl(url: string | URL): ScmIntegration | undefined {\n let candidates = Object.values(this.byType)\n .map(i => i.byUrl(url))\n .filter(Boolean);\n\n // Do not return deprecated integrations if there are other options\n if (candidates.length > 1) {\n const filteredCandidates = candidates.filter(\n x => !(x instanceof BitbucketIntegration),\n );\n if (filteredCandidates.length !== 0) {\n candidates = filteredCandidates;\n }\n }\n\n return candidates[0];\n }\n\n byHost(host: string): ScmIntegration | undefined {\n return Object.values(this.byType)\n .map(i => i.byHost(host))\n .find(Boolean);\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const integration = this.byUrl(options.base);\n if (!integration) {\n return defaultScmResolveUrl(options);\n }\n\n return integration.resolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n const integration = this.byUrl(url);\n if (!integration) {\n return url;\n }\n\n return integration.resolveEditUrl(url);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA6DO,MAAM,eAAkD,CAAA;AAAA,EAC5C,M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M,qBAAqB,UAAW,CAAA,MAAA;AAAA,QACpC,CAAA,CAAA,KAAK,EAAE,CAAa,YAAA,oBAAA;AAAA,OACtB;AACA,MAAI,IAAA,kBAAA,CAAmB,WAAW,CAAG,EAAA;AACnC,QAAa,UAAA,GAAA,kBAAA;AAAA;AACf;AAGF,IAAA,OAAO,WAAW,CAAC,CAAA;AAAA;AACrB,EAEA,OAAO,IAA0C,EAAA;AAC/C,IAAA,OAAO,MAAO,CAAA,MAAA,CAAO,IAAK,CAAA,MAAM,CAC7B,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA,IAAI,CAAC,CAAA,CACvB,KAAK,OAAO,CAAA;AAAA;AACjB,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,MAAM,WAAc,GAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,IAAI,CAAA;AAC3C,IAAA,IAAI,CAAC,WAAa,EAAA;AAChB,MAAA,OAAO,qBAAqB,OAAO,CAAA;AAAA;AAGrC,IAAO,OAAA,WAAA,CAAY,WAAW,OAAO,CAAA;AAAA;AACvC,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAM,MAAA,WAAA,GAAc,IAAK,CAAA,KAAA,CAAM,GAAG,CAAA;AAClC,IAAA,IAAI,CAAC,WAAa,EAAA;AAChB,MAAO,OAAA,GAAA;AAAA;AAGT,IAAO,OAAA,WAAA,CAAY,eAAe,GAAG,CAAA;AAAA;AAEzC;;;;"}
1
+ {"version":3,"file":"ScmIntegrations.esm.js","sources":["../src/ScmIntegrations.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 { AwsS3Integration } from './awsS3/AwsS3Integration';\nimport { AwsCodeCommitIntegration } from './awsCodeCommit/AwsCodeCommitIntegration';\nimport { AzureIntegration } from './azure/AzureIntegration';\nimport { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegration';\nimport { BitbucketIntegration } from './bitbucket/BitbucketIntegration';\nimport { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration';\nimport { GerritIntegration } from './gerrit/GerritIntegration';\nimport { GithubIntegration } from './github/GithubIntegration';\nimport { GitLabIntegration } from './gitlab/GitLabIntegration';\nimport { defaultScmResolveUrl } from './helpers';\nimport { ScmIntegration, ScmIntegrationsGroup } from './types';\nimport { ScmIntegrationRegistry } from './registry';\nimport { GiteaIntegration } from './gitea';\nimport { HarnessIntegration } from './harness/HarnessIntegration';\nimport { AzureBlobStorageIntergation } from './azureBlobStorage';\n\n/**\n * The set of supported integrations.\n *\n * @public\n */\nexport interface IntegrationsByType {\n awsS3: ScmIntegrationsGroup<AwsS3Integration>;\n awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;\n azureBlobStorage: ScmIntegrationsGroup<AzureBlobStorageIntergation>;\n azure: ScmIntegrationsGroup<AzureIntegration>;\n /**\n * @deprecated in favor of `bitbucketCloud` and `bitbucketServer`\n */\n bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;\n bitbucketCloud: ScmIntegrationsGroup<BitbucketCloudIntegration>;\n bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;\n gerrit: ScmIntegrationsGroup<GerritIntegration>;\n github: ScmIntegrationsGroup<GithubIntegration>;\n gitlab: ScmIntegrationsGroup<GitLabIntegration>;\n gitea: ScmIntegrationsGroup<GiteaIntegration>;\n harness: ScmIntegrationsGroup<HarnessIntegration>;\n}\n\n/**\n * Exposes the set of supported integrations.\n *\n * @public\n */\nexport class ScmIntegrations implements ScmIntegrationRegistry {\n private readonly byType: IntegrationsByType;\n\n static fromConfig(config: Config): ScmIntegrations {\n return new ScmIntegrations({\n awsS3: AwsS3Integration.factory({ config }),\n awsCodeCommit: AwsCodeCommitIntegration.factory({ config }),\n azureBlobStorage: AzureBlobStorageIntergation.factory({ config }),\n azure: AzureIntegration.factory({ config }),\n bitbucket: BitbucketIntegration.factory({ config }),\n bitbucketCloud: BitbucketCloudIntegration.factory({ config }),\n bitbucketServer: BitbucketServerIntegration.factory({ config }),\n gerrit: GerritIntegration.factory({ config }),\n github: GithubIntegration.factory({ config }),\n gitlab: GitLabIntegration.factory({ config }),\n gitea: GiteaIntegration.factory({ config }),\n harness: HarnessIntegration.factory({ config }),\n });\n }\n\n constructor(integrationsByType: IntegrationsByType) {\n this.byType = integrationsByType;\n }\n\n get awsS3(): ScmIntegrationsGroup<AwsS3Integration> {\n return this.byType.awsS3;\n }\n\n get awsCodeCommit(): ScmIntegrationsGroup<AwsCodeCommitIntegration> {\n return this.byType.awsCodeCommit;\n }\n\n get azureBlobStorage(): ScmIntegrationsGroup<AzureBlobStorageIntergation> {\n return this.byType.azureBlobStorage;\n }\n\n get azure(): ScmIntegrationsGroup<AzureIntegration> {\n return this.byType.azure;\n }\n\n /**\n * @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`\n */\n get bitbucket(): ScmIntegrationsGroup<BitbucketIntegration> {\n return this.byType.bitbucket;\n }\n\n get bitbucketCloud(): ScmIntegrationsGroup<BitbucketCloudIntegration> {\n return this.byType.bitbucketCloud;\n }\n\n get bitbucketServer(): ScmIntegrationsGroup<BitbucketServerIntegration> {\n return this.byType.bitbucketServer;\n }\n\n get gerrit(): ScmIntegrationsGroup<GerritIntegration> {\n return this.byType.gerrit;\n }\n\n get github(): ScmIntegrationsGroup<GithubIntegration> {\n return this.byType.github;\n }\n\n get gitlab(): ScmIntegrationsGroup<GitLabIntegration> {\n return this.byType.gitlab;\n }\n\n get gitea(): ScmIntegrationsGroup<GiteaIntegration> {\n return this.byType.gitea;\n }\n\n get harness(): ScmIntegrationsGroup<HarnessIntegration> {\n return this.byType.harness;\n }\n\n list(): ScmIntegration[] {\n return Object.values(this.byType).flatMap(\n i => i.list() as ScmIntegration[],\n );\n }\n\n byUrl(url: string | URL): ScmIntegration | undefined {\n let candidates = Object.values(this.byType)\n .map(i => i.byUrl(url))\n .filter(Boolean);\n\n // Do not return deprecated integrations if there are other options\n if (candidates.length > 1) {\n const filteredCandidates = candidates.filter(\n x => !(x instanceof BitbucketIntegration),\n );\n if (filteredCandidates.length !== 0) {\n candidates = filteredCandidates;\n }\n }\n\n return candidates[0];\n }\n\n byHost(host: string): ScmIntegration | undefined {\n return Object.values(this.byType)\n .map(i => i.byHost(host))\n .find(Boolean);\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const integration = this.byUrl(options.base);\n if (!integration) {\n return defaultScmResolveUrl(options);\n }\n\n return integration.resolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n const integration = this.byUrl(url);\n if (!integration) {\n return url;\n }\n\n return integration.resolveEditUrl(url);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA6DO,MAAM,eAAA,CAAkD;AAAA,EAC5C,MAAA;AAAA,EAEjB,OAAO,WAAW,MAAA,EAAiC;AACjD,IAAA,OAAO,IAAI,eAAA,CAAgB;AAAA,MACzB,KAAA,EAAO,gBAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,aAAA,EAAe,wBAAA,CAAyB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1D,gBAAA,EAAkB,2BAAA,CAA4B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAChE,KAAA,EAAO,gBAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,SAAA,EAAW,oBAAA,CAAqB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAClD,cAAA,EAAgB,yBAA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,CAAA,CAAE,MAAA,CAAO,IAAI,CAAC,CAAA,CACvB,KAAK,OAAO,CAAA;AAAA,EACjB;AAAA,EAEA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA;AAC3C,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,OAAO,qBAAqB,OAAO,CAAA;AAAA,IACrC;AAEA,IAAA,OAAO,WAAA,CAAY,WAAW,OAAO,CAAA;AAAA,EACvC;AAAA,EAEA,eAAe,GAAA,EAAqB;AAClC,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAClC,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,OAAO,GAAA;AAAA,IACT;AAEA,IAAA,OAAO,WAAA,CAAY,eAAe,GAAG,CAAA;AAAA,EACvC;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AwsCodeCommitIntegration.cjs.js","sources":["../../src/awsCodeCommit/AwsCodeCommitIntegration.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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n AwsCodeCommitIntegrationConfig,\n readAwsCodeCommitIntegrationConfigs,\n} from './config';\n\n/**\n * Integrates with AWS CodeCommit.\n *\n * @public\n */\nexport class AwsCodeCommitIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsCodeCommitIntegration> = ({\n config,\n }) => {\n const configs = readAwsCodeCommitIntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsCodeCommit') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsCodeCommitIntegration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsCodeCommit';\n }\n\n get config(): AwsCodeCommitIntegrationConfig {\n return this.integrationConfig;\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n constructor(\n private readonly integrationConfig: AwsCodeCommitIntegrationConfig,\n ) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n resolveEditUrl(url: string): string {\n const parsedUrl = new URL(url);\n const pathMatch = parsedUrl.pathname.match(\n /^\\/codesuite\\/codecommit\\/repositories\\/([^\\/]+)\\//,\n );\n if (!pathMatch) {\n throw new Error(``);\n }\n const [, repositoryName] = pathMatch;\n return replaceCodeCommitUrlType(url, repositoryName, 'edit');\n }\n}\n\n/**\n * Takes a CodeCommit URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'edit'\n * @public\n */\nexport function replaceCodeCommitUrlType(\n url: string,\n repositoryName: string,\n type: 'browse' | 'edit',\n): string {\n const newString = type === 'edit' ? `files/edit` : type;\n return url.replace(\n new RegExp(\n `\\/codesuite\\/codecommit\\/repositories\\/${repositoryName}\\/(browse|files\\/edit)\\/`,\n ),\n `/codesuite/codecommit/repositories/${repositoryName}/${newString}/`,\n );\n}\n"],"names":["config","readAwsCodeCommitIntegrationConfigs","basicIntegrations","defaultScmResolveUrl"],"mappings":";;;;;AA4BO,MAAM,wBAAmD,CAAA;AAAA,EAyB9D,YACmB,iBACjB,EAAA;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAChB,EA1BH,OAAO,UAA4D,CAAC;AAAA,YAClEA;AAAA,GACI,KAAA;AACJ,IAAA,MAAM,OAAU,GAAAC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CAAA,EAAI,SAAS,CAAA,CAAA;AAAA,GACnE;AACF;;;;;"}
1
+ {"version":3,"file":"AwsCodeCommitIntegration.cjs.js","sources":["../../src/awsCodeCommit/AwsCodeCommitIntegration.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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n AwsCodeCommitIntegrationConfig,\n readAwsCodeCommitIntegrationConfigs,\n} from './config';\n\n/**\n * Integrates with AWS CodeCommit.\n *\n * @public\n */\nexport class AwsCodeCommitIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsCodeCommitIntegration> = ({\n config,\n }) => {\n const configs = readAwsCodeCommitIntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsCodeCommit') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsCodeCommitIntegration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsCodeCommit';\n }\n\n get config(): AwsCodeCommitIntegrationConfig {\n return this.integrationConfig;\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n constructor(\n private readonly integrationConfig: AwsCodeCommitIntegrationConfig,\n ) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n resolveEditUrl(url: string): string {\n const parsedUrl = new URL(url);\n const pathMatch = parsedUrl.pathname.match(\n /^\\/codesuite\\/codecommit\\/repositories\\/([^\\/]+)\\//,\n );\n if (!pathMatch) {\n throw new Error(``);\n }\n const [, repositoryName] = pathMatch;\n return replaceCodeCommitUrlType(url, repositoryName, 'edit');\n }\n}\n\n/**\n * Takes a CodeCommit URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'edit'\n * @public\n */\nexport function replaceCodeCommitUrlType(\n url: string,\n repositoryName: string,\n type: 'browse' | 'edit',\n): string {\n const newString = type === 'edit' ? `files/edit` : type;\n return url.replace(\n new RegExp(\n `\\/codesuite\\/codecommit\\/repositories\\/${repositoryName}\\/(browse|files\\/edit)\\/`,\n ),\n `/codesuite/codecommit/repositories/${repositoryName}/${newString}/`,\n );\n}\n"],"names":["config","readAwsCodeCommitIntegrationConfigs","basicIntegrations","defaultScmResolveUrl"],"mappings":";;;;;AA4BO,MAAM,wBAAA,CAAmD;AAAA,EAyB9D,YACmB,iBAAA,EACjB;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAChB;AAAA,EA1BH,OAAO,UAA4D,CAAC;AAAA,YAClEA;AAAA,GACF,KAAM;AACJ,IAAA,MAAM,OAAA,GAAUC,0CAAA;AAAA,MACdD,QAAA,CAAO,sBAAA,CAAuB,4BAA4B,CAAA,IAAK;AAAC,KAClE;AACA,IAAA,OAAOE,yBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,wBAAA,CAAyB,CAAC,CAAC,CAAA;AAAA,MAChD,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAAA,EACF,CAAA;AAAA,EAEA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,eAAA;AAAA,EACT;AAAA,EAEA,IAAI,MAAA,GAAyC;AAC3C,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EACd;AAAA,EAEA,IAAI,KAAA,GAAgB;AAClB,IAAA,OAAO,KAAK,iBAAA,CAAkB,IAAA;AAAA,EAChC;AAAA,EAMA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,QAAA,GAAWC,6BAAqB,OAAO,CAAA;AAC7C,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EACA,eAAe,GAAA,EAAqB;AAClC,IAAA,MAAM,SAAA,GAAY,IAAI,GAAA,CAAI,GAAG,CAAA;AAC7B,IAAA,MAAM,SAAA,GAAY,UAAU,QAAA,CAAS,KAAA;AAAA,MACnC;AAAA,KACF;AACA,IAAA,IAAI,CAAC,SAAA,EAAW;AACd,MAAA,MAAM,IAAI,MAAM,CAAA,CAAE,CAAA;AAAA,IACpB;AACA,IAAA,MAAM,GAAG,cAAc,CAAA,GAAI,SAAA;AAC3B,IAAA,OAAO,wBAAA,CAAyB,GAAA,EAAK,cAAsB,CAAA;AAAA,EAC7D;AACF;AASO,SAAS,wBAAA,CACd,GAAA,EACA,cAAA,EACA,IAAA,EACQ;AACR,EAAA,MAAM,SAAA,GAA8B,CAAA,UAAA,CAAA,CAAe;AACnD,EAAA,OAAO,GAAA,CAAI,OAAA;AAAA,IACT,IAAI,MAAA;AAAA,MACF,sCAA0C,cAAc,CAAA,qBAAA;AAAA,KAC1D;AAAA,IACA,CAAA,mCAAA,EAAsC,cAAc,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA;AAAA,GACnE;AACF;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AwsCodeCommitIntegration.esm.js","sources":["../../src/awsCodeCommit/AwsCodeCommitIntegration.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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n AwsCodeCommitIntegrationConfig,\n readAwsCodeCommitIntegrationConfigs,\n} from './config';\n\n/**\n * Integrates with AWS CodeCommit.\n *\n * @public\n */\nexport class AwsCodeCommitIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsCodeCommitIntegration> = ({\n config,\n }) => {\n const configs = readAwsCodeCommitIntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsCodeCommit') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsCodeCommitIntegration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsCodeCommit';\n }\n\n get config(): AwsCodeCommitIntegrationConfig {\n return this.integrationConfig;\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n constructor(\n private readonly integrationConfig: AwsCodeCommitIntegrationConfig,\n ) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n resolveEditUrl(url: string): string {\n const parsedUrl = new URL(url);\n const pathMatch = parsedUrl.pathname.match(\n /^\\/codesuite\\/codecommit\\/repositories\\/([^\\/]+)\\//,\n );\n if (!pathMatch) {\n throw new Error(``);\n }\n const [, repositoryName] = pathMatch;\n return replaceCodeCommitUrlType(url, repositoryName, 'edit');\n }\n}\n\n/**\n * Takes a CodeCommit URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'edit'\n * @public\n */\nexport function replaceCodeCommitUrlType(\n url: string,\n repositoryName: string,\n type: 'browse' | 'edit',\n): string {\n const newString = type === 'edit' ? `files/edit` : type;\n return url.replace(\n new RegExp(\n `\\/codesuite\\/codecommit\\/repositories\\/${repositoryName}\\/(browse|files\\/edit)\\/`,\n ),\n `/codesuite/codecommit/repositories/${repositoryName}/${newString}/`,\n );\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,wBAAmD,CAAA;AAAA,EAyB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CAAA;AACnD,EAAA,OAAO,GAAI,CAAA,OAAA;AAAA,IACT,IAAI,MAAA;AAAA,MACF,sCAA0C,cAAc,CAAA,qBAAA;AAAA,KAC1D;AAAA,IACA,CAAA,mCAAA,EAAsC,cAAc,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA;AAAA,GACnE;AACF;;;;"}
1
+ {"version":3,"file":"AwsCodeCommitIntegration.esm.js","sources":["../../src/awsCodeCommit/AwsCodeCommitIntegration.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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n AwsCodeCommitIntegrationConfig,\n readAwsCodeCommitIntegrationConfigs,\n} from './config';\n\n/**\n * Integrates with AWS CodeCommit.\n *\n * @public\n */\nexport class AwsCodeCommitIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsCodeCommitIntegration> = ({\n config,\n }) => {\n const configs = readAwsCodeCommitIntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsCodeCommit') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsCodeCommitIntegration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsCodeCommit';\n }\n\n get config(): AwsCodeCommitIntegrationConfig {\n return this.integrationConfig;\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n constructor(\n private readonly integrationConfig: AwsCodeCommitIntegrationConfig,\n ) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n resolveEditUrl(url: string): string {\n const parsedUrl = new URL(url);\n const pathMatch = parsedUrl.pathname.match(\n /^\\/codesuite\\/codecommit\\/repositories\\/([^\\/]+)\\//,\n );\n if (!pathMatch) {\n throw new Error(``);\n }\n const [, repositoryName] = pathMatch;\n return replaceCodeCommitUrlType(url, repositoryName, 'edit');\n }\n}\n\n/**\n * Takes a CodeCommit URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'edit'\n * @public\n */\nexport function replaceCodeCommitUrlType(\n url: string,\n repositoryName: string,\n type: 'browse' | 'edit',\n): string {\n const newString = type === 'edit' ? `files/edit` : type;\n return url.replace(\n new RegExp(\n `\\/codesuite\\/codecommit\\/repositories\\/${repositoryName}\\/(browse|files\\/edit)\\/`,\n ),\n `/codesuite/codecommit/repositories/${repositoryName}/${newString}/`,\n );\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,wBAAA,CAAmD;AAAA,EAyB9D,YACmB,iBAAA,EACjB;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAChB;AAAA,EA1BH,OAAO,UAA4D,CAAC;AAAA,IAClE;AAAA,GACF,KAAM;AACJ,IAAA,MAAM,OAAA,GAAU,mCAAA;AAAA,MACd,MAAA,CAAO,sBAAA,CAAuB,4BAA4B,CAAA,IAAK;AAAC,KAClE;AACA,IAAA,OAAO,iBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,wBAAA,CAAyB,CAAC,CAAC,CAAA;AAAA,MAChD,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAAA,EACF,CAAA;AAAA,EAEA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,eAAA;AAAA,EACT;AAAA,EAEA,IAAI,MAAA,GAAyC;AAC3C,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EACd;AAAA,EAEA,IAAI,KAAA,GAAgB;AAClB,IAAA,OAAO,KAAK,iBAAA,CAAkB,IAAA;AAAA,EAChC;AAAA,EAMA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,QAAA,GAAW,qBAAqB,OAAO,CAAA;AAC7C,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EACA,eAAe,GAAA,EAAqB;AAClC,IAAA,MAAM,SAAA,GAAY,IAAI,GAAA,CAAI,GAAG,CAAA;AAC7B,IAAA,MAAM,SAAA,GAAY,UAAU,QAAA,CAAS,KAAA;AAAA,MACnC;AAAA,KACF;AACA,IAAA,IAAI,CAAC,SAAA,EAAW;AACd,MAAA,MAAM,IAAI,MAAM,CAAA,CAAE,CAAA;AAAA,IACpB;AACA,IAAA,MAAM,GAAG,cAAc,CAAA,GAAI,SAAA;AAC3B,IAAA,OAAO,wBAAA,CAAyB,GAAA,EAAK,cAAsB,CAAA;AAAA,EAC7D;AACF;AASO,SAAS,wBAAA,CACd,GAAA,EACA,cAAA,EACA,IAAA,EACQ;AACR,EAAA,MAAM,SAAA,GAA8B,CAAA,UAAA,CAAA,CAAe;AACnD,EAAA,OAAO,GAAA,CAAI,OAAA;AAAA,IACT,IAAI,MAAA;AAAA,MACF,sCAA0C,cAAc,CAAA,qBAAA;AAAA,KAC1D;AAAA,IACA,CAAA,mCAAA,EAAsC,cAAc,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA;AAAA,GACnE;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/awsCodeCommit/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';\n\nconst AMAZON_AWS_CODECOMMIT_HOST = 'console.aws.amazon.com';\n\n/**\n * The configuration parameters for a single AWS CodeCommit provider.\n *\n * @public\n */\nexport type AwsCodeCommitIntegrationConfig = {\n /**\n * Host, git host derived from region\n */\n host: string;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n\n /**\n * region to use for AWS (default: us-east-1)\n */\n region: string;\n};\n\n/**\n * Reads a single Aws CodeCommit integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsCodeCommitIntegrationConfig(\n config: Config,\n): AwsCodeCommitIntegrationConfig {\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n const region = config.getString('region');\n const host =\n config.getOptionalString('host') ||\n `${region}.${AMAZON_AWS_CODECOMMIT_HOST}`;\n\n return {\n host,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n region,\n };\n}\n\n/**\n * Reads a set of AWS CodeCommit integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsCodeCommitIntegrationConfigs(\n configs: Config[],\n): AwsCodeCommitIntegrationConfig[] {\n return configs.map(readAwsCodeCommitIntegrationConfig);\n}\n"],"names":[],"mappings":";;AAkBA,MAAM,0BAA6B,GAAA,wBAAA;AA8C5B,SAAS,mCACd,MACgC,EAAA;AAChC,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,iBAAA,CAAkB,aAAa,CAAA;AAC1D,EAAA,MAAM,eAAkB,GAAA,MAAA,CAAO,iBAAkB,CAAA,iBAAiB,GAAG,IAAK,EAAA;AAC1E,EAAM,MAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAClD,EAAM,MAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA;AACxD,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,QAAQ,CAAA;AACxC,EAAM,MAAA,IAAA,GACJ,OAAO,iBAAkB,CAAA,MAAM,KAC/B,CAAG,EAAA,MAAM,IAAI,0BAA0B,CAAA,CAAA;AAEzC,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF;AASO,SAAS,oCACd,OACkC,EAAA;AAClC,EAAO,OAAA,OAAA,CAAQ,IAAI,kCAAkC,CAAA;AACvD;;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../../src/awsCodeCommit/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';\n\nconst AMAZON_AWS_CODECOMMIT_HOST = 'console.aws.amazon.com';\n\n/**\n * The configuration parameters for a single AWS CodeCommit provider.\n *\n * @public\n */\nexport type AwsCodeCommitIntegrationConfig = {\n /**\n * Host, git host derived from region\n */\n host: string;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n\n /**\n * region to use for AWS (default: us-east-1)\n */\n region: string;\n};\n\n/**\n * Reads a single Aws CodeCommit integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsCodeCommitIntegrationConfig(\n config: Config,\n): AwsCodeCommitIntegrationConfig {\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n const region = config.getString('region');\n const host =\n config.getOptionalString('host') ||\n `${region}.${AMAZON_AWS_CODECOMMIT_HOST}`;\n\n return {\n host,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n region,\n };\n}\n\n/**\n * Reads a set of AWS CodeCommit integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsCodeCommitIntegrationConfigs(\n configs: Config[],\n): AwsCodeCommitIntegrationConfig[] {\n return configs.map(readAwsCodeCommitIntegrationConfig);\n}\n"],"names":[],"mappings":";;AAkBA,MAAM,0BAAA,GAA6B,wBAAA;AA8C5B,SAAS,mCACd,MAAA,EACgC;AAChC,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA;AAC1D,EAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,iBAAA,CAAkB,iBAAiB,GAAG,IAAA,EAAK;AAC1E,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,iBAAA,CAAkB,SAAS,CAAA;AAClD,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AACxD,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,QAAQ,CAAA;AACxC,EAAA,MAAM,IAAA,GACJ,OAAO,iBAAA,CAAkB,MAAM,KAC/B,CAAA,EAAG,MAAM,IAAI,0BAA0B,CAAA,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF;AASO,SAAS,oCACd,OAAA,EACkC;AAClC,EAAA,OAAO,OAAA,CAAQ,IAAI,kCAAkC,CAAA;AACvD;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/awsCodeCommit/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';\n\nconst AMAZON_AWS_CODECOMMIT_HOST = 'console.aws.amazon.com';\n\n/**\n * The configuration parameters for a single AWS CodeCommit provider.\n *\n * @public\n */\nexport type AwsCodeCommitIntegrationConfig = {\n /**\n * Host, git host derived from region\n */\n host: string;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n\n /**\n * region to use for AWS (default: us-east-1)\n */\n region: string;\n};\n\n/**\n * Reads a single Aws CodeCommit integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsCodeCommitIntegrationConfig(\n config: Config,\n): AwsCodeCommitIntegrationConfig {\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n const region = config.getString('region');\n const host =\n config.getOptionalString('host') ||\n `${region}.${AMAZON_AWS_CODECOMMIT_HOST}`;\n\n return {\n host,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n region,\n };\n}\n\n/**\n * Reads a set of AWS CodeCommit integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsCodeCommitIntegrationConfigs(\n configs: Config[],\n): AwsCodeCommitIntegrationConfig[] {\n return configs.map(readAwsCodeCommitIntegrationConfig);\n}\n"],"names":[],"mappings":"AAkBA,MAAM,0BAA6B,GAAA,wBAAA;AA8C5B,SAAS,mCACd,MACgC,EAAA;AAChC,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,iBAAA,CAAkB,aAAa,CAAA;AAC1D,EAAA,MAAM,eAAkB,GAAA,MAAA,CAAO,iBAAkB,CAAA,iBAAiB,GAAG,IAAK,EAAA;AAC1E,EAAM,MAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAClD,EAAM,MAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA;AACxD,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,QAAQ,CAAA;AACxC,EAAM,MAAA,IAAA,GACJ,OAAO,iBAAkB,CAAA,MAAM,KAC/B,CAAG,EAAA,MAAM,IAAI,0BAA0B,CAAA,CAAA;AAEzC,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF;AASO,SAAS,oCACd,OACkC,EAAA;AAClC,EAAO,OAAA,OAAA,CAAQ,IAAI,kCAAkC,CAAA;AACvD;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/awsCodeCommit/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';\n\nconst AMAZON_AWS_CODECOMMIT_HOST = 'console.aws.amazon.com';\n\n/**\n * The configuration parameters for a single AWS CodeCommit provider.\n *\n * @public\n */\nexport type AwsCodeCommitIntegrationConfig = {\n /**\n * Host, git host derived from region\n */\n host: string;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n\n /**\n * region to use for AWS (default: us-east-1)\n */\n region: string;\n};\n\n/**\n * Reads a single Aws CodeCommit integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsCodeCommitIntegrationConfig(\n config: Config,\n): AwsCodeCommitIntegrationConfig {\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n const region = config.getString('region');\n const host =\n config.getOptionalString('host') ||\n `${region}.${AMAZON_AWS_CODECOMMIT_HOST}`;\n\n return {\n host,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n region,\n };\n}\n\n/**\n * Reads a set of AWS CodeCommit integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsCodeCommitIntegrationConfigs(\n configs: Config[],\n): AwsCodeCommitIntegrationConfig[] {\n return configs.map(readAwsCodeCommitIntegrationConfig);\n}\n"],"names":[],"mappings":"AAkBA,MAAM,0BAAA,GAA6B,wBAAA;AA8C5B,SAAS,mCACd,MAAA,EACgC;AAChC,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA;AAC1D,EAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,iBAAA,CAAkB,iBAAiB,GAAG,IAAA,EAAK;AAC1E,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,iBAAA,CAAkB,SAAS,CAAA;AAClD,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AACxD,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,QAAQ,CAAA;AACxC,EAAA,MAAM,IAAA,GACJ,OAAO,iBAAA,CAAkB,MAAM,KAC/B,CAAA,EAAG,MAAM,IAAI,0BAA0B,CAAA,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF;AASO,SAAS,oCACd,OAAA,EACkC;AAClC,EAAA,OAAO,OAAA,CAAQ,IAAI,kCAAkC,CAAA;AACvD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AwsS3Integration.cjs.js","sources":["../../src/awsS3/AwsS3Integration.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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AwsS3IntegrationConfig, readAwsS3IntegrationConfigs } from './config';\n\n/**\n * Integrates with AWS S3 or compatible solutions.\n *\n * @public\n */\nexport class AwsS3Integration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsS3Integration> = ({ config }) => {\n const configs = readAwsS3IntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsS3') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsS3Integration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsS3';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AwsS3IntegrationConfig {\n return this.integrationConfig;\n }\n\n constructor(private readonly integrationConfig: AwsS3IntegrationConfig) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for awsS3\n return url;\n }\n}\n"],"names":["config","readAwsS3IntegrationConfigs","basicIntegrations","defaultScmResolveUrl"],"mappings":";;;;;AAyBO,MAAM,gBAA2C,CAAA;AAAA,EAuBtD,YAA6B,iBAA2C,EAAA;AAA3C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAA4C,EAtBzE,OAAO,OAAA,GAAoD,CAAC,UAAEA,UAAa,KAAA;AACzE,IAAA,MAAM,OAAU,GAAAC,kCAAA;AAAA,MACdD,QAAO,CAAA,sBAAA,CAAuB,oBAAoB,CAAA,IAAK;AAAC,KAC1D;AACA,IAAO,OAAAE,yBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,gBAAA,CAAiB,CAAC,CAAC,CAAA;AAAA,MACxC,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA;AAAA,KAChB;AAAA,GACF;AAAA,EAEA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,OAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA;AAAA;AAChC,EAEA,IAAI,MAAiC,GAAA;AACnC,IAAA,OAAO,IAAK,CAAA,iBAAA;AAAA;AACd,EAIA,WAAW,OAIA,EAAA;AACT,IAAM,MAAA,QAAA,GAAWC,6BAAqB,OAAO,CAAA;AAC7C,IAAO,OAAA,QAAA;AAAA;AACT,EAEA,eAAe,GAAqB,EAAA;AAElC,IAAO,OAAA,GAAA;AAAA;AAEX;;;;"}
1
+ {"version":3,"file":"AwsS3Integration.cjs.js","sources":["../../src/awsS3/AwsS3Integration.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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AwsS3IntegrationConfig, readAwsS3IntegrationConfigs } from './config';\n\n/**\n * Integrates with AWS S3 or compatible solutions.\n *\n * @public\n */\nexport class AwsS3Integration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsS3Integration> = ({ config }) => {\n const configs = readAwsS3IntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsS3') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsS3Integration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsS3';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AwsS3IntegrationConfig {\n return this.integrationConfig;\n }\n\n constructor(private readonly integrationConfig: AwsS3IntegrationConfig) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for awsS3\n return url;\n }\n}\n"],"names":["config","readAwsS3IntegrationConfigs","basicIntegrations","defaultScmResolveUrl"],"mappings":";;;;;AAyBO,MAAM,gBAAA,CAA2C;AAAA,EAuBtD,YAA6B,iBAAA,EAA2C;AAA3C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAA4C;AAAA,EAtBzE,OAAO,OAAA,GAAoD,CAAC,UAAEA,UAAO,KAAM;AACzE,IAAA,MAAM,OAAA,GAAUC,kCAAA;AAAA,MACdD,QAAA,CAAO,sBAAA,CAAuB,oBAAoB,CAAA,IAAK;AAAC,KAC1D;AACA,IAAA,OAAOE,yBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,gBAAA,CAAiB,CAAC,CAAC,CAAA;AAAA,MACxC,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAAA,EACF,CAAA;AAAA,EAEA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,OAAA;AAAA,EACT;AAAA,EAEA,IAAI,KAAA,GAAgB;AAClB,IAAA,OAAO,KAAK,iBAAA,CAAkB,IAAA;AAAA,EAChC;AAAA,EAEA,IAAI,MAAA,GAAiC;AACnC,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EACd;AAAA,EAIA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,QAAA,GAAWC,6BAAqB,OAAO,CAAA;AAC7C,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EAEA,eAAe,GAAA,EAAqB;AAElC,IAAA,OAAO,GAAA;AAAA,EACT;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AwsS3Integration.esm.js","sources":["../../src/awsS3/AwsS3Integration.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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AwsS3IntegrationConfig, readAwsS3IntegrationConfigs } from './config';\n\n/**\n * Integrates with AWS S3 or compatible solutions.\n *\n * @public\n */\nexport class AwsS3Integration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsS3Integration> = ({ config }) => {\n const configs = readAwsS3IntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsS3') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsS3Integration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsS3';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AwsS3IntegrationConfig {\n return this.integrationConfig;\n }\n\n constructor(private readonly integrationConfig: AwsS3IntegrationConfig) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for awsS3\n return url;\n }\n}\n"],"names":[],"mappings":";;;AAyBO,MAAM,gBAA2C,CAAA;AAAA,EAuBtD,YAA6B,iBAA2C,EAAA;AAA3C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAA4C,EAtBzE,OAAO,OAAA,GAAoD,CAAC,EAAE,QAAa,KAAA;AACzE,IAAA,MAAM,OAAU,GAAA,2BAAA;AAAA,MACd,MAAO,CAAA,sBAAA,CAAuB,oBAAoB,CAAA,IAAK;AAAC,KAC1D;AACA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,gBAAA,CAAiB,CAAC,CAAC,CAAA;AAAA,MACxC,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA;AAAA,KAChB;AAAA,GACF;AAAA,EAEA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,OAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA;AAAA;AAChC,EAEA,IAAI,MAAiC,GAAA;AACnC,IAAA,OAAO,IAAK,CAAA,iBAAA;AAAA;AACd,EAIA,WAAW,OAIA,EAAA;AACT,IAAM,MAAA,QAAA,GAAW,qBAAqB,OAAO,CAAA;AAC7C,IAAO,OAAA,QAAA;AAAA;AACT,EAEA,eAAe,GAAqB,EAAA;AAElC,IAAO,OAAA,GAAA;AAAA;AAEX;;;;"}
1
+ {"version":3,"file":"AwsS3Integration.esm.js","sources":["../../src/awsS3/AwsS3Integration.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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AwsS3IntegrationConfig, readAwsS3IntegrationConfigs } from './config';\n\n/**\n * Integrates with AWS S3 or compatible solutions.\n *\n * @public\n */\nexport class AwsS3Integration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsS3Integration> = ({ config }) => {\n const configs = readAwsS3IntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsS3') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsS3Integration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsS3';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AwsS3IntegrationConfig {\n return this.integrationConfig;\n }\n\n constructor(private readonly integrationConfig: AwsS3IntegrationConfig) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for awsS3\n return url;\n }\n}\n"],"names":[],"mappings":";;;AAyBO,MAAM,gBAAA,CAA2C;AAAA,EAuBtD,YAA6B,iBAAA,EAA2C;AAA3C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAA4C;AAAA,EAtBzE,OAAO,OAAA,GAAoD,CAAC,EAAE,QAAO,KAAM;AACzE,IAAA,MAAM,OAAA,GAAU,2BAAA;AAAA,MACd,MAAA,CAAO,sBAAA,CAAuB,oBAAoB,CAAA,IAAK;AAAC,KAC1D;AACA,IAAA,OAAO,iBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,gBAAA,CAAiB,CAAC,CAAC,CAAA;AAAA,MACxC,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAAA,EACF,CAAA;AAAA,EAEA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,OAAA;AAAA,EACT;AAAA,EAEA,IAAI,KAAA,GAAgB;AAClB,IAAA,OAAO,KAAK,iBAAA,CAAkB,IAAA;AAAA,EAChC;AAAA,EAEA,IAAI,MAAA,GAAiC;AACnC,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EACd;AAAA,EAIA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,QAAA,GAAW,qBAAqB,OAAO,CAAA;AAC7C,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EAEA,eAAe,GAAA,EAAqB;AAElC,IAAA,OAAO,GAAA;AAAA,EACT;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/awsS3/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';\n\nconst AMAZON_AWS_HOST = 'amazonaws.com';\n\n/**\n * The configuration parameters for a single AWS S3 provider.\n *\n * @public\n */\nexport type AwsS3IntegrationConfig = {\n /**\n * Host, derived from endpoint, and defaults to amazonaws.com\n */\n host: string;\n\n /**\n * (Optional) AWS Endpoint.\n * The endpoint URI to send requests to. The default endpoint is built from the configured region.\n * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property\n *\n * Supports non-AWS providers, e.g. for LocalStack, endpoint may look like http://localhost:4566\n */\n endpoint?: string;\n\n /**\n * (Optional) Whether to use path style URLs when communicating with S3.\n * Defaults to false.\n * This allows providers like LocalStack, Minio and Wasabi (and possibly others) to be used.\n */\n s3ForcePathStyle?: boolean;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n};\n\n/**\n * Reads a single Aws S3 integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsS3IntegrationConfig(\n config: Config,\n): AwsS3IntegrationConfig {\n const endpoint = config.getOptionalString('endpoint');\n const s3ForcePathStyle =\n config.getOptionalBoolean('s3ForcePathStyle') ?? false;\n let host;\n let pathname;\n if (endpoint) {\n try {\n const url = new URL(endpoint);\n host = url.host;\n pathname = url.pathname;\n } catch {\n throw new Error(\n `invalid awsS3 integration config, endpoint '${endpoint}' is not a valid URL`,\n );\n }\n if (pathname !== '/') {\n throw new Error(\n `invalid awsS3 integration config, endpoints cannot contain path, got '${endpoint}'`,\n );\n }\n } else {\n host = AMAZON_AWS_HOST;\n }\n\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n\n return {\n host,\n endpoint,\n s3ForcePathStyle,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n };\n}\n\n/**\n * Reads a set of AWS S3 integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsS3IntegrationConfigs(\n configs: Config[],\n): AwsS3IntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readAwsS3IntegrationConfig);\n\n // If no explicit amazonaws.com integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === AMAZON_AWS_HOST)) {\n result.push({\n host: AMAZON_AWS_HOST,\n });\n }\n return result;\n}\n"],"names":[],"mappings":";;AAkBA,MAAM,eAAkB,GAAA,eAAA;AAyDjB,SAAS,2BACd,MACwB,EAAA;AACxB,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,gBACJ,GAAA,MAAA,CAAO,kBAAmB,CAAA,kBAAkB,CAAK,IAAA,KAAA;AACnD,EAAI,IAAA,IAAA;AACJ,EAAI,IAAA,QAAA;AACJ,EAAA,IAAI,QAAU,EAAA;AACZ,IAAI,IAAA;AACF,MAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAC5B,MAAA,IAAA,GAAO,GAAI,CAAA,IAAA;AACX,MAAA,QAAA,GAAW,GAAI,CAAA,QAAA;AAAA,KACT,CAAA,MAAA;AACN,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,+CAA+C,QAAQ,CAAA,oBAAA;AAAA,OACzD;AAAA;AAEF,IAAA,IAAI,aAAa,GAAK,EAAA;AACpB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,yEAAyE,QAAQ,CAAA,CAAA;AAAA,OACnF;AAAA;AACF,GACK,MAAA;AACL,IAAO,IAAA,GAAA,eAAA;AAAA;AAGT,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,iBAAA,CAAkB,aAAa,CAAA;AAC1D,EAAA,MAAM,eAAkB,GAAA,MAAA,CAAO,iBAAkB,CAAA,iBAAiB,GAAG,IAAK,EAAA;AAC1E,EAAM,MAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAClD,EAAM,MAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA;AAExD,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF;AASO,SAAS,4BACd,OAC0B,EAAA;AAE1B,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,0BAA0B,CAAA;AAIrD,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,eAAe,CAAG,EAAA;AACjD,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA;AAAA,KACP,CAAA;AAAA;AAEH,EAAO,OAAA,MAAA;AACT;;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../../src/awsS3/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';\n\nconst AMAZON_AWS_HOST = 'amazonaws.com';\n\n/**\n * The configuration parameters for a single AWS S3 provider.\n *\n * @public\n */\nexport type AwsS3IntegrationConfig = {\n /**\n * Host, derived from endpoint, and defaults to amazonaws.com\n */\n host: string;\n\n /**\n * (Optional) AWS Endpoint.\n * The endpoint URI to send requests to. The default endpoint is built from the configured region.\n * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property\n *\n * Supports non-AWS providers, e.g. for LocalStack, endpoint may look like http://localhost:4566\n */\n endpoint?: string;\n\n /**\n * (Optional) Whether to use path style URLs when communicating with S3.\n * Defaults to false.\n * This allows providers like LocalStack, Minio and Wasabi (and possibly others) to be used.\n */\n s3ForcePathStyle?: boolean;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n};\n\n/**\n * Reads a single Aws S3 integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsS3IntegrationConfig(\n config: Config,\n): AwsS3IntegrationConfig {\n const endpoint = config.getOptionalString('endpoint');\n const s3ForcePathStyle =\n config.getOptionalBoolean('s3ForcePathStyle') ?? false;\n let host;\n let pathname;\n if (endpoint) {\n try {\n const url = new URL(endpoint);\n host = url.host;\n pathname = url.pathname;\n } catch {\n throw new Error(\n `invalid awsS3 integration config, endpoint '${endpoint}' is not a valid URL`,\n );\n }\n if (pathname !== '/') {\n throw new Error(\n `invalid awsS3 integration config, endpoints cannot contain path, got '${endpoint}'`,\n );\n }\n } else {\n host = AMAZON_AWS_HOST;\n }\n\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n\n return {\n host,\n endpoint,\n s3ForcePathStyle,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n };\n}\n\n/**\n * Reads a set of AWS S3 integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsS3IntegrationConfigs(\n configs: Config[],\n): AwsS3IntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readAwsS3IntegrationConfig);\n\n // If no explicit amazonaws.com integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === AMAZON_AWS_HOST)) {\n result.push({\n host: AMAZON_AWS_HOST,\n });\n }\n return result;\n}\n"],"names":[],"mappings":";;AAkBA,MAAM,eAAA,GAAkB,eAAA;AAyDjB,SAAS,2BACd,MAAA,EACwB;AACxB,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,gBAAA,GACJ,MAAA,CAAO,kBAAA,CAAmB,kBAAkB,CAAA,IAAK,KAAA;AACnD,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,IAAI;AACF,MAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAC5B,MAAA,IAAA,GAAO,GAAA,CAAI,IAAA;AACX,MAAA,QAAA,GAAW,GAAA,CAAI,QAAA;AAAA,IACjB,CAAA,CAAA,MAAQ;AACN,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,+CAA+C,QAAQ,CAAA,oBAAA;AAAA,OACzD;AAAA,IACF;AACA,IAAA,IAAI,aAAa,GAAA,EAAK;AACpB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,yEAAyE,QAAQ,CAAA,CAAA;AAAA,OACnF;AAAA,IACF;AAAA,EACF,CAAA,MAAO;AACL,IAAA,IAAA,GAAO,eAAA;AAAA,EACT;AAEA,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA;AAC1D,EAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,iBAAA,CAAkB,iBAAiB,GAAG,IAAA,EAAK;AAC1E,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,iBAAA,CAAkB,SAAS,CAAA;AAClD,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AAExD,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF;AASO,SAAS,4BACd,OAAA,EAC0B;AAE1B,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,0BAA0B,CAAA;AAIrD,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,eAAe,CAAA,EAAG;AACjD,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACA,EAAA,OAAO,MAAA;AACT;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/awsS3/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';\n\nconst AMAZON_AWS_HOST = 'amazonaws.com';\n\n/**\n * The configuration parameters for a single AWS S3 provider.\n *\n * @public\n */\nexport type AwsS3IntegrationConfig = {\n /**\n * Host, derived from endpoint, and defaults to amazonaws.com\n */\n host: string;\n\n /**\n * (Optional) AWS Endpoint.\n * The endpoint URI to send requests to. The default endpoint is built from the configured region.\n * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property\n *\n * Supports non-AWS providers, e.g. for LocalStack, endpoint may look like http://localhost:4566\n */\n endpoint?: string;\n\n /**\n * (Optional) Whether to use path style URLs when communicating with S3.\n * Defaults to false.\n * This allows providers like LocalStack, Minio and Wasabi (and possibly others) to be used.\n */\n s3ForcePathStyle?: boolean;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n};\n\n/**\n * Reads a single Aws S3 integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsS3IntegrationConfig(\n config: Config,\n): AwsS3IntegrationConfig {\n const endpoint = config.getOptionalString('endpoint');\n const s3ForcePathStyle =\n config.getOptionalBoolean('s3ForcePathStyle') ?? false;\n let host;\n let pathname;\n if (endpoint) {\n try {\n const url = new URL(endpoint);\n host = url.host;\n pathname = url.pathname;\n } catch {\n throw new Error(\n `invalid awsS3 integration config, endpoint '${endpoint}' is not a valid URL`,\n );\n }\n if (pathname !== '/') {\n throw new Error(\n `invalid awsS3 integration config, endpoints cannot contain path, got '${endpoint}'`,\n );\n }\n } else {\n host = AMAZON_AWS_HOST;\n }\n\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n\n return {\n host,\n endpoint,\n s3ForcePathStyle,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n };\n}\n\n/**\n * Reads a set of AWS S3 integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsS3IntegrationConfigs(\n configs: Config[],\n): AwsS3IntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readAwsS3IntegrationConfig);\n\n // If no explicit amazonaws.com integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === AMAZON_AWS_HOST)) {\n result.push({\n host: AMAZON_AWS_HOST,\n });\n }\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,eAAkB,GAAA,eAAA;AAyDjB,SAAS,2BACd,MACwB,EAAA;AACxB,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,gBACJ,GAAA,MAAA,CAAO,kBAAmB,CAAA,kBAAkB,CAAK,IAAA,KAAA;AACnD,EAAI,IAAA,IAAA;AACJ,EAAI,IAAA,QAAA;AACJ,EAAA,IAAI,QAAU,EAAA;AACZ,IAAI,IAAA;AACF,MAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAC5B,MAAA,IAAA,GAAO,GAAI,CAAA,IAAA;AACX,MAAA,QAAA,GAAW,GAAI,CAAA,QAAA;AAAA,KACT,CAAA,MAAA;AACN,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,+CAA+C,QAAQ,CAAA,oBAAA;AAAA,OACzD;AAAA;AAEF,IAAA,IAAI,aAAa,GAAK,EAAA;AACpB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,yEAAyE,QAAQ,CAAA,CAAA;AAAA,OACnF;AAAA;AACF,GACK,MAAA;AACL,IAAO,IAAA,GAAA,eAAA;AAAA;AAGT,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,iBAAA,CAAkB,aAAa,CAAA;AAC1D,EAAA,MAAM,eAAkB,GAAA,MAAA,CAAO,iBAAkB,CAAA,iBAAiB,GAAG,IAAK,EAAA;AAC1E,EAAM,MAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAClD,EAAM,MAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA;AAExD,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF;AASO,SAAS,4BACd,OAC0B,EAAA;AAE1B,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,0BAA0B,CAAA;AAIrD,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,eAAe,CAAG,EAAA;AACjD,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA;AAAA,KACP,CAAA;AAAA;AAEH,EAAO,OAAA,MAAA;AACT;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/awsS3/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';\n\nconst AMAZON_AWS_HOST = 'amazonaws.com';\n\n/**\n * The configuration parameters for a single AWS S3 provider.\n *\n * @public\n */\nexport type AwsS3IntegrationConfig = {\n /**\n * Host, derived from endpoint, and defaults to amazonaws.com\n */\n host: string;\n\n /**\n * (Optional) AWS Endpoint.\n * The endpoint URI to send requests to. The default endpoint is built from the configured region.\n * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property\n *\n * Supports non-AWS providers, e.g. for LocalStack, endpoint may look like http://localhost:4566\n */\n endpoint?: string;\n\n /**\n * (Optional) Whether to use path style URLs when communicating with S3.\n * Defaults to false.\n * This allows providers like LocalStack, Minio and Wasabi (and possibly others) to be used.\n */\n s3ForcePathStyle?: boolean;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n};\n\n/**\n * Reads a single Aws S3 integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsS3IntegrationConfig(\n config: Config,\n): AwsS3IntegrationConfig {\n const endpoint = config.getOptionalString('endpoint');\n const s3ForcePathStyle =\n config.getOptionalBoolean('s3ForcePathStyle') ?? false;\n let host;\n let pathname;\n if (endpoint) {\n try {\n const url = new URL(endpoint);\n host = url.host;\n pathname = url.pathname;\n } catch {\n throw new Error(\n `invalid awsS3 integration config, endpoint '${endpoint}' is not a valid URL`,\n );\n }\n if (pathname !== '/') {\n throw new Error(\n `invalid awsS3 integration config, endpoints cannot contain path, got '${endpoint}'`,\n );\n }\n } else {\n host = AMAZON_AWS_HOST;\n }\n\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n\n return {\n host,\n endpoint,\n s3ForcePathStyle,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n };\n}\n\n/**\n * Reads a set of AWS S3 integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsS3IntegrationConfigs(\n configs: Config[],\n): AwsS3IntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readAwsS3IntegrationConfig);\n\n // If no explicit amazonaws.com integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === AMAZON_AWS_HOST)) {\n result.push({\n host: AMAZON_AWS_HOST,\n });\n }\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,eAAA,GAAkB,eAAA;AAyDjB,SAAS,2BACd,MAAA,EACwB;AACxB,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,gBAAA,GACJ,MAAA,CAAO,kBAAA,CAAmB,kBAAkB,CAAA,IAAK,KAAA;AACnD,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,IAAI;AACF,MAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAC5B,MAAA,IAAA,GAAO,GAAA,CAAI,IAAA;AACX,MAAA,QAAA,GAAW,GAAA,CAAI,QAAA;AAAA,IACjB,CAAA,CAAA,MAAQ;AACN,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,+CAA+C,QAAQ,CAAA,oBAAA;AAAA,OACzD;AAAA,IACF;AACA,IAAA,IAAI,aAAa,GAAA,EAAK;AACpB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,yEAAyE,QAAQ,CAAA,CAAA;AAAA,OACnF;AAAA,IACF;AAAA,EACF,CAAA,MAAO;AACL,IAAA,IAAA,GAAO,eAAA;AAAA,EACT;AAEA,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA;AAC1D,EAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,iBAAA,CAAkB,iBAAiB,GAAG,IAAA,EAAK;AAC1E,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,iBAAA,CAAkB,SAAS,CAAA;AAClD,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AAExD,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF;AASO,SAAS,4BACd,OAAA,EAC0B;AAE1B,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,0BAA0B,CAAA;AAIrD,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,eAAe,CAAA,EAAG;AACjD,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACA,EAAA,OAAO,MAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AzureIntegration.cjs.js","sources":["../../src/azure/AzureIntegration.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 { basicIntegrations, isValidUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AzureUrl } from './AzureUrl';\nimport { AzureIntegrationConfig, readAzureIntegrationConfigs } from './config';\n\n/**\n * Microsoft Azure based integration.\n *\n * @public\n */\nexport class AzureIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AzureIntegration> = ({ config }) => {\n const configs = readAzureIntegrationConfigs(\n config.getOptionalConfigArray('integrations.azure') ?? [],\n );\n\n return basicIntegrations(\n configs.map(c => new AzureIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: AzureIntegrationConfig) {}\n\n get type(): string {\n return 'azure';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AzureIntegrationConfig {\n return this.integrationConfig;\n }\n\n /*\n * Azure repo URLs on the form with a `path` query param are treated specially.\n *\n * Example base URL: https://dev.azure.com/organization/project/_git/repository?path=%2Fcatalog-info.yaml\n */\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const { url, base } = options;\n\n // If we can parse the url, it is absolute - then return it verbatim\n if (isValidUrl(url)) {\n return url;\n }\n\n try {\n const azureUrl = AzureUrl.fromRepoUrl(base);\n const newUrl = new URL(base);\n\n // We lean on the URL path resolution logic to resolve the path param\n const mockBaseUrl = new URL(`https://a.com${azureUrl.getPath() ?? ''}`);\n const updatedPath = new URL(url, mockBaseUrl).pathname;\n newUrl.searchParams.set('path', updatedPath);\n\n if (options.lineNumber) {\n newUrl.searchParams.set('line', String(options.lineNumber));\n newUrl.searchParams.set('lineEnd', String(options.lineNumber + 1));\n newUrl.searchParams.set('lineStartColumn', '1');\n newUrl.searchParams.set('lineEndColumn', '1');\n }\n\n return newUrl.toString();\n } catch {\n // If not an actual file path within a repo, treat the URL as raw\n return new URL(url, base).toString();\n }\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for Azure, fallback to view url as I don't know\n // how azure works.\n return url;\n }\n}\n"],"names":["config","readAzureIntegrationConfigs","basicIntegrations","isValidUrl","AzureUrl"],"mappings":";;;;;;AA0BO,MAAM,gBAA2C,CAAA;AAAA,EAYtD,YAA6B,iBAA2C,EAAA;AAA3C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAA4C,EAXzE,OAAO,OAAA,GAAoD,CAAC,UAAEA,UAAa,KAAA;AACzE,IAAA,MAAM,OAAU,GAAAC,kCAAA;AAAA,MACdD,QAAO,CAAA,sBAAA,CAAuB,oBAAoB,CAAA,IAAK;AAAC,KAC1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AAA,UAAA,GAAa,CAAC,CAAC,CAAA;AACjE,QAAO,MAAA,CAAA,YAAA,CAAa,GAAI,CAAA,iBAAA,EAAmB,GAAG,CAAA;AAC9C,QAAO,MAAA,CAAA,YAAA,CAAa,GAAI,CAAA,eAAA,EAAiB,GAAG,CAAA;AAAA;AAG9C,MAAA,OAAO,OAAO,QAAS,EAAA;AAAA,KACjB,CAAA,MAAA;AAEN,MAAA,OAAO,IAAI,GAAA,CAAI,GAAK,EAAA,IAAI,EAAE,QAAS,EAAA;AAAA;AACrC;AACF,EAEA,eAAe,GAAqB,EAAA;AAGlC,IAAO,OAAA,GAAA;AAAA;AAEX;;;;"}
1
+ {"version":3,"file":"AzureIntegration.cjs.js","sources":["../../src/azure/AzureIntegration.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 { basicIntegrations, isValidUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AzureUrl } from './AzureUrl';\nimport { AzureIntegrationConfig, readAzureIntegrationConfigs } from './config';\n\n/**\n * Microsoft Azure based integration.\n *\n * @public\n */\nexport class AzureIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AzureIntegration> = ({ config }) => {\n const configs = readAzureIntegrationConfigs(\n config.getOptionalConfigArray('integrations.azure') ?? [],\n );\n\n return basicIntegrations(\n configs.map(c => new AzureIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: AzureIntegrationConfig) {}\n\n get type(): string {\n return 'azure';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AzureIntegrationConfig {\n return this.integrationConfig;\n }\n\n /*\n * Azure repo URLs on the form with a `path` query param are treated specially.\n *\n * Example base URL: https://dev.azure.com/organization/project/_git/repository?path=%2Fcatalog-info.yaml\n */\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const { url, base } = options;\n\n // If we can parse the url, it is absolute - then return it verbatim\n if (isValidUrl(url)) {\n return url;\n }\n\n try {\n const azureUrl = AzureUrl.fromRepoUrl(base);\n const newUrl = new URL(base);\n\n // We lean on the URL path resolution logic to resolve the path param\n const mockBaseUrl = new URL(`https://a.com${azureUrl.getPath() ?? ''}`);\n const updatedPath = new URL(url, mockBaseUrl).pathname;\n newUrl.searchParams.set('path', updatedPath);\n\n if (options.lineNumber) {\n newUrl.searchParams.set('line', String(options.lineNumber));\n newUrl.searchParams.set('lineEnd', String(options.lineNumber + 1));\n newUrl.searchParams.set('lineStartColumn', '1');\n newUrl.searchParams.set('lineEndColumn', '1');\n }\n\n return newUrl.toString();\n } catch {\n // If not an actual file path within a repo, treat the URL as raw\n return new URL(url, base).toString();\n }\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for Azure, fallback to view url as I don't know\n // how azure works.\n return url;\n }\n}\n"],"names":["config","readAzureIntegrationConfigs","basicIntegrations","isValidUrl","AzureUrl"],"mappings":";;;;;;AA0BO,MAAM,gBAAA,CAA2C;AAAA,EAYtD,YAA6B,iBAAA,EAA2C;AAA3C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAA4C;AAAA,EAXzE,OAAO,OAAA,GAAoD,CAAC,UAAEA,UAAO,KAAM;AACzE,IAAA,MAAM,OAAA,GAAUC,kCAAA;AAAA,MACdD,QAAA,CAAO,sBAAA,CAAuB,oBAAoB,CAAA,IAAK;AAAC,KAC1D;AAEA,IAAA,OAAOE,yBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,gBAAA,CAAiB,CAAC,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A,CAAI,iBAAA,EAAmB,GAAG,CAAA;AAC9C,QAAA,MAAA,CAAO,YAAA,CAAa,GAAA,CAAI,eAAA,EAAiB,GAAG,CAAA;AAAA,MAC9C;AAEA,MAAA,OAAO,OAAO,QAAA,EAAS;AAAA,IACzB,CAAA,CAAA,MAAQ;AAEN,MAAA,OAAO,IAAI,GAAA,CAAI,GAAA,EAAK,IAAI,EAAE,QAAA,EAAS;AAAA,IACrC;AAAA,EACF;AAAA,EAEA,eAAe,GAAA,EAAqB;AAGlC,IAAA,OAAO,GAAA;AAAA,EACT;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AzureIntegration.esm.js","sources":["../../src/azure/AzureIntegration.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 { basicIntegrations, isValidUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AzureUrl } from './AzureUrl';\nimport { AzureIntegrationConfig, readAzureIntegrationConfigs } from './config';\n\n/**\n * Microsoft Azure based integration.\n *\n * @public\n */\nexport class AzureIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AzureIntegration> = ({ config }) => {\n const configs = readAzureIntegrationConfigs(\n config.getOptionalConfigArray('integrations.azure') ?? [],\n );\n\n return basicIntegrations(\n configs.map(c => new AzureIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: AzureIntegrationConfig) {}\n\n get type(): string {\n return 'azure';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AzureIntegrationConfig {\n return this.integrationConfig;\n }\n\n /*\n * Azure repo URLs on the form with a `path` query param are treated specially.\n *\n * Example base URL: https://dev.azure.com/organization/project/_git/repository?path=%2Fcatalog-info.yaml\n */\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const { url, base } = options;\n\n // If we can parse the url, it is absolute - then return it verbatim\n if (isValidUrl(url)) {\n return url;\n }\n\n try {\n const azureUrl = AzureUrl.fromRepoUrl(base);\n const newUrl = new URL(base);\n\n // We lean on the URL path resolution logic to resolve the path param\n const mockBaseUrl = new URL(`https://a.com${azureUrl.getPath() ?? ''}`);\n const updatedPath = new URL(url, mockBaseUrl).pathname;\n newUrl.searchParams.set('path', updatedPath);\n\n if (options.lineNumber) {\n newUrl.searchParams.set('line', String(options.lineNumber));\n newUrl.searchParams.set('lineEnd', String(options.lineNumber + 1));\n newUrl.searchParams.set('lineStartColumn', '1');\n newUrl.searchParams.set('lineEndColumn', '1');\n }\n\n return newUrl.toString();\n } catch {\n // If not an actual file path within a repo, treat the URL as raw\n return new URL(url, base).toString();\n }\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for Azure, fallback to view url as I don't know\n // how azure works.\n return url;\n }\n}\n"],"names":[],"mappings":";;;;AA0BO,MAAM,gBAA2C,CAAA;AAAA,EAYtD,YAA6B,iBAA2C,EAAA;AAA3C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAA4C,EAXzE,OAAO,OAAA,GAAoD,CAAC,EAAE,QAAa,KAAA;AACzE,IAAA,MAAM,OAAU,GAAA,2BAAA;AAAA,MACd,MAAO,CAAA,sBAAA,CAAuB,oBAAoB,CAAA,IAAK;AAAC,KAC1D;AAEA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,gBAAA,CAAiB,CAAC,CAAC,CAAA;AAAA,MACxC,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA;AAAA,KAChB;AAAA,GACF;AAAA,EAI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A,OAAO,OAAO,QAAS,EAAA;AAAA,KACjB,CAAA,MAAA;AAEN,MAAA,OAAO,IAAI,GAAA,CAAI,GAAK,EAAA,IAAI,EAAE,QAAS,EAAA;AAAA;AACrC;AACF,EAEA,eAAe,GAAqB,EAAA;AAGlC,IAAO,OAAA,GAAA;AAAA;AAEX;;;;"}
1
+ {"version":3,"file":"AzureIntegration.esm.js","sources":["../../src/azure/AzureIntegration.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 { basicIntegrations, isValidUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AzureUrl } from './AzureUrl';\nimport { AzureIntegrationConfig, readAzureIntegrationConfigs } from './config';\n\n/**\n * Microsoft Azure based integration.\n *\n * @public\n */\nexport class AzureIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AzureIntegration> = ({ config }) => {\n const configs = readAzureIntegrationConfigs(\n config.getOptionalConfigArray('integrations.azure') ?? [],\n );\n\n return basicIntegrations(\n configs.map(c => new AzureIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: AzureIntegrationConfig) {}\n\n get type(): string {\n return 'azure';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AzureIntegrationConfig {\n return this.integrationConfig;\n }\n\n /*\n * Azure repo URLs on the form with a `path` query param are treated specially.\n *\n * Example base URL: https://dev.azure.com/organization/project/_git/repository?path=%2Fcatalog-info.yaml\n */\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const { url, base } = options;\n\n // If we can parse the url, it is absolute - then return it verbatim\n if (isValidUrl(url)) {\n return url;\n }\n\n try {\n const azureUrl = AzureUrl.fromRepoUrl(base);\n const newUrl = new URL(base);\n\n // We lean on the URL path resolution logic to resolve the path param\n const mockBaseUrl = new URL(`https://a.com${azureUrl.getPath() ?? ''}`);\n const updatedPath = new URL(url, mockBaseUrl).pathname;\n newUrl.searchParams.set('path', updatedPath);\n\n if (options.lineNumber) {\n newUrl.searchParams.set('line', String(options.lineNumber));\n newUrl.searchParams.set('lineEnd', String(options.lineNumber + 1));\n newUrl.searchParams.set('lineStartColumn', '1');\n newUrl.searchParams.set('lineEndColumn', '1');\n }\n\n return newUrl.toString();\n } catch {\n // If not an actual file path within a repo, treat the URL as raw\n return new URL(url, base).toString();\n }\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for Azure, fallback to view url as I don't know\n // how azure works.\n return url;\n }\n}\n"],"names":[],"mappings":";;;;AA0BO,MAAM,gBAAA,CAA2C;AAAA,EAYtD,YAA6B,iBAAA,EAA2C;AAA3C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAA4C;AAAA,EAXzE,OAAO,OAAA,GAAoD,CAAC,EAAE,QAAO,KAAM;AACzE,IAAA,MAAM,OAAA,GAAU,2BAAA;AAAA,MACd,MAAA,CAAO,sBAAA,CAAuB,oBAAoB,CAAA,IAAK;AAAC,KAC1D;AAEA,IAAA,OAAO,iBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,gBAAA,CAAiB,CAAC,CAAC,CAAA;AAAA,MACxC,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAAA,EACF,CAAA;AAAA,EAIA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,OAAA;AAAA,EACT;AAAA,EAEA,IAAI,KAAA,GAAgB;AAClB,IAAA,OAAO,KAAK,iBAAA,CAAkB,IAAA;AAAA,EAChC;AAAA,EAEA,I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S;AAAA,IACrC;AAAA,EACF;AAAA,EAEA,eAAe,GAAA,EAAqB;AAGlC,IAAA,OAAO,GAAA;AAAA,EACT;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AzureUrl.cjs.js","sources":["../../src/azure/AzureUrl.ts"],"sourcesContent":["/*\n * Copyright 2021 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\nconst VERSION_PREFIX_GIT_BRANCH = 'GB';\n\nexport class AzureUrl {\n /**\n * Parses an azure URL as copied from the browser address bar.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n static fromRepoUrl(repoUrl: string): AzureUrl {\n const url = new URL(repoUrl);\n\n let owner;\n let project;\n let repo;\n\n const parts = url.pathname.split('/').map(part => decodeURIComponent(part));\n if (parts[2] === '_git') {\n owner = parts[1];\n project = repo = parts[3];\n } else if (parts[3] === '_git') {\n owner = parts[1];\n project = parts[2];\n repo = parts[4];\n } else if (parts[4] === '_git') {\n owner = `${parts[1]}/${parts[2]}`;\n project = parts[3];\n repo = parts[5];\n }\n\n if (!owner || !project || !repo) {\n throw new Error('Azure URL must point to a git repository');\n }\n\n const path = url.searchParams.get('path') ?? undefined;\n\n let ref;\n const version = url.searchParams.get('version');\n if (version) {\n const prefix = version.slice(0, 2);\n if (prefix !== 'GB') {\n throw new Error('Azure URL version must point to a git branch');\n }\n ref = version.slice(2);\n }\n\n return new AzureUrl(url.origin, owner, project, repo, path, ref);\n }\n\n #origin: string;\n #owner: string;\n #project: string;\n #repo: string;\n #path?: string;\n #ref?: string;\n\n private constructor(\n origin: string,\n owner: string,\n project: string,\n repo: string,\n path?: string,\n ref?: string,\n ) {\n this.#origin = origin;\n this.#owner = owner;\n this.#project = project;\n this.#repo = repo;\n this.#path = path;\n this.#ref = ref;\n }\n\n #baseUrl = (...parts: string[]): URL => {\n const url = new URL(this.#origin);\n url.pathname = parts.map(part => encodeURIComponent(part)).join('/');\n return url;\n };\n\n /**\n * Returns a repo URL that can be used to navigate to the resource in azure.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n toRepoUrl(): string {\n let url;\n if (this.#project === this.#repo) {\n url = this.#baseUrl(this.#owner, '_git', this.#repo);\n } else {\n url = this.#baseUrl(this.#owner, this.#project, '_git', this.#repo);\n }\n\n if (this.#path) {\n url.searchParams.set('path', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', VERSION_PREFIX_GIT_BRANCH + this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the file download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a file.\n */\n toFileUrl(): string {\n if (!this.#path) {\n throw new Error(\n 'Azure URL must point to a specific path to be able to download a file',\n );\n }\n\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('api-version', '6.0');\n url.searchParams.set('path', this.#path);\n\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the archive download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a repo.\n */\n toArchiveUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('recursionLevel', 'full');\n url.searchParams.set('download', 'true');\n url.searchParams.set('api-version', '6.0');\n\n if (this.#path) {\n url.searchParams.set('scopePath', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the API url for fetching commits from a branch for this azure resource.\n *\n * Throws an error if the URL does not point to a commit.\n */\n toCommitsUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'commits',\n );\n url.searchParams.set('api-version', '6.0');\n\n if (this.#ref) {\n url.searchParams.set('searchCriteria.itemVersion.version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the name of the owner, a user or an organization.\n */\n getOwner(): string {\n return this.#owner;\n }\n\n /**\n * Returns the name of the project.\n */\n getProject(): string {\n return this.#project;\n }\n\n /**\n * Returns the name of the repo.\n */\n getRepo(): string {\n return this.#repo;\n }\n\n /**\n * Returns the file path within the repo if the URL contains one.\n */\n getPath(): string | undefined {\n return this.#path;\n }\n\n /**\n * Returns the git ref in the repo if the URL contains one.\n */\n getRef(): string | undefined {\n return this.#ref;\n }\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,yBAA4B,GAAA,IAAA;AAE3B,MAAM,QAAS,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,OAAO,YAAY,OAA2B,EAAA;AAC5C,IAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,OAAO,CAAA;AAE3B,IAAI,IAAA,KAAA;AACJ,IAAI,IAAA,OAAA;AACJ,IAAI,IAAA,IAAA;AAEJ,IAAM,MAAA,KAAA,GAAQ,GAAI,CAAA,QAAA,CAAS,KAAM,CAAA,GAAG,EAAE,GAAI,CAAA,CAAA,IAAA,KAAQ,kBAAmB,CAAA,IAAI,CAAC,CAAA;AAC1E,IAAI,IAAA,KAAA,CAAM,CAAC,CAAA,KAAM,MAAQ,EAAA;AACvB,MAAA,KAAA,GAAQ,MAAM,CAAC,CAAA;AACf,MAAU,OAAA,GAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,KACf,MAAA,IAAA,KAAA,CAAM,CAAC,CAAA,KAAM,MAAQ,EAAA;AAC9B,MAAA,KAAA,GAAQ,MAAM,CAAC,CAAA;AACf,MAAA,OAAA,GAAU,MAAM,CAAC,CAA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AE9C,IAAA,IAAI,KAAK,IAAM,EAAA;AACb,MAAA,GAAA,CAAI,YAAa,CAAA,GAAA,CAAI,SAAW,EAAA,IAAA,CAAK,IAAI,CAAA;AAAA;AAG3C,IAAA,OAAO,IAAI,QAAS,EAAA;AAAA;AACtB;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAuB,GAAA;AACrB,IAAA,MAAM,MAAM,IAAK,CAAA,QAAA;AAAA,MACf,IAAK,CAAA,MAAA;AAAA,MACL,IAAK,CAAA,QAAA;AAAA,MACL,OAAA;AAAA,MACA,KAAA;AAAA,MACA,cAAA;AAAA,MACA,IAAK,CAAA,KAAA;AAAA,MACL;AAAA,KACF;AACA,IAAI,GAAA,CAAA,YAAA,CAAa,GAAI,CAAA,aAAA,EAAe,KAAK,CAAA;AAEzC,IAAA,IAAI,KAAK,IAAM,EAAA;AACb,MAAA,GAAA,CAAI,YAAa,CAAA,GAAA,CAAI,oCAAsC,EAAA,IAAA,CAAK,IAAI,CAAA;AAAA;AAGtE,IAAA,OAAO,IAAI,QAAS,EAAA;AAAA;AACtB;AAAA;AAAA;AAAA,EAKA,QAAmB,GAAA;AACjB,IAAA,OAAO,IAAK,CAAA,MAAA;AAAA;AACd;AAAA;AAAA;AAAA,EAKA,UAAqB,GAAA;AACnB,IAAA,OAAO,IAAK,CAAA,QAAA;AAAA;AACd;AAAA;AAAA;AAAA,EAKA,OAAkB,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,KAAA;AAAA;AACd;AAAA;AAAA;AAAA,EAKA,OAA8B,GAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,KAAA;AAAA;AACd;AAAA;AAAA;AAAA,EAKA,MAA6B,GAAA;AAC3B,IAAA,OAAO,IAAK,CAAA,IAAA;AAAA;AAEhB;;;;"}
1
+ {"version":3,"file":"AzureUrl.cjs.js","sources":["../../src/azure/AzureUrl.ts"],"sourcesContent":["/*\n * Copyright 2021 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\nconst VERSION_PREFIX_GIT_BRANCH = 'GB';\n\nexport class AzureUrl {\n /**\n * Parses an azure URL as copied from the browser address bar.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n static fromRepoUrl(repoUrl: string): AzureUrl {\n const url = new URL(repoUrl);\n\n let owner;\n let project;\n let repo;\n\n const parts = url.pathname.split('/').map(part => decodeURIComponent(part));\n if (parts[2] === '_git') {\n owner = parts[1];\n project = repo = parts[3];\n } else if (parts[3] === '_git') {\n owner = parts[1];\n project = parts[2];\n repo = parts[4];\n } else if (parts[4] === '_git') {\n owner = `${parts[1]}/${parts[2]}`;\n project = parts[3];\n repo = parts[5];\n }\n\n if (!owner || !project || !repo) {\n throw new Error('Azure URL must point to a git repository');\n }\n\n const path = url.searchParams.get('path') ?? undefined;\n\n let ref;\n const version = url.searchParams.get('version');\n if (version) {\n const prefix = version.slice(0, 2);\n if (prefix !== 'GB') {\n throw new Error('Azure URL version must point to a git branch');\n }\n ref = version.slice(2);\n }\n\n return new AzureUrl(url.origin, owner, project, repo, path, ref);\n }\n\n #origin: string;\n #owner: string;\n #project: string;\n #repo: string;\n #path?: string;\n #ref?: string;\n\n private constructor(\n origin: string,\n owner: string,\n project: string,\n repo: string,\n path?: string,\n ref?: string,\n ) {\n this.#origin = origin;\n this.#owner = owner;\n this.#project = project;\n this.#repo = repo;\n this.#path = path;\n this.#ref = ref;\n }\n\n #baseUrl = (...parts: string[]): URL => {\n const url = new URL(this.#origin);\n url.pathname = parts.map(part => encodeURIComponent(part)).join('/');\n return url;\n };\n\n /**\n * Returns a repo URL that can be used to navigate to the resource in azure.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n toRepoUrl(): string {\n let url;\n if (this.#project === this.#repo) {\n url = this.#baseUrl(this.#owner, '_git', this.#repo);\n } else {\n url = this.#baseUrl(this.#owner, this.#project, '_git', this.#repo);\n }\n\n if (this.#path) {\n url.searchParams.set('path', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', VERSION_PREFIX_GIT_BRANCH + this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the file download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a file.\n */\n toFileUrl(): string {\n if (!this.#path) {\n throw new Error(\n 'Azure URL must point to a specific path to be able to download a file',\n );\n }\n\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('api-version', '6.0');\n url.searchParams.set('path', this.#path);\n\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the archive download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a repo.\n */\n toArchiveUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('recursionLevel', 'full');\n url.searchParams.set('download', 'true');\n url.searchParams.set('api-version', '6.0');\n\n if (this.#path) {\n url.searchParams.set('scopePath', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the API url for fetching commits from a branch for this azure resource.\n *\n * Throws an error if the URL does not point to a commit.\n */\n toCommitsUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'commits',\n );\n url.searchParams.set('api-version', '6.0');\n\n if (this.#ref) {\n url.searchParams.set('searchCriteria.itemVersion.version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the name of the owner, a user or an organization.\n */\n getOwner(): string {\n return this.#owner;\n }\n\n /**\n * Returns the name of the project.\n */\n getProject(): string {\n return this.#project;\n }\n\n /**\n * Returns the name of the repo.\n */\n getRepo(): string {\n return this.#repo;\n }\n\n /**\n * Returns the file path within the repo if the URL contains one.\n */\n getPath(): string | undefined {\n return this.#path;\n }\n\n /**\n * Returns the git ref in the repo if the URL contains one.\n */\n getRef(): string | undefined {\n return this.#ref;\n }\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,yBAAA,GAA4B,IAAA;AAE3B,MAAM,QAAA,CAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,OAAO,YAAY,OAAA,EAA2B;AAC5C,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,OAAO,CAAA;AAE3B,IAAA,IAAI,KAAA;AACJ,IAAA,IAAI,OAAA;AACJ,IAAA,IAAI,IAAA;AAEJ,IAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,QAAA,CAAS,KAAA,CAAM,GAAG,EAAE,GAAA,CAAI,CAAA,IAAA,KAAQ,kBAAA,CAAmB,IAAI,CAAC,CAAA;AAC1E,IAAA,IAAI,KAAA,CAAM,CAAC,CAAA,KAAM,MAAA,EAAQ;AACvB,MAAA,KAAA,GAAQ,MAAM,CAAC,CAAA;AACf,MAAA,OAAA,GAAU,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,IAC1B,CAAA,MAAA,IAAW,KAAA,CAAM,CAAC,CAAA,KAAM,MAAA,EAAQ;AAC9B,MAAA,KAAA,GAAQ,MAAM,CAAC,CAAA;AACf,MAAA,OAAA,GAAU,MAAM,CAAC,CAAA;AACjB,MAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,IAChB,CAAA,MAAA,IAAW,KAAA,CAAM,CAAC,CAAA,KAAM,MAAA,EAAQ;AAC9B,MAAA,KAAA,GAAQ,GAAG,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA,EAAI,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAC/B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IAAI,QAAA,EAAS;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAA,GAAuB;AACrB,IAAA,MAAM,MAAM,IAAA,CAAK,QAAA;AAAA,MACf,IAAA,CAAK,MAAA;AAAA,MACL,IAAA,CAAK,QAAA;AAAA,MACL,OAAA;AAAA,MACA,KAAA;AAAA,MACA,cAAA;AAAA,MACA,IAAA,CAAK,KAAA;AAAA,MACL;AAAA,KACF;AACA,IAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,aAAA,EAAe,KAAK,CAAA;AAEzC,IAAA,IAAI,KAAK,IAAA,EAAM;AACb,MAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,oCAAA,EAAsC,IAAA,CAAK,IAAI,CAAA;AAAA,IACtE;AAEA,IAAA,OAAO,IAAI,QAAA,EAAS;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA,GAAmB;AACjB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA,GAAqB;AACnB,IAAA,OAAO,IAAA,CAAK,QAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA,GAAkB;AAChB,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA,GAA8B;AAC5B,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,MAAA,GAA6B;AAC3B,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACd;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AzureUrl.esm.js","sources":["../../src/azure/AzureUrl.ts"],"sourcesContent":["/*\n * Copyright 2021 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\nconst VERSION_PREFIX_GIT_BRANCH = 'GB';\n\nexport class AzureUrl {\n /**\n * Parses an azure URL as copied from the browser address bar.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n static fromRepoUrl(repoUrl: string): AzureUrl {\n const url = new URL(repoUrl);\n\n let owner;\n let project;\n let repo;\n\n const parts = url.pathname.split('/').map(part => decodeURIComponent(part));\n if (parts[2] === '_git') {\n owner = parts[1];\n project = repo = parts[3];\n } else if (parts[3] === '_git') {\n owner = parts[1];\n project = parts[2];\n repo = parts[4];\n } else if (parts[4] === '_git') {\n owner = `${parts[1]}/${parts[2]}`;\n project = parts[3];\n repo = parts[5];\n }\n\n if (!owner || !project || !repo) {\n throw new Error('Azure URL must point to a git repository');\n }\n\n const path = url.searchParams.get('path') ?? undefined;\n\n let ref;\n const version = url.searchParams.get('version');\n if (version) {\n const prefix = version.slice(0, 2);\n if (prefix !== 'GB') {\n throw new Error('Azure URL version must point to a git branch');\n }\n ref = version.slice(2);\n }\n\n return new AzureUrl(url.origin, owner, project, repo, path, ref);\n }\n\n #origin: string;\n #owner: string;\n #project: string;\n #repo: string;\n #path?: string;\n #ref?: string;\n\n private constructor(\n origin: string,\n owner: string,\n project: string,\n repo: string,\n path?: string,\n ref?: string,\n ) {\n this.#origin = origin;\n this.#owner = owner;\n this.#project = project;\n this.#repo = repo;\n this.#path = path;\n this.#ref = ref;\n }\n\n #baseUrl = (...parts: string[]): URL => {\n const url = new URL(this.#origin);\n url.pathname = parts.map(part => encodeURIComponent(part)).join('/');\n return url;\n };\n\n /**\n * Returns a repo URL that can be used to navigate to the resource in azure.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n toRepoUrl(): string {\n let url;\n if (this.#project === this.#repo) {\n url = this.#baseUrl(this.#owner, '_git', this.#repo);\n } else {\n url = this.#baseUrl(this.#owner, this.#project, '_git', this.#repo);\n }\n\n if (this.#path) {\n url.searchParams.set('path', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', VERSION_PREFIX_GIT_BRANCH + this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the file download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a file.\n */\n toFileUrl(): string {\n if (!this.#path) {\n throw new Error(\n 'Azure URL must point to a specific path to be able to download a file',\n );\n }\n\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('api-version', '6.0');\n url.searchParams.set('path', this.#path);\n\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the archive download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a repo.\n */\n toArchiveUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('recursionLevel', 'full');\n url.searchParams.set('download', 'true');\n url.searchParams.set('api-version', '6.0');\n\n if (this.#path) {\n url.searchParams.set('scopePath', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the API url for fetching commits from a branch for this azure resource.\n *\n * Throws an error if the URL does not point to a commit.\n */\n toCommitsUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'commits',\n );\n url.searchParams.set('api-version', '6.0');\n\n if (this.#ref) {\n url.searchParams.set('searchCriteria.itemVersion.version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the name of the owner, a user or an organization.\n */\n getOwner(): string {\n return this.#owner;\n }\n\n /**\n * Returns the name of the project.\n */\n getProject(): string {\n return this.#project;\n }\n\n /**\n * Returns the name of the repo.\n */\n getRepo(): string {\n return this.#repo;\n }\n\n /**\n * Returns the file path within the repo if the URL contains one.\n */\n getPath(): string | undefined {\n return this.#path;\n }\n\n /**\n * Returns the git ref in the repo if the URL contains one.\n */\n getRef(): string | undefined {\n return this.#ref;\n }\n}\n"],"names":[],"mappings":"AAgBA,MAAM,yBAA4B,GAAA,IAAA;AAE3B,MAAM,QAAS,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,OAAO,YAAY,OAA2B,EAAA;AAC5C,IAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,OAAO,CAAA;AAE3B,IAAI,IAAA,KAAA;AACJ,IAAI,IAAA,OAAA;AACJ,IAAI,IAAA,IAAA;AAEJ,IAAM,MAAA,KAAA,GAAQ,GAAI,CAAA,QAAA,CAAS,KAAM,CAAA,GAAG,EAAE,GAAI,CAAA,CAAA,IAAA,KAAQ,kBAAmB,CAAA,IAAI,CAAC,CAAA;AAC1E,IAAI,IAAA,KAAA,CAAM,CAAC,CAAA,KAAM,MAAQ,EAAA;AACvB,MAAA,KAAA,GAAQ,MAAM,CAAC,CAAA;AACf,MAAU,OAAA,GAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,KACf,MAAA,IAAA,KAAA,CAAM,CAAC,CAAA,KAAM,MAAQ,EAAA;AAC9B,MAAA,KAAA,GAAQ,MAAM,CAAC,CAAA;AACf,MAAA,OAAA,GAAU,MAAM,CAAC,CAAA;AACjB,MAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,KACL,MAAA,IAAA,KAAA,CAAM,CAAC,CAAA,KAAM,MAAQ,EAAA;AAC9B,MAAA,KAAA,GAAQ,GAAG,KAAM,CAAA,CAAC,CAAC,CAAI,CAAA,EAAA,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAC/B,MAAA,OAAA,GAAU,MAAM,CAAC,CAAA;AACjB,MAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA;AAGhB,IAAA,IAAI,C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,OAAA;AAAA,MACA,KAAA;AAAA,MACA,cAAA;AAAA,MACA,IAAK,CAAA,KAAA;AAAA,MACL;AAAA,KACF;AACA,IAAI,GAAA,CAAA,YAAA,CAAa,GAAI,CAAA,aAAA,EAAe,KAAK,CAAA;AAEzC,IAAA,IAAI,KAAK,IAAM,EAAA;AACb,MAAA,GAAA,CAAI,YAAa,CAAA,GAAA,CAAI,oCAAsC,EAAA,IAAA,CAAK,IAAI,CAAA;AAAA;AAGtE,IAAA,OAAO,IAAI,QAAS,EAAA;AAAA;AACtB;AAAA;AAAA;AAAA,EAKA,QAAmB,GAAA;AACjB,IAAA,OAAO,IAAK,CAAA,MAAA;AAAA;AACd;AAAA;AAAA;AAAA,EAKA,UAAqB,GAAA;AACnB,IAAA,OAAO,IAAK,CAAA,QAAA;AAAA;AACd;AAAA;AAAA;AAAA,EAKA,OAAkB,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,KAAA;AAAA;AACd;AAAA;AAAA;AAAA,EAKA,OAA8B,GAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,KAAA;AAAA;AACd;AAAA;AAAA;AAAA,EAKA,MAA6B,GAAA;AAC3B,IAAA,OAAO,IAAK,CAAA,IAAA;AAAA;AAEhB;;;;"}
1
+ {"version":3,"file":"AzureUrl.esm.js","sources":["../../src/azure/AzureUrl.ts"],"sourcesContent":["/*\n * Copyright 2021 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\nconst VERSION_PREFIX_GIT_BRANCH = 'GB';\n\nexport class AzureUrl {\n /**\n * Parses an azure URL as copied from the browser address bar.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n static fromRepoUrl(repoUrl: string): AzureUrl {\n const url = new URL(repoUrl);\n\n let owner;\n let project;\n let repo;\n\n const parts = url.pathname.split('/').map(part => decodeURIComponent(part));\n if (parts[2] === '_git') {\n owner = parts[1];\n project = repo = parts[3];\n } else if (parts[3] === '_git') {\n owner = parts[1];\n project = parts[2];\n repo = parts[4];\n } else if (parts[4] === '_git') {\n owner = `${parts[1]}/${parts[2]}`;\n project = parts[3];\n repo = parts[5];\n }\n\n if (!owner || !project || !repo) {\n throw new Error('Azure URL must point to a git repository');\n }\n\n const path = url.searchParams.get('path') ?? undefined;\n\n let ref;\n const version = url.searchParams.get('version');\n if (version) {\n const prefix = version.slice(0, 2);\n if (prefix !== 'GB') {\n throw new Error('Azure URL version must point to a git branch');\n }\n ref = version.slice(2);\n }\n\n return new AzureUrl(url.origin, owner, project, repo, path, ref);\n }\n\n #origin: string;\n #owner: string;\n #project: string;\n #repo: string;\n #path?: string;\n #ref?: string;\n\n private constructor(\n origin: string,\n owner: string,\n project: string,\n repo: string,\n path?: string,\n ref?: string,\n ) {\n this.#origin = origin;\n this.#owner = owner;\n this.#project = project;\n this.#repo = repo;\n this.#path = path;\n this.#ref = ref;\n }\n\n #baseUrl = (...parts: string[]): URL => {\n const url = new URL(this.#origin);\n url.pathname = parts.map(part => encodeURIComponent(part)).join('/');\n return url;\n };\n\n /**\n * Returns a repo URL that can be used to navigate to the resource in azure.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n toRepoUrl(): string {\n let url;\n if (this.#project === this.#repo) {\n url = this.#baseUrl(this.#owner, '_git', this.#repo);\n } else {\n url = this.#baseUrl(this.#owner, this.#project, '_git', this.#repo);\n }\n\n if (this.#path) {\n url.searchParams.set('path', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', VERSION_PREFIX_GIT_BRANCH + this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the file download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a file.\n */\n toFileUrl(): string {\n if (!this.#path) {\n throw new Error(\n 'Azure URL must point to a specific path to be able to download a file',\n );\n }\n\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('api-version', '6.0');\n url.searchParams.set('path', this.#path);\n\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the archive download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a repo.\n */\n toArchiveUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('recursionLevel', 'full');\n url.searchParams.set('download', 'true');\n url.searchParams.set('api-version', '6.0');\n\n if (this.#path) {\n url.searchParams.set('scopePath', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the API url for fetching commits from a branch for this azure resource.\n *\n * Throws an error if the URL does not point to a commit.\n */\n toCommitsUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'commits',\n );\n url.searchParams.set('api-version', '6.0');\n\n if (this.#ref) {\n url.searchParams.set('searchCriteria.itemVersion.version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the name of the owner, a user or an organization.\n */\n getOwner(): string {\n return this.#owner;\n }\n\n /**\n * Returns the name of the project.\n */\n getProject(): string {\n return this.#project;\n }\n\n /**\n * Returns the name of the repo.\n */\n getRepo(): string {\n return this.#repo;\n }\n\n /**\n * Returns the file path within the repo if the URL contains one.\n */\n getPath(): string | undefined {\n return this.#path;\n }\n\n /**\n * Returns the git ref in the repo if the URL contains one.\n */\n getRef(): string | undefined {\n return this.#ref;\n }\n}\n"],"names":[],"mappings":"AAgBA,MAAM,yBAAA,GAA4B,IAAA;AAE3B,MAAM,QAAA,CAAS;AA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AA,EAAe,KAAK,CAAA;AAEzC,IAAA,IAAI,KAAK,IAAA,EAAM;AACb,MAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,oCAAA,EAAsC,IAAA,CAAK,IAAI,CAAA;AAAA,IACtE;AAEA,IAAA,OAAO,IAAI,QAAA,EAAS;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA,GAAmB;AACjB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA,GAAqB;AACnB,IAAA,OAAO,IAAA,CAAK,QAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA,GAAkB;AAChB,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA,GAA8B;AAC5B,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,MAAA,GAA6B;AAC3B,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACd;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CachedAzureDevOpsCredentialsProvider.cjs.js","sources":["../../src/azure/CachedAzureDevOpsCredentialsProvider.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 { AzureDevOpsCredential, PersonalAccessTokenCredential } from './config';\nimport {\n ClientAssertionCredential,\n ClientSecretCredential,\n ManagedIdentityCredential,\n TokenCredential,\n} from '@azure/identity';\nimport {\n AzureDevOpsCredentials,\n AzureDevOpsCredentialsProvider,\n} from './types';\nimport { ManagedIdentityClientAssertion } from './ManagedIdentityClientAssertion';\n\ntype CachedAzureDevOpsCredentials = AzureDevOpsCredentials & {\n expiresAt?: number;\n};\n\nfunction exhaustiveCheck(_param: never) {}\n\nconst tenMinutes = 1000 * 60 * 10;\n\n/**\n * A credentials provider that caches the credentials for as long as it is valid.\n *\n * @public\n */\nexport class CachedAzureDevOpsCredentialsProvider\n implements AzureDevOpsCredentialsProvider\n{\n azureDevOpsScope = '499b84ac-1321-427f-aa17-267ca6975798/.default';\n cached: CachedAzureDevOpsCredentials | undefined;\n\n static fromAzureDevOpsCredential(\n credential: AzureDevOpsCredential,\n ): CachedAzureDevOpsCredentialsProvider {\n switch (credential.kind) {\n case 'PersonalAccessToken':\n return CachedAzureDevOpsCredentialsProvider.fromPersonalAccessTokenCredential(\n credential,\n );\n case 'ClientSecret':\n return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(\n new ClientSecretCredential(\n credential.tenantId,\n credential.clientId,\n credential.clientSecret,\n ),\n );\n\n case 'ManagedIdentityClientAssertion': {\n const clientAssertion = new ManagedIdentityClientAssertion({\n clientId: credential.managedIdentityClientId,\n });\n\n return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(\n new ClientAssertionCredential(\n credential.tenantId,\n credential.clientId,\n () => clientAssertion.getSignedAssertion(),\n ),\n );\n }\n\n case 'ManagedIdentity':\n return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(\n credential.clientId === 'system-assigned'\n ? new ManagedIdentityCredential()\n : new ManagedIdentityCredential(credential.clientId),\n );\n default:\n exhaustiveCheck(credential);\n\n throw new Error(\n `Credential kind '${(credential as any).kind}' not supported`,\n );\n }\n }\n\n static fromTokenCredential(\n credential: TokenCredential,\n ): CachedAzureDevOpsCredentialsProvider {\n return new CachedAzureDevOpsCredentialsProvider(credential);\n }\n\n static fromPersonalAccessTokenCredential(\n credential: PersonalAccessTokenCredential,\n ) {\n return new CachedAzureDevOpsCredentialsProvider(\n credential.personalAccessToken,\n );\n }\n\n private constructor(private readonly credential: TokenCredential | string) {}\n\n async getCredentials(): Promise<AzureDevOpsCredentials> {\n if (\n this.cached === undefined ||\n (this.cached.expiresAt !== undefined &&\n Date.now() > this.cached.expiresAt)\n ) {\n if (typeof this.credential === 'string') {\n this.cached = {\n headers: {\n Authorization: `Basic ${btoa(`:${this.credential}`)}`,\n },\n type: 'pat',\n token: this.credential,\n };\n } else {\n const accessToken = await this.credential.getToken(\n this.azureDevOpsScope,\n );\n\n if (!accessToken) {\n throw new Error('Failed to retrieve access token');\n }\n\n this.cached = {\n expiresAt: accessToken.expiresOnTimestamp - tenMinutes,\n headers: {\n Authorization: `Bearer ${accessToken.token}`,\n },\n type: 'bearer',\n token: accessToken.token,\n };\n }\n }\n\n return this.cached;\n }\n}\n"],"names":["ClientSecretCredential","ManagedIdentityClientAssertion","ClientAssertionCredential","ManagedIdentityCredential"],"mappings":";;;;;AAkCA,MAAM,UAAA,GAAa,MAAO,EAAK,GAAA,EAAA;AAOxB,MAAM,oCAEb,CAAA;AAAA,EAgEU,YAA6B,UAAsC,EAAA;AAAtC,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAAA;AAAuC,EA/D5E,gBAAmB,GAAA,+CAAA;AAAA,EACnB,MAAA;AAAA,EAEA,OAAO,0BACL,UACsC,EAAA;AACtC,IAAA,QAAQ,WAAW,IAAM;AAAA,MACvB,KAAK,qBAAA;AACH,QAAA,OAAO,oCAAqC,CAAA,iCAAA;AAAA,UAC1C;AAAA,SACF;AAAA,MACF,KAAK,cAAA;AACH,QAAA,OAAO,oCAAqC,CAAA,mBAAA;AAAA,UAC1C,IAAIA,+BAAA;AAAA,YACF,UAAW,CAAA,QAAA;AAAA,YACX,UAAW,CAAA,QAAA;AAAA,YACX,UAAW,CAAA;AAAA;AACb,SACF;AAAA,MAEF,KAAK,gCAAkC,EAAA;AACrC,QAAM,MAAA,eAAA,GAAkB,IAAIC,6DAA+B,CAAA;AAAA,UACzD,UAAU,UAA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A,WAAA,GAAc,MAAM,IAAA,CAAK,UAAW,CAAA,QAAA;AAAA,UACxC,IAAK,CAAA;AAAA,SACP;AAEA,QAAA,IAAI,CAAC,WAAa,EAAA;AAChB,UAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA;AAAA;AAGnD,QAAA,IAAA,CAAK,MAAS,GAAA;AAAA,UACZ,SAAA,EAAW,YAAY,kBAAqB,GAAA,UAAA;AAAA,UAC5C,OAAS,EAAA;AAAA,YACP,aAAA,EAAe,CAAU,OAAA,EAAA,WAAA,CAAY,KAAK,CAAA;AAAA,WAC5C;AAAA,UACA,IAAM,EAAA,QAAA;AAAA,UACN,OAAO,WAAY,CAAA;AAAA,SACrB;AAAA;AACF;AAGF,IAAA,OAAO,IAAK,CAAA,MAAA;AAAA;AAEhB;;;;"}
1
+ {"version":3,"file":"CachedAzureDevOpsCredentialsProvider.cjs.js","sources":["../../src/azure/CachedAzureDevOpsCredentialsProvider.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 { AzureDevOpsCredential, PersonalAccessTokenCredential } from './config';\nimport {\n ClientAssertionCredential,\n ClientSecretCredential,\n ManagedIdentityCredential,\n TokenCredential,\n} from '@azure/identity';\nimport {\n AzureDevOpsCredentials,\n AzureDevOpsCredentialsProvider,\n} from './types';\nimport { ManagedIdentityClientAssertion } from './ManagedIdentityClientAssertion';\n\ntype CachedAzureDevOpsCredentials = AzureDevOpsCredentials & {\n expiresAt?: number;\n};\n\nfunction exhaustiveCheck(_param: never) {}\n\nconst tenMinutes = 1000 * 60 * 10;\n\n/**\n * A credentials provider that caches the credentials for as long as it is valid.\n *\n * @public\n */\nexport class CachedAzureDevOpsCredentialsProvider\n implements AzureDevOpsCredentialsProvider\n{\n azureDevOpsScope = '499b84ac-1321-427f-aa17-267ca6975798/.default';\n cached: CachedAzureDevOpsCredentials | undefined;\n\n static fromAzureDevOpsCredential(\n credential: AzureDevOpsCredential,\n ): CachedAzureDevOpsCredentialsProvider {\n switch (credential.kind) {\n case 'PersonalAccessToken':\n return CachedAzureDevOpsCredentialsProvider.fromPersonalAccessTokenCredential(\n credential,\n );\n case 'ClientSecret':\n return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(\n new ClientSecretCredential(\n credential.tenantId,\n credential.clientId,\n credential.clientSecret,\n ),\n );\n\n case 'ManagedIdentityClientAssertion': {\n const clientAssertion = new ManagedIdentityClientAssertion({\n clientId: credential.managedIdentityClientId,\n });\n\n return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(\n new ClientAssertionCredential(\n credential.tenantId,\n credential.clientId,\n () => clientAssertion.getSignedAssertion(),\n ),\n );\n }\n\n case 'ManagedIdentity':\n return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(\n credential.clientId === 'system-assigned'\n ? new ManagedIdentityCredential()\n : new ManagedIdentityCredential(credential.clientId),\n );\n default:\n exhaustiveCheck(credential);\n\n throw new Error(\n `Credential kind '${(credential as any).kind}' not supported`,\n );\n }\n }\n\n static fromTokenCredential(\n credential: TokenCredential,\n ): CachedAzureDevOpsCredentialsProvider {\n return new CachedAzureDevOpsCredentialsProvider(credential);\n }\n\n static fromPersonalAccessTokenCredential(\n credential: PersonalAccessTokenCredential,\n ) {\n return new CachedAzureDevOpsCredentialsProvider(\n credential.personalAccessToken,\n );\n }\n\n private constructor(private readonly credential: TokenCredential | string) {}\n\n async getCredentials(): Promise<AzureDevOpsCredentials> {\n if (\n this.cached === undefined ||\n (this.cached.expiresAt !== undefined &&\n Date.now() > this.cached.expiresAt)\n ) {\n if (typeof this.credential === 'string') {\n this.cached = {\n headers: {\n Authorization: `Basic ${btoa(`:${this.credential}`)}`,\n },\n type: 'pat',\n token: this.credential,\n };\n } else {\n const accessToken = await this.credential.getToken(\n this.azureDevOpsScope,\n );\n\n if (!accessToken) {\n throw new Error('Failed to retrieve access token');\n }\n\n this.cached = {\n expiresAt: accessToken.expiresOnTimestamp - tenMinutes,\n headers: {\n Authorization: `Bearer ${accessToken.token}`,\n },\n type: 'bearer',\n token: accessToken.token,\n };\n }\n }\n\n return this.cached;\n }\n}\n"],"names":["ClientSecretCredential","ManagedIdentityClientAssertion","ClientAssertionCredential","ManagedIdentityCredential"],"mappings":";;;;;AAkCA,MAAM,UAAA,GAAa,MAAO,EAAA,GAAK,EAAA;AAOxB,MAAM,oCAAA,CAEb;AAAA,EAgEU,YAA6B,UAAA,EAAsC;AAAtC,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAAA,EAAuC;AAAA,EA/D5E,gBAAA,GAAmB,+CAAA;AAAA,EACnB,MAAA;AAAA,EAEA,OAAO,0BACL,UAAA,EACsC;AACtC,IAAA,QAAQ,WAAW,IAAA;AAAM,MACvB,KAAK,qBAAA;AACH,QAAA,OAAO,oCAAA,CAAqC,iCAAA;AAAA,UAC1C;AAAA,SACF;AAAA,MACF,KAAK,cAAA;AACH,QAAA,OAAO,oCAAA,CAAqC,mBAAA;AAAA,UAC1C,IAAIA,+BAAA;AAAA,YACF,UAAA,CAAW,QAAA;AAAA,YACX,UAAA,CAAW,QAAA;AAAA,YACX,UAAA,CAAW;AAAA;AACb,SACF;AAAA,MAEF,KAAK,gCAAA,EAAkC;AACrC,QAAA,MAAM,eAAA,GAAkB,IAAIC,6DAAA,CAA+B;AAAA,UACzD,UAAU,UAAA,CAAW;AAAA,SACtB,CAAA;AAED,QAAA,OAAO,oCAAA,CAAqC,mBAAA;AAAA,UAC1C,IAAIC,kCAAA;AAAA,YACF,UAAA,CAAW,QAAA;AAAA,YACX,UAAA,CAAW,QAAA;AAAA,YACX,MAAM,gBAAgB,k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