@backstage/plugin-search-backend-module-catalog 0.3.7-next.0 → 0.3.7
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 +28 -0
- package/config.d.ts +1 -1
- package/dist/collators/DefaultCatalogCollatorFactory.cjs.js.map +1 -1
- package/dist/collators/config.cjs.js.map +1 -1
- package/dist/collators/defaultCatalogCollatorEntityTransformer.cjs.js.map +1 -1
- package/dist/module.cjs.js.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @backstage/plugin-search-backend-module-catalog
|
|
2
2
|
|
|
3
|
+
## 0.3.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d9bda0f: Allow filter to be an array in config schema
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/catalog-client@1.11.0
|
|
10
|
+
- @backstage/plugin-catalog-node@1.18.0
|
|
11
|
+
- @backstage/plugin-search-backend-node@1.3.14
|
|
12
|
+
- @backstage/backend-plugin-api@1.4.2
|
|
13
|
+
|
|
14
|
+
## 0.3.7-next.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- d9bda0f: Allow filter to be an array in config schema
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/backend-plugin-api@1.4.2-next.0
|
|
21
|
+
- @backstage/catalog-client@1.11.0-next.0
|
|
22
|
+
- @backstage/catalog-model@1.7.5
|
|
23
|
+
- @backstage/config@1.3.3
|
|
24
|
+
- @backstage/errors@1.2.7
|
|
25
|
+
- @backstage/plugin-catalog-common@1.1.5
|
|
26
|
+
- @backstage/plugin-catalog-node@1.18.0-next.0
|
|
27
|
+
- @backstage/plugin-permission-common@0.9.1
|
|
28
|
+
- @backstage/plugin-search-backend-node@1.3.14-next.0
|
|
29
|
+
- @backstage/plugin-search-common@1.2.19
|
|
30
|
+
|
|
3
31
|
## 0.3.7-next.0
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/config.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface Config {
|
|
|
36
36
|
*
|
|
37
37
|
* Defaults to no filter, ie indexing all entities.
|
|
38
38
|
*/
|
|
39
|
-
filter?: object;
|
|
39
|
+
filter?: object | object[];
|
|
40
40
|
/**
|
|
41
41
|
* The number of entities to process at a time. Keep this at a
|
|
42
42
|
* reasonable number to avoid overloading either the catalog or the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultCatalogCollatorFactory.cjs.js","sources":["../../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 { AuthService } from '@backstage/backend-plugin-api';\nimport { QueryEntitiesInitialRequest } 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 { CatalogService } from '@backstage/plugin-catalog-node';\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\nexport type DefaultCatalogCollatorFactoryOptions = {\n auth: AuthService;\n catalog: CatalogService;\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 */\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?: QueryEntitiesInitialRequest['filter'];\n private batchSize: number;\n private readonly catalog: CatalogService;\n private entityTransformer: CatalogCollatorEntityTransformer;\n private auth: AuthService;\n\n static fromConfig(\n configRoot: Config,\n options: DefaultCatalogCollatorFactoryOptions,\n ) {\n const configOptions = readCollatorConfigOptions(configRoot);\n return new DefaultCatalogCollatorFactory({\n locationTemplate: configOptions.locationTemplate,\n filter: configOptions.filter,\n batchSize: configOptions.batchSize,\n entityTransformer: options.entityTransformer,\n auth: options.auth,\n catalog: options.catalog,\n });\n }\n\n private constructor(options: {\n locationTemplate: string;\n filter: QueryEntitiesInitialRequest['filter'];\n batchSize: number;\n entityTransformer?: CatalogCollatorEntityTransformer;\n auth: AuthService;\n catalog: CatalogService;\n }) {\n const {\n auth,\n batchSize,\n locationTemplate,\n filter,\n catalog,\n entityTransformer,\n } = options;\n\n this.locationTemplate = locationTemplate;\n this.filter = filter;\n this.batchSize = batchSize;\n this.catalog = catalog;\n this.entityTransformer =\n entityTransformer ?? defaultCatalogCollatorEntityTransformer;\n this.auth = auth;\n }\n\n async getCollator(): Promise<Readable> {\n return Readable.from(this.execute());\n }\n\n private async *execute(): AsyncGenerator<CatalogEntityDocument> {\n let entitiesRetrieved = 0;\n let cursor: string | undefined = undefined;\n\n do {\n const response = await this.catalog.queryEntities(\n {\n filter: this.filter,\n limit: this.batchSize,\n ...(cursor ? { cursor } : {}),\n },\n { credentials: await this.auth.getOwnServiceCredentials() },\n );\n cursor = response.pageInfo.nextCursor;\n entitiesRetrieved += response.items.length;\n\n for (const entity of response.items) {\n yield {\n ...this.entityTransformer(entity),\n authorization: {\n resourceRef: stringifyEntityRef(entity),\n },\n location: this.applyArgsToFormat(this.locationTemplate, {\n namespace: encodeURIComponent(\n entity.metadata.namespace || 'default',\n ),\n kind: encodeURIComponent(entity.kind),\n name: encodeURIComponent(entity.metadata.name),\n }),\n };\n }\n } while (cursor);\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":["catalogEntityReadPermission","readCollatorConfigOptions","defaultCatalogCollatorEntityTransformer","Readable","stringifyEntityRef"],"mappings":";;;;;;;;AA0CO,MAAM,
|
|
1
|
+
{"version":3,"file":"DefaultCatalogCollatorFactory.cjs.js","sources":["../../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 { AuthService } from '@backstage/backend-plugin-api';\nimport { QueryEntitiesInitialRequest } 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 { CatalogService } from '@backstage/plugin-catalog-node';\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\nexport type DefaultCatalogCollatorFactoryOptions = {\n auth: AuthService;\n catalog: CatalogService;\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 */\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?: QueryEntitiesInitialRequest['filter'];\n private batchSize: number;\n private readonly catalog: CatalogService;\n private entityTransformer: CatalogCollatorEntityTransformer;\n private auth: AuthService;\n\n static fromConfig(\n configRoot: Config,\n options: DefaultCatalogCollatorFactoryOptions,\n ) {\n const configOptions = readCollatorConfigOptions(configRoot);\n return new DefaultCatalogCollatorFactory({\n locationTemplate: configOptions.locationTemplate,\n filter: configOptions.filter,\n batchSize: configOptions.batchSize,\n entityTransformer: options.entityTransformer,\n auth: options.auth,\n catalog: options.catalog,\n });\n }\n\n private constructor(options: {\n locationTemplate: string;\n filter: QueryEntitiesInitialRequest['filter'];\n batchSize: number;\n entityTransformer?: CatalogCollatorEntityTransformer;\n auth: AuthService;\n catalog: CatalogService;\n }) {\n const {\n auth,\n batchSize,\n locationTemplate,\n filter,\n catalog,\n entityTransformer,\n } = options;\n\n this.locationTemplate = locationTemplate;\n this.filter = filter;\n this.batchSize = batchSize;\n this.catalog = catalog;\n this.entityTransformer =\n entityTransformer ?? defaultCatalogCollatorEntityTransformer;\n this.auth = auth;\n }\n\n async getCollator(): Promise<Readable> {\n return Readable.from(this.execute());\n }\n\n private async *execute(): AsyncGenerator<CatalogEntityDocument> {\n let entitiesRetrieved = 0;\n let cursor: string | undefined = undefined;\n\n do {\n const response = await this.catalog.queryEntities(\n {\n filter: this.filter,\n limit: this.batchSize,\n ...(cursor ? { cursor } : {}),\n },\n { credentials: await this.auth.getOwnServiceCredentials() },\n );\n cursor = response.pageInfo.nextCursor;\n entitiesRetrieved += response.items.length;\n\n for (const entity of response.items) {\n yield {\n ...this.entityTransformer(entity),\n authorization: {\n resourceRef: stringifyEntityRef(entity),\n },\n location: this.applyArgsToFormat(this.locationTemplate, {\n namespace: encodeURIComponent(\n entity.metadata.namespace || 'default',\n ),\n kind: encodeURIComponent(entity.kind),\n name: encodeURIComponent(entity.metadata.name),\n }),\n };\n }\n } while (cursor);\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":["catalogEntityReadPermission","readCollatorConfigOptions","defaultCatalogCollatorEntityTransformer","Readable","stringifyEntityRef"],"mappings":";;;;;;;;AA0CO,MAAM,6BAAA,CAAiE;AAAA,EAC5D,IAAA,GAAO,kBAAA;AAAA,EACP,oBAAA,GACdA,iCAAA;AAAA,EAEM,gBAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACS,OAAA;AAAA,EACT,iBAAA;AAAA,EACA,IAAA;AAAA,EAER,OAAO,UAAA,CACL,UAAA,EACA,OAAA,EACA;AACA,IAAA,MAAM,aAAA,GAAgBC,iCAA0B,UAAU,CAAA;AAC1D,IAAA,OAAO,IAAI,6BAAA,CAA8B;AAAA,MACvC,kBAAkB,aAAA,CAAc,gBAAA;AAAA,MAChC,QAAQ,aAAA,CAAc,MAAA;AAAA,MACtB,WAAW,aAAA,CAAc,SAAA;AAAA,MACzB,mBAAmB,OAAA,CAAQ,iBAAA;AAAA,MAC3B,MAAM,OAAA,CAAQ,IAAA;AAAA,MACd,SAAS,OAAA,CAAQ;AAAA,KAClB,CAAA;AAAA,EACH;AAAA,EAEQ,YAAY,OAAA,EAOjB;AACD,IAAA,MAAM;AAAA,MACJ,IAAA;AAAA,MACA,SAAA;AAAA,MACA,gBAAA;AAAA,MACA,MAAA;AAAA,MACA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AAAA,YACtD,SAAA,EAAW,kBAAA;AAAA,cACT,MAAA,CAAO,SAAS,SAAA,IAAa;AAAA,aAC/B;AAAA,YACA,IAAA,EAAM,kBAAA,CAAmB,MAAA,CAAO,IAAI,CAAA;AAAA,YACpC,IAAA,EAAM,kBAAA,CAAmB,MAAA,CAAO,QAAA,CAAS,IAAI;AAAA,WAC9C;AAAA,SACH;AAAA,MACF;AAAA,IACF,CAAA,QAAS,MAAA;AAAA,EACX;AAAA,EAEQ,iBAAA,CACN,QACA,IAAA,EACQ;AACR,IAAA,IAAI,SAAA,GAAY,MAAA;AAEhB,IAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AAC/C,MAAA,SAAA,GAAY,SAAA,CAAU,OAAA,CAAQ,CAAA,CAAA,EAAI,GAAG,IAAI,KAAK,CAAA;AAAA,IAChD;AAEA,IAAA,OAAO,UAAU,WAAA,EAAY;AAAA,EAC/B;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.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 SchedulerServiceTaskScheduleDefinition,\n readSchedulerServiceTaskScheduleDefinitionFromConfig,\n} from '@backstage/backend-plugin-api';\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): SchedulerServiceTaskScheduleDefinition {\n let schedule: SchedulerServiceTaskScheduleDefinition | 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 =\n readSchedulerServiceTaskScheduleDefinitionFromConfig(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.getOptional<EntityFilterQuery>('filter') ??\n defaults.collatorOptions.filter,\n batchSize:\n config.getOptionalNumber('batchSize') ??\n defaults.collatorOptions.batchSize,\n };\n}\n"],"names":["readSchedulerServiceTaskScheduleDefinitionFromConfig","InputError"],"mappings":";;;;;AAwBA,MAAM,
|
|
1
|
+
{"version":3,"file":"config.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 SchedulerServiceTaskScheduleDefinition,\n readSchedulerServiceTaskScheduleDefinitionFromConfig,\n} from '@backstage/backend-plugin-api';\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): SchedulerServiceTaskScheduleDefinition {\n let schedule: SchedulerServiceTaskScheduleDefinition | 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 =\n readSchedulerServiceTaskScheduleDefinitionFromConfig(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.getOptional<EntityFilterQuery>('filter') ??\n defaults.collatorOptions.filter,\n batchSize:\n config.getOptionalNumber('batchSize') ??\n defaults.collatorOptions.batchSize,\n };\n}\n"],"names":["readSchedulerServiceTaskScheduleDefinitionFromConfig","InputError"],"mappings":";;;;;AAwBA,MAAM,SAAA,GAAY,0BAAA;AAEX,MAAM,QAAA,GAAW;AAAA,EACtB,QAAA,EAAU;AAAA,IACR,SAAA,EAAW,EAAE,OAAA,EAAS,EAAA,EAAG;AAAA,IACzB,OAAA,EAAS,EAAE,OAAA,EAAS,EAAA,EAAG;A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@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultCatalogCollatorEntityTransformer.cjs.js","sources":["../../src/collators/defaultCatalogCollatorEntityTransformer.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 if (entity.metadata.description) {\n documentTexts.push(entity.metadata.description);\n }\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"],"names":["isUserEntity","isGroupEntity"],"mappings":";;;;AAmBA,MAAM,eAAA,GAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"defaultCatalogCollatorEntityTransformer.cjs.js","sources":["../../src/collators/defaultCatalogCollatorEntityTransformer.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 if (entity.metadata.description) {\n documentTexts.push(entity.metadata.description);\n }\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"],"names":["isUserEntity","isGroupEntity"],"mappings":";;;;AAmBA,MAAM,eAAA,GAAkB,CAAC,MAAA,KAA2B;AAClD,EAAA,MAAM,gBAA0B,EAAC;AACjC,EAAA,IAAI,MAAA,CAAO,SAAS,WAAA,EAAa;AAC/B,IAAA,aAAA,CAAc,IAAA,CAAK,MAAA,CAAO,QAAA,CAAS,WAAW,CAAA;AAAA,EAChD;AAEA,EAAA,IAAIA,y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["/*\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 *\n * A collator module for the search backend that indexes your software catalog.\n */\n\nimport {\n coreServices,\n createBackendModule,\n createExtensionPoint,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\nimport { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';\nimport { readScheduleConfigOptions } from './collators/config';\nimport { CatalogCollatorEntityTransformer } from './collators';\nimport { DefaultCatalogCollatorFactory } from './collators/DefaultCatalogCollatorFactory';\n\n/**\n * Options for {@link catalogCollatorExtensionPoint}.\n *\n * @public\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.\n *\n * @public\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 * @public\n */\nexport const searchModuleCatalogCollator = createBackendModule({\n pluginId: 'search',\n moduleId: 'catalog-collator',\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 auth: coreServices.auth,\n config: coreServices.rootConfig,\n scheduler: coreServices.scheduler,\n indexRegistry: searchIndexRegistryExtensionPoint,\n catalog: catalogServiceRef,\n },\n async init({ auth, config, scheduler, indexRegistry, catalog }) {\n indexRegistry.addCollator({\n schedule: scheduler.createScheduledTaskRunner(\n readScheduleConfigOptions(config),\n ),\n factory: DefaultCatalogCollatorFactory.fromConfig(config, {\n auth,\n catalog,\n entityTransformer,\n }),\n });\n },\n });\n },\n});\n"],"names":["createExtensionPoint","createBackendModule","coreServices","searchIndexRegistryExtensionPoint","catalogServiceRef","config","readScheduleConfigOptions","DefaultCatalogCollatorFactory"],"mappings":";;;;;;;;AAmDO,MAAM,gCACXA,
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.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 *\n * A collator module for the search backend that indexes your software catalog.\n */\n\nimport {\n coreServices,\n createBackendModule,\n createExtensionPoint,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\nimport { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';\nimport { readScheduleConfigOptions } from './collators/config';\nimport { CatalogCollatorEntityTransformer } from './collators';\nimport { DefaultCatalogCollatorFactory } from './collators/DefaultCatalogCollatorFactory';\n\n/**\n * Options for {@link catalogCollatorExtensionPoint}.\n *\n * @public\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.\n *\n * @public\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 * @public\n */\nexport const searchModuleCatalogCollator = createBackendModule({\n pluginId: 'search',\n moduleId: 'catalog-collator',\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 auth: coreServices.auth,\n config: coreServices.rootConfig,\n scheduler: coreServices.scheduler,\n indexRegistry: searchIndexRegistryExtensionPoint,\n catalog: catalogServiceRef,\n },\n async init({ auth, config, scheduler, indexRegistry, catalog }) {\n indexRegistry.addCollator({\n schedule: scheduler.createScheduledTaskRunner(\n readScheduleConfigOptions(config),\n ),\n factory: DefaultCatalogCollatorFactory.fromConfig(config, {\n auth,\n catalog,\n entityTransformer,\n }),\n });\n },\n });\n },\n});\n"],"names":["createExtensionPoint","createBackendModule","coreServices","searchIndexRegistryExtensionPoint","catalogServiceRef","config","readScheduleConfigOptions","DefaultCatalogCollatorFactory"],"mappings":";;;;;;;;AAmDO,MAAM,gCACXA,qCAAA,CAAoD;AAAA,EAClD,EAAA,EAAI;AACN,CAAC;AAOI,MAAM,8BAA8BC,oCAAA,CAAoB;AAAA,EAC7D,QAAA,EAAU,QAAA;AAAA,EACV,QAAA,EAAU,kBAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,IAAI,iBAAA;AAEJ,IAAA,GAAA,CAAI,uBAAuB,6BAAA,EAA+B;AAAA,MACxD,qBAAqB,WAAA,EAAa;AAChC,QAAA,IAAI,iBAAA,EAAmB;AACrB,UAAA,MAAM,IAAI,MAAM,8CAA8C,CAAA;AAAA,QAChE;AACA,QAAA,iBAAA,GAAoB,WAAA;AAAA,MACtB;AAAA,KACD,CAAA;AAED,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,MAAMC,6BAAA,CAAa,IAAA;AAAA,QACnB,QAAQA,6BAAA,CAAa,UAAA;AAAA,QACrB,WAAWA,6BAAA,CAAa,SAAA;AAAA,QACxB,aAAA,EAAeC,uCAAA;AAAA,QACf,OAAA,EAASC;AAAA,OACX;AAAA,MACA,MAAM,KAAK,EAAE,IAAA,UAAMC,UAAQ,SAAA,EAAW,aAAA,EAAe,SAAQ,EAAG;AAC9D,QAAA,aAAA,CAAc,WAAA,CAAY;AAAA,UACxB,UAAU,SAAA,CAAU,yBAAA;AAAA,YAClBC,iCAA0BD,QAAM;AAAA,WAClC;AAAA,UACA,OAAA,EAASE,2DAAA,CAA8B,UAAA,CAAWF,QAAA,EAAQ;AAAA,YACxD,IAAA;AAAA,YACA,OAAA;AAAA,YACA;AAAA,WACD;AAAA,SACF,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-search-backend-module-catalog",
|
|
3
|
-
"version": "0.3.7
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "A module for the search backend that exports catalog modules",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -38,20 +38,20 @@
|
|
|
38
38
|
"test": "backstage-cli package test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@backstage/backend-plugin-api": "1.4.2
|
|
42
|
-
"@backstage/catalog-client": "1.11.0
|
|
43
|
-
"@backstage/catalog-model": "1.7.5",
|
|
44
|
-
"@backstage/config": "1.3.3",
|
|
45
|
-
"@backstage/errors": "1.2.7",
|
|
46
|
-
"@backstage/plugin-catalog-common": "1.1.5",
|
|
47
|
-
"@backstage/plugin-catalog-node": "1.18.0
|
|
48
|
-
"@backstage/plugin-permission-common": "0.9.1",
|
|
49
|
-
"@backstage/plugin-search-backend-node": "1.3.14
|
|
50
|
-
"@backstage/plugin-search-common": "1.2.19"
|
|
41
|
+
"@backstage/backend-plugin-api": "^1.4.2",
|
|
42
|
+
"@backstage/catalog-client": "^1.11.0",
|
|
43
|
+
"@backstage/catalog-model": "^1.7.5",
|
|
44
|
+
"@backstage/config": "^1.3.3",
|
|
45
|
+
"@backstage/errors": "^1.2.7",
|
|
46
|
+
"@backstage/plugin-catalog-common": "^1.1.5",
|
|
47
|
+
"@backstage/plugin-catalog-node": "^1.18.0",
|
|
48
|
+
"@backstage/plugin-permission-common": "^0.9.1",
|
|
49
|
+
"@backstage/plugin-search-backend-node": "^1.3.14",
|
|
50
|
+
"@backstage/plugin-search-common": "^1.2.19"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@backstage/backend-test-utils": "1.
|
|
54
|
-
"@backstage/cli": "0.
|
|
53
|
+
"@backstage/backend-test-utils": "^1.8.0",
|
|
54
|
+
"@backstage/cli": "^0.34.0"
|
|
55
55
|
},
|
|
56
56
|
"configSchema": "config.d.ts",
|
|
57
57
|
"typesVersions": {
|