@omegup/msync 0.1.61 → 0.1.63
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/adapters/mongodb.d.ts +22 -0
- package/adapters/mongodb.esm.js +12 -0
- package/adapters/mongodb.esm.js.map +1 -0
- package/adapters/mongodb.js +14 -0
- package/adapters/mongodb.js.map +1 -0
- package/driver-BUCc3b89.js +31 -0
- package/driver-BUCc3b89.js.map +1 -0
- package/driver-sc6MCG57.esm.js +14 -0
- package/driver-sc6MCG57.esm.js.map +1 -0
- package/index.d.ts +13 -847
- package/index.esm.js +1918 -2239
- package/index.esm.js.map +1 -0
- package/index.js +1944 -2254
- package/index.js.map +1 -0
- package/lib/accumulators/index.d.ts +1 -1
- package/lib/aggregate/$merge.d.ts +9 -9
- package/lib/aggregate/$upsert.d.ts +6 -6
- package/lib/aggregate/group/$group-merge.d.ts +9 -10
- package/lib/aggregate/group/utils/sub-group.d.ts +1 -1
- package/lib/aggregate/group/utils/sub-merge.d.ts +28 -5
- package/lib/aggregate/lookup/$lookup-delta.d.ts +2 -2
- package/lib/aggregate/lookup/$lookup-raw.d.ts +3 -3
- package/lib/aggregate/mongo-stages.d.ts +3 -2
- package/lib/aggregate/prefix.d.ts +6 -6
- package/lib/aggregate/raws.d.ts +1 -1
- package/lib/aggregate/set/$replace-with-each.d.ts +5 -5
- package/lib/aggregate/set/$set.d.ts +1 -1
- package/lib/aggregate/unwind/$unwind-delta.d.ts +1 -1
- package/lib/aggregate/unwind/index.d.ts +2 -2
- package/lib/boot/boot-simpl.d.ts +1 -1
- package/lib/boot/boot-utils.d.ts +2 -3
- package/lib/boot/boot.d.ts +2 -2
- package/lib/boot/first-stages.d.ts +1 -2
- package/lib/driver.d.ts +5 -0
- package/lib/expression/concat.d.ts +4 -4
- package/lib/expression/date.d.ts +3 -3
- package/lib/expression/expr-base.d.ts +2 -2
- package/lib/expression/logic.d.ts +1 -1
- package/lib/expression/range.d.ts +2 -2
- package/lib/expression/val.d.ts +3 -3
- package/lib/field/field.d.ts +1 -1
- package/lib/predicate/$eq.d.ts +3 -4
- package/lib/types/accumulator.d.ts +4 -4
- package/lib/types/aggregate.d.ts +4 -2
- package/lib/types/query.d.ts +1 -5
- package/lib/types/stream.d.ts +3 -4
- package/lib/update/updater.d.ts +1 -1
- package/lib/utils/coll.d.ts +2 -2
- package/lib/utils/db-indexes.d.ts +2 -2
- package/lib/utils/guard.d.ts +2 -12
- package/lib/utils/json.d.ts +1 -0
- package/lib/utils/map-object.d.ts +1 -5
- package/lib/utils/merge/merge.d.ts +5 -4
- package/lib/utils/merge/next-winner.d.ts +2 -1
- package/lib/utils/merge/types.d.ts +9 -5
- package/lib/utils/merge/utils.d.ts +4 -2
- package/lib/watch.d.ts +2 -3
- package/package.json +21 -2
- package/types/global-aug.d.ts +1 -1
- package/types/global.d.ts +2 -0
- package/types/json.d.ts +13 -4
- package/types/mongo.d.ts +83 -23
- package/types/view.d.ts +1 -2
- package/test/mongodb.d.ts +0 -9
- package/test/uri.d.ts +0 -1
package/lib/utils/coll.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ReadonlyCollection, WriteonlyCollection } from '../../types';
|
|
1
|
+
import type { RawObj, ReadonlyCollection, WriteonlyCollection } from '../../types';
|
|
2
2
|
export declare const dbcoll: (x: ReadonlyCollection<unknown> | WriteonlyCollection<never>) => {
|
|
3
3
|
db: string;
|
|
4
4
|
coll: string;
|
|
5
|
-
};
|
|
5
|
+
} & RawObj;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Collection, CreateIndexesOptions, Db, IndexSpecification } from '
|
|
1
|
+
import type { Collection, CreateIndexesOptions, Db, IndexSpecification } from '../../types';
|
|
2
2
|
export declare const indexMap: Map<string, Map<string, Promise<void>>>;
|
|
3
3
|
export declare const createIndex: (collection: {
|
|
4
|
-
readonly createIndex: Collection[
|
|
4
|
+
readonly createIndex: Collection['createIndex'];
|
|
5
5
|
collectionName: string;
|
|
6
6
|
}, indexSpec: IndexSpecification, op?: CreateIndexesOptions) => Promise<void>;
|
|
7
7
|
export declare const ensureCollection: (db: Db, collectionName: string) => Promise<void>;
|
package/lib/utils/guard.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { App, AsLiteral, HKT,
|
|
1
|
+
import type { App, AsLiteral, HKT, N } from '../../types';
|
|
2
2
|
export type Equal<Dom, T extends Dom, V extends Dom> = {
|
|
3
3
|
forward: <F extends HKT<Dom>>(x: App<F, T>) => App<F, V>;
|
|
4
4
|
forward1: (x: T) => V;
|
|
@@ -7,15 +7,5 @@ export type Equal<Dom, T extends Dom, V extends Dom> = {
|
|
|
7
7
|
};
|
|
8
8
|
export declare const sym: <Dom, T extends Dom, V extends Dom>(eq: Equal<Dom, T, V>) => Equal<Dom, V, T>;
|
|
9
9
|
export declare const reflex: <Dom, T extends Dom>() => Equal<Dom, T, T>;
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const fromEq: <Dom, T extends Dom, V extends Dom>(eq: Pick<Equal<Dom, T, V>, "forward" | "backward">) => Equal<Dom, T, V>;
|
|
10
|
+
export declare const fromEq: <Dom, T extends Dom, V extends Dom>(eq: Pick<Equal<Dom, T, V>, 'forward' | 'backward'>) => Equal<Dom, T, V>;
|
|
12
11
|
export declare const literalsEqaul: <T extends keyof any | boolean | N, V extends T>(_: AsLiteral<T> & V) => Equal<T, T, V>;
|
|
13
|
-
export declare const omitRORec: <K extends string, E extends string, R extends string, T extends unknown>() => Equal<unknown, RORec<Exclude<K, E | R>, T>, Omit<RORec<Exclude<K, E | R>, T>, R>>;
|
|
14
|
-
type s = keyof any;
|
|
15
|
-
export declare const omitPick: <K extends s, E extends s, R extends s, T extends RORec<Exclude<K, E | R>, unknown>>() => Equal<unknown, Pick<T, Exclude<K, E | R>>, Omit<Pick<T, Exclude<K, E | R>>, R>>;
|
|
16
|
-
export declare const omitExclude: <K extends s, E extends s, R extends s, T extends RORec<Exclude<K, E | R>, unknown>>() => Equal<unknown, Omit<T, E & Exclude<K, keyof T>>, Omit<Pick<T, Exclude<K, E | R>>, R>>;
|
|
17
|
-
export declare const renamedFields: <K extends s, F extends HKT<K, s>, G extends HKT<App<F, K>>>() => Equal<string | number | symbol, keyof { [P in K as App<F, P>]: App<G, P>; }, App<F, K>>;
|
|
18
|
-
export declare const translateOmit: <T, K extends string, Q extends string, P extends string>() => Equal<unknown, Omit<Omit<T, K | Q>, P>, Omit<Omit<T, K | Q>, Q | P>>;
|
|
19
|
-
export declare const excludeIdem: <K extends s, E extends s, S extends E = E>() => Equal<Exclude<K, E>, Exclude<K, E>, Exclude<Exclude<K, E>, S>>;
|
|
20
|
-
export declare const eqPar: <K extends string, T extends Rec<K, jsonItem>, K2 extends K>() => Equal<unknown, Par<K2, T>, Par<K, T>>;
|
|
21
|
-
export {};
|
package/lib/utils/json.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AsLiteral, Rec } from '../../types';
|
|
2
|
+
export declare const safeNarrow: <V>() => <T>(x: T & V) => T & V;
|
|
2
3
|
export declare const id: <T>(x: T) => T;
|
|
3
4
|
export declare const defined: <T>(x: T | undefined | null) => x is T;
|
|
4
5
|
export declare const noop: () => void;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import type { App, HKT, I, IdHKT, RORec, StrKey } from '../../types';
|
|
2
|
-
export declare const map: <T, K extends string & keyof T, V extends RORec<K, unknown>>(x: Pick<T, K>, f: <P extends K>(v: T[P], k: P) => V[P]) => V;
|
|
1
|
+
import type { App, HKT, I, IdHKT, Omit, RORec, StrKey } from '../../types';
|
|
3
2
|
export type ExactPart<T, F extends HKT<T[StrKey<T>]>> = MapOPart<T, MappedHKT<T, F>>;
|
|
4
3
|
export type ExactPart1<T, F extends HKT<StrKey<T>>> = {
|
|
5
4
|
readonly [K in StrKey<T>]: App<F, K>;
|
|
6
5
|
};
|
|
7
6
|
type s = string;
|
|
8
|
-
export type MapKDom<RK extends MapKDom<RK, F>, F extends HKT<StrKey<RK>>> = MapO<RK, F> & {
|
|
9
|
-
readonly [P in s]?: readonly [keyof RK, unknown];
|
|
10
|
-
};
|
|
11
7
|
export type ExactKeys<K extends string> = Exact<RORec<K, 1>, IdHKT>;
|
|
12
8
|
export type MapO<T, F extends HKT<K>, K extends StrKey<T> = StrKey<T>> = MapOPart<T, F, K> & {
|
|
13
9
|
readonly [P: string]: readonly [K, unknown];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { PRRec } from '../../../types';
|
|
1
2
|
import type { Frame, IteratorResult, HasJob } from '../../types';
|
|
2
3
|
import type { KEYS, Race, SourceIteratorResults, SourceResults } from './types';
|
|
3
|
-
export declare const mergeIterators: <K extends KEYS, Result, Info extends
|
|
4
|
+
export declare const mergeIterators: <K extends KEYS, Result, Info extends PRRec<K, HasJob>>(params: {
|
|
4
5
|
sources: SourceIteratorResults<K, Result, Info>;
|
|
5
|
-
interrupt?: (key: KEYS) => boolean;
|
|
6
|
-
select?: Race<K, Result, Info
|
|
6
|
+
interrupt?: ((key: KEYS) => boolean) | undefined;
|
|
7
|
+
select?: Race<K, Result, Info> | undefined;
|
|
7
8
|
hooks?: {
|
|
8
9
|
start?: (frame: Frame<Result, Info[K]>, result: IteratorResult<Result, Info[K]>) => void;
|
|
9
|
-
};
|
|
10
|
+
} | undefined;
|
|
10
11
|
}) => IteratorResult<Result, SourceResults<K, Info>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PRRec } from '../../../types';
|
|
1
2
|
import type { NextFrame, HasJob } from '../../types';
|
|
2
3
|
import type { KEYS, RaceWinner, SourceIteratorResults } from './types';
|
|
3
|
-
export declare const nextWinner: <K extends KEYS, Result, Info extends
|
|
4
|
+
export declare const nextWinner: <K extends KEYS, Result, Info extends PRRec<K, HasJob>>(previousWinner: RaceWinner<K, Result, Info>, previousWinnerNextFrame: NextFrame<Result, Info[K]>, sources: SourceIteratorResults<K, Result, Info>, interrupt?: (key: KEYS) => boolean) => PromiseLike<RaceWinner<K, Result, Info>>;
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
+
import type { PRRec } from '../../../types';
|
|
1
2
|
import type { Frame, IteratorResult, HasJob } from '../../types';
|
|
2
3
|
export type KEYS = string;
|
|
3
|
-
export type SourceIteratorResults<K extends KEYS, Result, Info extends
|
|
4
|
+
export type SourceIteratorResults<K extends KEYS, Result, Info extends PRRec<K, unknown>> = {
|
|
5
|
+
readonly [P in K]?: IteratorResult<Result, Info[P]>;
|
|
6
|
+
};
|
|
7
|
+
export type RSourceIteratorResults<K extends KEYS, Result, Info extends PRRec<K, unknown>> = {
|
|
4
8
|
readonly [P in K]: IteratorResult<Result, Info[P]>;
|
|
5
9
|
};
|
|
6
|
-
export type SourceResults<K extends KEYS, Info extends
|
|
10
|
+
export type SourceResults<K extends KEYS, Info extends PRRec<K, HasJob>> = {
|
|
7
11
|
readonly [P in K]: {
|
|
8
12
|
readonly key: P;
|
|
9
13
|
readonly value: Info[P];
|
|
10
|
-
readonly job: Info[P]['job'];
|
|
14
|
+
readonly job: (Info[P] & {})['job'];
|
|
11
15
|
};
|
|
12
16
|
}[K];
|
|
13
|
-
export type RaceWinner<K extends KEYS, Result, Info extends
|
|
17
|
+
export type RaceWinner<K extends KEYS, Result, Info extends PRRec<K, unknown>> = {
|
|
14
18
|
readonly [P in K]: {
|
|
15
19
|
readonly key: P;
|
|
16
20
|
readonly frame: Frame<Result, Info[P]>;
|
|
17
21
|
};
|
|
18
22
|
}[K];
|
|
19
|
-
export type Race<K extends KEYS, Result, Info extends
|
|
23
|
+
export type Race<K extends KEYS, Result, Info extends PRRec<K, HasJob>> = (arg: SourceIteratorResults<K, Result, Info>) => PromiseLike<RaceWinner<K, Result, Info>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { PRRec } from '../../../types';
|
|
1
2
|
import type { KEYS, RaceWinner, SourceIteratorResults } from './types';
|
|
3
|
+
export declare const map: <T, K extends string & keyof T & keyof V, V>(x: Pick<T, K>, f: <P extends K>(v: Required<T>[P], k: P) => V[P]) => V;
|
|
2
4
|
export declare const patch: <T, K extends keyof T>({ ...x }: T, k: K, v: T[K]) => T;
|
|
3
|
-
export declare const restart: <K extends KEYS, Result, Info extends
|
|
4
|
-
export declare const race: <W, K extends KEYS, Result, Info extends
|
|
5
|
+
export declare const restart: <K extends KEYS, Result, Info extends PRRec<K, unknown>>(sources: SourceIteratorResults<K, Result, Info>) => SourceIteratorResults<K, Result, Info>;
|
|
6
|
+
export declare const race: <W, K extends KEYS, Result, Info extends PRRec<K, W>>(sources: SourceIteratorResults<K, Result, Info>) => Promise<RaceWinner<K, Result, Info>>;
|
package/lib/watch.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { O, StrKey, View } from '../types';
|
|
1
|
+
import type { Db, Dict, Document, O, StrKey, Timestamp, View } from '../types';
|
|
3
2
|
import type { Field } from './field';
|
|
4
3
|
import type { Model, Query } from './types';
|
|
5
4
|
export type OplogEntry = {
|
|
6
5
|
ts: Timestamp;
|
|
7
6
|
ns: string;
|
|
8
7
|
op: 'i' | 'u' | 'd' | 'c' | 'n';
|
|
9
|
-
o:
|
|
8
|
+
o: Dict<unknown>;
|
|
10
9
|
o2?: {
|
|
11
10
|
_id: string;
|
|
12
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegup/msync",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.63",
|
|
4
4
|
"description": "Keeps derived MongoDB data in sync with the documents it comes from.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,10 +14,29 @@
|
|
|
14
14
|
"main": "index.js",
|
|
15
15
|
"module": "index.esm.js",
|
|
16
16
|
"typings": "index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"import": "./index.esm.js",
|
|
21
|
+
"require": "./index.js"
|
|
22
|
+
},
|
|
23
|
+
"./adapters/mongodb": {
|
|
24
|
+
"types": "./adapters/mongodb.d.ts",
|
|
25
|
+
"import": "./adapters/mongodb.esm.js",
|
|
26
|
+
"require": "./adapters/mongodb.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
17
29
|
"dependencies": {
|
|
18
30
|
"dayjs": "^1.11.9",
|
|
19
31
|
"dotenv": "^16.3.1",
|
|
20
|
-
"json-canonicalize": "^2.0.0"
|
|
32
|
+
"json-canonicalize": "^2.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
21
35
|
"mongodb": "^6.8.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"mongodb": {
|
|
39
|
+
"optional": true
|
|
40
|
+
}
|
|
22
41
|
}
|
|
23
42
|
}
|
package/types/global-aug.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { AsNum, GetDom } from './global';
|
|
|
4
4
|
export {};
|
|
5
5
|
declare global {
|
|
6
6
|
type Entry<T, K extends keyof T = keyof T> = readonly [string, T[string & K]] & {
|
|
7
|
-
[k in K]
|
|
7
|
+
[k in K]?: readonly [string & k, T[k]];
|
|
8
8
|
}[K];
|
|
9
9
|
interface ObjectConstructor {
|
|
10
10
|
entries<T, _ = 0>(object?: T): readonly Entry<T>[];
|
package/types/global.d.ts
CHANGED
package/types/json.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Timestamp } from 'mongodb';
|
|
2
1
|
import type { Type } from './class';
|
|
2
|
+
import type { Timestamp } from './mongo';
|
|
3
|
+
import type { Omit } from './global';
|
|
3
4
|
export type { Type } from './class';
|
|
4
5
|
export type U = undefined;
|
|
5
6
|
export type N = null | U;
|
|
@@ -18,8 +19,8 @@ export interface JsonArr {
|
|
|
18
19
|
export type A = {
|
|
19
20
|
[Type]: typeof array;
|
|
20
21
|
};
|
|
21
|
-
export type Arr<T
|
|
22
|
-
readonly [_
|
|
22
|
+
export type Arr<T> = A & {
|
|
23
|
+
readonly [_: number]: T;
|
|
23
24
|
};
|
|
24
25
|
type Obj = {
|
|
25
26
|
[Type]: typeof object;
|
|
@@ -31,6 +32,9 @@ export type RORec<K extends keyof never, T = unknown> = {
|
|
|
31
32
|
export type PRRec<K extends keyof never, T = unknown> = {
|
|
32
33
|
[P in K]?: T;
|
|
33
34
|
};
|
|
35
|
+
export type Dict<T> = {
|
|
36
|
+
[P: string]: T;
|
|
37
|
+
};
|
|
34
38
|
export type Par<K extends string, V extends Rec<K, jsonItem>> = {
|
|
35
39
|
readonly [k in K]?: V[k] | N;
|
|
36
40
|
};
|
|
@@ -48,7 +52,12 @@ export type raw = readonly rawItem[] | RawObj;
|
|
|
48
52
|
export type StrKey<T> = string & keyof T;
|
|
49
53
|
export type Replace<R, V> = Omit<R, StrKey<V>> & V & O;
|
|
50
54
|
export type ReplaceQ<R extends Q, VV, Q extends O> = Omit<R, StrKey<VV>> & Omit<VV, StrKey<Q>> & Q;
|
|
51
|
-
|
|
55
|
+
type AnyKeyed = {
|
|
56
|
+
[x: string]: never;
|
|
57
|
+
[x: number]: never;
|
|
58
|
+
[x: symbol]: never;
|
|
59
|
+
};
|
|
60
|
+
export type AsLiteral<T extends keyof any | boolean | N, V = NoUnion<T>> = T extends keyof any ? [Record<string, 1>] extends [never] ? [Record<T, 1>] extends [never] ? never : V : AnyKeyed extends {
|
|
52
61
|
[K in T]: 1;
|
|
53
62
|
} ? never : V : V;
|
|
54
63
|
type NoUnion<T, V = T> = T extends T ? ([V] extends [T] ? T : never) : never;
|
package/types/mongo.d.ts
CHANGED
|
@@ -1,24 +1,84 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import { BSON } from 'mongodb';
|
|
1
|
+
import type { PRRec } from './json';
|
|
3
2
|
export declare const RawStage: unique symbol;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
export type Document = object;
|
|
4
|
+
export type Filter<T> = PRRec<keyof T & string, unknown> & Document;
|
|
5
|
+
export type UpdateFilter<T> = {
|
|
6
|
+
$set?: PRRec<keyof T & string, unknown>;
|
|
7
|
+
} & Document;
|
|
8
|
+
export interface Timestamp {
|
|
9
|
+
readonly _bsontype: 'Timestamp';
|
|
10
|
+
readonly high: number;
|
|
11
|
+
readonly low: number;
|
|
12
|
+
comp(other: unknown): number;
|
|
13
|
+
}
|
|
14
|
+
export interface UUID {
|
|
15
|
+
toString(encoding: 'base64'): string;
|
|
16
|
+
}
|
|
17
|
+
export interface Driver {
|
|
18
|
+
Timestamp: {
|
|
19
|
+
new (value: bigint): Timestamp;
|
|
20
|
+
new (value: {
|
|
21
|
+
t: number;
|
|
22
|
+
i: number;
|
|
23
|
+
}): Timestamp;
|
|
24
|
+
};
|
|
25
|
+
UUID: new () => UUID;
|
|
26
|
+
}
|
|
27
|
+
export interface Cursor<T> extends AsyncIterable<T> {
|
|
28
|
+
next(): Promise<T | null>;
|
|
29
|
+
toArray(): Promise<T[]>;
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export type IndexSpecification = Document;
|
|
33
|
+
export type CreateIndexesOptions = Document & {
|
|
34
|
+
name?: string;
|
|
35
|
+
partialFilterExpression?: Document;
|
|
36
|
+
};
|
|
37
|
+
export type UpdateOptions = {
|
|
38
|
+
upsert?: boolean;
|
|
39
|
+
};
|
|
40
|
+
export interface Commander {
|
|
41
|
+
command<T extends object = PRRec<string, unknown>>(command: Document): Promise<T>;
|
|
42
|
+
}
|
|
43
|
+
export interface Client {
|
|
44
|
+
db(name: string): Db;
|
|
45
|
+
}
|
|
46
|
+
export interface Db extends Commander {
|
|
47
|
+
readonly s: {
|
|
48
|
+
readonly client?: Client;
|
|
49
|
+
};
|
|
50
|
+
readonly client: Client;
|
|
51
|
+
readonly namespace: string;
|
|
52
|
+
admin(): Commander;
|
|
53
|
+
collection<T = Document>(name: string): Collection<T>;
|
|
54
|
+
createCollection(name: string): Promise<unknown>;
|
|
55
|
+
listCollections(filter: Document, options: {
|
|
56
|
+
nameOnly: true;
|
|
57
|
+
}): Cursor<{
|
|
58
|
+
name: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
export interface Collection<TSchema = Document> {
|
|
62
|
+
readonly s: {
|
|
63
|
+
readonly db: Db;
|
|
64
|
+
};
|
|
65
|
+
readonly collectionName: string;
|
|
66
|
+
readonly namespace: string;
|
|
67
|
+
readonly dbName: string;
|
|
68
|
+
[RawStage]: {
|
|
69
|
+
(_: 2): TSchema;
|
|
70
|
+
(_: 1, x: TSchema): TSchema;
|
|
71
|
+
};
|
|
72
|
+
createIndex(spec: IndexSpecification, options?: CreateIndexesOptions): Promise<string>;
|
|
73
|
+
findOne(filter: Document): Promise<TSchema | null>;
|
|
74
|
+
find(filter: Document, options?: Document): Cursor<TSchema>;
|
|
75
|
+
updateOne(filter: Document, update: Document | readonly Document[], options?: UpdateOptions): Promise<unknown>;
|
|
76
|
+
updateMany(filter: Document, update: Document | readonly Document[]): Promise<unknown>;
|
|
77
|
+
deleteOne(filter: Document): Promise<unknown>;
|
|
78
|
+
deleteMany(filter: Document): Promise<unknown>;
|
|
79
|
+
drop(): Promise<unknown>;
|
|
80
|
+
}
|
|
81
|
+
export type WatchStream<T = {}> = {
|
|
82
|
+
close(): Promise<void>;
|
|
83
|
+
tryNext(): Promise<T | null>;
|
|
84
|
+
};
|
package/types/view.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Collection, Db } from 'mongodb';
|
|
2
1
|
import type { Del, Expr, Model, Query } from '../lib/types';
|
|
3
2
|
import type { ExactKeys } from '../lib/utils/map-object';
|
|
4
3
|
import type { O, StrKey } from './json';
|
|
5
|
-
import type { RawStage } from './mongo';
|
|
4
|
+
import type { Collection, Db, RawStage } from './mongo';
|
|
6
5
|
interface CommonCollection {
|
|
7
6
|
readonly s: {
|
|
8
7
|
readonly db: Db;
|
package/test/mongodb.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Collection, MongoClient } from 'mongodb';
|
|
2
|
-
import type { AsynIter, Iterator } from '../lib/types';
|
|
3
|
-
import type { ID, doc } from '../types';
|
|
4
|
-
import type { Db, OptionalUnlessRequiredId } from 'mongodb';
|
|
5
|
-
export declare const run: <T, Info>(cont: Iterator<T, Info>) => Promise<never>;
|
|
6
|
-
export declare const iterate: <T>([, next]: AsynIter<T>) => PromiseLike<never>;
|
|
7
|
-
export declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Promise<import("mongodb").Document>;
|
|
8
|
-
export declare const prepare: (testName?: string) => Promise<MongoClient>;
|
|
9
|
-
export declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
package/test/uri.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const uri: string;
|