wingbot-mongodb 4.2.6 → 4.2.8

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.6",
3
+ "version": "4.2.8",
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,6 +176,10 @@ 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
184
  return this._getCollection();
170
185
  }
@@ -172,7 +187,7 @@ class BaseStorage {
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,7 +295,7 @@ class BaseStorage {
280
295
  *
281
296
  * @protected
282
297
  * @param {boolean} [forRead]
283
- * @returns {Promise<import('mongodb').Collection<wingbotmongodb.WithId<T>>>}
298
+ * @returns {Promise<import('mongodb').Collection<WithId<T>>>}
284
299
  */
285
300
  async _getCollection (forRead = false) {
286
301
  if (this._collection === null) {
@@ -311,7 +326,7 @@ class BaseStorage {
311
326
  /**
312
327
  *
313
328
  * @param {object[]} indexes
314
- * @param {import('mongodb').Collection<wingbotmongodb.WithId<T>>} collection
329
+ * @param {import('mongodb').Collection<WithId<T>>} collection
315
330
  * @returns {Promise}
316
331
  */
317
332
  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,188 @@
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
+ * @returns {Promise<import('mongodb').Collection<WithId<T>>>}
135
+ */
136
+ protected _getCollection(forRead?: boolean): Promise<import("mongodb").Collection<WithId<T>>>;
137
+ /**
138
+ *
139
+ * @param {object[]} indexes
140
+ * @param {import('mongodb').Collection<WithId<T>>} collection
141
+ * @returns {Promise}
142
+ */
143
+ _ensureIndexes(indexes: object[], collection: import("mongodb").Collection<WithId<T>>): Promise<any>;
144
+ _checkExistingIndexes(collection: any): Promise<any>;
145
+ _checkFixtures(collection: any): Promise<any[]>;
146
+ /**
147
+ *
148
+ * @template T
149
+ * @protected
150
+ * @param {T} object
151
+ * @returns {Promise<T>}
152
+ */
153
+ protected _sign<T_1>(object: T_1): Promise<T_1>;
154
+ /**
155
+ *
156
+ * @protected
157
+ * @template T
158
+ * @param {T} object
159
+ * @returns {T}
160
+ */
161
+ protected _objectToSign<T_1>(object: T_1): T_1;
162
+ /**
163
+ *
164
+ * @template T
165
+ * @param {T} objToSign
166
+ * @param {string} secret
167
+ * @param {string} [previous]
168
+ * @returns {string}
169
+ */
170
+ _signWithSecret<T_1>(objToSign: T_1, secret: string, previous?: string): string;
171
+ /**
172
+ * Drop collection
173
+ *
174
+ * @returns {Promise}
175
+ */
176
+ drop(): Promise<any>;
177
+ }
178
+ declare namespace BaseStorage {
179
+ export { Db, Document, CreateIndexesOptions, CustomIdentifier, WithId };
180
+ }
181
+ import { ObjectId } from "mongodb";
182
+ type Db = import("mongodb").Db;
183
+ type Document = import("mongodb").Document;
184
+ type CreateIndexesOptions = import("mongodb").CreateIndexesOptions;
185
+ type CustomIdentifier<T> = {
186
+ _id: T;
187
+ };
188
+ type WithId<T extends unknown> = T & CustomIdentifier<ObjectId>;
@@ -0,0 +1,74 @@
1
+ export = BotConfigStorage;
2
+ /**
3
+ * Storage for wingbot.ai conversation config
4
+ *
5
+ * @class
6
+ */
7
+ declare class BotConfigStorage {
8
+ /**
9
+ *
10
+ * @param {Db|{():Promise<Db>}} mongoDb
11
+ * @param {string} collectionName
12
+ */
13
+ constructor(mongoDb: Db | {
14
+ (): Promise<Db>;
15
+ }, collectionName?: string);
16
+ _mongoDb: import("mongodb").Db | (() => Promise<Db>);
17
+ _collectionName: string;
18
+ /**
19
+ * @type {Collection}
20
+ */
21
+ _collection: Collection;
22
+ /**
23
+ * @returns {Promise<Collection>}
24
+ */
25
+ _getCollection(): Promise<Collection>;
26
+ /**
27
+ * Returns botUpdate API for wingbot
28
+ *
29
+ * @param {Function} [onUpdate] - async update handler function
30
+ * @param {Function|string[]} [acl] - acl configuration
31
+ * @returns {{updateBot:Function}}
32
+ */
33
+ api(onUpdate?: Function, acl?: Function | string[]): {
34
+ updateBot: Function;
35
+ };
36
+ /**
37
+ * Invalidates current configuration
38
+ *
39
+ * @returns {Promise}
40
+ */
41
+ invalidateConfig(): Promise<any>;
42
+ /**
43
+ * @returns {Promise<number>}
44
+ */
45
+ getConfigTimestamp(): Promise<number>;
46
+ /**
47
+ * @template T
48
+ * @param {T} newConfig
49
+ * @param {string} [id]
50
+ * @returns {Promise<T>}
51
+ */
52
+ updateConfig<T>(newConfig: T, id?: string): Promise<T>;
53
+ /**
54
+ *
55
+ * @param {string} id
56
+ * @param {object} newConfig
57
+ */
58
+ setConfig(id: string, newConfig: object): Promise<void>;
59
+ /**
60
+ * @param {string} [id]
61
+ * @returns {Promise<object | null>}
62
+ */
63
+ getConfig(id?: string): Promise<object | null>;
64
+ }
65
+ declare namespace BotConfigStorage {
66
+ export { BaseConfig, Db, Collection };
67
+ }
68
+ type BaseConfig = {
69
+ [key: string]: any;
70
+ } & {
71
+ _id: string;
72
+ };
73
+ type Db = import("mongodb").Db;
74
+ type Collection = import("mongodb").Collection<BaseConfig>;
@@ -0,0 +1,61 @@
1
+ export = BotTokenStorage;
2
+ /**
3
+ * @typedef {object} Token
4
+ * @prop {string} senderId
5
+ * @prop {string} pageId
6
+ * @prop {string} token
7
+ */
8
+ /** @typedef {import('mongodb').Db} Db */
9
+ /** @typedef {import('mongodb').Collection} Collection */
10
+ /**
11
+ * Storage for webview tokens
12
+ *
13
+ * @class
14
+ */
15
+ declare class BotTokenStorage {
16
+ /**
17
+ *
18
+ * @param {Db|{():Promise<Db>}} mongoDb
19
+ * @param {string} collectionName
20
+ */
21
+ constructor(mongoDb: Db | {
22
+ (): Promise<Db>;
23
+ }, collectionName?: string);
24
+ _mongoDb: import("mongodb").Db | (() => Promise<Db>);
25
+ _collectionName: string;
26
+ /**
27
+ * @type {Collection}
28
+ */
29
+ _collection: Collection;
30
+ /**
31
+ * @returns {Promise<Collection>}
32
+ */
33
+ _getCollection(): Promise<Collection>;
34
+ /**
35
+ *
36
+ * @param {string} token
37
+ * @returns {Promise<Token|null>}
38
+ */
39
+ findByToken(token: string): Promise<Token | null>;
40
+ /**
41
+ *
42
+ * @param {string} senderId
43
+ * @param {string} pageId
44
+ * @param {{(): Promise<string>}} createToken
45
+ * @returns {Promise<Token|null>}
46
+ */
47
+ getOrCreateToken(senderId: string, pageId: string, createToken?: {
48
+ (): Promise<string>;
49
+ }): Promise<Token | null>;
50
+ _wait(ms: any): Promise<any>;
51
+ }
52
+ declare namespace BotTokenStorage {
53
+ export { Token, Db, Collection };
54
+ }
55
+ type Token = {
56
+ senderId: string;
57
+ pageId: string;
58
+ token: string;
59
+ };
60
+ type Db = import("mongodb").Db;
61
+ type Collection = import("mongodb").Collection;
@@ -0,0 +1,66 @@
1
+ export = ChatLogStorage;
2
+ /** @typedef {import('mongodb').Db} Db */
3
+ /**
4
+ * Storage for conversation logs
5
+ *
6
+ * @class
7
+ */
8
+ declare class ChatLogStorage extends BaseStorage<any> {
9
+ /**
10
+ *
11
+ * @param {Db|{():Promise<Db>}} mongoDb
12
+ * @param {string} collectionName
13
+ * @param {{error:Function,log:Function}} [log] - console like logger
14
+ * @param {boolean} [isCosmo]
15
+ * @param {string|Promise<string>} [secret]
16
+ */
17
+ constructor(mongoDb: Db | {
18
+ (): Promise<Db>;
19
+ }, collectionName?: string, log?: {
20
+ error: Function;
21
+ log: Function;
22
+ }, isCosmo?: boolean, secret?: string | Promise<string>);
23
+ muteErrors: boolean;
24
+ _secret: string | Promise<string>;
25
+ /**
26
+ * Interate history
27
+ * all limits are inclusive
28
+ *
29
+ * @param {string} senderId
30
+ * @param {string} pageId
31
+ * @param {number} [limit]
32
+ * @param {number} [endAt] - iterate backwards to history
33
+ * @param {number} [startAt] - iterate forward to last interaction
34
+ * @returns {Promise<object[]>}
35
+ */
36
+ getInteractions(senderId: string, pageId: string, limit?: number, endAt?: number, startAt?: number): Promise<object[]>;
37
+ /**
38
+ * Log single event
39
+ *
40
+ * @param {string} senderId
41
+ * @param {object[]} responses - list of sent responses
42
+ * @param {object} request - event request
43
+ * @param {object} [metadata] - request metadata
44
+ * @returns {Promise}
45
+ */
46
+ log(senderId: string, responses?: object[], request?: object, metadata?: object): Promise<any>;
47
+ _storeLog(event: any): Promise<void>;
48
+ /**
49
+ * Log single event
50
+ *
51
+ * @method
52
+ * @name ChatLog#error
53
+ * @param {any} err - error
54
+ * @param {string} senderId
55
+ * @param {object[]} [responses] - list of sent responses
56
+ * @param {object} [request] - event request
57
+ * @param {object} [metadata] - request metadata
58
+ * @returns {Promise}
59
+ */
60
+ error(err: any, senderId: string, responses?: object[], request?: object, metadata?: object): Promise<any>;
61
+ }
62
+ declare namespace ChatLogStorage {
63
+ export { Db };
64
+ }
65
+ import BaseStorage = require("./BaseStorage");
66
+ type Db = import("mongodb").Db;
@@ -0,0 +1,295 @@
1
+ export = NotificationsStorage;
2
+ declare class NotificationsStorage {
3
+ /**
4
+ *
5
+ * @param {mongodb.Db|{():Promise<mongodb.Db>}} mongoDb
6
+ * @param {string} collectionsPrefix
7
+ * @param {{error:Function,log:Function}} [log] - console like logger
8
+ * @param {boolean} isCosmo
9
+ */
10
+ constructor(mongoDb: mongodb.Db | {
11
+ (): Promise<mongodb.Db>;
12
+ }, collectionsPrefix?: string, log?: {
13
+ error: Function;
14
+ log: Function;
15
+ }, isCosmo?: boolean);
16
+ _mongoDb: mongodb.Db | (() => Promise<mongodb.Db>);
17
+ taksCollection: string;
18
+ campaignsCollection: string;
19
+ subscribtionsCollection: string;
20
+ _isCosmo: boolean;
21
+ _log: {
22
+ error: Function;
23
+ log: Function;
24
+ };
25
+ /**
26
+ * @type {Map<string,Promise<mongodb.Collection>>}
27
+ */
28
+ _collections: Map<string, Promise<mongodb.Collection>>;
29
+ _getOrCreateCollection(name: any): Promise<mongodb.Collection<mongodb.BSON.Document>>;
30
+ /**
31
+ * @param {string} collectionName
32
+ * @returns {Promise<mongodb.Collection>}
33
+ */
34
+ _getCollection(collectionName: string): Promise<mongodb.Collection>;
35
+ _ensureIndexes(collection: any, indexes: any): Promise<void>;
36
+ _doesNotSupportTextIndex: boolean;
37
+ /**
38
+ *
39
+ * @param {object} tasks
40
+ * @returns {Promise<Task[]>}
41
+ */
42
+ pushTasks(tasks: object): Promise<Task[]>;
43
+ _mapGenericObject(obj: any): any;
44
+ _mapCampaign(camp: any): any;
45
+ popTasks(limit: any, until?: number): Promise<any[]>;
46
+ /**
47
+ *
48
+ * @param {string} campaignId
49
+ * @param {boolean} [sentWithoutReaction]
50
+ * @param {string} [pageId]
51
+ */
52
+ getUnsuccessfulSubscribersByCampaign(campaignId: string, sentWithoutReaction?: boolean, pageId?: string): Promise<mongodb.BSON.Document[]>;
53
+ /**
54
+ * Return Task By Id
55
+ *
56
+ * @param {string} taskId
57
+ * @returns {Promise<Task|null>}
58
+ */
59
+ getTaskById(taskId: string): Promise<Task | null>;
60
+ /**
61
+ *
62
+ * @param {string} taskId
63
+ * @param {object} data
64
+ */
65
+ updateTask(taskId: string, data: object): Promise<any>;
66
+ /**
67
+ * Get last sent task from campaign
68
+ *
69
+ * @param {string} pageId
70
+ * @param {string} senderId
71
+ * @param {string} campaignId
72
+ * @returns {Promise<Task|null>}
73
+ */
74
+ getSentTask(pageId: string, senderId: string, campaignId: string): Promise<Task | null>;
75
+ /**
76
+ *
77
+ * @param {string} pageId
78
+ * @param {string} senderId
79
+ * @param {string[]} checkCampaignIds
80
+ * @returns {Promise<string[]>}
81
+ */
82
+ getSentCampagnIds(pageId: string, senderId: string, checkCampaignIds: string[]): Promise<string[]>;
83
+ /**
84
+ *
85
+ * @param {string} senderId
86
+ * @param {string} pageId
87
+ * @param {number} watermark
88
+ * @param {('read'|'delivery')} eventType
89
+ * @param {number} ts
90
+ * @returns {Promise<Task[]>}
91
+ */
92
+ updateTasksByWatermark(senderId: string, pageId: string, watermark: number, eventType: ("read" | "delivery"), ts?: number): Promise<Task[]>;
93
+ /**
94
+ *
95
+ * @param {object} campaign
96
+ * @param {object} [updateCampaign]
97
+ * @returns {Promise<Campaign>}
98
+ */
99
+ upsertCampaign(campaign: object, updateCampaign?: object): Promise<Campaign>;
100
+ /**
101
+ *
102
+ * @param {string} campaignId
103
+ * @returns {Promise}
104
+ */
105
+ removeCampaign(campaignId: string): Promise<any>;
106
+ /**
107
+ *
108
+ * @param {string} campaignId
109
+ * @param {object} increment
110
+ * @returns {Promise}
111
+ */
112
+ incrementCampaign(campaignId: string, increment?: object): Promise<any>;
113
+ /**
114
+ *
115
+ * @param {string} campaignId
116
+ * @param {object} data
117
+ * @returns {Promise<Campaign|null>}
118
+ */
119
+ updateCampaign(campaignId: string, data: object): Promise<Campaign | null>;
120
+ /**
121
+ *
122
+ * @param {number} [now]
123
+ * @returns {Promise<Campaign|null>}
124
+ */
125
+ popCampaign(now?: number): Promise<Campaign | null>;
126
+ /**
127
+ *
128
+ * @param {string} campaignId
129
+ * @returns {Promise<null|Campaign>}
130
+ */
131
+ getCampaignById(campaignId: string): Promise<null | Campaign>;
132
+ /**
133
+ *
134
+ * @param {string[]} campaignIds
135
+ * @returns {Promise<Campaign[]>}
136
+ */
137
+ getCampaignByIds(campaignIds: string[]): Promise<Campaign[]>;
138
+ /**
139
+ *
140
+ * @param {object} condition
141
+ * @param {number} [limit]
142
+ * @param {object} [lastKey]
143
+ * @returns {Promise<{data:Campaign[],lastKey:string}>}
144
+ */
145
+ getCampaigns(condition: object, limit?: number, lastKey?: object): Promise<{
146
+ data: Campaign[];
147
+ lastKey: string;
148
+ }>;
149
+ /**
150
+ *
151
+ * @param {SubscriptionData[]} subscriptionData
152
+ * @param {boolean} [onlyToKnown=false]
153
+ * @returns {Promise}
154
+ */
155
+ batchSubscribe(subscriptionData: SubscriptionData[], onlyToKnown?: boolean): Promise<any>;
156
+ /**
157
+ *
158
+ * @param {string|string[]} senderId
159
+ * @param {string} pageId
160
+ * @param {string} tag
161
+ * @param {boolean} [onlyToKnown]
162
+ * @returns {Promise}
163
+ */
164
+ subscribe(senderId: string | string[], pageId: string, tag: string, onlyToKnown?: boolean): Promise<any>;
165
+ /**
166
+ *
167
+ * @param {string} senderId
168
+ * @param {string} pageId
169
+ * @param {string} [tag]
170
+ * @returns {Promise<string[]>}
171
+ */
172
+ unsubscribe(senderId: string, pageId: string, tag?: string): Promise<string[]>;
173
+ _createSubscribtionsCondition(include: any, exclude: any, pageId?: any): {};
174
+ /**
175
+ *
176
+ * @param {string[]} include
177
+ * @param {string[]} exclude
178
+ * @param {string} [pageId]
179
+ * @returns {Promise<number>}
180
+ */
181
+ getSubscribtionsCount(include: string[], exclude: string[], pageId?: string): Promise<number>;
182
+ /**
183
+ *
184
+ * @param {string[]} include
185
+ * @param {string[]} exclude
186
+ * @param {number} limit
187
+ * @param {string} [pageId]
188
+ * @param {*} lastKey
189
+ * @returns {Promise<{data: Target[], lastKey: string }>}
190
+ */
191
+ getSubscribtions(include: string[], exclude: string[], limit: number, pageId?: string, lastKey?: any): Promise<{
192
+ data: Target[];
193
+ lastKey: string;
194
+ }>;
195
+ /**
196
+ * @param {string} senderId
197
+ * @param {string} pageId
198
+ * @returns {Promise<Subscription[]>}
199
+ */
200
+ getSenderSubscriptions(senderId: string, pageId: string): Promise<Subscription[]>;
201
+ /**
202
+ *
203
+ * @param {string} senderId
204
+ * @param {string} pageId
205
+ * @returns {Promise<string[]>}
206
+ */
207
+ getSenderSubscribtions(senderId: string, pageId: string): Promise<string[]>;
208
+ getTags(pageId?: any): Promise<{
209
+ tag: any;
210
+ subscribtions: any;
211
+ }[]>;
212
+ }
213
+ declare namespace NotificationsStorage {
214
+ export { Target, Subscribtion, Campaign, Task, Subscription, SubscriptionData };
215
+ }
216
+ import mongodb = require("mongodb");
217
+ type Target = {
218
+ senderId: string;
219
+ pageId: string;
220
+ meta?: {
221
+ [key: string]: object;
222
+ };
223
+ };
224
+ type Subscribtion = {
225
+ senderId: string;
226
+ pageId: string;
227
+ subs: string[];
228
+ };
229
+ type Campaign = {
230
+ id: string;
231
+ /**
232
+ * Tatgeting
233
+ */
234
+ name: string;
235
+ include: string[];
236
+ /**
237
+ * Stats
238
+ */
239
+ exclude: string[];
240
+ sent: number;
241
+ succeeded: number;
242
+ failed: number;
243
+ unsubscribed: number;
244
+ delivery: number;
245
+ read: number;
246
+ notSent: number;
247
+ leaved: number;
248
+ /**
249
+ * Interaction
250
+ */
251
+ queued: number;
252
+ action: string;
253
+ /**
254
+ * Setup
255
+ */
256
+ data?: object;
257
+ sliding: boolean;
258
+ slide: number;
259
+ slideRound: number;
260
+ active: boolean;
261
+ in24hourWindow: boolean;
262
+ startAt: number;
263
+ };
264
+ type Task = {
265
+ id: string;
266
+ pageId: string;
267
+ senderId: string;
268
+ campaignId: string;
269
+ enqueue: number;
270
+ read?: number;
271
+ delivery?: number;
272
+ sent?: number;
273
+ insEnqueue?: number;
274
+ /**
275
+ * - user reacted
276
+ */
277
+ reaction?: boolean;
278
+ /**
279
+ * - time the event was not sent because user left
280
+ */
281
+ leaved?: number;
282
+ };
283
+ type Subscription = {
284
+ tag: string;
285
+ meta: object;
286
+ };
287
+ type SubscriptionData = {
288
+ pageId: string;
289
+ senderId: string;
290
+ tags: string[];
291
+ remove?: boolean;
292
+ meta?: {
293
+ [key: string]: object;
294
+ };
295
+ };
@@ -0,0 +1,97 @@
1
+ export = StateStorage;
2
+ /**
3
+ * @typedef {object} State
4
+ * @prop {string} senderId
5
+ * @prop {string} pageId
6
+ * @prop {object} state
7
+ */
8
+ /**
9
+ * @typedef {object} StateCondition
10
+ * @prop {string} [search]
11
+ * @prop {string[]} [senderIds]
12
+ * @prop {string} [pageId]
13
+ */
14
+ /** @typedef {import('mongodb').Db} Db */
15
+ /**
16
+ * Storage for chat states
17
+ *
18
+ * @class
19
+ */
20
+ declare class StateStorage extends BaseStorage<any> {
21
+ /**
22
+ *
23
+ * @param {Db|{():Promise<Db>}} mongoDb
24
+ * @param {string} collectionName
25
+ * @param {{error:Function,log:Function}} [log] - console like logger
26
+ * @param {boolean|number} isCosmo - boolean or number of failures in last 10min to kill app
27
+ */
28
+ constructor(mongoDb: Db | {
29
+ (): Promise<Db>;
30
+ }, collectionName?: string, log?: {
31
+ error: Function;
32
+ log: Function;
33
+ }, isCosmo?: boolean | number);
34
+ logCollisionsAsErrors: boolean;
35
+ /**
36
+ * Add custom indexing rule
37
+ *
38
+ * @param {object} index
39
+ * @param {object} options
40
+ * @param {string} options.name
41
+ * @deprecated
42
+ */
43
+ addCustomIndex(index: object, options: {
44
+ name: string;
45
+ }): void;
46
+ /**
47
+ *
48
+ * @param {string} senderId
49
+ * @param {string} pageId
50
+ * @returns {Promise<State|null>}
51
+ */
52
+ getState(senderId: string, pageId: string): Promise<State | null>;
53
+ /**
54
+ * Load state from database and lock it to prevent another reads
55
+ *
56
+ * @param {string} senderId - sender identifier
57
+ * @param {string} pageId - page identifier
58
+ * @param {object} [defaultState] - default state of the conversation
59
+ * @param {number} [timeout=300] - given default state
60
+ * @returns {Promise<object>} - conversation state
61
+ */
62
+ getOrCreateAndLock(senderId: string, pageId: string, defaultState?: object, timeout?: number): Promise<object>;
63
+ /**
64
+ *
65
+ * @param {StateCondition} condition
66
+ * @param {number} limit
67
+ * @param {string} lastKey
68
+ * @returns {Promise<{data:State[],lastKey:string}>}
69
+ */
70
+ getStates(condition?: StateCondition, limit?: number, lastKey?: string): Promise<{
71
+ data: State[];
72
+ lastKey: string;
73
+ }>;
74
+ _mapState(state: any): any;
75
+ /**
76
+ * Save the state to database
77
+ *
78
+ * @param {object} state - conversation state
79
+ * @returns {Promise<object>}
80
+ */
81
+ saveState(state: object): Promise<object>;
82
+ }
83
+ declare namespace StateStorage {
84
+ export { State, StateCondition, Db };
85
+ }
86
+ import BaseStorage = require("./BaseStorage");
87
+ type State = {
88
+ senderId: string;
89
+ pageId: string;
90
+ state: object;
91
+ };
92
+ type StateCondition = {
93
+ search?: string;
94
+ senderIds?: string[];
95
+ pageId?: string;
96
+ };
97
+ type Db = import("mongodb").Db;
@@ -0,0 +1,53 @@
1
+ export = compact;
2
+ /**
3
+ * @param {Db} db
4
+ * @param {string} dbUrl
5
+ * @param {string} dbName
6
+ * @param {any} log
7
+ * @returns {Promise<{bytesFreed: number}>}
8
+ */
9
+ declare function compact(db: Db, dbUrl: string, dbName: string, log?: any): Promise<{
10
+ bytesFreed: number;
11
+ }>;
12
+ declare namespace compact {
13
+ export { compactNode, getCompactableCollections, getReplicaSetNodes, Db };
14
+ }
15
+ /**
16
+ * Compacts all collections on a given replica set node
17
+ *
18
+ * @param {object} props
19
+ * @param {string} props.nodeUrl
20
+ * @param {boolean} [props.force]
21
+ * @param {string} props.dbUrl
22
+ * @param {string} props.dbName
23
+ * @param {string[]} props.collections
24
+ * @param {any} props.log
25
+ * @returns {Promise<{bytesFreed:number}>}
26
+ */
27
+ declare function compactNode({ nodeUrl, collections, force, dbUrl, dbName, log }: {
28
+ nodeUrl: string;
29
+ force?: boolean;
30
+ dbUrl: string;
31
+ dbName: string;
32
+ collections: string[];
33
+ log: any;
34
+ }): Promise<{
35
+ bytesFreed: number;
36
+ }>;
37
+ /** @typedef {import('mongodb').Db} Db */
38
+ /**
39
+ * @param {Db} db
40
+ * @returns {Promise<string[]>}
41
+ */
42
+ declare function getCompactableCollections(db: Db): Promise<string[]>;
43
+ /**
44
+ * Returns host addresses of replica set nodes
45
+ *
46
+ * @param {Db} db
47
+ * @returns {Promise<{primary: string, secondaries: string[]}>}
48
+ */
49
+ declare function getReplicaSetNodes(db: Db): Promise<{
50
+ primary: string;
51
+ secondaries: string[];
52
+ }>;
53
+ type Db = import("mongodb").Db;
@@ -0,0 +1,4 @@
1
+ export function log(...args: any[]): void;
2
+ export declare function error(...args: any[]): void;
3
+ export declare function warn(...args: any[]): void;
4
+ export { log as info, log as debug };
@@ -0,0 +1,10 @@
1
+ export = getNestedObjects;
2
+ /**
3
+ *
4
+ * @param {any} obj
5
+ * @param {boolean} nested
6
+ * @param {string} [attr]
7
+ * @param {object} [ret]
8
+ * @returns {object}
9
+ */
10
+ declare function getNestedObjects(obj: any, nested: boolean, attr?: string, ret?: object): object;
@@ -0,0 +1,9 @@
1
+ import BaseStorage = require("./BaseStorage");
2
+ import StateStorage = require("./StateStorage");
3
+ import BotTokenStorage = require("./BotTokenStorage");
4
+ import ChatLogStorage = require("./ChatLogStorage");
5
+ import BotConfigStorage = require("./BotConfigStorage");
6
+ import AttachmentCache = require("./AttachmentCache");
7
+ import NotificationsStorage = require("./NotificationsStorage");
8
+ import AuditLogStorage = require("./AuditLogStorage");
9
+ export { BaseStorage, StateStorage, BotTokenStorage, ChatLogStorage, BotConfigStorage, AttachmentCache, NotificationsStorage, AuditLogStorage };
@@ -0,0 +1,5 @@
1
+ export = tokenFactory;
2
+ /**
3
+ * @returns {Promise.<string>}
4
+ */
5
+ declare function tokenFactory(): Promise<string>;
package/baseStorage.d.ts DELETED
@@ -1,50 +0,0 @@
1
- 'use strict';
2
-
3
- declare namespace wingbotmongodb {
4
-
5
- type Collection<T> = import('mongodb').Collection<T>;
6
- type Db = import('mongodb').Db;
7
- type CreateIndexesOptions = import('mongodb').CreateIndexesOptions;
8
- type ObjectId = import('mongodb').ObjectId;
9
- export interface Logger {
10
- log: {(...any): void}
11
- error: {(...any): void}
12
- }
13
-
14
- export type WithId<T extends object> = T & { _id: ObjectId };
15
-
16
- export class BaseStorage<T = {}> {
17
-
18
- constructor (
19
- mongoDb: Db|{():Promise<Db>},
20
- collectionName: string,
21
- log?: Logger,
22
- isCosmo?: boolean
23
- )
24
-
25
- _getCollection (forRead?: boolean): Promise<Collection<WithId<T>>>
26
-
27
- public addFixtureDoc (...any: T)
28
-
29
- public addIndex (index: object, options: CreateIndexesOptions)
30
-
31
- protected _id (id: string): ObjectId
32
-
33
- protected _expandObjectToSet (
34
- attr: string|null,
35
- obj: {[key: string]: any},
36
- nested?: boolean
37
- ): {[key: string]: any}
38
-
39
- protected _log: { log: Function, error: Function };
40
-
41
- public preHeat(): Promise<void>
42
-
43
- public drop (): Promise<void>
44
-
45
- protected _catchNetworkIssues<I> (fn: {():I}): Promise<I>
46
-
47
- protected _detectNetworkIssueException<E extends Error> (e: E): E
48
- }
49
-
50
- }