@backstage/plugin-catalog-backend-module-bitbucket-server 0.2.5-next.0 → 0.2.5-next.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,18 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-bitbucket-server
|
|
2
2
|
|
|
3
|
+
## 0.2.5-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5c9cc05: Use native fetch instead of node-fetch
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-catalog-node@1.15.0-next.1
|
|
10
|
+
- @backstage/backend-plugin-api@1.1.0-next.1
|
|
11
|
+
- @backstage/catalog-model@1.7.1
|
|
12
|
+
- @backstage/config@1.3.0
|
|
13
|
+
- @backstage/errors@1.2.5
|
|
14
|
+
- @backstage/integration@1.16.0-next.0
|
|
15
|
+
|
|
3
16
|
## 0.2.5-next.0
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
2
|
import { LoggerService, SchedulerServiceTaskRunner, SchedulerService } from '@backstage/backend-plugin-api';
|
|
3
|
-
import { Response } from 'node-fetch';
|
|
4
3
|
import { BitbucketServerIntegrationConfig } from '@backstage/integration';
|
|
5
4
|
import { Config } from '@backstage/config';
|
|
6
5
|
import { LocationSpec, EntityProvider, EntityProviderConnection } from '@backstage/plugin-catalog-node';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fetch = require('node-fetch');
|
|
4
3
|
var integration = require('@backstage/integration');
|
|
5
4
|
|
|
6
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
9
|
-
|
|
10
5
|
class BitbucketServerClient {
|
|
11
6
|
config;
|
|
12
7
|
static fromConfig(options) {
|
|
@@ -31,14 +26,14 @@ class BitbucketServerClient {
|
|
|
31
26
|
}
|
|
32
27
|
async getFile(options) {
|
|
33
28
|
const base = new URL(this.config.apiBaseUrl);
|
|
34
|
-
return
|
|
29
|
+
return fetch(
|
|
35
30
|
`${base.protocol}//${base.host}/projects/${options.projectKey}/repos/${options.repo}/raw/${options.path}`,
|
|
36
31
|
integration.getBitbucketServerRequestOptions(this.config)
|
|
37
32
|
);
|
|
38
33
|
}
|
|
39
34
|
async getRepository(options) {
|
|
40
35
|
const request = `${this.config.apiBaseUrl}/projects/${options.projectKey}/repos/${options.repo}`;
|
|
41
|
-
const response = await
|
|
36
|
+
const response = await fetch(
|
|
42
37
|
request,
|
|
43
38
|
integration.getBitbucketServerRequestOptions(this.config)
|
|
44
39
|
);
|
|
@@ -65,10 +60,10 @@ class BitbucketServerClient {
|
|
|
65
60
|
});
|
|
66
61
|
}
|
|
67
62
|
async get(url) {
|
|
68
|
-
return this.request(new
|
|
63
|
+
return this.request(new Request(url.toString(), { method: "GET" }));
|
|
69
64
|
}
|
|
70
65
|
async request(req) {
|
|
71
|
-
return
|
|
66
|
+
return fetch(req, integration.getBitbucketServerRequestOptions(this.config)).then(
|
|
72
67
|
(response) => {
|
|
73
68
|
if (!response.ok) {
|
|
74
69
|
throw new Error(
|
|
@@ -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
|
|
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';\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 const base = new URL(this.config.apiBaseUrl);\n return fetch(\n `${base.protocol}//${base.host}/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 fetch(\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 fetch(req, getBitbucketServerRequestOptions(this.config)).then(\n (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/**\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 (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EAAA,EAAG,EAAE,MAAA,EAAQ,KAAM,EAAC,CAAC,CAAA;AAAA;AACpE,EAEA,MAAc,QAAQ,GAAiC,EAAA;AACrD,IAAA,OAAO,MAAM,GAAK,EAAAA,4CAAA,CAAiC,IAAK,CAAA,MAAM,CAAC,CAAE,CAAA,IAAA;AAAA,MAC/D,CAAC,QAAuB,KAAA;AACtB,QAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAAA,wBAAA,EAA2B,GAAI,CAAA,MAAM,CAAI,CAAA,EAAA,GAAA,CAAI,GAAG,CAAA,uBAAA,EAA0B,QAAS,CAAA,MAAM,CAAM,GAAA,EAAA,QAAA,CAAS,UAAU,CAAA;AAAA,WACpH;AAAA;AAEF,QAAO,OAAA,QAAA;AAAA;AACT,KACF;AAAA;AAEJ;AAuBuB,gBAAA,SAAA,CACrB,SAGA,OACA,EAAA;AACA,EAAA,MAAM,IAAO,GAAW,EAAE,KAAA,EAAO,CAAE,EAAA;AACnC,EAAI,IAAA,GAAA;AACJ,EAAG,GAAA;AACD,IAAM,GAAA,GAAA,MAAM,QAAQ,IAAI,CAAA;AACxB,IAAA,IAAA,CAAK,QAAQ,GAAI,CAAA,aAAA;AACjB,IAAW,KAAA,MAAA,IAAA,IAAQ,IAAI,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.2.5-next.
|
|
3
|
+
"version": "0.2.5-next.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin-module",
|
|
6
6
|
"pluginId": "catalog",
|
|
@@ -60,19 +60,17 @@
|
|
|
60
60
|
"test": "backstage-cli package test"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@backstage/backend-plugin-api": "1.0
|
|
63
|
+
"@backstage/backend-plugin-api": "1.1.0-next.1",
|
|
64
64
|
"@backstage/catalog-model": "1.7.1",
|
|
65
65
|
"@backstage/config": "1.3.0",
|
|
66
66
|
"@backstage/errors": "1.2.5",
|
|
67
67
|
"@backstage/integration": "1.16.0-next.0",
|
|
68
|
-
"@backstage/plugin-catalog-node": "1.
|
|
69
|
-
"@types/node-fetch": "^2.5.12",
|
|
70
|
-
"node-fetch": "^2.7.0",
|
|
68
|
+
"@backstage/plugin-catalog-node": "1.15.0-next.1",
|
|
71
69
|
"uuid": "^11.0.0"
|
|
72
70
|
},
|
|
73
71
|
"devDependencies": {
|
|
74
|
-
"@backstage/backend-test-utils": "1.2.0-next.
|
|
75
|
-
"@backstage/cli": "0.29.3-next.
|
|
72
|
+
"@backstage/backend-test-utils": "1.2.0-next.1",
|
|
73
|
+
"@backstage/cli": "0.29.3-next.1",
|
|
76
74
|
"luxon": "^3.0.0",
|
|
77
75
|
"msw": "^1.0.0"
|
|
78
76
|
},
|