diff --git a/.changeset/beige-files-reflect.md b/.changeset/beige-files-reflect.md new file mode 100644 index 0000000000..e888d5e0f8 --- /dev/null +++ b/.changeset/beige-files-reflect.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-search-backend-module-techdocs': patch +'@backstage/plugin-search-backend-module-catalog': patch +'@backstage/plugin-search-backend-module-explore': patch +--- + +Ensure that all services are dependency injected into the module instead of taken from options diff --git a/plugins/search-backend-module-catalog/alpha-api-report.md b/plugins/search-backend-module-catalog/alpha-api-report.md index 70fae9ef93..7c6e91b6a1 100644 --- a/plugins/search-backend-module-catalog/alpha-api-report.md +++ b/plugins/search-backend-module-catalog/alpha-api-report.md @@ -15,7 +15,7 @@ export const searchModuleCatalogCollator: ( // @alpha export type SearchModuleCatalogCollatorOptions = Omit< DefaultCatalogCollatorFactoryOptions, - 'discovery' | 'tokenManager' + 'discovery' | 'tokenManager' | 'catalogClient' > & { schedule?: TaskScheduleDefinition; }; diff --git a/plugins/search-backend-module-catalog/package.json b/plugins/search-backend-module-catalog/package.json index 1c625a6e5f..37473ef04b 100644 --- a/plugins/search-backend-module-catalog/package.json +++ b/plugins/search-backend-module-catalog/package.json @@ -49,6 +49,7 @@ "@backstage/catalog-model": "workspace:^", "@backstage/config": "workspace:^", "@backstage/plugin-catalog-common": "workspace:^", + "@backstage/plugin-catalog-node": "workspace:^", "@backstage/plugin-permission-common": "workspace:^", "@backstage/plugin-search-backend-node": "workspace:^", "@backstage/plugin-search-common": "workspace:^" diff --git a/plugins/search-backend-module-catalog/src/alpha.ts b/plugins/search-backend-module-catalog/src/alpha.ts index f79aacab52..cfd8c13539 100644 --- a/plugins/search-backend-module-catalog/src/alpha.ts +++ b/plugins/search-backend-module-catalog/src/alpha.ts @@ -30,6 +30,7 @@ import { DefaultCatalogCollatorFactory, DefaultCatalogCollatorFactoryOptions, } from '@backstage/plugin-search-backend-module-catalog'; +import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha'; /** * @alpha @@ -37,14 +38,15 @@ import { */ export type SearchModuleCatalogCollatorOptions = Omit< DefaultCatalogCollatorFactoryOptions, - 'discovery' | 'tokenManager' + 'discovery' | 'tokenManager' | 'catalogClient' > & { schedule?: TaskScheduleDefinition; }; /** - * @alpha * Search backend module for the Catalog index. + * + * @alpha */ export const searchModuleCatalogCollator = createBackendModule( (options?: SearchModuleCatalogCollatorOptions) => ({ @@ -58,6 +60,7 @@ export const searchModuleCatalogCollator = createBackendModule( tokenManager: coreServices.tokenManager, scheduler: coreServices.scheduler, indexRegistry: searchIndexRegistryExtensionPoint, + catalog: catalogServiceRef, }, async init({ config, @@ -65,6 +68,7 @@ export const searchModuleCatalogCollator = createBackendModule( tokenManager, scheduler, indexRegistry, + catalog, }) { const defaultSchedule = { frequency: { minutes: 10 }, @@ -80,6 +84,7 @@ export const searchModuleCatalogCollator = createBackendModule( ...options, discovery, tokenManager, + catalogClient: catalog, }), }); }, diff --git a/plugins/search-backend-module-explore/alpha-api-report.md b/plugins/search-backend-module-explore/alpha-api-report.md index cf32b59dd3..7b0f2658d6 100644 --- a/plugins/search-backend-module-explore/alpha-api-report.md +++ b/plugins/search-backend-module-explore/alpha-api-report.md @@ -5,7 +5,6 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; import { TaskScheduleDefinition } from '@backstage/backend-tasks'; -import { ToolDocumentCollatorFactoryOptions } from '@backstage/plugin-search-backend-module-explore'; // @alpha export const searchModuleExploreCollator: ( @@ -13,10 +12,7 @@ export const searchModuleExploreCollator: ( ) => BackendFeature; // @alpha -export type SearchModuleExploreCollatorOptions = Omit< - ToolDocumentCollatorFactoryOptions, - 'logger' | 'discovery' -> & { +export type SearchModuleExploreCollatorOptions = { schedule?: TaskScheduleDefinition; }; diff --git a/plugins/search-backend-module-explore/src/alpha.ts b/plugins/search-backend-module-explore/src/alpha.ts index 542d6def2b..fadbcda3a5 100644 --- a/plugins/search-backend-module-explore/src/alpha.ts +++ b/plugins/search-backend-module-explore/src/alpha.ts @@ -27,25 +27,21 @@ import { TaskScheduleDefinition } from '@backstage/backend-tasks'; import { loggerToWinstonLogger } from '@backstage/backend-common'; import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha'; -import { - ToolDocumentCollatorFactory, - ToolDocumentCollatorFactoryOptions, -} from '@backstage/plugin-search-backend-module-explore'; +import { ToolDocumentCollatorFactory } from '@backstage/plugin-search-backend-module-explore'; /** - * @alpha * Options for {@link searchModuleExploreCollator}. + * + * @alpha */ -export type SearchModuleExploreCollatorOptions = Omit< - ToolDocumentCollatorFactoryOptions, - 'logger' | 'discovery' -> & { +export type SearchModuleExploreCollatorOptions = { schedule?: TaskScheduleDefinition; }; /** - * @alpha * Search backend module for the Explore index. + * + * @alpha */ export const searchModuleExploreCollator = createBackendModule( (options?: SearchModuleExploreCollatorOptions) => ({ @@ -58,9 +54,17 @@ export const searchModuleExploreCollator = createBackendModule( logger: coreServices.logger, discovery: coreServices.discovery, scheduler: coreServices.scheduler, + tokenManager: coreServices.tokenManager, indexRegistry: searchIndexRegistryExtensionPoint, }, - async init({ config, logger, discovery, scheduler, indexRegistry }) { + async init({ + config, + logger, + discovery, + scheduler, + indexRegistry, + tokenManager, + }) { const defaultSchedule = { frequency: { minutes: 10 }, timeout: { minutes: 15 }, @@ -72,9 +76,9 @@ export const searchModuleExploreCollator = createBackendModule( options?.schedule ?? defaultSchedule, ), factory: ToolDocumentCollatorFactory.fromConfig(config, { - ...options, discovery, logger: loggerToWinstonLogger(logger), + tokenManager, }), }); }, diff --git a/plugins/search-backend-module-techdocs/alpha-api-report.md b/plugins/search-backend-module-techdocs/alpha-api-report.md index 71ce09b744..0eac010b4c 100644 --- a/plugins/search-backend-module-techdocs/alpha-api-report.md +++ b/plugins/search-backend-module-techdocs/alpha-api-report.md @@ -15,7 +15,7 @@ export const searchModuleTechDocsCollator: ( // @alpha export type SearchModuleTechDocsCollatorOptions = Omit< TechDocsCollatorFactoryOptions, - 'logger' | 'discovery' | 'tokenManager' + 'logger' | 'discovery' | 'tokenManager' | 'catalogClient' > & { schedule?: TaskScheduleDefinition; }; diff --git a/plugins/search-backend-module-techdocs/package.json b/plugins/search-backend-module-techdocs/package.json index c378a395c0..ffc9d0ff4f 100644 --- a/plugins/search-backend-module-techdocs/package.json +++ b/plugins/search-backend-module-techdocs/package.json @@ -49,6 +49,7 @@ "@backstage/catalog-model": "workspace:^", "@backstage/config": "workspace:^", "@backstage/plugin-catalog-common": "workspace:^", + "@backstage/plugin-catalog-node": "workspace:^", "@backstage/plugin-permission-common": "workspace:^", "@backstage/plugin-search-backend-node": "workspace:^", "@backstage/plugin-search-common": "workspace:^", diff --git a/plugins/search-backend-module-techdocs/src/alpha.ts b/plugins/search-backend-module-techdocs/src/alpha.ts index fe34d5241b..5d82b6804f 100644 --- a/plugins/search-backend-module-techdocs/src/alpha.ts +++ b/plugins/search-backend-module-techdocs/src/alpha.ts @@ -26,6 +26,7 @@ import { import { TaskScheduleDefinition } from '@backstage/backend-tasks'; import { loggerToWinstonLogger } from '@backstage/backend-common'; import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha'; +import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha'; import { DefaultTechDocsCollatorFactory, @@ -38,7 +39,7 @@ import { */ export type SearchModuleTechDocsCollatorOptions = Omit< TechDocsCollatorFactoryOptions, - 'logger' | 'discovery' | 'tokenManager' + 'logger' | 'discovery' | 'tokenManager' | 'catalogClient' > & { schedule?: TaskScheduleDefinition; }; @@ -59,6 +60,7 @@ export const searchModuleTechDocsCollator = createBackendModule( discovery: coreServices.discovery, tokenManager: coreServices.tokenManager, scheduler: coreServices.scheduler, + catalog: catalogServiceRef, indexRegistry: searchIndexRegistryExtensionPoint, }, async init({ @@ -67,6 +69,7 @@ export const searchModuleTechDocsCollator = createBackendModule( discovery, tokenManager, scheduler, + catalog, indexRegistry, }) { const defaultSchedule = { @@ -84,6 +87,7 @@ export const searchModuleTechDocsCollator = createBackendModule( discovery, tokenManager, logger: loggerToWinstonLogger(logger), + catalogClient: catalog, }), }); }, diff --git a/yarn.lock b/yarn.lock index 1fb653e7bc..f628161240 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8519,6 +8519,7 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" "@backstage/plugin-catalog-common": "workspace:^" + "@backstage/plugin-catalog-node": "workspace:^" "@backstage/plugin-permission-common": "workspace:^" "@backstage/plugin-search-backend-node": "workspace:^" "@backstage/plugin-search-common": "workspace:^" @@ -8599,6 +8600,7 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" "@backstage/plugin-catalog-common": "workspace:^" + "@backstage/plugin-catalog-node": "workspace:^" "@backstage/plugin-permission-common": "workspace:^" "@backstage/plugin-search-backend-node": "workspace:^" "@backstage/plugin-search-common": "workspace:^"