@backstage/plugin-catalog-backend-module-bitbucket-server 0.3.1-next.0 → 0.3.1
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,30 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-bitbucket-server
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8c04d7a: Updated the `getFile` method in `BitbucketServerClient` to use `this.config.apiBaseUrl` directly for constructing the API request URL, removing the creation of an unnecessary `URL` object. The method now relies on REST API paths for accessing resources instead of direct access, ensuring better alignment with Bitbucket's API conventions.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/integration@1.16.1
|
|
10
|
+
- @backstage/backend-plugin-api@1.1.1
|
|
11
|
+
- @backstage/catalog-model@1.7.3
|
|
12
|
+
- @backstage/config@1.3.2
|
|
13
|
+
- @backstage/errors@1.2.7
|
|
14
|
+
- @backstage/plugin-catalog-node@1.15.1
|
|
15
|
+
|
|
16
|
+
## 0.3.1-next.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @backstage/backend-plugin-api@1.1.1-next.1
|
|
22
|
+
- @backstage/catalog-model@1.7.3-next.0
|
|
23
|
+
- @backstage/config@1.3.2-next.0
|
|
24
|
+
- @backstage/errors@1.2.7-next.0
|
|
25
|
+
- @backstage/plugin-catalog-node@1.15.1-next.1
|
|
26
|
+
- @backstage/integration@1.16.1-next.0
|
|
27
|
+
|
|
3
28
|
## 0.3.1-next.0
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
|
@@ -39,9 +39,8 @@ class BitbucketServerClient {
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
async getFile(options) {
|
|
42
|
-
const base = new URL(this.config.apiBaseUrl);
|
|
43
42
|
return throttledFetch(
|
|
44
|
-
`${
|
|
43
|
+
`${this.config.apiBaseUrl}/projects/${options.projectKey}/repos/${options.repo}/raw/${options.path}`,
|
|
45
44
|
integration.getBitbucketServerRequestOptions(this.config)
|
|
46
45
|
);
|
|
47
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitbucketServerClient.cjs.js","sources":["../../src/lib/BitbucketServerClient.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 {\n BitbucketServerIntegrationConfig,\n getBitbucketServerRequestOptions,\n} from '@backstage/integration';\nimport { BitbucketServerProject, BitbucketServerRepository } from './types';\nimport pThrottle from 'p-throttle';\n\n// 1 per second\nconst throttle = pThrottle({\n limit: 1,\n interval: 1000,\n});\n\nconst throttledFetch = throttle(\n async (url: RequestInfo, options?: RequestInit) => {\n return await fetch(url, options);\n },\n);\n\n/**\n * A client for interacting with a Bitbucket Server instance\n *\n * @public\n */\nexport class BitbucketServerClient {\n private readonly config: BitbucketServerIntegrationConfig;\n\n static fromConfig(options: {\n config: BitbucketServerIntegrationConfig;\n }): BitbucketServerClient {\n return new BitbucketServerClient(options);\n }\n\n constructor(options: { config: BitbucketServerIntegrationConfig }) {\n this.config = options.config;\n }\n\n async listProjects(options: {\n listOptions?: BitbucketServerListOptions;\n }): Promise<BitbucketServerPagedResponse<BitbucketServerProject>> {\n return this.pagedRequest(\n `${this.config.apiBaseUrl}/projects`,\n options.listOptions,\n );\n }\n\n async listRepositories(options: {\n projectKey: string;\n listOptions?: BitbucketServerListOptions;\n }): Promise<BitbucketServerPagedResponse<BitbucketServerRepository>> {\n return this.pagedRequest(\n `${this.config.apiBaseUrl}/projects/${encodeURIComponent(\n options.projectKey,\n )}/repos`,\n options.listOptions,\n );\n }\n\n async getFile(options: {\n projectKey: string;\n repo: string;\n path: string;\n }): Promise<Response> {\n
|
|
1
|
+
{"version":3,"file":"BitbucketServerClient.cjs.js","sources":["../../src/lib/BitbucketServerClient.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 {\n BitbucketServerIntegrationConfig,\n getBitbucketServerRequestOptions,\n} from '@backstage/integration';\nimport { BitbucketServerProject, BitbucketServerRepository } from './types';\nimport pThrottle from 'p-throttle';\n\n// 1 per second\nconst throttle = pThrottle({\n limit: 1,\n interval: 1000,\n});\n\nconst throttledFetch = throttle(\n async (url: RequestInfo, options?: RequestInit) => {\n return await fetch(url, options);\n },\n);\n\n/**\n * A client for interacting with a Bitbucket Server instance\n *\n * @public\n */\nexport class BitbucketServerClient {\n private readonly config: BitbucketServerIntegrationConfig;\n\n static fromConfig(options: {\n config: BitbucketServerIntegrationConfig;\n }): BitbucketServerClient {\n return new BitbucketServerClient(options);\n }\n\n constructor(options: { config: BitbucketServerIntegrationConfig }) {\n this.config = options.config;\n }\n\n async listProjects(options: {\n listOptions?: BitbucketServerListOptions;\n }): Promise<BitbucketServerPagedResponse<BitbucketServerProject>> {\n return this.pagedRequest(\n `${this.config.apiBaseUrl}/projects`,\n options.listOptions,\n );\n }\n\n async listRepositories(options: {\n projectKey: string;\n listOptions?: BitbucketServerListOptions;\n }): Promise<BitbucketServerPagedResponse<BitbucketServerRepository>> {\n return this.pagedRequest(\n `${this.config.apiBaseUrl}/projects/${encodeURIComponent(\n options.projectKey,\n )}/repos`,\n options.listOptions,\n );\n }\n\n async getFile(options: {\n projectKey: string;\n repo: string;\n path: string;\n }): Promise<Response> {\n return throttledFetch(\n `${this.config.apiBaseUrl}/projects/${options.projectKey}/repos/${options.repo}/raw/${options.path}`,\n getBitbucketServerRequestOptions(this.config),\n );\n }\n\n async getRepository(options: {\n projectKey: string;\n repo: string;\n }): Promise<BitbucketServerRepository> {\n const request = `${this.config.apiBaseUrl}/projects/${options.projectKey}/repos/${options.repo}`;\n const response = await throttledFetch(\n request,\n getBitbucketServerRequestOptions(this.config),\n );\n return response.json();\n }\n\n resolvePath(options: { projectKey: string; repo: string; path: string }): {\n path: string;\n } {\n const base = new URL(this.config.apiBaseUrl || '');\n\n return {\n path: `${base.protocol}//${base.host}/projects/${options.projectKey}/repos/${options.repo}${options.path}`,\n };\n }\n\n private async pagedRequest(\n endpoint: string,\n options?: BitbucketServerListOptions,\n ): Promise<BitbucketServerPagedResponse<any>> {\n const request = new URL(endpoint);\n for (const key in options) {\n if (options[key]) {\n request.searchParams.append(key, options[key]!.toString());\n }\n }\n return this.getTypeMapped(request);\n }\n\n private async getTypeMapped<T = any>(url: URL): Promise<T> {\n return this.get(url).then((response: Response) => {\n return response.json() as Promise<T>;\n });\n }\n\n private async get(url: URL): Promise<Response> {\n return this.request(new Request(url.toString(), { method: 'GET' }));\n }\n\n private async request(req: Request): Promise<Response> {\n return throttledFetch(\n req,\n getBitbucketServerRequestOptions(this.config),\n ).then((response: Response) => {\n if (!response.ok) {\n throw new Error(\n `Unexpected response for ${req.method} ${req.url}. Expected 200 but got ${response.status} - ${response.statusText}`,\n );\n }\n return response;\n });\n }\n}\n\n/**\n * @public\n */\nexport type BitbucketServerListOptions = {\n [key: string]: number | undefined;\n limit?: number | undefined;\n start?: number | undefined;\n};\n\n/**\n * @public\n */\nexport type BitbucketServerPagedResponse<T> = {\n size: number;\n limit: number;\n start: number;\n isLastPage: boolean;\n values: T[];\n nextPageStart: number;\n};\n\nexport async function* paginated(\n request: (\n options: BitbucketServerListOptions,\n ) => Promise<BitbucketServerPagedResponse<any>>,\n options?: BitbucketServerListOptions,\n) {\n const opts = options || { start: 0 };\n let res;\n do {\n res = await request(opts);\n opts.start = res.nextPageStart;\n for (const item of res.values) {\n yield item;\n }\n } while (!res.isLastPage);\n}\n"],"names":["pThrottle","getBitbucketServerRequestOptions"],"mappings":";;;;;;;;;AAwBA,MAAM,WAAWA,0BAAU,CAAA;AAAA,EACzB,KAAO,EAAA,CAAA;AAAA,EACP,QAAU,EAAA;AACZ,CAAC,CAAA;AAED,MAAM,cAAiB,GAAA,QAAA;AAAA,EACrB,OAAO,KAAkB,OAA0B,KAAA;AACjD,IAAO,OAAA,MAAM,KAAM,CAAA,GAAA,EAAK,OAAO,CAAA;AAAA;AAEnC,CAAA;AAOO,MAAM,qBAAsB,CAAA;AAAA,EAChB,MAAA;AAAA,EAEjB,OAAO,WAAW,OAEQ,EAAA;AACxB,IAAO,OAAA,IAAI,sBAAsB,OAAO,CAAA;AAAA;AAC1C,EAEA,YAAY,OAAuD,EAAA;AACjE,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA;AAAA;AACxB,EAEA,MAAM,aAAa,OAE+C,EAAA;AAChE,IAAA,OAAO,IAAK,CAAA,YAAA;AAAA,MACV,CAAA,EAAG,IAAK,CAAA,MAAA,CAAO,UAAU,CAAA,SAAA,CAAA;AAAA,MACzB,OAAQ,CAAA;AAAA,KACV;AAAA;AACF,EAEA,MAAM,iBAAiB,OAG8C,EAAA;AACnE,IAAA,OAAO,IAAK,CAAA,YAAA;AAAA,MACV,CAAG,EAAA,IAAA,CAAK,MAAO,CAAA,UAAU,CAAa,UAAA,EAAA,kBAAA;AAAA,QACpC,OAAQ,CAAA;AAAA,OACT,CAAA,MAAA,CAAA;AAAA,MACD,OAAQ,CAAA;AAAA,KACV;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I,MAAQ,EAAA;AAC7B,MAAM,MAAA,IAAA;AAAA;AACR,GACF,QAAS,CAAC,GAAI,CAAA,UAAA;AAChB;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-backend-module-bitbucket-server",
|
|
3
|
-
"version": "0.3.1
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin-module",
|
|
6
6
|
"pluginId": "catalog",
|
|
@@ -60,18 +60,18 @@
|
|
|
60
60
|
"test": "backstage-cli package test"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@backstage/backend-plugin-api": "1.1.1
|
|
64
|
-
"@backstage/catalog-model": "1.7.
|
|
65
|
-
"@backstage/config": "1.3.
|
|
66
|
-
"@backstage/errors": "1.2.
|
|
67
|
-
"@backstage/integration": "1.16.
|
|
68
|
-
"@backstage/plugin-catalog-node": "1.15.1
|
|
63
|
+
"@backstage/backend-plugin-api": "^1.1.1",
|
|
64
|
+
"@backstage/catalog-model": "^1.7.3",
|
|
65
|
+
"@backstage/config": "^1.3.2",
|
|
66
|
+
"@backstage/errors": "^1.2.7",
|
|
67
|
+
"@backstage/integration": "^1.16.1",
|
|
68
|
+
"@backstage/plugin-catalog-node": "^1.15.1",
|
|
69
69
|
"p-throttle": "^4.1.1",
|
|
70
70
|
"uuid": "^11.0.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@backstage/backend-test-utils": "1.2.1
|
|
74
|
-
"@backstage/cli": "0.29.5
|
|
73
|
+
"@backstage/backend-test-utils": "^1.2.1",
|
|
74
|
+
"@backstage/cli": "^0.29.5",
|
|
75
75
|
"luxon": "^3.0.0",
|
|
76
76
|
"msw": "^1.0.0"
|
|
77
77
|
},
|