@sprucelabs/data-stores 26.4.89 → 27.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. package/build/.spruce/errors/dataStores/databaseNotConnected.schema.js +5 -5
  2. package/build/.spruce/errors/dataStores/duplicateKey.schema.js +1 -1
  3. package/build/.spruce/errors/dataStores/duplicateRecord.schema.js +9 -9
  4. package/build/.spruce/errors/dataStores/failedToLoadStore.schema.js +3 -3
  5. package/build/.spruce/errors/dataStores/failedToLoadStores.schema.js +5 -3
  6. package/build/.spruce/errors/dataStores/indexExists.schema.js +5 -5
  7. package/build/.spruce/errors/dataStores/indexNotFound.schema.js +5 -5
  8. package/build/.spruce/errors/dataStores/invalidConnectionStringScheme.schema.js +3 -3
  9. package/build/.spruce/errors/dataStores/invalidDatabaseName.schema.js +3 -3
  10. package/build/.spruce/errors/dataStores/invalidDbConnectionString.schema.js +1 -1
  11. package/build/.spruce/errors/dataStores/invalidFakeQueryResponse.schema.js +5 -5
  12. package/build/.spruce/errors/dataStores/invalidStore.schema copy.js +5 -5
  13. package/build/.spruce/errors/dataStores/invalidStore.schema.js +1 -1
  14. package/build/.spruce/errors/dataStores/invalidStoreName.schema.js +5 -5
  15. package/build/.spruce/errors/dataStores/mongoIdMappingError.schema.js +1 -1
  16. package/build/.spruce/errors/dataStores/notImplemented.schema.js +1 -1
  17. package/build/.spruce/errors/dataStores/queryNotFaked.schema.js +5 -5
  18. package/build/.spruce/errors/dataStores/record-not-found-query.schema.js +1 -1
  19. package/build/.spruce/errors/dataStores/recordNotFound.schema.js +5 -5
  20. package/build/.spruce/errors/dataStores/scrambleNotConfigured.schema.js +1 -1
  21. package/build/.spruce/errors/dataStores/unableToConnectToDb.schema.js +1 -1
  22. package/build/.spruce/errors/dataStores/unknownDatabaseError.schema.js +3 -3
  23. package/build/.spruce/errors/dataStores/unknownError.schema.js +1 -1
  24. package/build/.spruce/errors/dataStores/unknownStoreError.schema.js +5 -5
  25. package/build/.spruce/errors/errors.types.d.ts +53 -56
  26. package/build/.spruce/errors/errors.types.js +0 -2
  27. package/build/.spruce/errors/options.types.d.ts +2 -2
  28. package/build/.spruce/schemas/fields/fields.types.d.ts +1 -1
  29. package/build/cursors/BatchArrayCursor.d.ts +2 -2
  30. package/build/databases/MongoDatabase.js +3 -1
  31. package/build/databases/NeDbDatabase.js +9 -3
  32. package/build/databases/mongo.types.d.ts +89 -135
  33. package/build/databases/mongo.types.js +0 -1
  34. package/build/errors/SpruceError.d.ts +1 -1
  35. package/build/errors/SpruceError.js +6 -2
  36. package/build/errors/failedToLoadStores.builder.js +1 -1
  37. package/build/errors/mongoIdMappingError.builder.js +0 -2
  38. package/build/errors/scrambleNotConfigured.builder.js +0 -2
  39. package/build/esm/.spruce/errors/errors.types.d.ts +53 -56
  40. package/build/esm/.spruce/errors/errors.types.js +0 -2
  41. package/build/esm/.spruce/errors/options.types.d.ts +2 -2
  42. package/build/esm/cursors/BatchArrayCursor.d.ts +2 -2
  43. package/build/esm/databases/MongoDatabase.js +3 -1
  44. package/build/esm/databases/NeDbDatabase.js +9 -3
  45. package/build/esm/databases/mongo.types.d.ts +89 -135
  46. package/build/esm/databases/mongo.types.js +0 -1
  47. package/build/esm/errors/SpruceError.d.ts +1 -1
  48. package/build/esm/errors/SpruceError.js +6 -2
  49. package/build/esm/errors/failedToLoadStores.builder.js +1 -1
  50. package/build/esm/errors/mongoIdMappingError.builder.js +0 -2
  51. package/build/esm/errors/scrambleNotConfigured.builder.js +0 -2
  52. package/build/esm/loaders/StoreLoader.d.ts +1 -1
  53. package/build/esm/plugins/DatabaseFieldMapperPlugin.js +3 -1
  54. package/build/esm/stores/AbstractStore.js +4 -2
  55. package/build/esm/tests/AbstractDatabaseTest.js +3 -1
  56. package/build/esm/tests/databaseAssertUtil.js +66 -20
  57. package/build/esm/types/query.types.d.ts +4 -4
  58. package/build/esm/types/query.types.js +0 -1
  59. package/build/loaders/StoreLoader.d.ts +1 -1
  60. package/build/plugins/DatabaseFieldMapperPlugin.js +3 -1
  61. package/build/stores/AbstractStore.js +4 -2
  62. package/build/tests/AbstractDatabaseTest.js +3 -1
  63. package/build/tests/databaseAssertUtil.js +66 -20
  64. package/build/types/query.types.d.ts +4 -4
  65. package/build/types/query.types.js +0 -1
  66. package/package.json +17 -29
@@ -8,7 +8,7 @@ import { AggregationCursor, Code } from 'mongodb';
8
8
  import { ClientSession, MongoClient, MongoError, ReadPreference } from 'mongodb';
9
9
  type Cursor<A = any> = A extends true ? any : any;
10
10
  type CommandCursor = any;
11
- type FlattenIfArray<T> = T extends ReadonlyArray<infer R> ? R : T;
11
+ type FlattenIfArray<T> = T extends readonly (infer R)[] ? R : T;
12
12
  export type WithoutProjection<T> = T & {
13
13
  fields?: undefined;
14
14
  projection?: undefined;
@@ -103,9 +103,7 @@ export interface MongoClientCommonOption {
103
103
  * @param result The result object if the command was executed successfully.
104
104
  * @see https://mongodb.github.io/node-mongodb-native/3.6/api/Admin.html#~resultCallback
105
105
  */
106
- export interface MongoCallback<T> {
107
- (error: MongoError, result: T): void;
108
- }
106
+ export type MongoCallback<T> = (error: MongoError, result: T) => void;
109
107
  /**
110
108
  * A user provided function to be run within a transaction
111
109
  *
@@ -127,7 +125,7 @@ export interface MongoClientOptions extends DbCreateOptions, ServerOptions, Mong
127
125
  /**
128
126
  * Custom logger object
129
127
  */
130
- logger?: object | log | undefined;
128
+ logger?: object | Log | undefined;
131
129
  /**
132
130
  * Validate MongoClient passed in options for correctness
133
131
  * @default false
@@ -171,7 +169,7 @@ export interface MongoClientOptions extends DbCreateOptions, ServerOptions, Mong
171
169
  /** Type of compression to use */
172
170
  compression?: {
173
171
  /** The selected compressors in preference order */
174
- compressors?: Array<'snappy' | 'zlib'> | undefined;
172
+ compressors?: ('snappy' | 'zlib')[] | undefined;
175
173
  } | undefined;
176
174
  /**
177
175
  * Enable directConnection
@@ -328,11 +326,11 @@ export interface SSLOptions {
328
326
  /**
329
327
  * Array of valid certificates either as Buffers or Strings
330
328
  */
331
- sslCA?: ReadonlyArray<Buffer | string> | undefined;
329
+ sslCA?: readonly (Buffer | string)[] | undefined;
332
330
  /**
333
331
  * SSL Certificate revocation list binary buffer
334
332
  */
335
- sslCRL?: ReadonlyArray<Buffer | string> | undefined;
333
+ sslCRL?: readonly (Buffer | string)[] | undefined;
336
334
  /**
337
335
  * SSL Certificate binary buffer
338
336
  */
@@ -411,10 +409,10 @@ export interface HighAvailabilityOptions {
411
409
  */
412
410
  readPreferenceTags?: ReadPreferenceTags | undefined;
413
411
  }
414
- export type ReadPreferenceTags = ReadonlyArray<Record<string, string>>;
412
+ export type ReadPreferenceTags = readonly Record<string, string>[];
415
413
  export type ReadPreferenceMode = 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest';
416
414
  export type ReadPreferenceOrMode = ReadPreference | ReadPreferenceMode;
417
- export type ReadPreferenceOptions = {
415
+ export interface ReadPreferenceOptions {
418
416
  /** Server mode in which the same query is dispatched in parallel to multiple replica set members. */
419
417
  hedge?: {
420
418
  /** Explicitly enable or disable hedged reads. */
@@ -424,7 +422,7 @@ export type ReadPreferenceOptions = {
424
422
  * Max secondary read staleness in seconds, Minimum value is 90 seconds.
425
423
  */
426
424
  maxStalenessSeconds?: number | undefined;
427
- };
425
+ }
428
426
  /**
429
427
  * Optional settings for creating a new Db instance
430
428
  *
@@ -984,9 +982,7 @@ export type WithId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
984
982
  *
985
983
  * @see https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html
986
984
  */
987
- export interface Collection<TSchema extends {
988
- [key: string]: any;
989
- } = DefaultSchema> {
985
+ export interface Collection<TSchema extends Record<string, any> = DefaultSchema> {
990
986
  /**
991
987
  * Get the collection name.
992
988
  */
@@ -1029,9 +1025,9 @@ export interface Collection<TSchema extends {
1029
1025
  * @param callback The command result callback
1030
1026
  * @see https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#bulkWrite
1031
1027
  */
1032
- bulkWrite(operations: Array<BulkWriteOperation<TSchema>>, callback: MongoCallback<BulkWriteOpResultObject>): void;
1033
- bulkWrite(operations: Array<BulkWriteOperation<TSchema>>, options?: CollectionBulkWriteOptions): Promise<BulkWriteOpResultObject>;
1034
- bulkWrite(operations: Array<BulkWriteOperation<TSchema>>, options: CollectionBulkWriteOptions, callback: MongoCallback<BulkWriteOpResultObject>): void;
1028
+ bulkWrite(operations: BulkWriteOperation<TSchema>[], callback: MongoCallback<BulkWriteOpResultObject>): void;
1029
+ bulkWrite(operations: BulkWriteOperation<TSchema>[], options?: CollectionBulkWriteOptions): Promise<BulkWriteOpResultObject>;
1030
+ bulkWrite(operations: BulkWriteOperation<TSchema>[], options: CollectionBulkWriteOptions, callback: MongoCallback<BulkWriteOpResultObject>): void;
1035
1031
  /**
1036
1032
  * An estimated count of matching documents in the db to a query.
1037
1033
  *
@@ -1129,10 +1125,10 @@ export interface Collection<TSchema extends {
1129
1125
  * @returns Promise if no callback is passed
1130
1126
  * @see https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#distinct
1131
1127
  */
1132
- distinct<Key extends keyof WithId<TSchema>>(key: Key, callback: MongoCallback<Array<FlattenIfArray<WithId<Required<TSchema>>[Key]>>>): void;
1133
- distinct<Key extends keyof WithId<TSchema>>(key: Key, query: FilterQuery<TSchema>, callback: MongoCallback<Array<FlattenIfArray<WithId<Required<TSchema>>[Key]>>>): void;
1134
- distinct<Key extends keyof WithId<TSchema>>(key: Key, query?: FilterQuery<TSchema>, options?: MongoDistinctPreferences): Promise<Array<FlattenIfArray<WithId<Required<TSchema>>[Key]>>>;
1135
- distinct<Key extends keyof WithId<TSchema>>(key: Key, query: FilterQuery<TSchema>, options: MongoDistinctPreferences, callback: MongoCallback<Array<FlattenIfArray<WithId<Required<TSchema>>[Key]>>>): void;
1128
+ distinct<Key extends keyof WithId<TSchema>>(key: Key, callback: MongoCallback<FlattenIfArray<WithId<Required<TSchema>>[Key]>[]>): void;
1129
+ distinct<Key extends keyof WithId<TSchema>>(key: Key, query: FilterQuery<TSchema>, callback: MongoCallback<FlattenIfArray<WithId<Required<TSchema>>[Key]>[]>): void;
1130
+ distinct<Key extends keyof WithId<TSchema>>(key: Key, query?: FilterQuery<TSchema>, options?: MongoDistinctPreferences): Promise<FlattenIfArray<WithId<Required<TSchema>>[Key]>[]>;
1131
+ distinct<Key extends keyof WithId<TSchema>>(key: Key, query: FilterQuery<TSchema>, options: MongoDistinctPreferences, callback: MongoCallback<FlattenIfArray<WithId<Required<TSchema>>[Key]>[]>): void;
1136
1132
  distinct(key: string, callback: MongoCallback<any[]>): void;
1137
1133
  distinct(key: string, query: FilterQuery<TSchema>, callback: MongoCallback<any[]>): void;
1138
1134
  distinct(key: string, query?: FilterQuery<TSchema>, options?: MongoDistinctPreferences): Promise<any[]>;
@@ -1385,9 +1381,9 @@ export interface Collection<TSchema extends {
1385
1381
  * @returns Promise if no callback is passed
1386
1382
  * @see https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#insertMany
1387
1383
  */
1388
- insertMany(docs: Array<OptionalId<TSchema>>, callback: MongoCallback<InsertWriteOpResult<WithId<TSchema>>>): void;
1389
- insertMany(docs: Array<OptionalId<TSchema>>, options?: CollectionInsertManyOptions): Promise<InsertWriteOpResult<WithId<TSchema>>>;
1390
- insertMany(docs: Array<OptionalId<TSchema>>, options: CollectionInsertManyOptions, callback: MongoCallback<InsertWriteOpResult<WithId<TSchema>>>): void;
1384
+ insertMany(docs: OptionalId<TSchema>[], callback: MongoCallback<InsertWriteOpResult<WithId<TSchema>>>): void;
1385
+ insertMany(docs: OptionalId<TSchema>[], options?: CollectionInsertManyOptions): Promise<InsertWriteOpResult<WithId<TSchema>>>;
1386
+ insertMany(docs: OptionalId<TSchema>[], options: CollectionInsertManyOptions, callback: MongoCallback<InsertWriteOpResult<WithId<TSchema>>>): void;
1391
1387
  /**
1392
1388
  * Inserts a single document into MongoDB. If documents passed in do not contain the **_id** field,
1393
1389
  * one will be added to each of the documents missing it by the driver, mutating the document. This behavior
@@ -1465,9 +1461,9 @@ export interface Collection<TSchema extends {
1465
1461
  * @returns Promise if no callback is passed
1466
1462
  * @see https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#parallelCollectionScan
1467
1463
  */
1468
- parallelCollectionScan(callback: MongoCallback<Array<Cursor<any>>>): void;
1469
- parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise<Array<Cursor<any>>>;
1470
- parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback<Array<Cursor<any>>>): void;
1464
+ parallelCollectionScan(callback: MongoCallback<Cursor<any>[]>): void;
1465
+ parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise<Cursor<any>[]>;
1466
+ parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback<Cursor<any>[]>): void;
1471
1467
  /**
1472
1468
  * Reindex all indexes on the collection
1473
1469
  * Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
@@ -1623,15 +1619,13 @@ type AcceptedFields<TSchema, FieldType, AssignableType> = {
1623
1619
  type NotAcceptedFields<TSchema, FieldType> = {
1624
1620
  readonly [key in KeysOfOtherType<TSchema, FieldType>]?: never;
1625
1621
  };
1626
- type DotAndArrayNotation<AssignableType> = {
1627
- readonly [key: string]: AssignableType;
1628
- };
1622
+ type DotAndArrayNotation<AssignableType> = Readonly<Record<string, AssignableType>>;
1629
1623
  type ReadonlyPartial<TSchema> = {
1630
1624
  readonly [key in keyof TSchema]?: TSchema[key];
1631
1625
  };
1632
1626
  export type OnlyFieldsOfType<TSchema, FieldType = any, AssignableType = FieldType> = AcceptedFields<TSchema, FieldType, AssignableType> & NotAcceptedFields<TSchema, FieldType> & DotAndArrayNotation<AssignableType>;
1633
1627
  export type MatchKeysAndValues<TSchema> = ReadonlyPartial<TSchema> & DotAndArrayNotation<any>;
1634
- type Unpacked<Type> = Type extends ReadonlyArray<infer Element> ? Element : Type;
1628
+ type Unpacked<Type> = Type extends readonly (infer Element)[] ? Element : Type;
1635
1629
  type UpdateOptionalId<T> = T extends {
1636
1630
  _id?: any;
1637
1631
  } ? OptionalId<T> : T;
@@ -1649,41 +1643,31 @@ export type MetaProjectionOperators = MetaSortOperators
1649
1643
  | 'searchHighlights';
1650
1644
  export type SchemaMember<T, V> = {
1651
1645
  [P in keyof T]?: V;
1652
- } | {
1653
- [key: string]: V;
1654
- };
1646
+ } | Record<string, V>;
1655
1647
  export type SortOptionObject<T> = SchemaMember<T, number | {
1656
1648
  $meta?: MetaSortOperators | undefined;
1657
1649
  }>;
1658
- export type AddToSetOperators<Type> = {
1650
+ export interface AddToSetOperators<Type> {
1659
1651
  $each: Type;
1660
- };
1661
- export type ArrayOperator<Type> = {
1652
+ }
1653
+ export interface ArrayOperator<Type> {
1662
1654
  $each: Type;
1663
1655
  $slice?: number | undefined;
1664
1656
  $position?: number | undefined;
1665
1657
  $sort?: SortValues | Record<string, SortValues> | undefined;
1666
- };
1658
+ }
1667
1659
  export type SetFields<TSchema> = ({
1668
- readonly [key in KeysOfAType<TSchema, ReadonlyArray<any> | undefined>]?: UpdateOptionalId<Unpacked<TSchema[key]>> | AddToSetOperators<Array<UpdateOptionalId<Unpacked<TSchema[key]>>>>;
1669
- } & NotAcceptedFields<TSchema, ReadonlyArray<any> | undefined>) & {
1670
- readonly [key: string]: AddToSetOperators<any> | any;
1671
- };
1660
+ readonly [key in KeysOfAType<TSchema, readonly any[] | undefined>]?: UpdateOptionalId<Unpacked<TSchema[key]>> | AddToSetOperators<UpdateOptionalId<Unpacked<TSchema[key]>>[]>;
1661
+ } & NotAcceptedFields<TSchema, readonly any[] | undefined>) & Readonly<Record<string, AddToSetOperators<any> | any>>;
1672
1662
  export type PushOperator<TSchema> = ({
1673
- readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: Unpacked<TSchema[key]> | ArrayOperator<Array<Unpacked<TSchema[key]>>>;
1674
- } & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
1675
- readonly [key: string]: ArrayOperator<any> | any;
1676
- };
1663
+ readonly [key in KeysOfAType<TSchema, readonly any[]>]?: Unpacked<TSchema[key]> | ArrayOperator<Unpacked<TSchema[key]>[]>;
1664
+ } & NotAcceptedFields<TSchema, readonly any[]>) & Readonly<Record<string, ArrayOperator<any> | any>>;
1677
1665
  export type PullOperator<TSchema> = ({
1678
- readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: Partial<Unpacked<TSchema[key]>> | ObjectQuerySelector<Unpacked<TSchema[key]>>;
1679
- } & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
1680
- readonly [key: string]: QuerySelector<any> | any;
1681
- };
1666
+ readonly [key in KeysOfAType<TSchema, readonly any[]>]?: Partial<Unpacked<TSchema[key]>> | ObjectQuerySelector<Unpacked<TSchema[key]>>;
1667
+ } & NotAcceptedFields<TSchema, readonly any[]>) & Readonly<Record<string, QuerySelector<any> | any>>;
1682
1668
  export type PullAllOperator<TSchema> = ({
1683
- readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: TSchema[key];
1684
- } & NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
1685
- readonly [key: string]: any[];
1686
- };
1669
+ readonly [key in KeysOfAType<TSchema, readonly any[]>]?: TSchema[key];
1670
+ } & NotAcceptedFields<TSchema, readonly any[]>) & Readonly<Record<string, any[]>>;
1687
1671
  /**
1688
1672
  * Modifiers to use in update operations
1689
1673
  * @see https://docs.mongodb.com/v3.6/reference/operator/update
@@ -1709,7 +1693,7 @@ export type PullAllOperator<TSchema> = ({
1709
1693
  * @see https://docs.mongodb.com/v3.6/reference/operator/update-bitwise/
1710
1694
  *
1711
1695
  */
1712
- export type UpdateQuery<TSchema> = {
1696
+ export interface UpdateQuery<TSchema> {
1713
1697
  $currentDate?: OnlyFieldsOfType<TSchema, Date | Timestamp, true | {
1714
1698
  $type: 'date' | 'timestamp';
1715
1699
  }> | undefined;
@@ -1717,23 +1701,19 @@ export type UpdateQuery<TSchema> = {
1717
1701
  $min?: MatchKeysAndValues<TSchema> | undefined;
1718
1702
  $max?: MatchKeysAndValues<TSchema> | undefined;
1719
1703
  $mul?: OnlyFieldsOfType<TSchema, NumericTypes | undefined> | undefined;
1720
- $rename?: {
1721
- [key: string]: string;
1722
- } | undefined;
1704
+ $rename?: Record<string, string> | undefined;
1723
1705
  $set?: MatchKeysAndValues<TSchema> | undefined;
1724
1706
  $setOnInsert?: MatchKeysAndValues<TSchema> | undefined;
1725
1707
  $unset?: OnlyFieldsOfType<TSchema, any, '' | 1 | true> | undefined;
1726
1708
  $addToSet?: SetFields<TSchema> | undefined;
1727
- $pop?: OnlyFieldsOfType<TSchema, ReadonlyArray<any>, 1 | -1> | undefined;
1709
+ $pop?: OnlyFieldsOfType<TSchema, readonly any[], 1 | -1> | undefined;
1728
1710
  $pull?: PullOperator<TSchema> | undefined;
1729
1711
  $push?: PushOperator<TSchema> | undefined;
1730
1712
  $pullAll?: PullAllOperator<TSchema> | undefined;
1731
- $bit?: {
1732
- [key: string]: {
1733
- [key in 'and' | 'or' | 'xor']?: number;
1734
- };
1735
- } | undefined;
1736
- };
1713
+ $bit?: Record<string, {
1714
+ [key in 'and' | 'or' | 'xor']?: number;
1715
+ }> | undefined;
1716
+ }
1737
1717
  /**
1738
1718
  * Available BSON types
1739
1719
  *
@@ -1769,7 +1749,7 @@ type BSONTypeAlias = 'number' | 'double' | 'string' | 'object' | 'array' | 'binD
1769
1749
  /** @see https://docs.mongodb.com/v3.6/reference/operator/query-bitwise */
1770
1750
  type BitwiseQuery = number /** <numeric bitmask> */ | Binary /** <BinData bitmask> */ | number[]; /** [ <position1>, <position2>, ... ] */
1771
1751
  type RegExpForString<T> = T extends string ? RegExp | T : T;
1772
- type MongoAltQuery<T> = T extends ReadonlyArray<infer U> ? T | RegExpForString<U> : RegExpForString<T>;
1752
+ type MongoAltQuery<T> = T extends readonly (infer U)[] ? T | RegExpForString<U> : RegExpForString<T>;
1773
1753
  /**
1774
1754
  * Available query selector types
1775
1755
  *
@@ -1820,7 +1800,7 @@ type MongoAltQuery<T> = T extends ReadonlyArray<infer U> ? T | RegExpForString<U
1820
1800
  *
1821
1801
  * @see https://docs.mongodb.com/v3.6/reference/operator/query/#query-selectors
1822
1802
  */
1823
- export type QuerySelector<T> = {
1803
+ export interface QuerySelector<T> {
1824
1804
  $eq?: T | undefined;
1825
1805
  $gt?: T | undefined;
1826
1806
  $gte?: T | undefined;
@@ -1848,21 +1828,21 @@ export type QuerySelector<T> = {
1848
1828
  $near?: object | undefined;
1849
1829
  $nearSphere?: object | undefined;
1850
1830
  $maxDistance?: number | undefined;
1851
- $all?: T extends ReadonlyArray<infer U> ? U[] : never | undefined;
1852
- $elemMatch?: T extends ReadonlyArray<infer U> ? U : never | undefined;
1853
- $size?: T extends ReadonlyArray<infer U> ? U : never | undefined;
1831
+ $all?: T extends readonly (infer U)[] ? U[] : never | undefined;
1832
+ $elemMatch?: T extends readonly (infer U)[] ? U : never | undefined;
1833
+ $size?: T extends readonly (infer U)[] ? U : never | undefined;
1854
1834
  $bitsAllClear?: BitwiseQuery | undefined;
1855
1835
  $bitsAllSet?: BitwiseQuery | undefined;
1856
1836
  $bitsAnyClear?: BitwiseQuery | undefined;
1857
1837
  $bitsAnySet?: BitwiseQuery | undefined;
1858
- };
1859
- export type RootQuerySelector<T> = {
1838
+ }
1839
+ export interface RootQuerySelector<T> {
1860
1840
  /** @see https://docs.mongodb.com/v3.6/reference/operator/query/and/#op._S_and */
1861
- $and?: Array<FilterQuery<T>> | undefined;
1841
+ $and?: FilterQuery<T>[] | undefined;
1862
1842
  /** @see https://docs.mongodb.com/v3.6/reference/operator/query/nor/#op._S_nor */
1863
- $nor?: Array<FilterQuery<T>> | undefined;
1843
+ $nor?: FilterQuery<T>[] | undefined;
1864
1844
  /** @see https://docs.mongodb.com/v3.6/reference/operator/query/or/#op._S_or */
1865
- $or?: Array<FilterQuery<T>> | undefined;
1845
+ $or?: FilterQuery<T>[] | undefined;
1866
1846
  /** @see https://docs.mongodb.com/v3.6/reference/operator/query/text */
1867
1847
  $text?: {
1868
1848
  $search: string;
@@ -1875,7 +1855,7 @@ export type RootQuerySelector<T> = {
1875
1855
  /** @see https://docs.mongodb.com/v3.6/reference/operator/query/comment/#op._S_comment */
1876
1856
  $comment?: string | undefined;
1877
1857
  [key: string]: any;
1878
- };
1858
+ }
1879
1859
  export type ObjectQuerySelector<T> = T extends object ? {
1880
1860
  [key in keyof T]?: QuerySelector<T[key]>;
1881
1861
  } : QuerySelector<T>;
@@ -1884,12 +1864,12 @@ export type FilterQuery<T> = {
1884
1864
  [P in keyof T]?: Condition<T[P]>;
1885
1865
  } & RootQuerySelector<T>;
1886
1866
  /** @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#insertone */
1887
- export type BulkWriteInsertOneOperation<TSchema> = {
1867
+ export interface BulkWriteInsertOneOperation<TSchema> {
1888
1868
  insertOne: {
1889
1869
  /** @ts-ignore */
1890
1870
  document: OptionalId<TSchema>;
1891
1871
  };
1892
- };
1872
+ }
1893
1873
  /**
1894
1874
  * Options for the updateOne and updateMany operations
1895
1875
  *
@@ -1902,19 +1882,19 @@ export type BulkWriteInsertOneOperation<TSchema> = {
1902
1882
  * For more details see {@link https://docs.mongodb.com/v3.6/reference/method/db.collection.update/#upsert-behavior upsert behavior}
1903
1883
  * @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#updateone-and-updatemany
1904
1884
  */
1905
- export type BulkWriteUpdateOperation<TSchema> = {
1885
+ export interface BulkWriteUpdateOperation<TSchema> {
1906
1886
  arrayFilters?: object[] | undefined;
1907
1887
  collation?: object | undefined;
1908
1888
  filter: FilterQuery<TSchema>;
1909
1889
  update: UpdateQuery<TSchema>;
1910
1890
  upsert?: boolean | undefined;
1911
- };
1912
- export type BulkWriteUpdateOneOperation<TSchema> = {
1891
+ }
1892
+ export interface BulkWriteUpdateOneOperation<TSchema> {
1913
1893
  updateOne: BulkWriteUpdateOperation<TSchema>;
1914
- };
1915
- export type BulkWriteUpdateManyOperation<TSchema> = {
1894
+ }
1895
+ export interface BulkWriteUpdateManyOperation<TSchema> {
1916
1896
  updateMany: BulkWriteUpdateOperation<TSchema>;
1917
- };
1897
+ }
1918
1898
  /**
1919
1899
  * Options for the replaceOne operation
1920
1900
  *
@@ -1927,14 +1907,14 @@ export type BulkWriteUpdateManyOperation<TSchema> = {
1927
1907
  * For more details see {@link https://docs.mongodb.com/v3.6/reference/method/db.collection.update/#upsert-behavior upsert behavior}
1928
1908
  * @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#replaceone
1929
1909
  */
1930
- export type BulkWriteReplaceOneOperation<TSchema> = {
1910
+ export interface BulkWriteReplaceOneOperation<TSchema> {
1931
1911
  replaceOne: {
1932
1912
  collation?: object | undefined;
1933
1913
  filter: FilterQuery<TSchema>;
1934
1914
  replacement: TSchema;
1935
1915
  upsert?: boolean | undefined;
1936
1916
  };
1937
- };
1917
+ }
1938
1918
  /**
1939
1919
  * Options for the deleteOne and deleteMany operations
1940
1920
  *
@@ -1942,16 +1922,16 @@ export type BulkWriteReplaceOneOperation<TSchema> = {
1942
1922
  * @param filter Specifies deletion criteria using {@link https://docs.mongodb.com/v3.6/reference/operator/ query operators}.
1943
1923
  * @see https://docs.mongodb.com/v3.6/reference/method/db.collection.bulkWrite/#deleteone-and-deletemany
1944
1924
  */
1945
- export type BulkWriteDeleteOperation<TSchema> = {
1925
+ export interface BulkWriteDeleteOperation<TSchema> {
1946
1926
  collation?: object | undefined;
1947
1927
  filter: FilterQuery<TSchema>;
1948
- };
1949
- export type BulkWriteDeleteOneOperation<TSchema> = {
1928
+ }
1929
+ export interface BulkWriteDeleteOneOperation<TSchema> {
1950
1930
  deleteOne: BulkWriteDeleteOperation<TSchema>;
1951
- };
1952
- export type BulkWriteDeleteManyOperation<TSchema> = {
1931
+ }
1932
+ export interface BulkWriteDeleteManyOperation<TSchema> {
1953
1933
  deleteMany: BulkWriteDeleteOperation<TSchema>;
1954
- };
1934
+ }
1955
1935
  /**
1956
1936
  * Possible operations with the Collection.bulkWrite method
1957
1937
  *
@@ -2264,12 +2244,8 @@ export interface BulkWriteOpResultObject {
2264
2244
  modifiedCount?: number | undefined;
2265
2245
  deletedCount?: number | undefined;
2266
2246
  upsertedCount?: number | undefined;
2267
- insertedIds?: {
2268
- [index: number]: any;
2269
- } | undefined;
2270
- upsertedIds?: {
2271
- [index: number]: any;
2272
- } | undefined;
2247
+ insertedIds?: Record<number, any> | undefined;
2248
+ upsertedIds?: Record<number, any> | undefined;
2273
2249
  result?: any;
2274
2250
  }
2275
2251
  /**
@@ -2686,7 +2662,7 @@ export interface UnorderedBulkOperation {
2686
2662
  */
2687
2663
  export interface FindOneOptions<T> {
2688
2664
  limit?: number | undefined;
2689
- sort?: Array<[string, number]> | SortOptionObject<T> | undefined;
2665
+ sort?: [string, number][] | SortOptionObject<T> | undefined;
2690
2666
  projection?: SchemaMember<T, ProjectionOperators | number | boolean | any> | undefined;
2691
2667
  /**
2692
2668
  * @deprecated Use options.projection instead
@@ -2747,9 +2723,7 @@ export interface InsertWriteOpResult<TSchema extends {
2747
2723
  }> {
2748
2724
  insertedCount: number;
2749
2725
  ops: TSchema[];
2750
- insertedIds: {
2751
- [key: number]: TSchema['_id'];
2752
- };
2726
+ insertedIds: Record<number, TSchema['_id']>;
2753
2727
  connection: any;
2754
2728
  result: {
2755
2729
  ok: number;
@@ -2894,18 +2868,14 @@ export interface CursorCommentOptions {
2894
2868
  * @param doc An emitted document for the iterator
2895
2869
  * @see https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#~iteratorCallback
2896
2870
  */
2897
- export interface IteratorCallback<T> {
2898
- (doc: T): void;
2899
- }
2871
+ export type IteratorCallback<T> = (doc: T) => void;
2900
2872
  /**
2901
2873
  * The callback error format for the forEach iterator method
2902
2874
  *
2903
2875
  * @param error An error instance representing the error during the execution.
2904
2876
  * @see https://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#~endCallback
2905
2877
  */
2906
- export interface EndCallback {
2907
- (error: MongoError): void;
2908
- }
2878
+ export type EndCallback = (error: MongoError) => void;
2909
2879
  /**
2910
2880
  * Returning object for the AggregationCursor result callback
2911
2881
  *
@@ -2992,9 +2962,7 @@ export interface GridFSBucketWriteStreamOptions extends WriteConcern {
2992
2962
  disableMD5?: boolean | undefined;
2993
2963
  }
2994
2964
  export type ChangeEventTypes = 'insert' | 'delete' | 'replace' | 'update' | 'drop' | 'rename' | 'dropDatabase' | 'invalidate';
2995
- export interface ChangeEventBase<TSchema extends {
2996
- [key: string]: any;
2997
- } = DefaultSchema> {
2965
+ export interface ChangeEventBase<TSchema extends Record<string, any> = DefaultSchema> {
2998
2966
  _id: ResumeToken;
2999
2967
  /**
3000
2968
  * We leave this off the base type so that we can differentiate
@@ -3011,21 +2979,15 @@ export interface ChangeEventBase<TSchema extends {
3011
2979
  uid: any;
3012
2980
  } | undefined;
3013
2981
  }
3014
- export interface ChangeEventCR<TSchema extends {
3015
- [key: string]: any;
3016
- } = DefaultSchema> extends ChangeEventBase<TSchema> {
2982
+ export interface ChangeEventCR<TSchema extends Record<string, any> = DefaultSchema> extends ChangeEventBase<TSchema> {
3017
2983
  operationType: 'insert' | 'replace';
3018
2984
  fullDocument?: TSchema | undefined;
3019
2985
  documentKey: {
3020
2986
  _id: ExtractIdType<TSchema>;
3021
2987
  };
3022
2988
  }
3023
- type FieldUpdates<TSchema> = Partial<TSchema> & {
3024
- [key: string]: any;
3025
- };
3026
- export interface ChangeEventUpdate<TSchema extends {
3027
- [key: string]: any;
3028
- } = DefaultSchema> extends ChangeEventBase<TSchema> {
2989
+ type FieldUpdates<TSchema> = Partial<TSchema> & Record<string, any>;
2990
+ export interface ChangeEventUpdate<TSchema extends Record<string, any> = DefaultSchema> extends ChangeEventBase<TSchema> {
3029
2991
  operationType: 'update';
3030
2992
  updateDescription: {
3031
2993
  /**
@@ -3033,38 +2995,30 @@ export interface ChangeEventUpdate<TSchema extends {
3033
2995
  * the keys will be paths, e.g. 'question.answer.0.text': 'new text'
3034
2996
  */
3035
2997
  updatedFields: FieldUpdates<TSchema>;
3036
- removedFields: Array<keyof TSchema | string>;
2998
+ removedFields: (keyof TSchema | string)[];
3037
2999
  };
3038
3000
  fullDocument?: TSchema | undefined;
3039
3001
  documentKey: {
3040
3002
  _id: ExtractIdType<TSchema>;
3041
3003
  };
3042
3004
  }
3043
- export interface ChangeEventDelete<TSchema extends {
3044
- [key: string]: any;
3045
- } = DefaultSchema> extends ChangeEventBase<TSchema> {
3005
+ export interface ChangeEventDelete<TSchema extends Record<string, any> = DefaultSchema> extends ChangeEventBase<TSchema> {
3046
3006
  operationType: 'delete';
3047
3007
  documentKey: {
3048
3008
  _id: ExtractIdType<TSchema>;
3049
3009
  };
3050
3010
  }
3051
- export interface ChangeEventRename<TSchema extends {
3052
- [key: string]: any;
3053
- } = DefaultSchema> extends ChangeEventBase<TSchema> {
3011
+ export interface ChangeEventRename<TSchema extends Record<string, any> = DefaultSchema> extends ChangeEventBase<TSchema> {
3054
3012
  operationType: 'rename';
3055
3013
  to: {
3056
3014
  db: string;
3057
3015
  coll: string;
3058
3016
  };
3059
3017
  }
3060
- export interface ChangeEventOther<TSchema extends {
3061
- [key: string]: any;
3062
- } = DefaultSchema> extends ChangeEventBase<TSchema> {
3018
+ export interface ChangeEventOther<TSchema extends Record<string, any> = DefaultSchema> extends ChangeEventBase<TSchema> {
3063
3019
  operationType: 'drop' | 'dropDatabase';
3064
3020
  }
3065
- export interface ChangeEventInvalidate<TSchema extends {
3066
- [key: string]: any;
3067
- } = DefaultSchema> {
3021
+ export interface ChangeEventInvalidate<TSchema extends Record<string, any> = DefaultSchema> {
3068
3022
  _id: ResumeToken;
3069
3023
  operationType: 'invalidate';
3070
3024
  clusterTime: Timestamp;
@@ -3097,9 +3051,9 @@ export interface LoggerOptions {
3097
3051
  /**
3098
3052
  * Override default global log level.
3099
3053
  */
3100
- logger?: log | undefined;
3054
+ logger?: Log | undefined;
3101
3055
  }
3102
- export type log = (message?: string, state?: LoggerState) => void;
3056
+ export type Log = (message?: string, state?: LoggerState) => void;
3103
3057
  export interface LoggerState {
3104
3058
  type: string;
3105
3059
  message: string;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/ban-types */
3
2
  /// <reference types="node" />
4
3
  /// <reference lib="esnext.asynciterable" />
5
4
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
1
  import AbstractSpruceError from '@sprucelabs/error';
2
- import ErrorOptions from "./../.spruce/errors/options.types";
2
+ import ErrorOptions from './../.spruce/errors/options.types';
3
3
  export default class SpruceError extends AbstractSpruceError<ErrorOptions> {
4
4
  friendlyMessage(): string;
5
5
  }
@@ -54,13 +54,17 @@ class SpruceError extends error_1.default {
54
54
  case 'FAILED_TO_LOAD_STORE':
55
55
  message = `Dang it, I couldn't load your ${options.name} store!`;
56
56
  if (options.originalError) {
57
- message += '\n\nOriginal error:\n\n' + options.originalError.message;
57
+ message +=
58
+ '\n\nOriginal error:\n\n' +
59
+ options.originalError.message;
58
60
  }
59
61
  break;
60
62
  case 'INVALID_DB_CONNECTION_STRING':
61
63
  message = 'The database connection string you sent is no good!';
62
64
  if (options.originalError) {
63
- message += '\n\nOriginal error:\n\n' + options.originalError.message;
65
+ message +=
66
+ '\n\nOriginal error:\n\n' +
67
+ options.originalError.message;
64
68
  }
65
69
  break;
66
70
  case 'UNKNOWN_DATABASE_ERROR':
@@ -6,7 +6,7 @@ exports.default = (0, schema_1.buildErrorSchema)({
6
6
  name: 'failed to load stores',
7
7
  importsWhenLocal: [
8
8
  "import AbstractSpruceError from '@sprucelabs/error'",
9
- "import { FailedToLoadStoreErrorOptions } from "./../.spruce/errors/options.types"",
9
+ "import { FailedToLoadStoreErrorOptions } from '#spruce/errors/options.types'",
10
10
  ],
11
11
  fields: {
12
12
  errors: {
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable no-unused-vars */
4
- /* eslint-disable @typescript-eslint/no-unused-vars */
5
3
  const schema_1 = require("@sprucelabs/schema");
6
4
  //@ts-ignore
7
5
  exports.default = (0, schema_1.buildErrorSchema)({
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable @typescript-eslint/no-unused-vars */
4
- /* eslint-disable no-unused-vars */
5
3
  const schema_1 = require("@sprucelabs/schema");
6
4
  //@ts-ignore
7
5
  exports.default = (0, schema_1.buildErrorSchema)({