Clean up search-common/search-backend-node APIs, indicating beta.
Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
@@ -24,6 +24,7 @@ import { Transform, pipeline } from 'stream';
|
||||
import { Logger } from 'winston';
|
||||
import { Scheduler } from './index';
|
||||
import {
|
||||
IndexBuilderOptions,
|
||||
RegisterCollatorParameters,
|
||||
RegisterDecoratorParameters,
|
||||
} from './types';
|
||||
@@ -33,11 +34,9 @@ interface CollatorEnvelope {
|
||||
refreshInterval: number;
|
||||
}
|
||||
|
||||
type IndexBuilderOptions = {
|
||||
searchEngine: SearchEngine;
|
||||
logger: Logger;
|
||||
};
|
||||
|
||||
/**
|
||||
* @beta
|
||||
*/
|
||||
export class IndexBuilder {
|
||||
private collators: Record<string, CollatorEnvelope>;
|
||||
private decorators: Record<string, DocumentDecoratorFactory[]>;
|
||||
|
||||
@@ -26,6 +26,9 @@ type TaskEnvelope = {
|
||||
* TODO: coordination, error handling
|
||||
*/
|
||||
|
||||
/**
|
||||
* @beta
|
||||
*/
|
||||
export class Scheduler {
|
||||
private logger: Logger;
|
||||
private schedule: TaskEnvelope[];
|
||||
|
||||
@@ -25,6 +25,9 @@ import lunr from 'lunr';
|
||||
import { Logger } from 'winston';
|
||||
import { LunrSearchEngineIndexer } from './LunrSearchEngineIndexer';
|
||||
|
||||
/**
|
||||
* @beta
|
||||
*/
|
||||
export type ConcreteLunrQuery = {
|
||||
lunrQueryBuilder: lunr.Index.QueryBuilder;
|
||||
documentTypes?: string[];
|
||||
@@ -36,8 +39,14 @@ type LunrResultEnvelope = {
|
||||
type: string;
|
||||
};
|
||||
|
||||
type LunrQueryTranslator = (query: SearchQuery) => ConcreteLunrQuery;
|
||||
/**
|
||||
* @beta
|
||||
*/
|
||||
export type LunrQueryTranslator = (query: SearchQuery) => ConcreteLunrQuery;
|
||||
|
||||
/**
|
||||
* @beta
|
||||
*/
|
||||
export class LunrSearchEngine implements SearchEngine {
|
||||
protected lunrIndices: Record<string, lunr.Index> = {};
|
||||
protected docStore: Record<string, IndexableDocument>;
|
||||
|
||||
@@ -18,6 +18,9 @@ import { IndexableDocument } from '@backstage/search-common';
|
||||
import lunr from 'lunr';
|
||||
import { BatchSearchEngineIndexer } from '../indexing';
|
||||
|
||||
/**
|
||||
* @beta
|
||||
*/
|
||||
export class LunrSearchEngineIndexer extends BatchSearchEngineIndexer {
|
||||
private schemaInitialized = false;
|
||||
private builder: lunr.Builder;
|
||||
|
||||
@@ -15,5 +15,8 @@
|
||||
*/
|
||||
|
||||
export { LunrSearchEngine } from './LunrSearchEngine';
|
||||
export type { ConcreteLunrQuery } from './LunrSearchEngine';
|
||||
export type {
|
||||
ConcreteLunrQuery,
|
||||
LunrQueryTranslator,
|
||||
} from './LunrSearchEngine';
|
||||
export type { LunrSearchEngineIndexer } from './LunrSearchEngineIndexer';
|
||||
|
||||
@@ -23,7 +23,16 @@
|
||||
export { IndexBuilder } from './IndexBuilder';
|
||||
export { Scheduler } from './Scheduler';
|
||||
export { LunrSearchEngine } from './engines';
|
||||
export type { LunrSearchEngineIndexer } from './engines';
|
||||
export type {
|
||||
ConcreteLunrQuery,
|
||||
LunrQueryTranslator,
|
||||
LunrSearchEngineIndexer,
|
||||
} from './engines';
|
||||
export type {
|
||||
IndexBuilderOptions,
|
||||
RegisterCollatorParameters,
|
||||
RegisterDecoratorParameters,
|
||||
} from './types';
|
||||
export * from './indexing';
|
||||
export * from './test-utils';
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ import { assertError } from '@backstage/errors';
|
||||
import { IndexableDocument } from '@backstage/search-common';
|
||||
import { Writable } from 'stream';
|
||||
|
||||
/**
|
||||
* @beta
|
||||
*/
|
||||
export type BatchSearchEngineOptions = {
|
||||
batchSize: number;
|
||||
};
|
||||
@@ -25,6 +28,7 @@ export type BatchSearchEngineOptions = {
|
||||
/**
|
||||
* Base class encapsulating batch-based stream processing. Useful as a base
|
||||
* class for search engine indexers.
|
||||
* @beta
|
||||
*/
|
||||
export abstract class BatchSearchEngineIndexer extends Writable {
|
||||
private batchSize: number;
|
||||
|
||||
@@ -21,6 +21,7 @@ import { Transform } from 'stream';
|
||||
/**
|
||||
* Base class encapsulating simple async transformations. Useful as a base
|
||||
* class for Backstage search decorators.
|
||||
* @beta
|
||||
*/
|
||||
export abstract class DecoratorBase extends Transform {
|
||||
private initialized: Promise<undefined | Error>;
|
||||
|
||||
@@ -19,6 +19,7 @@ import { pipeline, Readable, Transform, Writable } from 'stream';
|
||||
|
||||
/**
|
||||
* Object resolved after a test pipeline is executed.
|
||||
* @beta
|
||||
*/
|
||||
export type TestPipelineResult = {
|
||||
/**
|
||||
@@ -36,6 +37,7 @@ export type TestPipelineResult = {
|
||||
|
||||
/**
|
||||
* Test utility for Backstage Search collators, decorators, and indexers.
|
||||
* @beta
|
||||
*/
|
||||
export class TestPipeline {
|
||||
private collator?: Readable;
|
||||
|
||||
@@ -17,10 +17,21 @@
|
||||
import {
|
||||
DocumentCollatorFactory,
|
||||
DocumentDecoratorFactory,
|
||||
SearchEngine,
|
||||
} from '@backstage/search-common';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
/**
|
||||
* @beta
|
||||
*/
|
||||
export type IndexBuilderOptions = {
|
||||
searchEngine: SearchEngine;
|
||||
logger: Logger;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parameters required to register a collator.
|
||||
* @beta
|
||||
*/
|
||||
export interface RegisterCollatorParameters {
|
||||
/**
|
||||
@@ -36,6 +47,7 @@ export interface RegisterCollatorParameters {
|
||||
|
||||
/**
|
||||
* Parameters required to register a decorator
|
||||
* @beta
|
||||
*/
|
||||
export interface RegisterDecoratorParameters {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user