@omegup/msync 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +605 -0
- package/index.esm.js +1583 -0
- package/index.js +1684 -0
- package/package.json +12 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import { Timestamp, BSON, Db, Collection, MongoClient as MongoClient$1 } from 'mongodb';
|
|
2
|
+
export { Collection, Timestamp } from 'mongodb';
|
|
3
|
+
import * as bson from 'bson';
|
|
4
|
+
|
|
5
|
+
type HasJob = {
|
|
6
|
+
job: object | undefined;
|
|
7
|
+
};
|
|
8
|
+
type Runner<T, Info extends HasJob> = Iterator<T, Info>;
|
|
9
|
+
type NextFrame<T, Info> = PromiseLike<Frame<T, Info>>;
|
|
10
|
+
type Frame<T, Info> = {
|
|
11
|
+
data: T;
|
|
12
|
+
info: Info;
|
|
13
|
+
cont: Iterator<T, Info>;
|
|
14
|
+
};
|
|
15
|
+
type IteratorResult<out T, out Info> = {
|
|
16
|
+
next: NextFrame<T, Info>;
|
|
17
|
+
stop: Iterator<T, Info>;
|
|
18
|
+
clear: () => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
type Iterator<out T, out Info> = () => IteratorResult<T, Info>;
|
|
21
|
+
|
|
22
|
+
declare const PredicateRaw: unique symbol;
|
|
23
|
+
type PredicateRaw = RawObj & {
|
|
24
|
+
[Type]?(x: typeof PredicateRaw): void;
|
|
25
|
+
};
|
|
26
|
+
declare const Predicate: unique symbol;
|
|
27
|
+
interface Predicate<in V> {
|
|
28
|
+
[Type]?(x: typeof Predicate, _: V): void;
|
|
29
|
+
raw: PredicateRaw;
|
|
30
|
+
expr: <D extends O, C>(field: Field<D, V, C>) => Expr<boolean, D, C>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare class Field<in R, out V, in C = unknown> {
|
|
34
|
+
private field;
|
|
35
|
+
private raw;
|
|
36
|
+
private concat;
|
|
37
|
+
has<R extends O>(this: Field<R, V>, p: Predicate<V>): Query<R, C>;
|
|
38
|
+
has<R extends O, V>(this: Field<R, Arr<V>>, p: Predicate<V>): Query<R, C>;
|
|
39
|
+
private constructor();
|
|
40
|
+
static root: <T extends O>() => Field<T, T, unknown>;
|
|
41
|
+
static ctx: <T>() => <K extends string>(k: K) => Field<unknown, T, RORec<K, T>>;
|
|
42
|
+
of<V, K extends keyof V, _ extends 0 = 0>(this: Field<R, Arr<V>, C>, k: AsLiteral<K>): Field<R, Arr<V[K]>, C>;
|
|
43
|
+
of<V, K extends keyof V, _ extends 1 = 1>(this: Field<R, O<V>, C>, k: K): Field<R, V[K], C>;
|
|
44
|
+
of<V, K extends keyof V, I extends N = never, _ extends 2 = 2>(this: Field<R, Arr<V> | Undef<I>, C>, k: K): Field<R, Arr<V[K]> | I, C>;
|
|
45
|
+
of<V, K extends keyof V, I extends N = never, _ extends 3 = 3>(this: Field<R, O<V> | Undef<I>, C>, k: K): Field<R, V[K] | I, C>;
|
|
46
|
+
with<V, W, C2 = unknown, _ extends 0 = 0>(this: Field<R, O<V>, C>, k: Field<O<V>, W, C2>): Field<R, W, C & C2>;
|
|
47
|
+
with<V, W, C2 = unknown, _ extends 1 = 1>(this: Field<R, Arr<V>, C>, k: Field<O<V>, Arr<W> | O<W>, C2>): Field<R, Arr<W>, C & C2>;
|
|
48
|
+
with<V, W, I extends N = never, C2 = unknown, _ extends 2 = 2>(this: Field<R, O<V> | Undef<I>, C>, k: Field<O<V>, W, C2>): Field<R, W | I, C & C2>;
|
|
49
|
+
with<V, W, I extends N = never, C2 = unknown, _ extends 3 = 3>(this: Field<R, Arr<V> | Undef<I>, C>, k: Field<O<V>, Arr<W> | O<W>, C2>): Field<R, Arr<W> | I, C & C2>;
|
|
50
|
+
str(this: Field<R, V>): string;
|
|
51
|
+
private exprRaw;
|
|
52
|
+
expr<R, V, C = unknown>(this: Field<R, V, C>): Expr<V, R, C>;
|
|
53
|
+
}
|
|
54
|
+
declare const root: <T extends O>() => Field<T, T, unknown>;
|
|
55
|
+
declare const ctx: <T>() => <K extends string>(k: K) => Field<unknown, T, RORec<K, T>>;
|
|
56
|
+
|
|
57
|
+
declare const QueryRaw: unique symbol;
|
|
58
|
+
type QueryRaw<T, C> = RawObj & {
|
|
59
|
+
[Type]?(x: typeof QueryRaw, y: T, c: C): void;
|
|
60
|
+
};
|
|
61
|
+
declare const Query: unique symbol;
|
|
62
|
+
type Query<in T extends O, in C = unknown> = {
|
|
63
|
+
[Type]?(x: typeof Query, y: T, c: C): void;
|
|
64
|
+
raw: <DeltaT extends O>(f: Field<DeltaT, T>) => QueryRaw<DeltaT, C>;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
declare const RawStage$1: unique symbol;
|
|
68
|
+
type RawArr = readonly RawObj[];
|
|
69
|
+
interface RawStages<out Q, in S extends Q, out R extends Q, in C = unknown, out M = number> extends RawArr {
|
|
70
|
+
[Type]?(_: typeof RawStage$1, source: S, ctx: C, q: Q): readonly [typeof RawStage$1, R, M, Q];
|
|
71
|
+
}
|
|
72
|
+
type FRawStages<out Q, in S extends Q & O, out R extends Q & O, in C = unknown, out M extends number = number> = <F extends HKT<O, O>>(f: <T extends O>() => Field<App<F, T>, T>) => RawStages<App<F, Q & O>, App<F, S>, App<F, R>, C, M>;
|
|
73
|
+
type DeltaStages<out Q, in S extends Q & O, out R extends Q & O, in C = unknown> = {
|
|
74
|
+
delta: RawStages<unknown, Delta<S>, Delta<R>, C>;
|
|
75
|
+
raw: FRawStages<Q, S, R, C>;
|
|
76
|
+
};
|
|
77
|
+
type LinStages<out Q, in S extends Q, out R extends Q, in C = unknown> = {
|
|
78
|
+
lin: RawStages<Q, S, R, C, 1>;
|
|
79
|
+
};
|
|
80
|
+
type TStages<in out S, out Q, in out B extends Q, out R extends Q, M extends number = number> = {
|
|
81
|
+
coll: ReadonlyCollection<S>;
|
|
82
|
+
input: RawStages<unknown, S, B, unknown, M>;
|
|
83
|
+
exec: RawStages<Q, B, R, unknown, M>;
|
|
84
|
+
};
|
|
85
|
+
type Stages<out Q, out R extends Q, out SDom> = <E>(consume: <S extends SDom, B extends Q>(value: TStages<S, Q, B, R>) => E) => E;
|
|
86
|
+
type StreamRunner<out V> = <Result>(input: RawStages<unknown, V, Result>) => Runner<readonly Result[], HasJob>;
|
|
87
|
+
type SimpleStreamExecutionResult<out Q, out V extends Q> = {
|
|
88
|
+
readonly out: StreamRunner<V>;
|
|
89
|
+
};
|
|
90
|
+
type SnapshotStreamExecutionResult<out Q, out V extends Q> = {
|
|
91
|
+
readonly out: StreamRunner<Delta<V>>;
|
|
92
|
+
readonly stages: Stages<Before<Q>, Before<V>, UBefore<Q>>;
|
|
93
|
+
};
|
|
94
|
+
type Stream<out Q extends O, in out T extends Q, in out F extends HKT<[O, O]>, in out G extends HKT<[O, O, O]>> = <Q2 extends O, Result extends Q2>(input: App<G, [Q2 | T, T, Result]>) => App<F, [Q | Q2, Result]>;
|
|
95
|
+
type TS = {
|
|
96
|
+
readonly touchedAt: Timestamp;
|
|
97
|
+
};
|
|
98
|
+
type Del = O<{
|
|
99
|
+
readonly deletedAt: Timestamp;
|
|
100
|
+
} & ID & TS>;
|
|
101
|
+
type D = O<{
|
|
102
|
+
readonly deletedAt?: Timestamp | null | undefined;
|
|
103
|
+
} & ID>;
|
|
104
|
+
type Model = D & TS;
|
|
105
|
+
type OutInput<T, A = T | null> = ID & Rec<'after', A>;
|
|
106
|
+
type BA = 'before' | 'after';
|
|
107
|
+
type PreDelta<T, K extends BA = BA, E = unknown> = Rec<K, T> & E;
|
|
108
|
+
type Delta<T, K extends BA = BA, E = ID> = PreDelta<T | null, K, E>;
|
|
109
|
+
type Before<T> = PreDelta<T, 'before'>;
|
|
110
|
+
type UBefore<T> = O & Partial<Delta<T | null, 'before'>>;
|
|
111
|
+
type SnapshotStream<out Q extends O, in out T extends Q> = <Q2 extends O, Result extends Q2>(input: DeltaStages<Q2 | T, T, Result>) => SnapshotStreamExecutionResult<Q | Q2, Result>;
|
|
112
|
+
|
|
113
|
+
declare const ExprRaw: unique symbol;
|
|
114
|
+
type ExprRaw<out T, in Doc, in Ctx = unknown> = {
|
|
115
|
+
[Type]?(x: typeof ExprRaw): void;
|
|
116
|
+
[ExprRaw]?(doc: Doc, ctx: Ctx): T;
|
|
117
|
+
get: () => rawItem;
|
|
118
|
+
};
|
|
119
|
+
declare const Expr: unique symbol;
|
|
120
|
+
type Expr<out T, in Doc, in Ctx = unknown> = {
|
|
121
|
+
[Type]?(x: typeof Expr): void;
|
|
122
|
+
[Expr]?(doc: Doc, ctx: Ctx): T;
|
|
123
|
+
raw: {
|
|
124
|
+
<DeltaD extends O, I extends U, C = unknown>(f: Field<DeltaD, Doc | Undef<I>, C>): ExprRaw<T | I, DeltaD, Ctx & C>;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
type BoolExpr<in D1, in D2, in Ctx = unknown> = {
|
|
128
|
+
[Type]?(x: typeof Expr): void;
|
|
129
|
+
[Expr](doc: D1, ctx: Ctx): true;
|
|
130
|
+
[Expr](doc: D2, ctx: Ctx): false;
|
|
131
|
+
raw: {
|
|
132
|
+
<DeltaD extends O, I extends U, C = unknown>(f: Field<DeltaD, D1 | D2 | Undef<I>, C>): ExprRaw<boolean, DeltaD, Ctx & C>;
|
|
133
|
+
<DeltaD extends O, I extends U, C = unknown>(f: Field<DeltaD, D1 | Undef<I>, C>): ExprRaw<true, DeltaD, Ctx & C>;
|
|
134
|
+
<DeltaD extends O, I extends U, C = unknown>(f: Field<DeltaD, D2 | Undef<I>, C>): ExprRaw<false, DeltaD, Ctx & C>;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
type ExactKeys<K extends string> = Exact<RORec<K, 1>, IdHKT>;
|
|
139
|
+
type MapO<T, F extends HKT<StrKey<T>>> = MapOPart<T, F> & {
|
|
140
|
+
readonly [P: string]: readonly [StrKey<T>, unknown];
|
|
141
|
+
};
|
|
142
|
+
type MapOPart<T, F extends HKT<StrKey<T>>, K extends keyof T = StrKey<T>> = {
|
|
143
|
+
readonly [P in K]: readonly [P, App<F, P & string>];
|
|
144
|
+
};
|
|
145
|
+
type Exact<T, F extends HKT<T[StrKey<T>]>> = MapO<T, MappedHKT<T, F>>;
|
|
146
|
+
interface MappedHKT<T, F extends HKT<T[StrKey<T>]>> extends HKT<StrKey<T>> {
|
|
147
|
+
readonly out: App<F, T[I<StrKey<T>, this>]>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
declare const AccumulatorRaw: unique symbol;
|
|
151
|
+
interface AccumulatorRaw<in Doc, out T, in C = unknown> extends RawObj {
|
|
152
|
+
[Type](_: typeof AccumulatorRaw, source: Doc, ctx: C): readonly [typeof AccumulatorRaw, T];
|
|
153
|
+
}
|
|
154
|
+
interface AccumulatorHKT<T, C = unknown> extends HKT<unknown> {
|
|
155
|
+
readonly out: Accumulator<T, I<unknown, this>, C>;
|
|
156
|
+
}
|
|
157
|
+
type Accumulators<T, V extends RORec<string, jsonItem>, C = unknown> = Exact<V, AccumulatorHKT<T, C>>;
|
|
158
|
+
interface DeltaAccumulatorHKT<T, C = unknown> extends HKT<unknown> {
|
|
159
|
+
readonly out: DeltaAccumulator<T, I<unknown, this>, C>;
|
|
160
|
+
}
|
|
161
|
+
type DeltaAccumulators<T, V extends RORec<string, jsonItem>, C = unknown> = Exact<V, DeltaAccumulatorHKT<T, C>>;
|
|
162
|
+
declare const Accumulator: unique symbol;
|
|
163
|
+
type Accumulator<in Doc, out T, in Ctx = unknown> = {
|
|
164
|
+
[Type]?(_: typeof Accumulator): typeof Accumulator;
|
|
165
|
+
raw: {
|
|
166
|
+
<DeltaD extends O, I extends U>(f: Field<DeltaD, Doc | Undef<I>>): AccumulatorRaw<T | I, DeltaD, Ctx>;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
type Part<Doc> = Rec<'v', Doc> & RORec<'old', boolean>;
|
|
170
|
+
type DeltaAccumulator<in out Doc, in out T, in out Ctx = unknown> = {
|
|
171
|
+
group: Accumulator<Part<Doc>, T, Ctx>;
|
|
172
|
+
merge: <D, C = Ctx>(a: Expr<T | N, D, C>, b: Expr<T, D, C>) => Expr<T, D, C>;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
interface ExprHKT<D, C = unknown, F extends HKT = IdHKT> extends HKT<unknown> {
|
|
176
|
+
readonly out: Expr<App<F, I<unknown, this>>, D, C>;
|
|
177
|
+
}
|
|
178
|
+
type ExprsExact<T, D, C = unknown, F extends HKT = IdHKT> = Exact<T, ExprHKT<D, C, F>>;
|
|
179
|
+
|
|
180
|
+
declare const Type: unique symbol;
|
|
181
|
+
|
|
182
|
+
type U = undefined;
|
|
183
|
+
type N = null | U;
|
|
184
|
+
type jsonPrim = number | null | string | boolean | Timestamp | Date;
|
|
185
|
+
type notObj = jsonPrim | U;
|
|
186
|
+
type notArr = notObj | O;
|
|
187
|
+
type jsonItem = unknown;
|
|
188
|
+
type rawItem = jsonPrim | raw | U;
|
|
189
|
+
type Undef<I extends N> = I | (I extends never ? I : notObj);
|
|
190
|
+
declare const object: unique symbol;
|
|
191
|
+
declare const array$1: unique symbol;
|
|
192
|
+
type A = {
|
|
193
|
+
[Type]: typeof array$1;
|
|
194
|
+
};
|
|
195
|
+
type Arr<T, N extends number = number> = A & {
|
|
196
|
+
readonly [_ in N]: T;
|
|
197
|
+
};
|
|
198
|
+
type Obj = {
|
|
199
|
+
[Type]: typeof object;
|
|
200
|
+
};
|
|
201
|
+
type O<T = unknown> = Obj & T;
|
|
202
|
+
type RORec<K extends keyof never, T = unknown> = {
|
|
203
|
+
readonly [P in K]: T;
|
|
204
|
+
};
|
|
205
|
+
type Rec<K extends string, T = unknown> = O<RORec<K, T>>;
|
|
206
|
+
type O2 = readonly [O, O];
|
|
207
|
+
type O3 = readonly [O, O, O];
|
|
208
|
+
type ID = {
|
|
209
|
+
readonly _id: string;
|
|
210
|
+
};
|
|
211
|
+
type doc = O & ID;
|
|
212
|
+
interface RawObj {
|
|
213
|
+
readonly [_: string]: rawItem | U;
|
|
214
|
+
}
|
|
215
|
+
type raw = readonly rawItem[] | RawObj;
|
|
216
|
+
type StrKey<T> = string & keyof T;
|
|
217
|
+
type Replace<R, V> = Omit<R, StrKey<V>> & V & O;
|
|
218
|
+
type AsLiteral<T extends keyof any | boolean, V = NoUnion<T>> = T extends keyof any ? {} extends {
|
|
219
|
+
[K in T]: 1;
|
|
220
|
+
} ? never : V : V;
|
|
221
|
+
type NoUnion<T, V = T> = T extends unknown ? ([V] extends [T] ? T : never) : never;
|
|
222
|
+
|
|
223
|
+
interface HKT<in Dom = unknown, out Im = unknown> {
|
|
224
|
+
readonly in: (x: Dom) => void;
|
|
225
|
+
readonly out: Im;
|
|
226
|
+
}
|
|
227
|
+
type App<F extends HKT<X>, X> = (F & {
|
|
228
|
+
readonly in: (x: X) => void;
|
|
229
|
+
})['out'];
|
|
230
|
+
type I<Dom, F extends HKT<Dom>> = F['in'] extends (x: infer X extends Dom) => void ? X : never;
|
|
231
|
+
interface IdHKT<Dom = unknown> extends HKT<Dom> {
|
|
232
|
+
readonly out: I<Dom, this>;
|
|
233
|
+
}
|
|
234
|
+
type AppMap<F extends HKT<Dom>, X extends readonly Dom[], Dom = unknown> = readonly App<F, Dom>[] & {
|
|
235
|
+
[I in keyof X]: App<F, X[I]>;
|
|
236
|
+
};
|
|
237
|
+
type AppMapRW<F extends HKT<Dom>, X extends readonly Dom[], Dom = unknown> = App<F, Dom>[] & {
|
|
238
|
+
[I in keyof X]: App<F, X[I]>;
|
|
239
|
+
};
|
|
240
|
+
interface PromiseHKT<Dom = unknown> extends HKT<Dom> {
|
|
241
|
+
readonly out: PromiseLike<I<Dom, this>>;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
type AsNum<R> = R extends `${infer A extends number}` ? A : never;
|
|
245
|
+
type GetDom<Dom = unknown> = readonly [readonly Dom[], keyof any];
|
|
246
|
+
declare global {
|
|
247
|
+
type Entry<T, K extends keyof T = keyof T> = readonly [string, T[string & K]] & {
|
|
248
|
+
[k in K]: readonly [string & k, T[k]];
|
|
249
|
+
}[K];
|
|
250
|
+
interface ObjectConstructor {
|
|
251
|
+
entries<T, _ = 0>(object?: T): readonly Entry<T>[];
|
|
252
|
+
fromEntries<T, _ = 0>(entries: readonly Entry<T>[]): T;
|
|
253
|
+
keys<T, _ extends 1>(obj: T): readonly StrKey<T>[];
|
|
254
|
+
}
|
|
255
|
+
interface ReadonlyArray<T> {
|
|
256
|
+
includes<T, V extends T>(this: ReadonlyArray<V>, item: T, fromIndex?: number): item is V;
|
|
257
|
+
map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[];
|
|
258
|
+
map<K extends string, T extends RORec<K>, U extends RORec<K>, _ extends 2 = 2>(this: readonly Entry<T, K>[], callbackfn: <P extends K>(value: [P, T[P]], index: number, array: this) => readonly [P, U[P]], thisArg?: any): readonly Entry<U, K>[];
|
|
259
|
+
map<V extends ReadonlyArray<unknown>, F extends HKT<unknown>, G extends HKT<unknown>, _ extends 1 = 1>(this: AppMap<F, V>, callbackfn: <I extends keyof V>(value: App<F, V[I]>, index: AsNum<I>, array: V) => App<G, V[I]>, thisArg?: any): AppMapRW<G, V>;
|
|
260
|
+
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
|
|
261
|
+
reduce<V extends ReadonlyArray<unknown>, F extends HKT, U>(this: AppMap<F, V>, callbackfn: <I extends keyof V>(previousValue: U, currentValue: App<F, V[I]>, currentIndex: AsNum<I>, array: V) => U, initialValue: U): U;
|
|
262
|
+
map<V extends ReadonlyArray<Dom>, F extends HKT<Dom>, G extends HKT<GetDom<Dom>>, Dom = unknown, _ extends 0 = 0>(this: AppMap<F, V, Dom>, callbackfn: <I extends keyof V>(value: App<F, V[I] & Dom>, index: AsNum<I>, array: V) => App<G, [V, I]>, thisArg?: any): AppMapRW<G, {
|
|
263
|
+
[I in keyof V]: [V, I];
|
|
264
|
+
}, GetDom<Dom>>;
|
|
265
|
+
}
|
|
266
|
+
interface Array<T> extends ReadonlyArray<T> {
|
|
267
|
+
includes<T, V extends T>(this: ReadonlyArray<V>, item: T, fromIndex?: number): item is V;
|
|
268
|
+
map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[];
|
|
269
|
+
map<K extends string, T extends RORec<K>, U extends RORec<K>, _ extends 2 = 2>(this: readonly Entry<T, K>[], callbackfn: <P extends K>(value: [P, T[P]], index: number, array: this) => readonly [P, U[P]], thisArg?: any): readonly Entry<U, K>[];
|
|
270
|
+
map<V extends ReadonlyArray<unknown>, F extends HKT<unknown>, G extends HKT<unknown>, _ extends 1 = 1>(this: AppMap<F, V>, callbackfn: <I extends keyof V>(value: App<F, V[I]>, index: AsNum<I>, array: V) => App<G, V[I]>, thisArg?: any): AppMapRW<G, V>;
|
|
271
|
+
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
|
|
272
|
+
reduce<V extends ReadonlyArray<unknown>, F extends HKT, U>(this: AppMap<F, V>, callbackfn: <I extends keyof V>(previousValue: U, currentValue: App<F, V[I]>, currentIndex: AsNum<I>, array: V) => U, initialValue: U): U;
|
|
273
|
+
map<V extends ReadonlyArray<Dom>, F extends HKT<Dom>, G extends HKT<GetDom<Dom>>, Dom = unknown, _ extends 0 = 0>(this: AppMap<F, V, Dom>, callbackfn: <I extends keyof V>(value: App<F, V[I] & Dom>, index: AsNum<I>, array: V) => App<G, [V, I]>, thisArg?: any): AppMapRW<G, {
|
|
274
|
+
[I in keyof V]: [V, I];
|
|
275
|
+
}, GetDom<Dom>>;
|
|
276
|
+
}
|
|
277
|
+
interface PromiseConstructor {
|
|
278
|
+
all<T extends readonly unknown[] | []>(values: AppMap<PromiseHKT, T>): Promise<T>;
|
|
279
|
+
race<T extends readonly unknown[] | [], _ extends 0 = 0>(values: AppMap<PromiseHKT, T>): Promise<T[number]>;
|
|
280
|
+
all<T extends readonly unknown[] | []>(values: T): Promise<{
|
|
281
|
+
-readonly [P in keyof T]: Awaited<T[P]>;
|
|
282
|
+
}>;
|
|
283
|
+
race<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
declare const RawStage: unique symbol;
|
|
288
|
+
declare module 'mongodb' {
|
|
289
|
+
interface Collection<TSchema extends BSON.Document = BSON.Document> {
|
|
290
|
+
[RawStage]: {
|
|
291
|
+
(_: 2): TSchema;
|
|
292
|
+
(_: 1, x: TSchema): TSchema;
|
|
293
|
+
};
|
|
294
|
+
s: {
|
|
295
|
+
db: Db;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
interface Db {
|
|
299
|
+
s: {
|
|
300
|
+
client?: MongoClient;
|
|
301
|
+
};
|
|
302
|
+
client: MongoClient;
|
|
303
|
+
}
|
|
304
|
+
interface Timestamp {
|
|
305
|
+
toExtendedJSON(): BSON.TimestampExtended;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface CommonCollection {
|
|
310
|
+
readonly s: {
|
|
311
|
+
readonly db: Db;
|
|
312
|
+
};
|
|
313
|
+
collectionName: string;
|
|
314
|
+
namespace: string;
|
|
315
|
+
dbName: string;
|
|
316
|
+
createIndex: Collection['createIndex'];
|
|
317
|
+
}
|
|
318
|
+
interface ReadonlyCollection<out Out> extends CommonCollection {
|
|
319
|
+
[RawStage](_: 2): Out;
|
|
320
|
+
}
|
|
321
|
+
interface WriteonlyCollection<in R> extends CommonCollection {
|
|
322
|
+
[RawStage]: {
|
|
323
|
+
(_: 1, x: R): unknown;
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
interface RWCollection<in R extends O, out Out extends O = R> extends CommonCollection {
|
|
327
|
+
[RawStage](_: 2): Out;
|
|
328
|
+
[RawStage](_: 1, x: R): unknown;
|
|
329
|
+
}
|
|
330
|
+
type OPick<V, K extends StrKey<V>, E extends StrKey<V> = never> = O & Pick<V, K | E>;
|
|
331
|
+
type OPickD<V extends Model, K extends StrKey<V>> = OPick<V, K, 'deletedAt' | '_id'>;
|
|
332
|
+
type View<V extends Model, K extends StrKey<V>> = {
|
|
333
|
+
collection: ReadonlyCollection<V | Del>;
|
|
334
|
+
projection: ExactKeys<K>;
|
|
335
|
+
match?: Expr<boolean, OPickD<V, K>>;
|
|
336
|
+
hardMatch?: Query<V>;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
declare const val: <T extends rawItem>(val: T) => Expr<T, unknown>;
|
|
340
|
+
declare const current: Expr<Timestamp, unknown>;
|
|
341
|
+
declare const $let: <T, D, C, V extends RORec<string, jsonItem>>(vars: ExprsExact<V, D, C>, inExpr: Expr<T, D, C & V>) => Expr<T, D, C>;
|
|
342
|
+
declare const nil: Expr<null, unknown>;
|
|
343
|
+
declare const $getField: {
|
|
344
|
+
<T, K extends StrKey<T>, D, C = unknown>(expr: Expr<T, D, C>, field: K): Expr<T[K], D, C>;
|
|
345
|
+
<T, K extends StrKey<T>, D, C = unknown>(expr: Expr<T | N, D, C>, field: K): Expr<T[K] | null, D, C>;
|
|
346
|
+
};
|
|
347
|
+
type NoRaw<T> = T extends Arr<infer U> ? NoRaw<U>[] : T extends readonly unknown[] ? {
|
|
348
|
+
[K in keyof T]: NoRaw<T[K]>;
|
|
349
|
+
} : T extends O ? {
|
|
350
|
+
[K in StrKey<T>]: NoRaw<T[K]>;
|
|
351
|
+
} : T;
|
|
352
|
+
type RONoRaw<T> = T extends Arr<infer U> ? readonly RONoRaw<U>[] : T extends readonly unknown[] ? {
|
|
353
|
+
readonly [K in keyof T]: RONoRaw<T[K]>;
|
|
354
|
+
} : T extends O ? {
|
|
355
|
+
readonly [K in StrKey<T>]: RONoRaw<T[K]>;
|
|
356
|
+
} : T;
|
|
357
|
+
declare const func: <T extends jsonItem, A extends readonly jsonItem[], D, C = unknown>(f: (...args: NoRaw<A>) => RONoRaw<T>, ...args: { [X in keyof A]: Expr<A[X], D, C>; }) => Expr<T, D, C>;
|
|
358
|
+
declare const rand: () => string;
|
|
359
|
+
declare const $rand: Expr<string, unknown, unknown>;
|
|
360
|
+
|
|
361
|
+
declare const $sum: <D extends O, C = unknown>(expr: Expr<number | N, D, C>) => DeltaAccumulator<D, number, C>;
|
|
362
|
+
declare const $accumulator: <D, T, Ctx, A extends readonly unknown[]>(init: () => NoRaw<T>, accumulateArgs: AppMap<ExprHKT<Part<D>, Ctx>, A>, accumulate: (a: NoRaw<T>, ...args: NoRaw<A>) => NoRaw<T>, merge: (...args: NoRaw<[T | N, T]>) => NoRaw<T>) => DeltaAccumulator<D, T, Ctx>;
|
|
363
|
+
declare const $countDict: <D extends O, C = unknown>(expr: Expr<string, D, C>) => DeltaAccumulator<D, Rec<string, number>, C>;
|
|
364
|
+
declare const $pushDict: <D extends O, V, C = unknown>(key: Expr<string, D, C>, value: Expr<V, D, C>) => DeltaAccumulator<D, Rec<string, Rec<"0" | "1", Arr<V>>>, C>;
|
|
365
|
+
declare const $keys: <D extends O, C = unknown>(expr: Expr<Rec<string, number>, D, C>) => Expr<Arr<string>, D, C>;
|
|
366
|
+
declare const $entries: <D extends O, V, C = unknown>(expr: Expr<Rec<string, Rec<"1" | "0", Arr<V>>>, D, C>) => Expr<Arr<Rec<"k", string> & Rec<"v", V>>, D, C>;
|
|
367
|
+
|
|
368
|
+
type MergeInto<T extends O, Out extends O, E = unknown> = {
|
|
369
|
+
whenNotMatched: 'insert';
|
|
370
|
+
into: RWCollection<T, Out>;
|
|
371
|
+
} | {
|
|
372
|
+
whenNotMatched: 'discard' | 'fail';
|
|
373
|
+
into: ReadonlyCollection<Out> & E;
|
|
374
|
+
};
|
|
375
|
+
type MergeArgs<T extends O, Out extends O, Ctx, In extends O> = {
|
|
376
|
+
on: Field<T, jsonItem> & Field<Out, jsonItem>;
|
|
377
|
+
} & MergeInto<T, Out> & (({
|
|
378
|
+
stages?: undefined;
|
|
379
|
+
} & ({
|
|
380
|
+
whenMatched: 'keepExisting' | 'fail';
|
|
381
|
+
} | {
|
|
382
|
+
whenMatched: 'replace';
|
|
383
|
+
into: RWCollection<T, Out>;
|
|
384
|
+
} | {
|
|
385
|
+
whenMatched: 'merge';
|
|
386
|
+
into: RWCollection<Replace<Out, T>, Out>;
|
|
387
|
+
})) | {
|
|
388
|
+
stages: true;
|
|
389
|
+
into: RWCollection<In, Out>;
|
|
390
|
+
whenMatched: RawStages<unknown, Out, In>;
|
|
391
|
+
} | {
|
|
392
|
+
stages: 'ctx';
|
|
393
|
+
vars: ExprsExact<Ctx, T>;
|
|
394
|
+
into: RWCollection<In, Out>;
|
|
395
|
+
whenMatched: RawStages<unknown, Out, In, Ctx>;
|
|
396
|
+
});
|
|
397
|
+
declare const $merge_: <T extends O, Out extends O = T, Ctx = unknown, In extends O = Out>({ into, on, whenNotMatched, ...notMatched }: MergeArgs<T, Out, Ctx, In>) => RawStages<unknown, T, "out", unknown, number>;
|
|
398
|
+
|
|
399
|
+
type GI$1<GG> = Exclude<GG, keyof TS>;
|
|
400
|
+
type IdAndTsKeys = keyof (TS & ID);
|
|
401
|
+
type V<VV, GG extends string> = Omit<VV, IdAndTsKeys | GI$1<GG>>;
|
|
402
|
+
type Prepare<Grp, GG extends string> = TS & ID & Rec<GI$1<GG>, Grp>;
|
|
403
|
+
type Loose<Grp, VV, GG extends string> = Prepare<Grp, GG> & Partial<V<VV, GG>>;
|
|
404
|
+
type Strict<Grp, VV, GG extends string, EE> = Prepare<Grp, GG> & V<VV, GG> & Omit<EE, IdAndTsKeys | GI$1<GG> | keyof V<VV, GG>>;
|
|
405
|
+
type V_Grp<VV, GG extends string, Grp> = Rec<GI$1<GG>, Grp> & V<VV, GG>;
|
|
406
|
+
type Extra<EE, VV, GG extends string> = Omit<EE, IdAndTsKeys | GI$1<GG> | keyof V<VV, GG>>;
|
|
407
|
+
|
|
408
|
+
type Denied<GID = never> = keyof (TS & ID) | GID;
|
|
409
|
+
type GI<GG> = Exclude<GG, keyof TS>;
|
|
410
|
+
declare const $groupMerge: <T extends O, Grp extends notArr, V extends O, GG extends string, EE = {}, Out extends Loose<Grp, V, GG> = Loose<Grp, V, GG>>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<GI<GG>>>>, out: MergeInto<Strict<Grp, V, GG, EE>, Out, WriteonlyCollection<Replace<Out, Strict<Grp, V, GG, EE>>>>, gid: AsLiteral<GI<GG>>, extra: ExprsExact<Extra<EE, V, GG>, V_Grp<V, GG, Grp>>, idPrefix?: string) => RawStages<unknown, Delta<T>, "out">;
|
|
411
|
+
declare const $groupId: <T extends O, V extends O, EE = {}, Out extends Loose<string, V, "_id"> = Loose<string, V, "_id">>(id: Expr<string, T>, args: DeltaAccumulators<T, O & Omit<V, Denied>>, out: RWCollection<Replace<Out, Strict<string, V, "_id", EE>>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | keyof Omit<V, IdAndTsKeys>>, doc & Omit<V, IdAndTsKeys>>) => RawStages<unknown, Delta<T>, "out">;
|
|
412
|
+
declare const $group: <T extends O, Grp extends notArr, V extends O, EE = {}, Out extends Loose<Grp, V, "_grp"> = Loose<Grp, V, "_grp">>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<"_grp">>>, out: RWCollection<Strict<Grp, V, "_grp", EE>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | "_grp" | keyof Omit<V, IdAndTsKeys | "_grp">>, Rec<"_grp", Grp> & Omit<V, IdAndTsKeys | "_grp">>, idPrefix?: string) => RawStages<unknown, Delta<T>, "out">;
|
|
413
|
+
|
|
414
|
+
type Params<As extends string, LQ extends O, RQ extends O, RE extends RQ, S extends notArr> = {
|
|
415
|
+
localField: Field<LQ, S>;
|
|
416
|
+
foreignField: Field<RQ, S>;
|
|
417
|
+
from: SnapshotStreamExecutionResult<RQ, RE>;
|
|
418
|
+
as: AsLiteral<As>;
|
|
419
|
+
};
|
|
420
|
+
declare const $lookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr>(p: Params<As, LQ, RQ, RE, S>) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ, LE & RORec<As, RE>>;
|
|
421
|
+
|
|
422
|
+
declare const $matchDelta: <T extends doc>(query: Expr<boolean, T>) => RawStages<unknown, Delta<T>, Delta<T>, unknown, number>;
|
|
423
|
+
|
|
424
|
+
declare const $match: <T extends doc>(query: Expr<boolean, T>) => DeltaStages<T, T, T>;
|
|
425
|
+
|
|
426
|
+
declare const Updater: unique symbol;
|
|
427
|
+
type Updater<in R, in T, out V, in C = unknown> = {
|
|
428
|
+
[Type]?(x: typeof Updater, r: R, t: T, c: C): V;
|
|
429
|
+
readonly raw: <D extends O>(f: Field<D, R | N>) => readonly (readonly [string, rawItem])[];
|
|
430
|
+
};
|
|
431
|
+
interface UpdaterHKT<R, Old, V, C, K extends keyof Old = keyof Old, V2 extends V = V> extends HKT<StrKey<V>> {
|
|
432
|
+
readonly out: Updater<R, Get<Old, I<StrKey<V>, this>, K>, V2[I<StrKey<V>, this>], C>;
|
|
433
|
+
}
|
|
434
|
+
type Get<T, P extends string, K extends keyof T = never> = P extends K ? T[P] : P extends keyof T ? T[P] : undefined;
|
|
435
|
+
|
|
436
|
+
declare const $set: <V extends O>() => <R extends O, C = unknown>(fields: MapO<V, UpdaterHKT<R, R, V, C>>) => DeltaStages<O, R, Replace<R, V>, C> & LinStages<O, R, Replace<R, V>, C>;
|
|
437
|
+
declare const $replaceWith: <T extends O, V extends O>(expr: Expr<V, T>) => DeltaStages<O, T, V> & LinStages<O, T, V>;
|
|
438
|
+
|
|
439
|
+
type s$1 = string;
|
|
440
|
+
declare const $unwindDelta: <K1 extends s$1, T extends doc, K2 extends s$1, U extends doc>(k1: AsLiteral<K1>, k2: AsLiteral<K2>, k: K1 | K2 | false) => RawStages<Delta<Rec<K1, T>>, Delta<Rec<K1, T> & Rec<K2, Arr<U>>>, Delta<Rec<K1, T> & Rec<K2, U> & ID>>;
|
|
441
|
+
|
|
442
|
+
type s = string;
|
|
443
|
+
declare const $unwind: <T extends doc, K extends s, U extends doc>(k: AsLiteral<K>, dict: RORec<K, "key">) => DeltaStages<O, T & Rec<K, Arr<U>>, T & Rec<K, U>>;
|
|
444
|
+
|
|
445
|
+
type Allowed$2<K extends string> = Exclude<K, keyof (TS & ID)>;
|
|
446
|
+
type Patch<V, KK extends StrKey<V>> = ((OPick<V, Allowed$2<KK>> & ID) | (Rec<Allowed$2<KK>, N> & ID)) & TS;
|
|
447
|
+
declare const $merge: <V extends Model & ID>() => <KK extends StrKey<V>, Out extends doc>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed$2<KK>>) => RawStages<unknown, OutInput<OPick<V, Allowed$2<KK>> & ID>, "out">;
|
|
448
|
+
|
|
449
|
+
type ND = {
|
|
450
|
+
readonly deletedAt?: null;
|
|
451
|
+
};
|
|
452
|
+
type Merge<T extends ID> = (T & ND & TS) | Del;
|
|
453
|
+
declare const $upsert: <T extends doc>(out: RWCollection<Merge<T>>) => RawStages<unknown, OutInput<T>, "out">;
|
|
454
|
+
|
|
455
|
+
type DeltaPipe<Q extends O, T extends Q, F extends HKT<O2>, G extends HKT<O3>> = {
|
|
456
|
+
with: <Q2 extends O, V extends Q2>(map: (a: Stream<Q, T, F, G>) => Stream<Q | Q2, V, F, G>) => DeltaPipe<Q | Q2, V, F, G>;
|
|
457
|
+
then: <Q2 extends O, V extends Q2>(next: App<G, [Q2 | T, T, V]>) => DeltaPipe<Q | Q2, V, F, G>;
|
|
458
|
+
get: () => App<F, [Q, T]>;
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
type Allowed$1<K> = Exclude<K, 'deletedAt' | '_id'>;
|
|
462
|
+
type AllowedPick$1<V extends Model, K extends StrKey<V>> = OPickD<V, Allowed$1<K>>;
|
|
463
|
+
interface SnapshotStreamHKT extends HKT<O2> {
|
|
464
|
+
readonly out: SnapshotStreamExecutionResult<I<O2, this>[0], I<O2, this>[1]>;
|
|
465
|
+
}
|
|
466
|
+
interface DeltaHKT extends HKT<O3> {
|
|
467
|
+
readonly out: DeltaStages<I<O3, this>[0], I<O3, this>[1], I<O3, this>[2]>;
|
|
468
|
+
}
|
|
469
|
+
declare const staging: <V extends Model, KK extends StrKey<V>>(view: View<V, Allowed$1<KK>>, streamName: string) => DeltaPipe<AllowedPick$1<V, KK>, AllowedPick$1<V, KK>, SnapshotStreamHKT, DeltaHKT>;
|
|
470
|
+
|
|
471
|
+
type Allowed<K> = Exclude<K, 'deletedAt' | '_id'>;
|
|
472
|
+
type AllowedPick<V extends Model, K extends StrKey<V>> = OPickD<V, Allowed<K>>;
|
|
473
|
+
interface StreamRunnerHKT extends HKT<O2> {
|
|
474
|
+
readonly out: SimpleStreamExecutionResult<I<O2, this>[0], I<O2, this>[1]>;
|
|
475
|
+
}
|
|
476
|
+
interface StagesHKT extends HKT<O3> {
|
|
477
|
+
readonly out: RORec<'lin', RawStages<I<O3, this>[0], I<O3, this>[1], I<O3, this>[2], unknown, 1>>;
|
|
478
|
+
}
|
|
479
|
+
declare const from: <V extends Model, KK extends StrKey<V>>(view: View<V, Allowed<KK>>, streamName: string) => DeltaPipe<AllowedPick<V, KK>, AllowedPick<V, KK>, StreamRunnerHKT, StagesHKT>;
|
|
480
|
+
|
|
481
|
+
declare const max: <D, C>(...expr: Expr<number, D, C>[]) => Expr<number, D, C>;
|
|
482
|
+
declare const lt: <D, C>(expr_0: Expr<number, D, C>, expr_1: Expr<number, D, C>) => Expr<boolean, D, C>;
|
|
483
|
+
declare const gt: <D, C>(expr_0: Expr<number, D, C>, expr_1: Expr<number, D, C>) => Expr<boolean, D, C>;
|
|
484
|
+
declare const lte: {
|
|
485
|
+
<D, C>(...expr: [Expr<Date, D, C>, Expr<Date, D, C>]): Expr<boolean, D, C>;
|
|
486
|
+
<D, C>(...expr: [Expr<number, D, C>, Expr<number, D, C>]): Expr<boolean, D, C>;
|
|
487
|
+
};
|
|
488
|
+
declare const gte: {
|
|
489
|
+
<D, C>(...expr: [Expr<Date, D, C>, Expr<Date, D, C>]): Expr<boolean, D, C>;
|
|
490
|
+
<D, C>(...expr: [Expr<number, D, C>, Expr<number, D, C>]): Expr<boolean, D, C>;
|
|
491
|
+
};
|
|
492
|
+
type Num = number | null | undefined;
|
|
493
|
+
declare function subtract<D, C>(...expr: [Expr<number, D, C>, Expr<number, D, C>]): Expr<number, D, C>;
|
|
494
|
+
declare function subtract<D, C>(...expr: [Expr<Num, D, C>, Expr<Num, D, C>]): Expr<Num, D, C>;
|
|
495
|
+
declare function add<D, C>(...expr: [Expr<number, D, C>, Expr<number, D, C>]): Expr<number, D, C>;
|
|
496
|
+
declare function add<D, C>(...expr: [Expr<Num, D, C>, Expr<Num, D, C>]): Expr<Num, D, C>;
|
|
497
|
+
declare function divide<D, C>(...expr: [Expr<number, D, C>, Expr<number, D, C>]): Expr<number, D, C>;
|
|
498
|
+
declare function divide<D, C>(...expr: [Expr<Num, D, C>, Expr<Num, D, C>]): Expr<Num, D, C>;
|
|
499
|
+
declare function multiply<D, C>(...expr: [Expr<number, D, C>, Expr<number, D, C>]): Expr<number, D, C>;
|
|
500
|
+
declare function multiply<D, C>(...expr: [Expr<Num, D, C>, Expr<Num, D, C>]): Expr<Num, D, C>;
|
|
501
|
+
declare function floor<D, C>(expr: Expr<number, D, C>): Expr<number, D, C>;
|
|
502
|
+
declare function floor<D, C>(expr: Expr<Num, D, C>): Expr<Num, D, C>;
|
|
503
|
+
declare function ceil<D, C>(expr: Expr<number, D, C>): Expr<number, D, C>;
|
|
504
|
+
declare function ceil<D, C>(expr: Expr<Num, D, C>): Expr<Num, D, C>;
|
|
505
|
+
|
|
506
|
+
declare const size: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<number, D, C>;
|
|
507
|
+
declare const filterDefined: <T, D, C = unknown>(expr: Expr<Arr<T | N>, D, C>) => Expr<Arr<T>, D, C>;
|
|
508
|
+
declare const filter: <T, D, K extends string, C = unknown>({ as, cond, expr, limit, }: {
|
|
509
|
+
expr: Expr<Arr<T>, D, C>;
|
|
510
|
+
as: K;
|
|
511
|
+
cond: Expr<unknown, D, C & RORec<K, T>>;
|
|
512
|
+
limit?: Expr<number, D, C>;
|
|
513
|
+
}) => Expr<Arr<T>, D, C>;
|
|
514
|
+
declare const sortArray: <T, D, C, K extends keyof T>({ sortBy, expr, order, }: {
|
|
515
|
+
expr: Expr<Arr<T>, D, C>;
|
|
516
|
+
sortBy: K;
|
|
517
|
+
order?: 1 | -1;
|
|
518
|
+
}) => Expr<Arr<T>, D, C>;
|
|
519
|
+
declare const isArray: <T extends notArr, D, C, F extends HKT<T | Arr<T>>>(expr: Expr<T | Arr<T>, D & (App<F, T> | App<F, Arr<T>>), C>) => BoolExpr<D & App<F, Arr<T>>, D & App<F, T>, C>;
|
|
520
|
+
declare const array: <T, D, C = unknown>(...exprs: Expr<T, D, C>[]) => Expr<Arr<T>, D, C>;
|
|
521
|
+
declare const concat: <T, D, C>(...exprs: Expr<Arr<T>, D, C>[]) => Expr<Arr<T>, D, C>;
|
|
522
|
+
declare const first: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
|
|
523
|
+
declare const firstSure: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T, D, C>;
|
|
524
|
+
declare const last: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
|
|
525
|
+
declare const mergeObjects: <T1, T2, D, C = unknown>(exprs_0: Expr<T1, D, C>, exprs_1: Expr<T2, D, C>) => Expr<T1 & T2, D, C>;
|
|
526
|
+
declare const inArray: <T, D, C = unknown>(exprs_0: Expr<T, D, C>, exprs_1: Expr<Arr<T>, D, C>) => Expr<boolean, D, C>;
|
|
527
|
+
declare const slice: <T, D, C>(array: Expr<Arr<T>, D, C>, start: Expr<number, D, C>, end: Expr<number, D, C>) => Expr<Arr<T>, D, C>;
|
|
528
|
+
declare const except: <T, D, C>(a: Expr<Arr<T>, D, C>, b: Expr<Arr<T>, D, C>) => Expr<Arr<T>, D, C>;
|
|
529
|
+
|
|
530
|
+
declare const dayAndMonthPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
|
|
531
|
+
declare const now: <D, C>() => Expr<Date, D, C>;
|
|
532
|
+
declare const monthPart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
|
|
533
|
+
declare const dateAdd: <D, C>(date: Expr<Date, D, C>, amount: Expr<number, D, C>, unit: Expr<"year" | "week" | "month" | "day" | "hour" | "minute" | "second", D, C>) => Expr<Date, D, C>;
|
|
534
|
+
declare const maxDate: <D, C>(expr: Expr<Arr<Date>, D, C>) => Expr<Date, D, C>;
|
|
535
|
+
declare const minDate: <D, C>(expr: Expr<Arr<Date>, D, C>) => Expr<Date, D, C>;
|
|
536
|
+
declare const datePart: <D, C>(date: Expr<Date, D, C>) => Expr<string, D, C>;
|
|
537
|
+
declare const startOf: <D, C>(startDate: Expr<Date, D, C>, freq: Expr<"week" | "day" | "month" | "year", D, C>, offset: Expr<number, D, C>) => Expr<Date, D, C>;
|
|
538
|
+
declare const dateDiff: <D, C>({ end, unit, start, }: {
|
|
539
|
+
start: Expr<Date, D, C>;
|
|
540
|
+
end: Expr<Date, D, C>;
|
|
541
|
+
unit: Expr<"week" | "day" | "month" | "year", D, C>;
|
|
542
|
+
}) => Expr<number, D, C>;
|
|
543
|
+
|
|
544
|
+
declare const ite: {
|
|
545
|
+
<T, D, C = unknown>(cond: Expr<unknown, D, C>, then: Expr<T, D, C>, orelse: Expr<T, D, C>): Expr<T, D, C>;
|
|
546
|
+
<T, R1, R2, F extends HKT<R1 | R2>, C = unknown>(cond: BoolExpr<App<F, R1>, App<F, R2>, C>, then: Expr<T, App<F, R1>, C>, orelse: Expr<T, App<F, R2>, C>): Expr<T, App<F, R1 | R2>, C>;
|
|
547
|
+
};
|
|
548
|
+
declare const and: <D, C = unknown>(expr_0: Expr<boolean, D, C>, expr_1: Expr<boolean, D, C>) => Expr<boolean, D, C>;
|
|
549
|
+
declare const eq: <T, D, C = unknown>(a: Expr<T, D, C>) => (b: Expr<T, D, C>) => Expr<boolean, D, C>;
|
|
550
|
+
declare const sub: <T, D, Ctx, P extends O>(a: Expr<T, D, Ctx>, f: Field<P, D, Ctx>) => Expr<T, P, Ctx>;
|
|
551
|
+
declare const eqTyped: <T1 extends Dom, T2 extends Dom, F extends HKT<Dom>, C = unknown, Dom = unknown>(a: Expr<T1 | T2, App<F, T1 | T2>, C>, b: Expr<T1, App<F, T1 | T2>, C>) => BoolExpr<App<F, T1>, App<F, T2>, C>;
|
|
552
|
+
declare const ne: <T, K, D, C>(a: Expr<T, D, C>) => (b: Expr<K, D, C>) => Expr<boolean, D, C>;
|
|
553
|
+
declare const notNull: <T, K, D, C>(a: Expr<T, D, C>) => Expr<boolean, D, C>;
|
|
554
|
+
declare const $ifNull: <R, D, C>(...expr: [...Expr<R | null | undefined, D, C>[], Expr<R, D, C>]) => Expr<R, D, C>;
|
|
555
|
+
declare const exprMapVal: <K extends string, T extends Partial<Record<K, rawItem>>, D, C>(expr: Expr<K, D, C>, map: { readonly [P in K]: Expr<T[P], D, C>; }, or?: Expr<T[K], D, C>) => Expr<T[K & keyof T], D, C>;
|
|
556
|
+
declare const mapVal: <K extends string, T extends Partial<Record<K, rawItem>>, D, C>(expr: Expr<K, D, C>, map: T, or: T[K & keyof T]) => Expr<T[K & keyof T], D, C>;
|
|
557
|
+
declare const setField: <K extends string, T, V, D, C>({ field, input, value, }: {
|
|
558
|
+
field: Expr<K, D, C>;
|
|
559
|
+
input: Expr<T, D, C>;
|
|
560
|
+
value: Expr<V, D, C>;
|
|
561
|
+
}) => Expr<T & Record<K, V>, D, C>;
|
|
562
|
+
|
|
563
|
+
declare const range: <D, C>(start: Expr<number, D, C>, end: Expr<number, D, C>, step?: Expr<number, D, C>) => Expr<Arr<number>, D, C>;
|
|
564
|
+
declare const $map1: <T, R, D, C>(ex: Expr<Arr<T>, D, C>, map: (i: Field<unknown, T, RORec<"item", T>>) => Expr<R, D, RORec<"item", T> & C>) => Expr<Arr<R>, D, C>;
|
|
565
|
+
declare const $map: <T, R, D, C = unknown>(ex: Expr<Arr<T>, D, C>, map: (i: Expr<T, D, RORec<"item", T>>) => Expr<R, D, RORec<"item", T> & C>) => Expr<Arr<R>, D, C>;
|
|
566
|
+
|
|
567
|
+
declare class Machine<Result = unknown> {
|
|
568
|
+
private sources;
|
|
569
|
+
constructor(root?: Iterator<Result, HasJob>);
|
|
570
|
+
add(x: Iterator<Result, HasJob>): void;
|
|
571
|
+
runner(): Iterator<Result, HasJob>;
|
|
572
|
+
start(cb?: (info: HasJob) => void | boolean): Promise<never>;
|
|
573
|
+
}
|
|
574
|
+
declare const wrap: <Result>(root: Machine<Result>) => Machine<Result>;
|
|
575
|
+
|
|
576
|
+
declare const $eq: <T extends unknown>(operand: rawItem & T) => Predicate<T>;
|
|
577
|
+
declare const $ne: <T extends unknown>(operand: rawItem & T) => Predicate<T>;
|
|
578
|
+
type Numeric = number | Timestamp | Date;
|
|
579
|
+
declare const comp: <D2 extends Numeric = number>(op: "$lte" | "$gte" | "$lt" | "$gt") => <T extends D2>(operand: rawItem & D2) => Predicate<D2>;
|
|
580
|
+
declare const $gt: <T extends number>(operand: rawItem & number) => Predicate<number>;
|
|
581
|
+
declare const $gtTs: <T extends Timestamp>(operand: rawItem & Timestamp) => Predicate<Timestamp>;
|
|
582
|
+
declare const $gteTs: <T extends Timestamp>(operand: rawItem & Timestamp) => Predicate<Timestamp>;
|
|
583
|
+
declare const $lt: <T extends number>(operand: rawItem & number) => Predicate<number>;
|
|
584
|
+
declare const dateLt: <T extends Date>(operand: rawItem & Date) => Predicate<Date>;
|
|
585
|
+
declare const $gte: <T extends number>(operand: rawItem & number) => Predicate<number>;
|
|
586
|
+
declare const $lte: <T extends number>(operand: rawItem & number) => Predicate<number>;
|
|
587
|
+
|
|
588
|
+
declare const $expr: <D extends O, C>(expr: Expr<boolean, D, C>) => Query<D, C>;
|
|
589
|
+
|
|
590
|
+
declare const $in: <T extends unknown>(operand: rawItem & readonly T[]) => Predicate<T>;
|
|
591
|
+
declare const $nin: <T extends unknown>(operand: rawItem & readonly T[]) => Predicate<T>;
|
|
592
|
+
|
|
593
|
+
type Many<T> = readonly (T | N)[];
|
|
594
|
+
type Combiner = {
|
|
595
|
+
<T extends O, C = unknown>(first: Query<T, C>, ...args: Many<Query<T, C>>): Query<T, C>;
|
|
596
|
+
<T extends O, C = unknown>(...args: Many<Query<T, C>>): Query<T, C> | undefined;
|
|
597
|
+
};
|
|
598
|
+
declare const $and: Combiner;
|
|
599
|
+
declare const $nor: Combiner;
|
|
600
|
+
declare const $or: Combiner;
|
|
601
|
+
|
|
602
|
+
declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Promise<bson.Document>;
|
|
603
|
+
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
604
|
+
|
|
605
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $sum, $unwind, $unwindDelta, $upsert, type Accumulators, type Arr, type AsLiteral, type Delta, type DeltaAccumulator, type DeltaAccumulators, Expr, Field, type ID, type Loose, Machine, type Merge, type MergeArgs, type MergeInto, type Model, type N, type NoRaw, type O, type OPick, type RONoRaw, type RORec, type RawStages, type Rec, type Replace, type SnapshotStreamExecutionResult, type StrKey, type Strict, type TS, Type, type WriteonlyCollection, add, and, array, ceil, comp, concat, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, type doc, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, filter, filterDefined, first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, lt, lte, mapVal, max, maxDate, mergeObjects, minDate, monthPart, multiply, ne, nil, type notArr, notNull, now, prepare, rand, range, root, setField, size, slice, sortArray, staging, startOf, sub, subtract, val, wrap };
|