From 2e6b24d53704cc15714df9965399f2b88ff8beb5 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Thu, 2 Jun 2022 12:02:00 +0200 Subject: [PATCH 01/10] clean up api report for search-backend-node package Signed-off-by: Emma Indal --- plugins/search-backend-node/api-report.md | 43 ++++++++----------- .../search-backend-node/src/IndexBuilder.ts | 9 +++- plugins/search-backend-node/src/Scheduler.ts | 10 +++-- .../NewlineDelimitedJsonCollatorFactory.ts | 8 ++-- .../src/engines/LunrSearchEngine.ts | 9 ++-- .../src/engines/LunrSearchEngineIndexer.ts | 3 +- .../src/indexing/BatchSearchEngineIndexer.ts | 5 ++- .../src/indexing/DecoratorBase.ts | 2 +- .../src/test-utils/TestPipeline.ts | 4 +- plugins/search-backend-node/src/types.ts | 7 +-- 10 files changed, 54 insertions(+), 46 deletions(-) diff --git a/plugins/search-backend-node/api-report.md b/plugins/search-backend-node/api-report.md index 8c10b031a2..7649bc5d0f 100644 --- a/plugins/search-backend-node/api-report.md +++ b/plugins/search-backend-node/api-report.md @@ -24,7 +24,7 @@ import { Transform } from 'stream'; import { UrlReader } from '@backstage/backend-common'; import { Writable } from 'stream'; -// @beta +// @public export abstract class BatchSearchEngineIndexer extends Writable { constructor(options: BatchSearchEngineOptions); abstract finalize(): Promise; @@ -32,19 +32,19 @@ export abstract class BatchSearchEngineIndexer extends Writable { abstract initialize(): Promise; } -// @beta (undocumented) +// @public export type BatchSearchEngineOptions = { batchSize: number; }; -// @beta (undocumented) +// @public export type ConcreteLunrQuery = { lunrQueryBuilder: lunr_2.Index.QueryBuilder; documentTypes?: string[]; pageSize: number; }; -// @beta +// @public export abstract class DecoratorBase extends Transform { constructor(); abstract decorate( @@ -54,7 +54,7 @@ export abstract class DecoratorBase extends Transform { abstract initialize(): Promise; } -// @beta (undocumented) +// @public export class IndexBuilder { constructor({ logger, searchEngine }: IndexBuilderOptions); addCollator({ factory, schedule }: RegisterCollatorParameters): void; @@ -62,22 +62,20 @@ export class IndexBuilder { build(): Promise<{ scheduler: Scheduler; }>; - // (undocumented) getDocumentTypes(): Record; - // (undocumented) getSearchEngine(): SearchEngine; } -// @beta (undocumented) +// @public export type IndexBuilderOptions = { searchEngine: SearchEngine; logger: Logger; }; -// @beta (undocumented) +// @public export type LunrQueryTranslator = (query: SearchQuery) => ConcreteLunrQuery; -// @beta (undocumented) +// @public export class LunrSearchEngine implements SearchEngine { constructor({ logger }: { logger: Logger }); // (undocumented) @@ -100,7 +98,7 @@ export class LunrSearchEngine implements SearchEngine { protected translator: QueryTranslator; } -// @beta (undocumented) +// @public export class LunrSearchEngineIndexer extends BatchSearchEngineIndexer { constructor(); // (undocumented) @@ -115,7 +113,7 @@ export class LunrSearchEngineIndexer extends BatchSearchEngineIndexer { initialize(): Promise; } -// @beta +// @public export class NewlineDelimitedJsonCollatorFactory implements DocumentCollatorFactory { @@ -131,7 +129,7 @@ export class NewlineDelimitedJsonCollatorFactory readonly visibilityPermission: Permission | undefined; } -// @beta (undocumented) +// @public export type NewlineDelimitedJsonCollatorFactoryOptions = { type: string; searchPattern: string; @@ -140,18 +138,18 @@ export type NewlineDelimitedJsonCollatorFactoryOptions = { visibilityPermission?: Permission; }; -// @beta +// @public export interface RegisterCollatorParameters { factory: DocumentCollatorFactory; schedule: TaskRunner; } -// @beta +// @public export interface RegisterDecoratorParameters { factory: DocumentDecoratorFactory; } -// @beta (undocumented) +// @public export class Scheduler { constructor({ logger }: { logger: Logger }); addToSchedule({ id, task, scheduledRunner }: ScheduleTaskParameters): void; @@ -160,25 +158,22 @@ export class Scheduler { } // @public -export interface ScheduleTaskParameters { - // (undocumented) +export type ScheduleTaskParameters = { id: string; - // (undocumented) - scheduledRunner: TaskRunner; - // (undocumented) task: TaskFunction; -} + scheduledRunner: TaskRunner; +}; export { SearchEngine }; -// @beta +// @public export class TestPipeline { execute(): Promise; withDocuments(documents: IndexableDocument[]): TestPipeline; static withSubject(subject: Readable | Transform | Writable): TestPipeline; } -// @beta +// @public export type TestPipelineResult = { error: unknown; documents: IndexableDocument[]; diff --git a/plugins/search-backend-node/src/IndexBuilder.ts b/plugins/search-backend-node/src/IndexBuilder.ts index 2131c6937d..3e1dae1c2f 100644 --- a/plugins/search-backend-node/src/IndexBuilder.ts +++ b/plugins/search-backend-node/src/IndexBuilder.ts @@ -28,7 +28,8 @@ import { } from './types'; /** - * @beta + * Used for adding collators, decorators and compile them into tasks which are added to a scheduler returned to the caller. + * @public */ export class IndexBuilder { private collators: Record; @@ -45,10 +46,16 @@ export class IndexBuilder { this.searchEngine = searchEngine; } + /** + * Responsible for returning the registered search engine. + */ getSearchEngine(): SearchEngine { return this.searchEngine; } + /** + * Responsible for returning the registered document types. + */ getDocumentTypes(): Record { return this.documentTypes; } diff --git a/plugins/search-backend-node/src/Scheduler.ts b/plugins/search-backend-node/src/Scheduler.ts index 9f3d95b112..404823c53a 100644 --- a/plugins/search-backend-node/src/Scheduler.ts +++ b/plugins/search-backend-node/src/Scheduler.ts @@ -24,16 +24,18 @@ type TaskEnvelope = { }; /** - * @public ScheduleTaskParameters + * ScheduleTaskParameters + * @public */ -export interface ScheduleTaskParameters { +export type ScheduleTaskParameters = { id: string; task: TaskFunction; scheduledRunner: TaskRunner; -} +}; /** - * @beta + * Scheduler responsible for all search tasks. + * @public */ export class Scheduler { private logger: Logger; diff --git a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts index 42c43818f1..fde6b9412a 100644 --- a/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts +++ b/plugins/search-backend-node/src/collators/NewlineDelimitedJsonCollatorFactory.ts @@ -23,7 +23,8 @@ import { Readable } from 'stream'; import { Logger } from 'winston'; /** - * @beta + * Options for instansiate NewlineDelimitedJsonCollatorFactory + * @public */ export type NewlineDelimitedJsonCollatorFactoryOptions = { type: string; @@ -60,15 +61,13 @@ export type NewlineDelimitedJsonCollatorFactoryOptions = { * }); * ``` * - * @beta + * @public */ export class NewlineDelimitedJsonCollatorFactory implements DocumentCollatorFactory { - /** {@inheritDoc @backstage/plugin-search-common#DocumentCollatorFactory."type"} */ readonly type: string; - /** {@inheritDoc @backstage/plugin-search-common#DocumentCollatorFactory.visibilityPermission} */ public readonly visibilityPermission: Permission | undefined; private constructor( @@ -123,7 +122,6 @@ export class NewlineDelimitedJsonCollatorFactory } } - /** {@inheritDoc @backstage/plugin-search-common#DocumentCollatorFactory.getCollator} */ async getCollator(): Promise { // Search for files matching the given pattern. const lastUrl = await this.lastUrl(); diff --git a/plugins/search-backend-node/src/engines/LunrSearchEngine.ts b/plugins/search-backend-node/src/engines/LunrSearchEngine.ts index 656cd3e1eb..4a5f4cdd18 100644 --- a/plugins/search-backend-node/src/engines/LunrSearchEngine.ts +++ b/plugins/search-backend-node/src/engines/LunrSearchEngine.ts @@ -27,7 +27,8 @@ import { Logger } from 'winston'; import { LunrSearchEngineIndexer } from './LunrSearchEngineIndexer'; /** - * @beta + * Type of translated query for the Lunr Search Engine. + * @public */ export type ConcreteLunrQuery = { lunrQueryBuilder: lunr.Index.QueryBuilder; @@ -41,12 +42,14 @@ type LunrResultEnvelope = { }; /** - * @beta + * Translator repsonsible for translating search term and filters to a query that the Lunr Search Engine understands. + * @public */ export type LunrQueryTranslator = (query: SearchQuery) => ConcreteLunrQuery; /** - * @beta + * Lunr specific search engine implementation. + * @public */ export class LunrSearchEngine implements SearchEngine { protected lunrIndices: Record = {}; diff --git a/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.ts b/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.ts index 4da27be94b..e723957077 100644 --- a/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.ts +++ b/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.ts @@ -19,7 +19,8 @@ import lunr from 'lunr'; import { BatchSearchEngineIndexer } from '../indexing'; /** - * @beta + * Lunr specific search engine indexer + * @public */ export class LunrSearchEngineIndexer extends BatchSearchEngineIndexer { private schemaInitialized = false; diff --git a/plugins/search-backend-node/src/indexing/BatchSearchEngineIndexer.ts b/plugins/search-backend-node/src/indexing/BatchSearchEngineIndexer.ts index 6070a577ed..24b90c2a59 100644 --- a/plugins/search-backend-node/src/indexing/BatchSearchEngineIndexer.ts +++ b/plugins/search-backend-node/src/indexing/BatchSearchEngineIndexer.ts @@ -19,7 +19,8 @@ import { IndexableDocument } from '@backstage/plugin-search-common'; import { Writable } from 'stream'; /** - * @beta + * Options for {@link BatchSearchEngineIndexer} + * @public */ export type BatchSearchEngineOptions = { batchSize: number; @@ -28,7 +29,7 @@ export type BatchSearchEngineOptions = { /** * Base class encapsulating batch-based stream processing. Useful as a base * class for search engine indexers. - * @beta + * @public */ export abstract class BatchSearchEngineIndexer extends Writable { private batchSize: number; diff --git a/plugins/search-backend-node/src/indexing/DecoratorBase.ts b/plugins/search-backend-node/src/indexing/DecoratorBase.ts index 0541ab82d7..bcf5729674 100644 --- a/plugins/search-backend-node/src/indexing/DecoratorBase.ts +++ b/plugins/search-backend-node/src/indexing/DecoratorBase.ts @@ -21,7 +21,7 @@ import { Transform } from 'stream'; /** * Base class encapsulating simple async transformations. Useful as a base * class for Backstage search decorators. - * @beta + * @public */ export abstract class DecoratorBase extends Transform { private initialized: Promise; diff --git a/plugins/search-backend-node/src/test-utils/TestPipeline.ts b/plugins/search-backend-node/src/test-utils/TestPipeline.ts index 688cab55be..00dd9b3755 100644 --- a/plugins/search-backend-node/src/test-utils/TestPipeline.ts +++ b/plugins/search-backend-node/src/test-utils/TestPipeline.ts @@ -19,7 +19,7 @@ import { pipeline, Readable, Transform, Writable } from 'stream'; /** * Object resolved after a test pipeline is executed. - * @beta + * @public */ export type TestPipelineResult = { /** @@ -37,7 +37,7 @@ export type TestPipelineResult = { /** * Test utility for Backstage Search collators, decorators, and indexers. - * @beta + * @public */ export class TestPipeline { private collator?: Readable; diff --git a/plugins/search-backend-node/src/types.ts b/plugins/search-backend-node/src/types.ts index a92398e8c8..dfcf4d12ce 100644 --- a/plugins/search-backend-node/src/types.ts +++ b/plugins/search-backend-node/src/types.ts @@ -23,7 +23,8 @@ import { import { Logger } from 'winston'; /** - * @beta + * Options required to instantiate the index builder. + * @public */ export type IndexBuilderOptions = { searchEngine: SearchEngine; @@ -32,7 +33,7 @@ export type IndexBuilderOptions = { /** * Parameters required to register a collator. - * @beta + * @public */ export interface RegisterCollatorParameters { /** @@ -48,7 +49,7 @@ export interface RegisterCollatorParameters { /** * Parameters required to register a decorator - * @beta + * @public */ export interface RegisterDecoratorParameters { /** From 52cc4d852523d6f7dd257cf7e631224a82f7a6ec Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Thu, 2 Jun 2022 12:02:58 +0200 Subject: [PATCH 02/10] clean up api report for search-backend package Signed-off-by: Emma Indal --- plugins/search-backend/api-report.md | 4 ---- plugins/search-backend/src/service/router.ts | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/search-backend/api-report.md b/plugins/search-backend/api-report.md index c5c8eb7a13..eed61069da 100644 --- a/plugins/search-backend/api-report.md +++ b/plugins/search-backend/api-report.md @@ -11,13 +11,9 @@ import { PermissionAuthorizer } from '@backstage/plugin-permission-common'; import { PermissionEvaluator } from '@backstage/plugin-permission-common'; import { SearchEngine } from '@backstage/plugin-search-backend-node'; -// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export function createRouter(options: RouterOptions): Promise; -// Warning: (ae-missing-release-tag) "RouterOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type RouterOptions = { engine: SearchEngine; diff --git a/plugins/search-backend/src/service/router.ts b/plugins/search-backend/src/service/router.ts index e42a31981c..f54c2d388f 100644 --- a/plugins/search-backend/src/service/router.ts +++ b/plugins/search-backend/src/service/router.ts @@ -51,6 +51,9 @@ const jsonObjectSchema: z.ZodSchema = z.lazy(() => { return z.record(jsonValueSchema); }); +/** + * @public + */ export type RouterOptions = { engine: SearchEngine; types: Record; @@ -61,6 +64,9 @@ export type RouterOptions = { const allowedLocationProtocols = ['http:', 'https:']; +/** + * @public + */ export async function createRouter( options: RouterOptions, ): Promise { From 0afede342d39dc7b3e0467f979f93a5e5e798ee3 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Thu, 2 Jun 2022 13:10:40 +0200 Subject: [PATCH 03/10] clean up api report for search-backend-module-elasticsearch package Signed-off-by: Emma Indal --- .../api-report.md | 127 ++++++++++++++---- .../src/engines/ElasticSearchClientOptions.ts | 20 ++- .../src/engines/ElasticSearchSearchEngine.ts | 17 ++- .../ElasticSearchSearchEngineIndexer.ts | 8 ++ .../src/engines/index.ts | 9 ++ .../src/index.ts | 8 ++ 6 files changed, 160 insertions(+), 29 deletions(-) diff --git a/plugins/search-backend-module-elasticsearch/api-report.md b/plugins/search-backend-module-elasticsearch/api-report.md index 7ef026745f..77ce0af61e 100644 --- a/plugins/search-backend-module-elasticsearch/api-report.md +++ b/plugins/search-backend-module-elasticsearch/api-report.md @@ -15,17 +15,44 @@ import { Logger } from 'winston'; import { SearchEngine } from '@backstage/plugin-search-common'; import { SearchQuery } from '@backstage/plugin-search-common'; -// Warning: (ae-missing-release-tag) "ElasticSearchClientOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-search-backend-module-elasticsearch" does not have an export "ElasticSearchEngine" -// +// @public +export type ConcreteElasticSearchQuery = { + documentTypes?: string[]; + elasticSearchQuery: Object; + pageSize: number; +}; + +// @public (undocumented) +export interface ElasticSearchAgentOptions { + // (undocumented) + keepAlive?: boolean; + // (undocumented) + keepAliveMsecs?: number; + // (undocumented) + maxFreeSockets?: number; + // (undocumented) + maxSockets?: number; +} + +// @public (undocumented) +export type ElasticSearchAuth = + | { + username: string; + password: string; + } + | { + apiKey: + | string + | { + id: string; + api_key: string; + }; + }; + // @public export interface ElasticSearchClientOptions { - // Warning: (ae-forgotten-export) The symbol "ElasticSearchAgentOptions" needs to be exported by the entry point index.d.ts - // // (undocumented) agent?: ElasticSearchAgentOptions | ((opts?: any) => unknown) | false; - // Warning: (ae-forgotten-export) The symbol "ElasticSearchAuth" needs to be exported by the entry point index.d.ts - // // (undocumented) auth?: ElasticSearchAuth; // (undocumented) @@ -36,8 +63,6 @@ export interface ElasticSearchClientOptions { }; // (undocumented) compression?: 'gzip'; - // Warning: (ae-forgotten-export) The symbol "ElasticSearchConnectionConstructor" needs to be exported by the entry point index.d.ts - // // (undocumented) Connection?: ElasticSearchConnectionConstructor; // (undocumented) @@ -50,8 +75,6 @@ export interface ElasticSearchClientOptions { maxRetries?: number; // (undocumented) name?: string | symbol; - // Warning: (ae-forgotten-export) The symbol "ElasticSearchNodeOptions" needs to be exported by the entry point index.d.ts - // // (undocumented) node?: | string @@ -92,12 +115,28 @@ export interface ElasticSearchClientOptions { ssl?: ConnectionOptions; // (undocumented) suggestCompression?: boolean; - // Warning: (ae-forgotten-export) The symbol "ElasticSearchTransportConstructor" needs to be exported by the entry point index.d.ts - // // (undocumented) Transport?: ElasticSearchTransportConstructor; } +// @public (undocumented) +export interface ElasticSearchConnectionConstructor { + // (undocumented) + new (opts?: any): any; + // (undocumented) + roles: { + MASTER: string; + DATA: string; + INGEST: string; + ML: string; + }; + // (undocumented) + statuses: { + ALIVE: string; + DEAD: string; + }; +} + // @public (undocumented) export type ElasticSearchHighlightConfig = { fragmentDelimiter: string; @@ -115,6 +154,41 @@ export type ElasticSearchHighlightOptions = { }; // @public (undocumented) +export interface ElasticSearchNodeOptions { + // (undocumented) + agent?: ElasticSearchAgentOptions; + // (undocumented) + headers?: Record; + // (undocumented) + id?: string; + // (undocumented) + roles?: { + master: boolean; + data: boolean; + ingest: boolean; + ml: boolean; + }; + // (undocumented) + ssl?: ConnectionOptions; + // (undocumented) + url: URL; +} + +// @public +export type ElasticSearchOptions = { + logger: Logger; + config: Config; + aliasPostfix?: string; + indexPrefix?: string; +}; + +// @public +export type ElasticSearchQueryTranslator = ( + query: SearchQuery, + options?: ElasticSearchQueryTranslatorOptions, +) => ConcreteElasticSearchQuery; + +// @public export type ElasticSearchQueryTranslatorOptions = { highlightOptions?: ElasticSearchHighlightConfig; }; @@ -128,8 +202,6 @@ export class ElasticSearchSearchEngine implements SearchEngine { logger: Logger, highlightOptions?: ElasticSearchHighlightOptions, ); - // Warning: (ae-forgotten-export) The symbol "ElasticSearchOptions" needs to be exported by the entry point index.d.ts - // // (undocumented) static fromConfig({ logger, @@ -142,12 +214,8 @@ export class ElasticSearchSearchEngine implements SearchEngine { newClient(create: (options: ElasticSearchClientOptions) => T): T; // (undocumented) query(query: SearchQuery): Promise; - // Warning: (ae-forgotten-export) The symbol "ElasticSearchQueryTranslator" needs to be exported by the entry point index.d.ts - // // (undocumented) setTranslator(translator: ElasticSearchQueryTranslator): void; - // Warning: (ae-forgotten-export) The symbol "ConcreteElasticSearchQuery" needs to be exported by the entry point index.d.ts - // // (undocumented) protected translator( query: SearchQuery, @@ -155,9 +223,7 @@ export class ElasticSearchSearchEngine implements SearchEngine { ): ConcreteElasticSearchQuery; } -// Warning: (ae-missing-release-tag) "ElasticSearchSearchEngineIndexer" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export class ElasticSearchSearchEngineIndexer extends BatchSearchEngineIndexer { constructor(options: ElasticSearchSearchEngineIndexerOptions); // (undocumented) @@ -170,9 +236,7 @@ export class ElasticSearchSearchEngineIndexer extends BatchSearchEngineIndexer { initialize(): Promise; } -// Warning: (ae-missing-release-tag) "ElasticSearchSearchEngineIndexerOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export type ElasticSearchSearchEngineIndexerOptions = { type: string; indexPrefix: string; @@ -181,4 +245,17 @@ export type ElasticSearchSearchEngineIndexerOptions = { logger: Logger; elasticSearchClient: Client; }; + +// @public (undocumented) +export interface ElasticSearchTransportConstructor { + // (undocumented) + new (opts?: any): any; + // (undocumented) + sniffReasons: { + SNIFF_ON_START: string; + SNIFF_INTERVAL: string; + SNIFF_ON_CONNECTION_FAULT: string; + DEFAULT: string; + }; +} ``` diff --git a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchClientOptions.ts b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchClientOptions.ts index 73cb149c0a..c5d1f11b0c 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchClientOptions.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchClientOptions.ts @@ -18,10 +18,12 @@ import type { ConnectionOptions as TLSConnectionOptions } from 'tls'; /** * Options used to configure the `@elastic/elasticsearch` client and * are what will be passed as an argument to the - * {@link ElasticSearchEngine.newClient} method + * {@link ElasticSearchSearchEngine.newClient} method * * They are drawn from the `ClientOptions` class of `@elastic/elasticsearch`, * but are maintained separately so that this interface is not coupled to + * + * @public */ export interface ElasticSearchClientOptions { provider?: 'aws' | 'elastic'; @@ -65,6 +67,9 @@ export interface ElasticSearchClientOptions { disablePrototypePoisoningProtection?: boolean | 'proto' | 'constructor'; } +/** + * @public + */ export type ElasticSearchAuth = | { username: string; @@ -79,6 +84,9 @@ export type ElasticSearchAuth = }; }; +/** + * @public + */ export interface ElasticSearchNodeOptions { url: URL; id?: string; @@ -93,6 +101,9 @@ export interface ElasticSearchNodeOptions { }; } +/** + * @public + */ export interface ElasticSearchAgentOptions { keepAlive?: boolean; keepAliveMsecs?: number; @@ -100,6 +111,9 @@ export interface ElasticSearchAgentOptions { maxFreeSockets?: number; } +/** + * @public + */ export interface ElasticSearchConnectionConstructor { new (opts?: any): any; statuses: { @@ -113,7 +127,9 @@ export interface ElasticSearchConnectionConstructor { ML: string; }; } - +/** + * @public + */ export interface ElasticSearchTransportConstructor { new (opts?: any): any; sniffReasons: { diff --git a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts index 70b085e5a7..621fe1cd55 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts @@ -36,6 +36,10 @@ import { ElasticSearchSearchEngineIndexer } from './ElasticSearchSearchEngineInd export type { ElasticSearchClientOptions }; +/** + * Search query that the elasticsearch engine understands. + * @public + */ export type ConcreteElasticSearchQuery = { documentTypes?: string[]; elasticSearchQuery: Object; @@ -43,18 +47,27 @@ export type ConcreteElasticSearchQuery = { }; /** + * Options available for the Elasticsearch specific query translator. * @public */ export type ElasticSearchQueryTranslatorOptions = { highlightOptions?: ElasticSearchHighlightConfig; }; -type ElasticSearchQueryTranslator = ( +/** + * Elasticsearch specific query translator. + * @public + */ +export type ElasticSearchQueryTranslator = ( query: SearchQuery, options?: ElasticSearchQueryTranslatorOptions, ) => ConcreteElasticSearchQuery; -type ElasticSearchOptions = { +/** + * Options for instansiate ElasticSearchSearchEngine + * @public + */ +export type ElasticSearchOptions = { logger: Logger; config: Config; aliasPostfix?: string; diff --git a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngineIndexer.ts b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngineIndexer.ts index 2a738e1506..fd16d0c963 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngineIndexer.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngineIndexer.ts @@ -20,6 +20,10 @@ import { Client } from '@elastic/elasticsearch'; import { Readable } from 'stream'; import { Logger } from 'winston'; +/** + * Options for instansiate ElasticSearchSearchEngineIndexer + * @public + */ export type ElasticSearchSearchEngineIndexerOptions = { type: string; indexPrefix: string; @@ -35,6 +39,10 @@ function duration(startTimestamp: [number, number]): string { return `${seconds.toFixed(1)}s`; } +/** + * Elasticsearch specific search engine indexer. + * @public + */ export class ElasticSearchSearchEngineIndexer extends BatchSearchEngineIndexer { private received: number = 0; private processed: number = 0; diff --git a/plugins/search-backend-module-elasticsearch/src/engines/index.ts b/plugins/search-backend-module-elasticsearch/src/engines/index.ts index c5628776ef..625c0d9b60 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/index.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/index.ts @@ -15,12 +15,21 @@ */ export { ElasticSearchSearchEngine } from './ElasticSearchSearchEngine'; +export type { + ElasticSearchAgentOptions, + ElasticSearchConnectionConstructor, + ElasticSearchTransportConstructor, + ElasticSearchNodeOptions, + ElasticSearchAuth, +} from './ElasticSearchClientOptions'; export type { ConcreteElasticSearchQuery, ElasticSearchClientOptions, ElasticSearchHighlightConfig, ElasticSearchHighlightOptions, + ElasticSearchQueryTranslator, ElasticSearchQueryTranslatorOptions, + ElasticSearchOptions, } from './ElasticSearchSearchEngine'; export type { ElasticSearchSearchEngineIndexer, diff --git a/plugins/search-backend-module-elasticsearch/src/index.ts b/plugins/search-backend-module-elasticsearch/src/index.ts index 744e12f8c8..3cfb3c403f 100644 --- a/plugins/search-backend-module-elasticsearch/src/index.ts +++ b/plugins/search-backend-module-elasticsearch/src/index.ts @@ -22,10 +22,18 @@ export { ElasticSearchSearchEngine } from './engines'; export type { + ElasticSearchAgentOptions, + ConcreteElasticSearchQuery, ElasticSearchClientOptions, ElasticSearchHighlightConfig, ElasticSearchHighlightOptions, + ElasticSearchQueryTranslator, ElasticSearchQueryTranslatorOptions, + ElasticSearchConnectionConstructor, + ElasticSearchTransportConstructor, + ElasticSearchNodeOptions, + ElasticSearchOptions, + ElasticSearchAuth, ElasticSearchSearchEngineIndexer, ElasticSearchSearchEngineIndexerOptions, } from './engines'; From b39d3ee4991aa49ae42e37f6e093499c50acdcc5 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Thu, 2 Jun 2022 13:11:42 +0200 Subject: [PATCH 04/10] add additional search packages to api-extractor NO_WARNING_PACKAGES list Signed-off-by: Emma Indal --- scripts/api-extractor.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/api-extractor.ts b/scripts/api-extractor.ts index ae74848af6..33933cbb21 100644 --- a/scripts/api-extractor.ts +++ b/scripts/api-extractor.ts @@ -256,7 +256,9 @@ const NO_WARNING_PACKAGES = [ 'plugins/scaffolder-backend-module-rails', 'plugins/scaffolder-backend-module-yeoman', 'plugins/scaffolder-common', + 'plugins/search-backend', 'plugins/search-backend-node', + 'plugins/search-backend-module-elasticsearch', 'plugins/search-common', 'plugins/search-react', 'plugins/techdocs', From 18e05f2b54d24e18dcdd9a203227f31514128100 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Thu, 2 Jun 2022 13:19:51 +0200 Subject: [PATCH 05/10] clean up api reports for search-common package Signed-off-by: Emma Indal --- plugins/search-common/api-report.md | 32 ++++++++++++++--------------- plugins/search-common/src/types.ts | 32 ++++++++++++++--------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/plugins/search-common/api-report.md b/plugins/search-common/api-report.md index 495d77ed26..bb049742f7 100644 --- a/plugins/search-common/api-report.md +++ b/plugins/search-common/api-report.md @@ -11,46 +11,46 @@ import { Readable } from 'stream'; import { Transform } from 'stream'; import { Writable } from 'stream'; -// @beta +// @public export interface DocumentCollatorFactory { getCollator(): Promise; readonly type: string; readonly visibilityPermission?: Permission; } -// @beta +// @public export interface DocumentDecoratorFactory { getDecorator(): Promise; readonly types?: string[]; } -// @beta +// @public export type DocumentTypeInfo = { visibilityPermission?: Permission; }; -// @beta +// @public export type IndexableDocument = SearchDocument & { authorization?: { resourceRef: string; }; }; -// @beta (undocumented) +// @public (undocumented) export type IndexableResult = Result; -// @beta (undocumented) +// @public (undocumented) export type IndexableResultSet = ResultSet; -// @beta +// @public export type QueryRequestOptions = { token?: string; }; -// @beta +// @public export type QueryTranslator = (query: SearchQuery) => unknown; -// @beta (undocumented) +// @public (undocumented) export interface Result { // (undocumented) document: TDocument; @@ -60,7 +60,7 @@ export interface Result { type: string; } -// @beta +// @public export interface ResultHighlight { // (undocumented) fields: { @@ -70,7 +70,7 @@ export interface ResultHighlight { preTag: string; } -// @beta (undocumented) +// @public (undocumented) export interface ResultSet { // (undocumented) nextPageCursor?: string; @@ -80,14 +80,14 @@ export interface ResultSet { results: Result[]; } -// @beta +// @public export interface SearchDocument { location: string; text: string; title: string; } -// @beta +// @public export interface SearchEngine { getIndexer(type: string): Promise; query( @@ -97,7 +97,7 @@ export interface SearchEngine { setTranslator(translator: QueryTranslator): void; } -// @beta (undocumented) +// @public (undocumented) export interface SearchQuery { // (undocumented) filters?: JsonObject; @@ -109,9 +109,9 @@ export interface SearchQuery { types?: string[]; } -// @beta (undocumented) +// @public (undocumented) export type SearchResult = Result; -// @beta (undocumented) +// @public (undocumented) export type SearchResultSet = ResultSet; ``` diff --git a/plugins/search-common/src/types.ts b/plugins/search-common/src/types.ts index f77e819364..fdcc06287c 100644 --- a/plugins/search-common/src/types.ts +++ b/plugins/search-common/src/types.ts @@ -19,7 +19,7 @@ import { JsonObject } from '@backstage/types'; import { Readable, Transform, Writable } from 'stream'; /** - * @beta + * @public */ export interface SearchQuery { term: string; @@ -29,10 +29,10 @@ export interface SearchQuery { } /** - * @beta * Metadata for result relevant document fields with matched terms highlighted * via wrapping in associated pre/post tags. The UI is expected to parse these * field excerpts by replacing wrapping tags with applicable UI elements for rendering. + * @public */ export interface ResultHighlight { /** @@ -53,7 +53,7 @@ export interface ResultHighlight { } /** - * @beta + * @public */ export interface Result { type: string; @@ -62,7 +62,7 @@ export interface Result { } /** - * @beta + * @public */ export interface ResultSet { results: Result[]; @@ -71,28 +71,28 @@ export interface ResultSet { } /** - * @beta + * @public */ export type SearchResult = Result; /** - * @beta + * @public */ export type SearchResultSet = ResultSet; /** - * @beta + * @public */ export type IndexableResult = Result; /** - * @beta + * @public */ export type IndexableResultSet = ResultSet; /** * Base properties that all search documents must include. - * @beta + * @public */ export interface SearchDocument { /** @@ -117,7 +117,7 @@ export interface SearchDocument { * backends working directly with documents being inserted or retrieved from * search indexes. When dealing with documents in the frontend, use * {@link SearchDocument}. - * @beta + * @public */ export type IndexableDocument = SearchDocument & { /** @@ -136,7 +136,7 @@ export type IndexableDocument = SearchDocument & { * Information about a specific document type. Intended to be used in the * {@link @backstage/plugin-search-backend-node#IndexBuilder} to collect information * about the types stored in the index. - * @beta + * @public */ export type DocumentTypeInfo = { /** @@ -148,7 +148,7 @@ export type DocumentTypeInfo = { /** * Factory class for instantiating collators. - * @beta + * @public */ export interface DocumentCollatorFactory { /** @@ -171,7 +171,7 @@ export interface DocumentCollatorFactory { /** * Factory class for instantiating decorators. - * @beta + * @public */ export interface DocumentDecoratorFactory { /** @@ -190,13 +190,13 @@ export interface DocumentDecoratorFactory { /** * A type of function responsible for translating an abstract search query into * a concrete query relevant to a particular search engine. - * @beta + * @public */ export type QueryTranslator = (query: SearchQuery) => unknown; /** * Options when querying a search engine. - * @beta + * @public */ export type QueryRequestOptions = { token?: string; @@ -206,7 +206,7 @@ export type QueryRequestOptions = { * Interface that must be implemented by specific search engines, responsible * for performing indexing and querying and translating abstract queries into * concrete, search engine-specific queries. - * @beta + * @public */ export interface SearchEngine { /** From 73fa59f6b20d34fd183ca6dc06a2c838267f1c84 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Thu, 2 Jun 2022 13:20:29 +0200 Subject: [PATCH 06/10] replace all usages of @backstage/search-common with @backstage/plugin-search-common Signed-off-by: Emma Indal --- .changeset/pre.json | 1 - contrib/search/confluence/ConfluenceCollator.md | 2 +- contrib/search/confluence/ConfluenceResultListItem.md | 2 +- plugins/catalog-common/package.json | 2 +- plugins/catalog-common/src/search/CatalogEntityDocument.ts | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index a7ee74e62c..4d4f1e0623 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -25,7 +25,6 @@ "@backstage/integration": "1.2.0", "@backstage/integration-react": "1.1.0", "@backstage/release-manifests": "0.0.3", - "@backstage/search-common": "0.3.4", "@techdocs/cli": "1.1.1", "techdocs-cli-embedded-app": "0.2.70", "@backstage/techdocs-common": "0.11.15", diff --git a/contrib/search/confluence/ConfluenceCollator.md b/contrib/search/confluence/ConfluenceCollator.md index f636ae88ea..7d7c8641f3 100644 --- a/contrib/search/confluence/ConfluenceCollator.md +++ b/contrib/search/confluence/ConfluenceCollator.md @@ -1,7 +1,7 @@ ConfluenceCollator.ts reference ```ts -import { DocumentCollator } from '@backstage/search-common'; +import { DocumentCollator } from '@backstage/plugin-search-common'; import fetch from 'cross-fetch'; export class ConfluenceCollator implements DocumentCollator { diff --git a/contrib/search/confluence/ConfluenceResultListItem.md b/contrib/search/confluence/ConfluenceResultListItem.md index ba7c4f91a9..059048d731 100644 --- a/contrib/search/confluence/ConfluenceResultListItem.md +++ b/contrib/search/confluence/ConfluenceResultListItem.md @@ -3,7 +3,7 @@ ConfluenceResultListItem.tsx reference ```tsx import React from 'react'; import { Link } from '@backstage/core-components'; -import { IndexableDocument } from '@backstage/search-common'; +import { IndexableDocument } from '@backstage/plugin-search-common'; import { Divider, ListItem, diff --git a/plugins/catalog-common/package.json b/plugins/catalog-common/package.json index 0e14a01006..c53acd3dd9 100644 --- a/plugins/catalog-common/package.json +++ b/plugins/catalog-common/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "@backstage/plugin-permission-common": "^0.6.2-next.0", - "@backstage/search-common": "^0.3.5-next.0" + "@backstage/plugin-search-common": "^0.3.4" }, "devDependencies": { "@backstage/cli": "^0.17.2-next.1" diff --git a/plugins/catalog-common/src/search/CatalogEntityDocument.ts b/plugins/catalog-common/src/search/CatalogEntityDocument.ts index 834dde2568..0c53c369cf 100644 --- a/plugins/catalog-common/src/search/CatalogEntityDocument.ts +++ b/plugins/catalog-common/src/search/CatalogEntityDocument.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { IndexableDocument } from '@backstage/search-common'; +import { IndexableDocument } from '@backstage/plugin-search-common'; /** * The Document format for an Entity in the Catalog for search From fd4dc882877e5370440e05ec4b0b1283dd85fd0f Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Thu, 2 Jun 2022 16:01:31 +0200 Subject: [PATCH 07/10] generate api report for @backstage/plugin-catalog-common Signed-off-by: Emma Indal --- plugins/catalog-common/api-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog-common/api-report.md b/plugins/catalog-common/api-report.md index c15cbae103..ab540d446b 100644 --- a/plugins/catalog-common/api-report.md +++ b/plugins/catalog-common/api-report.md @@ -4,7 +4,7 @@ ```ts import { BasicPermission } from '@backstage/plugin-permission-common'; -import { IndexableDocument } from '@backstage/search-common'; +import { IndexableDocument } from '@backstage/plugin-search-common'; import { ResourcePermission } from '@backstage/plugin-permission-common'; // @alpha From 7d8acfc32eafea91779ebcfd80b3616187c7b369 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Thu, 2 Jun 2022 16:10:29 +0200 Subject: [PATCH 08/10] add changesets Signed-off-by: Emma Indal --- .changeset/famous-cups-clap.md | 5 +++++ .changeset/hip-pears-shout.md | 5 +++++ .changeset/nervous-ravens-smash.md | 5 +++++ .changeset/seven-readers-drop.md | 14 ++++++++++++++ .changeset/twenty-mangos-clap.md | 5 +++++ 5 files changed, 34 insertions(+) create mode 100644 .changeset/famous-cups-clap.md create mode 100644 .changeset/hip-pears-shout.md create mode 100644 .changeset/nervous-ravens-smash.md create mode 100644 .changeset/seven-readers-drop.md create mode 100644 .changeset/twenty-mangos-clap.md diff --git a/.changeset/famous-cups-clap.md b/.changeset/famous-cups-clap.md new file mode 100644 index 0000000000..206aec9177 --- /dev/null +++ b/.changeset/famous-cups-clap.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search-common': patch +--- + +`@beta` exports now replaced with `@public` exports diff --git a/.changeset/hip-pears-shout.md b/.changeset/hip-pears-shout.md new file mode 100644 index 0000000000..61cb7c52a0 --- /dev/null +++ b/.changeset/hip-pears-shout.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-common': patch +--- + +Replaced all usages of `@backstage/search-common` with `@backstage/plugin-search-common` diff --git a/.changeset/nervous-ravens-smash.md b/.changeset/nervous-ravens-smash.md new file mode 100644 index 0000000000..b9d7546d44 --- /dev/null +++ b/.changeset/nervous-ravens-smash.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search-backend': patch +--- + +`RouterOptions` and `createRouter` now marked as public exports diff --git a/.changeset/seven-readers-drop.md b/.changeset/seven-readers-drop.md new file mode 100644 index 0000000000..174b8984e0 --- /dev/null +++ b/.changeset/seven-readers-drop.md @@ -0,0 +1,14 @@ +--- +'@backstage/plugin-search-backend-module-elasticsearch': patch +--- + +Additional types now exported publicly: + +- ElasticSearchAgentOptions +- ConcreteElasticSearchQuery +- ElasticSearchQueryTranslator +- ElasticSearchConnectionConstructor, +- ElasticSearchTransportConstructor, +- ElasticSearchNodeOptions, +- ElasticSearchOptions, +- ElasticSearchAuth, diff --git a/.changeset/twenty-mangos-clap.md b/.changeset/twenty-mangos-clap.md new file mode 100644 index 0000000000..5cb4284711 --- /dev/null +++ b/.changeset/twenty-mangos-clap.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search-backend-node': patch +--- + +Replaced all `@beta` exports with `@public` exports From ed360f6bd2efe7bd21122a26968e396eb9d50f7c Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Thu, 2 Jun 2022 16:22:23 +0200 Subject: [PATCH 09/10] depend on the right version of @backstage/plugin-search-common Signed-off-by: Emma Indal --- plugins/catalog-common/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog-common/package.json b/plugins/catalog-common/package.json index c53acd3dd9..f520a36c9b 100644 --- a/plugins/catalog-common/package.json +++ b/plugins/catalog-common/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "@backstage/plugin-permission-common": "^0.6.2-next.0", - "@backstage/plugin-search-common": "^0.3.4" + "@backstage/plugin-search-common": "^0.3.5-next.0" }, "devDependencies": { "@backstage/cli": "^0.17.2-next.1" From 28972473a016fd1a46ecce0ce2904ef2b36ad3f8 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Fri, 3 Jun 2022 14:12:39 +0200 Subject: [PATCH 10/10] rename ConcreteElasticSearchQuery -> ElasticSearchConcreteQuery Signed-off-by: Emma Indal --- .changeset/seven-readers-drop.md | 2 +- .../api-report.md | 18 +++++++++--------- .../engines/ElasticSearchSearchEngine.test.ts | 14 +++++++------- .../src/engines/ElasticSearchSearchEngine.ts | 6 +++--- .../src/engines/index.ts | 2 +- .../src/index.ts | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.changeset/seven-readers-drop.md b/.changeset/seven-readers-drop.md index 174b8984e0..687969edfe 100644 --- a/.changeset/seven-readers-drop.md +++ b/.changeset/seven-readers-drop.md @@ -5,7 +5,7 @@ Additional types now exported publicly: - ElasticSearchAgentOptions -- ConcreteElasticSearchQuery +- ElasticSearchConcreteQuery - ElasticSearchQueryTranslator - ElasticSearchConnectionConstructor, - ElasticSearchTransportConstructor, diff --git a/plugins/search-backend-module-elasticsearch/api-report.md b/plugins/search-backend-module-elasticsearch/api-report.md index 77ce0af61e..143d3ab3e8 100644 --- a/plugins/search-backend-module-elasticsearch/api-report.md +++ b/plugins/search-backend-module-elasticsearch/api-report.md @@ -15,13 +15,6 @@ import { Logger } from 'winston'; import { SearchEngine } from '@backstage/plugin-search-common'; import { SearchQuery } from '@backstage/plugin-search-common'; -// @public -export type ConcreteElasticSearchQuery = { - documentTypes?: string[]; - elasticSearchQuery: Object; - pageSize: number; -}; - // @public (undocumented) export interface ElasticSearchAgentOptions { // (undocumented) @@ -119,6 +112,13 @@ export interface ElasticSearchClientOptions { Transport?: ElasticSearchTransportConstructor; } +// @public +export type ElasticSearchConcreteQuery = { + documentTypes?: string[]; + elasticSearchQuery: Object; + pageSize: number; +}; + // @public (undocumented) export interface ElasticSearchConnectionConstructor { // (undocumented) @@ -186,7 +186,7 @@ export type ElasticSearchOptions = { export type ElasticSearchQueryTranslator = ( query: SearchQuery, options?: ElasticSearchQueryTranslatorOptions, -) => ConcreteElasticSearchQuery; +) => ElasticSearchConcreteQuery; // @public export type ElasticSearchQueryTranslatorOptions = { @@ -220,7 +220,7 @@ export class ElasticSearchSearchEngine implements SearchEngine { protected translator( query: SearchQuery, options?: ElasticSearchQueryTranslatorOptions, - ): ConcreteElasticSearchQuery; + ): ElasticSearchConcreteQuery; } // @public diff --git a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.test.ts b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.test.ts index d3ca3481ff..9867920c6e 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.test.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.test.ts @@ -19,7 +19,7 @@ import { ConfigReader } from '@backstage/config'; import { Client, errors } from '@elastic/elasticsearch'; import Mock from '@elastic/elasticsearch-mock'; import { - ConcreteElasticSearchQuery, + ElasticSearchConcreteQuery, decodePageCursor, ElasticSearchSearchEngine, encodePageCursor, @@ -131,7 +131,7 @@ describe('ElasticSearchSearchEngine', () => { types: ['indexName'], term: 'testTerm', filters: { kind: 'testKind' }, - }) as ConcreteElasticSearchQuery; + }) as ElasticSearchConcreteQuery; expect(actualTranslatedQuery).toMatchObject({ documentTypes: ['indexName'], @@ -170,7 +170,7 @@ describe('ElasticSearchSearchEngine', () => { types: ['indexName'], term: 'testTerm', pageCursor: 'MQ==', - }) as ConcreteElasticSearchQuery; + }) as ElasticSearchConcreteQuery; expect(actualTranslatedQuery).toMatchObject({ documentTypes: ['indexName'], @@ -210,7 +210,7 @@ describe('ElasticSearchSearchEngine', () => { foo: 123, bar: true, }, - }) as ConcreteElasticSearchQuery; + }) as ElasticSearchConcreteQuery; expect(actualTranslatedQuery).toMatchObject({ documentTypes: ['indexName'], @@ -266,7 +266,7 @@ describe('ElasticSearchSearchEngine', () => { types: ['indexName'], term: 'testTerm', filters: { kind: ['testKind', 'kastTeint'] }, - }) as ConcreteElasticSearchQuery; + }) as ElasticSearchConcreteQuery; expect(actualTranslatedQuery).toMatchObject({ documentTypes: ['indexName'], @@ -327,7 +327,7 @@ describe('ElasticSearchSearchEngine', () => { fragmentDelimiter: ' ... ', }, }, - ) as ConcreteElasticSearchQuery; + ) as ElasticSearchConcreteQuery; expect(actualTranslatedQuery).toMatchObject({ documentTypes: ['indexName'], @@ -369,7 +369,7 @@ describe('ElasticSearchSearchEngine', () => { types: ['indexName'], term: 'testTerm', filters: { kind: { a: 'b' } }, - }) as ConcreteElasticSearchQuery; + }) as ElasticSearchConcreteQuery; expect(actualTranslatedQuery).toThrow(); }); }); diff --git a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts index 621fe1cd55..6541d2ed80 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngine.ts @@ -40,7 +40,7 @@ export type { ElasticSearchClientOptions }; * Search query that the elasticsearch engine understands. * @public */ -export type ConcreteElasticSearchQuery = { +export type ElasticSearchConcreteQuery = { documentTypes?: string[]; elasticSearchQuery: Object; pageSize: number; @@ -61,7 +61,7 @@ export type ElasticSearchQueryTranslatorOptions = { export type ElasticSearchQueryTranslator = ( query: SearchQuery, options?: ElasticSearchQueryTranslatorOptions, -) => ConcreteElasticSearchQuery; +) => ElasticSearchConcreteQuery; /** * Options for instansiate ElasticSearchSearchEngine @@ -174,7 +174,7 @@ export class ElasticSearchSearchEngine implements SearchEngine { protected translator( query: SearchQuery, options?: ElasticSearchQueryTranslatorOptions, - ): ConcreteElasticSearchQuery { + ): ElasticSearchConcreteQuery { const { term, filters = {}, types, pageCursor } = query; const filter = Object.entries(filters) diff --git a/plugins/search-backend-module-elasticsearch/src/engines/index.ts b/plugins/search-backend-module-elasticsearch/src/engines/index.ts index 625c0d9b60..d99f96ef72 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/index.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/index.ts @@ -23,7 +23,7 @@ export type { ElasticSearchAuth, } from './ElasticSearchClientOptions'; export type { - ConcreteElasticSearchQuery, + ElasticSearchConcreteQuery, ElasticSearchClientOptions, ElasticSearchHighlightConfig, ElasticSearchHighlightOptions, diff --git a/plugins/search-backend-module-elasticsearch/src/index.ts b/plugins/search-backend-module-elasticsearch/src/index.ts index 3cfb3c403f..772c7d3689 100644 --- a/plugins/search-backend-module-elasticsearch/src/index.ts +++ b/plugins/search-backend-module-elasticsearch/src/index.ts @@ -23,7 +23,7 @@ export { ElasticSearchSearchEngine } from './engines'; export type { ElasticSearchAgentOptions, - ConcreteElasticSearchQuery, + ElasticSearchConcreteQuery, ElasticSearchClientOptions, ElasticSearchHighlightConfig, ElasticSearchHighlightOptions,