mongo-pipeline-kit
Version:
A feature-rich MongoDB pipeline builder kit for creating, reusing, and managing aggregation pipelines with enhanced JSON support and advanced utilities
68 lines (67 loc) • 1.62 kB
TypeScript
/**
* Represents a single MongoDB pipeline stage
*/
export type PipelineStage = {
[key: string]: any;
};
/**
* Represents a complete MongoDB pipeline
*/
export type Pipeline = PipelineStage[];
/**
* Options for pipeline validation
*/
export interface ValidationOptions {
strict?: boolean;
allowEmpty?: boolean;
maxStages?: number;
}
/**
* Options for pipeline composition
*/
export interface CompositionOptions {
deduplicate?: boolean;
validate?: boolean;
validationOptions?: ValidationOptions;
}
/**
* Pipeline stage builder interface
*/
export interface StageBuilder {
build(): PipelineStage;
}
/**
* Pipeline builder interface
*/
export interface IPipelineBuilder {
match(condition: object): this;
group(expression: object): this;
sort(sort: object): this;
limit(n: number): this;
skip(n: number): this;
project(projection: object): this;
addStage(stage: PipelineStage): this;
build(): Pipeline;
}
/**
* Pipeline composer interface
*/
export interface IPipelineComposer {
compose(...pipelines: Pipeline[]): this;
extend(basePipeline: Pipeline, extension: Pipeline): this;
validate(pipeline: Pipeline, options?: ValidationOptions): boolean;
build(): Pipeline;
}
/**
* Error types for pipeline operations
*/
export declare class PipelineError extends Error {
code: string;
constructor(message: string, code: string);
}
export declare class ValidationError extends PipelineError {
constructor(message: string);
}
export declare class CompositionError extends PipelineError {
constructor(message: string);
}