wingbot-mongodb 4.2.7 → 4.2.9

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/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "wingbot-mongodb",
3
- "version": "4.2.7",
3
+ "version": "4.2.9",
4
4
  "description": "MongoDB storage for wingbot.ai",
5
5
  "main": "src/main.js",
6
+ "types": "types/main.d.ts",
6
7
  "scripts": {
7
8
  "test": "npm run test:lint && npm run test:coverage && npm run test:coverage:threshold",
8
9
  "test:unit": "mocha ./test/**/*.js",
@@ -11,7 +12,9 @@
11
12
  "test:coverage": "nyc --reporter=html mocha ./test && nyc report",
12
13
  "test:coverage:threshold": "nyc check-coverage --lines 80 --functions 73 --branches 75",
13
14
  "test:lint": "eslint ./src/**/*.js ./bin/**/*.js ./test/**/*.js ",
14
- "doc": "node ./bin/makeApiDoc.js"
15
+ "doc": "node ./bin/makeApiDoc.js",
16
+ "build": "tsc",
17
+ "prepublishOnly": "npm run build"
15
18
  },
16
19
  "repository": {
17
20
  "type": "git",
@@ -34,6 +37,7 @@
34
37
  },
35
38
  "homepage": "https://github.com/wingbotai/wingbot-mongodb#readme",
36
39
  "devDependencies": {
40
+ "@types/jsonwebtoken": "^9.0.10",
37
41
  "cross-env": "^7.0.3",
38
42
  "eslint": "^8.28.0",
39
43
  "eslint-config-airbnb": "^19.0.4",
@@ -47,6 +51,7 @@
47
51
  "mocha": "^10.1.0",
48
52
  "mongodb": "^6.1.0",
49
53
  "nyc": "^15.1.0",
54
+ "typescript": "^5.9.3",
50
55
  "wingbot": "^3.46.3"
51
56
  },
52
57
  "peerDependencies": {
@@ -3,8 +3,14 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
+ /**
7
+ * @typedef {object} StoredAttachment
8
+ * @prop {string} _id
9
+ * @prop {number} attachmentId
10
+ */
11
+
6
12
  /** @typedef {import('mongodb').Db} Db */
7
- /** @typedef {import('mongodb').Collection} Collection */
13
+ /** @typedef {import('mongodb').Collection<StoredAttachment>} Collection */
8
14
 
9
15
  /**
10
16
  * Cache storage for Facebook attachments
@@ -69,7 +75,7 @@ class AttachmentCache {
69
75
  async saveAttachmentId (url, attachmentId) {
70
76
  const c = await this._getCollection();
71
77
 
72
- await c.replaceOne({ _id: url }, { _id: url, attachmentId }, { upsert: true });
78
+ await c.replaceOne({ _id: url }, { attachmentId }, { upsert: true });
73
79
  }
74
80
 
75
81
  }
@@ -13,6 +13,17 @@ const getNestedObjects = require('./getNestedObjects');
13
13
  /** @typedef {import('mongodb').Document} Document */
14
14
  /** @typedef {import('mongodb').CreateIndexesOptions} CreateIndexesOptions */
15
15
 
16
+ /**
17
+ * @template T=ObjectId
18
+ * @typedef {object} CustomIdentifier
19
+ * @prop {T} _id
20
+ */
21
+
22
+ /**
23
+ * @template {object} T
24
+ * @typedef {T & CustomIdentifier<ObjectId>} WithId
25
+ */
26
+
16
27
  /**
17
28
  *
18
29
  * @template T
@@ -92,7 +103,7 @@ class BaseStorage {
92
103
  this._log = log;
93
104
 
94
105
  // eslint-disable-next-line max-len
95
- /** @type {import('mongodb').Collection<wingbotmongodb.WithId<T>>|Promise<import('mongodb').Collection<wingbotmongodb.WithId<T>>>} */
106
+ /** @type {import('mongodb').Collection<WithId<T>>|Promise<import('mongodb').Collection<WithId<T>>>} */
96
107
  this._collection = null;
97
108
 
98
109
  this._indexes = [];
@@ -165,14 +176,18 @@ class BaseStorage {
165
176
  return e;
166
177
  }
167
178
 
179
+ /**
180
+ *
181
+ * @returns {Promise<import('mongodb').Collection<WithId<T>>>}
182
+ */
168
183
  preHeat () {
169
- return this._getCollection();
184
+ return this._getCollection(false, true);
170
185
  }
171
186
 
172
187
  /**
173
188
  * Insert defalt document to DB
174
189
  *
175
- * @param {...T} objects
190
+ * @param {...WithId<T>} objects
176
191
  */
177
192
  addFixtureDoc (...objects) {
178
193
  this._fixtures.push(...objects);
@@ -227,14 +242,14 @@ class BaseStorage {
227
242
  /**
228
243
  *
229
244
  * @param {string} name
230
- * @returns {Promise<import('mongodb').Collection<wingbotmongodb.WithId<T>>>}
245
+ * @returns {Promise<import('mongodb').Collection<WithId<T>>>}
231
246
  */
232
247
  async _getOrCreateCollection (name) {
233
248
  const db = typeof this._mongoDb === 'function'
234
249
  ? await this._mongoDb()
235
250
  : this._mongoDb;
236
251
 
237
- /** @type {import('mongodb').Collection<wingbotmongodb.WithId<T>>} */
252
+ /** @type {import('mongodb').Collection<WithId<T>>} */
238
253
  let collection;
239
254
 
240
255
  if (this._isCosmo) {
@@ -280,9 +295,10 @@ class BaseStorage {
280
295
  *
281
296
  * @protected
282
297
  * @param {boolean} [forRead]
283
- * @returns {Promise<import('mongodb').Collection<wingbotmongodb.WithId<T>>>}
298
+ * @param {boolean} [forceIndexAwait=false]
299
+ * @returns {Promise<import('mongodb').Collection<WithId<T>>>}
284
300
  */
285
- async _getCollection (forRead = false) {
301
+ async _getCollection (forRead = false, forceIndexAwait = false) {
286
302
  if (this._collection === null) {
287
303
  let c;
288
304
  try {
@@ -296,9 +312,11 @@ class BaseStorage {
296
312
  }
297
313
  }
298
314
 
315
+ const requiresIndexAwait = this._shouldWaitForIndex
316
+ && (!forRead || this._shouldIndexBeforeRead);
317
+
299
318
  if (this._indexing
300
- && this._shouldWaitForIndex
301
- && (!forRead || this._shouldIndexBeforeRead)) {
319
+ && (requiresIndexAwait || forceIndexAwait)) {
302
320
 
303
321
  const err = await this._indexing;
304
322
  this._indexing = false;
@@ -311,7 +329,7 @@ class BaseStorage {
311
329
  /**
312
330
  *
313
331
  * @param {object[]} indexes
314
- * @param {import('mongodb').Collection<wingbotmongodb.WithId<T>>} collection
332
+ * @param {import('mongodb').Collection<WithId<T>>} collection
315
333
  * @returns {Promise}
316
334
  */
317
335
  async _ensureIndexes (indexes, collection) {
@@ -11,8 +11,10 @@ try {
11
11
  // noop
12
12
  }
13
13
 
14
+ /** @typedef {{ [key: string]: any } & { _id: string }} BaseConfig */
15
+
14
16
  /** @typedef {import('mongodb').Db} Db */
15
- /** @typedef {import('mongodb').Collection} Collection */
17
+ /** @typedef {import('mongodb').Collection<BaseConfig>} Collection */
16
18
 
17
19
  const CONFIG_ID = 'config';
18
20
 
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "declaration": true,
5
+ "emitDeclarationOnly": true,
6
+ "outDir": "types",
7
+ "checkJs": true,
8
+ "strict": false, // Temporarily disable strict mode
9
+ "skipLibCheck": true, // Skip type checking for declaration files
10
+ "noImplicitAny": false, // Allow implicit 'any' types
11
+ "esModuleInterop": true, // Ensure compatibility with CommonJS modules
12
+ "resolveJsonModule": true // Allow importing JSON modules
13
+ },
14
+ "include": ["src/**/*.js"],
15
+ "typeRoots": ["./types", "./node_modules/@types"] // Include custom types
16
+ }
@@ -0,0 +1,55 @@
1
+ export = AttachmentCache;
2
+ /**
3
+ * @typedef {object} StoredAttachment
4
+ * @prop {string} _id
5
+ * @prop {number} attachmentId
6
+ */
7
+ /** @typedef {import('mongodb').Db} Db */
8
+ /** @typedef {import('mongodb').Collection<StoredAttachment>} Collection */
9
+ /**
10
+ * Cache storage for Facebook attachments
11
+ *
12
+ * @class
13
+ */
14
+ declare class AttachmentCache {
15
+ /**
16
+ *
17
+ * @param {Db|{():Promise<Db>}} mongoDb
18
+ * @param {string} collectionName
19
+ */
20
+ constructor(mongoDb: Db | {
21
+ (): Promise<Db>;
22
+ }, collectionName?: string);
23
+ _mongoDb: import("mongodb").Db | (() => Promise<Db>);
24
+ _collectionName: string;
25
+ /**
26
+ * @type {Collection}
27
+ */
28
+ _collection: Collection;
29
+ /**
30
+ * @returns {Promise<Collection>}
31
+ */
32
+ _getCollection(): Promise<Collection>;
33
+ /**
34
+ *
35
+ * @param {string} url
36
+ * @returns {Promise<number|null>}
37
+ */
38
+ findAttachmentByUrl(url: string): Promise<number | null>;
39
+ /**
40
+ *
41
+ * @param {string} url
42
+ * @param {number} attachmentId
43
+ * @returns {Promise}
44
+ */
45
+ saveAttachmentId(url: string, attachmentId: number): Promise<any>;
46
+ }
47
+ declare namespace AttachmentCache {
48
+ export { StoredAttachment, Db, Collection };
49
+ }
50
+ type StoredAttachment = {
51
+ _id: string;
52
+ attachmentId: number;
53
+ };
54
+ type Db = import("mongodb").Db;
55
+ type Collection = import("mongodb").Collection<StoredAttachment>;
@@ -0,0 +1,231 @@
1
+ export = AuditLogStorage;
2
+ /**
3
+ * @typedef {object} TrackingEvent
4
+ * @prop {string} [type='audit']
5
+ * @prop {string} category
6
+ * @prop {string} action
7
+ * @prop {string} [label]
8
+ * @prop {object} [payload]
9
+ */
10
+ /**
11
+ * @typedef {object} User
12
+ * @prop {string} [id]
13
+ * @prop {string} [senderId]
14
+ * @prop {string} [pageId]
15
+ * @prop {string} [jwt] - jwt to check the authorship
16
+ */
17
+ /**
18
+ * @typedef {object} Meta
19
+ * @prop {string} [ip]
20
+ * @prop {string} [ua]
21
+ * @prop {string} [ro] - referrer || origin
22
+ */
23
+ /**
24
+ * @typedef {object} LogEntry
25
+ * @prop {string} date - ISO date
26
+ * @prop {number} delta - time skew in ms if there was a write conflict
27
+ * @prop {string} [eventType='audit']
28
+ * @prop {string} category
29
+ * @prop {string} action
30
+ * @prop {string} [label]
31
+ * @prop {object} [payload]
32
+ * @prop {string} level - (Critical|Important|Debug)
33
+ * @prop {boolean} ok - signature matches
34
+ * @prop {number} seq - sequence number
35
+ * @prop {string} type - (Error|Warn|Info)
36
+ * @prop {User} user
37
+ * @prop {string} wid - workspace id
38
+ * @prop {Meta} meta
39
+ */
40
+ /**
41
+ * JWT Verifier
42
+ *
43
+ * @callback JwtVerifier
44
+ * @param {string} token
45
+ * @param {string} userId
46
+ * @param {User} [user]
47
+ * @returns {Promise<boolean>}
48
+ */
49
+ /**
50
+ * @typedef {object} AuditLogEntry
51
+ * @prop {string} date - ISO date
52
+ * @prop {string} [eventType='audit']
53
+ * @prop {string} category
54
+ * @prop {string} action
55
+ * @prop {string} [label]
56
+ * @prop {object} [payload]
57
+ * @prop {string} level - (Critical|Important|Debug)
58
+ * @prop {string} type - (Error|Warn|Info)
59
+ * @prop {User} user
60
+ * @prop {string} wid - workspace id
61
+ * @prop {Meta} meta
62
+ */
63
+ /**
64
+ * Audit Log Callback
65
+ *
66
+ * @callback AuditLogCallback
67
+ * @param {AuditLogEntry} entry
68
+ * @returns {Promise}
69
+ */
70
+ /** @typedef {import('mongodb').Db} Db */
71
+ /** @typedef {import('mongodb').Collection} Collection */
72
+ /**
73
+ * Storage for audit logs with signatures chain
74
+ */
75
+ declare class AuditLogStorage extends BaseStorage<any> {
76
+ /**
77
+ *
78
+ * @param {Db|{():Promise<Db>}} mongoDb
79
+ * @param {string} collectionName
80
+ * @param {{error:Function,log:Function}} [log] - console like logger
81
+ * @param {boolean} [isCosmo]
82
+ * @param {string|Promise<string>} [secret]
83
+ * @param {string|Promise<string>} [jwtVerifier]
84
+ */
85
+ constructor(mongoDb: Db | {
86
+ (): Promise<Db>;
87
+ }, collectionName?: string, log?: {
88
+ error: Function;
89
+ log: Function;
90
+ }, isCosmo?: boolean, secret?: string | Promise<string>, jwtVerifier?: string | Promise<string>);
91
+ defaultWid: string;
92
+ muteErrors: boolean;
93
+ maxRetries: number;
94
+ _secret: string | Promise<string>;
95
+ LEVEL_CRITICAL: string;
96
+ LEVEL_IMPORTANT: string;
97
+ LEVEL_DEBUG: string;
98
+ TYPE_ERROR: string;
99
+ TYPE_WARN: string;
100
+ TYPE_INFO: string;
101
+ /**
102
+ * @type {JwtVerifier}
103
+ */
104
+ _jwtVerify: JwtVerifier;
105
+ /** @type {AuditLogCallback} */
106
+ callback: AuditLogCallback;
107
+ /**
108
+ * Add a log
109
+ *
110
+ * @param {TrackingEvent} event
111
+ * @param {User} user
112
+ * @param {Meta} [meta]
113
+ * @param {string} [wid] - workspace ID
114
+ * @param {string} [type]
115
+ * @param {string} [level]
116
+ * @param {Date} [date]
117
+ * @returns {Promise}
118
+ */
119
+ log(event: TrackingEvent, user?: User, meta?: Meta, wid?: string, type?: string, level?: string, date?: Date): Promise<any>;
120
+ /**
121
+ *
122
+ * @param {string} [wid] - workspace id
123
+ * @param {number} [fromSeq] - for paging
124
+ * @param {number} [limit]
125
+ * @returns {Promise<LogEntry[]>}
126
+ */
127
+ list(wid?: string, fromSeq?: number, limit?: number): Promise<LogEntry[]>;
128
+ _wait(ms: any): Promise<any>;
129
+ _storeWithRetry(secret: any, entry: any, delta?: number, i?: number): any;
130
+ _store(entry: any, secret: any): Promise<void>;
131
+ }
132
+ declare namespace AuditLogStorage {
133
+ export { TrackingEvent, User, Meta, LogEntry, JwtVerifier, AuditLogEntry, AuditLogCallback, Db, Collection };
134
+ }
135
+ import BaseStorage = require("./BaseStorage");
136
+ type TrackingEvent = {
137
+ type?: string;
138
+ category: string;
139
+ action: string;
140
+ label?: string;
141
+ payload?: object;
142
+ };
143
+ type User = {
144
+ id?: string;
145
+ senderId?: string;
146
+ pageId?: string;
147
+ /**
148
+ * - jwt to check the authorship
149
+ */
150
+ jwt?: string;
151
+ };
152
+ type Meta = {
153
+ ip?: string;
154
+ ua?: string;
155
+ /**
156
+ * - referrer || origin
157
+ */
158
+ ro?: string;
159
+ };
160
+ type LogEntry = {
161
+ /**
162
+ * - ISO date
163
+ */
164
+ date: string;
165
+ /**
166
+ * - time skew in ms if there was a write conflict
167
+ */
168
+ delta: number;
169
+ eventType?: string;
170
+ category: string;
171
+ action: string;
172
+ label?: string;
173
+ payload?: object;
174
+ /**
175
+ * - (Critical|Important|Debug)
176
+ */
177
+ level: string;
178
+ /**
179
+ * - signature matches
180
+ */
181
+ ok: boolean;
182
+ /**
183
+ * - sequence number
184
+ */
185
+ seq: number;
186
+ /**
187
+ * - (Error|Warn|Info)
188
+ */
189
+ type: string;
190
+ user: User;
191
+ /**
192
+ * - workspace id
193
+ */
194
+ wid: string;
195
+ meta: Meta;
196
+ };
197
+ /**
198
+ * JWT Verifier
199
+ */
200
+ type JwtVerifier = (token: string, userId: string, user?: User) => Promise<boolean>;
201
+ type AuditLogEntry = {
202
+ /**
203
+ * - ISO date
204
+ */
205
+ date: string;
206
+ eventType?: string;
207
+ category: string;
208
+ action: string;
209
+ label?: string;
210
+ payload?: object;
211
+ /**
212
+ * - (Critical|Important|Debug)
213
+ */
214
+ level: string;
215
+ /**
216
+ * - (Error|Warn|Info)
217
+ */
218
+ type: string;
219
+ user: User;
220
+ /**
221
+ * - workspace id
222
+ */
223
+ wid: string;
224
+ meta: Meta;
225
+ };
226
+ /**
227
+ * Audit Log Callback
228
+ */
229
+ type AuditLogCallback = (entry: AuditLogEntry) => Promise<any>;
230
+ type Db = import("mongodb").Db;
231
+ type Collection = import("mongodb").Collection;
@@ -0,0 +1,189 @@
1
+ export = BaseStorage;
2
+ /**
3
+ * @template T={} {Document}
4
+ */
5
+ declare class BaseStorage<T> {
6
+ static netFailuresIntervalMs: number;
7
+ static netFailuresCount: number;
8
+ static _killing: any;
9
+ static _failStack: any[];
10
+ static killer: () => NodeJS.Timeout;
11
+ static networkFailureErrorNames: string[];
12
+ /**
13
+ *
14
+ * @param {Db|{():Promise<Db>}} mongoDb
15
+ * @param {string} collectionName
16
+ * @param {{error:Function,log:Function}} [log] - console like logger
17
+ * @param {boolean|number} [isCosmo]
18
+ * @example
19
+ *
20
+ * const { BaseStorage } = require('winbot-mongodb');
21
+ *
22
+ * class MyCoolDataStorage extends BaseStorage {
23
+ *
24
+ * constructor (mongoDb, collectionName, log = undefined, isCosmo = false) {
25
+ * super(mongoDb, collectionName, log, isCosmo);
26
+ *
27
+ * this.addIndex({
28
+ * foo: -1
29
+ * }, {
30
+ * name: 'foo_1'
31
+ * });
32
+ *
33
+ * this.addIndex({
34
+ * bar: -1,
35
+ * baz: 1
36
+ * }, {
37
+ * name: 'bar_-1_baz_1'
38
+ * });
39
+ * }
40
+ *
41
+ * }
42
+ */
43
+ constructor(mongoDb: Db | {
44
+ (): Promise<Db>;
45
+ }, collectionName: string, log?: {
46
+ error: Function;
47
+ log: Function;
48
+ }, isCosmo?: boolean | number);
49
+ _mongoDb: import("mongodb").Db | (() => Promise<Db>);
50
+ _collectionName: string;
51
+ _isCosmo: boolean;
52
+ _log: {
53
+ error: Function;
54
+ log: Function;
55
+ };
56
+ /** @type {import('mongodb').Collection<WithId<T>>|Promise<import('mongodb').Collection<WithId<T>>>} */
57
+ _collection: import("mongodb").Collection<WithId<T>> | Promise<import("mongodb").Collection<WithId<T>>>;
58
+ _indexes: any[];
59
+ ignoredSignatureKeys: string[];
60
+ _secret: any;
61
+ systemIndexes: string[];
62
+ _fixtures: any[];
63
+ _uniqueIndexFailed: boolean;
64
+ _indexing: any;
65
+ _shouldIndexBeforeRead: boolean;
66
+ _shouldWaitForIndex: boolean;
67
+ /**
68
+ *
69
+ * @template T
70
+ * @param {{():T}} fn
71
+ * @returns {Promise<T>}
72
+ */
73
+ _catchNetworkIssues<T_1>(fn: {
74
+ (): T_1;
75
+ }): Promise<T_1>;
76
+ /**
77
+ * @template {Error} T
78
+ * @param {T} e
79
+ * @returns {T}
80
+ */
81
+ _detectNetworkIssueException<T_1 extends Error>(e: T_1): T_1;
82
+ /**
83
+ *
84
+ * @returns {Promise<import('mongodb').Collection<WithId<T>>>}
85
+ */
86
+ preHeat(): Promise<import("mongodb").Collection<WithId<T>>>;
87
+ /**
88
+ * Insert defalt document to DB
89
+ *
90
+ * @param {...WithId<T>} objects
91
+ */
92
+ addFixtureDoc(...objects: WithId<T>[]): void;
93
+ /**
94
+ * Add custom indexing rule
95
+ *
96
+ * @param {object} index
97
+ * @param {CreateIndexesOptions} options
98
+ */
99
+ addIndex(index: object, options: CreateIndexesOptions): void;
100
+ /**
101
+ * @example
102
+ * {
103
+ * _id: ObjectId.isValid(id) ? new ObjectId(input) : input
104
+ * }
105
+ *
106
+ * @protected
107
+ * @param {string} id
108
+ * @returns {string|ObjectId}
109
+ */
110
+ protected _id(id: string): string | ObjectId;
111
+ /**
112
+ *
113
+ * @param {string|null} attr
114
+ * @param {{[key: string]: any}} obj
115
+ * @param {boolean} [nested]
116
+ * @returns {{[key: string]: any}}
117
+ */
118
+ _expandObjectToSet(attr: string | null, obj: {
119
+ [key: string]: any;
120
+ }, nested?: boolean): {
121
+ [key: string]: any;
122
+ };
123
+ /**
124
+ *
125
+ * @param {string} name
126
+ * @returns {Promise<import('mongodb').Collection<WithId<T>>>}
127
+ */
128
+ _getOrCreateCollection(name: string): Promise<import("mongodb").Collection<WithId<T>>>;
129
+ /**
130
+ * Returns the collection to operate with
131
+ *
132
+ * @protected
133
+ * @param {boolean} [forRead]
134
+ * @param {boolean} [forceIndexAwait=false]
135
+ * @returns {Promise<import('mongodb').Collection<WithId<T>>>}
136
+ */
137
+ protected _getCollection(forRead?: boolean, forceIndexAwait?: boolean): Promise<import("mongodb").Collection<WithId<T>>>;
138
+ /**
139
+ *
140
+ * @param {object[]} indexes
141
+ * @param {import('mongodb').Collection<WithId<T>>} collection
142
+ * @returns {Promise}
143
+ */
144
+ _ensureIndexes(indexes: object[], collection: import("mongodb").Collection<WithId<T>>): Promise<any>;
145
+ _checkExistingIndexes(collection: any): Promise<any>;
146
+ _checkFixtures(collection: any): Promise<any[]>;
147
+ /**
148
+ *
149
+ * @template T
150
+ * @protected
151
+ * @param {T} object
152
+ * @returns {Promise<T>}
153
+ */
154
+ protected _sign<T_1>(object: T_1): Promise<T_1>;
155
+ /**
156
+ *
157
+ * @protected
158
+ * @template T
159
+ * @param {T} object
160
+ * @returns {T}
161
+ */
162
+ protected _objectToSign<T_1>(object: T_1): T_1;
163
+ /**
164
+ *
165
+ * @template T
166
+ * @param {T} objToSign
167
+ * @param {string} secret
168
+ * @param {string} [previous]
169
+ * @returns {string}
170
+ */
171
+ _signWithSecret<T_1>(objToSign: T_1, secret: string, previous?: string): string;
172
+ /**
173
+ * Drop collection
174
+ *
175
+ * @returns {Promise}
176
+ */
177
+ drop(): Promise<any>;
178
+ }
179
+ declare namespace BaseStorage {
180
+ export { Db, Document, CreateIndexesOptions, CustomIdentifier, WithId };
181
+ }
182
+ import { ObjectId } from "mongodb";
183
+ type Db = import("mongodb").Db;
184
+ type Document = import("mongodb").Document;
185
+ type CreateIndexesOptions = import("mongodb").CreateIndexesOptions;
186
+ type CustomIdentifier<T> = {
187
+ _id: T;
188
+ };
189
+ type WithId<T extends unknown> = T & CustomIdentifier<ObjectId>;