@sprucelabs/data-stores 19.0.54 → 19.0.55
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/build/.spruce/errors/options.types.d.ts +1 -1
- package/build/cursors/CursorPager.d.ts +2 -2
- package/build/databases/mongo.types.d.ts +68 -68
- package/build/esm/.spruce/errors/options.types.d.ts +1 -1
- package/build/esm/cursors/CursorPager.d.ts +2 -2
- package/build/esm/databases/mongo.types.d.ts +68 -68
- package/build/esm/loaders/StoreLoader.d.ts +1 -1
- package/build/esm/stores/AbstractStore.d.ts +1 -1
- package/build/esm/types/database.types.d.ts +2 -2
- package/build/esm/types/query.types.d.ts +10 -10
- package/build/esm/types/stores.types.d.ts +6 -6
- package/build/loaders/StoreLoader.d.ts +1 -1
- package/build/stores/AbstractStore.d.ts +1 -1
- package/build/types/database.types.d.ts +2 -2
- package/build/types/query.types.d.ts +10 -10
- package/build/types/stores.types.d.ts +6 -6
- package/package.json +1 -1
|
@@ -54,5 +54,5 @@ export interface DuplicateKeyErrorOptions extends SpruceErrors.DataStores.Duplic
|
|
|
54
54
|
export interface DatabaseNotConnectedErrorOptions extends SpruceErrors.DataStores.DatabaseNotConnected, ISpruceErrorOptions {
|
|
55
55
|
code: 'DATABASE_NOT_CONNECTED';
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
|
|
58
58
|
export default ErrorOptions;
|
|
@@ -9,7 +9,7 @@ export interface RecordsWithCursors<Response extends Record<string, any>[] = Rec
|
|
|
9
9
|
next: string | null;
|
|
10
10
|
previous: string | null;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
type PrepareQueryOptions = CursorQueryOptions & {
|
|
13
13
|
limit: number;
|
|
14
14
|
};
|
|
15
15
|
export default class CursorPager {
|
|
@@ -25,5 +25,5 @@ export default class CursorPager {
|
|
|
25
25
|
export interface SimpleStore {
|
|
26
26
|
find: (...args: any[]) => Promise<any>;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
type UnPromisify<T> = T extends Promise<infer U> ? U : T;
|
|
29
29
|
export {};
|
|
@@ -6,22 +6,22 @@ import { Binary, Decimal128, Double, Int32, Long, ObjectId, Timestamp } from 'bs
|
|
|
6
6
|
import { BSONType, ResumeToken } from 'mongodb';
|
|
7
7
|
import { AggregationCursor, Code } from 'mongodb';
|
|
8
8
|
import { ClientSession, MongoClient, MongoError, ReadPreference } from 'mongodb';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
9
|
+
type Cursor<A = any> = A extends true ? any : any;
|
|
10
|
+
type CommandCursor = any;
|
|
11
|
+
type FlattenIfArray<T> = T extends ReadonlyArray<infer R> ? R : T;
|
|
12
|
+
export type WithoutProjection<T> = T & {
|
|
13
13
|
fields?: undefined;
|
|
14
14
|
projection?: undefined;
|
|
15
15
|
};
|
|
16
16
|
export { Binary, DBRef, Decimal128, Double, Int32, Long, MaxKey, MinKey, ObjectID, ObjectId, Timestamp, } from 'bson';
|
|
17
|
-
|
|
18
|
-
export
|
|
17
|
+
type NumericTypes = number | Decimal128 | Double | Int32 | Long;
|
|
18
|
+
export type ClientSessionId = unknown;
|
|
19
19
|
/**
|
|
20
20
|
* The MongoDB ReadConcern, which allows for control of the consistency and isolation properties
|
|
21
21
|
* of the data read from replica sets and replica set shards.
|
|
22
22
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/global.html#ReadConcern
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
type ReadConcernLevel = 'local' | 'available' | 'majority' | 'linearizable' | 'snapshot';
|
|
25
25
|
/**
|
|
26
26
|
* The MongoDB ReadConcern, which allows for control of the consistency and isolation properties
|
|
27
27
|
* of the data read from replica sets and replica set shards.
|
|
@@ -113,7 +113,7 @@ export interface MongoCallback<T> {
|
|
|
113
113
|
* @returns Resulting Promise of operations run within this transaction
|
|
114
114
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/global.html#WithTransactionCallback
|
|
115
115
|
*/
|
|
116
|
-
export
|
|
116
|
+
export type WithTransactionCallback = (session: ClientSession) => Promise<void>;
|
|
117
117
|
/**
|
|
118
118
|
* Optional settings for MongoClient.connect()
|
|
119
119
|
*
|
|
@@ -411,10 +411,10 @@ export interface HighAvailabilityOptions {
|
|
|
411
411
|
*/
|
|
412
412
|
readPreferenceTags?: ReadPreferenceTags | undefined;
|
|
413
413
|
}
|
|
414
|
-
export
|
|
415
|
-
export
|
|
416
|
-
export
|
|
417
|
-
export
|
|
414
|
+
export type ReadPreferenceTags = ReadonlyArray<Record<string, string>>;
|
|
415
|
+
export type ReadPreferenceMode = 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest';
|
|
416
|
+
export type ReadPreferenceOrMode = ReadPreference | ReadPreferenceMode;
|
|
417
|
+
export type ReadPreferenceOptions = {
|
|
418
418
|
/** Server mode in which the same query is dispatched in parallel to multiple replica set members. */
|
|
419
419
|
hedge?: {
|
|
420
420
|
/** Explicitly enable or disable hedged reads. */
|
|
@@ -687,7 +687,7 @@ export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions {
|
|
|
687
687
|
*/
|
|
688
688
|
socketOptions?: SocketOptions | undefined;
|
|
689
689
|
}
|
|
690
|
-
export
|
|
690
|
+
export type ProfilingLevel = 'off' | 'slow_only' | 'all';
|
|
691
691
|
export interface CommonOptions extends WriteConcern {
|
|
692
692
|
session?: ClientSession | undefined;
|
|
693
693
|
writeConcern?: WriteConcern | string | undefined;
|
|
@@ -966,17 +966,17 @@ export interface AddUserOptions extends CommonOptions {
|
|
|
966
966
|
export interface FSyncOptions extends CommonOptions {
|
|
967
967
|
fsync?: boolean | undefined;
|
|
968
968
|
}
|
|
969
|
-
|
|
970
|
-
|
|
969
|
+
type EnhancedOmit<T, K> = string | number extends keyof T ? T : T extends any ? Pick<T, Exclude<keyof T, K>> : never;
|
|
970
|
+
type ExtractIdType<TSchema> = TSchema extends {
|
|
971
971
|
_id: infer U;
|
|
972
972
|
} ? {} extends U ? Exclude<U, {}> : unknown extends U ? ObjectId : U : ObjectId;
|
|
973
|
-
export
|
|
973
|
+
export type OptionalId<TSchema extends {
|
|
974
974
|
_id?: any;
|
|
975
975
|
}> = ObjectId extends TSchema['_id'] ? // a Schema with ObjectId _id type or "any" or "indexed type" provided
|
|
976
976
|
EnhancedOmit<TSchema, '_id'> & {
|
|
977
977
|
_id?: ExtractIdType<TSchema> | undefined;
|
|
978
978
|
} : WithId<TSchema>;
|
|
979
|
-
export
|
|
979
|
+
export type WithId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
|
|
980
980
|
_id: ExtractIdType<TSchema>;
|
|
981
981
|
};
|
|
982
982
|
/**
|
|
@@ -1610,76 +1610,76 @@ export interface Collection<TSchema extends {
|
|
|
1610
1610
|
updateOne(filter: FilterQuery<TSchema>, update: UpdateQuery<TSchema> | Partial<TSchema>, options: UpdateOneOptions, callback: MongoCallback<UpdateWriteOpResult>): void;
|
|
1611
1611
|
}
|
|
1612
1612
|
/** Update Query */
|
|
1613
|
-
|
|
1613
|
+
type KeysOfAType<TSchema, Type> = {
|
|
1614
1614
|
[key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? key : never;
|
|
1615
1615
|
}[keyof TSchema];
|
|
1616
|
-
|
|
1616
|
+
type KeysOfOtherType<TSchema, Type> = {
|
|
1617
1617
|
[key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? never : key;
|
|
1618
1618
|
}[keyof TSchema];
|
|
1619
|
-
|
|
1619
|
+
type AcceptedFields<TSchema, FieldType, AssignableType> = {
|
|
1620
1620
|
readonly [key in KeysOfAType<TSchema, FieldType>]?: AssignableType;
|
|
1621
1621
|
};
|
|
1622
1622
|
/** It avoids using fields with not acceptable types */
|
|
1623
|
-
|
|
1623
|
+
type NotAcceptedFields<TSchema, FieldType> = {
|
|
1624
1624
|
readonly [key in KeysOfOtherType<TSchema, FieldType>]?: never;
|
|
1625
1625
|
};
|
|
1626
|
-
|
|
1626
|
+
type DotAndArrayNotation<AssignableType> = {
|
|
1627
1627
|
readonly [key: string]: AssignableType;
|
|
1628
1628
|
};
|
|
1629
|
-
|
|
1629
|
+
type ReadonlyPartial<TSchema> = {
|
|
1630
1630
|
readonly [key in keyof TSchema]?: TSchema[key];
|
|
1631
1631
|
};
|
|
1632
|
-
export
|
|
1633
|
-
export
|
|
1634
|
-
|
|
1635
|
-
|
|
1632
|
+
export type OnlyFieldsOfType<TSchema, FieldType = any, AssignableType = FieldType> = AcceptedFields<TSchema, FieldType, AssignableType> & NotAcceptedFields<TSchema, FieldType> & DotAndArrayNotation<AssignableType>;
|
|
1633
|
+
export type MatchKeysAndValues<TSchema> = ReadonlyPartial<TSchema> & DotAndArrayNotation<any>;
|
|
1634
|
+
type Unpacked<Type> = Type extends ReadonlyArray<infer Element> ? Element : Type;
|
|
1635
|
+
type UpdateOptionalId<T> = T extends {
|
|
1636
1636
|
_id?: any;
|
|
1637
1637
|
} ? OptionalId<T> : T;
|
|
1638
|
-
export
|
|
1638
|
+
export type SortValues = -1 | 1;
|
|
1639
1639
|
/**
|
|
1640
1640
|
* Values for the $meta aggregation pipeline operator
|
|
1641
1641
|
*
|
|
1642
1642
|
* @see https://docs.mongodb.com/v3.6/reference/operator/aggregation/meta/#proj._S_meta
|
|
1643
1643
|
*/
|
|
1644
|
-
export
|
|
1645
|
-
export
|
|
1644
|
+
export type MetaSortOperators = 'textScore' | 'indexKey';
|
|
1645
|
+
export type MetaProjectionOperators = MetaSortOperators
|
|
1646
1646
|
/** Only for Atlas Search https://docs.atlas.mongodb.com/reference/atlas-search/scoring/ */
|
|
1647
1647
|
| 'searchScore'
|
|
1648
1648
|
/** Only for Atlas Search https://docs.atlas.mongodb.com/reference/atlas-search/highlighting/ */
|
|
1649
1649
|
| 'searchHighlights';
|
|
1650
|
-
export
|
|
1650
|
+
export type SchemaMember<T, V> = {
|
|
1651
1651
|
[P in keyof T]?: V;
|
|
1652
1652
|
} | {
|
|
1653
1653
|
[key: string]: V;
|
|
1654
1654
|
};
|
|
1655
|
-
export
|
|
1655
|
+
export type SortOptionObject<T> = SchemaMember<T, number | {
|
|
1656
1656
|
$meta?: MetaSortOperators | undefined;
|
|
1657
1657
|
}>;
|
|
1658
|
-
export
|
|
1658
|
+
export type AddToSetOperators<Type> = {
|
|
1659
1659
|
$each: Type;
|
|
1660
1660
|
};
|
|
1661
|
-
export
|
|
1661
|
+
export type ArrayOperator<Type> = {
|
|
1662
1662
|
$each: Type;
|
|
1663
1663
|
$slice?: number | undefined;
|
|
1664
1664
|
$position?: number | undefined;
|
|
1665
1665
|
$sort?: SortValues | Record<string, SortValues> | undefined;
|
|
1666
1666
|
};
|
|
1667
|
-
export
|
|
1667
|
+
export type SetFields<TSchema> = ({
|
|
1668
1668
|
readonly [key in KeysOfAType<TSchema, ReadonlyArray<any> | undefined>]?: UpdateOptionalId<Unpacked<TSchema[key]>> | AddToSetOperators<Array<UpdateOptionalId<Unpacked<TSchema[key]>>>>;
|
|
1669
1669
|
} & NotAcceptedFields<TSchema, ReadonlyArray<any> | undefined>) & {
|
|
1670
1670
|
readonly [key: string]: AddToSetOperators<any> | any;
|
|
1671
1671
|
};
|
|
1672
|
-
export
|
|
1672
|
+
export type PushOperator<TSchema> = ({
|
|
1673
1673
|
readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: Unpacked<TSchema[key]> | ArrayOperator<Array<Unpacked<TSchema[key]>>>;
|
|
1674
1674
|
} & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
|
1675
1675
|
readonly [key: string]: ArrayOperator<any> | any;
|
|
1676
1676
|
};
|
|
1677
|
-
export
|
|
1677
|
+
export type PullOperator<TSchema> = ({
|
|
1678
1678
|
readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: Partial<Unpacked<TSchema[key]>> | ObjectQuerySelector<Unpacked<TSchema[key]>>;
|
|
1679
1679
|
} & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
|
1680
1680
|
readonly [key: string]: QuerySelector<any> | any;
|
|
1681
1681
|
};
|
|
1682
|
-
export
|
|
1682
|
+
export type PullAllOperator<TSchema> = ({
|
|
1683
1683
|
readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: TSchema[key];
|
|
1684
1684
|
} & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
|
1685
1685
|
readonly [key: string]: any[];
|
|
@@ -1709,7 +1709,7 @@ export declare type PullAllOperator<TSchema> = ({
|
|
|
1709
1709
|
* @see https://docs.mongodb.com/v3.6/reference/operator/update-bitwise/
|
|
1710
1710
|
*
|
|
1711
1711
|
*/
|
|
1712
|
-
export
|
|
1712
|
+
export type UpdateQuery<TSchema> = {
|
|
1713
1713
|
$currentDate?: OnlyFieldsOfType<TSchema, Date | Timestamp, true | {
|
|
1714
1714
|
$type: 'date' | 'timestamp';
|
|
1715
1715
|
}> | undefined;
|
|
@@ -1765,11 +1765,11 @@ export declare enum BsonType {
|
|
|
1765
1765
|
MinKey = -1,
|
|
1766
1766
|
MaxKey = 127
|
|
1767
1767
|
}
|
|
1768
|
-
|
|
1768
|
+
type BSONTypeAlias = 'number' | 'double' | 'string' | 'object' | 'array' | 'binData' | 'undefined' | 'objectId' | 'bool' | 'date' | 'null' | 'regex' | 'dbPointer' | 'javascript' | 'symbol' | 'javascriptWithScope' | 'int' | 'timestamp' | 'long' | 'decimal' | 'minKey' | 'maxKey';
|
|
1769
1769
|
/** @see https://docs.mongodb.com/v3.6/reference/operator/query-bitwise */
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1770
|
+
type BitwiseQuery = number /** <numeric bitmask> */ | Binary /** <BinData bitmask> */ | number[]; /** [ <position1>, <position2>, ... ] */
|
|
1771
|
+
type RegExpForString<T> = T extends string ? RegExp | T : T;
|
|
1772
|
+
type MongoAltQuery<T> = T extends ReadonlyArray<infer U> ? T | RegExpForString<U> : RegExpForString<T>;
|
|
1773
1773
|
/**
|
|
1774
1774
|
* Available query selector types
|
|
1775
1775
|
*
|
|
@@ -1820,7 +1820,7 @@ declare type MongoAltQuery<T> = T extends ReadonlyArray<infer U> ? T | RegExpFor
|
|
|
1820
1820
|
*
|
|
1821
1821
|
* @see https://docs.mongodb.com/v3.6/reference/operator/query/#query-selectors
|
|
1822
1822
|
*/
|
|
1823
|
-
export
|
|
1823
|
+
export type QuerySelector<T> = {
|
|
1824
1824
|
$eq?: T | undefined;
|
|
1825
1825
|
$gt?: T | undefined;
|
|
1826
1826
|
$gte?: T | undefined;
|
|
@@ -1856,7 +1856,7 @@ export declare type QuerySelector<T> = {
|
|
|
1856
1856
|
$bitsAnyClear?: BitwiseQuery | undefined;
|
|
1857
1857
|
$bitsAnySet?: BitwiseQuery | undefined;
|
|
1858
1858
|
};
|
|
1859
|
-
export
|
|
1859
|
+
export type RootQuerySelector<T> = {
|
|
1860
1860
|
/** @see https://docs.mongodb.com/v3.6/reference/operator/query/and/#op._S_and */
|
|
1861
1861
|
$and?: Array<FilterQuery<T>> | undefined;
|
|
1862
1862
|
/** @see https://docs.mongodb.com/v3.6/reference/operator/query/nor/#op._S_nor */
|
|
@@ -1876,15 +1876,15 @@ export declare type RootQuerySelector<T> = {
|
|
|
1876
1876
|
$comment?: string | undefined;
|
|
1877
1877
|
[key: string]: any;
|
|
1878
1878
|
};
|
|
1879
|
-
export
|
|
1879
|
+
export type ObjectQuerySelector<T> = T extends object ? {
|
|
1880
1880
|
[key in keyof T]?: QuerySelector<T[key]>;
|
|
1881
1881
|
} : QuerySelector<T>;
|
|
1882
|
-
export
|
|
1883
|
-
export
|
|
1882
|
+
export type Condition<T> = MongoAltQuery<T> | QuerySelector<MongoAltQuery<T>>;
|
|
1883
|
+
export type FilterQuery<T> = {
|
|
1884
1884
|
[P in keyof T]?: Condition<T[P]>;
|
|
1885
1885
|
} & RootQuerySelector<T>;
|
|
1886
1886
|
/** @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#insertone */
|
|
1887
|
-
export
|
|
1887
|
+
export type BulkWriteInsertOneOperation<TSchema> = {
|
|
1888
1888
|
insertOne: {
|
|
1889
1889
|
/** @ts-ignore */
|
|
1890
1890
|
document: OptionalId<TSchema>;
|
|
@@ -1902,17 +1902,17 @@ export declare type BulkWriteInsertOneOperation<TSchema> = {
|
|
|
1902
1902
|
* For more details see {@link https://docs.mongodb.com/v3.6/reference/method/db.collection.update/#upsert-behavior upsert behavior}
|
|
1903
1903
|
* @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#updateone-and-updatemany
|
|
1904
1904
|
*/
|
|
1905
|
-
export
|
|
1905
|
+
export type BulkWriteUpdateOperation<TSchema> = {
|
|
1906
1906
|
arrayFilters?: object[] | undefined;
|
|
1907
1907
|
collation?: object | undefined;
|
|
1908
1908
|
filter: FilterQuery<TSchema>;
|
|
1909
1909
|
update: UpdateQuery<TSchema>;
|
|
1910
1910
|
upsert?: boolean | undefined;
|
|
1911
1911
|
};
|
|
1912
|
-
export
|
|
1912
|
+
export type BulkWriteUpdateOneOperation<TSchema> = {
|
|
1913
1913
|
updateOne: BulkWriteUpdateOperation<TSchema>;
|
|
1914
1914
|
};
|
|
1915
|
-
export
|
|
1915
|
+
export type BulkWriteUpdateManyOperation<TSchema> = {
|
|
1916
1916
|
updateMany: BulkWriteUpdateOperation<TSchema>;
|
|
1917
1917
|
};
|
|
1918
1918
|
/**
|
|
@@ -1927,7 +1927,7 @@ export declare type BulkWriteUpdateManyOperation<TSchema> = {
|
|
|
1927
1927
|
* For more details see {@link https://docs.mongodb.com/v3.6/reference/method/db.collection.update/#upsert-behavior upsert behavior}
|
|
1928
1928
|
* @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#replaceone
|
|
1929
1929
|
*/
|
|
1930
|
-
export
|
|
1930
|
+
export type BulkWriteReplaceOneOperation<TSchema> = {
|
|
1931
1931
|
replaceOne: {
|
|
1932
1932
|
collation?: object | undefined;
|
|
1933
1933
|
filter: FilterQuery<TSchema>;
|
|
@@ -1942,14 +1942,14 @@ export declare type BulkWriteReplaceOneOperation<TSchema> = {
|
|
|
1942
1942
|
* @param filter Specifies deletion criteria using {@link https://docs.mongodb.com/v3.6/reference/operator/ query operators}.
|
|
1943
1943
|
* @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#deleteone-and-deletemany
|
|
1944
1944
|
*/
|
|
1945
|
-
export
|
|
1945
|
+
export type BulkWriteDeleteOperation<TSchema> = {
|
|
1946
1946
|
collation?: object | undefined;
|
|
1947
1947
|
filter: FilterQuery<TSchema>;
|
|
1948
1948
|
};
|
|
1949
|
-
export
|
|
1949
|
+
export type BulkWriteDeleteOneOperation<TSchema> = {
|
|
1950
1950
|
deleteOne: BulkWriteDeleteOperation<TSchema>;
|
|
1951
1951
|
};
|
|
1952
|
-
export
|
|
1952
|
+
export type BulkWriteDeleteManyOperation<TSchema> = {
|
|
1953
1953
|
deleteMany: BulkWriteDeleteOperation<TSchema>;
|
|
1954
1954
|
};
|
|
1955
1955
|
/**
|
|
@@ -1957,7 +1957,7 @@ export declare type BulkWriteDeleteManyOperation<TSchema> = {
|
|
|
1957
1957
|
*
|
|
1958
1958
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#bulkWrite
|
|
1959
1959
|
*/
|
|
1960
|
-
export
|
|
1960
|
+
export type BulkWriteOperation<TSchema> = BulkWriteInsertOneOperation<TSchema> | BulkWriteUpdateOneOperation<TSchema> | BulkWriteUpdateManyOperation<TSchema> | BulkWriteReplaceOneOperation<TSchema> | BulkWriteDeleteOneOperation<TSchema> | BulkWriteDeleteManyOperation<TSchema>;
|
|
1961
1961
|
/**
|
|
1962
1962
|
* Returned object for the CollStats command in db.runCommand
|
|
1963
1963
|
*
|
|
@@ -2857,8 +2857,8 @@ export interface MapReduceOptions {
|
|
|
2857
2857
|
bypassDocumentValidation?: boolean | undefined;
|
|
2858
2858
|
session?: ClientSession | undefined;
|
|
2859
2859
|
}
|
|
2860
|
-
export
|
|
2861
|
-
export
|
|
2860
|
+
export type CollectionMapFunction<TSchema> = (this: TSchema) => void;
|
|
2861
|
+
export type CollectionReduceFunction<TKey, TValue> = (key: TKey, values: TValue[]) => TValue;
|
|
2862
2862
|
/**
|
|
2863
2863
|
* Returning object from write operations
|
|
2864
2864
|
*
|
|
@@ -2874,8 +2874,8 @@ export interface WriteOpResult {
|
|
|
2874
2874
|
*
|
|
2875
2875
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#~resultCallback
|
|
2876
2876
|
*/
|
|
2877
|
-
export
|
|
2878
|
-
|
|
2877
|
+
export type CursorResult = object | null | boolean;
|
|
2878
|
+
type DefaultSchema = any;
|
|
2879
2879
|
/**
|
|
2880
2880
|
* Options for Cursor.count() operations.
|
|
2881
2881
|
*
|
|
@@ -2911,13 +2911,13 @@ export interface EndCallback {
|
|
|
2911
2911
|
*
|
|
2912
2912
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#~resultCallback
|
|
2913
2913
|
*/
|
|
2914
|
-
export
|
|
2914
|
+
export type AggregationCursorResult = object | null;
|
|
2915
2915
|
/**
|
|
2916
2916
|
* Result object from CommandCursor.resultCallback
|
|
2917
2917
|
*
|
|
2918
2918
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#~resultCallback
|
|
2919
2919
|
*/
|
|
2920
|
-
export
|
|
2920
|
+
export type CommandCursorResult = object | null;
|
|
2921
2921
|
/**
|
|
2922
2922
|
* Options for creating a new GridFSBucket
|
|
2923
2923
|
*
|
|
@@ -2991,7 +2991,7 @@ export interface GridFSBucketWriteStreamOptions extends WriteConcern {
|
|
|
2991
2991
|
*/
|
|
2992
2992
|
disableMD5?: boolean | undefined;
|
|
2993
2993
|
}
|
|
2994
|
-
export
|
|
2994
|
+
export type ChangeEventTypes = 'insert' | 'delete' | 'replace' | 'update' | 'drop' | 'rename' | 'dropDatabase' | 'invalidate';
|
|
2995
2995
|
export interface ChangeEventBase<TSchema extends {
|
|
2996
2996
|
[key: string]: any;
|
|
2997
2997
|
} = DefaultSchema> {
|
|
@@ -3020,7 +3020,7 @@ export interface ChangeEventCR<TSchema extends {
|
|
|
3020
3020
|
_id: ExtractIdType<TSchema>;
|
|
3021
3021
|
};
|
|
3022
3022
|
}
|
|
3023
|
-
|
|
3023
|
+
type FieldUpdates<TSchema> = Partial<TSchema> & {
|
|
3024
3024
|
[key: string]: any;
|
|
3025
3025
|
};
|
|
3026
3026
|
export interface ChangeEventUpdate<TSchema extends {
|
|
@@ -3069,7 +3069,7 @@ export interface ChangeEventInvalidate<TSchema extends {
|
|
|
3069
3069
|
operationType: 'invalidate';
|
|
3070
3070
|
clusterTime: Timestamp;
|
|
3071
3071
|
}
|
|
3072
|
-
export
|
|
3072
|
+
export type ChangeEvent<TSchema extends object = {
|
|
3073
3073
|
_id: ObjectId;
|
|
3074
3074
|
}> = ChangeEventCR<TSchema> | ChangeEventUpdate<TSchema> | ChangeEventDelete<TSchema> | ChangeEventRename<TSchema> | ChangeEventOther<TSchema> | ChangeEventInvalidate<TSchema>;
|
|
3075
3075
|
/**
|
|
@@ -3088,7 +3088,7 @@ export interface ChangeStreamOptions {
|
|
|
3088
3088
|
collation?: CollationDocument | undefined;
|
|
3089
3089
|
readPreference?: ReadPreferenceOrMode | undefined;
|
|
3090
3090
|
}
|
|
3091
|
-
|
|
3091
|
+
type GridFSBucketWriteStreamId = string | number | object | ObjectId;
|
|
3092
3092
|
export interface LoggerOptions {
|
|
3093
3093
|
/**
|
|
3094
3094
|
* Custom logger function
|
|
@@ -3099,7 +3099,7 @@ export interface LoggerOptions {
|
|
|
3099
3099
|
*/
|
|
3100
3100
|
logger?: log | undefined;
|
|
3101
3101
|
}
|
|
3102
|
-
export
|
|
3102
|
+
export type log = (message?: string, state?: LoggerState) => void;
|
|
3103
3103
|
export interface LoggerState {
|
|
3104
3104
|
type: string;
|
|
3105
3105
|
message: string;
|
|
@@ -54,5 +54,5 @@ export interface DuplicateKeyErrorOptions extends SpruceErrors.DataStores.Duplic
|
|
|
54
54
|
export interface DatabaseNotConnectedErrorOptions extends SpruceErrors.DataStores.DatabaseNotConnected, ISpruceErrorOptions {
|
|
55
55
|
code: 'DATABASE_NOT_CONNECTED';
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
|
|
58
58
|
export default ErrorOptions;
|
|
@@ -9,7 +9,7 @@ export interface RecordsWithCursors<Response extends Record<string, any>[] = Rec
|
|
|
9
9
|
next: string | null;
|
|
10
10
|
previous: string | null;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
type PrepareQueryOptions = CursorQueryOptions & {
|
|
13
13
|
limit: number;
|
|
14
14
|
};
|
|
15
15
|
export default class CursorPager {
|
|
@@ -25,5 +25,5 @@ export default class CursorPager {
|
|
|
25
25
|
export interface SimpleStore {
|
|
26
26
|
find: (...args: any[]) => Promise<any>;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
type UnPromisify<T> = T extends Promise<infer U> ? U : T;
|
|
29
29
|
export {};
|
|
@@ -6,22 +6,22 @@ import { Binary, Decimal128, Double, Int32, Long, ObjectId, Timestamp } from 'bs
|
|
|
6
6
|
import { BSONType, ResumeToken } from 'mongodb';
|
|
7
7
|
import { AggregationCursor, Code } from 'mongodb';
|
|
8
8
|
import { ClientSession, MongoClient, MongoError, ReadPreference } from 'mongodb';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
9
|
+
type Cursor<A = any> = A extends true ? any : any;
|
|
10
|
+
type CommandCursor = any;
|
|
11
|
+
type FlattenIfArray<T> = T extends ReadonlyArray<infer R> ? R : T;
|
|
12
|
+
export type WithoutProjection<T> = T & {
|
|
13
13
|
fields?: undefined;
|
|
14
14
|
projection?: undefined;
|
|
15
15
|
};
|
|
16
16
|
export { Binary, DBRef, Decimal128, Double, Int32, Long, MaxKey, MinKey, ObjectID, ObjectId, Timestamp, } from 'bson';
|
|
17
|
-
|
|
18
|
-
export
|
|
17
|
+
type NumericTypes = number | Decimal128 | Double | Int32 | Long;
|
|
18
|
+
export type ClientSessionId = unknown;
|
|
19
19
|
/**
|
|
20
20
|
* The MongoDB ReadConcern, which allows for control of the consistency and isolation properties
|
|
21
21
|
* of the data read from replica sets and replica set shards.
|
|
22
22
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/global.html#ReadConcern
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
type ReadConcernLevel = 'local' | 'available' | 'majority' | 'linearizable' | 'snapshot';
|
|
25
25
|
/**
|
|
26
26
|
* The MongoDB ReadConcern, which allows for control of the consistency and isolation properties
|
|
27
27
|
* of the data read from replica sets and replica set shards.
|
|
@@ -113,7 +113,7 @@ export interface MongoCallback<T> {
|
|
|
113
113
|
* @returns Resulting Promise of operations run within this transaction
|
|
114
114
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/global.html#WithTransactionCallback
|
|
115
115
|
*/
|
|
116
|
-
export
|
|
116
|
+
export type WithTransactionCallback = (session: ClientSession) => Promise<void>;
|
|
117
117
|
/**
|
|
118
118
|
* Optional settings for MongoClient.connect()
|
|
119
119
|
*
|
|
@@ -411,10 +411,10 @@ export interface HighAvailabilityOptions {
|
|
|
411
411
|
*/
|
|
412
412
|
readPreferenceTags?: ReadPreferenceTags | undefined;
|
|
413
413
|
}
|
|
414
|
-
export
|
|
415
|
-
export
|
|
416
|
-
export
|
|
417
|
-
export
|
|
414
|
+
export type ReadPreferenceTags = ReadonlyArray<Record<string, string>>;
|
|
415
|
+
export type ReadPreferenceMode = 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest';
|
|
416
|
+
export type ReadPreferenceOrMode = ReadPreference | ReadPreferenceMode;
|
|
417
|
+
export type ReadPreferenceOptions = {
|
|
418
418
|
/** Server mode in which the same query is dispatched in parallel to multiple replica set members. */
|
|
419
419
|
hedge?: {
|
|
420
420
|
/** Explicitly enable or disable hedged reads. */
|
|
@@ -687,7 +687,7 @@ export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions {
|
|
|
687
687
|
*/
|
|
688
688
|
socketOptions?: SocketOptions | undefined;
|
|
689
689
|
}
|
|
690
|
-
export
|
|
690
|
+
export type ProfilingLevel = 'off' | 'slow_only' | 'all';
|
|
691
691
|
export interface CommonOptions extends WriteConcern {
|
|
692
692
|
session?: ClientSession | undefined;
|
|
693
693
|
writeConcern?: WriteConcern | string | undefined;
|
|
@@ -966,17 +966,17 @@ export interface AddUserOptions extends CommonOptions {
|
|
|
966
966
|
export interface FSyncOptions extends CommonOptions {
|
|
967
967
|
fsync?: boolean | undefined;
|
|
968
968
|
}
|
|
969
|
-
|
|
970
|
-
|
|
969
|
+
type EnhancedOmit<T, K> = string | number extends keyof T ? T : T extends any ? Pick<T, Exclude<keyof T, K>> : never;
|
|
970
|
+
type ExtractIdType<TSchema> = TSchema extends {
|
|
971
971
|
_id: infer U;
|
|
972
972
|
} ? {} extends U ? Exclude<U, {}> : unknown extends U ? ObjectId : U : ObjectId;
|
|
973
|
-
export
|
|
973
|
+
export type OptionalId<TSchema extends {
|
|
974
974
|
_id?: any;
|
|
975
975
|
}> = ObjectId extends TSchema['_id'] ? // a Schema with ObjectId _id type or "any" or "indexed type" provided
|
|
976
976
|
EnhancedOmit<TSchema, '_id'> & {
|
|
977
977
|
_id?: ExtractIdType<TSchema> | undefined;
|
|
978
978
|
} : WithId<TSchema>;
|
|
979
|
-
export
|
|
979
|
+
export type WithId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
|
|
980
980
|
_id: ExtractIdType<TSchema>;
|
|
981
981
|
};
|
|
982
982
|
/**
|
|
@@ -1610,76 +1610,76 @@ export interface Collection<TSchema extends {
|
|
|
1610
1610
|
updateOne(filter: FilterQuery<TSchema>, update: UpdateQuery<TSchema> | Partial<TSchema>, options: UpdateOneOptions, callback: MongoCallback<UpdateWriteOpResult>): void;
|
|
1611
1611
|
}
|
|
1612
1612
|
/** Update Query */
|
|
1613
|
-
|
|
1613
|
+
type KeysOfAType<TSchema, Type> = {
|
|
1614
1614
|
[key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? key : never;
|
|
1615
1615
|
}[keyof TSchema];
|
|
1616
|
-
|
|
1616
|
+
type KeysOfOtherType<TSchema, Type> = {
|
|
1617
1617
|
[key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? never : key;
|
|
1618
1618
|
}[keyof TSchema];
|
|
1619
|
-
|
|
1619
|
+
type AcceptedFields<TSchema, FieldType, AssignableType> = {
|
|
1620
1620
|
readonly [key in KeysOfAType<TSchema, FieldType>]?: AssignableType;
|
|
1621
1621
|
};
|
|
1622
1622
|
/** It avoids using fields with not acceptable types */
|
|
1623
|
-
|
|
1623
|
+
type NotAcceptedFields<TSchema, FieldType> = {
|
|
1624
1624
|
readonly [key in KeysOfOtherType<TSchema, FieldType>]?: never;
|
|
1625
1625
|
};
|
|
1626
|
-
|
|
1626
|
+
type DotAndArrayNotation<AssignableType> = {
|
|
1627
1627
|
readonly [key: string]: AssignableType;
|
|
1628
1628
|
};
|
|
1629
|
-
|
|
1629
|
+
type ReadonlyPartial<TSchema> = {
|
|
1630
1630
|
readonly [key in keyof TSchema]?: TSchema[key];
|
|
1631
1631
|
};
|
|
1632
|
-
export
|
|
1633
|
-
export
|
|
1634
|
-
|
|
1635
|
-
|
|
1632
|
+
export type OnlyFieldsOfType<TSchema, FieldType = any, AssignableType = FieldType> = AcceptedFields<TSchema, FieldType, AssignableType> & NotAcceptedFields<TSchema, FieldType> & DotAndArrayNotation<AssignableType>;
|
|
1633
|
+
export type MatchKeysAndValues<TSchema> = ReadonlyPartial<TSchema> & DotAndArrayNotation<any>;
|
|
1634
|
+
type Unpacked<Type> = Type extends ReadonlyArray<infer Element> ? Element : Type;
|
|
1635
|
+
type UpdateOptionalId<T> = T extends {
|
|
1636
1636
|
_id?: any;
|
|
1637
1637
|
} ? OptionalId<T> : T;
|
|
1638
|
-
export
|
|
1638
|
+
export type SortValues = -1 | 1;
|
|
1639
1639
|
/**
|
|
1640
1640
|
* Values for the $meta aggregation pipeline operator
|
|
1641
1641
|
*
|
|
1642
1642
|
* @see https://docs.mongodb.com/v3.6/reference/operator/aggregation/meta/#proj._S_meta
|
|
1643
1643
|
*/
|
|
1644
|
-
export
|
|
1645
|
-
export
|
|
1644
|
+
export type MetaSortOperators = 'textScore' | 'indexKey';
|
|
1645
|
+
export type MetaProjectionOperators = MetaSortOperators
|
|
1646
1646
|
/** Only for Atlas Search https://docs.atlas.mongodb.com/reference/atlas-search/scoring/ */
|
|
1647
1647
|
| 'searchScore'
|
|
1648
1648
|
/** Only for Atlas Search https://docs.atlas.mongodb.com/reference/atlas-search/highlighting/ */
|
|
1649
1649
|
| 'searchHighlights';
|
|
1650
|
-
export
|
|
1650
|
+
export type SchemaMember<T, V> = {
|
|
1651
1651
|
[P in keyof T]?: V;
|
|
1652
1652
|
} | {
|
|
1653
1653
|
[key: string]: V;
|
|
1654
1654
|
};
|
|
1655
|
-
export
|
|
1655
|
+
export type SortOptionObject<T> = SchemaMember<T, number | {
|
|
1656
1656
|
$meta?: MetaSortOperators | undefined;
|
|
1657
1657
|
}>;
|
|
1658
|
-
export
|
|
1658
|
+
export type AddToSetOperators<Type> = {
|
|
1659
1659
|
$each: Type;
|
|
1660
1660
|
};
|
|
1661
|
-
export
|
|
1661
|
+
export type ArrayOperator<Type> = {
|
|
1662
1662
|
$each: Type;
|
|
1663
1663
|
$slice?: number | undefined;
|
|
1664
1664
|
$position?: number | undefined;
|
|
1665
1665
|
$sort?: SortValues | Record<string, SortValues> | undefined;
|
|
1666
1666
|
};
|
|
1667
|
-
export
|
|
1667
|
+
export type SetFields<TSchema> = ({
|
|
1668
1668
|
readonly [key in KeysOfAType<TSchema, ReadonlyArray<any> | undefined>]?: UpdateOptionalId<Unpacked<TSchema[key]>> | AddToSetOperators<Array<UpdateOptionalId<Unpacked<TSchema[key]>>>>;
|
|
1669
1669
|
} & NotAcceptedFields<TSchema, ReadonlyArray<any> | undefined>) & {
|
|
1670
1670
|
readonly [key: string]: AddToSetOperators<any> | any;
|
|
1671
1671
|
};
|
|
1672
|
-
export
|
|
1672
|
+
export type PushOperator<TSchema> = ({
|
|
1673
1673
|
readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: Unpacked<TSchema[key]> | ArrayOperator<Array<Unpacked<TSchema[key]>>>;
|
|
1674
1674
|
} & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
|
1675
1675
|
readonly [key: string]: ArrayOperator<any> | any;
|
|
1676
1676
|
};
|
|
1677
|
-
export
|
|
1677
|
+
export type PullOperator<TSchema> = ({
|
|
1678
1678
|
readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: Partial<Unpacked<TSchema[key]>> | ObjectQuerySelector<Unpacked<TSchema[key]>>;
|
|
1679
1679
|
} & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
|
1680
1680
|
readonly [key: string]: QuerySelector<any> | any;
|
|
1681
1681
|
};
|
|
1682
|
-
export
|
|
1682
|
+
export type PullAllOperator<TSchema> = ({
|
|
1683
1683
|
readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: TSchema[key];
|
|
1684
1684
|
} & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
|
1685
1685
|
readonly [key: string]: any[];
|
|
@@ -1709,7 +1709,7 @@ export declare type PullAllOperator<TSchema> = ({
|
|
|
1709
1709
|
* @see https://docs.mongodb.com/v3.6/reference/operator/update-bitwise/
|
|
1710
1710
|
*
|
|
1711
1711
|
*/
|
|
1712
|
-
export
|
|
1712
|
+
export type UpdateQuery<TSchema> = {
|
|
1713
1713
|
$currentDate?: OnlyFieldsOfType<TSchema, Date | Timestamp, true | {
|
|
1714
1714
|
$type: 'date' | 'timestamp';
|
|
1715
1715
|
}> | undefined;
|
|
@@ -1765,11 +1765,11 @@ export declare enum BsonType {
|
|
|
1765
1765
|
MinKey = -1,
|
|
1766
1766
|
MaxKey = 127
|
|
1767
1767
|
}
|
|
1768
|
-
|
|
1768
|
+
type BSONTypeAlias = 'number' | 'double' | 'string' | 'object' | 'array' | 'binData' | 'undefined' | 'objectId' | 'bool' | 'date' | 'null' | 'regex' | 'dbPointer' | 'javascript' | 'symbol' | 'javascriptWithScope' | 'int' | 'timestamp' | 'long' | 'decimal' | 'minKey' | 'maxKey';
|
|
1769
1769
|
/** @see https://docs.mongodb.com/v3.6/reference/operator/query-bitwise */
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1770
|
+
type BitwiseQuery = number /** <numeric bitmask> */ | Binary /** <BinData bitmask> */ | number[]; /** [ <position1>, <position2>, ... ] */
|
|
1771
|
+
type RegExpForString<T> = T extends string ? RegExp | T : T;
|
|
1772
|
+
type MongoAltQuery<T> = T extends ReadonlyArray<infer U> ? T | RegExpForString<U> : RegExpForString<T>;
|
|
1773
1773
|
/**
|
|
1774
1774
|
* Available query selector types
|
|
1775
1775
|
*
|
|
@@ -1820,7 +1820,7 @@ declare type MongoAltQuery<T> = T extends ReadonlyArray<infer U> ? T | RegExpFor
|
|
|
1820
1820
|
*
|
|
1821
1821
|
* @see https://docs.mongodb.com/v3.6/reference/operator/query/#query-selectors
|
|
1822
1822
|
*/
|
|
1823
|
-
export
|
|
1823
|
+
export type QuerySelector<T> = {
|
|
1824
1824
|
$eq?: T | undefined;
|
|
1825
1825
|
$gt?: T | undefined;
|
|
1826
1826
|
$gte?: T | undefined;
|
|
@@ -1856,7 +1856,7 @@ export declare type QuerySelector<T> = {
|
|
|
1856
1856
|
$bitsAnyClear?: BitwiseQuery | undefined;
|
|
1857
1857
|
$bitsAnySet?: BitwiseQuery | undefined;
|
|
1858
1858
|
};
|
|
1859
|
-
export
|
|
1859
|
+
export type RootQuerySelector<T> = {
|
|
1860
1860
|
/** @see https://docs.mongodb.com/v3.6/reference/operator/query/and/#op._S_and */
|
|
1861
1861
|
$and?: Array<FilterQuery<T>> | undefined;
|
|
1862
1862
|
/** @see https://docs.mongodb.com/v3.6/reference/operator/query/nor/#op._S_nor */
|
|
@@ -1876,15 +1876,15 @@ export declare type RootQuerySelector<T> = {
|
|
|
1876
1876
|
$comment?: string | undefined;
|
|
1877
1877
|
[key: string]: any;
|
|
1878
1878
|
};
|
|
1879
|
-
export
|
|
1879
|
+
export type ObjectQuerySelector<T> = T extends object ? {
|
|
1880
1880
|
[key in keyof T]?: QuerySelector<T[key]>;
|
|
1881
1881
|
} : QuerySelector<T>;
|
|
1882
|
-
export
|
|
1883
|
-
export
|
|
1882
|
+
export type Condition<T> = MongoAltQuery<T> | QuerySelector<MongoAltQuery<T>>;
|
|
1883
|
+
export type FilterQuery<T> = {
|
|
1884
1884
|
[P in keyof T]?: Condition<T[P]>;
|
|
1885
1885
|
} & RootQuerySelector<T>;
|
|
1886
1886
|
/** @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#insertone */
|
|
1887
|
-
export
|
|
1887
|
+
export type BulkWriteInsertOneOperation<TSchema> = {
|
|
1888
1888
|
insertOne: {
|
|
1889
1889
|
/** @ts-ignore */
|
|
1890
1890
|
document: OptionalId<TSchema>;
|
|
@@ -1902,17 +1902,17 @@ export declare type BulkWriteInsertOneOperation<TSchema> = {
|
|
|
1902
1902
|
* For more details see {@link https://docs.mongodb.com/v3.6/reference/method/db.collection.update/#upsert-behavior upsert behavior}
|
|
1903
1903
|
* @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#updateone-and-updatemany
|
|
1904
1904
|
*/
|
|
1905
|
-
export
|
|
1905
|
+
export type BulkWriteUpdateOperation<TSchema> = {
|
|
1906
1906
|
arrayFilters?: object[] | undefined;
|
|
1907
1907
|
collation?: object | undefined;
|
|
1908
1908
|
filter: FilterQuery<TSchema>;
|
|
1909
1909
|
update: UpdateQuery<TSchema>;
|
|
1910
1910
|
upsert?: boolean | undefined;
|
|
1911
1911
|
};
|
|
1912
|
-
export
|
|
1912
|
+
export type BulkWriteUpdateOneOperation<TSchema> = {
|
|
1913
1913
|
updateOne: BulkWriteUpdateOperation<TSchema>;
|
|
1914
1914
|
};
|
|
1915
|
-
export
|
|
1915
|
+
export type BulkWriteUpdateManyOperation<TSchema> = {
|
|
1916
1916
|
updateMany: BulkWriteUpdateOperation<TSchema>;
|
|
1917
1917
|
};
|
|
1918
1918
|
/**
|
|
@@ -1927,7 +1927,7 @@ export declare type BulkWriteUpdateManyOperation<TSchema> = {
|
|
|
1927
1927
|
* For more details see {@link https://docs.mongodb.com/v3.6/reference/method/db.collection.update/#upsert-behavior upsert behavior}
|
|
1928
1928
|
* @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#replaceone
|
|
1929
1929
|
*/
|
|
1930
|
-
export
|
|
1930
|
+
export type BulkWriteReplaceOneOperation<TSchema> = {
|
|
1931
1931
|
replaceOne: {
|
|
1932
1932
|
collation?: object | undefined;
|
|
1933
1933
|
filter: FilterQuery<TSchema>;
|
|
@@ -1942,14 +1942,14 @@ export declare type BulkWriteReplaceOneOperation<TSchema> = {
|
|
|
1942
1942
|
* @param filter Specifies deletion criteria using {@link https://docs.mongodb.com/v3.6/reference/operator/ query operators}.
|
|
1943
1943
|
* @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#deleteone-and-deletemany
|
|
1944
1944
|
*/
|
|
1945
|
-
export
|
|
1945
|
+
export type BulkWriteDeleteOperation<TSchema> = {
|
|
1946
1946
|
collation?: object | undefined;
|
|
1947
1947
|
filter: FilterQuery<TSchema>;
|
|
1948
1948
|
};
|
|
1949
|
-
export
|
|
1949
|
+
export type BulkWriteDeleteOneOperation<TSchema> = {
|
|
1950
1950
|
deleteOne: BulkWriteDeleteOperation<TSchema>;
|
|
1951
1951
|
};
|
|
1952
|
-
export
|
|
1952
|
+
export type BulkWriteDeleteManyOperation<TSchema> = {
|
|
1953
1953
|
deleteMany: BulkWriteDeleteOperation<TSchema>;
|
|
1954
1954
|
};
|
|
1955
1955
|
/**
|
|
@@ -1957,7 +1957,7 @@ export declare type BulkWriteDeleteManyOperation<TSchema> = {
|
|
|
1957
1957
|
*
|
|
1958
1958
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#bulkWrite
|
|
1959
1959
|
*/
|
|
1960
|
-
export
|
|
1960
|
+
export type BulkWriteOperation<TSchema> = BulkWriteInsertOneOperation<TSchema> | BulkWriteUpdateOneOperation<TSchema> | BulkWriteUpdateManyOperation<TSchema> | BulkWriteReplaceOneOperation<TSchema> | BulkWriteDeleteOneOperation<TSchema> | BulkWriteDeleteManyOperation<TSchema>;
|
|
1961
1961
|
/**
|
|
1962
1962
|
* Returned object for the CollStats command in db.runCommand
|
|
1963
1963
|
*
|
|
@@ -2857,8 +2857,8 @@ export interface MapReduceOptions {
|
|
|
2857
2857
|
bypassDocumentValidation?: boolean | undefined;
|
|
2858
2858
|
session?: ClientSession | undefined;
|
|
2859
2859
|
}
|
|
2860
|
-
export
|
|
2861
|
-
export
|
|
2860
|
+
export type CollectionMapFunction<TSchema> = (this: TSchema) => void;
|
|
2861
|
+
export type CollectionReduceFunction<TKey, TValue> = (key: TKey, values: TValue[]) => TValue;
|
|
2862
2862
|
/**
|
|
2863
2863
|
* Returning object from write operations
|
|
2864
2864
|
*
|
|
@@ -2874,8 +2874,8 @@ export interface WriteOpResult {
|
|
|
2874
2874
|
*
|
|
2875
2875
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#~resultCallback
|
|
2876
2876
|
*/
|
|
2877
|
-
export
|
|
2878
|
-
|
|
2877
|
+
export type CursorResult = object | null | boolean;
|
|
2878
|
+
type DefaultSchema = any;
|
|
2879
2879
|
/**
|
|
2880
2880
|
* Options for Cursor.count() operations.
|
|
2881
2881
|
*
|
|
@@ -2911,13 +2911,13 @@ export interface EndCallback {
|
|
|
2911
2911
|
*
|
|
2912
2912
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/AggregationCursor.html#~resultCallback
|
|
2913
2913
|
*/
|
|
2914
|
-
export
|
|
2914
|
+
export type AggregationCursorResult = object | null;
|
|
2915
2915
|
/**
|
|
2916
2916
|
* Result object from CommandCursor.resultCallback
|
|
2917
2917
|
*
|
|
2918
2918
|
* @see https://mongodb.github.io/node-mongodb-native/3.6/api/CommandCursor.html#~resultCallback
|
|
2919
2919
|
*/
|
|
2920
|
-
export
|
|
2920
|
+
export type CommandCursorResult = object | null;
|
|
2921
2921
|
/**
|
|
2922
2922
|
* Options for creating a new GridFSBucket
|
|
2923
2923
|
*
|
|
@@ -2991,7 +2991,7 @@ export interface GridFSBucketWriteStreamOptions extends WriteConcern {
|
|
|
2991
2991
|
*/
|
|
2992
2992
|
disableMD5?: boolean | undefined;
|
|
2993
2993
|
}
|
|
2994
|
-
export
|
|
2994
|
+
export type ChangeEventTypes = 'insert' | 'delete' | 'replace' | 'update' | 'drop' | 'rename' | 'dropDatabase' | 'invalidate';
|
|
2995
2995
|
export interface ChangeEventBase<TSchema extends {
|
|
2996
2996
|
[key: string]: any;
|
|
2997
2997
|
} = DefaultSchema> {
|
|
@@ -3020,7 +3020,7 @@ export interface ChangeEventCR<TSchema extends {
|
|
|
3020
3020
|
_id: ExtractIdType<TSchema>;
|
|
3021
3021
|
};
|
|
3022
3022
|
}
|
|
3023
|
-
|
|
3023
|
+
type FieldUpdates<TSchema> = Partial<TSchema> & {
|
|
3024
3024
|
[key: string]: any;
|
|
3025
3025
|
};
|
|
3026
3026
|
export interface ChangeEventUpdate<TSchema extends {
|
|
@@ -3069,7 +3069,7 @@ export interface ChangeEventInvalidate<TSchema extends {
|
|
|
3069
3069
|
operationType: 'invalidate';
|
|
3070
3070
|
clusterTime: Timestamp;
|
|
3071
3071
|
}
|
|
3072
|
-
export
|
|
3072
|
+
export type ChangeEvent<TSchema extends object = {
|
|
3073
3073
|
_id: ObjectId;
|
|
3074
3074
|
}> = ChangeEventCR<TSchema> | ChangeEventUpdate<TSchema> | ChangeEventDelete<TSchema> | ChangeEventRename<TSchema> | ChangeEventOther<TSchema> | ChangeEventInvalidate<TSchema>;
|
|
3075
3075
|
/**
|
|
@@ -3088,7 +3088,7 @@ export interface ChangeStreamOptions {
|
|
|
3088
3088
|
collation?: CollationDocument | undefined;
|
|
3089
3089
|
readPreference?: ReadPreferenceOrMode | undefined;
|
|
3090
3090
|
}
|
|
3091
|
-
|
|
3091
|
+
type GridFSBucketWriteStreamId = string | number | object | ObjectId;
|
|
3092
3092
|
export interface LoggerOptions {
|
|
3093
3093
|
/**
|
|
3094
3094
|
* Custom logger function
|
|
@@ -3099,7 +3099,7 @@ export interface LoggerOptions {
|
|
|
3099
3099
|
*/
|
|
3100
3100
|
logger?: log | undefined;
|
|
3101
3101
|
}
|
|
3102
|
-
export
|
|
3102
|
+
export type log = (message?: string, state?: LoggerState) => void;
|
|
3103
3103
|
export interface LoggerState {
|
|
3104
3104
|
type: string;
|
|
3105
3105
|
message: string;
|
|
@@ -2,7 +2,7 @@ import AbstractSpruceError from '@sprucelabs/error';
|
|
|
2
2
|
import { FailedToLoadStoreErrorOptions } from "./../.spruce/errors/options.types";
|
|
3
3
|
import StoreFactory from '../factories/StoreFactory';
|
|
4
4
|
import { Database } from '../types/database.types';
|
|
5
|
-
|
|
5
|
+
type StoreLoadError = AbstractSpruceError<FailedToLoadStoreErrorOptions>;
|
|
6
6
|
export default class StoreLoader {
|
|
7
7
|
private activeDir;
|
|
8
8
|
private db;
|
|
@@ -3,7 +3,7 @@ import AbstractMutexer from '../mutexers/AbstractMutexer';
|
|
|
3
3
|
import { Database } from '../types/database.types';
|
|
4
4
|
import { QueryBuilder, QueryOptions } from '../types/query.types';
|
|
5
5
|
import { PrepareOptions, PrepareResults, SaveOperations } from '../types/stores.types';
|
|
6
|
-
|
|
6
|
+
type Response<FullSchema extends Schema, CreateEntityInstances extends boolean, IncludePrivateFields extends boolean, PF extends SchemaPublicFieldNames<FullSchema>, F extends SchemaFieldNames<FullSchema>> = IsDynamicSchema<FullSchema> extends true ? DynamicSchemaAllValues<FullSchema, CreateEntityInstances> : IncludePrivateFields extends false ? Pick<SchemaPublicValues<FullSchema, CreateEntityInstances>, PF> : Pick<SchemaAllValues<FullSchema, CreateEntityInstances>, F>;
|
|
7
7
|
export default abstract class AbstractStore<FullSchema extends Schema, CreateSchema extends Schema = FullSchema, UpdateSchema extends Schema = CreateSchema, DatabaseSchema extends Schema = FullSchema, DatabaseRecord = SchemaValues<DatabaseSchema> & {
|
|
8
8
|
id: string;
|
|
9
9
|
}, QueryRecord = SchemaPartialValues<FullSchema>, FullRecord = SchemaValues<FullSchema>, CreateRecord = SchemaValues<CreateSchema>, UpdateRecord = SchemaValues<UpdateSchema> & SaveOperations> extends AbstractMutexer {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryOptions } from './query.types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type UniqueIndex = string[];
|
|
3
|
+
export type Index = string[];
|
|
4
4
|
export interface Database {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
syncUniqueIndexes(collectionName: string, indexes: UniqueIndex[]): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QuerySelector } from '../databases/mongo.types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
2
|
+
type QueryPredicate<Query, K extends keyof Query> = Query[K] | QuerySelector<Query[K]> | string;
|
|
3
|
+
type Obj = Record<string, any>;
|
|
4
|
+
export type QueryBuilder<Query> = {
|
|
5
5
|
[K in keyof Query]?: QueryPredicate<Query, K>;
|
|
6
6
|
} & {
|
|
7
7
|
id?: string | QuerySelector<string>;
|
|
@@ -15,15 +15,15 @@ export interface QueryOptions {
|
|
|
15
15
|
}[];
|
|
16
16
|
includeFields?: string[];
|
|
17
17
|
}
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
18
|
+
export type FlattenAndPathKeys<O extends Obj, T extends Obj = PathKeys<O>> = Flatten<T>;
|
|
19
|
+
export type Flatten<T extends Obj> = Pick<T, NonObjectKeysOf<T>> & UnionToIntersection<ObjectValuesOf<T>>;
|
|
20
|
+
export type PathKeys<Query extends Obj, prefix extends string = ''> = {
|
|
21
21
|
[K in Extract<keyof Query, string> as `${prefix}${K}`]: Query[K] extends Obj ? PathKeys<Query[K], `${K}.`> : Query[K];
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
24
|
+
type ValuesOf<T> = T[keyof T];
|
|
25
|
+
type ObjectValuesOf<T> = Exclude<Extract<ValuesOf<T>, object>, Array<any>>;
|
|
26
|
+
type NonObjectKeysOf<T> = {
|
|
27
27
|
[K in keyof T]: T[K] extends Array<any> ? K : T[K] extends Obj ? never : K;
|
|
28
28
|
}[keyof T];
|
|
29
29
|
export {};
|
|
@@ -2,8 +2,8 @@ import { Schema, SchemaFieldNames, SchemaPublicValues, SchemaValues } from '@spr
|
|
|
2
2
|
import StoreFactory from '../factories/StoreFactory';
|
|
3
3
|
import { Database } from './database.types';
|
|
4
4
|
export declare const saveOperations: readonly ["$push", "$inc", "$min", "$max", "$mul", "$push", "$pull", "$pop"];
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type SaveOperation = typeof saveOperations[number];
|
|
6
|
+
export type SaveOperations = Partial<Record<SaveOperation, Record<string, any>>>;
|
|
7
7
|
export interface UniversalStoreOptions {
|
|
8
8
|
db: Database;
|
|
9
9
|
storeFactory: StoreFactory;
|
|
@@ -11,7 +11,7 @@ export interface UniversalStoreOptions {
|
|
|
11
11
|
export interface Store {
|
|
12
12
|
initialize?(): Promise<void>;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export type SimplifiedStoreFactory = Pick<StoreFactory, 'getStore'>;
|
|
15
15
|
export interface StoreMap {
|
|
16
16
|
}
|
|
17
17
|
export interface StoreOptionsMap {
|
|
@@ -20,6 +20,6 @@ export interface PrepareOptions<IncludePrivateFields extends boolean, S extends
|
|
|
20
20
|
shouldIncludePrivateFields?: IncludePrivateFields;
|
|
21
21
|
includeFields?: FieldNames[];
|
|
22
22
|
}
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
23
|
+
export type PrepareResults<S extends Schema, IncludePrivateFields extends boolean> = IncludePrivateFields extends true ? SchemaPublicValues<S> : SchemaValues<S>;
|
|
24
|
+
export type StoreName = keyof StoreMap;
|
|
25
|
+
export type StoreOptions<Name extends StoreName> = Name extends keyof StoreOptionsMap ? StoreOptionsMap[Name] : Record<string, never>;
|
|
@@ -2,7 +2,7 @@ import AbstractSpruceError from '@sprucelabs/error';
|
|
|
2
2
|
import { FailedToLoadStoreErrorOptions } from "./../.spruce/errors/options.types";
|
|
3
3
|
import StoreFactory from '../factories/StoreFactory';
|
|
4
4
|
import { Database } from '../types/database.types';
|
|
5
|
-
|
|
5
|
+
type StoreLoadError = AbstractSpruceError<FailedToLoadStoreErrorOptions>;
|
|
6
6
|
export default class StoreLoader {
|
|
7
7
|
private activeDir;
|
|
8
8
|
private db;
|
|
@@ -3,7 +3,7 @@ import AbstractMutexer from '../mutexers/AbstractMutexer';
|
|
|
3
3
|
import { Database } from '../types/database.types';
|
|
4
4
|
import { QueryBuilder, QueryOptions } from '../types/query.types';
|
|
5
5
|
import { PrepareOptions, PrepareResults, SaveOperations } from '../types/stores.types';
|
|
6
|
-
|
|
6
|
+
type Response<FullSchema extends Schema, CreateEntityInstances extends boolean, IncludePrivateFields extends boolean, PF extends SchemaPublicFieldNames<FullSchema>, F extends SchemaFieldNames<FullSchema>> = IsDynamicSchema<FullSchema> extends true ? DynamicSchemaAllValues<FullSchema, CreateEntityInstances> : IncludePrivateFields extends false ? Pick<SchemaPublicValues<FullSchema, CreateEntityInstances>, PF> : Pick<SchemaAllValues<FullSchema, CreateEntityInstances>, F>;
|
|
7
7
|
export default abstract class AbstractStore<FullSchema extends Schema, CreateSchema extends Schema = FullSchema, UpdateSchema extends Schema = CreateSchema, DatabaseSchema extends Schema = FullSchema, DatabaseRecord = SchemaValues<DatabaseSchema> & {
|
|
8
8
|
id: string;
|
|
9
9
|
}, QueryRecord = SchemaPartialValues<FullSchema>, FullRecord = SchemaValues<FullSchema>, CreateRecord = SchemaValues<CreateSchema>, UpdateRecord = SchemaValues<UpdateSchema> & SaveOperations> extends AbstractMutexer {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryOptions } from './query.types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type UniqueIndex = string[];
|
|
3
|
+
export type Index = string[];
|
|
4
4
|
export interface Database {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
syncUniqueIndexes(collectionName: string, indexes: UniqueIndex[]): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QuerySelector } from '../databases/mongo.types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
2
|
+
type QueryPredicate<Query, K extends keyof Query> = Query[K] | QuerySelector<Query[K]> | string;
|
|
3
|
+
type Obj = Record<string, any>;
|
|
4
|
+
export type QueryBuilder<Query> = {
|
|
5
5
|
[K in keyof Query]?: QueryPredicate<Query, K>;
|
|
6
6
|
} & {
|
|
7
7
|
id?: string | QuerySelector<string>;
|
|
@@ -15,15 +15,15 @@ export interface QueryOptions {
|
|
|
15
15
|
}[];
|
|
16
16
|
includeFields?: string[];
|
|
17
17
|
}
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
18
|
+
export type FlattenAndPathKeys<O extends Obj, T extends Obj = PathKeys<O>> = Flatten<T>;
|
|
19
|
+
export type Flatten<T extends Obj> = Pick<T, NonObjectKeysOf<T>> & UnionToIntersection<ObjectValuesOf<T>>;
|
|
20
|
+
export type PathKeys<Query extends Obj, prefix extends string = ''> = {
|
|
21
21
|
[K in Extract<keyof Query, string> as `${prefix}${K}`]: Query[K] extends Obj ? PathKeys<Query[K], `${K}.`> : Query[K];
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
24
|
+
type ValuesOf<T> = T[keyof T];
|
|
25
|
+
type ObjectValuesOf<T> = Exclude<Extract<ValuesOf<T>, object>, Array<any>>;
|
|
26
|
+
type NonObjectKeysOf<T> = {
|
|
27
27
|
[K in keyof T]: T[K] extends Array<any> ? K : T[K] extends Obj ? never : K;
|
|
28
28
|
}[keyof T];
|
|
29
29
|
export {};
|
|
@@ -2,8 +2,8 @@ import { Schema, SchemaFieldNames, SchemaPublicValues, SchemaValues } from '@spr
|
|
|
2
2
|
import StoreFactory from '../factories/StoreFactory';
|
|
3
3
|
import { Database } from './database.types';
|
|
4
4
|
export declare const saveOperations: readonly ["$push", "$inc", "$min", "$max", "$mul", "$push", "$pull", "$pop"];
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type SaveOperation = typeof saveOperations[number];
|
|
6
|
+
export type SaveOperations = Partial<Record<SaveOperation, Record<string, any>>>;
|
|
7
7
|
export interface UniversalStoreOptions {
|
|
8
8
|
db: Database;
|
|
9
9
|
storeFactory: StoreFactory;
|
|
@@ -11,7 +11,7 @@ export interface UniversalStoreOptions {
|
|
|
11
11
|
export interface Store {
|
|
12
12
|
initialize?(): Promise<void>;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export type SimplifiedStoreFactory = Pick<StoreFactory, 'getStore'>;
|
|
15
15
|
export interface StoreMap {
|
|
16
16
|
}
|
|
17
17
|
export interface StoreOptionsMap {
|
|
@@ -20,6 +20,6 @@ export interface PrepareOptions<IncludePrivateFields extends boolean, S extends
|
|
|
20
20
|
shouldIncludePrivateFields?: IncludePrivateFields;
|
|
21
21
|
includeFields?: FieldNames[];
|
|
22
22
|
}
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
23
|
+
export type PrepareResults<S extends Schema, IncludePrivateFields extends boolean> = IncludePrivateFields extends true ? SchemaPublicValues<S> : SchemaValues<S>;
|
|
24
|
+
export type StoreName = keyof StoreMap;
|
|
25
|
+
export type StoreOptions<Name extends StoreName> = Name extends keyof StoreOptionsMap ? StoreOptionsMap[Name] : Record<string, never>;
|