@backstage/plugin-search-backend-module-explore 0.1.4-next.2 → 0.1.4

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,22 @@
1
1
  # @backstage/plugin-search-backend-module-explore
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 629cbd194a87: Use `coreServices.rootConfig` instead of `coreService.config`
8
+ - 29f77f923c71: Ensure that all services are dependency injected into the module instead of taken from options
9
+ - 12a8c94eda8d: Add package repository and homepage metadata
10
+ - 6694e79ab396: Breaking change for the alpha export moved `schedule` from module options into app-config for the new backend system. You can now pass in a `TaskScheduleDefinitionConfig` through the `search.collators.explore.schedule` configuration key.
11
+ - Updated dependencies
12
+ - @backstage/backend-common@0.19.2
13
+ - @backstage/backend-plugin-api@0.6.0
14
+ - @backstage/plugin-search-backend-node@1.2.4
15
+ - @backstage/backend-tasks@0.5.5
16
+ - @backstage/config@1.0.8
17
+ - @backstage/plugin-explore-common@0.0.1
18
+ - @backstage/plugin-search-common@1.2.5
19
+
3
20
  ## 0.1.4-next.2
4
21
 
5
22
  ### Patch Changes
package/README.md CHANGED
@@ -2,47 +2,36 @@
2
2
 
3
3
  > DISCLAIMER: The new backend system is in alpha, and so are the search backend module support for the new backend system. We don't recommend you to migrate your backend installations to the new system yet. But if you want to experiment, you can find getting started guides below.
4
4
 
5
- This package exports explore backend modules responsible for extending search.
5
+ This package exports a module that extends the search backend to also indexing the tools exposed by the [`explore` service](https://github.com/backstage/backstage/tree/master/plugins/explore-backend).
6
6
 
7
- ## Example
7
+ ## Installation
8
8
 
9
- ### Use default schedule
9
+ Add the module package as a dependency:
10
10
 
11
- ```tsx
12
- // packages/backend-next/src/index.ts
13
- import { createBackend } from '@backstage/backend-defaults';
14
- import { searchPlugin } from '@backstage/plugin-search-backend/alpha';
15
- import { searchModuleExploreCollator } from '@backstage/plugin-search-backend-module-explore/alpha';
16
-
17
- const backend = createBackend();
18
- backend.add(searchPlugin());
19
- backend.add(searchModuleExploreCollator());
20
- backend.start();
11
+ ```bash
12
+ # From your Backstage root directory
13
+ yarn add --cwd packages/backend @backstage/plugin-search-backend-module-explore
21
14
  ```
22
15
 
23
- ### Use custom schedule
16
+ Add the collator to your backend instance, along with the search plugin itself:
24
17
 
25
18
  ```tsx
26
- // packages/backend-next/src/index.ts
19
+ // packages/backend/src/index.ts
27
20
  import { createBackend } from '@backstage/backend-defaults';
28
21
  import { searchPlugin } from '@backstage/plugin-search-backend/alpha';
29
22
  import { searchModuleExploreCollator } from '@backstage/plugin-search-backend-module-explore/alpha';
30
23
 
31
- const schedule = {
32
- frequency: { minutes: 10 },
33
- timeout: { minutes: 15 },
34
- initialDelay: { seconds: 3 },
35
- };
36
-
37
24
  const backend = createBackend();
38
25
  backend.add(searchPlugin());
39
- backend.add(searchModuleExploreCollator({ schedule }));
26
+ backend.add(searchModuleExploreCollator());
40
27
  backend.start();
41
28
  ```
42
29
 
43
- ### Using Auth Middleware
30
+ You may also want to add configuration parameters to your app-config, for example for controlling the scheduled indexing interval. These parameters should be placed under the `search.collators.explore` key. See [the config definition file](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-explore/config.d.ts) for more details.
31
+
32
+ ## Using Auth Middleware
44
33
 
45
- If your Backstage instance uses service-to-service authentication you can pass an optional `tokenManager` to the collator factory. This will ensure that the collator makes authenticated requests to the explore backend.
34
+ If your Backstage instance uses service-to-service authentication, the collator will need to have access to a `tokenManager`. This is automatically injected by the collator module when using the new backend system. But if you are using the old backend system, you will want to add it manually to ensure that the collator makes authenticated requests to the explore backend.
46
35
 
47
36
  ```tsx
48
37
  indexBuilder.addCollator({
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-search-backend-module-explore",
3
- "version": "0.1.4-next.2",
3
+ "version": "0.1.4",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/config.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright 2023 The Backstage Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { TaskScheduleDefinitionConfig } from '@backstage/backend-tasks';
18
+
19
+ export interface Config {
20
+ search?: {
21
+ collators?: {
22
+ /**
23
+ * Configuration options for `@backstage/plugin-search-backend-module-explore`
24
+ */
25
+ explore?: {
26
+ /**
27
+ * The schedule for how often to run the collation job.
28
+ */
29
+ schedule?: TaskScheduleDefinitionConfig;
30
+ };
31
+ };
32
+ };
33
+ }
package/dist/alpha.cjs.js CHANGED
@@ -6,50 +6,49 @@ var backendPluginApi = require('@backstage/backend-plugin-api');
6
6
  var backendCommon = require('@backstage/backend-common');
7
7
  var alpha = require('@backstage/plugin-search-backend-node/alpha');
8
8
  var pluginSearchBackendModuleExplore = require('@backstage/plugin-search-backend-module-explore');
9
+ var backendTasks = require('@backstage/backend-tasks');
9
10
 
10
- const searchModuleExploreCollator = backendPluginApi.createBackendModule(
11
- (options) => ({
12
- moduleId: "exploreCollator",
13
- pluginId: "search",
14
- register(env) {
15
- env.registerInit({
16
- deps: {
17
- config: backendPluginApi.coreServices.rootConfig,
18
- logger: backendPluginApi.coreServices.logger,
19
- discovery: backendPluginApi.coreServices.discovery,
20
- scheduler: backendPluginApi.coreServices.scheduler,
21
- tokenManager: backendPluginApi.coreServices.tokenManager,
22
- indexRegistry: alpha.searchIndexRegistryExtensionPoint
23
- },
24
- async init({
25
- config,
26
- logger,
27
- discovery,
28
- scheduler,
29
- indexRegistry,
30
- tokenManager
31
- }) {
32
- var _a;
33
- const defaultSchedule = {
34
- frequency: { minutes: 10 },
35
- timeout: { minutes: 15 },
36
- initialDelay: { seconds: 3 }
37
- };
38
- indexRegistry.addCollator({
39
- schedule: scheduler.createScheduledTaskRunner(
40
- (_a = options == null ? void 0 : options.schedule) != null ? _a : defaultSchedule
41
- ),
42
- factory: pluginSearchBackendModuleExplore.ToolDocumentCollatorFactory.fromConfig(config, {
43
- discovery,
44
- logger: backendCommon.loggerToWinstonLogger(logger),
45
- tokenManager
46
- })
47
- });
48
- }
49
- });
50
- }
51
- })
52
- );
11
+ const searchModuleExploreCollator = backendPluginApi.createBackendModule({
12
+ moduleId: "exploreCollator",
13
+ pluginId: "search",
14
+ register(env) {
15
+ env.registerInit({
16
+ deps: {
17
+ config: backendPluginApi.coreServices.rootConfig,
18
+ logger: backendPluginApi.coreServices.logger,
19
+ discovery: backendPluginApi.coreServices.discovery,
20
+ scheduler: backendPluginApi.coreServices.scheduler,
21
+ tokenManager: backendPluginApi.coreServices.tokenManager,
22
+ indexRegistry: alpha.searchIndexRegistryExtensionPoint
23
+ },
24
+ async init({
25
+ config,
26
+ logger,
27
+ discovery,
28
+ scheduler,
29
+ indexRegistry,
30
+ tokenManager
31
+ }) {
32
+ const defaultSchedule = {
33
+ frequency: { minutes: 10 },
34
+ timeout: { minutes: 15 },
35
+ initialDelay: { seconds: 3 }
36
+ };
37
+ const schedule = config.has("search.collators.explore.schedule") ? backendTasks.readTaskScheduleDefinitionFromConfig(
38
+ config.getConfig("search.collators.explore.schedule")
39
+ ) : defaultSchedule;
40
+ indexRegistry.addCollator({
41
+ schedule: scheduler.createScheduledTaskRunner(schedule),
42
+ factory: pluginSearchBackendModuleExplore.ToolDocumentCollatorFactory.fromConfig(config, {
43
+ discovery,
44
+ logger: backendCommon.loggerToWinstonLogger(logger),
45
+ tokenManager
46
+ })
47
+ });
48
+ }
49
+ });
50
+ }
51
+ });
53
52
 
54
53
  exports.searchModuleExploreCollator = searchModuleExploreCollator;
55
54
  //# sourceMappingURL=alpha.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.ts"],"sourcesContent":["/*\n * Copyright 2023 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\n/**\n * @packageDocumentation\n * A module for the search backend that exports Explore modules.\n */\n\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { TaskScheduleDefinition } from '@backstage/backend-tasks';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';\n\nimport { ToolDocumentCollatorFactory } from '@backstage/plugin-search-backend-module-explore';\n\n/**\n * Options for {@link searchModuleExploreCollator}.\n *\n * @alpha\n */\nexport type SearchModuleExploreCollatorOptions = {\n schedule?: TaskScheduleDefinition;\n};\n\n/**\n * Search backend module for the Explore index.\n *\n * @alpha\n */\nexport const searchModuleExploreCollator = createBackendModule(\n (options?: SearchModuleExploreCollatorOptions) => ({\n moduleId: 'exploreCollator',\n pluginId: 'search',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n logger: coreServices.logger,\n discovery: coreServices.discovery,\n scheduler: coreServices.scheduler,\n tokenManager: coreServices.tokenManager,\n indexRegistry: searchIndexRegistryExtensionPoint,\n },\n async init({\n config,\n logger,\n discovery,\n scheduler,\n indexRegistry,\n tokenManager,\n }) {\n const defaultSchedule = {\n frequency: { minutes: 10 },\n timeout: { minutes: 15 },\n initialDelay: { seconds: 3 },\n };\n\n indexRegistry.addCollator({\n schedule: scheduler.createScheduledTaskRunner(\n options?.schedule ?? defaultSchedule,\n ),\n factory: ToolDocumentCollatorFactory.fromConfig(config, {\n discovery,\n logger: loggerToWinstonLogger(logger),\n tokenManager,\n }),\n });\n },\n });\n },\n }),\n);\n"],"names":["createBackendModule","coreServices","searchIndexRegistryExtensionPoint","ToolDocumentCollatorFactory","loggerToWinstonLogger"],"mappings":";;;;;;;;;AA6CO,MAAM,2BAA8B,GAAAA,oCAAA;AAAA,EACzC,CAAC,OAAkD,MAAA;AAAA,IACjD,QAAU,EAAA,iBAAA;AAAA,IACV,QAAU,EAAA,QAAA;AAAA,IACV,SAAS,GAAK,EAAA;AACZ,MAAA,GAAA,CAAI,YAAa,CAAA;AAAA,QACf,IAAM,EAAA;AAAA,UACJ,QAAQC,6BAAa,CAAA,UAAA;AAAA,UACrB,QAAQA,6BAAa,CAAA,MAAA;AAAA,UACrB,WAAWA,6BAAa,CAAA,SAAA;AAAA,UACxB,WAAWA,6BAAa,CAAA,SAAA;AAAA,UACxB,cAAcA,6BAAa,CAAA,YAAA;AAAA,UAC3B,aAAe,EAAAC,uCAAA;AAAA,SACjB;AAAA,QACA,MAAM,IAAK,CAAA;AAAA,UACT,MAAA;AAAA,UACA,MAAA;AAAA,UACA,SAAA;AAAA,UACA,SAAA;AAAA,UACA,aAAA;AAAA,UACA,YAAA;AAAA,SACC,EAAA;AAlEX,UAAA,IAAA,EAAA,CAAA;AAmEU,UAAA,MAAM,eAAkB,GAAA;AAAA,YACtB,SAAA,EAAW,EAAE,OAAA,EAAS,EAAG,EAAA;AAAA,YACzB,OAAA,EAAS,EAAE,OAAA,EAAS,EAAG,EAAA;AAAA,YACvB,YAAA,EAAc,EAAE,OAAA,EAAS,CAAE,EAAA;AAAA,WAC7B,CAAA;AAEA,UAAA,aAAA,CAAc,WAAY,CAAA;AAAA,YACxB,UAAU,SAAU,CAAA,yBAAA;AAAA,cAClB,CAAA,EAAA,GAAA,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAS,aAAT,IAAqB,GAAA,EAAA,GAAA,eAAA;AAAA,aACvB;AAAA,YACA,OAAA,EAASC,4DAA4B,CAAA,UAAA,CAAW,MAAQ,EAAA;AAAA,cACtD,SAAA;AAAA,cACA,MAAA,EAAQC,oCAAsB,MAAM,CAAA;AAAA,cACpC,YAAA;AAAA,aACD,CAAA;AAAA,WACF,CAAA,CAAA;AAAA,SACH;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.ts"],"sourcesContent":["/*\n * Copyright 2023 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\n/**\n * @packageDocumentation\n * A module for the search backend that exports Explore modules.\n */\n\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';\n\nimport { ToolDocumentCollatorFactory } from '@backstage/plugin-search-backend-module-explore';\nimport { readTaskScheduleDefinitionFromConfig } from '@backstage/backend-tasks';\n\n/**\n * Search backend module for the Explore index.\n *\n * @alpha\n */\nexport const searchModuleExploreCollator = createBackendModule({\n moduleId: 'exploreCollator',\n pluginId: 'search',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n logger: coreServices.logger,\n discovery: coreServices.discovery,\n scheduler: coreServices.scheduler,\n tokenManager: coreServices.tokenManager,\n indexRegistry: searchIndexRegistryExtensionPoint,\n },\n async init({\n config,\n logger,\n discovery,\n scheduler,\n indexRegistry,\n tokenManager,\n }) {\n const defaultSchedule = {\n frequency: { minutes: 10 },\n timeout: { minutes: 15 },\n initialDelay: { seconds: 3 },\n };\n\n const schedule = config.has('search.collators.explore.schedule')\n ? readTaskScheduleDefinitionFromConfig(\n config.getConfig('search.collators.explore.schedule'),\n )\n : defaultSchedule;\n\n indexRegistry.addCollator({\n schedule: scheduler.createScheduledTaskRunner(schedule),\n factory: ToolDocumentCollatorFactory.fromConfig(config, {\n discovery,\n logger: loggerToWinstonLogger(logger),\n tokenManager,\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","coreServices","searchIndexRegistryExtensionPoint","readTaskScheduleDefinitionFromConfig","ToolDocumentCollatorFactory","loggerToWinstonLogger"],"mappings":";;;;;;;;;;AAoCO,MAAM,8BAA8BA,oCAAoB,CAAA;AAAA,EAC7D,QAAU,EAAA,iBAAA;AAAA,EACV,QAAU,EAAA,QAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,UAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,MAAA;AAAA,QACrB,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,cAAcA,6BAAa,CAAA,YAAA;AAAA,QAC3B,aAAe,EAAAC,uCAAA;AAAA,OACjB;AAAA,MACA,MAAM,IAAK,CAAA;AAAA,QACT,MAAA;AAAA,QACA,MAAA;AAAA,QACA,SAAA;AAAA,QACA,SAAA;AAAA,QACA,aAAA;AAAA,QACA,YAAA;AAAA,OACC,EAAA;AACD,QAAA,MAAM,eAAkB,GAAA;AAAA,UACtB,SAAA,EAAW,EAAE,OAAA,EAAS,EAAG,EAAA;AAAA,UACzB,OAAA,EAAS,EAAE,OAAA,EAAS,EAAG,EAAA;AAAA,UACvB,YAAA,EAAc,EAAE,OAAA,EAAS,CAAE,EAAA;AAAA,SAC7B,CAAA;AAEA,QAAA,MAAM,QAAW,GAAA,MAAA,CAAO,GAAI,CAAA,mCAAmC,CAC3D,GAAAC,iDAAA;AAAA,UACE,MAAA,CAAO,UAAU,mCAAmC,CAAA;AAAA,SAEtD,GAAA,eAAA,CAAA;AAEJ,QAAA,aAAA,CAAc,WAAY,CAAA;AAAA,UACxB,QAAA,EAAU,SAAU,CAAA,yBAAA,CAA0B,QAAQ,CAAA;AAAA,UACtD,OAAA,EAASC,4DAA4B,CAAA,UAAA,CAAW,MAAQ,EAAA;AAAA,YACtD,SAAA;AAAA,YACA,MAAA,EAAQC,oCAAsB,MAAM,CAAA;AAAA,YACpC,YAAA;AAAA,WACD,CAAA;AAAA,SACF,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
package/dist/alpha.d.ts CHANGED
@@ -1,19 +1,10 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
- import { TaskScheduleDefinition } from '@backstage/backend-tasks';
3
2
 
4
- /**
5
- * Options for {@link searchModuleExploreCollator}.
6
- *
7
- * @alpha
8
- */
9
- type SearchModuleExploreCollatorOptions = {
10
- schedule?: TaskScheduleDefinition;
11
- };
12
3
  /**
13
4
  * Search backend module for the Explore index.
14
5
  *
15
6
  * @alpha
16
7
  */
17
- declare const searchModuleExploreCollator: (options?: SearchModuleExploreCollatorOptions | undefined) => _backstage_backend_plugin_api.BackendFeature;
8
+ declare const searchModuleExploreCollator: () => _backstage_backend_plugin_api.BackendFeature;
18
9
 
19
- export { SearchModuleExploreCollatorOptions, searchModuleExploreCollator };
10
+ export { searchModuleExploreCollator };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-search-backend-module-explore",
3
3
  "description": "A module for the search backend that exports explore modules",
4
- "version": "0.1.4-next.2",
4
+ "version": "0.1.4",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -40,23 +40,25 @@
40
40
  "clean": "backstage-cli package clean"
41
41
  },
42
42
  "dependencies": {
43
- "@backstage/backend-common": "^0.19.2-next.2",
44
- "@backstage/backend-plugin-api": "^0.6.0-next.2",
45
- "@backstage/backend-tasks": "^0.5.5-next.2",
43
+ "@backstage/backend-common": "^0.19.2",
44
+ "@backstage/backend-plugin-api": "^0.6.0",
45
+ "@backstage/backend-tasks": "^0.5.5",
46
46
  "@backstage/config": "^1.0.8",
47
47
  "@backstage/plugin-explore-common": "^0.0.1",
48
- "@backstage/plugin-search-backend-node": "^1.2.4-next.2",
48
+ "@backstage/plugin-search-backend-node": "^1.2.4",
49
49
  "@backstage/plugin-search-common": "^1.2.5",
50
50
  "node-fetch": "^2.6.7",
51
51
  "winston": "^3.2.1"
52
52
  },
53
53
  "devDependencies": {
54
- "@backstage/backend-test-utils": "^0.2.0-next.2",
55
- "@backstage/cli": "^0.22.10-next.1",
54
+ "@backstage/backend-test-utils": "^0.2.0",
55
+ "@backstage/cli": "^0.22.10",
56
56
  "msw": "^1.2.1"
57
57
  },
58
58
  "files": [
59
59
  "dist",
60
+ "config.d.ts",
60
61
  "alpha"
61
- ]
62
+ ],
63
+ "configSchema": "config.d.ts"
62
64
  }