@backstage/integration 1.15.1-next.1 → 1.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/CHANGELOG.md +19 -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/config.cjs.js.map +1 -1
  21. package/dist/azure/config.esm.js.map +1 -1
  22. package/dist/azure/core.cjs.js.map +1 -1
  23. package/dist/azure/core.esm.js.map +1 -1
  24. package/dist/azure/deprecated.cjs.js.map +1 -1
  25. package/dist/azure/deprecated.esm.js.map +1 -1
  26. package/dist/bitbucket/BitbucketIntegration.cjs.js.map +1 -1
  27. package/dist/bitbucket/BitbucketIntegration.esm.js.map +1 -1
  28. package/dist/bitbucket/config.cjs.js.map +1 -1
  29. package/dist/bitbucket/config.esm.js.map +1 -1
  30. package/dist/bitbucket/core.cjs.js.map +1 -1
  31. package/dist/bitbucket/core.esm.js.map +1 -1
  32. package/dist/bitbucketCloud/BitbucketCloudIntegration.cjs.js.map +1 -1
  33. package/dist/bitbucketCloud/BitbucketCloudIntegration.esm.js.map +1 -1
  34. package/dist/bitbucketCloud/config.cjs.js.map +1 -1
  35. package/dist/bitbucketCloud/config.esm.js.map +1 -1
  36. package/dist/bitbucketCloud/core.cjs.js.map +1 -1
  37. package/dist/bitbucketCloud/core.esm.js.map +1 -1
  38. package/dist/bitbucketServer/BitbucketServerIntegration.cjs.js.map +1 -1
  39. package/dist/bitbucketServer/BitbucketServerIntegration.esm.js.map +1 -1
  40. package/dist/bitbucketServer/config.cjs.js.map +1 -1
  41. package/dist/bitbucketServer/config.esm.js.map +1 -1
  42. package/dist/bitbucketServer/core.cjs.js.map +1 -1
  43. package/dist/bitbucketServer/core.esm.js.map +1 -1
  44. package/dist/gerrit/GerritIntegration.cjs.js.map +1 -1
  45. package/dist/gerrit/GerritIntegration.esm.js.map +1 -1
  46. package/dist/gerrit/config.cjs.js.map +1 -1
  47. package/dist/gerrit/config.esm.js.map +1 -1
  48. package/dist/gerrit/core.cjs.js.map +1 -1
  49. package/dist/gerrit/core.esm.js.map +1 -1
  50. package/dist/gitea/GiteaIntegration.cjs.js.map +1 -1
  51. package/dist/gitea/GiteaIntegration.esm.js.map +1 -1
  52. package/dist/gitea/config.cjs.js.map +1 -1
  53. package/dist/gitea/config.esm.js.map +1 -1
  54. package/dist/gitea/core.cjs.js.map +1 -1
  55. package/dist/gitea/core.esm.js.map +1 -1
  56. package/dist/github/DefaultGithubCredentialsProvider.cjs.js.map +1 -1
  57. package/dist/github/DefaultGithubCredentialsProvider.esm.js.map +1 -1
  58. package/dist/github/GithubIntegration.cjs.js.map +1 -1
  59. package/dist/github/GithubIntegration.esm.js.map +1 -1
  60. package/dist/github/SingleInstanceGithubCredentialsProvider.cjs.js.map +1 -1
  61. package/dist/github/SingleInstanceGithubCredentialsProvider.esm.js.map +1 -1
  62. package/dist/github/config.cjs.js.map +1 -1
  63. package/dist/github/config.esm.js.map +1 -1
  64. package/dist/github/core.cjs.js.map +1 -1
  65. package/dist/github/core.esm.js.map +1 -1
  66. package/dist/gitlab/DefaultGitlabCredentialsProvider.cjs.js.map +1 -1
  67. package/dist/gitlab/DefaultGitlabCredentialsProvider.esm.js.map +1 -1
  68. package/dist/gitlab/GitLabIntegration.cjs.js.map +1 -1
  69. package/dist/gitlab/GitLabIntegration.esm.js.map +1 -1
  70. package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.cjs.js.map +1 -1
  71. package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.esm.js.map +1 -1
  72. package/dist/gitlab/config.cjs.js.map +1 -1
  73. package/dist/gitlab/config.esm.js.map +1 -1
  74. package/dist/gitlab/core.cjs.js.map +1 -1
  75. package/dist/gitlab/core.esm.js.map +1 -1
  76. package/dist/googleGcs/config.cjs.js.map +1 -1
  77. package/dist/googleGcs/config.esm.js.map +1 -1
  78. package/dist/harness/HarnessIntegration.cjs.js.map +1 -1
  79. package/dist/harness/HarnessIntegration.esm.js.map +1 -1
  80. package/dist/harness/config.cjs.js.map +1 -1
  81. package/dist/harness/config.esm.js.map +1 -1
  82. package/dist/harness/core.cjs.js.map +1 -1
  83. package/dist/harness/core.esm.js.map +1 -1
  84. package/dist/helpers.cjs.js.map +1 -1
  85. package/dist/helpers.esm.js.map +1 -1
  86. package/package.json +12 -5
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/github/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 GITHUB_HOST = 'github.com';\nconst GITHUB_API_BASE_URL = 'https://api.github.com';\nconst GITHUB_RAW_BASE_URL = 'https://raw.githubusercontent.com';\n\n/**\n * The configuration parameters for a single GitHub integration.\n *\n * @public\n */\nexport type GithubIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"github.com\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.github.com\",\n * with no trailing slash.\n *\n * May be omitted specifically for GitHub; then it will be deduced.\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 base URL of the raw fetch endpoint of this provider, e.g.\n * \"https://raw.githubusercontent.com\", with no trailing slash.\n *\n * May be omitted specifically for GitHub; then it will be deduced.\n *\n * The API will always be preferred if both its base URL and a token are\n * present.\n */\n rawBaseUrl?: string;\n\n /**\n * The authorization token to use for requests to this provider.\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The GitHub Apps configuration to use for requests to this provider.\n *\n * If no apps are specified, token or anonymous is used.\n */\n apps?: GithubAppConfig[];\n};\n\n/**\n * The configuration parameters for authenticating a GitHub Application.\n *\n * @remarks\n *\n * A GitHub Apps configuration can be generated using the `backstage-cli create-github-app` command.\n *\n * @public\n */\nexport type GithubAppConfig = {\n /**\n * Unique app identifier, found at https://github.com/organizations/$org/settings/apps/$AppName\n */\n appId: number;\n /**\n * The private key is used by the GitHub App integration to authenticate the app.\n * A private key can be generated from the app at https://github.com/organizations/$org/settings/apps/$AppName\n */\n privateKey: string;\n /**\n * Webhook secret can be configured at https://github.com/organizations/$org/settings/apps/$AppName\n */\n webhookSecret: string;\n /**\n * Found at https://github.com/organizations/$org/settings/apps/$AppName\n */\n clientId: string;\n /**\n * Client secrets can be generated at https://github.com/organizations/$org/settings/apps/$AppName\n */\n clientSecret: string;\n /**\n * List of installation owners allowed to be used by this GitHub app. The GitHub UI does not provide a way to list the installations.\n * However you can list the installations with the GitHub API. You can find the list of installations here:\n * https://api.github.com/app/installations\n * The relevant documentation for this is here.\n * https://docs.github.com/en/rest/reference/apps#list-installations-for-the-authenticated-app--code-samples\n */\n allowedInstallationOwners?: string[];\n};\n\n/**\n * Reads a single GitHub integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGithubIntegrationConfig(\n config: Config,\n): GithubIntegrationConfig {\n const host = config.getOptionalString('host') ?? GITHUB_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n let rawBaseUrl = config.getOptionalString('rawBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const apps = config.getOptionalConfigArray('apps')?.map(c => ({\n appId: c.getNumber('appId'),\n clientId: c.getString('clientId'),\n clientSecret: c.getString('clientSecret'),\n webhookSecret: c.getString('webhookSecret'),\n privateKey: c.getString('privateKey'),\n allowedInstallationOwners: c.getOptionalStringArray(\n 'allowedInstallationOwners',\n ),\n }));\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid GitHub integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === GITHUB_HOST) {\n apiBaseUrl = GITHUB_API_BASE_URL;\n }\n\n if (rawBaseUrl) {\n rawBaseUrl = trimEnd(rawBaseUrl, '/');\n } else if (host === GITHUB_HOST) {\n rawBaseUrl = GITHUB_RAW_BASE_URL;\n }\n\n return { host, apiBaseUrl, rawBaseUrl, token, apps };\n}\n\n/**\n * Reads a set of GitHub integration configs, and inserts some defaults for\n * public GitHub if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readGithubIntegrationConfigs(\n configs: Config[],\n): GithubIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readGithubIntegrationConfig);\n\n // If no explicit github.com integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === GITHUB_HOST)) {\n result.push({\n host: GITHUB_HOST,\n apiBaseUrl: GITHUB_API_BASE_URL,\n rawBaseUrl: GITHUB_RAW_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":";;;AAoBA,MAAM,WAAc,GAAA,YAAA,CAAA;AACpB,MAAM,mBAAsB,GAAA,wBAAA,CAAA;AAC5B,MAAM,mBAAsB,GAAA,mCAAA,CAAA;AAiGrB,SAAS,4BACd,MACyB,EAAA;AACzB,EAAA,MAAM,IAAO,GAAA,MAAA,CAAO,iBAAkB,CAAA,MAAM,CAAK,IAAA,WAAA,CAAA;AACjD,EAAI,IAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA,CAAA;AACtD,EAAI,IAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA,CAAA;AACtD,EAAA,MAAM,KAAQ,GAAA,MAAA,CAAO,iBAAkB,CAAA,OAAO,GAAG,IAAK,EAAA,CAAA;AACtD,EAAA,MAAM,OAAO,MAAO,CAAA,sBAAA,CAAuB,MAAM,CAAA,EAAG,IAAI,CAAM,CAAA,MAAA;AAAA,IAC5D,KAAA,EAAO,CAAE,CAAA,SAAA,CAAU,OAAO,CAAA;AAAA,IAC1B,QAAA,EAAU,CAAE,CAAA,SAAA,CAAU,UAAU,CAAA;AAAA,IAChC,YAAA,EAAc,CAAE,CAAA,SAAA,CAAU,cAAc,CAAA;AAAA,IACxC,aAAA,EAAe,CAAE,CAAA,SAAA,CAAU,eAAe,CAAA;AAAA,IAC1C,UAAA,EAAY,CAAE,CAAA,SAAA,CAAU,YAAY,CAAA;AAAA,IACpC,2BAA2B,CAAE,CAAA,sBAAA;AAAA,MAC3B,2BAAA;AAAA,KACF;AAAA,GACA,CAAA,CAAA,CAAA;AAEF,EAAI,IAAA,CAAC,WAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,IAAI,CAAA,qBAAA,CAAA;AAAA,KAC7C,CAAA;AAAA,GACF;AAEA,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAA,OAAA,CAAQ,YAAY,GAAG,CAAA,CAAA;AAAA,GACtC,MAAA,IAAW,SAAS,WAAa,EAAA;AAC/B,IAAa,UAAA,GAAA,mBAAA,CAAA;AAAA,GACf;AAEA,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAA,OAAA,CAAQ,YAAY,GAAG,CAAA,CAAA;AAAA,GACtC,MAAA,IAAW,SAAS,WAAa,EAAA;AAC/B,IAAa,UAAA,GAAA,mBAAA,CAAA;AAAA,GACf;AAEA,EAAA,OAAO,EAAE,IAAA,EAAM,UAAY,EAAA,UAAA,EAAY,OAAO,IAAK,EAAA,CAAA;AACrD,CAAA;AASO,SAAS,6BACd,OAC2B,EAAA;AAE3B,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,2BAA2B,CAAA,CAAA;AAItD,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,WAAW,CAAG,EAAA;AAC7C,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,WAAA;AAAA,MACN,UAAY,EAAA,mBAAA;AAAA,MACZ,UAAY,EAAA,mBAAA;AAAA,KACb,CAAA,CAAA;AAAA,GACH;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/github/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 GITHUB_HOST = 'github.com';\nconst GITHUB_API_BASE_URL = 'https://api.github.com';\nconst GITHUB_RAW_BASE_URL = 'https://raw.githubusercontent.com';\n\n/**\n * The configuration parameters for a single GitHub integration.\n *\n * @public\n */\nexport type GithubIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"github.com\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.github.com\",\n * with no trailing slash.\n *\n * May be omitted specifically for GitHub; then it will be deduced.\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 base URL of the raw fetch endpoint of this provider, e.g.\n * \"https://raw.githubusercontent.com\", with no trailing slash.\n *\n * May be omitted specifically for GitHub; then it will be deduced.\n *\n * The API will always be preferred if both its base URL and a token are\n * present.\n */\n rawBaseUrl?: string;\n\n /**\n * The authorization token to use for requests to this provider.\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The GitHub Apps configuration to use for requests to this provider.\n *\n * If no apps are specified, token or anonymous is used.\n */\n apps?: GithubAppConfig[];\n};\n\n/**\n * The configuration parameters for authenticating a GitHub Application.\n *\n * @remarks\n *\n * A GitHub Apps configuration can be generated using the `backstage-cli create-github-app` command.\n *\n * @public\n */\nexport type GithubAppConfig = {\n /**\n * Unique app identifier, found at https://github.com/organizations/$org/settings/apps/$AppName\n */\n appId: number;\n /**\n * The private key is used by the GitHub App integration to authenticate the app.\n * A private key can be generated from the app at https://github.com/organizations/$org/settings/apps/$AppName\n */\n privateKey: string;\n /**\n * Webhook secret can be configured at https://github.com/organizations/$org/settings/apps/$AppName\n */\n webhookSecret: string;\n /**\n * Found at https://github.com/organizations/$org/settings/apps/$AppName\n */\n clientId: string;\n /**\n * Client secrets can be generated at https://github.com/organizations/$org/settings/apps/$AppName\n */\n clientSecret: string;\n /**\n * List of installation owners allowed to be used by this GitHub app. The GitHub UI does not provide a way to list the installations.\n * However you can list the installations with the GitHub API. You can find the list of installations here:\n * https://api.github.com/app/installations\n * The relevant documentation for this is here.\n * https://docs.github.com/en/rest/reference/apps#list-installations-for-the-authenticated-app--code-samples\n */\n allowedInstallationOwners?: string[];\n};\n\n/**\n * Reads a single GitHub integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGithubIntegrationConfig(\n config: Config,\n): GithubIntegrationConfig {\n const host = config.getOptionalString('host') ?? GITHUB_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n let rawBaseUrl = config.getOptionalString('rawBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const apps = config.getOptionalConfigArray('apps')?.map(c => ({\n appId: c.getNumber('appId'),\n clientId: c.getString('clientId'),\n clientSecret: c.getString('clientSecret'),\n webhookSecret: c.getString('webhookSecret'),\n privateKey: c.getString('privateKey'),\n allowedInstallationOwners: c.getOptionalStringArray(\n 'allowedInstallationOwners',\n ),\n }));\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid GitHub integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === GITHUB_HOST) {\n apiBaseUrl = GITHUB_API_BASE_URL;\n }\n\n if (rawBaseUrl) {\n rawBaseUrl = trimEnd(rawBaseUrl, '/');\n } else if (host === GITHUB_HOST) {\n rawBaseUrl = GITHUB_RAW_BASE_URL;\n }\n\n return { host, apiBaseUrl, rawBaseUrl, token, apps };\n}\n\n/**\n * Reads a set of GitHub integration configs, and inserts some defaults for\n * public GitHub if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readGithubIntegrationConfigs(\n configs: Config[],\n): GithubIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readGithubIntegrationConfig);\n\n // If no explicit github.com integration was added, put one in the list as\n // a convenience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AAY,EAAA;AACd,IAAa,UAAA,GAAA,OAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,GACtC,MAAA,IAAW,SAAS,WAAa,EAAA;AAC/B,IAAa,UAAA,GAAA,mBAAA;AAAA;AAGf,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAA,OAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,GACtC,MAAA,IAAW,SAAS,WAAa,EAAA;AAC/B,IAAa,UAAA,GAAA,mBAAA;AAAA;AAGf,EAAA,OAAO,EAAE,IAAA,EAAM,UAAY,EAAA,UAAA,EAAY,OAAO,IAAK,EAAA;AACrD;AASO,SAAS,6BACd,OAC2B,EAAA;AAE3B,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,2BAA2B,CAAA;AAItD,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,WAAW,CAAG,EAAA;AAC7C,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,WAAA;AAAA,MACN,UAAY,EAAA,mBAAA;AAAA,MACZ,UAAY,EAAA;AAAA,KACb,CAAA;AAAA;AAGH,EAAO,OAAA,MAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"core.cjs.js","sources":["../../src/github/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 parseGitUrl from 'git-url-parse';\nimport { GithubIntegrationConfig } from './config';\nimport { GithubCredentials } from './types';\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://github.com/a/b/blob/branchname/path/to/c.yaml\n * to: https://api.github.com/repos/a/b/contents/path/to/c.yaml?ref=branchname\n * or: https://raw.githubusercontent.com/a/b/branchname/c.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getGithubFileFetchUrl(\n url: string,\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n !ref ||\n // GitHub is automatically redirecting tree urls to blob urls so it's\n // fine to pass a tree url.\n (filepathtype !== 'blob' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'tree')\n ) {\n throw new Error('Invalid GitHub URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n if (chooseEndpoint(config, credentials) === 'api') {\n return `${config.apiBaseUrl}/repos/${owner}/${name}/contents/${pathWithoutSlash}?ref=${ref}`;\n }\n return `${config.rawBaseUrl}/${owner}/${name}/${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 * @deprecated This function is no longer used internally\n * @param config - The relevant provider config\n * @public\n */\nexport function getGitHubRequestOptions(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (chooseEndpoint(config, credentials) === 'api') {\n headers.Accept = 'application/vnd.github.v3.raw';\n }\n\n if (credentials.token) {\n headers.Authorization = `token ${credentials.token}`;\n }\n\n return { headers };\n}\n\nexport function chooseEndpoint(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): 'api' | 'raw' {\n if (config.apiBaseUrl && (credentials.token || !config.rawBaseUrl)) {\n return 'api';\n }\n return 'raw';\n}\n"],"names":["parseGitUrl"],"mappings":";;;;;;;;AAmCg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,GACnB;AAEA,EAAA,IAAI,YAAY,KAAO,EAAA;AACrB,IAAQ,OAAA,CAAA,aAAA,GAAgB,CAAS,MAAA,EAAA,WAAA,CAAY,KAAK,CAAA,CAAA,CAAA;AAAA,GACpD;AAEA,EAAA,OAAO,EAAE,OAAQ,EAAA,CAAA;AACnB,CAAA;AAEgB,SAAA,cAAA,CACd,QACA,WACe,EAAA;AACf,EAAA,IAAI,OAAO,UAAe,KAAA,WAAA,CAAY,KAAS,IAAA,CAAC,OAAO,UAAa,CAAA,EAAA;AAClE,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACA,EAAO,OAAA,KAAA,CAAA;AACT;;;;;;"}
1
+ {"version":3,"file":"core.cjs.js","sources":["../../src/github/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 parseGitUrl from 'git-url-parse';\nimport { GithubIntegrationConfig } from './config';\nimport { GithubCredentials } from './types';\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://github.com/a/b/blob/branchname/path/to/c.yaml\n * to: https://api.github.com/repos/a/b/contents/path/to/c.yaml?ref=branchname\n * or: https://raw.githubusercontent.com/a/b/branchname/c.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getGithubFileFetchUrl(\n url: string,\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n !ref ||\n // GitHub is automatically redirecting tree urls to blob urls so it's\n // fine to pass a tree url.\n (filepathtype !== 'blob' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'tree')\n ) {\n throw new Error('Invalid GitHub URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n if (chooseEndpoint(config, credentials) === 'api') {\n return `${config.apiBaseUrl}/repos/${owner}/${name}/contents/${pathWithoutSlash}?ref=${ref}`;\n }\n return `${config.rawBaseUrl}/${owner}/${name}/${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 * @deprecated This function is no longer used internally\n * @param config - The relevant provider config\n * @public\n */\nexport function getGitHubRequestOptions(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (chooseEndpoint(config, credentials) === 'api') {\n headers.Accept = 'application/vnd.github.v3.raw';\n }\n\n if (credentials.token) {\n headers.Authorization = `token ${credentials.token}`;\n }\n\n return { headers };\n}\n\nexport function chooseEndpoint(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): 'api' | 'raw' {\n if (config.apiBaseUrl && (credentials.token || !config.rawBaseUrl)) {\n return 'api';\n }\n return 'raw';\n}\n"],"names":["parseGitUrl"],"mappings":";;;;;;;;AAmCgB,SAAA,qBAAA,CACd,GACA,EAAA,MAAA,EACA,WACQ,EAAA;AACR,EAAI,IAAA;AACF,IAAM,MAAA,EAAE,OAAO,IAAM,EAAA,GAAA,EAAK,cAAc,QAAS,EAAA,GAAIA,6BAAY,GAAG,CAAA;AACpE,IAAA,IACE,CAAC,KAAA,IACD,CAAC,IAAA,IACD,CAAC,GAAA;AAAA;AAAA,IAGA,YAAiB,KAAA,MAAA,IAChB,YAAiB,KAAA,KAAA,IACjB,iBAAiB,MACnB,EAAA;AACA,MAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA;AAAA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ent":["/*\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 { GithubIntegrationConfig } from './config';\nimport { GithubCredentials } from './types';\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://github.com/a/b/blob/branchname/path/to/c.yaml\n * to: https://api.github.com/repos/a/b/contents/path/to/c.yaml?ref=branchname\n * or: https://raw.githubusercontent.com/a/b/branchname/c.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getGithubFileFetchUrl(\n url: string,\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n !ref ||\n // GitHub is automatically redirecting tree urls to blob urls so it's\n // fine to pass a tree url.\n (filepathtype !== 'blob' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'tree')\n ) {\n throw new Error('Invalid GitHub URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n if (chooseEndpoint(config, credentials) === 'api') {\n return `${config.apiBaseUrl}/repos/${owner}/${name}/contents/${pathWithoutSlash}?ref=${ref}`;\n }\n return `${config.rawBaseUrl}/${owner}/${name}/${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 * @deprecated This function is no longer used internally\n * @param config - The relevant provider config\n * @public\n */\nexport function getGitHubRequestOptions(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (chooseEndpoint(config, credentials) === 'api') {\n headers.Accept = 'application/vnd.github.v3.raw';\n }\n\n if (credentials.token) {\n headers.Authorization = `token ${credentials.token}`;\n }\n\n return { headers };\n}\n\nexport function chooseEndpoint(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): 'api' | 'raw' {\n if (config.apiBaseUrl && (credentials.token || !config.rawBaseUrl)) {\n return 'api';\n }\n return 'raw';\n}\n"],"names":[],"mappings":";;AAmCgB,SAAA,qBAAA,CACd,GACA,EAAA,MAAA,EACA,WACQ,EAAA;AACR,EAAI,IAAA;AACF,IAAM,MAAA,EAAE,OAAO,IAAM,EAAA,GAAA,EAAK,cAAc,QAAS,EAAA,GAAI,YAAY,GAAG,CAAA,CAAA;AACpE,IAAA,IACE,CAAC,KAAA,IACD,CAAC,IAAA,IACD,CAAC,GAAA;AAAA;AAAA,IAGA,YAAiB,KAAA,MAAA,IAChB,YAAiB,KAAA,KAAA,IACjB,iBAAiB,MACnB,EAAA;AACA,MAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA,CAAA;AAAA,KACnD;AAEA,IAAA,MAAM,gBAAmB,GAAA,QAAA,CAAS,OAAQ,CAAA,KAAA,EAAO,EAAE,CAAA,CAAA;AACnD,IAAA,IAAI,cAAe,CAAA,MAAA,EAAQ,WAAW,CAAA,KAAM,KAAO,EAAA;AACjD,MAAO,OAAA,CAAA,EAAG,MAAO,CAAA,UAAU,CAAU,OAAA,EAAA,KAAK,IAAI,IAAI,CAAA,UAAA,EAAa,gBAAgB,CAAA,KAAA,EAAQ,GAAG,CAAA,CAAA,CAAA;AAAA,KAC5F;AACA,IAAO,OAAA,CAAA,EAAG,MAAO,CAAA,UAAU,CAAI,CAAA,EAAA,KAAK,IAAI,IAAI,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA,EAAI,gBAAgB,CAAA,CAAA,CAAA;AAAA,WAChE,CAAG,EAAA;AACV,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,eAAA,EAAkB,GAAG,CAAA,EAAA,EAAK,CAAC,CAAE,CAAA,CAAA,CAAA;AAAA,GAC/C;AACF,CAAA;AASgB,SAAA,uBAAA,CACd,QACA,WACqC,EAAA;AACrC,EAAA,MAAM,UAAkC,EAAC,CAAA;AAEzC,EAAA,IAAI,cAAe,CAAA,MAAA,EAAQ,WAAW,CAAA,KAAM,KAAO,EAAA;AACjD,IAAA,OAAA,CAAQ,MAAS,GAAA,+BAAA,CAAA;AAAA,GACnB;AAEA,EAAA,IAAI,YAAY,KAAO,EAAA;AACrB,IAAQ,OAAA,CAAA,aAAA,GAAgB,CAAS,MAAA,EAAA,WAAA,CAAY,KAAK,CAAA,CAAA,CAAA;AAAA,GACpD;AAEA,EAAA,OAAO,EAAE,OAAQ,EAAA,CAAA;AACnB,CAAA;AAEgB,SAAA,cAAA,CACd,QACA,WACe,EAAA;AACf,EAAA,IAAI,OAAO,UAAe,KAAA,WAAA,CAAY,KAAS,IAAA,CAAC,OAAO,UAAa,CAAA,EAAA;AAClE,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACA,EAAO,OAAA,KAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"core.esm.js","sources":["../../src/github/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 parseGitUrl from 'git-url-parse';\nimport { GithubIntegrationConfig } from './config';\nimport { GithubCredentials } from './types';\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://github.com/a/b/blob/branchname/path/to/c.yaml\n * to: https://api.github.com/repos/a/b/contents/path/to/c.yaml?ref=branchname\n * or: https://raw.githubusercontent.com/a/b/branchname/c.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getGithubFileFetchUrl(\n url: string,\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n !ref ||\n // GitHub is automatically redirecting tree urls to blob urls so it's\n // fine to pass a tree url.\n (filepathtype !== 'blob' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'tree')\n ) {\n throw new Error('Invalid GitHub URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n if (chooseEndpoint(config, credentials) === 'api') {\n return `${config.apiBaseUrl}/repos/${owner}/${name}/contents/${pathWithoutSlash}?ref=${ref}`;\n }\n return `${config.rawBaseUrl}/${owner}/${name}/${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 * @deprecated This function is no longer used internally\n * @param config - The relevant provider config\n * @public\n */\nexport function getGitHubRequestOptions(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (chooseEndpoint(config, credentials) === 'api') {\n headers.Accept = 'application/vnd.github.v3.raw';\n }\n\n if (credentials.token) {\n headers.Authorization = `token ${credentials.token}`;\n }\n\n return { headers };\n}\n\nexport function chooseEndpoint(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): 'api' | 'raw' {\n if (config.apiBaseUrl && (credentials.token || !config.rawBaseUrl)) {\n return 'api';\n }\n return 'raw';\n}\n"],"names":[],"mappings":";;AAmCgB,SAAA,qBAA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AAA,EAAA,WAAA,CAAY,KAAK,CAAA,CAAA;AAAA;AAGpD,EAAA,OAAO,EAAE,OAAQ,EAAA;AACnB;AAEgB,SAAA,cAAA,CACd,QACA,WACe,EAAA;AACf,EAAA,IAAI,OAAO,UAAe,KAAA,WAAA,CAAY,KAAS,IAAA,CAAC,OAAO,UAAa,CAAA,EAAA;AAClE,IAAO,OAAA,KAAA;AAAA;AAET,EAAO,OAAA,KAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultGitlabCredentialsProvider.cjs.js","sources":["../../src/gitlab/DefaultGitlabCredentialsProvider.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ScmIntegrationRegistry } from '../registry';\nimport { SingleInstanceGitlabCredentialsProvider } from './SingleInstanceGitlabCredentialsProvider';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\n/**\n * Handles the creation and caching of credentials for GitLab integrations.\n *\n * @public\n */\nexport class DefaultGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static fromIntegrations(integrations: ScmIntegrationRegistry) {\n const credentialsProviders: Map<string, GitlabCredentialsProvider> =\n new Map<string, GitlabCredentialsProvider>();\n\n integrations.gitlab.list().forEach(integration => {\n const credentialsProvider =\n SingleInstanceGitlabCredentialsProvider.create(integration.config);\n credentialsProviders.set(integration.config.host, credentialsProvider);\n });\n return new DefaultGitlabCredentialsProvider(credentialsProviders);\n }\n\n private constructor(\n private readonly providers: Map<string, GitlabCredentialsProvider>,\n ) {}\n\n async getCredentials(opts: { url: string }): Promise<GitlabCredentials> {\n const parsed = new URL(opts.url);\n const provider = this.providers.get(parsed.host);\n\n if (!provider) {\n throw new Error(\n `There is no GitLab integration that matches ${opts.url}. Please add a configuration for an integration.`,\n );\n }\n\n return provider.getCredentials(opts);\n }\n}\n"],"names":["SingleInstanceGitlabCredentialsProvider"],"mappings":";;;;AAyBO,MAAM,gCAEb,CAAA;AAAA,EAaU,YACW,SACjB,EAAA;AADiB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AAAA,GAChB;AAAA,EAdH,OAAO,iBAAiB,YAAsC,EAAA;AAC5D,IAAM,MAAA,oBAAA,uBACA,GAAuC,EAAA,CAAA;AAE7C,IAAA,YAAA,CAAa,MAAO,CAAA,IAAA,EAAO,CAAA,OAAA,CAAQ,CAAe,WAAA,KAAA;AAChD,MAAA,MAAM,mBACJ,GAAAA,+EAAA,CAAwC,MAAO,CAAA,WAAA,CAAY,MAAM,CAAA,CAAA;AACnE,MAAA,oBAAA,CAAqB,GAAI,CAAA,WAAA,CAAY,MAAO,CAAA,IAAA,EAAM,mBAAmB,CAAA,CAAA;AAAA,KACtE,CAAA,CAAA;AACD,IAAO,OAAA,IAAI,iCAAiC,oBAAoB,CAAA,CAAA;AAAA,GAClE;AAAA,EAMA,MAAM,eAAe,IAAmD,EAAA;AACtE,IAAA,MAAM,MAAS,GAAA,IAAI,GAAI,CAAA,IAAA,CAAK,GAAG,CAAA,CAAA;AAC/B,IAAA,MAAM,QAAW,GAAA,IAAA,CAAK,SAAU,CAAA,GAAA,CAAI,OAAO,IAAI,CAAA,CAAA;AAE/C,IAAA,IAAI,CAAC,QAAU,EAAA;AACb,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,4CAAA,EAA+C,KAAK,GAAG,CAAA,gDAAA,CAAA;AAAA,OACzD,CAAA;AAAA,KACF;AAEA,IAAO,OAAA,QAAA,CAAS,eAAe,IAAI,CAAA,CAAA;AAAA,GACrC;AACF;;;;"}
1
+ {"version":3,"file":"DefaultGitlabCredentialsProvider.cjs.js","sources":["../../src/gitlab/DefaultGitlabCredentialsProvider.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ScmIntegrationRegistry } from '../registry';\nimport { SingleInstanceGitlabCredentialsProvider } from './SingleInstanceGitlabCredentialsProvider';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\n/**\n * Handles the creation and caching of credentials for GitLab integrations.\n *\n * @public\n */\nexport class DefaultGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static fromIntegrations(integrations: ScmIntegrationRegistry) {\n const credentialsProviders: Map<string, GitlabCredentialsProvider> =\n new Map<string, GitlabCredentialsProvider>();\n\n integrations.gitlab.list().forEach(integration => {\n const credentialsProvider =\n SingleInstanceGitlabCredentialsProvider.create(integration.config);\n credentialsProviders.set(integration.config.host, credentialsProvider);\n });\n return new DefaultGitlabCredentialsProvider(credentialsProviders);\n }\n\n private constructor(\n private readonly providers: Map<string, GitlabCredentialsProvider>,\n ) {}\n\n async getCredentials(opts: { url: string }): Promise<GitlabCredentials> {\n const parsed = new URL(opts.url);\n const provider = this.providers.get(parsed.host);\n\n if (!provider) {\n throw new Error(\n `There is no GitLab integration that matches ${opts.url}. Please add a configuration for an integration.`,\n );\n }\n\n return provider.getCredentials(opts);\n }\n}\n"],"names":["SingleInstanceGitlabCredentialsProvider"],"mappings":";;;;AAyBO,MAAM,gCAEb,CAAA;AAAA,EAaU,YACW,SACjB,EAAA;AADiB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAAA;AAChB,EAdH,OAAO,iBAAiB,YAAsC,EAAA;AAC5D,IAAM,MAAA,oBAAA,uBACA,GAAuC,EAAA;AAE7C,IAAA,YAAA,CAAa,MAAO,CAAA,IAAA,EAAO,CAAA,OAAA,CAAQ,CAAe,WAAA,KAAA;AAChD,MAAA,MAAM,mBACJ,GAAAA,+EAAA,CAAwC,MAAO,CAAA,WAAA,CAAY,MAAM,CAAA;AACnE,MAAA,oBAAA,CAAqB,GAAI,CAAA,WAAA,CAAY,MAAO,CAAA,IAAA,EAAM,mBAAmB,CAAA;AAAA,KACtE,CAAA;AACD,IAAO,OAAA,IAAI,iCAAiC,oBAAoB,CAAA;AAAA;AAClE,EAMA,MAAM,eAAe,IAAmD,EAAA;AACtE,IAAA,MAAM,MAAS,GAAA,IAAI,GAAI,CAAA,IAAA,CAAK,GAAG,CAAA;AAC/B,IAAA,MAAM,QAAW,GAAA,IAAA,CAAK,SAAU,CAAA,GAAA,CAAI,OAAO,IAAI,CAAA;AAE/C,IAAA,IAAI,CAAC,QAAU,EAAA;AACb,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,4CAAA,EAA+C,KAAK,GAAG,CAAA,gDAAA;AAAA,OACzD;AAAA;AAGF,IAAO,OAAA,QAAA,CAAS,eAAe,IAAI,CAAA;AAAA;AAEvC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultGitlabCredentialsProvider.esm.js","sources":["../../src/gitlab/DefaultGitlabCredentialsProvider.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ScmIntegrationRegistry } from '../registry';\nimport { SingleInstanceGitlabCredentialsProvider } from './SingleInstanceGitlabCredentialsProvider';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\n/**\n * Handles the creation and caching of credentials for GitLab integrations.\n *\n * @public\n */\nexport class DefaultGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static fromIntegrations(integrations: ScmIntegrationRegistry) {\n const credentialsProviders: Map<string, GitlabCredentialsProvider> =\n new Map<string, GitlabCredentialsProvider>();\n\n integrations.gitlab.list().forEach(integration => {\n const credentialsProvider =\n SingleInstanceGitlabCredentialsProvider.create(integration.config);\n credentialsProviders.set(integration.config.host, credentialsProvider);\n });\n return new DefaultGitlabCredentialsProvider(credentialsProviders);\n }\n\n private constructor(\n private readonly providers: Map<string, GitlabCredentialsProvider>,\n ) {}\n\n async getCredentials(opts: { url: string }): Promise<GitlabCredentials> {\n const parsed = new URL(opts.url);\n const provider = this.providers.get(parsed.host);\n\n if (!provider) {\n throw new Error(\n `There is no GitLab integration that matches ${opts.url}. Please add a configuration for an integration.`,\n );\n }\n\n return provider.getCredentials(opts);\n }\n}\n"],"names":[],"mappings":";;AAyBO,MAAM,gCAEb,CAAA;AAAA,EAaU,YACW,SACjB,EAAA;AADiB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AAAA,GAChB;AAAA,EAdH,OAAO,iBAAiB,YAAsC,EAAA;AAC5D,IAAM,MAAA,oBAAA,uBACA,GAAuC,EAAA,CAAA;AAE7C,IAAA,YAAA,CAAa,MAAO,CAAA,IAAA,EAAO,CAAA,OAAA,CAAQ,CAAe,WAAA,KAAA;AAChD,MAAA,MAAM,mBACJ,GAAA,uCAAA,CAAwC,MAAO,CAAA,WAAA,CAAY,MAAM,CAAA,CAAA;AACnE,MAAA,oBAAA,CAAqB,GAAI,CAAA,WAAA,CAAY,MAAO,CAAA,IAAA,EAAM,mBAAmB,CAAA,CAAA;AAAA,KACtE,CAAA,CAAA;AACD,IAAO,OAAA,IAAI,iCAAiC,oBAAoB,CAAA,CAAA;AAAA,GAClE;AAAA,EAMA,MAAM,eAAe,IAAmD,EAAA;AACtE,IAAA,MAAM,MAAS,GAAA,IAAI,GAAI,CAAA,IAAA,CAAK,GAAG,CAAA,CAAA;AAC/B,IAAA,MAAM,QAAW,GAAA,IAAA,CAAK,SAAU,CAAA,GAAA,CAAI,OAAO,IAAI,CAAA,CAAA;AAE/C,IAAA,IAAI,CAAC,QAAU,EAAA;AACb,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,4CAAA,EAA+C,KAAK,GAAG,CAAA,gDAAA,CAAA;AAAA,OACzD,CAAA;AAAA,KACF;AAEA,IAAO,OAAA,QAAA,CAAS,eAAe,IAAI,CAAA,CAAA;AAAA,GACrC;AACF;;;;"}
1
+ {"version":3,"file":"DefaultGitlabCredentialsProvider.esm.js","sources":["../../src/gitlab/DefaultGitlabCredentialsProvider.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ScmIntegrationRegistry } from '../registry';\nimport { SingleInstanceGitlabCredentialsProvider } from './SingleInstanceGitlabCredentialsProvider';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\n/**\n * Handles the creation and caching of credentials for GitLab integrations.\n *\n * @public\n */\nexport class DefaultGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static fromIntegrations(integrations: ScmIntegrationRegistry) {\n const credentialsProviders: Map<string, GitlabCredentialsProvider> =\n new Map<string, GitlabCredentialsProvider>();\n\n integrations.gitlab.list().forEach(integration => {\n const credentialsProvider =\n SingleInstanceGitlabCredentialsProvider.create(integration.config);\n credentialsProviders.set(integration.config.host, credentialsProvider);\n });\n return new DefaultGitlabCredentialsProvider(credentialsProviders);\n }\n\n private constructor(\n private readonly providers: Map<string, GitlabCredentialsProvider>,\n ) {}\n\n async getCredentials(opts: { url: string }): Promise<GitlabCredentials> {\n const parsed = new URL(opts.url);\n const provider = this.providers.get(parsed.host);\n\n if (!provider) {\n throw new Error(\n `There is no GitLab integration that matches ${opts.url}. Please add a configuration for an integration.`,\n );\n }\n\n return provider.getCredentials(opts);\n }\n}\n"],"names":[],"mappings":";;AAyBO,MAAM,gCAEb,CAAA;AAAA,EAaU,YACW,SACjB,EAAA;AADiB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAAA;AAChB,EAdH,OAAO,iBAAiB,YAAsC,EAAA;AAC5D,IAAM,MAAA,oBAAA,uBACA,GAAuC,EAAA;AAE7C,IAAA,YAAA,CAAa,MAAO,CAAA,IAAA,EAAO,CAAA,OAAA,CAAQ,CAAe,WAAA,KAAA;AAChD,MAAA,MAAM,mBACJ,GAAA,uCAAA,CAAwC,MAAO,CAAA,WAAA,CAAY,MAAM,CAAA;AACnE,MAAA,oBAAA,CAAqB,GAAI,CAAA,WAAA,CAAY,MAAO,CAAA,IAAA,EAAM,mBAAmB,CAAA;AAAA,KACtE,CAAA;AACD,IAAO,OAAA,IAAI,iCAAiC,oBAAoB,CAAA;AAAA;AAClE,EAMA,MAAM,eAAe,IAAmD,EAAA;AACtE,IAAA,MAAM,MAAS,GAAA,IAAI,GAAI,CAAA,IAAA,CAAK,GAAG,CAAA;AAC/B,IAAA,MAAM,QAAW,GAAA,IAAA,CAAK,SAAU,CAAA,GAAA,CAAI,OAAO,IAAI,CAAA;AAE/C,IAAA,IAAI,CAAC,QAAU,EAAA;AACb,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,4CAAA,EAA+C,KAAK,GAAG,CAAA,gDAAA;AAAA,OACzD;AAAA;AAGF,IAAO,OAAA,QAAA,CAAS,eAAe,IAAI,CAAA;AAAA;AAEvC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"GitLabIntegration.cjs.js","sources":["../../src/gitlab/GitLabIntegration.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 GitLabIntegrationConfig,\n readGitLabIntegrationConfigs,\n} from './config';\n\n/**\n * A GitLab based integration.\n *\n * @public\n */\nexport class GitLabIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GitLabIntegration> = ({ config }) => {\n const configs = readGitLabIntegrationConfigs(\n config.getOptionalConfigArray('integrations.gitlab') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new GitLabIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: GitLabIntegrationConfig) {}\n\n get type(): string {\n return 'gitlab';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): GitLabIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return replaceGitLabUrlType(url, 'edit');\n }\n}\n\n/**\n * Takes a GitLab URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'tree', 'edit'\n * @public\n */\nexport function replaceGitLabUrlType(\n url: string,\n type: 'blob' | 'tree' | 'edit',\n): string {\n return url.replace(/\\/\\-\\/(blob|t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file":"GitLabIntegration.cjs.js","sources":["../../src/gitlab/GitLabIntegration.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 GitLabIntegrationConfig,\n readGitLabIntegrationConfigs,\n} from './config';\n\n/**\n * A GitLab based integration.\n *\n * @public\n */\nexport class GitLabIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GitLabIntegration> = ({ config }) => {\n const configs = readGitLabIntegrationConfigs(\n config.getOptionalConfigArray('integrations.gitlab') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new GitLabIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: GitLabIntegrationConfig) {}\n\n get type(): string {\n return 'gitlab';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): GitLabIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return replaceGitLabUrlType(url, 'edit');\n }\n}\n\n/**\n * Takes a GitLab URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'tree', 'edit'\n * @public\n */\nexport function replaceGitLabUrlType(\n url: string,\n type: 'blob' | 'tree' | 'edit',\n): string {\n return url.replace(/\\/\\-\\/(blob|tree|edit)\\//, `/-/${type}/`);\n}\n"],"names":["config","readGitLabIntegrationConfigs","basicIntegrations","defaultScmResolveUrl"],"mappings":";;;;;AA4BO,MAAM,iBAA4C,CAAA;AAAA,EAWvD,YAA6B,iBAA4C,EAAA;AAA5C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAA6C,EAV1E,OAAO,OAAA,GAAqD,CAAC,UAAEA,UAAa,KAAA;AAC1E,IAAA,MAAM,OAAU,GAAAC,mCAAA;AAAA,MACdD,QAAO,CAAA,sBAAA,CAAuB,qBAAqB,CAAA,IAAK;AAAC,KAC3D;AACA,IAAO,OAAAE,yBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,iBAAA,CAAkB,CAAC,CAAC,CAAA;AAAA,MACzC,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA;AAAA,KAChB;AAAA,GACF;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,QAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA;AAAA;AAChC,EAEA,IAAI,MAAkC,GAAA;AACpC,IAAA,OAAO,IAAK,CAAA,iBAAA;AAAA;AACd,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,OAAOC,6BAAqB,OAAO,CAAA;AAAA;AACrC,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAO,OAAA,oBAAA,CAAqB,KAAK,MAAM,CAAA;AAAA;AAE3C;AASgB,SAAA,oBAAA,CACd,KACA,IACQ,EAAA;AACR,EAAA,OAAO,GAAI,CAAA,OAAA,CAAQ,0BAA4B,EAAA,CAAA,GAAA,EAAM,IAAI,CAAG,CAAA,CAAA,CAAA;AAC9D;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"GitLabIntegration.esm.js","sources":["../../src/gitlab/GitLabIntegration.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 GitLabIntegrationConfig,\n readGitLabIntegrationConfigs,\n} from './config';\n\n/**\n * A GitLab based integration.\n *\n * @public\n */\nexport class GitLabIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GitLabIntegration> = ({ config }) => {\n const configs = readGitLabIntegrationConfigs(\n config.getOptionalConfigArray('integrations.gitlab') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new GitLabIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: GitLabIntegrationConfig) {}\n\n get type(): string {\n return 'gitlab';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): GitLabIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return replaceGitLabUrlType(url, 'edit');\n }\n}\n\n/**\n * Takes a GitLab URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'tree', 'edit'\n * @public\n */\nexport function replaceGitLabUrlType(\n url: string,\n type: 'blob' | 'tree' | 'edit',\n): string {\n return url.replace(/\\/\\-\\/(blob|tree|edit)\\//, `/-/${type}/`);\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,iBAA4C,CAAA;AAAA,EAWvD,YAA6B,iBAA4C,EAAA;AAA5C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA,CAAA;AAAA,GAA6C;AAAA,EAV1E,OAAO,OAAA,GAAqD,CAAC,EAAE,QAAa,KAAA;AAC1E,IAAA,MAAM,OAAU,GAAA,4BAAA;AAAA,MACd,MAAO,CAAA,sBAAA,CAAuB,qBAAqB,CAAA,IAAK,EAAC;AAAA,KAC3D,CAAA;AACA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,iBAAA,CAAkB,CAAC,CAAC,CAAA;AAAA,MACzC,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA,IAAA;AAAA,KAChB,CAAA;AAAA,GACF,CAAA;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,QAAA,CAAA;AAAA,GACT;AAAA,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA,CAAA;AAAA,GAChC;AAAA,EAEA,IAAI,MAAkC,GAAA;AACpC,IAAA,OAAO,IAAK,CAAA,iBAAA,CAAA;AAAA,GACd;AAAA,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,OAAO,qBAAqB,OAAO,CAAA,CAAA;AAAA,GACrC;AAAA,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAO,OAAA,oBAAA,CAAqB,KAAK,MAAM,CAAA,CAAA;AAAA,GACzC;AACF,CAAA;AASgB,SAAA,oBAAA,CACd,KACA,IACQ,EAAA;AACR,EAAA,OAAO,GAAI,CAAA,OAAA,CAAQ,0BAA4B,EAAA,CAAA,GAAA,EAAM,IAAI,CAAG,CAAA,CAAA,CAAA,CAAA;AAC9D;;;;"}
1
+ {"version":3,"file":"GitLabIntegration.esm.js","sources":["../../src/gitlab/GitLabIntegration.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 GitLabIntegrationConfig,\n readGitLabIntegrationConfigs,\n} from './config';\n\n/**\n * A GitLab based integration.\n *\n * @public\n */\nexport class GitLabIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GitLabIntegration> = ({ config }) => {\n const configs = readGitLabIntegrationConfigs(\n config.getOptionalConfigArray('integrations.gitlab') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new GitLabIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: GitLabIntegrationConfig) {}\n\n get type(): string {\n return 'gitlab';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): GitLabIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return replaceGitLabUrlType(url, 'edit');\n }\n}\n\n/**\n * Takes a GitLab URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'tree', 'edit'\n * @public\n */\nexport function replaceGitLabUrlType(\n url: string,\n type: 'blob' | 'tree' | 'edit',\n): string {\n return url.replace(/\\/\\-\\/(blob|tree|edit)\\//, `/-/${type}/`);\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,iBAA4C,CAAA;AAAA,EAWvD,YAA6B,iBAA4C,EAAA;AAA5C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA;AAA6C,EAV1E,OAAO,OAAA,GAAqD,CAAC,EAAE,QAAa,KAAA;AAC1E,IAAA,MAAM,OAAU,GAAA,4BAAA;AAAA,MACd,MAAO,CAAA,sBAAA,CAAuB,qBAAqB,CAAA,IAAK;AAAC,KAC3D;AACA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,iBAAA,CAAkB,CAAC,CAAC,CAAA;AAAA,MACzC,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA;AAAA,KAChB;AAAA,GACF;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,QAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA;AAAA;AAChC,EAEA,IAAI,MAAkC,GAAA;AACpC,IAAA,OAAO,IAAK,CAAA,iBAAA;AAAA;AACd,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,OAAO,qBAAqB,OAAO,CAAA;AAAA;AACrC,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAO,OAAA,oBAAA,CAAqB,KAAK,MAAM,CAAA;AAAA;AAE3C;AASgB,SAAA,oBAAA,CACd,KACA,IACQ,EAAA;AACR,EAAA,OAAO,GAAI,CAAA,OAAA,CAAQ,0BAA4B,EAAA,CAAA,GAAA,EAAM,IAAI,CAAG,CAAA,CAAA,CAAA;AAC9D;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SingleInstanceGitlabCredentialsProvider.cjs.js","sources":["../../src/gitlab/SingleInstanceGitlabCredentialsProvider.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GitLabIntegrationConfig } from './config';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\nexport class SingleInstanceGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static create: (\n config: GitLabIntegrationConfig,\n ) => GitlabCredentialsProvider = config => {\n return new SingleInstanceGitlabCredentialsProvider(config.token);\n };\n\n private constructor(private readonly token?: string) {}\n\n async getCredentials(_opts: { url: string }): Promise<GitlabCredentials> {\n if (!this.token) {\n return {};\n }\n\n return {\n headers: {\n Authorization: `Bearer ${this.token}`,\n },\n token: this.token,\n };\n }\n}\n"],"names":[],"mappings":";;AAmBO,MAAM,uCAEb,CAAA;AAAA,EAOU,YAA6B,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AAAA,GAAiB;AAAA,EANtD,OAAO,SAE0B,CAAU,MAAA,KAAA;AACzC,IAAO,OAAA,IAAI,uCAAwC,CAAA,MAAA,CAAO,KAAK,CAAA,CAAA;AAAA,GACjE,CAAA;AAAA,EAIA,MAAM,eAAe,KAAoD,EAAA;AACvE,IAAI,IAAA,CAAC,KAAK,KAAO,EAAA;AACf,MAAA,OAAO,EAAC,CAAA;AAAA,KACV;AAEA,IAAO,OAAA;AAAA,MACL,OAAS,EAAA;AAAA,QACP,aAAA,EAAe,CAAU,OAAA,EAAA,IAAA,CAAK,KAAK,CAAA,CAAA;AAAA,OACrC;AAAA,MACA,OAAO,IAAK,CAAA,KAAA;AAAA,KACd,CAAA;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"SingleInstanceGitlabCredentialsProvider.cjs.js","sources":["../../src/gitlab/SingleInstanceGitlabCredentialsProvider.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GitLabIntegrationConfig } from './config';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\nexport class SingleInstanceGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static create: (\n config: GitLabIntegrationConfig,\n ) => GitlabCredentialsProvider = config => {\n return new SingleInstanceGitlabCredentialsProvider(config.token);\n };\n\n private constructor(private readonly token?: string) {}\n\n async getCredentials(_opts: { url: string }): Promise<GitlabCredentials> {\n if (!this.token) {\n return {};\n }\n\n return {\n headers: {\n Authorization: `Bearer ${this.token}`,\n },\n token: this.token,\n };\n }\n}\n"],"names":[],"mappings":";;AAmBO,MAAM,uCAEb,CAAA;AAAA,EAOU,YAA6B,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAAA;AAAiB,EANtD,OAAO,SAE0B,CAAU,MAAA,KAAA;AACzC,IAAO,OAAA,IAAI,uCAAwC,CAAA,MAAA,CAAO,KAAK,CAAA;AAAA,GACjE;AAAA,EAIA,MAAM,eAAe,KAAoD,EAAA;AACvE,IAAI,IAAA,CAAC,KAAK,KAAO,EAAA;AACf,MAAA,OAAO,EAAC;AAAA;AAGV,IAAO,OAAA;AAAA,MACL,OAAS,EAAA;AAAA,QACP,aAAA,EAAe,CAAU,OAAA,EAAA,IAAA,CAAK,KAAK,CAAA;AAAA,OACrC;AAAA,MACA,OAAO,IAAK,CAAA;AAAA,KACd;AAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SingleInstanceGitlabCredentialsProvider.esm.js","sources":["../../src/gitlab/SingleInstanceGitlabCredentialsProvider.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GitLabIntegrationConfig } from './config';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\nexport class SingleInstanceGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static create: (\n config: GitLabIntegrationConfig,\n ) => GitlabCredentialsProvider = config => {\n return new SingleInstanceGitlabCredentialsProvider(config.token);\n };\n\n private constructor(private readonly token?: string) {}\n\n async getCredentials(_opts: { url: string }): Promise<GitlabCredentials> {\n if (!this.token) {\n return {};\n }\n\n return {\n headers: {\n Authorization: `Bearer ${this.token}`,\n },\n token: this.token,\n };\n }\n}\n"],"names":[],"mappings":"AAmBO,MAAM,uCAEb,CAAA;AAAA,EAOU,YAA6B,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AAAA,GAAiB;AAAA,EANtD,OAAO,SAE0B,CAAU,MAAA,KAAA;AACzC,IAAO,OAAA,IAAI,uCAAwC,CAAA,MAAA,CAAO,KAAK,CAAA,CAAA;AAAA,GACjE,CAAA;AAAA,EAIA,MAAM,eAAe,KAAoD,EAAA;AACvE,IAAI,IAAA,CAAC,KAAK,KAAO,EAAA;AACf,MAAA,OAAO,EAAC,CAAA;AAAA,KACV;AAEA,IAAO,OAAA;AAAA,MACL,OAAS,EAAA;AAAA,QACP,aAAA,EAAe,CAAU,OAAA,EAAA,IAAA,CAAK,KAAK,CAAA,CAAA;AAAA,OACrC;AAAA,MACA,OAAO,IAAK,CAAA,KAAA;AAAA,KACd,CAAA;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"SingleInstanceGitlabCredentialsProvider.esm.js","sources":["../../src/gitlab/SingleInstanceGitlabCredentialsProvider.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GitLabIntegrationConfig } from './config';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\nexport class SingleInstanceGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static create: (\n config: GitLabIntegrationConfig,\n ) => GitlabCredentialsProvider = config => {\n return new SingleInstanceGitlabCredentialsProvider(config.token);\n };\n\n private constructor(private readonly token?: string) {}\n\n async getCredentials(_opts: { url: string }): Promise<GitlabCredentials> {\n if (!this.token) {\n return {};\n }\n\n return {\n headers: {\n Authorization: `Bearer ${this.token}`,\n },\n token: this.token,\n };\n }\n}\n"],"names":[],"mappings":"AAmBO,MAAM,uCAEb,CAAA;AAAA,EAOU,YAA6B,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAAA;AAAiB,EANtD,OAAO,SAE0B,CAAU,MAAA,KAAA;AACzC,IAAO,OAAA,IAAI,uCAAwC,CAAA,MAAA,CAAO,KAAK,CAAA;AAAA,GACjE;AAAA,EAIA,MAAM,eAAe,KAAoD,EAAA;AACvE,IAAI,IAAA,CAAC,KAAK,KAAO,EAAA;AACf,MAAA,OAAO,EAAC;AAAA;AAGV,IAAO,OAAA;AAAA,MACL,OAAS,EAAA;AAAA,QACP,aAAA,EAAe,CAAU,OAAA,EAAA,IAAA,CAAK,KAAK,CAAA;AAAA,OACrC;AAAA,MACA,OAAO,IAAK,CAAA;AAAA,KACd;AAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/gitlab/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, isValidUrl } from '../helpers';\n\nconst GITLAB_HOST = 'gitlab.com';\nconst GITLAB_API_BASE_URL = 'https://gitlab.com/api/v4';\n\n/**\n * The configuration parameters for a single GitLab integration.\n *\n * @public\n */\nexport type GitLabIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. `gitlab.com`.\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g.\n * `https://gitlab.com/api/v4`, with no trailing slash.\n *\n * May be omitted specifically for public GitLab; then it will be deduced.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to this provider.\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The baseUrl of this provider, e.g. `https://gitlab.com`, which is passed\n * into the GitLab client.\n *\n * If no baseUrl is provided, it will default to `https://${host}`\n */\n baseUrl: string;\n};\n\n/**\n * Reads a single GitLab integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGitLabIntegrationConfig(\n config: Config,\n): GitLabIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n let baseUrl = config.getOptionalString('baseUrl');\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === GITLAB_HOST) {\n apiBaseUrl = GITLAB_API_BASE_URL;\n }\n\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid GitLab integration config, '${host}' is not a valid host`,\n );\n } else if (!apiBaseUrl || !isValidUrl(apiBaseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${apiBaseUrl}' is not a valid apiBaseUrl`,\n );\n } else if (!isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n }\n\n return { host, token, apiBaseUrl, baseUrl };\n}\n\n/**\n * Reads a set of GitLab integration configs, and inserts some defaults for\n * public GitLab if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readGitLabIntegrationConfigs(\n configs: Config[],\n): GitLabIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readGitLabIntegrationConfig);\n\n // As a convenience we always make sure there's at least an unauthenticated\n // reader for public gitlab repos.\n if (!result.some(c => c.host === GITLAB_HOST)) {\n result.push({\n host: GITLAB_HOST,\n apiBaseUrl: GITLAB_API_BASE_URL,\n baseUrl: `https://${GITLAB_HOST}`,\n });\n }\n\n return result;\n}\n\n/**\n * Reads a GitLab integration config, and returns\n * relative path.\n *\n * @param config - GitLabIntegrationConfig object\n * @public\n */\nexport function getGitLabIntegrationRelativePath(\n config: GitLabIntegrationConfig,\n): string {\n let relativePath = '';\n if (config.host !== GITLAB_HOST) {\n relativePath = new URL(config.baseUrl).pathname;\n }\n return trimEnd(relativePath, '/');\n}\n"],"names":["trimEnd","isValidHost","isValidUrl"],"mappings":";;;;;AAoBA,MAAM,WAAc,GAAA,YAAA,CAAA;AACpB,MAAM,mBAAsB,GAAA,2BAAA,CAAA;AA2CrB,SAAS,4BACd,MACyB,EAAA;AACzB,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA,CAAA;AACpC,EAAI,IAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA,CAAA;AACtD,EAAA,MAAM,KAAQ,GAAA,MAAA,CAAO,iBAAkB,CAAA,OAAO,GAAG,IAAK,EAAA,CAAA;AACtD,EAAI,IAAA,OAAA,GAAU,MAAO,CAAA,iBAA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UAAY,EAAA,mBAAA;AAAA,MACZ,OAAA,EAAS,WAAW,WAAW,CAAA,CAAA;AAAA,KAChC,CAAA,CAAA;AAAA,GACH;AAEA,EAAO,OAAA,MAAA,CAAA;AACT,CAAA;AASO,SAAS,iCACd,MACQ,EAAA;AACR,EAAA,IAAI,YAAe,GAAA,EAAA,CAAA;AACnB,EAAI,IAAA,MAAA,CAAO,SAAS,WAAa,EAAA;AAC/B,IAAA,YAAA,GAAe,IAAI,GAAA,CAAI,MAAO,CAAA,OAAO,CAAE,CAAA,QAAA,CAAA;AAAA,GACzC;AACA,EAAO,OAAAF,cAAA,CAAQ,cAAc,GAAG,CAAA,CAAA;AAClC;;;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../../src/gitlab/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, isValidUrl } from '../helpers';\n\nconst GITLAB_HOST = 'gitlab.com';\nconst GITLAB_API_BASE_URL = 'https://gitlab.com/api/v4';\n\n/**\n * The configuration parameters for a single GitLab integration.\n *\n * @public\n */\nexport type GitLabIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. `gitlab.com`.\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g.\n * `https://gitlab.com/api/v4`, with no trailing slash.\n *\n * May be omitted specifically for public GitLab; then it will be deduced.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to this provider.\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The baseUrl of this provider, e.g. `https://gitlab.com`, which is passed\n * into the GitLab client.\n *\n * If no baseUrl is provided, it will default to `https://${host}`\n */\n baseUrl: string;\n};\n\n/**\n * Reads a single GitLab integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGitLabIntegrationConfig(\n config: Config,\n): GitLabIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n let baseUrl = config.getOptionalString('baseUrl');\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === GITLAB_HOST) {\n apiBaseUrl = GITLAB_API_BASE_URL;\n }\n\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid GitLab integration config, '${host}' is not a valid host`,\n );\n } else if (!apiBaseUrl || !isValidUrl(apiBaseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${apiBaseUrl}' is not a valid apiBaseUrl`,\n );\n } else if (!isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n }\n\n return { host, token, apiBaseUrl, baseUrl };\n}\n\n/**\n * Reads a set of GitLab integration configs, and inserts some defaults for\n * public GitLab if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readGitLabIntegrationConfigs(\n configs: Config[],\n): GitLabIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readGitLabIntegrationConfig);\n\n // As a convenience we always make sure there's at least an unauthenticated\n // reader for public gitlab repos.\n if (!result.some(c => c.host === GITLAB_HOST)) {\n result.push({\n host: GITLAB_HOST,\n apiBaseUrl: GITLAB_API_BASE_URL,\n baseUrl: `https://${GITLAB_HOST}`,\n });\n }\n\n return result;\n}\n\n/**\n * Reads a GitLab integration config, and returns\n * relative path.\n *\n * @param config - GitLabIntegrationConfig object\n * @public\n */\nexport function getGitLabIntegrationRelativePath(\n config: GitLabIntegrationConfig,\n): string {\n let relativePath = '';\n if (config.host !== GITLAB_HOST) {\n relativePath = new URL(config.baseUrl).pathname;\n }\n return trimEnd(relativePath, '/');\n}\n"],"names":["trimEnd","isValidHost","isValidUrl"],"mappings":";;;;;AAoBA,MAAM,WAAc,GAAA,YAAA;AACpB,MAAM,mBAAsB,GAAA,2BAAA;AA2CrB,SAAS,4BACd,MACyB,EAAA;AACzB,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,EAAI,IAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAChD,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAAA,cAAA,CAAQ,YAAY,GAAG,CAAA;AAAA,GACtC,MAAA,IAAW,SAAS,WAAa,EAAA;AAC/B,IAAa,UAAA,GAAA,mBAAA;AAAA;AAGf,EAAA,IAAI,OAAS,EAAA;AACX,IAAU,OAAA,GAAAA,cAAA,CAAQ,SAAS,GAAG,CAAA;AAAA,GACzB,MAAA;AACL,IAAA,OAAA,GAAU,WAAW,IAAI,CAAA,CAAA;AAAA;AAG3B,EAAI,IAAA,CAACC,mBAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,IAAI,CAAA,qBAAA;AAAA,KAC7C;AAAA,aACS,CAAC,UAAA,IAAc,CAACC,kBAAA,CAAW,UAAU,CAAG,EAAA;AACjD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,UAAU,CAAA,2BAAA;AAAA,KACnD;AAAA,GACS,MAAA,IAAA,CAACA,kBAAW,CAAA,OAAO,CAAG,EAAA;AAC/B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,OAAO,CAAA,wBAAA;AAAA,KAChD;AAAA;AAGF,EAAA,OAAO,EAAE,IAAA,EAAM,KAAO,EAAA,UAAA,EAAY,OAAQ,EAAA;AAC5C;AASO,SAAS,6BACd,OAC2B,EAAA;AAE3B,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,2BAA2B,CAAA;AAItD,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,WAAW,CAAG,EAAA;AAC7C,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,WAAA;AAAA,MACN,UAAY,EAAA,mBAAA;AAAA,MACZ,OAAA,EAAS,WAAW,WAAW,CAAA;AAAA,KAChC,CAAA;AAAA;AAGH,EAAO,OAAA,MAAA;AACT;AASO,SAAS,iCACd,MACQ,EAAA;AACR,EAAA,IAAI,YAAe,GAAA,EAAA;AACnB,EAAI,IAAA,MAAA,CAAO,SAAS,WAAa,EAAA;AAC/B,IAAA,YAAA,GAAe,IAAI,GAAA,CAAI,MAAO,CAAA,OAAO,CAAE,CAAA,QAAA;AAAA;AAEzC,EAAO,OAAAF,cAAA,CAAQ,cAAc,GAAG,CAAA;AAClC;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/gitlab/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, isValidUrl } from '../helpers';\n\nconst GITLAB_HOST = 'gitlab.com';\nconst GITLAB_API_BASE_URL = 'https://gitlab.com/api/v4';\n\n/**\n * The configuration parameters for a single GitLab integration.\n *\n * @public\n */\nexport type GitLabIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. `gitlab.com`.\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g.\n * `https://gitlab.com/api/v4`, with no trailing slash.\n *\n * May be omitted specifically for public GitLab; then it will be deduced.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to this provider.\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The baseUrl of this provider, e.g. `https://gitlab.com`, which is passed\n * into the GitLab client.\n *\n * If no baseUrl is provided, it will default to `https://${host}`\n */\n baseUrl: string;\n};\n\n/**\n * Reads a single GitLab integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGitLabIntegrationConfig(\n config: Config,\n): GitLabIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n let baseUrl = config.getOptionalString('baseUrl');\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === GITLAB_HOST) {\n apiBaseUrl = GITLAB_API_BASE_URL;\n }\n\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid GitLab integration config, '${host}' is not a valid host`,\n );\n } else if (!apiBaseUrl || !isValidUrl(apiBaseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${apiBaseUrl}' is not a valid apiBaseUrl`,\n );\n } else if (!isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n }\n\n return { host, token, apiBaseUrl, baseUrl };\n}\n\n/**\n * Reads a set of GitLab integration configs, and inserts some defaults for\n * public GitLab if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readGitLabIntegrationConfigs(\n configs: Config[],\n): GitLabIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readGitLabIntegrationConfig);\n\n // As a convenience we always make sure there's at least an unauthenticated\n // reader for public gitlab repos.\n if (!result.some(c => c.host === GITLAB_HOST)) {\n result.push({\n host: GITLAB_HOST,\n apiBaseUrl: GITLAB_API_BASE_URL,\n baseUrl: `https://${GITLAB_HOST}`,\n });\n }\n\n return result;\n}\n\n/**\n * Reads a GitLab integration config, and returns\n * relative path.\n *\n * @param config - GitLabIntegrationConfig object\n * @public\n */\nexport function getGitLabIntegrationRelativePath(\n config: GitLabIntegrationConfig,\n): string {\n let relativePath = '';\n if (config.host !== GITLAB_HOST) {\n relativePath = new URL(config.baseUrl).pathname;\n }\n return trimEnd(relativePath, '/');\n}\n"],"names":[],"mappings":";;;AAoBA,MAAM,WAAc,GAAA,YAAA,CAAA;AACpB,MAAM,mBAAsB,GAAA,2BAAA,CAAA;AA2CrB,SAAS,4BACd,MACyB,EAAA;AACzB,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA,CAAA;AACpC,EAAI,IAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA,CAAA;AACtD,EAAA,MAAM,KAAQ,GAAA,MAAA,CAAO,iBAAkB,CAAA,OAAO,GAAG,IAAK,EAAA,CAAA;AACtD,EAAI,IAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA,CAAA;AAChD,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAA,OAAA,CAAQ,YAAY,GAAG,CAAA,CAAA;AAAA,GACtC,MAAA,IAAW,SAAS,WAAa,EAAA;AAC/B,IAAa,UAAA,GAAA,mBAAA,CAAA;AAAA,GACf;AAEA,EAAA,IAAI,OAAS,EAAA;AACX,IAAU,OAAA,GA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/B,IAAA,YAAA,GAAe,IAAI,GAAA,CAAI,MAAO,CAAA,OAAO,CAAE,CAAA,QAAA,CAAA;AAAA,GACzC;AACA,EAAO,OAAA,OAAA,CAAQ,cAAc,GAAG,CAAA,CAAA;AAClC;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/gitlab/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, isValidUrl } from '../helpers';\n\nconst GITLAB_HOST = 'gitlab.com';\nconst GITLAB_API_BASE_URL = 'https://gitlab.com/api/v4';\n\n/**\n * The configuration parameters for a single GitLab integration.\n *\n * @public\n */\nexport type GitLabIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. `gitlab.com`.\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g.\n * `https://gitlab.com/api/v4`, with no trailing slash.\n *\n * May be omitted specifically for public GitLab; then it will be deduced.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to this provider.\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The baseUrl of this provider, e.g. `https://gitlab.com`, which is passed\n * into the GitLab client.\n *\n * If no baseUrl is provided, it will default to `https://${host}`\n */\n baseUrl: string;\n};\n\n/**\n * Reads a single GitLab integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGitLabIntegrationConfig(\n config: Config,\n): GitLabIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n let baseUrl = config.getOptionalString('baseUrl');\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === GITLAB_HOST) {\n apiBaseUrl = GITLAB_API_BASE_URL;\n }\n\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid GitLab integration config, '${host}' is not a valid host`,\n );\n } else if (!apiBaseUrl || !isValidUrl(apiBaseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${apiBaseUrl}' is not a valid apiBaseUrl`,\n );\n } else if (!isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n }\n\n return { host, token, apiBaseUrl, baseUrl };\n}\n\n/**\n * Reads a set of GitLab integration configs, and inserts some defaults for\n * public GitLab if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readGitLabIntegrationConfigs(\n configs: Config[],\n): GitLabIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readGitLabIntegrationConfig);\n\n // As a convenience we always make sure there's at least an unauthenticated\n // reader for public gitlab repos.\n if (!result.some(c => c.host === GITLAB_HOST)) {\n result.push({\n host: GITLAB_HOST,\n apiBaseUrl: GITLAB_API_BASE_URL,\n baseUrl: `https://${GITLAB_HOST}`,\n });\n }\n\n return result;\n}\n\n/**\n * Reads a GitLab integration config, and returns\n * relative path.\n *\n * @param config - GitLabIntegrationConfig object\n * @public\n */\nexport function getGitLabIntegrationRelativePath(\n config: GitLabIntegrationConfig,\n): string {\n let relativePath = '';\n if (config.host !== GITLAB_HOST) {\n relativePath = new URL(config.baseUrl).pathname;\n }\n return trimEnd(relativePath, '/');\n}\n"],"names":[],"mappings":";;;AAoBA,MAAM,WAAc,GAAA,YAAA;AACpB,MAAM,mBAAsB,GAAA,2BAAA;AA2CrB,SAAS,4BACd,MACyB,EAAA;AACzB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AC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,WAAW,CAAG,EAAA;AAC7C,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,WAAA;AAAA,MACN,UAAY,EAAA,mBAAA;AAAA,MACZ,OAAA,EAAS,WAAW,WAAW,CAAA;AAAA,KAChC,CAAA;AAAA;AAGH,EAAO,OAAA,MAAA;AACT;AASO,SAAS,iCACd,MACQ,EAAA;AACR,EAAA,IAAI,YAAe,GAAA,EAAA;AACnB,EAAI,IAAA,MAAA,CAAO,SAAS,WAAa,EAAA;AAC/B,IAAA,YAAA,GAAe,IAAI,GAAA,CAAI,MAAO,CAAA,OAAO,CAAE,CAAA,QAAA;AAAA;AAEzC,EAAO,OAAA,OAAA,CAAQ,cAAc,GAAG,CAAA;AAClC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"core.cjs.js","sources":["../../src/gitlab/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 {\n getGitLabIntegrationRelativePath,\n GitLabIntegrationConfig,\n} from './config';\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://gitlab.example.com/a/b/blob/master/c.yaml\n * to: https://gitlab.com/api/v4/projects/projectId/repository/c.yaml?ref=master\n * -or-\n * from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n * to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport async function getGitLabFileFetchUrl(\n url: string,\n config: GitLabIntegrationConfig,\n): Promise<string> {\n const projectID = await getProjectId(url, config);\n return buildProjectUrl(url, projectID, config).toString();\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 getGitLabRequestOptions(\n config: GitLabIntegrationConfig,\n token?: string,\n): { headers: Record<string, string> } {\n if (token) {\n // If token comes from the user and starts with \"gl\", it's a private token (see https://docs.gitlab.com/ee/security/token_overview.html#token-prefixes)\n return {\n headers: token.startsWith('gl')\n ? { 'PRIVATE-TOKEN': token }\n : { Authorization: `Bearer ${token}` }, // Otherwise, it's a bearer token\n };\n }\n\n // If token not provided, fetch the integration token\n const { token: configToken = '' } = config;\n return {\n headers: { 'PRIVATE-TOKEN': configToken },\n };\n}\n\n// Converts\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\nexport function buildProjectUrl(\n target: string,\n projectID: Number,\n config: GitLabIntegrationConfig,\n): URL {\n try {\n const url = new URL(target);\n\n const branchAndFilePath = url.pathname\n .split('/blob/')\n .slice(1)\n .join('/blob/');\n const [branch, ...filePath] = branchAndFilePath.split('/');\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n url.pathname = [\n ...(relativePath ? [relativePath] : []),\n 'api/v4/projects',\n projectID,\n 'repository/files',\n encodeURIComponent(decodeURIComponent(filePath.join('/'))),\n 'raw',\n ].join('/');\n\n url.search = `?ref=${branch}`;\n\n return url;\n } catch (e) {\n throw new Error(`Incorrect url: ${target}, ${e}`);\n }\n}\n\n// Convert\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: The project ID that corresponds to the URL\nexport async function getProjectId(\n target: string,\n config: GitLabIntegrationConfig,\n): Promise<number> {\n const url = new URL(target);\n\n if (!url.pathname.includes('/blob/')) {\n throw new Error(\n `Failed converting ${url.pathname} to a project id. Url path must include /blob/.`,\n );\n }\n\n try {\n let repo = url.pathname.split('/-/blob/')[0].split('/blob/')[0];\n\n // Get gitlab relative path\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n // Check relative path exist and replace it if it's the case.\n if (relativePath) {\n repo = repo.replace(relativePath, '');\n }\n\n // Convert\n // to: https://gitlab.com/api/v4/projects/groupA%2Fteams%2FsubgroupA%2FteamA%2Frepo\n const repoIDLookup = new URL(\n `${url.origin}${relativePath}/api/v4/projects/${encodeURIComponent(\n repo.replace(/^\\//, ''),\n )}`,\n );\n\n const response = await fetch(\n repoIDLookup.toString(),\n getGitLabRequestOptions(config),\n );\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new Error(\n `GitLab Error '${data.error}', ${data.error_description}`,\n );\n }\n\n return Number(data.id);\n } catch (e) {\n throw new Error(`Could not get GitLab project ID for: ${target}, ${e}`);\n }\n}\n"],"names":["config","getGitLabIntegrationRelativePath","fetch"],"mappings":";;;;;;;;;AAuCsB,eAAA,qBAAA,CACpB,KACA,MACiB,EAAA;AACjB,EAAA,MAAM,SAAY,GAAA,MAAM,YAAa,CAAA,GAAA,EAAK,MAAM,CAAA,CAAA;AAChD,EAAA,OAAO,eAAgB,CAAA,GAAA,EAAK,SAAW,EAAA,MAAM,EAAE,QAAS,EAAA,CAAA;AAC1D,CAAA;AAQgB,SAAA,uBAAA,CACd,QACA,KACqC,EAAA;AACrC,EAAA,IAAI,KAAO,EAAA;AAET,IAAO,OAAA;AAAA,MACL,OAAS,EAAA,KAAA,CAAM,UAAW,CAAA,IAAI,CAC1B,GAAA,EAAE,eAAiB,EAAA,KAAA,EACnB,GAAA,EAAE,aAAe,EAAA,CAAA,OAAA,EAAU,KAAK,CAAG,CAAA,EAAA;AAAA;AAAA,KACzC,CAAA;AAAA,GACF;AAGA,EAAA,MAAM,EAAE,KAAA,EAAO,WAAc,GAAA,EAA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AAA,MAAM,IAAI,KAAM,CAAA,CAAA,qCAAA,EAAwC,MAAM,CAAA,EAAA,EAAK,CAAC,CAAE,CAAA,CAAA,CAAA;AAAA,GACxE;AACF;;;;;;;"}
1
+ {"version":3,"file":"core.cjs.js","sources":["../../src/gitlab/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 {\n getGitLabIntegrationRelativePath,\n GitLabIntegrationConfig,\n} from './config';\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://gitlab.example.com/a/b/blob/master/c.yaml\n * to: https://gitlab.com/api/v4/projects/projectId/repository/c.yaml?ref=master\n * -or-\n * from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n * to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport async function getGitLabFileFetchUrl(\n url: string,\n config: GitLabIntegrationConfig,\n): Promise<string> {\n const projectID = await getProjectId(url, config);\n return buildProjectUrl(url, projectID, config).toString();\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 getGitLabRequestOptions(\n config: GitLabIntegrationConfig,\n token?: string,\n): { headers: Record<string, string> } {\n if (token) {\n // If token comes from the user and starts with \"gl\", it's a private token (see https://docs.gitlab.com/ee/security/token_overview.html#token-prefixes)\n return {\n headers: token.startsWith('gl')\n ? { 'PRIVATE-TOKEN': token }\n : { Authorization: `Bearer ${token}` }, // Otherwise, it's a bearer token\n };\n }\n\n // If token not provided, fetch the integration token\n const { token: configToken = '' } = config;\n return {\n headers: { 'PRIVATE-TOKEN': configToken },\n };\n}\n\n// Converts\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\nexport function buildProjectUrl(\n target: string,\n projectID: Number,\n config: GitLabIntegrationConfig,\n): URL {\n try {\n const url = new URL(target);\n\n const branchAndFilePath = url.pathname\n .split('/blob/')\n .slice(1)\n .join('/blob/');\n const [branch, ...filePath] = branchAndFilePath.split('/');\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n url.pathname = [\n ...(relativePath ? [relativePath] : []),\n 'api/v4/projects',\n projectID,\n 'repository/files',\n encodeURIComponent(decodeURIComponent(filePath.join('/'))),\n 'raw',\n ].join('/');\n\n url.search = `?ref=${branch}`;\n\n return url;\n } catch (e) {\n throw new Error(`Incorrect url: ${target}, ${e}`);\n }\n}\n\n// Convert\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: The project ID that corresponds to the URL\nexport async function getProjectId(\n target: string,\n config: GitLabIntegrationConfig,\n): Promise<number> {\n const url = new URL(target);\n\n if (!url.pathname.includes('/blob/')) {\n throw new Error(\n `Failed converting ${url.pathname} to a project id. Url path must include /blob/.`,\n );\n }\n\n try {\n let repo = url.pathname.split('/-/blob/')[0].split('/blob/')[0];\n\n // Get gitlab relative path\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n // Check relative path exist and replace it if it's the case.\n if (relativePath) {\n repo = repo.replace(relativePath, '');\n }\n\n // Convert\n // to: https://gitlab.com/api/v4/projects/groupA%2Fteams%2FsubgroupA%2FteamA%2Frepo\n const repoIDLookup = new URL(\n `${url.origin}${relativePath}/api/v4/projects/${encodeURIComponent(\n repo.replace(/^\\//, ''),\n )}`,\n );\n\n const response = await fetch(\n repoIDLookup.toString(),\n getGitLabRequestOptions(config),\n );\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new Error(\n `GitLab Error '${data.error}', ${data.error_description}`,\n );\n }\n\n return Number(data.id);\n } catch (e) {\n throw new Error(`Could not get GitLab project ID for: ${target}, ${e}`);\n }\n}\n"],"names":["config","getGitLabIntegrationRelativePath","fetch"],"mappings":";;;;;;;;;AAuCsB,eAAA,qBAAA,CACpB,KACA,MACiB,EAAA;AACjB,EAAA,MAAM,SAAY,GAAA,MAAM,YAAa,CAAA,GAAA,EAAK,MAAM,CAAA;AAChD,EAAA,OAAO,eAAgB,CAAA,GAAA,EAAK,SAAW,EAAA,MAAM,EAAE,QAAS,EAAA;AAC1D;AAQgB,SAAA,uBAAA,CACd,QACA,KACqC,EAAA;AACrC,EAAA,IAAI,KAAO,EAAA;AAET,IAAO,OAAA;AAAA,MACL,OAAS,EAAA,KAAA,CAAM,UAAW,CAAA,IAAI,CAC1B,GAAA,EAAE,eAAiB,EAAA,KAAA,EACnB,GAAA,EAAE,aAAe,EAAA,CAAA,OAAA,EAAU,KAAK,CAAG,CAAA;AAAA;AAAA,KACzC;AAAA;AAIF,EAAA,MAAM,EAAE,KAAA,EAAO,WAAc,GAAA,EAAA,EAAO,GAAA,MAAA;AACpC,EAAO,OAAA;AAAA,IACL,OAAA,EAAS,EAAE,eAAA,EAAiB,WAAY;AAAA,GAC1C;AACF;AAKgB,SAAA,eAAA,CACd,MACA,EAAA,SAAA,EACAA,QACK,EAAA;AACL,EAAI,IAAA;AACF,IAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,MAAM,CAAA;AAE1B,IAAM,MAAA,iBAAA,GAAoB,GAAI,CAAA,QAAA,CAC3B,KAAM,CAAA,QAAQ,EACd,KAAM,CAAA,CAAC,CACP,CAAA,IAAA,CAAK,QAAQ,CAAA;AAChB,IAAA,MAAM,CAAC,MAAQ,EAAA,GAAG,QAAQ,CAAI,GAAA,iBAAA,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AAA,MACvB,CAAG,EAAA,GAAA,CAAI,MAAM,CAAA,EAAG,YAAY,CAAoB,iBAAA,EAAA,kBAAA;AAAA,QAC9C,IAAA,CAAK,OAAQ,CAAA,KAAA,EAAO,EAAE;AAAA,OACvB,CAAA;AAAA,KACH;AAEA,IAAA,MAAM,WAAW,MAAME,sBAAA;AAAA,MACrB,aAAa,QAAS,EAAA;AAAA,MACtB,wBAAwBF,QAAM;AAAA,KAChC;AAEA,IAAM,MAAA,IAAA,GAAO,MAAM,QAAA,CAAS,IAAK,EAAA;AAEjC,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAiB,cAAA,EAAA,IAAA,CAAK,KAAK,CAAA,GAAA,EAAM,KAAK,iBAAiB,CAAA;AAAA,OACzD;AAAA;AAGF,IAAO,OAAA,MAAA,CAAO,KAAK,EAAE,CAAA;AAAA,WACd,CAAG,EAAA;AACV,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,qCAAA,EAAwC,MAAM,CAAA,EAAA,EAAK,CAAC,CAAE,CAAA,CAAA;AAAA;AAE1E;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"core.esm.js","sources":["../../src/gitlab/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 {\n getGitLabIntegrationRelativePath,\n GitLabIntegrationConfig,\n} from './config';\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://gitlab.example.com/a/b/blob/master/c.yaml\n * to: https://gitlab.com/api/v4/projects/projectId/repository/c.yaml?ref=master\n * -or-\n * from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n * to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport async function getGitLabFileFetchUrl(\n url: string,\n config: GitLabIntegrationConfig,\n): Promise<string> {\n const projectID = await getProjectId(url, config);\n return buildProjectUrl(url, projectID, config).toString();\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 getGitLabRequestOptions(\n config: GitLabIntegrationConfig,\n token?: string,\n): { headers: Record<string, string> } {\n if (token) {\n // If token comes from the user and starts with \"gl\", it's a private token (see https://docs.gitlab.com/ee/security/token_overview.html#token-prefixes)\n return {\n headers: token.startsWith('gl')\n ? { 'PRIVATE-TOKEN': token }\n : { Authorization: `Bearer ${token}` }, // Otherwise, it's a bearer token\n };\n }\n\n // If token not provided, fetch the integration token\n const { token: configToken = '' } = config;\n return {\n headers: { 'PRIVATE-TOKEN': configToken },\n };\n}\n\n// Converts\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\nexport function buildProjectUrl(\n target: string,\n projectID: Number,\n config: GitLabIntegrationConfig,\n): URL {\n try {\n const url = new URL(target);\n\n const branchAndFilePath = url.pathname\n .split('/blob/')\n .slice(1)\n .join('/blob/');\n const [branch, ...filePath] = branchAndFilePath.split('/');\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n url.pathname = [\n ...(relativePath ? [relativePath] : []),\n 'api/v4/projects',\n projectID,\n 'repository/files',\n encodeURIComponent(decodeURIComponent(filePath.join('/'))),\n 'raw',\n ].join('/');\n\n url.search = `?ref=${branch}`;\n\n return url;\n } catch (e) {\n throw new Error(`Incorrect url: ${target}, ${e}`);\n }\n}\n\n// Convert\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: The project ID that corresponds to the URL\nexport async function getProjectId(\n target: string,\n config: GitLabIntegrationConfig,\n): Promise<number> {\n const url = new URL(target);\n\n if (!url.pathname.includes('/blob/')) {\n throw new Error(\n `Failed converting ${url.pathname} to a project id. Url path must include /blob/.`,\n );\n }\n\n try {\n let repo = url.pathname.split('/-/blob/')[0].split('/blob/')[0];\n\n // Get gitlab relative path\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n // Check relative path exist and replace it if it's the case.\n if (relativePath) {\n repo = repo.replace(relativePath, '');\n }\n\n // Convert\n // to: https://gitlab.com/api/v4/projects/groupA%2Fteams%2FsubgroupA%2FteamA%2Frepo\n const repoIDLookup = new URL(\n `${url.origin}${relativePath}/api/v4/projects/${encodeURIComponent(\n repo.replace(/^\\//, ''),\n )}`,\n );\n\n const response = await fetch(\n repoIDLookup.toString(),\n getGitLabRequestOptions(config),\n );\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new Error(\n `GitLab Error '${data.error}', ${data.error_description}`,\n );\n }\n\n return Number(data.id);\n } catch (e) {\n throw new Error(`Could not get GitLab project ID for: ${target}, ${e}`);\n }\n}\n"],"names":[],"mappings":";;;AAuCsB,eAAA,qBAAA,CACpB,KACA,MACiB,EAAA;AACjB,EAAA,MAAM,SAAY,GAAA,MAAM,YAAa,CAAA,GAAA,EAAK,MAAM,CAAA,CAAA;AAChD,EAAA,OAAO,eAAgB,CAAA,GAAA,EAAK,SAAW,EAAA,MAAM,EAAE,QAAS,EAAA,CAAA;AAC1D,CAAA;AAQgB,SAAA,uBAAA,CACd,QACA,KACqC,EAAA;AACrC,EAAA,IAAI,KAAO,EAAA;AAET,IAAO,OAAA;AAAA,MACL,OAAS,EAAA,KAAA,CAAM,UAAW,CAAA,IAAI,CAC1B,GAAA,EAAE,eAAiB,EAAA,KAAA,EACnB,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AAM,KAAK,iBAAiB,CAAA,CAAA;AAAA,OACzD,CAAA;AAAA,KACF;AAEA,IAAO,OAAA,MAAA,CAAO,KAAK,EAAE,CAAA,CAAA;AAAA,WACd,CAAG,EAAA;AACV,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,qCAAA,EAAwC,MAAM,CAAA,EAAA,EAAK,CAAC,CAAE,CAAA,CAAA,CAAA;AAAA,GACxE;AACF;;;;"}
1
+ {"version":3,"file":"core.esm.js","sources":["../../src/gitlab/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 {\n getGitLabIntegrationRelativePath,\n GitLabIntegrationConfig,\n} from './config';\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://gitlab.example.com/a/b/blob/master/c.yaml\n * to: https://gitlab.com/api/v4/projects/projectId/repository/c.yaml?ref=master\n * -or-\n * from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n * to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport async function getGitLabFileFetchUrl(\n url: string,\n config: GitLabIntegrationConfig,\n): Promise<string> {\n const projectID = await getProjectId(url, config);\n return buildProjectUrl(url, projectID, config).toString();\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 getGitLabRequestOptions(\n config: GitLabIntegrationConfig,\n token?: string,\n): { headers: Record<string, string> } {\n if (token) {\n // If token comes from the user and starts with \"gl\", it's a private token (see https://docs.gitlab.com/ee/security/token_overview.html#token-prefixes)\n return {\n headers: token.startsWith('gl')\n ? { 'PRIVATE-TOKEN': token }\n : { Authorization: `Bearer ${token}` }, // Otherwise, it's a bearer token\n };\n }\n\n // If token not provided, fetch the integration token\n const { token: configToken = '' } = config;\n return {\n headers: { 'PRIVATE-TOKEN': configToken },\n };\n}\n\n// Converts\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\nexport function buildProjectUrl(\n target: string,\n projectID: Number,\n config: GitLabIntegrationConfig,\n): URL {\n try {\n const url = new URL(target);\n\n const branchAndFilePath = url.pathname\n .split('/blob/')\n .slice(1)\n .join('/blob/');\n const [branch, ...filePath] = branchAndFilePath.split('/');\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n url.pathname = [\n ...(relativePath ? [relativePath] : []),\n 'api/v4/projects',\n projectID,\n 'repository/files',\n encodeURIComponent(decodeURIComponent(filePath.join('/'))),\n 'raw',\n ].join('/');\n\n url.search = `?ref=${branch}`;\n\n return url;\n } catch (e) {\n throw new Error(`Incorrect url: ${target}, ${e}`);\n }\n}\n\n// Convert\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: The project ID that corresponds to the URL\nexport async function getProjectId(\n target: string,\n config: GitLabIntegrationConfig,\n): Promise<number> {\n const url = new URL(target);\n\n if (!url.pathname.includes('/blob/')) {\n throw new Error(\n `Failed converting ${url.pathname} to a project id. Url path must include /blob/.`,\n );\n }\n\n try {\n let repo = url.pathname.split('/-/blob/')[0].split('/blob/')[0];\n\n // Get gitlab relative path\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n // Check relative path exist and replace it if it's the case.\n if (relativePath) {\n repo = repo.replace(relativePath, '');\n }\n\n // Convert\n // to: https://gitlab.com/api/v4/projects/groupA%2Fteams%2FsubgroupA%2FteamA%2Frepo\n const repoIDLookup = new URL(\n `${url.origin}${relativePath}/api/v4/projects/${encodeURIComponent(\n repo.replace(/^\\//, ''),\n )}`,\n );\n\n const response = await fetch(\n repoIDLookup.toString(),\n getGitLabRequestOptions(config),\n );\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new Error(\n `GitLab Error '${data.error}', ${data.error_description}`,\n );\n }\n\n return Number(data.id);\n } catch (e) {\n throw new Error(`Could not get GitLab project ID for: ${target}, ${e}`);\n }\n}\n"],"names":[],"mappings":";;;AAuCsB,eAAA,qBAAA,CACpB,KACA,MACiB,EAAA;AACjB,EAAA,MAAM,SAAY,GAAA,MAAM,YAAa,CAAA,GAAA,EAAK,MAAM,CAAA;AAChD,EAAA,OAAO,eAAgB,CAAA,GAAA,EAAK,SAAW,EAAA,MAAM,EAAE,QAAS,EAAA;AAC1D;AAQgB,SAAA,uBAAA,CACd,QACA,KACqC,EAAA;AACrC,EAAA,IAAI,KAAO,EAAA;AAET,IAAO,OAAA;AAAA,MACL,OAAS,EAAA,KAAA,CAAM,UAAW,CAAA,IAAI,CAC1B,GAAA,EAAE,eAAiB,EAAA,KAAA,EACnB,GAAA,EAAE,aAAe,EAAA,CAAA,OAAA,EAAU,KAAK,CAAG,CAAA;AAAA;AAAA,KACzC;AAAA;AAIF,EAAA,MAAM,EAAE,KAAA,EAAO,WAAc,GAAA,EAAA,EAAO,GAAA,MAAA;AACpC,EAAO,OAAA;AAAA,IACL,OAAA,EAAS,EAAE,eAAA,EAAiB,WAAY;AAAA,GAC1C;AACF;AAKgB,SAAA,eAAA,CACd,MACA,EAAA,SAAA,EACA,MACK,EAAA;AACL,EAAI,IAAA;AACF,IAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,MAAM,CAAA;AAE1B,IAAM,MAAA,iBAAA,GAAoB,GAAI,CAAA,QAAA,CAC3B,KAAM,CAAA,QAAQ,EACd,KAAM,CAAA,CAAC,CAC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AA,IAAA,CAAK,OAAQ,CAAA,YAAA,EAAc,EAAE,CAAA;AAAA;AAKtC,IAAA,MAAM,eAAe,IAAI,GAAA;AAAA,MACvB,CAAG,EAAA,GAAA,CAAI,MAAM,CAAA,EAAG,YAAY,CAAoB,iBAAA,EAAA,kBAAA;AAAA,QAC9C,IAAA,CAAK,OAAQ,CAAA,KAAA,EAAO,EAAE;AAAA,OACvB,CAAA;AAAA,KACH;AAEA,IAAA,MAAM,WAAW,MAAM,KAAA;AAAA,MACrB,aAAa,QAAS,EAAA;AAAA,MACtB,wBAAwB,MAAM;AAAA,KAChC;AAEA,IAAM,MAAA,IAAA,GAAO,MAAM,QAAA,CAAS,IAAK,EAAA;AAEjC,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAiB,cAAA,EAAA,IAAA,CAAK,KAAK,CAAA,GAAA,EAAM,KAAK,iBAAiB,CAAA;AAAA,OACzD;AAAA;AAGF,IAAO,OAAA,MAAA,CAAO,KAAK,EAAE,CAAA;AAAA,WACd,CAAG,EAAA;AACV,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,qCAAA,EAAwC,MAAM,CAAA,EAAA,EAAK,CAAC,CAAE,CAAA,CAAA;AAAA;AAE1E;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/googleGcs/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\n/**\n * The configuration parameters for a single Google Cloud Storage provider.\n *\n * @public\n */\nexport type GoogleGcsIntegrationConfig = {\n /**\n * Service account email used to authenticate requests.\n */\n clientEmail?: string;\n /**\n * Service account private key used to authenticate requests.\n */\n privateKey?: string;\n};\n\n/**\n * Reads a single Google GCS integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGoogleGcsIntegrationConfig(\n config: Config,\n): GoogleGcsIntegrationConfig {\n if (!config) {\n return {};\n }\n\n if (!config.has('clientEmail') && !config.has('privateKey')) {\n return {};\n }\n\n const privateKey = config.getString('privateKey').split('\\\\n').join('\\n');\n\n const clientEmail = config.getString('clientEmail');\n return { clientEmail: clientEmail, privateKey: privateKey };\n}\n"],"names":[],"mappings":";;AAwCO,SAAS,+BACd,MAC4B,EAAA;AAC5B,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AAEA,EAAI,IAAA,CAAC,OAAO,GAAI,CAAA,aAAa,KAAK,CAAC,MAAA,CAAO,GAAI,CAAA,YAAY,CAAG,EAAA;AAC3D,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AAEA,EAAM,MAAA,UAAA,GAAa,OAAO,SAAU,CAAA,YAAY,EAAE,KAAM,CAAA,KAAK,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA,CAAA;AAExE,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,SAAA,CAAU,aAAa,CAAA,CAAA;AAClD,EAAO,OAAA,EAAE,aAA0B,UAAuB,EAAA,CAAA;AAC5D;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../../src/googleGcs/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\n/**\n * The configuration parameters for a single Google Cloud Storage provider.\n *\n * @public\n */\nexport type GoogleGcsIntegrationConfig = {\n /**\n * Service account email used to authenticate requests.\n */\n clientEmail?: string;\n /**\n * Service account private key used to authenticate requests.\n */\n privateKey?: string;\n};\n\n/**\n * Reads a single Google GCS integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGoogleGcsIntegrationConfig(\n config: Config,\n): GoogleGcsIntegrationConfig {\n if (!config) {\n return {};\n }\n\n if (!config.has('clientEmail') && !config.has('privateKey')) {\n return {};\n }\n\n const privateKey = config.getString('privateKey').split('\\\\n').join('\\n');\n\n const clientEmail = config.getString('clientEmail');\n return { clientEmail: clientEmail, privateKey: privateKey };\n}\n"],"names":[],"mappings":";;AAwCO,SAAS,+BACd,MAC4B,EAAA;AAC5B,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAA,OAAO,EAAC;AAAA;AAGV,EAAI,IAAA,CAAC,OAAO,GAAI,CAAA,aAAa,KAAK,CAAC,MAAA,CAAO,GAAI,CAAA,YAAY,CAAG,EAAA;AAC3D,IAAA,OAAO,EAAC;AAAA;AAGV,EAAM,MAAA,UAAA,GAAa,OAAO,SAAU,CAAA,YAAY,EAAE,KAAM,CAAA,KAAK,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA;AAExE,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,SAAA,CAAU,aAAa,CAAA;AAClD,EAAO,OAAA,EAAE,aAA0B,UAAuB,EAAA;AAC5D;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/googleGcs/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\n/**\n * The configuration parameters for a single Google Cloud Storage provider.\n *\n * @public\n */\nexport type GoogleGcsIntegrationConfig = {\n /**\n * Service account email used to authenticate requests.\n */\n clientEmail?: string;\n /**\n * Service account private key used to authenticate requests.\n */\n privateKey?: string;\n};\n\n/**\n * Reads a single Google GCS integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGoogleGcsIntegrationConfig(\n config: Config,\n): GoogleGcsIntegrationConfig {\n if (!config) {\n return {};\n }\n\n if (!config.has('clientEmail') && !config.has('privateKey')) {\n return {};\n }\n\n const privateKey = config.getString('privateKey').split('\\\\n').join('\\n');\n\n const clientEmail = config.getString('clientEmail');\n return { clientEmail: clientEmail, privateKey: privateKey };\n}\n"],"names":[],"mappings":"AAwCO,SAAS,+BACd,MAC4B,EAAA;AAC5B,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AAEA,EAAI,IAAA,CAAC,OAAO,GAAI,CAAA,aAAa,KAAK,CAAC,MAAA,CAAO,GAAI,CAAA,YAAY,CAAG,EAAA;AAC3D,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AAEA,EAAM,MAAA,UAAA,GAAa,OAAO,SAAU,CAAA,YAAY,EAAE,KAAM,CAAA,KAAK,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA,CAAA;AAExE,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,SAAA,CAAU,aAAa,CAAA,CAAA;AAClD,EAAO,OAAA,EAAE,aAA0B,UAAuB,EAAA,CAAA;AAC5D;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/googleGcs/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\n/**\n * The configuration parameters for a single Google Cloud Storage provider.\n *\n * @public\n */\nexport type GoogleGcsIntegrationConfig = {\n /**\n * Service account email used to authenticate requests.\n */\n clientEmail?: string;\n /**\n * Service account private key used to authenticate requests.\n */\n privateKey?: string;\n};\n\n/**\n * Reads a single Google GCS integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGoogleGcsIntegrationConfig(\n config: Config,\n): GoogleGcsIntegrationConfig {\n if (!config) {\n return {};\n }\n\n if (!config.has('clientEmail') && !config.has('privateKey')) {\n return {};\n }\n\n const privateKey = config.getString('privateKey').split('\\\\n').join('\\n');\n\n const clientEmail = config.getString('clientEmail');\n return { clientEmail: clientEmail, privateKey: privateKey };\n}\n"],"names":[],"mappings":"AAwCO,SAAS,+BACd,MAC4B,EAAA;AAC5B,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAA,OAAO,EAAC;AAAA;AAGV,EAAI,IAAA,CAAC,OAAO,GAAI,CAAA,aAAa,KAAK,CAAC,MAAA,CAAO,GAAI,CAAA,YAAY,CAAG,EAAA;AAC3D,IAAA,OAAO,EAAC;AAAA;AAGV,EAAM,MAAA,UAAA,GAAa,OAAO,SAAU,CAAA,YAAY,EAAE,KAAM,CAAA,KAAK,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA;AAExE,EAAM,MAAA,WAAA,GAAc,MAAO,CAAA,SAAA,CAAU,aAAa,CAAA;AAClD,EAAO,OAAA,EAAE,aAA0B,UAAuB,EAAA;AAC5D;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"HarnessIntegration.cjs.js","sources":["../../src/harness/HarnessIntegration.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { HarnessIntegrationConfig, readHarnessConfig } from './config';\nimport { getHarnessEditContentsUrl } from './core';\n\n/**\n * A Harness Code based integration.\n *\n * @public\n */\nexport class HarnessIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<HarnessIntegration> = ({ config }) => {\n const configs = config.getOptionalConfigArray('integrations.harness') ?? [];\n const harnessConfigs = configs.map(c => readHarnessConfig(c));\n\n return basicIntegrations(\n harnessConfigs.map(c => new HarnessIntegration(c)),\n (harness: HarnessIntegration) => harness.config.host,\n );\n };\n\n constructor(readonly config: HarnessIntegrationConfig) {}\n\n get type(): string {\n return 'harness';\n }\n\n get title(): string {\n return this.config.host;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return getHarnessEditContentsUrl(this.config, url);\n }\n}\n"],"names":["config","readHarnessConfig","basicIntegrations","defaultScmResolveUrl","getHarnessEditContentsUrl"],"mappings":";;;;;;AAyBO,MAAM,kBAA6C,CAAA;AAAA,EAWxD,YAAqB,MAAkC,EAAA;AAAlC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;AAAA,GAAmC;AAAA,EAVxD,OAAO,OAAA,GAAsD,CAAC,UAAEA,UAAa,KAAA;AAC3E,IAAA,MAAM,OAAU,GAAAA,QAAA,CAAO,sBAAuB,CAAA,sBAAsB,KAAK,EAAC,CAAA;AAC1E,IAAA,MAAM,iBAAiB,OAAQ,CAAA,GAAA,CAAI,CAAK,CAAA,KAAAC,wBAAA,CAAkB,CAAC,CAAC,CAAA,CAAA;AAE5D,IAAO,OAAAC,yBAAA;AAAA,MACL,eAAe,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,kBAAA,CAAmB,CAAC,CAAC,CAAA;AAAA,MACjD,CAAC,OAAgC,KAAA,OAAA,CAAQ,MAAO,CAAA,IAAA;AAAA,KAClD,CAAA;AAAA,GACF,CAAA;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,SAAA,CAAA;AAAA,GACT;AAAA,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,MAAO,CAAA,IAAA,CAAA;AAAA,GACrB;AAAA,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,OAAOC,6BAAqB,OAAO,CAAA,CAAA;AAAA,GACrC;AAAA,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAO,OAAAC,8BAAA,CAA0B,IAAK,CAAA,MAAA,EAAQ,GAAG,CAAA,CAAA;AAAA,GACnD;AACF;;;;"}
1
+ {"version":3,"file":"HarnessIntegration.cjs.js","sources":["../../src/harness/HarnessIntegration.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { HarnessIntegrationConfig, readHarnessConfig } from './config';\nimport { getHarnessEditContentsUrl } from './core';\n\n/**\n * A Harness Code based integration.\n *\n * @public\n */\nexport class HarnessIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<HarnessIntegration> = ({ config }) => {\n const configs = config.getOptionalConfigArray('integrations.harness') ?? [];\n const harnessConfigs = configs.map(c => readHarnessConfig(c));\n\n return basicIntegrations(\n harnessConfigs.map(c => new HarnessIntegration(c)),\n (harness: HarnessIntegration) => harness.config.host,\n );\n };\n\n constructor(readonly config: HarnessIntegrationConfig) {}\n\n get type(): string {\n return 'harness';\n }\n\n get title(): string {\n return this.config.host;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return getHarnessEditContentsUrl(this.config, url);\n }\n}\n"],"names":["config","readHarnessConfig","basicIntegrations","defaultScmResolveUrl","getHarnessEditContentsUrl"],"mappings":";;;;;;AAyBO,MAAM,kBAA6C,CAAA;AAAA,EAWxD,YAAqB,MAAkC,EAAA;AAAlC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AAAmC,EAVxD,OAAO,OAAA,GAAsD,CAAC,UAAEA,UAAa,KAAA;AAC3E,IAAA,MAAM,OAAU,GAAAA,QAAA,CAAO,sBAAuB,CAAA,sBAAsB,KAAK,EAAC;AAC1E,IAAA,MAAM,iBAAiB,OAAQ,CAAA,GAAA,CAAI,CAAK,CAAA,KAAAC,wBAAA,CAAkB,CAAC,CAAC,CAAA;AAE5D,IAAO,OAAAC,yBAAA;AAAA,MACL,eAAe,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,kBAAA,CAAmB,CAAC,CAAC,CAAA;AAAA,MACjD,CAAC,OAAgC,KAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,KAClD;AAAA,GACF;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,SAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,MAAO,CAAA,IAAA;AAAA;AACrB,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,OAAOC,6BAAqB,OAAO,CAAA;AAAA;AACrC,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAO,OAAAC,8BAAA,CAA0B,IAAK,CAAA,MAAA,EAAQ,GAAG,CAAA;AAAA;AAErD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"HarnessIntegration.esm.js","sources":["../../src/harness/HarnessIntegration.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { HarnessIntegrationConfig, readHarnessConfig } from './config';\nimport { getHarnessEditContentsUrl } from './core';\n\n/**\n * A Harness Code based integration.\n *\n * @public\n */\nexport class HarnessIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<HarnessIntegration> = ({ config }) => {\n const configs = config.getOptionalConfigArray('integrations.harness') ?? [];\n const harnessConfigs = configs.map(c => readHarnessConfig(c));\n\n return basicIntegrations(\n harnessConfigs.map(c => new HarnessIntegration(c)),\n (harness: HarnessIntegration) => harness.config.host,\n );\n };\n\n constructor(readonly config: HarnessIntegrationConfig) {}\n\n get type(): string {\n return 'harness';\n }\n\n get title(): string {\n return this.config.host;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return getHarnessEditContentsUrl(this.config, url);\n }\n}\n"],"names":[],"mappings":";;;;AAyBO,MAAM,kBAA6C,CAAA;AAAA,EAWxD,YAAqB,MAAkC,EAAA;AAAlC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;AAAA,GAAmC;AAAA,EAVxD,OAAO,OAAA,GAAsD,CAAC,EAAE,QAAa,KAAA;AAC3E,IAAA,MAAM,OAAU,GAAA,MAAA,CAAO,sBAAuB,CAAA,sBAAsB,KAAK,EAAC,CAAA;AAC1E,IAAA,MAAM,iBAAiB,OAAQ,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,iBAAA,CAAkB,CAAC,CAAC,CAAA,CAAA;AAE5D,IAAO,OAAA,iBAAA;AAAA,MACL,eAAe,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,kBAAA,CAAmB,CAAC,CAAC,CAAA;AAAA,MACjD,CAAC,OAAgC,KAAA,OAAA,CAAQ,MAAO,CAAA,IAAA;AAAA,KAClD,CAAA;AAAA,GACF,CAAA;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,SAAA,CAAA;AAAA,GACT;AAAA,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,MAAO,CAAA,IAAA,CAAA;AAAA,GACrB;AAAA,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,OAAO,qBAAqB,OAAO,CAAA,CAAA;AAAA,GACrC;AAAA,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAO,OAAA,yBAAA,CAA0B,IAAK,CAAA,MAAA,EAAQ,GAAG,CAAA,CAAA;AAAA,GACnD;AACF;;;;"}
1
+ {"version":3,"file":"HarnessIntegration.esm.js","sources":["../../src/harness/HarnessIntegration.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { HarnessIntegrationConfig, readHarnessConfig } from './config';\nimport { getHarnessEditContentsUrl } from './core';\n\n/**\n * A Harness Code based integration.\n *\n * @public\n */\nexport class HarnessIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<HarnessIntegration> = ({ config }) => {\n const configs = config.getOptionalConfigArray('integrations.harness') ?? [];\n const harnessConfigs = configs.map(c => readHarnessConfig(c));\n\n return basicIntegrations(\n harnessConfigs.map(c => new HarnessIntegration(c)),\n (harness: HarnessIntegration) => harness.config.host,\n );\n };\n\n constructor(readonly config: HarnessIntegrationConfig) {}\n\n get type(): string {\n return 'harness';\n }\n\n get title(): string {\n return this.config.host;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return getHarnessEditContentsUrl(this.config, url);\n }\n}\n"],"names":[],"mappings":";;;;AAyBO,MAAM,kBAA6C,CAAA;AAAA,EAWxD,YAAqB,MAAkC,EAAA;AAAlC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AAAmC,EAVxD,OAAO,OAAA,GAAsD,CAAC,EAAE,QAAa,KAAA;AAC3E,IAAA,MAAM,OAAU,GAAA,MAAA,CAAO,sBAAuB,CAAA,sBAAsB,KAAK,EAAC;AAC1E,IAAA,MAAM,iBAAiB,OAAQ,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,iBAAA,CAAkB,CAAC,CAAC,CAAA;AAE5D,IAAO,OAAA,iBAAA;AAAA,MACL,eAAe,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,kBAAA,CAAmB,CAAC,CAAC,CAAA;AAAA,MACjD,CAAC,OAAgC,KAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,KAClD;AAAA,GACF;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,SAAA;AAAA;AACT,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,MAAO,CAAA,IAAA;AAAA;AACrB,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,OAAO,qBAAqB,OAAO,CAAA;AAAA;AACrC,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAO,OAAA,yBAAA,CAA0B,IAAK,CAAA,MAAA,EAAQ,GAAG,CAAA;AAAA;AAErD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs.js","sources":["../../src/harness/config.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { isValidHost } from '../helpers';\n\n/**\n * The configuration for a single Harness integration.\n *\n * @public\n */\nexport type HarnessIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"app.harness.io\"\n */\n host: string;\n /**\n * The password or http token to use for authentication.\n */\n token?: string;\n /**\n * The API key to use for authentication.\n */\n apiKey?: string;\n};\n\n/**\n * Parses a location config block for use in HarnessIntegration\n *\n * @public\n */\nexport function readHarnessConfig(config: Config): HarnessIntegrationConfig {\n const host = config.getString('host');\n const token = config.getOptionalString('token');\n const apiKey = config.getOptionalString('apiKey');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Harness Code integration config, '${host}' is not a valid host`,\n );\n }\n\n return {\n host,\n apiKey,\n token,\n };\n}\n"],"names":["isValidHost"],"mappings":";;;;AA4CO,SAAS,kBAAkB,MAA0C,EAAA;AAC1E,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA,CAAA;AACpC,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,iBAAA,CAAkB,OAAO,CAAA,CAAA;AAC9C,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,iBAAA,CAAkB,QAAQ,CAAA,CAAA;AAEhD,EAAI,IAAA,CAACA,mBAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,6CAA6C,IAAI,CAAA,qBAAA,CAAA;AAAA,KACnD,CAAA;AAAA,GACF;AAEA,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"config.cjs.js","sources":["../../src/harness/config.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { isValidHost } from '../helpers';\n\n/**\n * The configuration for a single Harness integration.\n *\n * @public\n */\nexport type HarnessIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"app.harness.io\"\n */\n host: string;\n /**\n * The password or http token to use for authentication.\n */\n token?: string;\n /**\n * The API key to use for authentication.\n */\n apiKey?: string;\n};\n\n/**\n * Parses a location config block for use in HarnessIntegration\n *\n * @public\n */\nexport function readHarnessConfig(config: Config): HarnessIntegrationConfig {\n const host = config.getString('host');\n const token = config.getOptionalString('token');\n const apiKey = config.getOptionalString('apiKey');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Harness Code integration config, '${host}' is not a valid host`,\n );\n }\n\n return {\n host,\n apiKey,\n token,\n };\n}\n"],"names":["isValidHost"],"mappings":";;;;AA4CO,SAAS,kBAAkB,MAA0C,EAAA;AAC1E,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA;AACpC,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAC9C,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,iBAAA,CAAkB,QAAQ,CAAA;AAEhD,EAAI,IAAA,CAACA,mBAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,6CAA6C,IAAI,CAAA,qBAAA;AAAA,KACnD;AAAA;AAGF,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/harness/config.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { isValidHost } from '../helpers';\n\n/**\n * The configuration for a single Harness integration.\n *\n * @public\n */\nexport type HarnessIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"app.harness.io\"\n */\n host: string;\n /**\n * The password or http token to use for authentication.\n */\n token?: string;\n /**\n * The API key to use for authentication.\n */\n apiKey?: string;\n};\n\n/**\n * Parses a location config block for use in HarnessIntegration\n *\n * @public\n */\nexport function readHarnessConfig(config: Config): HarnessIntegrationConfig {\n const host = config.getString('host');\n const token = config.getOptionalString('token');\n const apiKey = config.getOptionalString('apiKey');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Harness Code integration config, '${host}' is not a valid host`,\n );\n }\n\n return {\n host,\n apiKey,\n token,\n };\n}\n"],"names":[],"mappings":";;AA4CO,SAAS,kBAAkB,MAA0C,EAAA;AAC1E,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA,CAAA;AACpC,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,iBAAA,CAAkB,OAAO,CAAA,CAAA;AAC9C,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,iBAAA,CAAkB,QAAQ,CAAA,CAAA;AAEhD,EAAI,IAAA,CAAC,WAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,6CAA6C,IAAI,CAAA,qBAAA,CAAA;AAAA,KACnD,CAAA;AAAA,GACF;AAEA,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/harness/config.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { isValidHost } from '../helpers';\n\n/**\n * The configuration for a single Harness integration.\n *\n * @public\n */\nexport type HarnessIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"app.harness.io\"\n */\n host: string;\n /**\n * The password or http token to use for authentication.\n */\n token?: string;\n /**\n * The API key to use for authentication.\n */\n apiKey?: string;\n};\n\n/**\n * Parses a location config block for use in HarnessIntegration\n *\n * @public\n */\nexport function readHarnessConfig(config: Config): HarnessIntegrationConfig {\n const host = config.getString('host');\n const token = config.getOptionalString('token');\n const apiKey = config.getOptionalString('apiKey');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Harness Code integration config, '${host}' is not a valid host`,\n );\n }\n\n return {\n host,\n apiKey,\n token,\n };\n}\n"],"names":[],"mappings":";;AA4CO,SAAS,kBAAkB,MAA0C,EAAA;AAC1E,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA;AACpC,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAC9C,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,iBAAA,CAAkB,QAAQ,CAAA;AAEhD,EAAI,IAAA,CAAC,WAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,6CAA6C,IAAI,CAAA,qBAAA;AAAA,KACnD;AAAA;AAGF,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"core.cjs.js","sources":["../../src/harness/core.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { HarnessIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a file, returns a URL\n * for editing the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://app.harness.io/a/b/src/branchname/path/to/c.yaml\n * or: https://app.harness.io/a/b/_edit/branchname/path/to/c.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessEditContentsUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code${\n parsedUrl.orgName !== '' ? `/orgs/${parsedUrl.orgName}` : ''\n }${\n parsedUrl.projectName !== '' ? `/projects/${parsedUrl.projectName}` : ''\n }/repos/${parsedUrl.repoName}/files/${parsedUrl.branch}/~/${parsedUrl.path}`;\n}\n\n/**\n * Given a file path URL,\n * it returns an API URL which returns the contents of the file .\n * @remarks\n *\n * Converts\n * from: https://app.harness.io/ng/account/accountId/module/code/orgs/orgName/projects/projName/repos/repoName/files/refMain/~/all-apis.yaml\n * https://qa.harness.io/ng/account/bDCAuAjFSJCLFj_0ug3lCg/module/code/orgs/HiteshTest/repos/impoorter/files/main/~/catalog.yaml\n * to: https://app.harness.io/gateway/code/api/v1/repos/accountId/orgName/projName/repoName/+/content/all-apis.yaml?routingId=accountId&include_commit=false&ref=refMain\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessFileContentsUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n let constructedUrl = `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}`;\n\n if (parsedUrl.orgName) {\n constructedUrl += `/${parsedUrl.orgName}`;\n }\n\n if (parsedUrl.projectName) {\n constructedUrl += `/${parsedUrl.projectName}`;\n }\n\n constructedUrl += `/${parsedUrl.repoName}/+/raw/${parsedUrl.path}?routingId=${parsedUrl.accountId}&git_ref=refs/heads/${parsedUrl.refString}`;\n\n return constructedUrl;\n}\n\n/**\n * Given a URL pointing to a repository/path, returns a URL\n * for archive contents of the repository.\n *\n * @remarks\n *\n * Converts\n * from: https://qa.harness.io/ng/account/accountId/module/code/orgs/orgId/projects/projectName/repos/repoName/files/branch/~/fileName\n * to: https://qa.harness.io/gateway/code/api/v1/repos/accountId/orgId/projectName/repoName/+/archive/branch.zip?routingId=accountId\n *\n * @param url - A URL pointing to a repository/path\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessArchiveUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n let constructedUrl = `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}`;\n\n if (parsedUrl.orgName) {\n constructedUrl += `/${parsedUrl.orgName}`;\n }\n\n if (parsedUrl.projectName) {\n constructedUrl += `/${parsedUrl.projectName}`;\n }\n\n constructedUrl += `/${parsedUrl.repoName}/+/archive/${parsedUrl.branch}.zip?routingId=${parsedUrl.accountId}`;\n\n return constructedUrl;\n}\n\n/**\n * Given a URL pointing to a repository branch, returns a URL\n * for latest commit information.\n *\n * @remarks\n *\n * Converts\n * from: https://app.harness.io/ng/account/accountId/module/code/orgs/orgName/projects/projectName/repos/repoName/files/branchName\n * to: https://app.harness.io/gateway/code/api/v1/repos/accountId/orgName/projectName/repoName/+/content?routingId=accountId&include_commit=true&git_ref=refs/heads/branchName\n *\n * @param url - A URL pointing to a repository branch\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessLatestCommitUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n let constructedUrl = `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}`;\n\n if (parsedUrl.orgName) {\n constructedUrl += `/${parsedUrl.orgName}`;\n }\n\n if (parsedUrl.projectName) {\n constructedUrl += `/${parsedUrl.projectName}`;\n }\n\n constructedUrl += `/${parsedUrl.repoName}/+/content?routingId=${parsedUrl.accountId}&include_commit=true&git_ref=refs/heads/${parsedUrl.branch}`;\n\n return constructedUrl;\n}\n\n/**\n * Return request headers for a Harness Code provider.\n *\n * @param config - A Harness Code provider config\n * @public\n */\nexport function getHarnessRequestOptions(config: HarnessIntegrationConfig): {\n headers?: Record<string, string>;\n} {\n const headers: Record<string, string> = {};\n const { token, apiKey } = config;\n\n if (apiKey) {\n headers['x-api-key'] = apiKey;\n } else if (token) {\n headers.Authorization = `Bearer ${token}`;\n }\n\n return {\n headers,\n };\n}\n\n/**\n * Return parsed git url properties.\n *\n * @param config - A Harness provider config\n * @param url - A URL pointing to a repository\n * @public\n */\nexport function parseHarnessUrl(\n config: HarnessIntegrationConfig,\n url: string,\n): {\n baseUrl: string;\n accountId: string;\n orgName: string;\n projectName: string;\n refString: string;\n repoName: string;\n path: string;\n refDashStr: string;\n branch: string;\n} {\n const baseUrl = `https://${config.host}`;\n try {\n const pathUrl = new URL(url);\n const pathSegments = pathUrl.pathname\n .split('/')\n .filter(segment => segment !== '');\n const urlParts = pathUrl.pathname.split('/');\n\n const accountIdIndex =\n pathSegments.findIndex(segment => segment === 'account') + 1;\n const accountId = pathSegments[accountIdIndex];\n\n const orgNameIndex = pathSegments.findIndex(segment => segment === 'orgs');\n const orgName = orgNameIndex !== -1 ? pathSegments[orgNameIndex + 1] : '';\n const projectNameIndex = pathSegments.findIndex(\n segment => segment === 'projects',\n );\n\n const projectName =\n projectNameIndex !== -1 ? pathSegments[projectNameIndex + 1] : '';\n // Adjust repoNameIndex to correctly identify the repository name\n const repoNameIndex =\n pathSegments.findIndex(\n (segment, index) =>\n segment === 'repos' &&\n index > Math.max(accountIdIndex, orgNameIndex, projectNameIndex),\n ) + 1;\n const repoName = pathSegments[repoNameIndex];\n const refAndPath = urlParts.slice(\n urlParts.findIndex(i => i === 'files' || i === 'edit') + 1,\n );\n const refIndex = refAndPath.findIndex(item => item === '~');\n\n const refString = refAndPath.slice(0, refIndex).join('/');\n const pathWithoutSlash =\n refIndex !== -1\n ? refAndPath\n .slice(refIndex + 1)\n .join('/')\n .replace(/^\\//, '')\n : '';\n\n return {\n baseUrl: baseUrl,\n accountId: accountId,\n orgName: orgName,\n projectName: projectName,\n refString: refString,\n path: pathWithoutSlash,\n repoName: repoName,\n refDashStr: refAndPath.slice(0, refIndex).join('-'),\n branch:\n refIndex !== -1\n ? refAndPath.slice(0, refIndex).join('/')\n : refAndPath.join('/'),\n };\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n"],"names":[],"mappings":";;AA+BgB,SAAA,yBAAA,CACd,QACA,GACA,EAAA;AACA,EAAM,MAAA,SAAA,GAAY,eAAgB,CAAA,MAAA,EAAQ,GAAG,CAAA,CAAA;AAE7C,EAAA,OAAO,CAAG,EAAA,SAAA,CAAU,OAAO,CAAA,YAAA,EAAe,UAAU,SAAS,CAAA,YAAA,EAC3D,SAAU,CAAA,OAAA,KAAY,EAAK,GAAA,CAAA,MAAA,EAAS,SAAU,CAAA,OAAO,KAAK,EAC5D,CAAA,EACE,SAAU,CAAA,WAAA,KAAgB,EAAK,GAAA,CAAA,UAAA,EAAa,SAAU,CAAA,WAAW,KAAK,EACxE,CAAA,OAAA,EAAU,SAAU,CAAA,QAAQ,CAAU,OAAA,EAAA,SAAA,CAAU,MAAM,CAAA,GAAA,EAAM,UAAU,IAAI,CAAA,CAAA,CAAA;AAC5E,CAAA;AAgBgB,SAAA,yBAAA,CACd,QACA,GACA,EAAA;AACA,EAAM,MAAA,SAAA,GAAY,eAAgB,CAAA,MAAA,EAAQ,GAAG,CAAA,CAAA;AAE7C,EAAA,IAAI,iBAAiB,CAAG,EAAA,SAAA,CAAU,OAAO,CAAA,2BAAA,EAA8B,UAAU,SAAS,CAAA,CAAA,CAAA;AAE1F,EAAA,IAAI,UAAU,OAAS,EAAA;AACrB,IAAkB,cAAA,IAAA,CAAA,CAAA,EAAI,UAAU,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KAAK,GAAG,CAAA,CAAA;AACxD,IAAA,MAAM,gBACJ,GAAA,QAAA,KAAa,CACT,CAAA,GAAA,UAAA,CACG,MAAM,QAAW,GAAA,CAAC,CAClB,CAAA,IAAA,CAAK,GAAG,CAAA,CACR,OAAQ,CAAA,KAAA,EAAO,EAAE,CACpB,GAAA,EAAA,CAAA;AAEN,IAAO,OAAA;AAAA,MACL,OAAA;AAAA,MACA,SAAA;AAAA,MACA,OAAA;AAAA,MACA,WAAA;AAAA,MACA,SAAA;AAAA,MACA,IAAM,EAAA,gBAAA;AAAA,MACN,QAAA;AAAA,MACA,YAAY,UAAW,CAAA,KAAA,CAAM,GAAG,QAAQ,CAAA,CAAE,KAAK,GAAG,CAAA;AAAA,MAClD,MACE,EAAA,QAAA,KAAa,CACT,CAAA,GAAA,UAAA,CAAW,KAAM,CAAA,CAAA,EAAG,QAAQ,CAAA,CAAE,IAAK,CAAA,GAAG,CACtC,GAAA,UAAA,CAAW,KAAK,GAAG,CAAA;AAAA,KAC3B,CAAA;AAAA,WACO,CAAG,EAAA;AACV,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,eAAA,EAAkB,GAAG,CAAA,EAAA,EAAK,CAAC,CAAE,CAAA,CAAA,CAAA;AAAA,GAC/C;AACF;;;;;;;;;"}
1
+ {"version":3,"file":"core.cjs.js","sources":["../../src/harness/core.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { HarnessIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a file, returns a URL\n * for editing the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://app.harness.io/a/b/src/branchname/path/to/c.yaml\n * or: https://app.harness.io/a/b/_edit/branchname/path/to/c.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessEditContentsUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code${\n parsedUrl.orgName !== '' ? `/orgs/${parsedUrl.orgName}` : ''\n }${\n parsedUrl.projectName !== '' ? `/projects/${parsedUrl.projectName}` : ''\n }/repos/${parsedUrl.repoName}/files/${parsedUrl.branch}/~/${parsedUrl.path}`;\n}\n\n/**\n * Given a file path URL,\n * it returns an API URL which returns the contents of the file .\n * @remarks\n *\n * Converts\n * from: https://app.harness.io/ng/account/accountId/module/code/orgs/orgName/projects/projName/repos/repoName/files/refMain/~/all-apis.yaml\n * https://qa.harness.io/ng/account/bDCAuAjFSJCLFj_0ug3lCg/module/code/orgs/HiteshTest/repos/impoorter/files/main/~/catalog.yaml\n * to: https://app.harness.io/gateway/code/api/v1/repos/accountId/orgName/projName/repoName/+/content/all-apis.yaml?routingId=accountId&include_commit=false&ref=refMain\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessFileContentsUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n let constructedUrl = `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}`;\n\n if (parsedUrl.orgName) {\n constructedUrl += `/${parsedUrl.orgName}`;\n }\n\n if (parsedUrl.projectName) {\n constructedUrl += `/${parsedUrl.projectName}`;\n }\n\n constructedUrl += `/${parsedUrl.repoName}/+/raw/${parsedUrl.path}?routingId=${parsedUrl.accountId}&git_ref=refs/heads/${parsedUrl.refString}`;\n\n return constructedUrl;\n}\n\n/**\n * Given a URL pointing to a repository/path, returns a URL\n * for archive contents of the repository.\n *\n * @remarks\n *\n * Converts\n * from: https://qa.harness.io/ng/account/accountId/module/code/orgs/orgId/projects/projectName/repos/repoName/files/branch/~/fileName\n * to: https://qa.harness.io/gateway/code/api/v1/repos/accountId/orgId/projectName/repoName/+/archive/branch.zip?routingId=accountId\n *\n * @param url - A URL pointing to a repository/path\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessArchiveUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n let constructedUrl = `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}`;\n\n if (parsedUrl.orgName) {\n constructedUrl += `/${parsedUrl.orgName}`;\n }\n\n if (parsedUrl.projectName) {\n constructedUrl += `/${parsedUrl.projectName}`;\n }\n\n constructedUrl += `/${parsedUrl.repoName}/+/archive/${parsedUrl.branch}.zip?routingId=${parsedUrl.accountId}`;\n\n return constructedUrl;\n}\n\n/**\n * Given a URL pointing to a repository branch, returns a URL\n * for latest commit information.\n *\n * @remarks\n *\n * Converts\n * from: https://app.harness.io/ng/account/accountId/module/code/orgs/orgName/projects/projectName/repos/repoName/files/branchName\n * to: https://app.harness.io/gateway/code/api/v1/repos/accountId/orgName/projectName/repoName/+/content?routingId=accountId&include_commit=true&git_ref=refs/heads/branchName\n *\n * @param url - A URL pointing to a repository branch\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessLatestCommitUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n let constructedUrl = `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}`;\n\n if (parsedUrl.orgName) {\n constructedUrl += `/${parsedUrl.orgName}`;\n }\n\n if (parsedUrl.projectName) {\n constructedUrl += `/${parsedUrl.projectName}`;\n }\n\n constructedUrl += `/${parsedUrl.repoName}/+/content?routingId=${parsedUrl.accountId}&include_commit=true&git_ref=refs/heads/${parsedUrl.branch}`;\n\n return constructedUrl;\n}\n\n/**\n * Return request headers for a Harness Code provider.\n *\n * @param config - A Harness Code provider config\n * @public\n */\nexport function getHarnessRequestOptions(config: HarnessIntegrationConfig): {\n headers?: Record<string, string>;\n} {\n const headers: Record<string, string> = {};\n const { token, apiKey } = config;\n\n if (apiKey) {\n headers['x-api-key'] = apiKey;\n } else if (token) {\n headers.Authorization = `Bearer ${token}`;\n }\n\n return {\n headers,\n };\n}\n\n/**\n * Return parsed git url properties.\n *\n * @param config - A Harness provider config\n * @param url - A URL pointing to a repository\n * @public\n */\nexport function parseHarnessUrl(\n config: HarnessIntegrationConfig,\n url: string,\n): {\n baseUrl: string;\n accountId: string;\n orgName: string;\n projectName: string;\n refString: string;\n repoName: string;\n path: string;\n refDashStr: string;\n branch: string;\n} {\n const baseUrl = `https://${config.host}`;\n try {\n const pathUrl = new URL(url);\n const pathSegments = pathUrl.pathname\n .split('/')\n .filter(segment => segment !== '');\n const urlParts = pathUrl.pathname.split('/');\n\n const accountIdIndex =\n pathSegments.findIndex(segment => segment === 'account') + 1;\n const accountId = pathSegments[accountIdIndex];\n\n const orgNameIndex = pathSegments.findIndex(segment => segment === 'orgs');\n const orgName = orgNameIndex !== -1 ? pathSegments[orgNameIndex + 1] : '';\n const projectNameIndex = pathSegments.findIndex(\n segment => segment === 'projects',\n );\n\n const projectName =\n projectNameIndex !== -1 ? pathSegments[projectNameIndex + 1] : '';\n // Adjust repoNameIndex to correctly identify the repository name\n const repoNameIndex =\n pathSegments.findIndex(\n (segment, index) =>\n segment === 'repos' &&\n index > Math.max(accountIdIndex, orgNameIndex, projectNameIndex),\n ) + 1;\n const repoName = pathSegments[repoNameIndex];\n const refAndPath = urlParts.slice(\n urlParts.findIndex(i => i === 'files' || i === 'edit') + 1,\n );\n const refIndex = refAndPath.findIndex(item => item === '~');\n\n const refString = refAndPath.slice(0, refIndex).join('/');\n const pathWithoutSlash =\n refIndex !== -1\n ? refAndPath\n .slice(refIndex + 1)\n .join('/')\n .replace(/^\\//, '')\n : '';\n\n return {\n baseUrl: baseUrl,\n accountId: accountId,\n orgName: orgName,\n projectName: projectName,\n refString: refString,\n path: pathWithoutSlash,\n repoName: repoName,\n refDashStr: refAndPath.slice(0, refIndex).join('-'),\n branch:\n refIndex !== -1\n ? refAndPath.slice(0, refIndex).join('/')\n : refAndPath.join('/'),\n };\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n"],"names":[],"mappings":";;AA+BgB,SAAA,yBAAA,CACd,QACA,GACA,EAAA;AACA,EAAM,MAAA,SAAA,GAAY,eAAgB,CAAA,MAAA,EAAQ,GAAG,CAAA;AAE7C,EAAA,OAAO,CAAG,EAAA,SAAA,CAAU,OAAO,CAAA,YAAA,EAAe,UAAU,SAAS,CAAA,YAAA,EAC3D,SAAU,CAAA,OAAA,KAAY,EAAK,GAAA,CAAA,MAAA,EAAS,SAAU,CAAA,OAAO,KAAK,EAC5D,CAAA,EACE,SAAU,CAAA,WAAA,KAAgB,EAAK,GAAA,CAAA,UAAA,EAAa,SAAU,CAAA,WAAW,KAAK,EACxE,CAAA,OAAA,EAAU,SAAU,CAAA,QAAQ,CAAU,OAAA,EAAA,SAAA,CAAU,MAAM,CAAA,GAAA,EAAM,UAAU,IAAI,CAAA,CAAA;AAC5E;AAgBgB,SAAA,yBAAA,CACd,QACA,GACA,EAAA;AACA,EAAM,MAAA,SAAA,GAAY,eAAgB,CAAA,MAAA,EAAQ,GAAG,CAAA;AAE7C,EAAA,IAAI,iBAAiB,CAAG,EAAA,SAAA,CAAU,OAAO,CAAA,2BAAA,EAA8B,UAAU,SAAS,CAAA,CAAA;AAE1F,EAAA,IAAI,UAAU,OAAS,EAAA;AACrB,IAAkB,cAAA,IAAA,CAAA,CAAA,EAAI,UAAU,OAAO,CAAA,CAAA;AAAA;AAGzC,EAAA,IAAI,UAAU,WAAa,EAAA;AACzB,IAAkB,cAAA,IAAA,CAAA,CAAA,EAAI,UAAU,WAAW,CAAA,CAAA;AAAA;AAG7C,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