diff --git a/plugins/search-backend-module-explore/alpha-api-report.md b/plugins/search-backend-module-explore/alpha-api-report.md index 7b0f2658d6..a01bc999fb 100644 --- a/plugins/search-backend-module-explore/alpha-api-report.md +++ b/plugins/search-backend-module-explore/alpha-api-report.md @@ -4,17 +4,9 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -import { TaskScheduleDefinition } from '@backstage/backend-tasks'; // @alpha -export const searchModuleExploreCollator: ( - options?: SearchModuleExploreCollatorOptions | undefined, -) => BackendFeature; - -// @alpha -export type SearchModuleExploreCollatorOptions = { - schedule?: TaskScheduleDefinition; -}; +export const searchModuleExploreCollator: () => BackendFeature; // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/search-backend-module-explore/package.json b/plugins/search-backend-module-explore/package.json index e8f3835b39..b8ee2f04e0 100644 --- a/plugins/search-backend-module-explore/package.json +++ b/plugins/search-backend-module-explore/package.json @@ -58,6 +58,8 @@ "msw": "^1.2.1" }, "files": [ - "dist" - ] + "dist", + "config.d.ts" + ], + "configSchema": "config.d.ts" } diff --git a/plugins/search-backend-module-explore/src/alpha.test.ts b/plugins/search-backend-module-explore/src/alpha.test.ts index 9b133f0fd5..b7a44e4898 100644 --- a/plugins/search-backend-module-explore/src/alpha.test.ts +++ b/plugins/search-backend-module-explore/src/alpha.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { startTestBackend } from '@backstage/backend-test-utils'; +import { mockServices, startTestBackend } from '@backstage/backend-test-utils'; import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha'; import { searchModuleExploreCollator } from './alpha'; @@ -34,7 +34,18 @@ describe('searchModuleExploreCollator', () => { extensionPoints: [ [searchIndexRegistryExtensionPoint, extensionPointMock], ], - features: [searchModuleExploreCollator({ schedule })], + features: [searchModuleExploreCollator()], + services: [ + mockServices.rootConfig.factory({ + data: { + search: { + explore: { + schedule, + }, + }, + }, + }), + ], }); expect(extensionPointMock.addCollator).toHaveBeenCalledTimes(1); diff --git a/plugins/search-backend-module-techdocs/alpha-api-report.md b/plugins/search-backend-module-techdocs/alpha-api-report.md index 0eac010b4c..6e36a0020a 100644 --- a/plugins/search-backend-module-techdocs/alpha-api-report.md +++ b/plugins/search-backend-module-techdocs/alpha-api-report.md @@ -4,21 +4,9 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -import { TaskScheduleDefinition } from '@backstage/backend-tasks'; -import { TechDocsCollatorFactoryOptions } from '@backstage/plugin-search-backend-module-techdocs'; // @alpha -export const searchModuleTechDocsCollator: ( - options?: SearchModuleTechDocsCollatorOptions | undefined, -) => BackendFeature; - -// @alpha -export type SearchModuleTechDocsCollatorOptions = Omit< - TechDocsCollatorFactoryOptions, - 'logger' | 'discovery' | 'tokenManager' | 'catalogClient' -> & { - schedule?: TaskScheduleDefinition; -}; +export const searchModuleTechDocsCollator: () => BackendFeature; // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/search-backend-module-techdocs/config.d.ts b/plugins/search-backend-module-techdocs/config.d.ts index 645895243b..03431a5de5 100644 --- a/plugins/search-backend-module-techdocs/config.d.ts +++ b/plugins/search-backend-module-techdocs/config.d.ts @@ -20,7 +20,7 @@ export interface Config { search?: { techdocs?: { schedule?: TaskScheduleDefinitionConfig; - collatorsFactory?: { + collators?: { locationTemplate?: string; parallelismLimit?: number; legacyPathCasing?: boolean; diff --git a/plugins/search-backend-module-techdocs/package.json b/plugins/search-backend-module-techdocs/package.json index 1ee329075d..9baa673a4a 100644 --- a/plugins/search-backend-module-techdocs/package.json +++ b/plugins/search-backend-module-techdocs/package.json @@ -65,6 +65,8 @@ "msw": "^1.0.0" }, "files": [ - "dist" - ] + "dist", + "config.d.ts" + ], + "configSchema": "config.d.ts" } diff --git a/plugins/search-backend-module-techdocs/src/alpha.test.ts b/plugins/search-backend-module-techdocs/src/alpha.test.ts index 011b00b12c..1e7ef494bb 100644 --- a/plugins/search-backend-module-techdocs/src/alpha.test.ts +++ b/plugins/search-backend-module-techdocs/src/alpha.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { startTestBackend } from '@backstage/backend-test-utils'; +import { mockServices, startTestBackend } from '@backstage/backend-test-utils'; import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha'; import { searchModuleTechDocsCollator } from './alpha'; @@ -34,7 +34,18 @@ describe('searchModuleTechDocsCollator', () => { extensionPoints: [ [searchIndexRegistryExtensionPoint, extensionPointMock], ], - features: [searchModuleTechDocsCollator({ schedule })], + features: [searchModuleTechDocsCollator()], + services: [ + mockServices.rootConfig.factory({ + data: { + search: { + techdocs: { + schedule, + }, + }, + }, + }), + ], }); expect(extensionPointMock.addCollator).toHaveBeenCalledTimes(1); diff --git a/plugins/search-backend-module-techdocs/src/alpha.ts b/plugins/search-backend-module-techdocs/src/alpha.ts index e4c75425ca..de2800bf81 100644 --- a/plugins/search-backend-module-techdocs/src/alpha.ts +++ b/plugins/search-backend-module-techdocs/src/alpha.ts @@ -71,15 +71,6 @@ export const searchModuleTechDocsCollator = createBackendModule({ indexRegistry.addCollator({ schedule: scheduler.createScheduledTaskRunner(schedule), factory: DefaultTechDocsCollatorFactory.fromConfig(config, { - locationTemplate: config.getOptionalString( - 'search.techdocs.collatorsFactory.locationTemplate', - ), - parallelismLimit: config.getOptionalNumber( - 'search.techdocs.collatorsFactory.parallelismLimit', - ), - legacyPathCasing: config.getOptionalBoolean( - 'search.techdocs.collatorsFactory.legacyPathCasing', - ), discovery, tokenManager, logger: loggerToWinstonLogger(logger), diff --git a/plugins/search-backend-module-techdocs/src/collators/DefaultTechDocsCollatorFactory.test.ts b/plugins/search-backend-module-techdocs/src/collators/DefaultTechDocsCollatorFactory.test.ts index d9329151c6..ac03178925 100644 --- a/plugins/search-backend-module-techdocs/src/collators/DefaultTechDocsCollatorFactory.test.ts +++ b/plugins/search-backend-module-techdocs/src/collators/DefaultTechDocsCollatorFactory.test.ts @@ -174,10 +174,15 @@ describe('DefaultTechDocsCollatorFactory', () => { it('maps a returned entity with a custom locationTemplate', async () => { // Provide an alternate location template. - factory = DefaultTechDocsCollatorFactory.fromConfig(config, { + const _config = new ConfigReader({ + ...config.get(), + search: { + techdocs: { collators: { locationTemplate: '/software/:name' } }, + }, + }); + factory = DefaultTechDocsCollatorFactory.fromConfig(_config, { discovery: mockDiscoveryApi, tokenManager: mockTokenManager, - locationTemplate: '/software/:name', logger, }); collator = await factory.getCollator(); @@ -194,10 +199,17 @@ describe('DefaultTechDocsCollatorFactory', () => { // A parallelismLimit of 1 is a catalog limit of 50 per request. Code // above in the /entities handler ensures valid entities are only // returned on the second page. - factory = DefaultTechDocsCollatorFactory.fromConfig(config, { - ...options, - parallelismLimit: 1, + const _config = new ConfigReader({ + ...config.get(), + search: { + techdocs: { + collators: { + parallelismLimit: 1, + }, + }, + }, }); + factory = DefaultTechDocsCollatorFactory.fromConfig(_config, options); collator = await factory.getCollator(); const pipeline = TestPipeline.fromCollator(collator); @@ -205,6 +217,9 @@ describe('DefaultTechDocsCollatorFactory', () => { // Only 1 entity with TechDocs configured multiplied by 3 pages. expect(documents).toHaveLength(3); + expect(_config.get('search.techdocs.collators.parallelismLimit')).toEqual( + 1, + ); }); describe('with legacyPathCasing configuration', () => { diff --git a/plugins/search-backend-module-techdocs/src/collators/DefaultTechDocsCollatorFactory.ts b/plugins/search-backend-module-techdocs/src/collators/DefaultTechDocsCollatorFactory.ts index e2c6f5913c..0925b93300 100644 --- a/plugins/search-backend-module-techdocs/src/collators/DefaultTechDocsCollatorFactory.ts +++ b/plugins/search-backend-module-techdocs/src/collators/DefaultTechDocsCollatorFactory.ts @@ -104,7 +104,18 @@ export class DefaultTechDocsCollatorFactory implements DocumentCollatorFactory { config.getOptionalBoolean( 'techdocs.legacyUseCaseSensitiveTripletPaths', ) || false; - return new DefaultTechDocsCollatorFactory({ ...options, legacyPathCasing }); + const locationTemplate = config.getOptionalString( + 'search.techdocs.collators.locationTemplate', + ); + const parallelismLimit = config.getOptionalNumber( + 'search.techdocs.collators.parallelismLimit', + ); + return new DefaultTechDocsCollatorFactory({ + ...options, + locationTemplate, + parallelismLimit, + legacyPathCasing, + }); } async getCollator(): Promise {