@backstage/plugin-search-backend-module-explore 0.2.5 → 0.2.6-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,27 @@
|
|
|
1
1
|
# @backstage/plugin-search-backend-module-explore
|
|
2
2
|
|
|
3
|
+
## 0.2.6-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5c9cc05: Use native fetch instead of node-fetch
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-search-backend-node@1.3.6-next.1
|
|
10
|
+
- @backstage/backend-plugin-api@1.1.0-next.1
|
|
11
|
+
- @backstage/config@1.3.0
|
|
12
|
+
- @backstage/plugin-search-common@1.2.15
|
|
13
|
+
|
|
14
|
+
## 0.2.6-next.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- ed0aaec: Update README
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/backend-plugin-api@1.0.3-next.0
|
|
21
|
+
- @backstage/config@1.3.0
|
|
22
|
+
- @backstage/plugin-search-backend-node@1.3.6-next.0
|
|
23
|
+
- @backstage/plugin-search-common@1.2.15
|
|
24
|
+
|
|
3
25
|
## 0.2.5
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -16,12 +16,10 @@ Add the collator to your backend instance, along with the search plugin itself:
|
|
|
16
16
|
```tsx
|
|
17
17
|
// packages/backend/src/index.ts
|
|
18
18
|
import { createBackend } from '@backstage/backend-defaults';
|
|
19
|
-
import { searchPlugin } from '@backstage/plugin-search-backend/alpha';
|
|
20
|
-
import { searchModuleExploreCollator } from '@backstage/plugin-search-backend-module-explore/alpha';
|
|
21
19
|
|
|
22
20
|
const backend = createBackend();
|
|
23
|
-
backend.add(
|
|
24
|
-
backend.add(
|
|
21
|
+
backend.add(import('@backstage/plugin-search-backend'));
|
|
22
|
+
backend.add(import('@backstage/plugin-search-backend-module-explore'));
|
|
25
23
|
backend.start();
|
|
26
24
|
```
|
|
27
25
|
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var backendCommon = require('@backstage/backend-common');
|
|
4
|
-
var fetch = require('node-fetch');
|
|
5
4
|
var stream = require('stream');
|
|
6
5
|
|
|
7
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
|
-
|
|
9
|
-
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
10
|
-
|
|
11
6
|
class ToolDocumentCollatorFactory {
|
|
12
7
|
type = "tools";
|
|
13
8
|
discovery;
|
|
@@ -42,7 +37,7 @@ class ToolDocumentCollatorFactory {
|
|
|
42
37
|
onBehalfOf: await this.auth.getOwnServiceCredentials(),
|
|
43
38
|
targetPluginId: "explore"
|
|
44
39
|
});
|
|
45
|
-
const response = await
|
|
40
|
+
const response = await fetch(`${baseUrl}/tools`, {
|
|
46
41
|
headers: { Authorization: `Bearer ${token}` }
|
|
47
42
|
});
|
|
48
43
|
if (!response.ok) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolDocumentCollatorFactory.cjs.js","sources":["../../src/collators/ToolDocumentCollatorFactory.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 createLegacyAuthAdapters,\n TokenManager,\n} from '@backstage/backend-common';\nimport {\n AuthService,\n DiscoveryService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport { ExploreTool } from '@backstage-community/plugin-explore-common';\nimport {\n DocumentCollatorFactory,\n IndexableDocument,\n} from '@backstage/plugin-search-common';\nimport
|
|
1
|
+
{"version":3,"file":"ToolDocumentCollatorFactory.cjs.js","sources":["../../src/collators/ToolDocumentCollatorFactory.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 createLegacyAuthAdapters,\n TokenManager,\n} from '@backstage/backend-common';\nimport {\n AuthService,\n DiscoveryService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport { ExploreTool } from '@backstage-community/plugin-explore-common';\nimport {\n DocumentCollatorFactory,\n IndexableDocument,\n} from '@backstage/plugin-search-common';\nimport { Readable } from 'stream';\n\n/**\n * Extended IndexableDocument with explore tool specific properties\n *\n * @public\n */\nexport interface ToolDocument extends IndexableDocument, ExploreTool {}\n\n/**\n * @public\n * @deprecated This type is deprecated along with the {@link ToolDocumentCollatorFactory}.\n */\nexport type ToolDocumentCollatorFactoryOptions = {\n discovery: DiscoveryService;\n logger: LoggerService;\n tokenManager?: TokenManager;\n auth?: AuthService;\n};\n\n/**\n * Search collator responsible for collecting explore tools to index.\n *\n * @public\n * @deprecated Migrate to the {@link https://backstage.io/docs/backend-system/building-backends/migrating | new backend system} and install this collator via module instead (see {@link https://github.com/backstage/backstage/blob/nbs10/search-deprecate-create-router/plugins/search-backend-module-explore/README.md#installation | here} for more installation details).\n */\nexport class ToolDocumentCollatorFactory implements DocumentCollatorFactory {\n public readonly type: string = 'tools';\n\n private readonly discovery: DiscoveryService;\n private readonly logger: LoggerService;\n private readonly auth: AuthService;\n\n private constructor(options: ToolDocumentCollatorFactoryOptions) {\n this.discovery = options.discovery;\n this.logger = options.logger;\n this.auth = createLegacyAuthAdapters(options).auth;\n }\n\n static fromConfig(\n _config: Config,\n options: ToolDocumentCollatorFactoryOptions,\n ) {\n return new ToolDocumentCollatorFactory(options);\n }\n\n async getCollator() {\n return Readable.from(this.execute());\n }\n\n async *execute(): AsyncGenerator<ToolDocument> {\n this.logger.info('Starting collation of explore tools');\n\n const tools = await this.fetchTools();\n\n for (const tool of tools) {\n yield {\n ...tool,\n text: tool.description,\n location: tool.url,\n };\n }\n\n this.logger.info('Finished collation of explore tools');\n }\n\n private async fetchTools() {\n const baseUrl = await this.discovery.getBaseUrl('explore');\n\n const { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'explore',\n });\n const response = await fetch(`${baseUrl}/tools`, {\n headers: { Authorization: `Bearer ${token}` },\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to explore fetch tools, ${response.status}: ${response.statusText}`,\n );\n }\n\n const data = await response.json();\n return data.tools;\n }\n}\n"],"names":["createLegacyAuthAdapters","Readable"],"mappings":";;;;;AAyDO,MAAM,2BAA+D,CAAA;AAAA,EAC1D,IAAe,GAAA,OAAA;AAAA,EAEd,SAAA;AAAA,EACA,MAAA;AAAA,EACA,IAAA;AAAA,EAET,YAAY,OAA6C,EAAA;AAC/D,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA;AACzB,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA;AACtB,IAAK,IAAA,CAAA,IAAA,GAAOA,sCAAyB,CAAA,OAAO,CAAE,CAAA,IAAA;AAAA;AAChD,EAEA,OAAO,UACL,CAAA,OAAA,EACA,OACA,EAAA;AACA,IAAO,OAAA,IAAI,4BAA4B,OAAO,CAAA;AAAA;A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O,IAAK,CAAA,KAAA;AAAA;AAEhB;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
|
4
4
|
import { DiscoveryService, LoggerService, AuthService } from '@backstage/backend-plugin-api';
|
|
5
5
|
import { Config } from '@backstage/config';
|
|
6
6
|
import { ExploreTool } from '@backstage-community/plugin-explore-common';
|
|
7
|
-
import {
|
|
7
|
+
import { IndexableDocument, DocumentCollatorFactory } from '@backstage/plugin-search-common';
|
|
8
8
|
import { Readable } from 'stream';
|
|
9
9
|
|
|
10
10
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-search-backend-module-explore",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6-next.1",
|
|
4
4
|
"description": "A module for the search backend that exports explore modules",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -60,15 +60,14 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@backstage-community/plugin-explore-common": "^0.0.7",
|
|
62
62
|
"@backstage/backend-common": "^0.25.0",
|
|
63
|
-
"@backstage/backend-plugin-api": "
|
|
64
|
-
"@backstage/config": "
|
|
65
|
-
"@backstage/plugin-search-backend-node": "
|
|
66
|
-
"@backstage/plugin-search-common": "
|
|
67
|
-
"node-fetch": "^2.7.0"
|
|
63
|
+
"@backstage/backend-plugin-api": "1.1.0-next.1",
|
|
64
|
+
"@backstage/config": "1.3.0",
|
|
65
|
+
"@backstage/plugin-search-backend-node": "1.3.6-next.1",
|
|
66
|
+
"@backstage/plugin-search-common": "1.2.15"
|
|
68
67
|
},
|
|
69
68
|
"devDependencies": {
|
|
70
|
-
"@backstage/backend-test-utils": "
|
|
71
|
-
"@backstage/cli": "
|
|
69
|
+
"@backstage/backend-test-utils": "1.2.0-next.1",
|
|
70
|
+
"@backstage/cli": "0.29.3-next.1",
|
|
72
71
|
"msw": "^1.2.1"
|
|
73
72
|
},
|
|
74
73
|
"configSchema": "config.d.ts"
|