@backstage-community/plugin-explore-backend 0.2.0 → 0.3.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,11 @@
1
1
  # @backstage-community/plugin-explore-backend
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 088f904: Remove support for old backend system
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -40,116 +40,6 @@ explore:
40
40
  - nerdGraph
41
41
  ```
42
42
 
43
- ### Adding the plugin to your `packages/backend` (old)
44
-
45
- #### Tools as Config
46
-
47
- Install dependencies
48
-
49
- ```bash
50
- # From your Backstage root directory
51
- yarn --cwd packages/backend add @backstage-community/plugin-explore-backend
52
- ```
53
-
54
- You'll need to add the plugin to the router in your `backend` package. You can
55
- do this by creating a file called `packages/backend/src/plugins/explore.ts` with the following content:
56
-
57
- ```ts title="packages/backend/src/plugins/explore.ts"
58
- import {
59
- createRouter,
60
- StaticExploreToolProvider,
61
- } from '@backstage-community/plugin-explore-backend';
62
- import { Router } from 'express';
63
- import { PluginEnvironment } from '../types';
64
-
65
- export default async function createPlugin(
66
- env: PluginEnvironment,
67
- ): Promise<Router> {
68
- return await createRouter({
69
- logger: env.logger,
70
- toolProvider: StaticExploreToolProvider.fromConfig(env.config),
71
- });
72
- }
73
- ```
74
-
75
- Config:
76
-
77
- ```yaml
78
- explore:
79
- tools:
80
- - title: New Relic
81
- description: new relic plugin
82
- url: /newrelic
83
- image: https://i.imgur.com/L37ikrX.jpg
84
- tags:
85
- - newrelic
86
- - proxy
87
- - nerdGraph
88
- ```
89
-
90
- #### Tools as Code
91
-
92
- Install dependencies
93
-
94
- ```bash
95
- # From your Backstage root directory
96
- yarn --cwd packages/backend add @backstage-community/plugin-explore-backend @backstage-community/plugin-explore-common
97
- ```
98
-
99
- You'll need to add the plugin to the router in your `backend` package. You can
100
- do this by creating a file called `packages/backend/src/plugins/explore.ts` with the following content:
101
-
102
- ```ts
103
- import {
104
- createRouter,
105
- StaticExploreToolProvider,
106
- } from '@backstage-community/plugin-explore-backend';
107
- import { ExploreTool } from '@backstage-community/plugin-explore-common';
108
- import { Router } from 'express';
109
- import { PluginEnvironment } from '../types';
110
-
111
- // List of tools you want to surface in the Explore plugin "Tools" page.
112
- const exploreTools: ExploreTool[] = [
113
- {
114
- title: 'New Relic',
115
- description: 'new relic plugin',
116
- url: '/newrelic',
117
- image: 'https://i.imgur.com/L37ikrX.jpg',
118
- tags: ['newrelic', 'proxy', 'nerdGraph'],
119
- },
120
- ];
121
-
122
- export default async function createPlugin(
123
- env: PluginEnvironment,
124
- ): Promise<Router> {
125
- return await createRouter({
126
- logger: env.logger,
127
- toolProvider: StaticExploreToolProvider.fromData(exploreTools),
128
- });
129
- }
130
- ```
131
-
132
- #### Register the plugin router
133
-
134
- With the `explore.ts` router setup in place, add the router to
135
- `packages/backend/src/index.ts`:
136
-
137
- ```diff
138
- +import explore from './plugins/explore';
139
-
140
- async function main() {
141
- ...
142
- const createEnv = makeCreateEnv(config);
143
-
144
- const catalogEnv = useHotMemoize(module, () => createEnv('catalog'));
145
- + const exploreEnv = useHotMemoize(module, () => createEnv('explore'));
146
-
147
- const apiRouter = Router();
148
- + apiRouter.use('/explore', await explore(exploreEnv));
149
- ...
150
- apiRouter.use(notFoundHandler());
151
- ```
152
-
153
43
  ### Wire up Search Indexing
154
44
 
155
45
  To index explore tools you will need to register the search collator in the
@@ -184,50 +74,6 @@ can be customized to provide tools from any source. For example you could create
184
74
  a `CustomExploreToolProvider` that queries an internal for tools in your
185
75
  `packages/backend/src/plugins/explore.ts` file.
186
76
 
187
- Old Backend system:
188
-
189
- ```ts
190
- import {
191
- createRouter,
192
- StaticExploreToolProvider,
193
- } from '@backstage-community/plugin-explore-backend';
194
- import { Router } from 'express';
195
- import { PluginEnvironment } from '../types';
196
-
197
- class CustomExploreToolProvider implements ExploreToolProvider {
198
- async getTools(
199
- request: GetExploreToolsRequest,
200
- ): Promise<GetExploreToolsResponse> {
201
- const externalTools = await queryExternalTools(request);
202
-
203
- const tools: ExploreTool[] = [
204
- ...externalTools,
205
- // Backstage Tools
206
- {
207
- title: 'New Relic',
208
- description: 'new relic plugin',
209
- url: '/newrelic',
210
- image: 'https://i.imgur.com/L37ikrX.jpg',
211
- tags: ['newrelic', 'proxy', 'nerdGraph'],
212
- },
213
- ];
214
-
215
- return { tools };
216
- }
217
- }
218
-
219
- export default async function createPlugin(
220
- env: PluginEnvironment,
221
- ): Promise<Router> {
222
- return await createRouter({
223
- logger: env.logger,
224
- toolProvider: new CustomExploreToolProvider(),
225
- });
226
- }
227
- ```
228
-
229
- New Backend system:
230
-
231
77
  ```ts
232
78
  // packages/backend/src/modules/exploreToolProviderModule.ts
233
79
 
package/dist/index.cjs.js CHANGED
@@ -3,14 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var plugin = require('./plugin.cjs.js');
6
- var router = require('./service/router.cjs.js');
7
6
  var StaticExploreToolProvider = require('./tools/providers/StaticExploreToolProvider.cjs.js');
8
7
  var exampleTools = require('./example/exampleTools.cjs.js');
9
8
 
10
9
 
11
10
 
12
11
  exports.default = plugin.explorePlugin;
13
- exports.createRouter = router.createRouter;
14
12
  exports.StaticExploreToolProvider = StaticExploreToolProvider.StaticExploreToolProvider;
15
13
  exports.exampleTools = exampleTools.exampleTools;
16
14
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
- import { LoggerService } from '@backstage/backend-plugin-api';
3
- import express from 'express';
4
- import { ExploreToolProvider as ExploreToolProvider$1 } from '@backstage-community/plugin-explore-node';
5
2
  import { Config } from '@backstage/config';
6
3
  import { ExploreTool, GetExploreToolsRequest, GetExploreToolsResponse } from '@backstage-community/plugin-explore-common';
4
+ import { ExploreToolProvider as ExploreToolProvider$1 } from '@backstage-community/plugin-explore-node';
7
5
 
8
6
  /**
9
7
  * The explore backend plugin.
@@ -12,22 +10,6 @@ import { ExploreTool, GetExploreToolsRequest, GetExploreToolsResponse } from '@b
12
10
  */
13
11
  declare const explorePlugin: _backstage_backend_plugin_api.BackendFeature;
14
12
 
15
- /**
16
- * @deprecated Please migrate to the new backend system as this will be removed in the future.
17
- *
18
- * @public
19
- */
20
- interface RouterOptions {
21
- logger: LoggerService;
22
- toolProvider: ExploreToolProvider$1;
23
- }
24
- /**
25
- * @deprecated Please migrate to the new backend system as this will be removed in the future.
26
- *
27
- * @public
28
- */
29
- declare function createRouter(options: RouterOptions): Promise<express.Router>;
30
-
31
13
  /**
32
14
  * A basic ExploreToolProvider implementation using static data.
33
15
  *
@@ -47,4 +29,4 @@ declare class StaticExploreToolProvider implements ExploreToolProvider$1 {
47
29
  */
48
30
  type ExploreToolProvider = ExploreToolProvider$1;
49
31
 
50
- export { type ExploreToolProvider, type RouterOptions, StaticExploreToolProvider, createRouter, explorePlugin as default };
32
+ export { type ExploreToolProvider, StaticExploreToolProvider, explorePlugin as default };
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var backendCommon = require('@backstage/backend-common');
4
3
  var express = require('express');
5
4
  var Router = require('express-promise-router');
6
5
 
@@ -18,7 +17,6 @@ async function createRouter(options) {
18
17
  const result = await toolProvider.getTools(requestQuery);
19
18
  response.json(result);
20
19
  });
21
- router.use(backendCommon.errorHandler());
22
20
  return router;
23
21
  }
24
22
  function parseExploreToolRequestQuery(params) {
@@ -1 +1 @@
1
- {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.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 { errorHandler } from '@backstage/backend-common';\nimport { GetExploreToolsRequest } from '@backstage-community/plugin-explore-common';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { ExploreToolProvider } from '@backstage-community/plugin-explore-node';\n\n/**\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n *\n * @public\n */\nexport interface RouterOptions {\n logger: LoggerService;\n toolProvider: ExploreToolProvider;\n}\n\n/**\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n *\n * @public\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const { toolProvider } = options;\n\n const router = Router();\n router.use(express.json());\n\n router.get('/tools', async (request, response) => {\n const requestQuery = parseExploreToolRequestQuery(request.query);\n const result = await toolProvider.getTools(requestQuery);\n response.json(result);\n });\n\n router.use(errorHandler());\n\n return router;\n}\n\nfunction parseExploreToolRequestQuery(\n params: Record<string, unknown>,\n): GetExploreToolsRequest {\n // TODO: Implement proper query parsing for the filters\n // Also consider using a `filter` query string like catalog client does\n return {\n filter: {\n tags: [...[(params?.tag as any) ?? []]].flat(),\n lifecycle: [...[(params?.lifecycle as any) ?? []]].flat(),\n },\n };\n}\n"],"names":["Router","express","errorHandler"],"mappings":";;;;;;;;;;;AAsCA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AAEzB,EAAA,MAAM,SAASA,uBAAO,EAAA;AACtB,EAAO,MAAA,CAAA,GAAA,CAAIC,wBAAQ,CAAA,IAAA,EAAM,CAAA;AAEzB,EAAA,MAAA,CAAO,GAAI,CAAA,QAAA,EAAU,OAAO,OAAA,EAAS,QAAa,KAAA;AAChD,IAAM,MAAA,YAAA,GAAe,4BAA6B,CAAA,OAAA,CAAQ,KAAK,CAAA;AAC/D,IAAA,MAAM,MAAS,GAAA,MAAM,YAAa,CAAA,QAAA,CAAS,YAAY,CAAA;AACvD,IAAA,QAAA,CAAS,KAAK,MAAM,CAAA;AAAA,GACrB,CAAA;AAED,EAAO,MAAA,CAAA,GAAA,CAAIC,4BAAc,CAAA;AAEzB,EAAO,OAAA,MAAA;AACT;AAEA,SAAS,6BACP,MACwB,EAAA;AAGxB,EAAO,OAAA;AAAA,IACL,MAAQ,EAAA;AAAA,MACN,IAAA,EAAM,CAAC,GAAG,CAAE,MAAA,EAAQ,OAAe,EAAE,CAAC,CAAA,CAAE,IAAK,EAAA;AAAA,MAC7C,SAAA,EAAW,CAAC,GAAG,CAAE,MAAA,EAAQ,aAAqB,EAAE,CAAC,CAAA,CAAE,IAAK;AAAA;AAC1D,GACF;AACF;;;;"}
1
+ {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.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 { GetExploreToolsRequest } from '@backstage-community/plugin-explore-common';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { ExploreToolProvider } from '@backstage-community/plugin-explore-node';\n\nexport interface RouterOptions {\n logger: LoggerService;\n toolProvider: ExploreToolProvider;\n}\n\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const { toolProvider } = options;\n\n const router = Router();\n router.use(express.json());\n\n router.get('/tools', async (request, response) => {\n const requestQuery = parseExploreToolRequestQuery(request.query);\n const result = await toolProvider.getTools(requestQuery);\n response.json(result);\n });\n\n return router;\n}\n\nfunction parseExploreToolRequestQuery(\n params: Record<string, unknown>,\n): GetExploreToolsRequest {\n // TODO: Implement proper query parsing for the filters\n // Also consider using a `filter` query string like catalog client does\n return {\n filter: {\n tags: [...[(params?.tag as any) ?? []]].flat(),\n lifecycle: [...[(params?.lifecycle as any) ?? []]].flat(),\n },\n };\n}\n"],"names":["Router","express"],"mappings":";;;;;;;;;;AA2BA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AAEzB,EAAA,MAAM,SAASA,uBAAO,EAAA;AACtB,EAAO,MAAA,CAAA,GAAA,CAAIC,wBAAQ,CAAA,IAAA,EAAM,CAAA;AAEzB,EAAA,MAAA,CAAO,GAAI,CAAA,QAAA,EAAU,OAAO,OAAA,EAAS,QAAa,KAAA;AAChD,IAAM,MAAA,YAAA,GAAe,4BAA6B,CAAA,OAAA,CAAQ,KAAK,CAAA;AAC/D,IAAA,MAAM,MAAS,GAAA,MAAM,YAAa,CAAA,QAAA,CAAS,YAAY,CAAA;AACvD,IAAA,QAAA,CAAS,KAAK,MAAM,CAAA;AAAA,GACrB,CAAA;AAED,EAAO,OAAA,MAAA;AACT;AAEA,SAAS,6BACP,MACwB,EAAA;AAGxB,EAAO,OAAA;AAAA,IACL,MAAQ,EAAA;AAAA,MACN,IAAA,EAAM,CAAC,GAAG,CAAE,MAAA,EAAQ,OAAe,EAAE,CAAC,CAAA,CAAE,IAAK,EAAA;AAAA,MAC7C,SAAA,EAAW,CAAC,GAAG,CAAE,MAAA,EAAQ,aAAqB,EAAE,CAAC,CAAA,CAAE,IAAK;AAAA;AAC1D,GACF;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-explore-backend",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "backstage": {
5
5
  "role": "backend-plugin",
6
6
  "pluginId": "explore",
@@ -42,7 +42,6 @@
42
42
  "dependencies": {
43
43
  "@backstage-community/plugin-explore-common": "^0.1.0",
44
44
  "@backstage-community/plugin-explore-node": "^0.2.0",
45
- "@backstage/backend-common": "^0.25.0",
46
45
  "@backstage/backend-plugin-api": "^1.1.0",
47
46
  "@backstage/config": "^1.3.1",
48
47
  "@backstage/types": "^1.2.0",