@backstage/integration 1.12.0-next.1 → 1.13.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @backstage/integration
2
2
 
3
+ ## 1.13.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b5deed0: Add support for `token` for `bitbucketCloud` integration
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @backstage/config@1.2.0
13
+ - @backstage/errors@1.2.4
14
+
15
+ ## 1.12.0
16
+
17
+ ### Minor Changes
18
+
19
+ - be1014d: **BREAKING** Removed deprecated code from when casing was changed from `GitHub` to `Github` nearly two years ago. The following items have been removed:
20
+
21
+ - `getGitHubFileFetchUrl` (use `getGithubFileFetchUrl` instead)
22
+ - `GitHubIntegrationConfig` (use `GithubIntegrationConfig` instead)
23
+ - `GitHubIntegration` (use `GithubIntegration` instead)
24
+ - `readGitHubIntegrationConfig` (use `readGithubIntegrationConfig` instead)
25
+ - `readGitHubIntegrationConfigs` (use `readGithubIntegrationConfigs` instead)
26
+ - `replaceGitHubUrlType` (use `replaceGithubUrlType` instead)
27
+
28
+ - 395b973: Implemented `readTree` for Harness provider to support TechDocs functionality
29
+ - 662dce8: **BREAKING**: `gitilesBaseUrl` is now mandatory for the Gerrit integration. The
30
+ ability to override this requirement using the `DISABLE_GERRIT_GITILES_REQUIREMENT`
31
+ environment variable has been removed.
32
+
33
+ ### Patch Changes
34
+
35
+ - 509e08c: Updated function for getHarnessEditContentsUrl
36
+ - 23ee9ab: Fix AWS CodeCommit integration by allowing to change the host
37
+ - Updated dependencies
38
+ - @backstage/config@1.2.0
39
+ - @backstage/errors@1.2.4
40
+
3
41
  ## 1.12.0-next.1
4
42
 
5
43
  ### Minor Changes
package/config.d.ts CHANGED
@@ -151,6 +151,11 @@ export interface Config {
151
151
  * @visibility frontend
152
152
  */
153
153
  baseUrl?: string;
154
+ /**
155
+ * The gitiles base url.
156
+ * @visibility frontend
157
+ */
158
+ gitilesBaseUrl: string;
154
159
  /**
155
160
  * The base url for cloning repos.
156
161
  * @visibility frontend
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/bitbucketCloud/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\nconst BITBUCKET_CLOUD_HOST = 'bitbucket.org';\nconst BITBUCKET_CLOUD_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket Cloud API provider.\n *\n * @public\n */\nexport type BitbucketCloudIntegrationConfig = {\n /**\n * Constant. bitbucket.org\n */\n host: string;\n\n /**\n * Constant. https://api.bitbucket.org/2.0\n */\n apiBaseUrl: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n};\n\n/**\n * Reads a single Bitbucket Cloud integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketCloudIntegrationConfig(\n config: Config,\n): BitbucketCloudIntegrationConfig {\n const host = BITBUCKET_CLOUD_HOST;\n const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;\n // If config is provided, we assume authenticated access is desired\n // (as the anonymous one is provided by default).\n const username = config.getString('username');\n const appPassword = config.getString('appPassword')?.trim();\n\n return {\n host,\n apiBaseUrl,\n username,\n appPassword,\n };\n}\n\n/**\n * Reads a set of Bitbucket Cloud integration configs,\n * and inserts one for public Bitbucket Cloud if none specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketCloudIntegrationConfigs(\n configs: Config[],\n): BitbucketCloudIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketCloudIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added,\n // put one in the list as a convenience\n if (result.length === 0) {\n result.push({\n host: BITBUCKET_CLOUD_HOST,\n apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,oBAAuB,GAAA,eAAA,CAAA;AAC7B,MAAM,4BAA+B,GAAA,+BAAA,CAAA;AAqC9B,SAAS,oCACd,MACiC,EAAA;AACjC,EAAA,MAAM,IAAO,GAAA,oBAAA,CAAA;AACb,EAAA,MAAM,UAAa,GAAA,4BAAA,CAAA;AAGnB,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA,CAAA;AAC5C,EAAA,MAAM,WAAc,GAAA,MAAA,CAAO,SAAU,CAAA,aAAa,GAAG,IAAK,EAAA,CAAA;AAE1D,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,GACF,CAAA;AACF,CAAA;AASO,SAAS,qCACd,OACmC,EAAA;AAEnC,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,mCAAmC,CAAA,CAAA;AAI9D,EAAI,IAAA,MAAA,CAAO,WAAW,CAAG,EAAA;AACvB,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,oBAAA;AAAA,MACN,UAAY,EAAA,4BAAA;AAAA,KACb,CAAA,CAAA;AAAA,GACH;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/bitbucketCloud/config.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\nconst BITBUCKET_CLOUD_HOST = 'bitbucket.org';\nconst BITBUCKET_CLOUD_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket Cloud API provider.\n *\n * @public\n */\nexport type BitbucketCloudIntegrationConfig = {\n /**\n * Constant. bitbucket.org\n */\n host: string;\n\n /**\n * Constant. https://api.bitbucket.org/2.0\n */\n apiBaseUrl: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * The access token to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n token?: string;\n};\n\n/**\n * Reads a single Bitbucket Cloud integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketCloudIntegrationConfig(\n config: Config,\n): BitbucketCloudIntegrationConfig {\n const host = BITBUCKET_CLOUD_HOST;\n const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;\n // If config is provided, we assume authenticated access is desired\n // (as the anonymous one is provided by default).\n const username = config.getString('username');\n const appPassword = config.getString('appPassword')?.trim();\n\n return {\n host,\n apiBaseUrl,\n username,\n appPassword,\n };\n}\n\n/**\n * Reads a set of Bitbucket Cloud integration configs,\n * and inserts one for public Bitbucket Cloud if none specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketCloudIntegrationConfigs(\n configs: Config[],\n): BitbucketCloudIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketCloudIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added,\n // put one in the list as a convenience\n if (result.length === 0) {\n result.push({\n host: BITBUCKET_CLOUD_HOST,\n apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,oBAAuB,GAAA,eAAA,CAAA;AAC7B,MAAM,4BAA+B,GAAA,+BAAA,CAAA;AA0C9B,SAAS,oCACd,MACiC,EAAA;AACjC,EAAA,MAAM,IAAO,GAAA,oBAAA,CAAA;AACb,EAAA,MAAM,UAAa,GAAA,4BAAA,CAAA;AAGnB,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA,CAAA;AAC5C,EAAA,MAAM,WAAc,GAAA,MAAA,CAAO,SAAU,CAAA,aAAa,GAAG,IAAK,EAAA,CAAA;AAE1D,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,GACF,CAAA;AACF,CAAA;AASO,SAAS,qCACd,OACmC,EAAA;AAEnC,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,mCAAmC,CAAA,CAAA;AAI9D,EAAI,IAAA,MAAA,CAAO,WAAW,CAAG,EAAA;AACvB,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,oBAAA;AAAA,MACN,UAAY,EAAA,4BAAA;AAAA,KACb,CAAA,CAAA;AAAA,GACH;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
@@ -5,7 +5,7 @@ function readGerritIntegrationConfig(config) {
5
5
  const host = config.getString("host");
6
6
  let baseUrl = config.getOptionalString("baseUrl");
7
7
  let cloneUrl = config.getOptionalString("cloneUrl");
8
- let gitilesBaseUrl = config.getOptionalString("gitilesBaseUrl");
8
+ let gitilesBaseUrl = config.getString("gitilesBaseUrl");
9
9
  const username = config.getOptionalString("username");
10
10
  const password = config.getOptionalString("password")?.trim();
11
11
  if (!isValidHost(host)) {
@@ -20,7 +20,7 @@ function readGerritIntegrationConfig(config) {
20
20
  throw new Error(
21
21
  `Invalid Gerrit integration config, '${cloneUrl}' is not a valid cloneUrl`
22
22
  );
23
- } else if (gitilesBaseUrl && !isValidUrl(gitilesBaseUrl)) {
23
+ } else if (!isValidUrl(gitilesBaseUrl)) {
24
24
  throw new Error(
25
25
  `Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`
26
26
  );
@@ -1 +1 @@
1
- {"version":3,"file":"config.esm.js","sources":["../../src/gerrit/config.ts"],"sourcesContent":["/*\n * Copyright 2022 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\n/**\n * The configuration parameters for a single Gerrit API provider.\n *\n * @public\n */\nexport type GerritIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"gerrit-review.com\"\n */\n host: string;\n\n /**\n * The optional base URL of the Gerrit instance. It is assumed that https\n * is used and that the base path is \"/\" on the host. If that is not the\n * case set the complete base url to the gerrit instance, e.g.\n * \"https://gerrit-review.com/gerrit\". This is the url that you would open\n * in a browser.\n */\n baseUrl?: string;\n\n /**\n * The optional base url to use for cloning a repository. If not set the\n * baseUrl will be used.\n */\n cloneUrl?: string;\n\n /**\n * Optional base url for Gitiles. This is needed for creating a valid\n * user-friendly url that can be used for browsing the content of the\n * provider. If not set a default value will be created in the same way\n * as the \"baseUrl\" option.\n */\n gitilesBaseUrl?: string;\n\n /**\n * The username to use for requests to gerrit.\n */\n username?: string;\n\n /**\n * The password or http token to use for authentication.\n */\n password?: string;\n};\n\n/**\n * Reads a single Gerrit integration config.\n *\n * @param config - The config object of a single integration\n *\n * @public\n */\nexport function readGerritIntegrationConfig(\n config: Config,\n): GerritIntegrationConfig {\n const host = config.getString('host');\n let baseUrl = config.getOptionalString('baseUrl');\n let cloneUrl = config.getOptionalString('cloneUrl');\n let gitilesBaseUrl = config.getOptionalString('gitilesBaseUrl');\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Gerrit integration config, '${host}' is not a valid host`,\n );\n } else if (baseUrl && !isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n } else if (cloneUrl && !isValidUrl(cloneUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${cloneUrl}' is not a valid cloneUrl`,\n );\n } else if (gitilesBaseUrl && !isValidUrl(gitilesBaseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`,\n );\n }\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n if (gitilesBaseUrl) {\n gitilesBaseUrl = trimEnd(gitilesBaseUrl, '/');\n } else {\n gitilesBaseUrl = `https://${host}`;\n }\n if (cloneUrl) {\n cloneUrl = trimEnd(cloneUrl, '/');\n } else {\n cloneUrl = baseUrl;\n }\n\n return {\n host,\n baseUrl,\n cloneUrl,\n gitilesBaseUrl,\n username,\n password,\n };\n}\n\n/**\n * Reads a set of Gerrit integration configs.\n *\n * @param configs - All of the integration config objects\n *\n * @public\n */\nexport function readGerritIntegrationConfigs(\n config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EAAA,IAAI,OAAS,EAAA;AACX,IAAU,OAAA,GAAA,OAAA,CAAQ,SAAS,GAAG,CAAA,CAAA;AAAA,GACzB,MAAA;AACL,IAAA,OAAA,GAAU,WAAW,IAAI,CAAA,CAAA,CAAA;AAAA,GAC3B;AACA,EAAA,IAAI,cAAgB,EAAA;AAClB,IAAiB,cAAA,GAAA,OAAA,CAAQ,gBAAgB,GAAG,CAAA,CAAA;AAAA,GACvC,MAAA;AACL,IAAA,cAAA,GAAiB,WAAW,IAAI,CAAA,CAAA,CAAA;AAAA,GAClC;AACA,EAAA,IAAI,QAAU,EAAA;AACZ,IAAW,QAAA,GAAA,OAAA,CAAQ,UAAU,GAAG,CAAA,CAAA;AAAA,GAC3B,MAAA;AACL,IAAW,QAAA,GAAA,OAAA,CAAA;AAAA,GACb;AAEA,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AACF,CAAA;AASO,SAAS,6BACd,OAC2B,EAAA;AAC3B,EAAO,OAAA,OAAA,CAAQ,IAAI,2BAA2B,CAAA,CAAA;AAChD;;;;"}
1
+ {"version":3,"file":"config.esm.js","sources":["../../src/gerrit/config.ts"],"sourcesContent":["/*\n * Copyright 2022 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\n/**\n * The configuration parameters for a single Gerrit API provider.\n *\n * @public\n */\nexport type GerritIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"gerrit-review.com\"\n */\n host: string;\n\n /**\n * The optional base URL of the Gerrit instance. It is assumed that https\n * is used and that the base path is \"/\" on the host. If that is not the\n * case set the complete base url to the gerrit instance, e.g.\n * \"https://gerrit-review.com/gerrit\". This is the url that you would open\n * in a browser.\n */\n baseUrl?: string;\n\n /**\n * The optional base url to use for cloning a repository. If not set the\n * baseUrl will be used.\n */\n cloneUrl?: string;\n\n /**\n * Base url for Gitiles. This is needed for creating a valid\n * user-friendly url that can be used for browsing the content of the\n * provider.\n */\n gitilesBaseUrl: string;\n\n /**\n * The username to use for requests to gerrit.\n */\n username?: string;\n\n /**\n * The password or http token to use for authentication.\n */\n password?: string;\n};\n\n/**\n * Reads a single Gerrit integration config.\n *\n * @param config - The config object of a single integration\n *\n * @public\n */\nexport function readGerritIntegrationConfig(\n config: Config,\n): GerritIntegrationConfig {\n const host = config.getString('host');\n let baseUrl = config.getOptionalString('baseUrl');\n let cloneUrl = config.getOptionalString('cloneUrl');\n let gitilesBaseUrl = config.getString('gitilesBaseUrl');\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Gerrit integration config, '${host}' is not a valid host`,\n );\n } else if (baseUrl && !isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n } else if (cloneUrl && !isValidUrl(cloneUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${cloneUrl}' is not a valid cloneUrl`,\n );\n } else if (!isValidUrl(gitilesBaseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`,\n );\n }\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n if (gitilesBaseUrl) {\n gitilesBaseUrl = trimEnd(gitilesBaseUrl, '/');\n } else {\n gitilesBaseUrl = `https://${host}`;\n }\n if (cloneUrl) {\n cloneUrl = trimEnd(cloneUrl, '/');\n } else {\n cloneUrl = baseUrl;\n }\n\n return {\n host,\n baseUrl,\n cloneUrl,\n gitilesBaseUrl,\n username,\n password,\n };\n}\n\n/**\n * Reads a set of Gerrit integration configs.\n *\n * @param configs - All of the integration config objects\n *\n * @public\n */\nexport function readGerritIntegrationConfigs(\n configs: Config[],\n): GerritIntegrationConfig[] {\n return configs.map(readGerritIntegrationConfig);\n}\n"],"names":[],"mappings":";;;AAuEO,SAAS,4BACd,MACyB,EAAA;AACzB,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA,CAAA;AACpC,EAAI,IAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA,CAAA;AAChD,EAAI,IAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AAClD,EAAI,IAAA,cAAA,GAAiB,MAAO,CAAA,SAAA,CAAU,gBAAgB,CAAA,CAAA;AACtD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AACpD,EAAA,MAAM,QAAW,GAAA,MAAA,CAAO,iBAAkB,CAAA,UAAU,GAAG,IAAK,EAAA,CAAA;AAE5D,EAAI,IAAA,CAAC,WAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,IAAI,CAAA,qBAAA,CAAA;AAAA,KAC7C,CAAA;AAAA,GACS,MAAA,IAAA,OAAA,IAAW,CAAC,UAAA,CAAW,OAAO,CAAG,EAAA;AAC1C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,OAAO,CAAA,wBAAA,CAAA;AAAA,KAChD,CAAA;AAAA,GACS,MAAA,IAAA,QAAA,IAAY,CAAC,UAAA,CAAW,QAAQ,CAAG,EAAA;AAC5C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,QAAQ,CAAA,yBAAA,CAAA;AAAA,KACjD,CAAA;AAAA,GACS,MAAA,IAAA,CAAC,UAAW,CAAA,cAAc,CAAG,EAAA;AACtC,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,cAAc,CAAA,+BAAA,CAAA;AAAA,KACvD,CAAA;AAAA,GACF;AACA,EAAA,IAAI,OAAS,EAAA;AACX,IAAU,OAAA,GAAA,OAAA,CAAQ,SAAS,GAAG,CAAA,CAAA;AAAA,GACzB,MAAA;AACL,IAAA,OAAA,GAAU,WAAW,IAAI,CAAA,CAAA,CAAA;AAAA,GAC3B;AACA,EAAA,IAAI,cAAgB,EAAA;AAClB,IAAiB,cAAA,GAAA,OAAA,CAAQ,gBAAgB,GAAG,CAAA,CAAA;AAAA,GACvC,MAAA;AACL,IAAA,cAAA,GAAiB,WAAW,IAAI,CAAA,CAAA,CAAA;AAAA,GAClC;AACA,EAAA,IAAI,QAAU,EAAA;AACZ,IAAW,QAAA,GAAA,OAAA,CAAQ,UAAU,GAAG,CAAA,CAAA;AAAA,GAC3B,MAAA;AACL,IAAW,QAAA,GAAA,OAAA,CAAA;AAAA,GACb;AAEA,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AACF,CAAA;AASO,SAAS,6BACd,OAC2B,EAAA;AAC3B,EAAO,OAAA,OAAA,CAAQ,IAAI,2BAA2B,CAAA,CAAA;AAChD;;;;"}
@@ -1,6 +1,6 @@
1
1
  function getHarnessEditContentsUrl(config, url) {
2
2
  const parsedUrl = parseHarnessUrl(config, url);
3
- return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code/orgs/${parsedUrl.orgName}/projects/${parsedUrl.projectName}/${parsedUrl.repoName}/files/${parsedUrl.branch}/~/${parsedUrl.path}`;
3
+ return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code/orgs/${parsedUrl.orgName}/projects/${parsedUrl.projectName}/repos/${parsedUrl.repoName}/files/${parsedUrl.branch}/~/${parsedUrl.path}`;
4
4
  }
5
5
  function getHarnessFileContentsUrl(config, url) {
6
6
  const parsedUrl = parseHarnessUrl(config, url);
@@ -1 +1 @@
1
- {"version":3,"file":"core.esm.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 return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code/orgs/${parsedUrl.orgName}/projects/${parsedUrl.projectName}/${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 * 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 return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/raw/${parsedUrl.path}?routingId=${parsedUrl.accountId}&git_ref=refs/heads/${parsedUrl.refString}`;\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 return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/archive/${parsedUrl.branch}.zip?routingId=${parsedUrl.accountId}`;\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 return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/content?routingId=${parsedUrl.accountId}&include_commit=true&git_ref=refs/heads/${parsedUrl.branch}`;\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 const [\n _ng,\n _account,\n accountId,\n _module,\n _moduleName,\n _org,\n orgName,\n _projects,\n projectName,\n _repos,\n repoName,\n _files,\n _ref,\n _branch,\n ..._path\n ] = pathSegments;\n const refAndPath = urlParts.slice(\n urlParts.findIndex(i => i === 'files' || i === 'edit') + 1,\n );\n const refIndex = refAndPath.findIndex(item => item === '~');\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 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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K,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.esm.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 return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code/orgs/${parsedUrl.orgName}/projects/${parsedUrl.projectName}/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 * 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 return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/raw/${parsedUrl.path}?routingId=${parsedUrl.accountId}&git_ref=refs/heads/${parsedUrl.refString}`;\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 return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/archive/${parsedUrl.branch}.zip?routingId=${parsedUrl.accountId}`;\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 return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/content?routingId=${parsedUrl.accountId}&include_commit=true&git_ref=refs/heads/${parsedUrl.branch}`;\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 const [\n _ng,\n _account,\n accountId,\n _module,\n _moduleName,\n _org,\n orgName,\n _projects,\n projectName,\n _repos,\n repoName,\n _files,\n _ref,\n _branch,\n ..._path\n ] = pathSegments;\n const refAndPath = urlParts.slice(\n urlParts.findIndex(i => i === 'files' || i === 'edit') + 1,\n );\n const refIndex = refAndPath.findIndex(item => item === '~');\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 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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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;;;;"}
package/dist/index.cjs.js CHANGED
@@ -1206,7 +1206,7 @@ function readGerritIntegrationConfig(config) {
1206
1206
  const host = config.getString("host");
1207
1207
  let baseUrl = config.getOptionalString("baseUrl");
1208
1208
  let cloneUrl = config.getOptionalString("cloneUrl");
1209
- let gitilesBaseUrl = config.getOptionalString("gitilesBaseUrl");
1209
+ let gitilesBaseUrl = config.getString("gitilesBaseUrl");
1210
1210
  const username = config.getOptionalString("username");
1211
1211
  const password = config.getOptionalString("password")?.trim();
1212
1212
  if (!isValidHost(host)) {
@@ -1221,7 +1221,7 @@ function readGerritIntegrationConfig(config) {
1221
1221
  throw new Error(
1222
1222
  `Invalid Gerrit integration config, '${cloneUrl}' is not a valid cloneUrl`
1223
1223
  );
1224
- } else if (gitilesBaseUrl && !isValidUrl(gitilesBaseUrl)) {
1224
+ } else if (!isValidUrl(gitilesBaseUrl)) {
1225
1225
  throw new Error(
1226
1226
  `Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`
1227
1227
  );
@@ -2094,7 +2094,7 @@ function readHarnessConfig(config) {
2094
2094
 
2095
2095
  function getHarnessEditContentsUrl(config, url) {
2096
2096
  const parsedUrl = parseHarnessUrl(config, url);
2097
- return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code/orgs/${parsedUrl.orgName}/projects/${parsedUrl.projectName}/${parsedUrl.repoName}/files/${parsedUrl.branch}/~/${parsedUrl.path}`;
2097
+ return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code/orgs/${parsedUrl.orgName}/projects/${parsedUrl.projectName}/repos/${parsedUrl.repoName}/files/${parsedUrl.branch}/~/${parsedUrl.path}`;
2098
2098
  }
2099
2099
  function getHarnessFileContentsUrl(config, url) {
2100
2100
  const parsedUrl = parseHarnessUrl(config, url);