plugins/search-backend-module-*: flip around alpha exports to stable

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-10-13 12:58:37 +02:00
parent 7138ee6f41
commit b071eec7d7
28 changed files with 640 additions and 488 deletions
@@ -7,17 +7,23 @@ import { BackendFeature } from '@backstage/backend-plugin-api';
import { CatalogCollatorEntityTransformer } from '@backstage/plugin-search-backend-module-catalog';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
// @alpha
export type CatalogCollatorExtensionPoint = {
setEntityTransformer(transformer: CatalogCollatorEntityTransformer): void;
};
// Warning: (ae-forgotten-export) The symbol "CatalogCollatorExtensionPoint_2" needs to be exported by the entry point alpha.d.ts
//
// @alpha (undocumented)
export type CatalogCollatorExtensionPoint = CatalogCollatorExtensionPoint_2;
// @alpha
export const catalogCollatorExtensionPoint: ExtensionPoint<CatalogCollatorExtensionPoint>;
// @alpha (undocumented)
export const catalogCollatorExtensionPoint: ExtensionPoint<CatalogCollatorExtensionPoint_2>;
// @alpha
const _default: BackendFeature;
export default _default;
// @alpha (undocumented)
const _feature: BackendFeature;
export default _feature;
// Warnings were encountered during analysis:
//
// src/alpha.d.ts:3:15 - (ae-undocumented) Missing documentation for "_feature".
// src/alpha.d.ts:6:1 - (ae-undocumented) Missing documentation for "CatalogCollatorExtensionPoint".
// src/alpha.d.ts:8:22 - (ae-undocumented) Missing documentation for "catalogCollatorExtensionPoint".
// (No @packageDocumentation comment for this package)
```
@@ -8,11 +8,13 @@
import { AuthService } from '@backstage/backend-plugin-api';
import { BackendFeature } from '@backstage/backend-plugin-api';
import { CatalogApi } from '@backstage/catalog-client';
import { CatalogCollatorEntityTransformer as CatalogCollatorEntityTransformer_2 } from '@backstage/plugin-search-backend-module-catalog';
import { CatalogEntityDocument } from '@backstage/plugin-catalog-common';
import { Config } from '@backstage/config';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import { DocumentCollatorFactory } from '@backstage/plugin-search-common';
import { Entity } from '@backstage/catalog-model';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { GetEntitiesRequest } from '@backstage/catalog-client';
import { Permission } from '@backstage/plugin-permission-common';
import { Readable } from 'stream';
@@ -23,6 +25,18 @@ export type CatalogCollatorEntityTransformer = (
entity: Entity,
) => Omit<CatalogEntityDocument, 'location' | 'authorization'>;
// @public
export type CatalogCollatorExtensionPoint = {
setEntityTransformer(transformer: CatalogCollatorEntityTransformer_2): void;
};
// @public
export const catalogCollatorExtensionPoint: ExtensionPoint<CatalogCollatorExtensionPoint>;
// @public
const _default: BackendFeature;
export default _default;
// @public (undocumented)
export const defaultCatalogCollatorEntityTransformer: CatalogCollatorEntityTransformer;
@@ -53,10 +67,6 @@ export type DefaultCatalogCollatorFactoryOptions = {
entityTransformer?: CatalogCollatorEntityTransformer;
};
// @public (undocumented)
const _feature: BackendFeature;
export default _feature;
// Warnings were encountered during analysis:
//
// src/collators/CatalogCollatorEntityTransformer.d.ts:4:1 - (ae-undocumented) Missing documentation for "CatalogCollatorEntityTransformer".
@@ -66,5 +76,4 @@ export default _feature;
// src/collators/DefaultCatalogCollatorFactory.d.ts:51:5 - (ae-undocumented) Missing documentation for "fromConfig".
// src/collators/DefaultCatalogCollatorFactory.d.ts:53:5 - (ae-undocumented) Missing documentation for "getCollator".
// src/collators/defaultCatalogCollatorEntityTransformer.d.ts:3:22 - (ae-undocumented) Missing documentation for "defaultCatalogCollatorEntityTransformer".
// src/index.d.ts:7:15 - (ae-undocumented) Missing documentation for "_feature".
```
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,96 +14,17 @@
* limitations under the License.
*/
/**
* @packageDocumentation
* A module for the search backend that exports Catalog modules.
*/
import {
coreServices,
createBackendModule,
createExtensionPoint,
} from '@backstage/backend-plugin-api';
import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';
import {
CatalogCollatorEntityTransformer,
DefaultCatalogCollatorFactory,
} from '@backstage/plugin-search-backend-module-catalog';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import { readScheduleConfigOptions } from './collators/config';
default as feature,
CatalogCollatorExtensionPoint as ExtensionPoint,
catalogCollatorExtensionPoint as extensionPoint,
} from './module';
/**
* Options for {@link catalogCollatorExtensionPoint}.
*
* @alpha
*/
export type CatalogCollatorExtensionPoint = {
/**
* Allows you to customize how entities are shaped into documents.
*/
setEntityTransformer(transformer: CatalogCollatorEntityTransformer): void;
};
/** @alpha */
const _feature = feature;
export default _feature;
/**
* Extension point for customizing how catalog entities are shaped into
* documents for the search backend.
*
* @alpha
*/
export const catalogCollatorExtensionPoint =
createExtensionPoint<CatalogCollatorExtensionPoint>({
id: 'search.catalogCollator.extension',
});
/**
* Search backend module for the Catalog index.
*
* @alpha
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'catalog-collator',
register(env) {
let entityTransformer: CatalogCollatorEntityTransformer | undefined;
env.registerExtensionPoint(catalogCollatorExtensionPoint, {
setEntityTransformer(transformer) {
if (entityTransformer) {
throw new Error('setEntityTransformer can only be called once');
}
entityTransformer = transformer;
},
});
env.registerInit({
deps: {
auth: coreServices.auth,
config: coreServices.rootConfig,
discovery: coreServices.discovery,
scheduler: coreServices.scheduler,
indexRegistry: searchIndexRegistryExtensionPoint,
catalog: catalogServiceRef,
},
async init({
auth,
config,
discovery,
scheduler,
indexRegistry,
catalog,
}) {
indexRegistry.addCollator({
schedule: scheduler.createScheduledTaskRunner(
readScheduleConfigOptions(config),
),
factory: DefaultCatalogCollatorFactory.fromConfig(config, {
auth,
entityTransformer,
discovery,
catalogClient: catalog,
}),
});
},
});
},
});
/** @alpha */
export type CatalogCollatorExtensionPoint = ExtensionPoint;
/** @alpha */
export const catalogCollatorExtensionPoint = extensionPoint;
@@ -14,15 +14,11 @@
* limitations under the License.
*/
import { default as feature } from './alpha';
/**
* @packageDocumentation
* A module for the search backend that exports Catalog modules.
*/
export * from './module';
export { default } from './module';
export * from './collators';
/** @public */
const _feature = feature;
export default _feature;
@@ -16,7 +16,7 @@
import { mockServices, startTestBackend } from '@backstage/backend-test-utils';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import searchModuleCatalogCollator from './alpha';
import searchModuleCatalogCollator from './module';
describe('searchModuleCatalogCollator', () => {
it('should register the catalog collator to the search index registry extension point with factory and schedule', async () => {
@@ -0,0 +1,109 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @packageDocumentation
* A module for the search backend that exports Catalog modules.
*/
import {
coreServices,
createBackendModule,
createExtensionPoint,
} from '@backstage/backend-plugin-api';
import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';
import {
CatalogCollatorEntityTransformer,
DefaultCatalogCollatorFactory,
} from '@backstage/plugin-search-backend-module-catalog';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import { readScheduleConfigOptions } from './collators/config';
/**
* Options for {@link catalogCollatorExtensionPoint}.
*
* @public
*/
export type CatalogCollatorExtensionPoint = {
/**
* Allows you to customize how entities are shaped into documents.
*/
setEntityTransformer(transformer: CatalogCollatorEntityTransformer): void;
};
/**
* Extension point for customizing how catalog entities are shaped into
* documents for the search backend.
*
* @public
*/
export const catalogCollatorExtensionPoint =
createExtensionPoint<CatalogCollatorExtensionPoint>({
id: 'search.catalogCollator.extension',
});
/**
* Search backend module for the Catalog index.
*
* @public
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'catalog-collator',
register(env) {
let entityTransformer: CatalogCollatorEntityTransformer | undefined;
env.registerExtensionPoint(catalogCollatorExtensionPoint, {
setEntityTransformer(transformer) {
if (entityTransformer) {
throw new Error('setEntityTransformer can only be called once');
}
entityTransformer = transformer;
},
});
env.registerInit({
deps: {
auth: coreServices.auth,
config: coreServices.rootConfig,
discovery: coreServices.discovery,
scheduler: coreServices.scheduler,
indexRegistry: searchIndexRegistryExtensionPoint,
catalog: catalogServiceRef,
},
async init({
auth,
config,
discovery,
scheduler,
indexRegistry,
catalog,
}) {
indexRegistry.addCollator({
schedule: scheduler.createScheduledTaskRunner(
readScheduleConfigOptions(config),
),
factory: DefaultCatalogCollatorFactory.fromConfig(config, {
auth,
entityTransformer,
discovery,
catalogClient: catalog,
}),
});
},
});
},
});
@@ -7,23 +7,24 @@ import { BackendFeature } from '@backstage/backend-plugin-api';
import { ElasticSearchQueryTranslator } from '@backstage/plugin-search-backend-module-elasticsearch';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
// @alpha
const _default: BackendFeature;
export default _default;
// Warning: (ae-forgotten-export) The symbol "ElasticSearchQueryTranslatorExtensionPoint_2" needs to be exported by the entry point alpha.d.ts
//
// @alpha (undocumented)
export type ElasticSearchQueryTranslatorExtensionPoint =
ElasticSearchQueryTranslatorExtensionPoint_2;
// @alpha (undocumented)
export interface ElasticSearchQueryTranslatorExtensionPoint {
// (undocumented)
setTranslator(translator: ElasticSearchQueryTranslator): void;
}
export const elasticsearchTranslatorExtensionPoint: ExtensionPoint<ElasticSearchQueryTranslatorExtensionPoint_2>;
// @alpha
export const elasticsearchTranslatorExtensionPoint: ExtensionPoint<ElasticSearchQueryTranslatorExtensionPoint>;
// @alpha (undocumented)
const _feature: BackendFeature;
export default _feature;
// Warnings were encountered during analysis:
//
// src/alpha.d.ts:3:1 - (ae-undocumented) Missing documentation for "ElasticSearchQueryTranslatorExtensionPoint".
// src/alpha.d.ts:4:5 - (ae-undocumented) Missing documentation for "setTranslator".
// src/alpha.d.ts:3:15 - (ae-undocumented) Missing documentation for "_feature".
// src/alpha.d.ts:6:1 - (ae-undocumented) Missing documentation for "ElasticSearchQueryTranslatorExtensionPoint".
// src/alpha.d.ts:8:22 - (ae-undocumented) Missing documentation for "elasticsearchTranslatorExtensionPoint".
// (No @packageDocumentation comment for this package)
```
@@ -13,6 +13,8 @@ import { BulkHelper } from '@elastic/elasticsearch/lib/Helpers';
import { BulkStats } from '@elastic/elasticsearch/lib/Helpers';
import { Config } from '@backstage/config';
import type { ConnectionOptions } from 'tls';
import { ElasticSearchQueryTranslator as ElasticSearchQueryTranslator_2 } from '@backstage/plugin-search-backend-module-elasticsearch';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { IndexableDocument } from '@backstage/plugin-search-common';
import { IndexableResultSet } from '@backstage/plugin-search-common';
import { LoggerService } from '@backstage/backend-plugin-api';
@@ -73,6 +75,10 @@ export function decodeElasticSearchPageCursor(pageCursor?: string): {
page: number;
};
// @public
const _default: BackendFeature;
export default _default;
// @public (undocumented)
export interface ElasticSearchAgentOptions {
// (undocumented)
@@ -319,6 +325,12 @@ export type ElasticSearchQueryTranslator = (
options?: ElasticSearchQueryTranslatorOptions,
) => ElasticSearchConcreteQuery;
// @public (undocumented)
export interface ElasticSearchQueryTranslatorExtensionPoint {
// (undocumented)
setTranslator(translator: ElasticSearchQueryTranslator_2): void;
}
// @public
export type ElasticSearchQueryTranslatorOptions = {
highlightOptions?: ElasticSearchHighlightConfig;
@@ -379,6 +391,9 @@ export type ElasticSearchSearchEngineIndexerOptions = {
skipRefresh?: boolean;
};
// @public
export const elasticsearchTranslatorExtensionPoint: ExtensionPoint<ElasticSearchQueryTranslatorExtensionPoint>;
// @public (undocumented)
export interface ElasticSearchTransportConstructor {
// (undocumented)
@@ -392,10 +407,6 @@ export interface ElasticSearchTransportConstructor {
};
}
// @public (undocumented)
const _feature: BackendFeature;
export default _feature;
// @public
export const isOpenSearchCompatible: (
opts: ElasticSearchClientOptions,
@@ -557,8 +568,6 @@ export interface OpenSearchNodeOptions {
// src/engines/ElasticSearchSearchEngineIndexer.d.ts:39:5 - (ae-undocumented) Missing documentation for "initialize".
// src/engines/ElasticSearchSearchEngineIndexer.d.ts:40:5 - (ae-undocumented) Missing documentation for "index".
// src/engines/ElasticSearchSearchEngineIndexer.d.ts:41:5 - (ae-undocumented) Missing documentation for "finalize".
// src/index.d.ts:2:15 - (ae-undocumented) Missing documentation for "_feature".
// src/index.d.ts:4:1 - (ae-misplaced-package-tag) The @packageDocumentation comment must appear at the top of entry point *.d.ts file
// (No @packageDocumentation comment for this package)
// src/module.d.ts:3:1 - (ae-undocumented) Missing documentation for "ElasticSearchQueryTranslatorExtensionPoint".
// src/module.d.ts:4:5 - (ae-undocumented) Missing documentation for "setTranslator".
```
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,78 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
coreServices,
createBackendModule,
createExtensionPoint,
} from '@backstage/backend-plugin-api';
import { searchEngineRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import {
ElasticSearchQueryTranslator,
ElasticSearchSearchEngine,
} from '@backstage/plugin-search-backend-module-elasticsearch';
default as feature,
ElasticSearchQueryTranslatorExtensionPoint as ExtensionPoint,
elasticsearchTranslatorExtensionPoint as extensionPoint,
} from './module';
/** @alpha */
export interface ElasticSearchQueryTranslatorExtensionPoint {
setTranslator(translator: ElasticSearchQueryTranslator): void;
}
const _feature = feature;
export default _feature;
/**
* Extension point used to customize the ElasticSearch query translator.
*
* @alpha
*/
export const elasticsearchTranslatorExtensionPoint =
createExtensionPoint<ElasticSearchQueryTranslatorExtensionPoint>({
id: 'search.elasticsearchEngine.translator',
});
/**
* Search backend module for the Elasticsearch engine.
*
* @alpha
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'elasticsearch-engine',
register(env) {
let translator: ElasticSearchQueryTranslator | undefined;
env.registerExtensionPoint(elasticsearchTranslatorExtensionPoint, {
setTranslator(newTranslator) {
if (translator) {
throw new Error(
'ElasticSearch query translator may only be set once',
);
}
translator = newTranslator;
},
});
env.registerInit({
deps: {
searchEngineRegistry: searchEngineRegistryExtensionPoint,
logger: coreServices.logger,
config: coreServices.rootConfig,
},
async init({ searchEngineRegistry, logger, config }) {
const baseKey = 'search.elasticsearch';
const baseConfig = config.getOptional(baseKey);
if (!baseConfig) {
logger.warn(
'No configuration found under "search.elasticsearch" key. Skipping search engine inititalization.',
);
return;
}
searchEngineRegistry.setSearchEngine(
await ElasticSearchSearchEngine.fromConfig({
logger,
config,
translator,
}),
);
},
});
},
});
/** @alpha */
export type ElasticSearchQueryTranslatorExtensionPoint = ExtensionPoint;
/** @alpha */
export const elasticsearchTranslatorExtensionPoint = extensionPoint;
@@ -14,18 +14,14 @@
* limitations under the License.
*/
import { default as feature } from './alpha';
/** @public */
const _feature = feature;
export default _feature;
/**
* A module for the search backend that implements search using ElasticSearch
*
* @packageDocumentation
*/
export { default } from './module';
export * from './module';
export {
decodeElasticSearchPageCursor,
ElasticSearchSearchEngine,
@@ -0,0 +1,90 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
coreServices,
createBackendModule,
createExtensionPoint,
} from '@backstage/backend-plugin-api';
import { searchEngineRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import {
ElasticSearchQueryTranslator,
ElasticSearchSearchEngine,
} from '@backstage/plugin-search-backend-module-elasticsearch';
/** @public */
export interface ElasticSearchQueryTranslatorExtensionPoint {
setTranslator(translator: ElasticSearchQueryTranslator): void;
}
/**
* Extension point used to customize the ElasticSearch query translator.
*
* @public
*/
export const elasticsearchTranslatorExtensionPoint =
createExtensionPoint<ElasticSearchQueryTranslatorExtensionPoint>({
id: 'search.elasticsearchEngine.translator',
});
/**
* Search backend module for the Elasticsearch engine.
*
* @public
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'elasticsearch-engine',
register(env) {
let translator: ElasticSearchQueryTranslator | undefined;
env.registerExtensionPoint(elasticsearchTranslatorExtensionPoint, {
setTranslator(newTranslator) {
if (translator) {
throw new Error(
'ElasticSearch query translator may only be set once',
);
}
translator = newTranslator;
},
});
env.registerInit({
deps: {
searchEngineRegistry: searchEngineRegistryExtensionPoint,
logger: coreServices.logger,
config: coreServices.rootConfig,
},
async init({ searchEngineRegistry, logger, config }) {
const baseKey = 'search.elasticsearch';
const baseConfig = config.getOptional(baseKey);
if (!baseConfig) {
logger.warn(
'No configuration found under "search.elasticsearch" key. Skipping search engine inititalization.',
);
return;
}
searchEngineRegistry.setSearchEngine(
await ElasticSearchSearchEngine.fromConfig({
logger,
config,
translator,
}),
);
},
});
},
});
@@ -5,9 +5,13 @@
```ts
import { BackendFeature } from '@backstage/backend-plugin-api';
// @alpha
const _default: BackendFeature;
export default _default;
// @alpha (undocumented)
const _feature: BackendFeature;
export default _feature;
// Warnings were encountered during analysis:
//
// src/alpha.d.ts:2:15 - (ae-undocumented) Missing documentation for "_feature".
// (No @packageDocumentation comment for this package)
```
@@ -16,9 +16,9 @@ import { LoggerService } from '@backstage/backend-plugin-api';
import { Readable } from 'stream';
import { TokenManager } from '@backstage/backend-common';
// @public (undocumented)
const _feature: BackendFeature;
export default _feature;
// @public
const _default: BackendFeature;
export default _default;
// @public
export interface ToolDocument extends IndexableDocument, ExploreTool {}
@@ -53,5 +53,4 @@ export type ToolDocumentCollatorFactoryOptions = {
// src/collators/ToolDocumentCollatorFactory.d.ts:37:5 - (ae-undocumented) Missing documentation for "fromConfig".
// src/collators/ToolDocumentCollatorFactory.d.ts:38:5 - (ae-undocumented) Missing documentation for "getCollator".
// src/collators/ToolDocumentCollatorFactory.d.ts:39:5 - (ae-undocumented) Missing documentation for "execute".
// src/index.d.ts:7:15 - (ae-undocumented) Missing documentation for "_feature".
```
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,67 +14,8 @@
* limitations under the License.
*/
/**
* @packageDocumentation
* A module for the search backend that exports Explore modules.
*/
import { default as feature } from './module';
import {
coreServices,
createBackendModule,
readSchedulerServiceTaskScheduleDefinitionFromConfig,
} from '@backstage/backend-plugin-api';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import { ToolDocumentCollatorFactory } from '@backstage/plugin-search-backend-module-explore';
/**
* Search backend module for the Explore index.
*
* @alpha
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'explore-collator',
register(env) {
env.registerInit({
deps: {
config: coreServices.rootConfig,
logger: coreServices.logger,
discovery: coreServices.discovery,
scheduler: coreServices.scheduler,
auth: coreServices.auth,
indexRegistry: searchIndexRegistryExtensionPoint,
},
async init({
config,
logger,
discovery,
scheduler,
auth,
indexRegistry,
}) {
const defaultSchedule = {
frequency: { minutes: 10 },
timeout: { minutes: 15 },
initialDelay: { seconds: 3 },
};
const schedule = config.has('search.collators.explore.schedule')
? readSchedulerServiceTaskScheduleDefinitionFromConfig(
config.getConfig('search.collators.explore.schedule'),
)
: defaultSchedule;
indexRegistry.addCollator({
schedule: scheduler.createScheduledTaskRunner(schedule),
factory: ToolDocumentCollatorFactory.fromConfig(config, {
discovery,
logger,
auth,
}),
});
},
});
},
});
/** @alpha */
const _feature = feature;
export default _feature;
@@ -14,15 +14,10 @@
* limitations under the License.
*/
import { default as feature } from './alpha';
/**
* @packageDocumentation
* A module for the search backend that exports Explore modules.
*/
export * from './collators';
/** @public */
const _feature = feature;
export default _feature;
export { default } from './module';
@@ -16,7 +16,7 @@
import { mockServices, startTestBackend } from '@backstage/backend-test-utils';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import searchModuleExploreCollator from './alpha';
import searchModuleExploreCollator from './module';
describe('searchModuleExploreCollator', () => {
const schedule = {
@@ -0,0 +1,80 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @packageDocumentation
* A module for the search backend that exports Explore modules.
*/
import {
coreServices,
createBackendModule,
readSchedulerServiceTaskScheduleDefinitionFromConfig,
} from '@backstage/backend-plugin-api';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import { ToolDocumentCollatorFactory } from '@backstage/plugin-search-backend-module-explore';
/**
* Search backend module for the Explore index.
*
* @public
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'explore-collator',
register(env) {
env.registerInit({
deps: {
config: coreServices.rootConfig,
logger: coreServices.logger,
discovery: coreServices.discovery,
scheduler: coreServices.scheduler,
auth: coreServices.auth,
indexRegistry: searchIndexRegistryExtensionPoint,
},
async init({
config,
logger,
discovery,
scheduler,
auth,
indexRegistry,
}) {
const defaultSchedule = {
frequency: { minutes: 10 },
timeout: { minutes: 15 },
initialDelay: { seconds: 3 },
};
const schedule = config.has('search.collators.explore.schedule')
? readSchedulerServiceTaskScheduleDefinitionFromConfig(
config.getConfig('search.collators.explore.schedule'),
)
: defaultSchedule;
indexRegistry.addCollator({
schedule: scheduler.createScheduledTaskRunner(schedule),
factory: ToolDocumentCollatorFactory.fromConfig(config, {
discovery,
logger,
auth,
}),
});
},
});
},
});
@@ -5,9 +5,13 @@
```ts
import { BackendFeature } from '@backstage/backend-plugin-api';
// @alpha
const _default: BackendFeature;
export default _default;
// @alpha (undocumented)
const _feature: BackendFeature;
export default _feature;
// Warnings were encountered during analysis:
//
// src/alpha.d.ts:2:15 - (ae-undocumented) Missing documentation for "_feature".
// (No @packageDocumentation comment for this package)
```
@@ -71,6 +71,10 @@ export interface DatabaseStore {
transaction<T>(fn: (tx: Knex.Transaction) => Promise<T>): Promise<T>;
}
// @public
const _default: BackendFeature;
export default _default;
// @public (undocumented)
export interface DocumentResultRow {
// (undocumented)
@@ -81,10 +85,6 @@ export interface DocumentResultRow {
type: string;
}
// @public (undocumented)
const _feature: BackendFeature;
export default _feature;
// @public (undocumented)
export class PgSearchEngine implements SearchEngine {
// @deprecated
@@ -240,8 +240,4 @@ export interface RawDocumentRow {
// src/database/types.d.ts:30:5 - (ae-undocumented) Missing documentation for "document".
// src/database/types.d.ts:31:5 - (ae-undocumented) Missing documentation for "type".
// src/database/types.d.ts:32:5 - (ae-undocumented) Missing documentation for "highlight".
// src/index.d.ts:2:15 - (ae-undocumented) Missing documentation for "_feature".
// src/index.d.ts:4:1 - (ae-misplaced-package-tag) The @packageDocumentation comment must appear at the top of entry point *.d.ts file
// (No @packageDocumentation comment for this package)
```
+6 -39
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,42 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
coreServices,
createBackendModule,
} from '@backstage/backend-plugin-api';
import { searchEngineRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import { PgSearchEngine } from './PgSearchEngine';
/**
* @alpha
* Search backend module for the Postgres engine.
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'postgres-engine',
register(env) {
env.registerInit({
deps: {
searchEngineRegistry: searchEngineRegistryExtensionPoint,
database: coreServices.database,
config: coreServices.rootConfig,
logger: coreServices.logger,
},
async init({ searchEngineRegistry, database, config, logger }) {
if (await PgSearchEngine.supported(database)) {
searchEngineRegistry.setSearchEngine(
await PgSearchEngine.fromConfig(config, {
database,
logger,
}),
);
} else {
logger.warn(
'Postgres search engine is not supported, skipping registration of search-backend-module-pg',
);
}
},
});
},
});
import { default as feature } from './module';
/** @alpha */
const _feature = feature;
export default _feature;
@@ -14,17 +14,12 @@
* limitations under the License.
*/
import { default as feature } from './alpha';
/** @public */
const _feature = feature;
export default _feature;
/**
* A module for the search backend that implements search using PostgreSQL
*
* @packageDocumentation
*/
export { default } from './module';
export * from './database';
export * from './PgSearchEngine';
@@ -0,0 +1,54 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
coreServices,
createBackendModule,
} from '@backstage/backend-plugin-api';
import { searchEngineRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import { PgSearchEngine } from './PgSearchEngine';
/**
* @public
* Search backend module for the Postgres engine.
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'postgres-engine',
register(env) {
env.registerInit({
deps: {
searchEngineRegistry: searchEngineRegistryExtensionPoint,
database: coreServices.database,
config: coreServices.rootConfig,
logger: coreServices.logger,
},
async init({ searchEngineRegistry, database, config, logger }) {
if (await PgSearchEngine.supported(database)) {
searchEngineRegistry.setSearchEngine(
await PgSearchEngine.fromConfig(config, {
database,
logger,
}),
);
} else {
logger.warn(
'Postgres search engine is not supported, skipping registration of search-backend-module-pg',
);
}
},
});
},
});
@@ -8,28 +8,24 @@ import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { TechDocsCollatorDocumentTransformer } from '@backstage/plugin-search-backend-module-techdocs';
import { TechDocsCollatorEntityTransformer } from '@backstage/plugin-search-backend-module-techdocs';
// @alpha
const _default: BackendFeature;
export default _default;
// @alpha (undocumented)
const _feature: BackendFeature;
export default _feature;
// Warning: (ae-forgotten-export) The symbol "TechDocsCollatorEntityTransformerExtensionPoint_2" needs to be exported by the entry point alpha.d.ts
//
// @alpha (undocumented)
export type TechDocsCollatorEntityTransformerExtensionPoint =
TechDocsCollatorEntityTransformerExtensionPoint_2;
// @alpha (undocumented)
export interface TechDocsCollatorEntityTransformerExtensionPoint {
// (undocumented)
setDocumentTransformer(
transformer: TechDocsCollatorDocumentTransformer,
): void;
// (undocumented)
setTransformer(transformer: TechDocsCollatorEntityTransformer): void;
}
// @alpha
export const techdocsCollatorEntityTransformerExtensionPoint: ExtensionPoint<TechDocsCollatorEntityTransformerExtensionPoint>;
export const techdocsCollatorEntityTransformerExtensionPoint: ExtensionPoint<TechDocsCollatorEntityTransformerExtensionPoint_2>;
// Warnings were encountered during analysis:
//
// src/alpha.d.ts:3:1 - (ae-undocumented) Missing documentation for "TechDocsCollatorEntityTransformerExtensionPoint".
// src/alpha.d.ts:4:5 - (ae-undocumented) Missing documentation for "setTransformer".
// src/alpha.d.ts:5:5 - (ae-undocumented) Missing documentation for "setDocumentTransformer".
// src/alpha.d.ts:3:15 - (ae-undocumented) Missing documentation for "_feature".
// src/alpha.d.ts:6:1 - (ae-undocumented) Missing documentation for "TechDocsCollatorEntityTransformerExtensionPoint".
// src/alpha.d.ts:8:22 - (ae-undocumented) Missing documentation for "techdocsCollatorEntityTransformerExtensionPoint".
// (No @packageDocumentation comment for this package)
```
@@ -12,13 +12,20 @@ import { Config } from '@backstage/config';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import { DocumentCollatorFactory } from '@backstage/plugin-search-common';
import { Entity } from '@backstage/catalog-model';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { HttpAuthService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { Permission } from '@backstage/plugin-permission-common';
import { Readable } from 'stream';
import { TechDocsCollatorDocumentTransformer as TechDocsCollatorDocumentTransformer_2 } from '@backstage/plugin-search-backend-module-techdocs';
import { TechDocsCollatorEntityTransformer as TechDocsCollatorEntityTransformer_2 } from '@backstage/plugin-search-backend-module-techdocs';
import { TechDocsDocument } from '@backstage/plugin-techdocs-node';
import { TokenManager } from '@backstage/backend-common';
// @public
const _default: BackendFeature;
export default _default;
// @public (undocumented)
export const defaultTechDocsCollatorEntityTransformer: TechDocsCollatorEntityTransformer;
@@ -37,10 +44,6 @@ export class DefaultTechDocsCollatorFactory implements DocumentCollatorFactory {
readonly visibilityPermission: Permission;
}
// @public (undocumented)
const _feature: BackendFeature;
export default _feature;
// @public (undocumented)
export interface MkSearchIndexDoc {
// (undocumented)
@@ -74,6 +77,19 @@ export type TechDocsCollatorEntityTransformer = (
entity: Entity,
) => Partial<Omit<TechDocsDocument, 'location' | 'authorization'>>;
// @public (undocumented)
export interface TechDocsCollatorEntityTransformerExtensionPoint {
// (undocumented)
setDocumentTransformer(
transformer: TechDocsCollatorDocumentTransformer_2,
): void;
// (undocumented)
setTransformer(transformer: TechDocsCollatorEntityTransformer_2): void;
}
// @public
export const techdocsCollatorEntityTransformerExtensionPoint: ExtensionPoint<TechDocsCollatorEntityTransformerExtensionPoint>;
// @public @deprecated
export type TechDocsCollatorFactoryOptions = {
discovery: DiscoveryService;
@@ -103,5 +119,7 @@ export type TechDocsCollatorFactoryOptions = {
// src/collators/TechDocsCollatorDocumentTransformer.d.ts:10:1 - (ae-undocumented) Missing documentation for "TechDocsCollatorDocumentTransformer".
// src/collators/TechDocsCollatorEntityTransformer.d.ts:4:1 - (ae-undocumented) Missing documentation for "TechDocsCollatorEntityTransformer".
// src/collators/defaultTechDocsCollatorEntityTransformer.d.ts:3:22 - (ae-undocumented) Missing documentation for "defaultTechDocsCollatorEntityTransformer".
// src/index.d.ts:7:15 - (ae-undocumented) Missing documentation for "_feature".
// src/module.d.ts:3:1 - (ae-undocumented) Missing documentation for "TechDocsCollatorEntityTransformerExtensionPoint".
// src/module.d.ts:4:5 - (ae-undocumented) Missing documentation for "setTransformer".
// src/module.d.ts:5:5 - (ae-undocumented) Missing documentation for "setDocumentTransformer".
```
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,122 +14,17 @@
* limitations under the License.
*/
/**
* @packageDocumentation
* A module for the search backend that exports TechDocs modules.
*/
import {
coreServices,
createBackendModule,
createExtensionPoint,
readSchedulerServiceTaskScheduleDefinitionFromConfig,
} from '@backstage/backend-plugin-api';
import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';
import {
DefaultTechDocsCollatorFactory,
TechDocsCollatorDocumentTransformer,
TechDocsCollatorEntityTransformer,
} from '@backstage/plugin-search-backend-module-techdocs';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
default as feature,
TechDocsCollatorEntityTransformerExtensionPoint as ExtensionPoint,
techdocsCollatorEntityTransformerExtensionPoint as extensionPoint,
} from './module';
/** @alpha */
export interface TechDocsCollatorEntityTransformerExtensionPoint {
setTransformer(transformer: TechDocsCollatorEntityTransformer): void;
setDocumentTransformer(
transformer: TechDocsCollatorDocumentTransformer,
): void;
}
const _feature = feature;
export default _feature;
/**
* Extension point used to customize the TechDocs collator entity transformer.
*
* @alpha
*/
export const techdocsCollatorEntityTransformerExtensionPoint =
createExtensionPoint<TechDocsCollatorEntityTransformerExtensionPoint>({
id: 'search.techdocsCollator.transformer',
});
/**
* @alpha
* Search backend module for the TechDocs index.
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'techdocs-collator',
register(env) {
let entityTransformer: TechDocsCollatorEntityTransformer | undefined;
let documentTransformer: TechDocsCollatorDocumentTransformer | undefined;
env.registerExtensionPoint(
techdocsCollatorEntityTransformerExtensionPoint,
{
setTransformer(newTransformer) {
if (entityTransformer) {
throw new Error(
'TechDocs collator entity transformer may only be set once',
);
}
entityTransformer = newTransformer;
},
setDocumentTransformer(newTransformer) {
if (documentTransformer) {
throw new Error(
'TechDocs collator document transformer may only be set once',
);
}
documentTransformer = newTransformer;
},
},
);
env.registerInit({
deps: {
config: coreServices.rootConfig,
logger: coreServices.logger,
auth: coreServices.auth,
httpAuth: coreServices.httpAuth,
discovery: coreServices.discovery,
scheduler: coreServices.scheduler,
catalog: catalogServiceRef,
indexRegistry: searchIndexRegistryExtensionPoint,
},
async init({
config,
logger,
auth,
httpAuth,
discovery,
scheduler,
catalog,
indexRegistry,
}) {
const defaultSchedule = {
frequency: { minutes: 10 },
timeout: { minutes: 15 },
initialDelay: { seconds: 3 },
};
const schedule = config.has('search.collators.techdocs.schedule')
? readSchedulerServiceTaskScheduleDefinitionFromConfig(
config.getConfig('search.collators.techdocs.schedule'),
)
: defaultSchedule;
indexRegistry.addCollator({
schedule: scheduler.createScheduledTaskRunner(schedule),
factory: DefaultTechDocsCollatorFactory.fromConfig(config, {
discovery,
auth,
httpAuth,
logger,
catalogClient: catalog,
entityTransformer,
documentTransformer,
}),
});
},
});
},
});
/** @alpha */
export type TechDocsCollatorEntityTransformerExtensionPoint = ExtensionPoint;
/** @alpha */
export const techdocsCollatorEntityTransformerExtensionPoint = extensionPoint;
@@ -14,15 +14,11 @@
* limitations under the License.
*/
import { default as feature } from './alpha';
/**
* @packageDocumentation
* A module for the search backend that exports TechDocs modules.
*/
export { default } from './module';
export * from './module';
export * from './collators';
/** @public */
const _feature = feature;
export default _feature;
@@ -16,7 +16,7 @@
import { mockServices, startTestBackend } from '@backstage/backend-test-utils';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
import searchModuleTechDocsCollator from './alpha';
import searchModuleTechDocsCollator from './module';
describe('searchModuleTechDocsCollator', () => {
const schedule = {
@@ -0,0 +1,135 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @packageDocumentation
* A module for the search backend that exports TechDocs modules.
*/
import {
coreServices,
createBackendModule,
createExtensionPoint,
readSchedulerServiceTaskScheduleDefinitionFromConfig,
} from '@backstage/backend-plugin-api';
import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';
import {
DefaultTechDocsCollatorFactory,
TechDocsCollatorDocumentTransformer,
TechDocsCollatorEntityTransformer,
} from '@backstage/plugin-search-backend-module-techdocs';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
/** @public */
export interface TechDocsCollatorEntityTransformerExtensionPoint {
setTransformer(transformer: TechDocsCollatorEntityTransformer): void;
setDocumentTransformer(
transformer: TechDocsCollatorDocumentTransformer,
): void;
}
/**
* Extension point used to customize the TechDocs collator entity transformer.
*
* @public
*/
export const techdocsCollatorEntityTransformerExtensionPoint =
createExtensionPoint<TechDocsCollatorEntityTransformerExtensionPoint>({
id: 'search.techdocsCollator.transformer',
});
/**
* @public
* Search backend module for the TechDocs index.
*/
export default createBackendModule({
pluginId: 'search',
moduleId: 'techdocs-collator',
register(env) {
let entityTransformer: TechDocsCollatorEntityTransformer | undefined;
let documentTransformer: TechDocsCollatorDocumentTransformer | undefined;
env.registerExtensionPoint(
techdocsCollatorEntityTransformerExtensionPoint,
{
setTransformer(newTransformer) {
if (entityTransformer) {
throw new Error(
'TechDocs collator entity transformer may only be set once',
);
}
entityTransformer = newTransformer;
},
setDocumentTransformer(newTransformer) {
if (documentTransformer) {
throw new Error(
'TechDocs collator document transformer may only be set once',
);
}
documentTransformer = newTransformer;
},
},
);
env.registerInit({
deps: {
config: coreServices.rootConfig,
logger: coreServices.logger,
auth: coreServices.auth,
httpAuth: coreServices.httpAuth,
discovery: coreServices.discovery,
scheduler: coreServices.scheduler,
catalog: catalogServiceRef,
indexRegistry: searchIndexRegistryExtensionPoint,
},
async init({
config,
logger,
auth,
httpAuth,
discovery,
scheduler,
catalog,
indexRegistry,
}) {
const defaultSchedule = {
frequency: { minutes: 10 },
timeout: { minutes: 15 },
initialDelay: { seconds: 3 },
};
const schedule = config.has('search.collators.techdocs.schedule')
? readSchedulerServiceTaskScheduleDefinitionFromConfig(
config.getConfig('search.collators.techdocs.schedule'),
)
: defaultSchedule;
indexRegistry.addCollator({
schedule: scheduler.createScheduledTaskRunner(schedule),
factory: DefaultTechDocsCollatorFactory.fromConfig(config, {
discovery,
auth,
httpAuth,
logger,
catalogClient: catalog,
entityTransformer,
documentTransformer,
}),
});
},
});
},
});