@backstage/plugin-search-backend-module-catalog 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,28 @@
1
1
  # @backstage/plugin-search-backend-module-catalog
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
+ - ec1032129e47: Breaking change in the alpha export `searchModuleCatalogCollator`: Moved collator settings from module options into app-config. You are now expected to set up the catalog collator under the `search.collators.catalog` configuration key. There is also a new `catalogCollatorExtensionPoint` extension point for the module, wherein you can set custom transformers.
11
+ - d4f19a16bd52: Add User Entity email to the search index so that users can be found by their email.
12
+ - Updated dependencies
13
+ - @backstage/backend-common@0.19.2
14
+ - @backstage/backend-plugin-api@0.6.0
15
+ - @backstage/plugin-search-backend-node@1.2.4
16
+ - @backstage/plugin-catalog-node@1.4.1
17
+ - @backstage/backend-tasks@0.5.5
18
+ - @backstage/catalog-client@1.4.3
19
+ - @backstage/catalog-model@1.4.1
20
+ - @backstage/config@1.0.8
21
+ - @backstage/errors@1.2.1
22
+ - @backstage/plugin-catalog-common@1.0.15
23
+ - @backstage/plugin-permission-common@0.7.7
24
+ - @backstage/plugin-search-common@1.2.5
25
+
3
26
  ## 0.1.4-next.2
4
27
 
5
28
  ### Patch Changes
package/README.md CHANGED
@@ -2,11 +2,18 @@
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 catalog backend modules responsible for extending search.
5
+ This package exports a module that extends the search backend to also indexing the entities of your catalog.
6
6
 
7
- ## Example
7
+ ## Installation
8
8
 
9
- ### Use default schedule
9
+ Add the module package as a dependency:
10
+
11
+ ```bash
12
+ # From your Backstage root directory
13
+ yarn add --cwd packages/backend @backstage/plugin-search-backend-module-catalog
14
+ ```
15
+
16
+ Add the collator to your backend instance, along with the search plugin itself:
10
17
 
11
18
  ```tsx
12
19
  // packages/backend-next/src/index.ts
@@ -20,22 +27,50 @@ backend.add(searchModuleCatalogCollator());
20
27
  backend.start();
21
28
  ```
22
29
 
23
- ### Use custom schedule
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.catalog` key. See [the config definition file](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-catalog/config.d.ts) for more details.
31
+
32
+ ## Advanced Customizations
33
+
34
+ This module also has an extension point, which lets you inject advanced customizations. Here's an example of how to leverage that extension point to tweak the transformer used for building the search indexer documents:
24
35
 
25
36
  ```tsx
26
37
  // packages/backend-next/src/index.ts
27
38
  import { createBackend } from '@backstage/backend-defaults';
39
+ import { createBackendModule } from '@backstage/backend-plugin-api';
28
40
  import { searchPlugin } from '@backstage/plugin-search-backend/alpha';
29
- import { searchModuleCatalogCollator } from '@backstage/plugin-search-backend-module-catalog/alpha';
41
+ import { CatalogCollatorEntityTransformer } from '@backstage/plugin-search-backend-module-catalog';
42
+ import {
43
+ searchModuleCatalogCollator,
44
+ catalogCollatorExtensionPoint,
45
+ } from '@backstage/plugin-search-backend-module-catalog/alpha';
30
46
 
31
- const schedule = {
32
- frequency: { minutes: 10 },
33
- timeout: { minutes: 15 },
34
- initialDelay: { seconds: 3 },
35
- };
47
+ const customTransformer: CatalogCollatorEntityTransformer = entity => ({
48
+ title: entity.metadata.title || entity.metadata.name,
49
+ text: entity.metadata.description || '',
50
+ componentType: entity.spec?.type?.toString() || 'other',
51
+ type: entity.spec?.type?.toString() || 'other',
52
+ namespace: entity.metadata.namespace || 'default',
53
+ kind: entity.kind,
54
+ lifecycle: (entity.spec?.lifecycle as string) || '',
55
+ owner: (entity.spec?.owner as string) || '',
56
+ });
36
57
 
37
58
  const backend = createBackend();
38
59
  backend.add(searchPlugin());
39
- backend.add(searchModuleCatalogCollator({ schedule }));
60
+ backend.add(searchModuleCatalogCollator());
61
+ backend.add(
62
+ createBackendModule({
63
+ pluginId: 'search',
64
+ moduleId: 'myCatalogCollatorOptions',
65
+ register(reg) {
66
+ reg.registerInit({
67
+ deps: { collator: catalogCollatorExtensionPoint },
68
+ init({ collator }) {
69
+ collator.setEntityTransformer(customTransformer);
70
+ },
71
+ });
72
+ },
73
+ })(),
74
+ );
40
75
  backend.start();
41
76
  ```
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-search-backend-module-catalog",
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,55 @@
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-catalog`
24
+ */
25
+ catalog?: {
26
+ /**
27
+ * A templating string with placeholders, to form the final location of
28
+ * the entity.
29
+ *
30
+ * Defaults to '/catalog/:namespace/:kind/:name'
31
+ */
32
+ locationTemplate?: string;
33
+ /**
34
+ * A filter expression passed to the catalog client, to select what
35
+ * entities to collate.
36
+ *
37
+ * Defaults to no filter, ie indexing all entities.
38
+ */
39
+ filter?: object;
40
+ /**
41
+ * The number of entities to process at a time. Keep this at a
42
+ * reasonable number to avoid overloading either the catalog or the
43
+ * search backend.
44
+ *
45
+ * Defaults to 500
46
+ */
47
+ batchSize?: number;
48
+ /**
49
+ * The schedule for how often to run the collation job.
50
+ */
51
+ schedule?: TaskScheduleDefinitionConfig;
52
+ };
53
+ };
54
+ };
55
+ }
package/dist/alpha.cjs.js CHANGED
@@ -3,54 +3,62 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
- var alpha = require('@backstage/plugin-search-backend-node/alpha');
7
- var pluginSearchBackendModuleCatalog = require('@backstage/plugin-search-backend-module-catalog');
8
6
  var alpha$1 = require('@backstage/plugin-catalog-node/alpha');
7
+ var pluginSearchBackendModuleCatalog = require('@backstage/plugin-search-backend-module-catalog');
8
+ var alpha = require('@backstage/plugin-search-backend-node/alpha');
9
+ var config = require('./cjs/config-6c7298b0.cjs.js');
10
+ require('@backstage/backend-tasks');
11
+ require('@backstage/errors');
9
12
 
10
- const searchModuleCatalogCollator = backendPluginApi.createBackendModule(
11
- (options) => ({
12
- moduleId: "catalogCollator",
13
- pluginId: "search",
14
- register(env) {
15
- env.registerInit({
16
- deps: {
17
- config: backendPluginApi.coreServices.rootConfig,
18
- discovery: backendPluginApi.coreServices.discovery,
19
- tokenManager: backendPluginApi.coreServices.tokenManager,
20
- scheduler: backendPluginApi.coreServices.scheduler,
21
- indexRegistry: alpha.searchIndexRegistryExtensionPoint,
22
- catalog: alpha$1.catalogServiceRef
23
- },
24
- async init({
25
- config,
26
- discovery,
27
- tokenManager,
28
- scheduler,
29
- indexRegistry,
30
- catalog
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: pluginSearchBackendModuleCatalog.DefaultCatalogCollatorFactory.fromConfig(config, {
43
- ...options,
44
- discovery,
45
- tokenManager,
46
- catalogClient: catalog
47
- })
48
- });
13
+ const catalogCollatorExtensionPoint = backendPluginApi.createExtensionPoint({
14
+ id: "search.catalogCollator.extension"
15
+ });
16
+ const searchModuleCatalogCollator = backendPluginApi.createBackendModule({
17
+ moduleId: "catalogCollator",
18
+ pluginId: "search",
19
+ register(env) {
20
+ let entityTransformer;
21
+ env.registerExtensionPoint(catalogCollatorExtensionPoint, {
22
+ setEntityTransformer(transformer) {
23
+ if (entityTransformer) {
24
+ throw new Error("setEntityTransformer can only be called once");
49
25
  }
50
- });
51
- }
52
- })
53
- );
26
+ entityTransformer = transformer;
27
+ }
28
+ });
29
+ env.registerInit({
30
+ deps: {
31
+ config: backendPluginApi.coreServices.rootConfig,
32
+ discovery: backendPluginApi.coreServices.discovery,
33
+ tokenManager: backendPluginApi.coreServices.tokenManager,
34
+ scheduler: backendPluginApi.coreServices.scheduler,
35
+ indexRegistry: alpha.searchIndexRegistryExtensionPoint,
36
+ catalog: alpha$1.catalogServiceRef
37
+ },
38
+ async init({
39
+ config: config$1,
40
+ discovery,
41
+ tokenManager,
42
+ scheduler,
43
+ indexRegistry,
44
+ catalog
45
+ }) {
46
+ indexRegistry.addCollator({
47
+ schedule: scheduler.createScheduledTaskRunner(
48
+ config.readScheduleConfigOptions(config$1)
49
+ ),
50
+ factory: pluginSearchBackendModuleCatalog.DefaultCatalogCollatorFactory.fromConfig(config$1, {
51
+ entityTransformer,
52
+ discovery,
53
+ tokenManager,
54
+ catalogClient: catalog
55
+ })
56
+ });
57
+ }
58
+ });
59
+ }
60
+ });
54
61
 
62
+ exports.catalogCollatorExtensionPoint = catalogCollatorExtensionPoint;
55
63
  exports.searchModuleCatalogCollator = searchModuleCatalogCollator;
56
64
  //# 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 Catalog modules.\n */\n\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { TaskScheduleDefinition } from '@backstage/backend-tasks';\nimport { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';\n\nimport {\n DefaultCatalogCollatorFactory,\n DefaultCatalogCollatorFactoryOptions,\n} from '@backstage/plugin-search-backend-module-catalog';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\n\n/**\n * @alpha\n * Options for {@link searchModuleCatalogCollator}.\n */\nexport type SearchModuleCatalogCollatorOptions = Omit<\n DefaultCatalogCollatorFactoryOptions,\n 'discovery' | 'tokenManager' | 'catalogClient'\n> & {\n schedule?: TaskScheduleDefinition;\n};\n\n/**\n * Search backend module for the Catalog index.\n *\n * @alpha\n */\nexport const searchModuleCatalogCollator = createBackendModule(\n (options?: SearchModuleCatalogCollatorOptions) => ({\n moduleId: 'catalogCollator',\n pluginId: 'search',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n discovery: coreServices.discovery,\n tokenManager: coreServices.tokenManager,\n scheduler: coreServices.scheduler,\n indexRegistry: searchIndexRegistryExtensionPoint,\n catalog: catalogServiceRef,\n },\n async init({\n config,\n discovery,\n tokenManager,\n scheduler,\n indexRegistry,\n catalog,\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: DefaultCatalogCollatorFactory.fromConfig(config, {\n ...options,\n discovery,\n tokenManager,\n catalogClient: catalog,\n }),\n });\n },\n });\n },\n }),\n);\n"],"names":["createBackendModule","coreServices","searchIndexRegistryExtensionPoint","catalogServiceRef","DefaultCatalogCollatorFactory"],"mappings":";;;;;;;;;AAkDO,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,WAAWA,6BAAa,CAAA,SAAA;AAAA,UACxB,cAAcA,6BAAa,CAAA,YAAA;AAAA,UAC3B,WAAWA,6BAAa,CAAA,SAAA;AAAA,UACxB,aAAe,EAAAC,uCAAA;AAAA,UACf,OAAS,EAAAC,yBAAA;AAAA,SACX;AAAA,QACA,MAAM,IAAK,CAAA;AAAA,UACT,MAAA;AAAA,UACA,SAAA;AAAA,UACA,YAAA;AAAA,UACA,SAAA;AAAA,UACA,aAAA;AAAA,UACA,OAAA;AAAA,SACC,EAAA;AAvEX,UAAA,IAAA,EAAA,CAAA;AAwEU,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,8DAA8B,CAAA,UAAA,CAAW,MAAQ,EAAA;AAAA,cACxD,GAAG,OAAA;AAAA,cACH,SAAA;AAAA,cACA,YAAA;AAAA,cACA,aAAe,EAAA,OAAA;AAAA,aAChB,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 Catalog modules.\n */\n\nimport {\n coreServices,\n createBackendModule,\n createExtensionPoint,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\nimport {\n CatalogCollatorEntityTransformer,\n DefaultCatalogCollatorFactory,\n} from '@backstage/plugin-search-backend-module-catalog';\nimport { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';\nimport { readScheduleConfigOptions } from './collators/config';\n\n/**\n * Options for {@link catalogCollatorExtensionPoint}.\n *\n * @alpha\n */\nexport type CatalogCollatorExtensionPoint = {\n /**\n * Allows you to customize how entities are shaped into documents.\n */\n setEntityTransformer(transformer: CatalogCollatorEntityTransformer): void;\n};\n\n/**\n * Extension point for customizing how catalog entities are shaped into\n * documents for the search backend, when using\n * {@link searchModuleCatalogCollator}.\n *\n * @alpha\n */\nexport const catalogCollatorExtensionPoint =\n createExtensionPoint<CatalogCollatorExtensionPoint>({\n id: 'search.catalogCollator.extension',\n });\n\n/**\n * Search backend module for the Catalog index.\n *\n * @alpha\n */\nexport const searchModuleCatalogCollator = createBackendModule({\n moduleId: 'catalogCollator',\n pluginId: 'search',\n register(env) {\n let entityTransformer: CatalogCollatorEntityTransformer | undefined;\n\n env.registerExtensionPoint(catalogCollatorExtensionPoint, {\n setEntityTransformer(transformer) {\n if (entityTransformer) {\n throw new Error('setEntityTransformer can only be called once');\n }\n entityTransformer = transformer;\n },\n });\n\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n discovery: coreServices.discovery,\n tokenManager: coreServices.tokenManager,\n scheduler: coreServices.scheduler,\n indexRegistry: searchIndexRegistryExtensionPoint,\n catalog: catalogServiceRef,\n },\n async init({\n config,\n discovery,\n tokenManager,\n scheduler,\n indexRegistry,\n catalog,\n }) {\n indexRegistry.addCollator({\n schedule: scheduler.createScheduledTaskRunner(\n readScheduleConfigOptions(config),\n ),\n factory: DefaultCatalogCollatorFactory.fromConfig(config, {\n entityTransformer,\n discovery,\n tokenManager,\n catalogClient: catalog,\n }),\n });\n },\n });\n },\n});\n"],"names":["createExtensionPoint","createBackendModule","coreServices","searchIndexRegistryExtensionPoint","catalogServiceRef","config","readScheduleConfigOptions","DefaultCatalogCollatorFactory"],"mappings":";;;;;;;;;;;;AAqDO,MAAM,gCACXA,qCAAoD,CAAA;AAAA,EAClD,EAAI,EAAA,kCAAA;AACN,CAAC,EAAA;AAOI,MAAM,8BAA8BC,oCAAoB,CAAA;AAAA,EAC7D,QAAU,EAAA,iBAAA;AAAA,EACV,QAAU,EAAA,QAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAI,IAAA,iBAAA,CAAA;AAEJ,IAAA,GAAA,CAAI,uBAAuB,6BAA+B,EAAA;AAAA,MACxD,qBAAqB,WAAa,EAAA;AAChC,QAAA,IAAI,iBAAmB,EAAA;AACrB,UAAM,MAAA,IAAI,MAAM,8CAA8C,CAAA,CAAA;AAAA,SAChE;AACA,QAAoB,iBAAA,GAAA,WAAA,CAAA;AAAA,OACtB;AAAA,KACD,CAAA,CAAA;AAED,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,UAAA;AAAA,QACrB,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,cAAcA,6BAAa,CAAA,YAAA;AAAA,QAC3B,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,aAAe,EAAAC,uCAAA;AAAA,QACf,OAAS,EAAAC,yBAAA;AAAA,OACX;AAAA,MACA,MAAM,IAAK,CAAA;AAAA,gBACTC,QAAA;AAAA,QACA,SAAA;AAAA,QACA,YAAA;AAAA,QACA,SAAA;AAAA,QACA,aAAA;AAAA,QACA,OAAA;AAAA,OACC,EAAA;AACD,QAAA,aAAA,CAAc,WAAY,CAAA;AAAA,UACxB,UAAU,SAAU,CAAA,yBAAA;AAAA,YAClBC,iCAA0BD,QAAM,CAAA;AAAA,WAClC;AAAA,UACA,OAAA,EAASE,8DAA8B,CAAA,UAAA,CAAWF,QAAQ,EAAA;AAAA,YACxD,iBAAA;AAAA,YACA,SAAA;AAAA,YACA,YAAA;AAAA,YACA,aAAe,EAAA,OAAA;AAAA,WAChB,CAAA;AAAA,SACF,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
package/dist/alpha.d.ts CHANGED
@@ -1,19 +1,30 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
- import { TaskScheduleDefinition } from '@backstage/backend-tasks';
3
- import { DefaultCatalogCollatorFactoryOptions } from '@backstage/plugin-search-backend-module-catalog';
2
+ import { CatalogCollatorEntityTransformer } from '@backstage/plugin-search-backend-module-catalog';
4
3
 
5
4
  /**
5
+ * Options for {@link catalogCollatorExtensionPoint}.
6
+ *
6
7
  * @alpha
7
- * Options for {@link searchModuleCatalogCollator}.
8
8
  */
9
- type SearchModuleCatalogCollatorOptions = Omit<DefaultCatalogCollatorFactoryOptions, 'discovery' | 'tokenManager' | 'catalogClient'> & {
10
- schedule?: TaskScheduleDefinition;
9
+ type CatalogCollatorExtensionPoint = {
10
+ /**
11
+ * Allows you to customize how entities are shaped into documents.
12
+ */
13
+ setEntityTransformer(transformer: CatalogCollatorEntityTransformer): void;
11
14
  };
15
+ /**
16
+ * Extension point for customizing how catalog entities are shaped into
17
+ * documents for the search backend, when using
18
+ * {@link searchModuleCatalogCollator}.
19
+ *
20
+ * @alpha
21
+ */
22
+ declare const catalogCollatorExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<CatalogCollatorExtensionPoint>;
12
23
  /**
13
24
  * Search backend module for the Catalog index.
14
25
  *
15
26
  * @alpha
16
27
  */
17
- declare const searchModuleCatalogCollator: (options?: SearchModuleCatalogCollatorOptions | undefined) => _backstage_backend_plugin_api.BackendFeature;
28
+ declare const searchModuleCatalogCollator: () => _backstage_backend_plugin_api.BackendFeature;
18
29
 
19
- export { SearchModuleCatalogCollatorOptions, searchModuleCatalogCollator };
30
+ export { CatalogCollatorExtensionPoint, catalogCollatorExtensionPoint, searchModuleCatalogCollator };
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var backendTasks = require('@backstage/backend-tasks');
4
+ var errors = require('@backstage/errors');
5
+
6
+ const configKey = "search.collators.catalog";
7
+ const defaults = {
8
+ schedule: {
9
+ frequency: { minutes: 10 },
10
+ timeout: { minutes: 15 },
11
+ initialDelay: { seconds: 3 }
12
+ },
13
+ collatorOptions: {
14
+ locationTemplate: "/catalog/:namespace/:kind/:name",
15
+ filter: void 0,
16
+ batchSize: 500
17
+ }
18
+ };
19
+ function readScheduleConfigOptions(configRoot) {
20
+ let schedule = void 0;
21
+ const config = configRoot.getOptionalConfig(configKey);
22
+ if (config) {
23
+ const scheduleConfig = config.getOptionalConfig("schedule");
24
+ if (scheduleConfig) {
25
+ try {
26
+ schedule = backendTasks.readTaskScheduleDefinitionFromConfig(scheduleConfig);
27
+ } catch (error) {
28
+ throw new errors.InputError(`Invalid schedule at ${configKey}, ${error}`);
29
+ }
30
+ }
31
+ }
32
+ return schedule != null ? schedule : defaults.schedule;
33
+ }
34
+ function readCollatorConfigOptions(configRoot) {
35
+ var _a, _b, _c, _d;
36
+ const config = configRoot.getOptionalConfig(configKey);
37
+ if (!config) {
38
+ return defaults.collatorOptions;
39
+ }
40
+ return {
41
+ locationTemplate: (_a = config.getOptionalString("locationTemplate")) != null ? _a : defaults.collatorOptions.locationTemplate,
42
+ filter: (_c = (_b = config.getOptionalConfig("filter")) == null ? void 0 : _b.get()) != null ? _c : defaults.collatorOptions.filter,
43
+ batchSize: (_d = config.getOptionalNumber("batchSize")) != null ? _d : defaults.collatorOptions.batchSize
44
+ };
45
+ }
46
+
47
+ exports.readCollatorConfigOptions = readCollatorConfigOptions;
48
+ exports.readScheduleConfigOptions = readScheduleConfigOptions;
49
+ //# sourceMappingURL=config-6c7298b0.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-6c7298b0.cjs.js","sources":["../../src/collators/config.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\nimport {\n readTaskScheduleDefinitionFromConfig,\n TaskScheduleDefinition,\n} from '@backstage/backend-tasks';\nimport { EntityFilterQuery } from '@backstage/catalog-client';\nimport { Config } from '@backstage/config';\nimport { InputError } from '@backstage/errors';\n\nconst configKey = 'search.collators.catalog';\n\nexport const defaults = {\n schedule: {\n frequency: { minutes: 10 },\n timeout: { minutes: 15 },\n initialDelay: { seconds: 3 },\n },\n collatorOptions: {\n locationTemplate: '/catalog/:namespace/:kind/:name',\n filter: undefined,\n batchSize: 500,\n },\n};\n\nexport function readScheduleConfigOptions(\n configRoot: Config,\n): TaskScheduleDefinition {\n let schedule: TaskScheduleDefinition | undefined = undefined;\n\n const config = configRoot.getOptionalConfig(configKey);\n if (config) {\n const scheduleConfig = config.getOptionalConfig('schedule');\n if (scheduleConfig) {\n try {\n schedule = readTaskScheduleDefinitionFromConfig(scheduleConfig);\n } catch (error) {\n throw new InputError(`Invalid schedule at ${configKey}, ${error}`);\n }\n }\n }\n\n return schedule ?? defaults.schedule;\n}\n\nexport function readCollatorConfigOptions(configRoot: Config): {\n locationTemplate: string;\n filter: EntityFilterQuery | undefined;\n batchSize: number;\n} {\n const config = configRoot.getOptionalConfig(configKey);\n if (!config) {\n return defaults.collatorOptions;\n }\n\n return {\n locationTemplate:\n config.getOptionalString('locationTemplate') ??\n defaults.collatorOptions.locationTemplate,\n filter:\n config.getOptionalConfig('filter')?.get<EntityFilterQuery>() ??\n defaults.collatorOptions.filter,\n batchSize:\n config.getOptionalNumber('batchSize') ??\n defaults.collatorOptions.batchSize,\n };\n}\n"],"names":["readTaskScheduleDefinitionFromConfig","InputError"],"mappings":";;;;;AAwBA,MAAM,SAAY,GAAA,0BAAA,CAAA;AAEX,MAAM,QAAW,GAAA;AAAA,EACtB,QAAU,EAAA;AAAA,IACR,SAAA,EAAW,EAAE,OAAA,EAAS,EAAG,EAAA;AAAA,IACzB,OAAA,EAAS,EAAE,OAAA,EAAS,EAAG,EAAA;AAAA,IACvB,YAAA,EAAc,EAAE,OAAA,EAAS,CAAE,EAAA;AAAA,GAC7B;AAAA,EACA,eAAiB,EAAA;AAAA,IACf,gBAAkB,EAAA,iCAAA;AAAA,IAClB,MAAQ,EAAA,KAAA,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AAgB,CAAA,MAAA;AAAA,IAC3B,YACE,EAAO,GAAA,MAAA,CAAA,iBAAA,CAAkB,WAAW,CAApC,KAAA,IAAA,GAAA,EAAA,GACA,SAAS,eAAgB,CAAA,SAAA;AAAA,GAC7B,CAAA;AACF;;;;;"}
package/dist/index.cjs.js CHANGED
@@ -3,12 +3,15 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var catalogClient = require('@backstage/catalog-client');
6
+ var catalogModel = require('@backstage/catalog-model');
6
7
  var alpha = require('@backstage/plugin-catalog-common/alpha');
7
8
  var stream = require('stream');
8
- var catalogModel = require('@backstage/catalog-model');
9
+ var config = require('./cjs/config-6c7298b0.cjs.js');
10
+ require('@backstage/backend-tasks');
11
+ require('@backstage/errors');
9
12
 
10
13
  const getDocumentText = (entity) => {
11
- var _a, _b;
14
+ var _a, _b, _c, _d;
12
15
  const documentTexts = [];
13
16
  documentTexts.push(entity.metadata.description || "");
14
17
  if (catalogModel.isUserEntity(entity) || catalogModel.isGroupEntity(entity)) {
@@ -16,6 +19,11 @@ const getDocumentText = (entity) => {
16
19
  documentTexts.push(entity.spec.profile.displayName);
17
20
  }
18
21
  }
22
+ if (catalogModel.isUserEntity(entity)) {
23
+ if ((_d = (_c = entity.spec) == null ? void 0 : _c.profile) == null ? void 0 : _d.email) {
24
+ documentTexts.push(entity.spec.profile.email);
25
+ }
26
+ }
19
27
  return documentTexts.join(" : ");
20
28
  };
21
29
  const defaultCatalogCollatorEntityTransformer = (entity) => {
@@ -57,15 +65,25 @@ class DefaultCatalogCollatorFactory {
57
65
  tokenManager,
58
66
  entityTransformer
59
67
  } = options;
60
- this.locationTemplate = locationTemplate || "/catalog/:namespace/:kind/:name";
68
+ this.locationTemplate = locationTemplate;
61
69
  this.filter = filter;
62
- this.batchSize = batchSize || 500;
70
+ this.batchSize = batchSize;
63
71
  this.catalogClient = catalogClient$1 || new catalogClient.CatalogClient({ discoveryApi: discovery });
64
72
  this.tokenManager = tokenManager;
65
73
  this.entityTransformer = entityTransformer != null ? entityTransformer : defaultCatalogCollatorEntityTransformer;
66
74
  }
67
- static fromConfig(_config, options) {
68
- return new DefaultCatalogCollatorFactory(options);
75
+ static fromConfig(configRoot, options) {
76
+ var _a, _b, _c;
77
+ const configOptions = config.readCollatorConfigOptions(configRoot);
78
+ return new DefaultCatalogCollatorFactory({
79
+ locationTemplate: (_a = options.locationTemplate) != null ? _a : configOptions.locationTemplate,
80
+ filter: (_b = options.filter) != null ? _b : configOptions.filter,
81
+ batchSize: (_c = options.batchSize) != null ? _c : configOptions.batchSize,
82
+ entityTransformer: options.entityTransformer,
83
+ discovery: options.discovery,
84
+ tokenManager: options.tokenManager,
85
+ catalogClient: options.catalogClient
86
+ });
69
87
  }
70
88
  async getCollator() {
71
89
  return stream.Readable.from(this.execute());
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/collators/defaultCatalogCollatorEntityTransformer.ts","../src/collators/DefaultCatalogCollatorFactory.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 { Entity, isGroupEntity, isUserEntity } from '@backstage/catalog-model';\nimport { CatalogCollatorEntityTransformer } from './CatalogCollatorEntityTransformer';\n\nconst getDocumentText = (entity: Entity): string => {\n const documentTexts: string[] = [];\n documentTexts.push(entity.metadata.description || '');\n\n if (isUserEntity(entity) || isGroupEntity(entity)) {\n if (entity.spec?.profile?.displayName) {\n documentTexts.push(entity.spec.profile.displayName);\n }\n }\n\n return documentTexts.join(' : ');\n};\n\n/** @public */\nexport const defaultCatalogCollatorEntityTransformer: CatalogCollatorEntityTransformer =\n (entity: Entity) => {\n return {\n title: entity.metadata.title ?? entity.metadata.name,\n text: getDocumentText(entity),\n componentType: entity.spec?.type?.toString() || 'other',\n type: entity.spec?.type?.toString() || 'other',\n namespace: entity.metadata.namespace || 'default',\n kind: entity.kind,\n lifecycle: (entity.spec?.lifecycle as string) || '',\n owner: (entity.spec?.owner as string) || '',\n };\n };\n","/*\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 { Config } from '@backstage/config';\nimport {\n PluginEndpointDiscovery,\n TokenManager,\n} from '@backstage/backend-common';\nimport {\n CatalogApi,\n CatalogClient,\n GetEntitiesRequest,\n} from '@backstage/catalog-client';\nimport { DocumentCollatorFactory } from '@backstage/plugin-search-common';\nimport { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha';\nimport { CatalogEntityDocument } from '@backstage/plugin-catalog-common';\nimport { Permission } from '@backstage/plugin-permission-common';\nimport { Readable } from 'stream';\nimport { CatalogCollatorEntityTransformer } from './CatalogCollatorEntityTransformer';\nimport { defaultCatalogCollatorEntityTransformer } from './defaultCatalogCollatorEntityTransformer';\nimport { stringifyEntityRef } from '@backstage/catalog-model';\n\n/** @public */\nexport type DefaultCatalogCollatorFactoryOptions = {\n discovery: PluginEndpointDiscovery;\n tokenManager: TokenManager;\n locationTemplate?: string;\n filter?: GetEntitiesRequest['filter'];\n batchSize?: number;\n catalogClient?: CatalogApi;\n entityTransformer?: CatalogCollatorEntityTransformer;\n};\n\n/** @public */\nexport class DefaultCatalogCollatorFactory implements DocumentCollatorFactory {\n public readonly type = 'software-catalog';\n public readonly visibilityPermission: Permission =\n catalogEntityReadPermission;\n\n private locationTemplate: string;\n private filter?: GetEntitiesRequest['filter'];\n private batchSize: number;\n private readonly catalogClient: CatalogApi;\n private tokenManager: TokenManager;\n private entityTransformer: CatalogCollatorEntityTransformer;\n\n static fromConfig(\n _config: Config,\n options: DefaultCatalogCollatorFactoryOptions,\n ) {\n return new DefaultCatalogCollatorFactory(options);\n }\n\n private constructor(options: DefaultCatalogCollatorFactoryOptions) {\n const {\n batchSize,\n discovery,\n locationTemplate,\n filter,\n catalogClient,\n tokenManager,\n entityTransformer,\n } = options;\n\n this.locationTemplate =\n locationTemplate || '/catalog/:namespace/:kind/:name';\n this.filter = filter;\n this.batchSize = batchSize || 500;\n this.catalogClient =\n catalogClient || new CatalogClient({ discoveryApi: discovery });\n this.tokenManager = tokenManager;\n this.entityTransformer =\n entityTransformer ?? defaultCatalogCollatorEntityTransformer;\n }\n\n async getCollator(): Promise<Readable> {\n return Readable.from(this.execute());\n }\n\n private async *execute(): AsyncGenerator<CatalogEntityDocument> {\n const { token } = await this.tokenManager.getToken();\n let entitiesRetrieved = 0;\n let moreEntitiesToGet = true;\n\n // Offset/limit pagination is used on the Catalog Client in order to\n // limit (and allow some control over) memory used by the search backend\n // at index-time.\n while (moreEntitiesToGet) {\n const entities = (\n await this.catalogClient.getEntities(\n {\n filter: this.filter,\n limit: this.batchSize,\n offset: entitiesRetrieved,\n },\n { token },\n )\n ).items;\n\n // Control looping through entity batches.\n moreEntitiesToGet = entities.length === this.batchSize;\n entitiesRetrieved += entities.length;\n\n for (const entity of entities) {\n yield {\n ...this.entityTransformer(entity),\n authorization: {\n resourceRef: stringifyEntityRef(entity),\n },\n location: this.applyArgsToFormat(this.locationTemplate, {\n namespace: entity.metadata.namespace || 'default',\n kind: entity.kind,\n name: entity.metadata.name,\n }),\n };\n }\n }\n }\n\n private applyArgsToFormat(\n format: string,\n args: Record<string, string>,\n ): string {\n let formatted = format;\n\n for (const [key, value] of Object.entries(args)) {\n formatted = formatted.replace(`:${key}`, value);\n }\n\n return formatted.toLowerCase();\n }\n}\n"],"names":["isUserEntity","isGroupEntity","catalogEntityReadPermission","catalogClient","CatalogClient","Readable","stringifyEntityRef"],"mappings":";;;;;;;;;AAmBA,MAAM,eAAA,GAAkB,CAAC,MAA2B,KAAA;AAnBpD,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAoBE,EAAA,MAAM,gBAA0B,EAAC,CAAA;AACjC,EAAA,aAAA,CAAc,IAAK,CAAA,MAAA,CAAO,QAAS,CAAA,WAAA,IAAe,EAAE,CAAA,CAAA;AAEpD,EAAA,IAAIA,yBAAa,CAAA,MAAM,CAAK,IAAAC,0BAAA,CAAc,MAAM,CAAG,EAAA;AACjD,IAAA,IAAA,CAAI,EAAO,GAAA,CAAA,EAAA,GAAA,MAAA,CAAA,IAAA,KAAP,IAAa,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAA,KAAb,mBAAsB,WAAa,EAAA;AACrC,MAAA,aAAA,CAAc,IAAK,CAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,WAAW,CAAA,CAAA;AAAA,KACpD;AAAA,GACF;AAEA,EAAO,OAAA,aAAA,CAAc,KAAK,KAAK,CAAA,CAAA;AACjC,CAAA,CAAA;AAGa,MAAA,uCAAA,GACX,CAAC,MAAmB,KAAA;AAlCtB,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAmCI,EAAO,OAAA;AAAA,IACL,QAAO,EAAO,GAAA,MAAA,CAAA,QAAA,CAAS,KAAhB,KAAA,IAAA,GAAA,EAAA,GAAyB,OAAO,QAAS,CAAA,IAAA;AAAA,IAChD,IAAA,EAAM,gBAAgB,MAAM,CAAA;AAAA,IAC5B,iBAAe,EAAO,GAAA,CAAA,EAAA,GAAA,MAAA,CAAA,IAAA,KAAP,IAAa,GAAA,KAAA,CAAA,GAAA,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,iBAAA,GAAA,QAAA,CAAS,WAAW,IAAK,CAAA,SAAA,CAAA;AAC7C,MAAA,iBAAA,IAAqB,QAAS,CAAA,MAAA,CAAA;AAE9B,MAAA,KAAA,MAAW,UAAU,QAAU,EAAA;AAC7B,QAAM,MAAA;AAAA,UACJ,GAAG,IAAK,CAAA,iBAAA,CAAkB,MAAM,CAAA;AAAA,UAChC,aAAe,EAAA;AAAA,YACb,WAAA,EAAaC,gCAAmB,MAAM,CAAA;AAAA,WACxC;AAAA,UACA,QAAU,EAAA,IAAA,CAAK,iBAAkB,CAAA,IAAA,CAAK,gBAAkB,EAAA;AAAA,YACtD,SAAA,EAAW,MAAO,CAAA,QAAA,CAAS,SAAa,IAAA,SAAA;AAAA,YACxC,MAAM,MAAO,CAAA,IAAA;AAAA,YACb,IAAA,EAAM,OAAO,QAAS,CAAA,IAAA;AAAA,WACvB,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACF;AAAA,GACF;AAAA,EAEQ,iBAAA,CACN,QACA,IACQ,EAAA;AACR,IAAA,IAAI,SAAY,GAAA,MAAA,CAAA;AAEhB,IAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,IAAI,CAAG,EAAA;AAC/C,MAAA,SAAA,GAAY,SAAU,CAAA,OAAA,CAAQ,CAAI,CAAA,EAAA,GAAG,IAAI,KAAK,CAAA,CAAA;AAAA,KAChD;AAEA,IAAA,OAAO,UAAU,WAAY,EAAA,CAAA;AAAA,GAC/B;AACF;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/collators/defaultCatalogCollatorEntityTransformer.ts","../src/collators/DefaultCatalogCollatorFactory.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 { Entity, isGroupEntity, isUserEntity } from '@backstage/catalog-model';\nimport { CatalogCollatorEntityTransformer } from './CatalogCollatorEntityTransformer';\n\nconst getDocumentText = (entity: Entity): string => {\n const documentTexts: string[] = [];\n documentTexts.push(entity.metadata.description || '');\n\n if (isUserEntity(entity) || isGroupEntity(entity)) {\n if (entity.spec?.profile?.displayName) {\n documentTexts.push(entity.spec.profile.displayName);\n }\n }\n\n if (isUserEntity(entity)) {\n if (entity.spec?.profile?.email) {\n documentTexts.push(entity.spec.profile.email);\n }\n }\n\n return documentTexts.join(' : ');\n};\n\n/** @public */\nexport const defaultCatalogCollatorEntityTransformer: CatalogCollatorEntityTransformer =\n (entity: Entity) => {\n return {\n title: entity.metadata.title ?? entity.metadata.name,\n text: getDocumentText(entity),\n componentType: entity.spec?.type?.toString() || 'other',\n type: entity.spec?.type?.toString() || 'other',\n namespace: entity.metadata.namespace || 'default',\n kind: entity.kind,\n lifecycle: (entity.spec?.lifecycle as string) || '',\n owner: (entity.spec?.owner as string) || '',\n };\n };\n","/*\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 PluginEndpointDiscovery,\n TokenManager,\n} from '@backstage/backend-common';\nimport {\n CatalogApi,\n CatalogClient,\n GetEntitiesRequest,\n} from '@backstage/catalog-client';\nimport { stringifyEntityRef } from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport { CatalogEntityDocument } from '@backstage/plugin-catalog-common';\nimport { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha';\nimport { Permission } from '@backstage/plugin-permission-common';\nimport { DocumentCollatorFactory } from '@backstage/plugin-search-common';\nimport { Readable } from 'stream';\nimport { CatalogCollatorEntityTransformer } from './CatalogCollatorEntityTransformer';\nimport { readCollatorConfigOptions } from './config';\nimport { defaultCatalogCollatorEntityTransformer } from './defaultCatalogCollatorEntityTransformer';\n\n/** @public */\nexport type DefaultCatalogCollatorFactoryOptions = {\n discovery: PluginEndpointDiscovery;\n tokenManager: TokenManager;\n /**\n * @deprecated Use the config key `search.collators.catalog.locationTemplate` instead.\n */\n locationTemplate?: string;\n /**\n * @deprecated Use the config key `search.collators.catalog.filter` instead.\n */\n filter?: GetEntitiesRequest['filter'];\n /**\n * @deprecated Use the config key `search.collators.catalog.batchSize` instead.\n */\n batchSize?: number;\n catalogClient?: CatalogApi;\n /**\n * Allows you to customize how entities are shaped into documents.\n */\n entityTransformer?: CatalogCollatorEntityTransformer;\n};\n\n/**\n * Collates entities from the Catalog into documents for the search backend.\n *\n * @public\n */\nexport class DefaultCatalogCollatorFactory implements DocumentCollatorFactory {\n public readonly type = 'software-catalog';\n public readonly visibilityPermission: Permission =\n catalogEntityReadPermission;\n\n private locationTemplate: string;\n private filter?: GetEntitiesRequest['filter'];\n private batchSize: number;\n private readonly catalogClient: CatalogApi;\n private tokenManager: TokenManager;\n private entityTransformer: CatalogCollatorEntityTransformer;\n\n static fromConfig(\n configRoot: Config,\n options: DefaultCatalogCollatorFactoryOptions,\n ) {\n const configOptions = readCollatorConfigOptions(configRoot);\n return new DefaultCatalogCollatorFactory({\n locationTemplate:\n options.locationTemplate ?? configOptions.locationTemplate,\n filter: options.filter ?? configOptions.filter,\n batchSize: options.batchSize ?? configOptions.batchSize,\n entityTransformer: options.entityTransformer,\n discovery: options.discovery,\n tokenManager: options.tokenManager,\n catalogClient: options.catalogClient,\n });\n }\n\n private constructor(options: {\n locationTemplate: string;\n filter: GetEntitiesRequest['filter'];\n batchSize: number;\n entityTransformer?: CatalogCollatorEntityTransformer;\n discovery: PluginEndpointDiscovery;\n tokenManager: TokenManager;\n catalogClient?: CatalogApi;\n }) {\n const {\n batchSize,\n discovery,\n locationTemplate,\n filter,\n catalogClient,\n tokenManager,\n entityTransformer,\n } = options;\n\n this.locationTemplate = locationTemplate;\n this.filter = filter;\n this.batchSize = batchSize;\n this.catalogClient =\n catalogClient || new CatalogClient({ discoveryApi: discovery });\n this.tokenManager = tokenManager;\n this.entityTransformer =\n entityTransformer ?? defaultCatalogCollatorEntityTransformer;\n }\n\n async getCollator(): Promise<Readable> {\n return Readable.from(this.execute());\n }\n\n private async *execute(): AsyncGenerator<CatalogEntityDocument> {\n const { token } = await this.tokenManager.getToken();\n let entitiesRetrieved = 0;\n let moreEntitiesToGet = true;\n\n // Offset/limit pagination is used on the Catalog Client in order to\n // limit (and allow some control over) memory used by the search backend\n // at index-time.\n while (moreEntitiesToGet) {\n const entities = (\n await this.catalogClient.getEntities(\n {\n filter: this.filter,\n limit: this.batchSize,\n offset: entitiesRetrieved,\n },\n { token },\n )\n ).items;\n\n // Control looping through entity batches.\n moreEntitiesToGet = entities.length === this.batchSize;\n entitiesRetrieved += entities.length;\n\n for (const entity of entities) {\n yield {\n ...this.entityTransformer(entity),\n authorization: {\n resourceRef: stringifyEntityRef(entity),\n },\n location: this.applyArgsToFormat(this.locationTemplate, {\n namespace: entity.metadata.namespace || 'default',\n kind: entity.kind,\n name: entity.metadata.name,\n }),\n };\n }\n }\n }\n\n private applyArgsToFormat(\n format: string,\n args: Record<string, string>,\n ): string {\n let formatted = format;\n\n for (const [key, value] of Object.entries(args)) {\n formatted = formatted.replace(`:${key}`, value);\n }\n\n return formatted.toLowerCase();\n }\n}\n"],"names":["isUserEntity","isGroupEntity","catalogEntityReadPermission","catalogClient","CatalogClient","readCollatorConfigOptions","Readable","stringifyEntityRef"],"mappings":";;;;;;;;;;;;AAmBA,MAAM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;AAAA,YACxC,MAAM,MAAO,CAAA,IAAA;AAAA,YACb,IAAA,EAAM,OAAO,QAAS,CAAA,IAAA;AAAA,WACvB,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACF;AAAA,GACF;AAAA,EAEQ,iBAAA,CACN,QACA,IACQ,EAAA;AACR,IAAA,IAAI,SAAY,GAAA,MAAA,CAAA;AAEhB,IAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,IAAI,CAAG,EAAA;AAC/C,MAAA,SAAA,GAAY,SAAU,CAAA,OAAA,CAAQ,CAAI,CAAA,EAAA,GAAG,IAAI,KAAK,CAAA,CAAA;AAAA,KAChD;AAEA,IAAA,OAAO,UAAU,WAAY,EAAA,CAAA;AAAA,GAC/B;AACF;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
- import { Config } from '@backstage/config';
3
2
  import { PluginEndpointDiscovery, TokenManager } from '@backstage/backend-common';
4
3
  import { GetEntitiesRequest, CatalogApi } from '@backstage/catalog-client';
5
- import { DocumentCollatorFactory } from '@backstage/plugin-search-common';
4
+ import { Config } from '@backstage/config';
6
5
  import { Permission } from '@backstage/plugin-permission-common';
6
+ import { DocumentCollatorFactory } from '@backstage/plugin-search-common';
7
7
  import { Readable } from 'stream';
8
8
  import { Entity } from '@backstage/catalog-model';
9
9
  import { CatalogEntityDocument } from '@backstage/plugin-catalog-common';
@@ -15,13 +15,29 @@ type CatalogCollatorEntityTransformer = (entity: Entity) => Omit<CatalogEntityDo
15
15
  type DefaultCatalogCollatorFactoryOptions = {
16
16
  discovery: PluginEndpointDiscovery;
17
17
  tokenManager: TokenManager;
18
+ /**
19
+ * @deprecated Use the config key `search.collators.catalog.locationTemplate` instead.
20
+ */
18
21
  locationTemplate?: string;
22
+ /**
23
+ * @deprecated Use the config key `search.collators.catalog.filter` instead.
24
+ */
19
25
  filter?: GetEntitiesRequest['filter'];
26
+ /**
27
+ * @deprecated Use the config key `search.collators.catalog.batchSize` instead.
28
+ */
20
29
  batchSize?: number;
21
30
  catalogClient?: CatalogApi;
31
+ /**
32
+ * Allows you to customize how entities are shaped into documents.
33
+ */
22
34
  entityTransformer?: CatalogCollatorEntityTransformer;
23
35
  };
24
- /** @public */
36
+ /**
37
+ * Collates entities from the Catalog into documents for the search backend.
38
+ *
39
+ * @public
40
+ */
25
41
  declare class DefaultCatalogCollatorFactory implements DocumentCollatorFactory {
26
42
  readonly type = "software-catalog";
27
43
  readonly visibilityPermission: Permission;
@@ -31,7 +47,7 @@ declare class DefaultCatalogCollatorFactory implements DocumentCollatorFactory {
31
47
  private readonly catalogClient;
32
48
  private tokenManager;
33
49
  private entityTransformer;
34
- static fromConfig(_config: Config, options: DefaultCatalogCollatorFactoryOptions): DefaultCatalogCollatorFactory;
50
+ static fromConfig(configRoot: Config, options: DefaultCatalogCollatorFactoryOptions): DefaultCatalogCollatorFactory;
35
51
  private constructor();
36
52
  getCollator(): Promise<Readable>;
37
53
  private execute;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-search-backend-module-catalog",
3
3
  "description": "A module for the search backend that exports catalog 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,26 +40,29 @@
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/catalog-client": "^1.4.3",
47
47
  "@backstage/catalog-model": "^1.4.1",
48
48
  "@backstage/config": "^1.0.8",
49
+ "@backstage/errors": "^1.2.1",
49
50
  "@backstage/plugin-catalog-common": "^1.0.15",
50
- "@backstage/plugin-catalog-node": "^1.4.1-next.2",
51
+ "@backstage/plugin-catalog-node": "^1.4.1",
51
52
  "@backstage/plugin-permission-common": "^0.7.7",
52
- "@backstage/plugin-search-backend-node": "^1.2.4-next.2",
53
+ "@backstage/plugin-search-backend-node": "^1.2.4",
53
54
  "@backstage/plugin-search-common": "^1.2.5"
54
55
  },
55
56
  "devDependencies": {
56
- "@backstage/backend-common": "^0.19.2-next.2",
57
- "@backstage/backend-test-utils": "^0.2.0-next.2",
58
- "@backstage/cli": "^0.22.10-next.1",
57
+ "@backstage/backend-common": "^0.19.2",
58
+ "@backstage/backend-test-utils": "^0.2.0",
59
+ "@backstage/cli": "^0.22.10",
59
60
  "msw": "^1.0.0"
60
61
  },
61
62
  "files": [
62
63
  "dist",
64
+ "config.d.ts",
63
65
  "alpha"
64
- ]
66
+ ],
67
+ "configSchema": "config.d.ts"
65
68
  }