@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
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/azureBlobStorage/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 AZURE_HOST = 'blob.core.windows.net';\n\n/**\n * The configuration parameters for a single Azure Blob Storage account.\n *\n * @public\n */\nexport type AzureBlobStorageIntegrationConfig = {\n /**\n * The name of the Azure Storage Account, e.g., \"mystorageaccount\".\n */\n accountName?: string;\n\n /**\n * The primary or secondary key for the Azure Storage Account.\n * Only required if connectionString or SAS token are not specified.\n */\n accountKey?: string;\n\n /**\n * A Shared Access Signature (SAS) token for limited access to resources.\n */\n sasToken?: string;\n\n /**\n * A full connection string for the Azure Storage Account.\n * This includes the account name, key, and endpoint details.\n */\n connectionString?: string;\n\n /**\n * Optional endpoint suffix for custom domains or sovereign clouds.\n * e.g., \"core.windows.net\" for public Azure or \"core.usgovcloudapi.net\" for US Government cloud.\n */\n endpointSuffix?: string;\n\n /**\n * The host of the target that this matches on, e.g., \"blob.core.windows.net\".\n */\n host: string;\n\n endpoint?: string;\n /**\n * Optional credential to use for Azure Active Directory authentication.\n */\n aadCredential?: {\n /**\n * The client ID of the Azure AD application.\n */\n clientId: string;\n\n /**\n * The tenant ID for Azure AD.\n */\n tenantId: string;\n\n /**\n * The client secret for the Azure AD application.\n */\n clientSecret: string;\n };\n};\n\n/**\n * Reads a single Azure Blob Storage integration config.\n *\n * @param config - The config object of a single integration.\n * @public\n */\nexport function readAzureBlobStorageIntegrationConfig(\n config: Config,\n): AzureBlobStorageIntegrationConfig {\n const endpoint = config.getOptionalString('endpoint');\n const accountName = config.getString('accountName');\n const accountKey = config.getOptionalString('accountKey')?.trim();\n const sasToken = config.getOptionalString('sasToken')?.trim();\n const connectionString = config.getOptionalString('connectionString')?.trim();\n const endpointSuffix = config.getOptionalString('endpointSuffix')?.trim();\n\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 azureBlobStorage integration config, endpoint '${endpoint}' is not a valid URL`,\n );\n }\n if (pathname !== '/') {\n throw new Error(\n `invalid azureBlobStorage integration config, endpoints cannot contain path, got '${endpoint}'`,\n );\n }\n } else {\n host = AZURE_HOST;\n }\n const aadCredential = config.has('aadCredential')\n ? {\n clientId: config.getString('aadCredential.clientId'),\n tenantId: config.getString('aadCredential.tenantId'),\n clientSecret: config.getString('aadCredential.clientSecret')?.trim(),\n }\n : undefined;\n\n if (accountKey && sasToken) {\n throw new Error(\n `Invalid Azure Blob Storage config for ${accountName}: Both account key and SAS token cannot be used simultaneously.`,\n );\n }\n\n if (aadCredential && (accountKey || sasToken)) {\n throw new Error(\n `Invalid Azure Blob Storage config for ${accountName}: Cannot use both Azure AD credentials and account keys/SAS tokens for the same account.`,\n );\n }\n\n return {\n host,\n endpoint,\n accountName,\n accountKey,\n sasToken,\n connectionString,\n endpointSuffix,\n aadCredential,\n };\n}\n\n/**\n * Reads a set of Azure Blob Storage integration configs.\n *\n * @param configs - All of the integration config objects.\n * @public\n */\nexport function readAzureBlobStorageIntegrationConfigs(\n configs: Config[],\n): AzureBlobStorageIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readAzureBlobStorageIntegrationConfig);\n\n // If no explicit blob.core.windows.net integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === AZURE_HOST)) {\n result.push({\n host: AZURE_HOST,\n });\n }\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,UAAa,GAAA,uBAAA;AAqEZ,SAAS,sCACd,MACmC,EAAA;AACnC,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,SAAA,CAAU,aAAa,CAAA;AAClD,EAAA,MAAM,UAAa,GAAA,MAAA,CAAO,iBAAkB,CAAA,YAAY,GAAG,IAAK,EAAA;AAChE,EAAA,MAAM,QAAW,GAAA,MAAA,CAAO,iBAAkB,CAAA,UAAU,GAAG,IAAK,EAAA;AAC5D,EAAA,MAAM,gBAAmB,GAAA,MAAA,CAAO,iBAAkB,CAAA,kBAAkB,GAAG,IAAK,EAAA;AAC5E,EAAA,MAAM,cAAiB,GAAA,MAAA,CAAO,iBAAkB,CAAA,gBAAgB,GAAG,IAAK,EAAA;AAExE,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,0DAA0D,QAAQ,CAAA,oBAAA;AAAA,OACpE;AAAA;AAEF,IAAA,IAAI,aAAa,GAAK,EAAA;AACpB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,oFAAoF,QAAQ,CAAA,CAAA;AAAA,OAC9F;AAAA;AACF,GACK,MAAA;AACL,IAAO,IAAA,GAAA,UAAA;AAAA;AAET,EAAA,MAAM,aAAgB,GAAA,MAAA,CAAO,GAAI,CAAA,eAAe,CAC5C,GAAA;AAAA,IACE,QAAA,EAAU,MAAO,CAAA,SAAA,CAAU,wBAAwB,CAAA;AAAA,IACnD,QAAA,EAAU,MAAO,CAAA,SAAA,CAAU,wBAAwB,CAAA;AAAA,IACnD,YAAc,EAAA,MAAA,CAAO,SAAU,CAAA,4BAA4B,GAAG,IAAK;AAAA,GAErE,GAAA,KAAA,CAAA;AAEJ,EAAA,IAAI,cAAc,QAAU,EAAA;AAC1B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,yCAAyC,WAAW,CAAA,+DAAA;AAAA,KACtD;AAAA;AAGF,EAAI,IAAA,aAAA,KAAkB,cAAc,QAAW,CAAA,EAAA;AAC7C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,yCAAyC,WAAW,CAAA,wFAAA;AAAA,KACtD;AAAA;AAGF,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACF;AACF;AAQO,SAAS,uCACd,OACqC,EAAA;AAErC,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,qCAAqC,CAAA;AAIhE,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,UAAU,CAAG,EAAA;AAC5C,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/azureBlobStorage/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 AZURE_HOST = 'blob.core.windows.net';\n\n/**\n * The configuration parameters for a single Azure Blob Storage account.\n *\n * @public\n */\nexport type AzureBlobStorageIntegrationConfig = {\n /**\n * The name of the Azure Storage Account, e.g., \"mystorageaccount\".\n */\n accountName?: string;\n\n /**\n * The primary or secondary key for the Azure Storage Account.\n * Only required if connectionString or SAS token are not specified.\n */\n accountKey?: string;\n\n /**\n * A Shared Access Signature (SAS) token for limited access to resources.\n */\n sasToken?: string;\n\n /**\n * A full connection string for the Azure Storage Account.\n * This includes the account name, key, and endpoint details.\n */\n connectionString?: string;\n\n /**\n * Optional endpoint suffix for custom domains or sovereign clouds.\n * e.g., \"core.windows.net\" for public Azure or \"core.usgovcloudapi.net\" for US Government cloud.\n */\n endpointSuffix?: string;\n\n /**\n * The host of the target that this matches on, e.g., \"blob.core.windows.net\".\n */\n host: string;\n\n endpoint?: string;\n /**\n * Optional credential to use for Azure Active Directory authentication.\n */\n aadCredential?: {\n /**\n * The client ID of the Azure AD application.\n */\n clientId: string;\n\n /**\n * The tenant ID for Azure AD.\n */\n tenantId: string;\n\n /**\n * The client secret for the Azure AD application.\n */\n clientSecret: string;\n };\n};\n\n/**\n * Reads a single Azure Blob Storage integration config.\n *\n * @param config - The config object of a single integration.\n * @public\n */\nexport function readAzureBlobStorageIntegrationConfig(\n config: Config,\n): AzureBlobStorageIntegrationConfig {\n const endpoint = config.getOptionalString('endpoint');\n const accountName = config.getString('accountName');\n const accountKey = config.getOptionalString('accountKey')?.trim();\n const sasToken = config.getOptionalString('sasToken')?.trim();\n const connectionString = config.getOptionalString('connectionString')?.trim();\n const endpointSuffix = config.getOptionalString('endpointSuffix')?.trim();\n\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 azureBlobStorage integration config, endpoint '${endpoint}' is not a valid URL`,\n );\n }\n if (pathname !== '/') {\n throw new Error(\n `invalid azureBlobStorage integration config, endpoints cannot contain path, got '${endpoint}'`,\n );\n }\n } else {\n host = AZURE_HOST;\n }\n const aadCredential = config.has('aadCredential')\n ? {\n clientId: config.getString('aadCredential.clientId'),\n tenantId: config.getString('aadCredential.tenantId'),\n clientSecret: config.getString('aadCredential.clientSecret')?.trim(),\n }\n : undefined;\n\n if (accountKey && sasToken) {\n throw new Error(\n `Invalid Azure Blob Storage config for ${accountName}: Both account key and SAS token cannot be used simultaneously.`,\n );\n }\n\n if (aadCredential && (accountKey || sasToken)) {\n throw new Error(\n `Invalid Azure Blob Storage config for ${accountName}: Cannot use both Azure AD credentials and account keys/SAS tokens for the same account.`,\n );\n }\n\n return {\n host,\n endpoint,\n accountName,\n accountKey,\n sasToken,\n connectionString,\n endpointSuffix,\n aadCredential,\n };\n}\n\n/**\n * Reads a set of Azure Blob Storage integration configs.\n *\n * @param configs - All of the integration config objects.\n * @public\n */\nexport function readAzureBlobStorageIntegrationConfigs(\n configs: Config[],\n): AzureBlobStorageIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readAzureBlobStorageIntegrationConfig);\n\n // If no explicit blob.core.windows.net integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === AZURE_HOST)) {\n result.push({\n host: AZURE_HOST,\n });\n }\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,UAAA,GAAa,uBAAA;AAqEZ,SAAS,sCACd,MAAA,EACmC;AACnC,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,SAAA,CAAU,aAAa,CAAA;AAClD,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,G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AAA,EACF;AAEA,EAAA,IAAI,aAAA,KAAkB,cAAc,QAAA,CAAA,EAAW;AAC7C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,yCAAyC,WAAW,CAAA,wFAAA;AAAA,KACtD;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACF;AACF;AAQO,SAAS,uCACd,OAAA,EACqC;AAErC,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,qCAAqC,CAAA;AAIhE,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,UAAU,CAAA,EAAG;AAC5C,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":"BitbucketIntegration.cjs.js","sources":["../../src/bitbucket/BitbucketIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketIntegrationConfig,\n readBitbucketIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket based integration.\n *\n * @public\n * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.\n */\nexport class BitbucketIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucket') ?? [\n // if integrations.bitbucket was not used assume the use was migrated to the new configs\n // and backport for the deprecated integration to be usable for other parts of the system\n // until these got migrated\n ...(config.getOptionalConfigArray('integrations.bitbucketCloud') ?? []),\n ...(config.getOptionalConfigArray('integrations.bitbucketServer') ??\n []),\n ],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: BitbucketIntegrationConfig) {}\n\n get type(): string {\n return 'bitbucket';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n if (!options.lineNumber) {\n return resolved;\n }\n\n const url = new URL(resolved);\n\n if (this.integrationConfig.host === 'bitbucket.org') {\n // Bitbucket Cloud uses the syntax #lines-{start}[:{end}][,...]\n url.hash = `lines-${options.lineNumber}`;\n } else {\n // Bitbucket Server uses the syntax #{start}[-{end}][,...]\n url.hash = `${options.lineNumber}`;\n }\n\n return url.toString();\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n // TODO: Not sure what spa=0 does, at least bitbucket.org doesn't support it\n // but this is taken over from the initial implementation.\n editUrl.searchParams.set('spa', '0');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":["config","readBitbucketIntegrationConfigs","basicIntegrations","defaultScmResolveUrl","parseGitUrl"],"mappings":";;;;;;;;;;AA8BO,MAAM,oBAA+C,CAAA;AAAA,EAoB1D,YAA6B,iBAA+C,EAAA;AAA/C,I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,CAAA;AAAA;AAGlC,IAAA,OAAO,IAAI,QAAS,EAAA;AAAA;AACtB,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAM,MAAA,OAAA,GAAUC,6BAAY,GAAG,CAAA;AAC/B,IAAM,MAAA,OAAA,GAAU,IAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,IAAQ,OAAA,CAAA,YAAA,CAAa,GAAI,CAAA,MAAA,EAAQ,MAAM,CAAA;AAGvC,IAAQ,OAAA,CAAA,YAAA,CAAa,GAAI,CAAA,KAAA,EAAO,GAAG,CAAA;AACnC,IAAA,OAAA,CAAQ,YAAa,CAAA,GAAA,CAAI,IAAM,EAAA,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAS,EAAA;AAAA;AAE5B;;;;"}
1
+ {"version":3,"file":"BitbucketIntegration.cjs.js","sources":["../../src/bitbucket/BitbucketIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketIntegrationConfig,\n readBitbucketIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket based integration.\n *\n * @public\n * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.\n */\nexport class BitbucketIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucket') ?? [\n // if integrations.bitbucket was not used assume the use was migrated to the new configs\n // and backport for the deprecated integration to be usable for other parts of the system\n // until these got migrated\n ...(config.getOptionalConfigArray('integrations.bitbucketCloud') ?? []),\n ...(config.getOptionalConfigArray('integrations.bitbucketServer') ??\n []),\n ],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: BitbucketIntegrationConfig) {}\n\n get type(): string {\n return 'bitbucket';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n if (!options.lineNumber) {\n return resolved;\n }\n\n const url = new URL(resolved);\n\n if (this.integrationConfig.host === 'bitbucket.org') {\n // Bitbucket Cloud uses the syntax #lines-{start}[:{end}][,...]\n url.hash = `lines-${options.lineNumber}`;\n } else {\n // Bitbucket Server uses the syntax #{start}[-{end}][,...]\n url.hash = `${options.lineNumber}`;\n }\n\n return url.toString();\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n // TODO: Not sure what spa=0 does, at least bitbucket.org doesn't support it\n // but this is taken over from the initial implementation.\n editUrl.searchParams.set('spa', '0');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":["config","readBitbucketIntegrationConfigs","basicIntegrations","defaultScmResolveUrl","parseGitUrl"],"mappings":";;;;;;;;;;AA8BO,MAAM,oBAAA,CAA+C;AAAA,EAoB1D,YAA6B,iBAAA,EAA+C;AAA/C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAAgD;AAAA,EAnB7E,OAAO,UAAwD,CAAC;AAAA,YAC9DA;AAAA,GACF,KAAM;AACJ,IAAA,MAAM,OAAA,GAAUC,sCAAA;AAAA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AAA,GAAUC,6BAAY,GAAG,CAAA;AAC/B,IAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAM,CAAA;AAGvC,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA;AACnC,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,IAAA,EAAM,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAA,EAAS;AAAA,EAC1B;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BitbucketIntegration.esm.js","sources":["../../src/bitbucket/BitbucketIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketIntegrationConfig,\n readBitbucketIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket based integration.\n *\n * @public\n * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.\n */\nexport class BitbucketIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucket') ?? [\n // if integrations.bitbucket was not used assume the use was migrated to the new configs\n // and backport for the deprecated integration to be usable for other parts of the system\n // until these got migrated\n ...(config.getOptionalConfigArray('integrations.bitbucketCloud') ?? []),\n ...(config.getOptionalConfigArray('integrations.bitbucketServer') ??\n []),\n ],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: BitbucketIntegrationConfig) {}\n\n get type(): string {\n return 'bitbucket';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n if (!options.lineNumber) {\n return resolved;\n }\n\n const url = new URL(resolved);\n\n if (this.integrationConfig.host === 'bitbucket.org') {\n // Bitbucket Cloud uses the syntax #lines-{start}[:{end}][,...]\n url.hash = `lines-${options.lineNumber}`;\n } else {\n // Bitbucket Server uses the syntax #{start}[-{end}][,...]\n url.hash = `${options.lineNumber}`;\n }\n\n return url.toString();\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n // TODO: Not sure what spa=0 does, at least bitbucket.org doesn't support it\n // but this is taken over from the initial implementation.\n editUrl.searchParams.set('spa', '0');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":[],"mappings":";;;;AA8BO,MAAM,oBAA+C,CAAA;AAAA,EAoB1D,YAA6B,iBAA+C,EAAA;AAA/C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAAgD,EAnB7E,OAAO,UAAwD,CAAC;AAAA,IAC9D;AAAA,GACI,KAAA;AACJ,IAAA,MAAM,OAAU,GAAA,+BAAA;AAAA,MACd,MAAA,CAAO,sBAAuB,CAAA,wBAAwB,CAAK,IAAA;AAAA;AAAA;AAAA;AAAA,QAIzD,GAAI,MAAA,CAAO,sBAAuB,CAAA,6BAA6B,KAAK,EAAC;AAAA,QACrE,GAAI,MAAA,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AA,KAAA,EAAO,GAAG,CAAA;AACnC,IAAA,OAAA,CAAQ,YAAa,CAAA,GAAA,CAAI,IAAM,EAAA,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAS,EAAA;AAAA;AAE5B;;;;"}
1
+ {"version":3,"file":"BitbucketIntegration.esm.js","sources":["../../src/bitbucket/BitbucketIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketIntegrationConfig,\n readBitbucketIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket based integration.\n *\n * @public\n * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.\n */\nexport class BitbucketIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucket') ?? [\n // if integrations.bitbucket was not used assume the use was migrated to the new configs\n // and backport for the deprecated integration to be usable for other parts of the system\n // until these got migrated\n ...(config.getOptionalConfigArray('integrations.bitbucketCloud') ?? []),\n ...(config.getOptionalConfigArray('integrations.bitbucketServer') ??\n []),\n ],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: BitbucketIntegrationConfig) {}\n\n get type(): string {\n return 'bitbucket';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n if (!options.lineNumber) {\n return resolved;\n }\n\n const url = new URL(resolved);\n\n if (this.integrationConfig.host === 'bitbucket.org') {\n // Bitbucket Cloud uses the syntax #lines-{start}[:{end}][,...]\n url.hash = `lines-${options.lineNumber}`;\n } else {\n // Bitbucket Server uses the syntax #{start}[-{end}][,...]\n url.hash = `${options.lineNumber}`;\n }\n\n return url.toString();\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n // TODO: Not sure what spa=0 does, at least bitbucket.org doesn't support it\n // but this is taken over from the initial implementation.\n editUrl.searchParams.set('spa', '0');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":[],"mappings":";;;;AA8BO,MAAM,oBAAA,CAA+C;AAAA,EAoB1D,YAA6B,iBAAA,EAA+C;AAA/C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAAgD;AAAA,EAnB7E,OAAO,UAAwD,CAAC;AAAA,IAC9D;AAAA,GACF,KAAM;AACJ,IAAA,MAAM,OAAA,GAAU,+BAAA;AAAA,MACd,MAAA,CAAO,sBAAA,CAAuB,wBAAwB,CAAA,IAAK;AAAA;AAAA;AAAA;AAAA,QAIzD,GAAI,MAAA,CAAO,sBAAA,CAAuB,6BAA6B,KAAK,EAAC;AAAA,QACrE,GAAI,MAAA,CAAO,sBAAA,CAAuB,8BAA8B,KAC9D;AAAC;AACL,KACF;AACA,IAAA,OAAO,iBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,oBAAA,CAAqB,CAAC,CAAC,CAAA;AAAA,MAC5C,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAA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-1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/bitbucket/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\nconst BITBUCKET_HOST = 'bitbucket.org';\nconst BITBUCKET_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket API provider.\n *\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport type BitbucketIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.org\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.bitbucket.org/2.0\",\n * with no trailing slash.\n *\n * Values omitted at the optional property at the app-config will be deduced\n * from the \"host\" value.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket integration config.\n *\n * @param config - The config object of a single integration\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfig(\n config: Config,\n): BitbucketIntegrationConfig {\n const host = config.getOptionalString('host') ?? BITBUCKET_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const appPassword = config.getOptionalString('appPassword')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === BITBUCKET_HOST) {\n apiBaseUrl = BITBUCKET_API_BASE_URL;\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n appPassword,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket integration configs, and inserts some defaults for\n * public Bitbucket if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfigs(\n configs: Config[],\n): BitbucketIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === BITBUCKET_HOST)) {\n result.push({\n host: BITBUCKET_HOST,\n apiBaseUrl: BITBUCKET_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":["isValidHost","trimEnd"],"mappings":";;;;;AAoBA,MAAM,cAAiB,GAAA,eAAA;AACvB,MAAM,sBAAyB,GAAA,+BAAA;AAyDxB,SAAS,+BACd,MAC4B,EAAA;AAC5B,EAAA,MAAM,IAAO,GAAA,MAAA,CAAO,iBAAkB,CAAA,MAAM,CAAK,IAAA,cAAA;AACjD,EAAI,IAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA;AACtD,EAAA,MAAM,KAAQ,GAAA,MAAA,CAAO,iBAAkB,CAAA,OAAO,GAAG,IAAK,EAAA;AACtD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,WAAc,GAAA,MAAA,CAAO,iBAAkB,CAAA,aAAa,GAAG,IAAK,EAAA;AAElE,EAAI,IAAA,CAACA,mBAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,0CAA0C,IAAI,CAAA,qBAAA;AAAA,KAChD;AAAA;AAGF,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAAC,cAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,GACtC,MAAA,IAAW,SAAS,cAAgB,EAAA;AAClC,IAAa,UAAA,GAAA,sBAAA;AAAA,GACR,MAAA;AACL,IAAA,UAAA,GAAa,WAAW,IAAI,CAAA,aAAA,CAAA;AAAA;AAG9B,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAO,CAAA,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AAUO,SAAS,gCACd,OAC8B,EAAA;AAE9B,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,8BAA8B,CAAA;AAIzD,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,cAAc,CAAG,EAAA;AAChD,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,cAAA;AAAA,MACN,UAAY,EAAA;AAAA,KACb,CAAA;AAAA;AAGH,EAAO,OAAA,MAAA;AACT;;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../../src/bitbucket/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\nconst BITBUCKET_HOST = 'bitbucket.org';\nconst BITBUCKET_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket API provider.\n *\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport type BitbucketIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.org\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.bitbucket.org/2.0\",\n * with no trailing slash.\n *\n * Values omitted at the optional property at the app-config will be deduced\n * from the \"host\" value.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket integration config.\n *\n * @param config - The config object of a single integration\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfig(\n config: Config,\n): BitbucketIntegrationConfig {\n const host = config.getOptionalString('host') ?? BITBUCKET_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const appPassword = config.getOptionalString('appPassword')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === BITBUCKET_HOST) {\n apiBaseUrl = BITBUCKET_API_BASE_URL;\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n appPassword,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket integration configs, and inserts some defaults for\n * public Bitbucket if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfigs(\n configs: Config[],\n): BitbucketIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === BITBUCKET_HOST)) {\n result.push({\n host: BITBUCKET_HOST,\n apiBaseUrl: BITBUCKET_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":["isValidHost","trimEnd"],"mappings":";;;;;AAoBA,MAAM,cAAA,GAAiB,eAAA;AACvB,MAAM,sBAAA,GAAyB,+BAAA;AAyDxB,SAAS,+BACd,MAAA,EAC4B;AAC5B,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,iBAAA,CAAkB,MAAM,CAAA,IAAK,cAAA;AACjD,EAAA,IAAI,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AACtD,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,iBAAA,CAAkB,OAAO,GAAG,IAAA,EAAK;AACtD,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,iBAAA,CAAkB,aAAa,GAAG,IAAA,EAAK;AAElE,EAAA,IAAI,CAACA,mBAAA,CAAY,IAAI,CAAA,EAAG;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,0CAA0C,IAAI,CAAA,qBAAA;AAAA,KAChD;AAAA,EACF;AAEA,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,UAAA,GAAaC,cAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,EACtC,CAAA,MAAA,IAAW,SAAS,cAAA,EAAgB;AAClC,IAAA,UAAA,GAAa,sBAAA;AAAA,EACf,CAAA,MAAO;AACL,IAAA,UAAA,GAAa,WAAW,IAAI,CAAA,aAAA,CAAA;AAAA,EAC9B;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAA,CAAO,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AAUO,SAAS,gCACd,OAAA,EAC8B;AAE9B,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,8BAA8B,CAAA;AAIzD,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,cAAc,CAAA,EAAG;AAChD,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM,cAAA;AAAA,MACN,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,MAAA;AACT;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/bitbucket/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\nconst BITBUCKET_HOST = 'bitbucket.org';\nconst BITBUCKET_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket API provider.\n *\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport type BitbucketIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.org\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.bitbucket.org/2.0\",\n * with no trailing slash.\n *\n * Values omitted at the optional property at the app-config will be deduced\n * from the \"host\" value.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket integration config.\n *\n * @param config - The config object of a single integration\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfig(\n config: Config,\n): BitbucketIntegrationConfig {\n const host = config.getOptionalString('host') ?? BITBUCKET_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const appPassword = config.getOptionalString('appPassword')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === BITBUCKET_HOST) {\n apiBaseUrl = BITBUCKET_API_BASE_URL;\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n appPassword,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket integration configs, and inserts some defaults for\n * public Bitbucket if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfigs(\n configs: Config[],\n): BitbucketIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === BITBUCKET_HOST)) {\n result.push({\n host: BITBUCKET_HOST,\n apiBaseUrl: BITBUCKET_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":";;;AAoBA,MAAM,cAAiB,GAAA,eAAA;AACvB,MAAM,sBAAyB,GAAA,+BAAA;AAyDxB,SAAS,+BACd,MAC4B,EAAA;AAC5B,EAAA,MAAM,IAAO,GAAA,MAAA,CAAO,iBAAkB,CAAA,MAAM,CAAK,IAAA,cAAA;AACjD,EAAI,IAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA;AACtD,EAAA,MAAM,KAAQ,GAAA,MAAA,CAAO,iBAAkB,CAAA,OAAO,GAAG,IAAK,EAAA;AACtD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,WAAc,GAAA,MAAA,CAAO,iBAAkB,CAAA,aAAa,GAAG,IAAK,EAAA;AAElE,EAAI,IAAA,CAAC,WAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,0CAA0C,IAAI,CAAA,qBAAA;AAAA,KAChD;AAAA;AAGF,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAA,OAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,GACtC,MAAA,IAAW,SAAS,cAAgB,EAAA;AAClC,IAAa,UAAA,GAAA,sBAAA;AAAA,GACR,MAAA;AACL,IAAA,UAAA,GAAa,WAAW,IAAI,CAAA,aAAA,CAAA;AAAA;AAG9B,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAO,CAAA,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AAUO,SAAS,gCACd,OAC8B,EAAA;AAE9B,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,8BAA8B,CAAA;AAIzD,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,cAAc,CAAG,EAAA;AAChD,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,cAAA;AAAA,MACN,UAAY,EAAA;AAAA,KACb,CAAA;AAAA;AAGH,EAAO,OAAA,MAAA;AACT;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/bitbucket/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\nconst BITBUCKET_HOST = 'bitbucket.org';\nconst BITBUCKET_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket API provider.\n *\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport type BitbucketIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.org\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.bitbucket.org/2.0\",\n * with no trailing slash.\n *\n * Values omitted at the optional property at the app-config will be deduced\n * from the \"host\" value.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket integration config.\n *\n * @param config - The config object of a single integration\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfig(\n config: Config,\n): BitbucketIntegrationConfig {\n const host = config.getOptionalString('host') ?? BITBUCKET_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const appPassword = config.getOptionalString('appPassword')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === BITBUCKET_HOST) {\n apiBaseUrl = BITBUCKET_API_BASE_URL;\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n appPassword,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket integration configs, and inserts some defaults for\n * public Bitbucket if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfigs(\n configs: Config[],\n): BitbucketIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === BITBUCKET_HOST)) {\n result.push({\n host: BITBUCKET_HOST,\n apiBaseUrl: BITBUCKET_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":";;;AAoBA,MAAM,cAAA,GAAiB,eAAA;AACvB,MAAM,sBAAA,GAAyB,+BAAA;AAyDxB,SAAS,+BACd,MAAA,EAC4B;AAC5B,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,iBAAA,CAAkB,MAAM,CAAA,IAAK,cAAA;AACjD,EAAA,IAAI,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AACtD,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,iBAAA,CAAkB,OAAO,GAAG,IAAA,EAAK;AACtD,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,iBAAA,CAAkB,aAAa,GAAG,IAAA,EAAK;AAElE,EAAA,IAAI,CAAC,WAAA,CAAY,IAAI,CAAA,EAAG;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,0CAA0C,IAAI,CAAA,qBAAA;AAAA,KAChD;AAAA,EACF;AAEA,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,UAAA,GAAa,OAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,EACtC,CAAA,MAAA,IAAW,SAAS,cAAA,EAAgB;AAClC,IAAA,UAAA,GAAa,sBAAA;AAAA,EACf,CAAA,MAAO;AACL,IAAA,UAAA,GAAa,WAAW,IAAI,CAAA,aAAA,CAAA;AAAA,EAC9B;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAA,CAAO,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AAUO,SAAS,gCACd,OAAA,EAC8B;AAE9B,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,8BAA8B,CAAA;AAIzD,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,cAAc,CAAA,EAAG;AAChD,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM,cAAA;AAAA,MACN,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,MAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"core.cjs.js","sources":["../../src/bitbucket/core.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 fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDefaultBranch(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project, resource } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n // Bitbucket Server https://docs.atlassian.com/bitbucket-server/rest/7.9.0/bitbucket-rest.html#idp184\n let branchUrl = isHosted\n ? `${config.apiBaseUrl}/repositories/${project}/${repoName}`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;\n\n let response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n\n if (response.status === 404 && !isHosted) {\n // First try the new format, and then if it gets specifically a 404 it should try the old format\n // (to support old Atlassian Bitbucket v5.11.1 format )\n branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;\n response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n }\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n let defaultBranch;\n if (isHosted) {\n const repoInfo = await response.json();\n defaultBranch = repoInfo.mainbranch.name;\n } else {\n const { displayId } = await response.json();\n defaultBranch = displayId;\n }\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDownloadUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n filepath,\n } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketDefaultBranch(url, config);\n }\n // path will limit the downloaded content\n // /docs will only download the docs folder and everything below it\n // /docs/index.md will download the docs folder and everything below it\n const path = filepath\n ? `&path=${encodeURIComponent(decodeURIComponent(filepath))}`\n : '';\n const archiveUrl = isHosted\n ? `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;\n\n return archiveUrl;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketFileFetchUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n (filepathtype !== 'browse' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'src')\n ) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (config.host === 'bitbucket.org') {\n if (!ref) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n }\n return `${config.apiBaseUrl}/projects/${owner}/repos/${name}/raw/${pathWithoutSlash}?at=${ref}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketRequestOptions(\n config: BitbucketIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.token) {\n headers.Authorization = `Bearer ${config.token}`;\n } else if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n"],"names":["parseGitUrl","fetch"],"mappings":";;;;;;;;;;AA4BsB,eAAA,yBAAA,CACpB,KACA,MACiB,EAAA;AACjB,EAAM,MAAA,EAAE,MAAM,QAAU,EAAA,KAAA,EAAO,SAAS,QAAS,EAAA,GAAIA,6BAAY,GAAG,CAAA;AAEpE,EAAA,MAAM,WAAW,QAAa,KAAA,eAAA;AAE9B,EAAA,IAAI,YAAY,QACZ,GAAA,CAAA,EAAG,MAAO,CAAA,UAAU,iBAAiB,OAAO,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GACxD,GAAG,MAAO,CAAA,UAAU,CAAa,UAAA,EAAA,OAAO,UAAU,QAAQ,CAAA,eAAA,CAAA;AAE9D,EAAA,IAAI,WAAW,MAAMC,sBAAA,CAAM,SAAW,EAAA,0BAAA,CAA2B,MAAM,CAAC,CAAA;AAExE,EAAA,IAAI,QAAS,CAAA,MAAA,KAAW,GAAO,IAAA,CAAC,QAAU,EAAA;AAGxC,IAAA,SAAA,GAAY,GAAG,MAAO,CAAA,UAAU,CAAa,UAAA,EAAA,OAAO,UAAU,QAAQ,CAAA,iBAAA,CAAA;AACtE,IAAA,QAAA,GAAW,MAAMA,sBAAA,CAAM,SAAW,EAAA,0BAAA,CAA2B,MAAM,CAAC,CAAA;AAAA;AAGtE,EAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,IAAM,MAAA,OAAA,GAAU,0CAA0C,SAAS,CAAA,EAAA,EAAK,SAAS,MAAM,CAAA,CAAA,EAAI,SA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,CAAC,CAAE,CAAA,CAAA;AAAA;AAEjD;AASO,SAAS,2BACd,MACqC,EAAA;AACrC,EAAA,MAAM,UAAkC,EAAC;AAEzC,EAAA,IAAI,OAAO,KAAO,EAAA;AAChB,IAAQ,OAAA,CAAA,aAAA,GAAgB,CAAU,OAAA,EAAA,MAAA,CAAO,KAAK,CAAA,CAAA;AAAA,GACrC,MAAA,IAAA,MAAA,CAAO,QAAY,IAAA,MAAA,CAAO,WAAa,EAAA;AAChD,IAAA,MAAM,SAAS,MAAO,CAAA,IAAA;AAAA,MACpB,CAAG,EAAA,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC;AAAA,KACF;AACA,IAAA,OAAA,CAAQ,aAAgB,GAAA,CAAA,MAAA,EAAS,MAAO,CAAA,QAAA,CAAS,QAAQ,CAAC,CAAA,CAAA;AAAA;AAG5D,EAAO,OAAA;AAAA,IACL;AAAA,GACF;AACF;;;;;;;"}
1
+ {"version":3,"file":"core.cjs.js","sources":["../../src/bitbucket/core.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 fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDefaultBranch(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project, resource } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n // Bitbucket Server https://docs.atlassian.com/bitbucket-server/rest/7.9.0/bitbucket-rest.html#idp184\n let branchUrl = isHosted\n ? `${config.apiBaseUrl}/repositories/${project}/${repoName}`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;\n\n let response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n\n if (response.status === 404 && !isHosted) {\n // First try the new format, and then if it gets specifically a 404 it should try the old format\n // (to support old Atlassian Bitbucket v5.11.1 format )\n branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;\n response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n }\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n let defaultBranch;\n if (isHosted) {\n const repoInfo = await response.json();\n defaultBranch = repoInfo.mainbranch.name;\n } else {\n const { displayId } = await response.json();\n defaultBranch = displayId;\n }\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDownloadUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n filepath,\n } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketDefaultBranch(url, config);\n }\n // path will limit the downloaded content\n // /docs will only download the docs folder and everything below it\n // /docs/index.md will download the docs folder and everything below it\n const path = filepath\n ? `&path=${encodeURIComponent(decodeURIComponent(filepath))}`\n : '';\n const archiveUrl = isHosted\n ? `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;\n\n return archiveUrl;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketFileFetchUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n (filepathtype !== 'browse' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'src')\n ) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (config.host === 'bitbucket.org') {\n if (!ref) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n }\n return `${config.apiBaseUrl}/projects/${owner}/repos/${name}/raw/${pathWithoutSlash}?at=${ref}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketRequestOptions(\n config: BitbucketIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.token) {\n headers.Authorization = `Bearer ${config.token}`;\n } else if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n"],"names":["parseGitUrl","fetch"],"mappings":";;;;;;;;;;AA4BA,eAAsB,yBAAA,CACpB,KACA,MAAA,EACiB;AACjB,EAAA,MAAM,EAAE,MAAM,QAAA,EAAU,KAAA,EAAO,SAAS,QAAA,EAAS,GAAIA,6BAAY,GAAG,CAAA;AAEpE,EAAA,MAAM,WAAW,QAAA,KAAa,eAAA;AAE9B,EAAA,IAAI,YAAY,QAAA,GACZ,CAAA,EAAG,MAAA,CAAO,UAAU,iBAAiB,OAAO,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GACxD,GAAG,MAAA,CAAO,UAAU,CAAA,UAAA,EAAa,OAAO,UAAU,QAAQ,CAAA,eAAA,CAAA;AAE9D,EAAA,IAAI,WAAW,MAAMC,sBAAA,CAAM,SAAA,EAAW,0BAAA,CAA2B,MAAM,CAAC,CAAA;AAExE,EAAA,IAAI,QAAA,CAAS,MAAA,KAAW,GAAA,IAAO,CAAC,QAAA,EAAU;AAGxC,IAAA,SAAA,GAAY,GAAG,MAAA,CAAO,UAAU,CAAA,UAAA,EAAa,OAAO,UAAU,QAAQ,CAAA,iBAAA,CAAA;AACtE,IAAA,QAAA,GAAW,MAAMA,sBAAA,CAAM,SAAA,EAAW,0BAAA,CAA2B,MAAM,CAAC,CAAA;AAAA,EACtE;AAEA,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,IAAA,MAAM,OAAA,GAAU,0CAA0C,SAAS,CAAA,EAAA,EAAK,SAAS,MAAM,CAAA,CAAA,EAAI,SAAS,UAAU,CAAA,CAAA;AAC9G,IAAA,MAAM,IAAI,MAAM,OAAO,CAAA;AAAA,EACzB;AAEA,EAAA,IAAI,aAAA;AACJ,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,MAAM,QAAA,GAAW,MAAM,QAAA,CAAS,IAAA,E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B,IAAA,OAAA,CAAQ,aAAA,GAAgB,CAAA,OAAA,EAAU,MAAA,CAAO,KAAK,CAAA,CAAA;AAAA,EAChD,CAAA,MAAA,IAAW,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,WAAA,EAAa;AAChD,IAAA,MAAM,SAAS,MAAA,CAAO,IAAA;AAAA,MACpB,CAAA,EAAG,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC;AAAA,KACF;AACA,IAAA,OAAA,CAAQ,aAAA,GAAgB,CAAA,MAAA,EAAS,MAAA,CAAO,QAAA,CAAS,QAAQ,CAAC,CAAA,CAAA;AAAA,EAC5D;AAEA,EAAA,OAAO;AAAA,IACL;AAAA,GACF;AACF;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"core.esm.js","sources":["../../src/bitbucket/core.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 fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDefaultBranch(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project, resource } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n // Bitbucket Server https://docs.atlassian.com/bitbucket-server/rest/7.9.0/bitbucket-rest.html#idp184\n let branchUrl = isHosted\n ? `${config.apiBaseUrl}/repositories/${project}/${repoName}`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;\n\n let response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n\n if (response.status === 404 && !isHosted) {\n // First try the new format, and then if it gets specifically a 404 it should try the old format\n // (to support old Atlassian Bitbucket v5.11.1 format )\n branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;\n response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n }\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n let defaultBranch;\n if (isHosted) {\n const repoInfo = await response.json();\n defaultBranch = repoInfo.mainbranch.name;\n } else {\n const { displayId } = await response.json();\n defaultBranch = displayId;\n }\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDownloadUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n filepath,\n } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketDefaultBranch(url, config);\n }\n // path will limit the downloaded content\n // /docs will only download the docs folder and everything below it\n // /docs/index.md will download the docs folder and everything below it\n const path = filepath\n ? `&path=${encodeURIComponent(decodeURIComponent(filepath))}`\n : '';\n const archiveUrl = isHosted\n ? `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;\n\n return archiveUrl;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketFileFetchUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n (filepathtype !== 'browse' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'src')\n ) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (config.host === 'bitbucket.org') {\n if (!ref) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n }\n return `${config.apiBaseUrl}/projects/${owner}/repos/${name}/raw/${pathWithoutSlash}?at=${ref}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketRequestOptions(\n config: BitbucketIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.token) {\n headers.Authorization = `Bearer ${config.token}`;\n } else if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n"],"names":[],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A,MACpB,CAAG,EAAA,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC;AAAA,KACF;AACA,IAAA,OAAA,CAAQ,aAAgB,GAAA,CAAA,MAAA,EAAS,MAAO,CAAA,QAAA,CAAS,QAAQ,CAAC,CAAA,CAAA;AAAA;AAG5D,EAAO,OAAA;AAAA,IACL;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"core.esm.js","sources":["../../src/bitbucket/core.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 fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDefaultBranch(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project, resource } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n // Bitbucket Server https://docs.atlassian.com/bitbucket-server/rest/7.9.0/bitbucket-rest.html#idp184\n let branchUrl = isHosted\n ? `${config.apiBaseUrl}/repositories/${project}/${repoName}`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;\n\n let response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n\n if (response.status === 404 && !isHosted) {\n // First try the new format, and then if it gets specifically a 404 it should try the old format\n // (to support old Atlassian Bitbucket v5.11.1 format )\n branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;\n response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n }\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n let defaultBranch;\n if (isHosted) {\n const repoInfo = await response.json();\n defaultBranch = repoInfo.mainbranch.name;\n } else {\n const { displayId } = await response.json();\n defaultBranch = displayId;\n }\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDownloadUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n filepath,\n } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketDefaultBranch(url, config);\n }\n // path will limit the downloaded content\n // /docs will only download the docs folder and everything below it\n // /docs/index.md will download the docs folder and everything below it\n const path = filepath\n ? `&path=${encodeURIComponent(decodeURIComponent(filepath))}`\n : '';\n const archiveUrl = isHosted\n ? `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;\n\n return archiveUrl;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketFileFetchUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n (filepathtype !== 'browse' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'src')\n ) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (config.host === 'bitbucket.org') {\n if (!ref) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n }\n return `${config.apiBaseUrl}/projects/${owner}/repos/${name}/raw/${pathWithoutSlash}?at=${ref}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketRequestOptions(\n config: BitbucketIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.token) {\n headers.Authorization = `Bearer ${config.token}`;\n } else if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n"],"names":[],"mappings":";;;AA4BA,eAAsB,yBAAA,CACpB,KACA,MAAA,EACiB;AACjB,EAAA,MAAM,EAAE,MAAM,QAAA,EAAU,KAAA,EAAO,SAAS,QAAA,EAAS,GAAI,YAAY,GAAG,CAAA;AAEpE,EAAA,MAAM,WAAW,QAAA,KAAa,eAAA;AAE9B,EAAA,IAAI,YAAY,QAAA,GACZ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QAAA,CAAS,QAAQ,CAAC,CAAA,CAAA;AAAA,EAC5D;AAEA,EAAA,OAAO;AAAA,IACL;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BitbucketCloudIntegration.cjs.js","sources":["../../src/bitbucketCloud/BitbucketCloudIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketCloudIntegrationConfig,\n readBitbucketCloudIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Cloud based integration.\n *\n * @public\n */\nexport class BitbucketCloudIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketCloudIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketCloudIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketCloud') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketCloudIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketCloudIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketCloud';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketCloudIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Cloud line numbers use the syntax #lines-42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = `lines-${options.lineNumber}`;\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":["config","readBitbucketCloudIntegrationConfigs","basicIntegrations","defaultScmResolveUrl","parseGitUrl"],"mappings":";;;;;;;;;;AA6BO,MAAM,yBAAoD,CAAA;AAAA,EAa/D,YACmB,iBACjB,EAAA;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAChB,EAdH,OAAO,UAA6D,CAAC;AAAA,YACnEA;AAAA,GACI,KAAA;AACJ,IAAA,MAAM,OAAU,GAAAC,2CAAA;AAAA,MACdD,QAAO,CAAA,sBAAA,CAAuB,6BAA6B,CAAA,IAAK;AAAC,KACnE;AACA,IAAO,OAAAE,yBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,yBAAA,CAA0B,CAAC,CAAC,CAAA;AAAA,MACjD,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA;AAAA,KAChB;AAAA,GACF;AAAA,EAMA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,gBAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA;AAAA;AAChC,EAEA,IAAI,MAA0C,GAAA;AAC5C,IAAA,OAAO,IAAK,CAAA,iBAAA;AAAA;AACd,EAEA,WAAW,OAIA,EAAA;AACT,IAAM,MAAA,QAAA,GAAWC,6BAAqB,OAAO,CAAA;AAG7C,IAAA,IAAI,QAAQ,UAAY,EAAA;AACtB,MAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAE5B,MAAI,GAAA,CAAA,IAAA,GAAO,CAAS,MAAA,EAAA,OAAA,CAAQ,UAAU,CAAA,CAAA;AACtC,MAAA,OAAO,IAAI,QAAS,EAAA;AAAA;AAGtB,IAAO,OAAA,QAAA;AAAA;AACT,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAM,MAAA,OAAA,GAAUC,6BAAY,GAAG,CAAA;AAC/B,IAAM,MAAA,OAAA,GAAU,IAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,IAAQ,OAAA,CAAA,YAAA,CAAa,GAAI,CAAA,MAAA,EAAQ,MAAM,CAAA;AACvC,IAAA,OAAA,CAAQ,YAAa,CAAA,GAAA,CAAI,IAAM,EAAA,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAS,EAAA;AAAA;AAE5B;;;;"}
1
+ {"version":3,"file":"BitbucketCloudIntegration.cjs.js","sources":["../../src/bitbucketCloud/BitbucketCloudIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketCloudIntegrationConfig,\n readBitbucketCloudIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Cloud based integration.\n *\n * @public\n */\nexport class BitbucketCloudIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketCloudIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketCloudIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketCloud') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketCloudIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketCloudIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketCloud';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketCloudIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Cloud line numbers use the syntax #lines-42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = `lines-${options.lineNumber}`;\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":["config","readBitbucketCloudIntegrationConfigs","basicIntegrations","defaultScmResolveUrl","parseGitUrl"],"mappings":";;;;;;;;;;AA6BO,MAAM,yBAAA,CAAoD;AAAA,EAa/D,YACmB,iBAAA,EACjB;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAChB;AAAA,EAdH,OAAO,UAA6D,CAAC;AAAA,YACnEA;AAAA,GACF,KAAM;AACJ,IAAA,MAAM,OAAA,GAAUC,2CAAA;AAAA,MACdD,QAAA,CAAO,sBAAA,CAAuB,6BAA6B,CAAA,IAAK;AAAC,KACnE;AACA,IAAA,OAAOE,yBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,yBAAA,CAA0B,CAAC,CAAC,CAAA;AAAA,MACjD,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAAA,EACF,CAAA;AAAA,EAMA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,gBAAA;AAAA,EACT;AAAA,EAEA,IAAI,KAAA,GAAgB;AAClB,IAAA,OAAO,KAAK,iBAAA,CAAkB,IAAA;AAAA,EAChC;AAAA,EAEA,IAAI,MAAA,GAA0C;AAC5C,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EACd;AAAA,EAEA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,QAAA,GAAWC,6BAAqB,OAAO,CAAA;AAG7C,IAAA,IAAI,QAAQ,UAAA,EAAY;AACtB,MAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAE5B,MAAA,GAAA,CAAI,IAAA,GAAO,CAAA,MAAA,EAAS,OAAA,CAAQ,UAAU,CAAA,CAAA;AACtC,MAAA,OAAO,IAAI,QAAA,EAAS;AAAA,IACtB;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EAEA,eAAe,GAAA,EAAqB;AAClC,IAAA,MAAM,OAAA,GAAUC,6BAAY,GAAG,CAAA;AAC/B,IAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAM,CAAA;AACvC,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,IAAA,EAAM,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAA,EAAS;AAAA,EAC1B;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BitbucketCloudIntegration.esm.js","sources":["../../src/bitbucketCloud/BitbucketCloudIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketCloudIntegrationConfig,\n readBitbucketCloudIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Cloud based integration.\n *\n * @public\n */\nexport class BitbucketCloudIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketCloudIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketCloudIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketCloud') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketCloudIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketCloudIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketCloud';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketCloudIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Cloud line numbers use the syntax #lines-42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = `lines-${options.lineNumber}`;\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":[],"mappings":";;;;AA6BO,MAAM,yBAAoD,CAAA;AAAA,EAa/D,YACmB,iBACjB,EAAA;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAChB,EAdH,OAAO,UAA6D,CAAC;AAAA,IACnE;AAAA,GACI,KAAA;AACJ,IAAA,MAAM,OAAU,GAAA,oCAAA;AAAA,MACd,MAAO,CAAA,sBAAA,CAAuB,6BAA6B,CAAA,IAAK;AAAC,KACnE;AACA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,yBAAA,CAA0B,CAAC,CAAC,CAAA;AAAA,MACjD,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA;AAAA,KAChB;AAAA,GACF;AAAA,EAMA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,gBAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA;AAAA;AAChC,EAEA,IAAI,MAA0C,GAAA;AAC5C,IAAA,OAAO,IAAK,CAAA,iBAAA;AAAA;AACd,EAEA,WAAW,OAIA,EAAA;AACT,IAAM,MAAA,QAAA,GAAW,qBAAqB,OAAO,CAAA;AAG7C,IAAA,IAAI,QAAQ,UAAY,EAAA;AACtB,MAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAE5B,MAAI,GAAA,CAAA,IAAA,GAAO,CAAS,MAAA,EAAA,OAAA,CAAQ,UAAU,CAAA,CAAA;AACtC,MAAA,OAAO,IAAI,QAAS,EAAA;AAAA;AAGtB,IAAO,OAAA,QAAA;AAAA;AACT,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAM,MAAA,OAAA,GAAU,YAAY,GAAG,CAAA;AAC/B,IAAM,MAAA,OAAA,GAAU,IAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,IAAQ,OAAA,CAAA,YAAA,CAAa,GAAI,CAAA,MAAA,EAAQ,MAAM,CAAA;AACvC,IAAA,OAAA,CAAQ,YAAa,CAAA,GAAA,CAAI,IAAM,EAAA,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAS,EAAA;AAAA;AAE5B;;;;"}
1
+ {"version":3,"file":"BitbucketCloudIntegration.esm.js","sources":["../../src/bitbucketCloud/BitbucketCloudIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketCloudIntegrationConfig,\n readBitbucketCloudIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Cloud based integration.\n *\n * @public\n */\nexport class BitbucketCloudIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketCloudIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketCloudIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketCloud') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketCloudIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketCloudIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketCloud';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketCloudIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Cloud line numbers use the syntax #lines-42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = `lines-${options.lineNumber}`;\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":[],"mappings":";;;;AA6BO,MAAM,yBAAA,CAAoD;AAAA,EAa/D,YACm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,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,IAAA,EAAM,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAA,EAAS;AAAA,EAC1B;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/bitbucketCloud/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 BITBUCKET_CLOUD_HOST = 'bitbucket.org';\nconst BITBUCKET_CLOUD_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket Cloud API provider.\n *\n * @public\n */\nexport type BitbucketCloudIntegrationConfig = {\n /**\n * Constant. bitbucket.org\n */\n host: string;\n\n /**\n * Constant. https://api.bitbucket.org/2.0\n */\n apiBaseUrl: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * The access token to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n token?: string;\n\n /** PGP private key for signing commits. */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket Cloud integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketCloudIntegrationConfig(\n config: Config,\n): BitbucketCloudIntegrationConfig {\n const host = BITBUCKET_CLOUD_HOST;\n const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;\n // If config is provided, we assume authenticated access is desired\n // (as the anonymous one is provided by default).\n const username = config.getString('username');\n const appPassword = config.getString('appPassword')?.trim();\n\n return {\n host,\n apiBaseUrl,\n username,\n appPassword,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket Cloud integration configs,\n * and inserts one for public Bitbucket Cloud if none specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketCloudIntegrationConfigs(\n configs: Config[],\n): BitbucketCloudIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketCloudIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added,\n // put one in the list as a convenience\n if (result.length === 0) {\n result.push({\n host: BITBUCKET_CLOUD_HOST,\n apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":";;AAkBA,MAAM,oBAAuB,GAAA,eAAA;AAC7B,MAAM,4BAA+B,GAAA,+BAAA;AA6C9B,SAAS,oCACd,MACiC,EAAA;AACjC,EAAA,MAAM,IAAO,GAAA,oBAAA;AACb,EAAA,MAAM,UAAa,GAAA,4BAAA;AAGnB,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA;AAC5C,EAAA,MAAM,WAAc,GAAA,MAAA,CAAO,SAAU,CAAA,aAAa,GAAG,IAAK,EAAA;AAE1D,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAO,CAAA,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AASO,SAAS,qCACd,OACmC,EAAA;AAEnC,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,mCAAmC,CAAA;AAI9D,EAAI,IAAA,MAAA,CAAO,WAAW,CAAG,EAAA;AACvB,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,oBAAA;AAAA,MACN,UAAY,EAAA;AAAA,KACb,CAAA;AAAA;AAGH,EAAO,OAAA,MAAA;AACT;;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../../src/bitbucketCloud/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 BITBUCKET_CLOUD_HOST = 'bitbucket.org';\nconst BITBUCKET_CLOUD_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket Cloud API provider.\n *\n * @public\n */\nexport type BitbucketCloudIntegrationConfig = {\n /**\n * Constant. bitbucket.org\n */\n host: string;\n\n /**\n * Constant. https://api.bitbucket.org/2.0\n */\n apiBaseUrl: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * The access token to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n token?: string;\n\n /** PGP private key for signing commits. */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket Cloud integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketCloudIntegrationConfig(\n config: Config,\n): BitbucketCloudIntegrationConfig {\n const host = BITBUCKET_CLOUD_HOST;\n const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;\n // If config is provided, we assume authenticated access is desired\n // (as the anonymous one is provided by default).\n const username = config.getString('username');\n const appPassword = config.getString('appPassword')?.trim();\n\n return {\n host,\n apiBaseUrl,\n username,\n appPassword,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket Cloud integration configs,\n * and inserts one for public Bitbucket Cloud if none specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketCloudIntegrationConfigs(\n configs: Config[],\n): BitbucketCloudIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketCloudIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added,\n // put one in the list as a convenience\n if (result.length === 0) {\n result.push({\n host: BITBUCKET_CLOUD_HOST,\n apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":";;AAkBA,MAAM,oBAAA,GAAuB,eAAA;AAC7B,MAAM,4BAAA,GAA+B,+BAAA;AA6C9B,SAAS,oCACd,MAAA,EACiC;AACjC,EAAA,MAAM,IAAA,GAAO,oBAAA;AACb,EAAA,MAAM,UAAA,GAAa,4BAAA;AAGnB,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,SAAA,CAAU,UAAU,CAAA;AAC5C,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,SAAA,CAAU,aAAa,GAAG,IAAA,EAAK;AAE1D,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAA,CAAO,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AASO,SAAS,qCACd,OAAA,EACmC;AAEnC,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,mCAAmC,CAAA;AAI9D,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM,oBAAA;AAAA,MACN,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,MAAA;AACT;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/bitbucketCloud/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 BITBUCKET_CLOUD_HOST = 'bitbucket.org';\nconst BITBUCKET_CLOUD_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket Cloud API provider.\n *\n * @public\n */\nexport type BitbucketCloudIntegrationConfig = {\n /**\n * Constant. bitbucket.org\n */\n host: string;\n\n /**\n * Constant. https://api.bitbucket.org/2.0\n */\n apiBaseUrl: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * The access token to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n token?: string;\n\n /** PGP private key for signing commits. */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket Cloud integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketCloudIntegrationConfig(\n config: Config,\n): BitbucketCloudIntegrationConfig {\n const host = BITBUCKET_CLOUD_HOST;\n const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;\n // If config is provided, we assume authenticated access is desired\n // (as the anonymous one is provided by default).\n const username = config.getString('username');\n const appPassword = config.getString('appPassword')?.trim();\n\n return {\n host,\n apiBaseUrl,\n username,\n appPassword,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket Cloud integration configs,\n * and inserts one for public Bitbucket Cloud if none specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketCloudIntegrationConfigs(\n configs: Config[],\n): BitbucketCloudIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketCloudIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added,\n // put one in the list as a convenience\n if (result.length === 0) {\n result.push({\n host: BITBUCKET_CLOUD_HOST,\n apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,oBAAuB,GAAA,eAAA;AAC7B,MAAM,4BAA+B,GAAA,+BAAA;AA6C9B,SAAS,oCACd,MACiC,EAAA;AACjC,EAAA,MAAM,IAAO,GAAA,oBAAA;AACb,EAAA,MAAM,UAAa,GAAA,4BAAA;AAGnB,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA;AAC5C,EAAA,MAAM,WAAc,GAAA,MAAA,CAAO,SAAU,CAAA,aAAa,GAAG,IAAK,EAAA;AAE1D,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAO,CAAA,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AASO,SAAS,qCACd,OACmC,EAAA;AAEnC,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,mCAAmC,CAAA;AAI9D,EAAI,IAAA,MAAA,CAAO,WAAW,CAAG,EAAA;AACvB,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,oBAAA;AAAA,MACN,UAAY,EAAA;AAAA,KACb,CAAA;AAAA;AAGH,EAAO,OAAA,MAAA;AACT;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/bitbucketCloud/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 BITBUCKET_CLOUD_HOST = 'bitbucket.org';\nconst BITBUCKET_CLOUD_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket Cloud API provider.\n *\n * @public\n */\nexport type BitbucketCloudIntegrationConfig = {\n /**\n * Constant. bitbucket.org\n */\n host: string;\n\n /**\n * Constant. https://api.bitbucket.org/2.0\n */\n apiBaseUrl: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * The access token to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n token?: string;\n\n /** PGP private key for signing commits. */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket Cloud integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketCloudIntegrationConfig(\n config: Config,\n): BitbucketCloudIntegrationConfig {\n const host = BITBUCKET_CLOUD_HOST;\n const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;\n // If config is provided, we assume authenticated access is desired\n // (as the anonymous one is provided by default).\n const username = config.getString('username');\n const appPassword = config.getString('appPassword')?.trim();\n\n return {\n host,\n apiBaseUrl,\n username,\n appPassword,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket Cloud integration configs,\n * and inserts one for public Bitbucket Cloud if none specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketCloudIntegrationConfigs(\n configs: Config[],\n): BitbucketCloudIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketCloudIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added,\n // put one in the list as a convenience\n if (result.length === 0) {\n result.push({\n host: BITBUCKET_CLOUD_HOST,\n apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,oBAAA,GAAuB,eAAA;AAC7B,MAAM,4BAAA,GAA+B,+BAAA;AA6C9B,SAAS,oCACd,MAAA,EACiC;AACjC,EAAA,MAAM,IAAA,GAAO,oBAAA;AACb,EAAA,MAAM,UAAA,GAAa,4BAAA;AAGnB,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,SAAA,CAAU,UAAU,CAAA;AAC5C,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,SAAA,CAAU,aAAa,GAAG,IAAA,EAAK;AAE1D,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAA,CAAO,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AASO,SAAS,qCACd,OAAA,EACmC;AAEnC,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,mCAAmC,CAAA;AAI9D,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM,oBAAA;AAAA,MACN,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,MAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"core.cjs.js","sources":["../../src/bitbucketCloud/core.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 fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketCloudIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDefaultBranch(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project } = parseGitUrl(url);\n\n const branchUrl = `${config.apiBaseUrl}/repositories/${project}/${repoName}`;\n const response = await fetch(\n branchUrl,\n getBitbucketCloudRequestOptions(config),\n );\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n const repoInfo = await response.json();\n const defaultBranch = repoInfo.mainbranch.name;\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDownloadUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n } = parseGitUrl(url);\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketCloudDefaultBranch(url, config);\n }\n return `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudFileFetchUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (!owner || !name || (filepathtype !== 'src' && filepathtype !== 'raw')) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (!ref) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudRequestOptions(\n config: BitbucketCloudIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n"],"names":["parseGitUrl","fetch"],"mappings":";;;;;;;;;;AA2BsB,eAAA,8BAAA,CACpB,KACA,MACiB,EAAA;AACjB,EAAA,MAAM,EAAE,IAAM,EAAA,QAAA,EAAU,OAAO,OAAQ,EAAA,GAAIA,6BAAY,GAAG,CAAA;AAE1D,EAAA,MAAM,YAAY,CAAG,EAAA,MAAA,CAAO,UAAU,CA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esContent":["/*\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 fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketCloudIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDefaultBranch(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project } = parseGitUrl(url);\n\n const branchUrl = `${config.apiBaseUrl}/repositories/${project}/${repoName}`;\n const response = await fetch(\n branchUrl,\n getBitbucketCloudRequestOptions(config),\n );\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n const repoInfo = await response.json();\n const defaultBranch = repoInfo.mainbranch.name;\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDownloadUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n } = parseGitUrl(url);\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketCloudDefaultBranch(url, config);\n }\n return `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudFileFetchUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (!owner || !name || (filepathtype !== 'src' && filepathtype !== 'raw')) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (!ref) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudRequestOptions(\n config: BitbucketCloudIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n"],"names":["parseGitUrl","fetch"],"mappings":";;;;;;;;;;AA2BA,eAAsB,8BAAA,CACpB,KACA,MAAA,EACiB;AACjB,EAAA,MAAM,EAAE,IAAA,EAAM,QAAA,EAAU,OAAO,OAAA,EAAQ,GAAIA,6BAAY,GAAG,CAAA;AAE1D,EAAA,MAAM,YAAY,CAAA,EAAG,MAAA,CAAO,UAAU,CAAA,cAAA,EAAiB,OAAO,IAAI,QAAQ,CAAA,CAAA;AAC1E,EAAA,MAAM,WAAW,MAAMC,sBAAA;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\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 fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketCloudIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDefaultBranch(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project } = parseGitUrl(url);\n\n const branchUrl = `${config.apiBaseUrl}/repositories/${project}/${repoName}`;\n const response = await fetch(\n branchUrl,\n getBitbucketCloudRequestOptions(config),\n );\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n const repoInfo = await response.json();\n const defaultBranch = repoInfo.mainbranch.name;\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDownloadUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n } = parseGitUrl(url);\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketCloudDefaultBranch(url, config);\n }\n return `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudFileFetchUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (!owner || !name || (filepathtype !== 'src' && filepathtype !== 'raw')) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (!ref) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudRequestOptions(\n config: BitbucketCloudIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n"],"names":[],"mappings":";;;AA2BsB,eAAA,8BAAA,CACpB,KACA,MACiB,EAAA;AACjB,EAAA,MAAM,EAAE,IAAM,EAAA,QAAA,EAAU,OAAO,OAAQ,EAAA,GAAI,YAAY,GAAG,CAAA;AAE1D,EAAA,MAAM,YAAY,CAAG,EAAA,MAAA,CAAO,UAAU,CAAiB,cAAA,EAAA,OAAO,IAAI,QAAQ,CAAA,CAAA;AAC1E,EAAA,MAAM,WAAW,MAAM,KAAA;AAAA,IACrB,SAAA;AAAA,IACA,gCAAgC,MAAM;AAAA,GACxC;AAEA,E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AA,CAAC,QAAS,YAAiB,KAAA,KAAA,IAAS,iBAAiB,KAAQ,EAAA;AACzE,MAAM,MAAA,IAAI,MAAM,0CAA0C,CAAA;AAAA;AAG5D,IAAA,MAAM,gBAAmB,GAAA,QAAA,CAAS,OAAQ,CAAA,KAAA,EAAO,EAAE,CAAA;AAEnD,IAAA,IAAI,CAAC,GAAK,EAAA;AACR,MAAM,MAAA,IAAI,MAAM,0CAA0C,CAAA;AAAA;AAE5D,IAAO,OAAA,CAAA,EAAG,MAAO,CAAA,UAAU,CAAiB,cAAA,EAAA,KAAK,IAAI,IAAI,CAAA,KAAA,EAAQ,GAAG,CAAA,CAAA,EAAI,gBAAgB,CAAA,CAAA;AAAA,WACjF,CAAG,EAAA;AACV,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,eAAA,EAAkB,GAAG,CAAA,EAAA,EAAK,CAAC,CAAE,CAAA,CAAA;AAAA;AAEjD;AAQO,SAAS,gCACd,MACqC,EAAA;AACrC,EAAA,MAAM,UAAkC,EAAC;AAEzC,EAAI,IAAA,MAAA,CAAO,QAAY,IAAA,MAAA,CAAO,WAAa,EAAA;AACzC,IAAA,MAAM,SAAS,MAAO,CAAA,IAAA;AAAA,MACpB,CAAG,EAAA,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC;AAAA,KACF;AACA,IAAA,OAAA,CAAQ,aAAgB,GAAA,CAAA,MAAA,EAAS,MAAO,CAAA,QAAA,CAAS,QAAQ,CAAC,CAAA,CAAA;AAAA;AAG5D,EAAO,OAAA;AAAA,IACL;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"core.esm.js","sources":["../../src/bitbucketCloud/core.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 fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketCloudIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDefaultBranch(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project } = parseGitUrl(url);\n\n const branchUrl = `${config.apiBaseUrl}/repositories/${project}/${repoName}`;\n const response = await fetch(\n branchUrl,\n getBitbucketCloudRequestOptions(config),\n );\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n const repoInfo = await response.json();\n const defaultBranch = repoInfo.mainbranch.name;\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDownloadUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n } = parseGitUrl(url);\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketCloudDefaultBranch(url, config);\n }\n return `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudFileFetchUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (!owner || !name || (filepathtype !== 'src' && filepathtype !== 'raw')) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (!ref) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudRequestOptions(\n config: BitbucketCloudIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n"],"names":[],"mappings":";;;AA2BA,eAAsB,8BAAA,CACpB,KACA,MAAA,EACiB;AACjB,EAAA,MAAM,EAAE,IAAA,EAAM,QAAA,EAAU,OAAO,OAAA,EAAQ,GAAI,YAAY,GAAG,CAAA;AAE1D,EAAA,MAAM,YAAY,CAAA,EAAG,MAAA,CAAO,UAAU,CAAA,cAAA,EAAiB,OAAO,IAAI,QAAQ,CAAA,CAAA;AAC1E,EAAA,MAAM,WAAW,MAAM,KAAA;AAAA,IACrB,SAAA;AAAA,IACA,gCAAgC,MAAM;AAAA,GACxC;AAEA,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,IAAA,MAAM,OAAA,GAAU,0CAA0C,SAAS,CAAA,EAAA,EAAK,SAAS,MAAM,CAAA,CAAA,EA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,IAC5D;AAEA,IAAA,MAAM,gBAAA,GAAmB,QAAA,CAAS,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAEnD,IAAA,IAAI,CAAC,GAAA,EAAK;AACR,MAAA,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAAA,IAC5D;AACA,IAAA,OAAO,CAAA,EAAG,MAAA,CAAO,UAAU,CAAA,cAAA,EAAiB,KAAK,IAAI,IAAI,CAAA,KAAA,EAAQ,GAAG,CAAA,CAAA,EAAI,gBAAgB,CAAA,CAAA;AAAA,EAC1F,SAAS,CAAA,EAAG;AACV,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,eAAA,EAAkB,GAAG,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EAC/C;AACF;AAQO,SAAS,gCACd,MAAA,EACqC;AACrC,EAAA,MAAM,UAAkC,EAAC;AAEzC,EAAA,IAAI,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,WAAA,EAAa;AACzC,IAAA,MAAM,SAAS,MAAA,CAAO,IAAA;AAAA,MACpB,CAAA,EAAG,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC;AAAA,KACF;AACA,IAAA,OAAA,CAAQ,aAAA,GAAgB,CAAA,MAAA,EAAS,MAAA,CAAO,QAAA,CAAS,QAAQ,CAAC,CAAA,CAAA;AAAA,EAC5D;AAEA,EAAA,OAAO;AAAA,IACL;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BitbucketServerIntegration.cjs.js","sources":["../../src/bitbucketServer/BitbucketServerIntegration.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 BitbucketServerIntegrationConfig,\n readBitbucketServerIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Server based integration.\n *\n * @public\n */\nexport class BitbucketServerIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketServerIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketServerIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketServer') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketServerIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketServerIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketServer';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketServerIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Server line numbers use the syntax #42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = options.lineNumber.toString();\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // Bitbucket Server doesn't support deep linking to edit mode, therefore there's nothing to do here.\n // We just remove query parameters since they cause issues with TechDocs edit button.\n if (url.includes('?')) {\n return url.substring(0, url.indexOf('?'));\n }\n return url;\n }\n}\n"],"names":["config","readBitbucketServerIntegrationConfigs","basicIntegrations","defaultScmResolveUrl"],"mappings":";;;;;AA4BO,MAAM,0BAAqD,CAAA;AAAA,EAahE,YACmB,iBACjB,EAAA;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAChB,EAdH,OAAO,UAA8D,CAAC;AAAA,YACpEA;AAAA,GACI,KAAA;AACJ,IAAA,MAAM,OAAU,GAAAC,4CAAA;AAAA,MACdD,QAAO,CAAA,sBAAA,CAAuB,8BAA8B,CAAA,IAAK;AAAC,KACpE;AACA,IAAO,OAAAE,yBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,0BAAA,CAA2B,CAAC,CAAC,CAAA;AAAA,MAClD,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA;AAAA,KAChB;AAAA,GACF;AAAA,EAMA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,iBAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA;AAAA;AAChC,EAEA,IAAI,MAA2C,GAAA;AAC7C,IAAA,OAAO,IAAK,CAAA,iBAAA;AAAA;AACd,EAEA,WAAW,OAIA,EAAA;AACT,IAAM,MAAA,QAAA,GAAWC,6BAAqB,OAAO,CAAA;AAG7C,IAAA,IAAI,QAAQ,UAAY,EAAA;AACtB,MAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAE5B,MAAI,GAAA,CAAA,IAAA,GAAO,OAAQ,CAAA,UAAA,CAAW,QAAS,EAAA;AACvC,MAAA,OAAO,IAAI,QAAS,EAAA;AAAA;AAGtB,IAAO,OAAA,QAAA;AAAA;AACT,EAEA,eAAe,GAAqB,EAAA;AAGlC,IAAI,IAAA,GAAA,CAAI,QAAS,CAAA,GAAG,CAAG,EAAA;AACrB,MAAA,OAAO,IAAI,SAAU,CAAA,CAAA,EAAG,GAAI,CAAA,OAAA,CAAQ,GAAG,CAAC,CAAA;AAAA;AAE1C,IAAO,OAAA,GAAA;AAAA;AAEX;;;;"}
1
+ {"version":3,"file":"BitbucketServerIntegration.cjs.js","sources":["../../src/bitbucketServer/BitbucketServerIntegration.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 BitbucketServerIntegrationConfig,\n readBitbucketServerIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Server based integration.\n *\n * @public\n */\nexport class BitbucketServerIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketServerIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketServerIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketServer') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketServerIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketServerIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketServer';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketServerIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Server line numbers use the syntax #42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = options.lineNumber.toString();\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // Bitbucket Server doesn't support deep linking to edit mode, therefore there's nothing to do here.\n // We just remove query parameters since they cause issues with TechDocs edit button.\n if (url.includes('?')) {\n return url.substring(0, url.indexOf('?'));\n }\n return url;\n }\n}\n"],"names":["config","readBitbucketServerIntegrationConfigs","basicIntegrations","defaultScmResolveUrl"],"mappings":";;;;;AA4BO,MAAM,0BAAA,CAAqD;A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,GAAA;AAAA,EACT;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BitbucketServerIntegration.esm.js","sources":["../../src/bitbucketServer/BitbucketServerIntegration.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 BitbucketServerIntegrationConfig,\n readBitbucketServerIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Server based integration.\n *\n * @public\n */\nexport class BitbucketServerIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketServerIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketServerIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketServer') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketServerIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketServerIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketServer';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketServerIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Server line numbers use the syntax #42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = options.lineNumber.toString();\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // Bitbucket Server doesn't support deep linking to edit mode, therefore there's nothing to do here.\n // We just remove query parameters since they cause issues with TechDocs edit button.\n if (url.includes('?')) {\n return url.substring(0, url.indexOf('?'));\n }\n return url;\n }\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,0BAAqD,CAAA;AAAA,EAahE,YACmB,iBACjB,EAAA;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAChB,EAdH,OAAO,UAA8D,CAAC;AAAA,IACpE;AAAA,GACI,KAAA;AACJ,IAAA,MAAM,OAAU,GAAA,qCAAA;AAAA,MACd,MAAO,CAAA,sBAAA,CAAuB,8BAA8B,CAAA,IAAK;AAAC,KACpE;AACA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,0BAAA,CAA2B,CAAC,CAAC,CAAA;AAAA,MAClD,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA;AAAA,KAChB;AAAA,GACF;AAAA,EAMA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,iBAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA;AAAA;AAChC,EAEA,IAAI,MAA2C,GAAA;AAC7C,IAAA,OAAO,IAAK,CAAA,iBAAA;AAAA;AACd,EAEA,WAAW,OAIA,EAAA;AACT,IAAM,MAAA,QAAA,GAAW,qBAAqB,OAAO,CAAA;AAG7C,IAAA,IAAI,QAAQ,UAAY,EAAA;AACtB,MAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAE5B,MAAI,GAAA,CAAA,IAAA,GAAO,OAAQ,CAAA,UAAA,CAAW,QAAS,EAAA;AACvC,MAAA,OAAO,IAAI,QAAS,EAAA;AAAA;AAGtB,IAAO,OAAA,QAAA;AAAA;AACT,EAEA,eAAe,GAAqB,EAAA;AAGlC,IAAI,IAAA,GAAA,CAAI,QAAS,CAAA,GAAG,CAAG,EAAA;AACrB,MAAA,OAAO,IAAI,SAAU,CAAA,CAAA,EAAG,GAAI,CAAA,OAAA,CAAQ,GAAG,CAAC,CAAA;AAAA;AAE1C,IAAO,OAAA,GAAA;AAAA;AAEX;;;;"}
1
+ {"version":3,"file":"BitbucketServerIntegration.esm.js","sources":["../../src/bitbucketServer/BitbucketServerIntegration.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 BitbucketServerIntegrationConfig,\n readBitbucketServerIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Server based integration.\n *\n * @public\n */\nexport class BitbucketServerIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketServerIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketServerIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketServer') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketServerIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketServerIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketServer';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketServerIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Server line numbers use the syntax #42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = options.lineNumber.toString();\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // Bitbucket Server doesn't support deep linking to edit mode, therefore there's nothing to do here.\n // We just remove query parameters since they cause issues with TechDocs edit button.\n if (url.includes('?')) {\n return url.substring(0, url.indexOf('?'));\n }\n return url;\n }\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,0BAAA,CAAqD;AAAA,EAahE,YACmB,iBAAA,EACjB;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAChB;AAAA,EAdH,OAAO,UAA8D,CAAC;AAAA,IACpE;AAAA,GACF,KAAM;AACJ,IAAA,MAAM,OAAA,GAAU,qCAAA;AAAA,MACd,MAAA,CAAO,sBAAA,CAAuB,8BAA8B,CAAA,IAAK;AAAC,KACpE;AACA,IAAA,OAAO,iBAAA;AAAA,MACL,QAAQ,GAAA,CAAI,CAAA,CAAA,KAAK,IAAI,0BAAA,CAA2B,CAAC,CAAC,CAAA;AAAA,MAClD,CAAA,CAAA,KAAK,EAAE,MAAA,CAAO;AAAA,KAChB;AAAA,EACF,CAAA;AAAA,EAMA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,iBAAA;AAAA,EACT;AAAA,EAEA,IAAI,KAAA,GAAgB;AAClB,IAAA,OAAO,KAAK,iBAAA,CAAkB,IAAA;AAAA,EAChC;AAAA,EAEA,IAAI,MAAA,GAA2C;AAC7C,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EACd;AAAA,EAEA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,QAAA,GAAW,qBAAqB,OAAO,CAAA;AAG7C,IAAA,IAAI,QAAQ,UAAA,EAAY;AACtB,MAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA;AAE5B,MAAA,GAAA,CAAI,IAAA,GAAO,OAAA,CAAQ,UAAA,CAAW,QAAA,EAAS;AACvC,MAAA,OAAO,IAAI,QAAA,EAAS;AAAA,IACtB;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EAEA,eAAe,GAAA,EAAqB;AAGlC,IAAA,IAAI,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AACrB,MAAA,OAAO,IAAI,SAAA,CAAU,CAAA,EAAG,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAC,CAAA;AAAA,IAC1C;AACA,IAAA,OAAO,GAAA;AAAA,EACT;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/bitbucketServer/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\n/**\n * The configuration parameters for a single Bitbucket Server API provider.\n *\n * @public\n */\nexport type BitbucketServerIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.company.com\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://<host>/rest/api/1.0\",\n * with no trailing slash.\n *\n * The API will always be preferred if both its base URL and a token are\n * present.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n username?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n password?: string;\n\n /**\n * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket Server integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketServerIntegrationConfig(\n config: Config,\n): BitbucketServerIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket Server integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n password,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket Server integration configs.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketServerIntegrationConfigs(\n configs: Config[],\n): BitbucketServerIntegrationConfig[] {\n // Read all the explicit integrations\n // No default integration will be added\n return configs.map(readBitbucketServerIntegrationConfig);\n}\n"],"names":["isValidHost","trimEnd"],"mappings":";;;;;AA+EO,SAAS,qCACd,MACkC,EAAA;AAClC,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA;AACpC,EAAI,IAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA;AACtD,EAAA,MAAM,KAAQ,GAAA,MAAA,CAAO,iBAAkB,CAAA,OAAO,GAAG,IAAK,EAAA;AACtD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA;AAEpD,EAAI,IAAA,CAACA,mBAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,iDAAiD,IAAI,CAAA,qBAAA;AAAA,KACvD;AAAA;AAGF,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAAC,cAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,GAC/B,MAAA;AACL,IAAA,UAAA,GAAa,WAAW,IAAI,CAAA,aAAA,CAAA;AAAA;AAG9B,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA,EAAkB,MAAO,CAAA,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AAQO,SAAS,sCACd,OACoC,EAAA;AAGpC,EAAO,OAAA,OAAA,CAAQ,IAAI,oCAAoC,CAAA;AACzD;;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../../src/bitbucketServer/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\n/**\n * The configuration parameters for a single Bitbucket Server API provider.\n *\n * @public\n */\nexport type BitbucketServerIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.company.com\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://<host>/rest/api/1.0\",\n * with no trailing slash.\n *\n * The API will always be preferred if both its base URL and a token are\n * present.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n username?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n password?: string;\n\n /**\n * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * Reads a single Bitbucket Server integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketServerIntegrationConfig(\n config: Config,\n): BitbucketServerIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket Server integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n password,\n commitSigningKey: config.getOptionalString('commitSigningKey'),\n };\n}\n\n/**\n * Reads a set of Bitbucket Server integration configs.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketServerIntegrationConfigs(\n configs: Config[],\n): BitbucketServerIntegrationConfig[] {\n // Read all the explicit integrations\n // No default integration will be added\n return configs.map(readBitbucketServerIntegrationConfig);\n}\n"],"names":["isValidHost","trimEnd"],"mappings":";;;;;AA+EO,SAAS,qCACd,MAAA,EACkC;AAClC,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,SAAA,CAAU,MAAM,CAAA;AACpC,EAAA,IAAI,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AACtD,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,iBAAA,CAAkB,OAAO,GAAG,IAAA,EAAK;AACtD,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU,CAAA;AACpD,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU,CAAA;AAEpD,EAAA,IAAI,CAACA,mBAAA,CAAY,IAAI,CAAA,EAAG;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,iDAAiD,IAAI,CAAA,qBAAA;AAAA,KACvD;AAAA,EACF;AAEA,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,UAAA,GAAaC,cAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,EACtC,CAAA,MAAO;AACL,IAAA,UAAA,GAAa,WAAW,IAAI,CAAA,aAAA,CAAA;AAAA,EAC9B;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA,EAAkB,MAAA,CAAO,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AAQO,SAAS,sCACd,OAAA,EACoC;AAGpC,EAAA,OAAO,OAAA,CAAQ,IAAI,oCAAoC,CAAA;AACzD;;;;;"}