core.d.ts
4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { Key, Comparator } from "./utils";
export interface Operation<TItem> {
readonly keep: boolean;
readonly done: boolean;
reset(): any;
next(item: TItem, key?: Key, owner?: any): any;
}
export declare type Tester = (item: any, key?: Key, owner?: any) => boolean;
export interface NamedOperation {
name: string;
}
export declare type OperationCreator<TItem> = (params: any, parentQuery: any, options: Options, name: string) => Operation<TItem>;
declare type BasicValueQuery<TValue> = {
$eq?: TValue;
$ne?: TValue;
$lt?: TValue;
$gt?: TValue;
$lte?: TValue;
$gte?: TValue;
$in?: TValue[];
$nin?: TValue[];
$all?: TValue[];
$mod?: [number, number];
$exists?: boolean;
$regex?: string | RegExp;
$size?: number;
$where?: ((this: TValue) => boolean) | string;
$options?: "i" | "g" | "m" | "u";
$type?: Function;
$not?: NestedQuery<TValue>;
$or?: NestedQuery<TValue>[];
$nor?: NestedQuery<TValue>[];
$and?: NestedQuery<TValue>[];
};
declare type ArrayValueQuery<TValue> = {
$elemMatch?: Query<TValue>;
} & BasicValueQuery<TValue>;
declare type Unpacked<T> = T extends (infer U)[] ? U : T;
declare type ValueQuery<TValue> = TValue extends Array<any> ? ArrayValueQuery<Unpacked<TValue>> : BasicValueQuery<TValue>;
declare type NotObject = string | number | Date | boolean | Array<any>;
declare type ShapeQuery<TItemSchema> = TItemSchema extends NotObject ? {} : {
[k in keyof TItemSchema]?: TItemSchema[k] | ValueQuery<TItemSchema[k]>;
};
declare type NestedQuery<TItemSchema> = ValueQuery<TItemSchema> & ShapeQuery<TItemSchema>;
export declare type Query<TItemSchema> = TItemSchema | RegExp | NestedQuery<TItemSchema>;
declare abstract class BaseOperation<TParams, TItem = any> implements Operation<TItem> {
readonly params: TParams;
readonly owneryQuery: any;
readonly options: Options;
keep: boolean;
done: boolean;
constructor(params: TParams, owneryQuery: any, options: Options);
protected init(): void;
reset(): void;
abstract next(item: any, key: Key, parent: any): any;
}
export declare abstract class NamedBaseOperation<TParams, TItem = any> extends BaseOperation<TParams, TItem> implements NamedOperation {
readonly name: string;
constructor(params: TParams, owneryQuery: any, options: Options, name: string);
}
declare abstract class GroupOperation extends BaseOperation<any> {
readonly children: Operation<any>[];
keep: boolean;
done: boolean;
constructor(params: any, owneryQuery: any, options: Options, children: Operation<any>[]);
/**
*/
reset(): void;
abstract next(item: any, key: Key, owner: any): any;
/**
*/
protected childrenNext(item: any, key: Key, owner: any): void;
}
export declare abstract class NamedGroupOperation extends GroupOperation implements NamedOperation {
readonly name: string;
constructor(params: any, owneryQuery: any, options: Options, children: Operation<any>[], name: string);
}
export declare class QueryOperation<TItem> extends GroupOperation {
/**
*/
next(item: TItem, key: Key, parent: any): void;
}
export declare class NestedOperation extends GroupOperation {
readonly keyPath: Key[];
constructor(keyPath: Key[], params: any, owneryQuery: any, options: Options, children: Operation<any>[]);
/**
*/
next(item: any, key: Key, parent: any): void;
/**
*/
private _nextNestedValue;
}
export declare const createTester: (a: any, compare: Comparator) => any;
export declare class EqualsOperation<TParam> extends BaseOperation<TParam> {
private _test;
init(): void;
next(item: any, key: Key, parent: any): void;
}
export declare const createEqualsOperation: (params: any, owneryQuery: any, options: Options) => EqualsOperation<any>;
export declare class NopeOperation<TParam> extends BaseOperation<TParam> {
next(): void;
}
export declare const numericalOperationCreator: (createNumericalOperation: OperationCreator<any>) => (params: any, owneryQuery: any, options: Options, name: string) => Operation<any> | NopeOperation<any>;
export declare const numericalOperation: (createTester: (any: any) => Tester) => (params: any, owneryQuery: any, options: Options, name: string) => Operation<any> | NopeOperation<any>;
export declare type Options = {
operations: {
[identifier: string]: OperationCreator<any>;
};
compare: (a: any, b: any) => boolean;
};
export declare const containsOperation: (query: any) => boolean;
export declare const createQueryOperation: <TItem, TSchema = TItem>(query: Query<TSchema>, owneryQuery?: any, { compare, operations }?: Partial<Options>) => QueryOperation<TItem>;
export declare const createOperationTester: <TItem>(operation: Operation<TItem>) => (item: TItem, key?: string | number, owner?: any) => boolean;
export declare const createQueryTester: <TItem, TSchema = TItem>(query: Query<TSchema>, options?: Partial<Options>) => (item: TItem, key?: string | number, owner?: any) => boolean;
export {};