wingbot-mongodb 2.20.0 → 2.20.1
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/.nyc_output/f60575da-064f-476a-a3be-be7e864d586d.json +1 -0
- package/.nyc_output/processinfo/{aa11686d-390e-407a-a6db-ecee5afa6347.json → f60575da-064f-476a-a3be-be7e864d586d.json} +1 -1
- package/.nyc_output/processinfo/index.json +1 -1
- package/README.md +257 -20
- package/package.json +2 -1
- package/src/BaseStorage.js +6 -8
- package/.nyc_output/aa11686d-390e-407a-a6db-ecee5afa6347.json +0 -1
package/README.md
CHANGED
|
@@ -23,6 +23,9 @@ Contains storage for tokens, chat states, bot config and chat logs.
|
|
|
23
23
|
<dt><a href="#AttachmentCache">AttachmentCache</a></dt>
|
|
24
24
|
<dd><p>Cache storage for Facebook attachments</p>
|
|
25
25
|
</dd>
|
|
26
|
+
<dt><a href="#AuditLogStorage">AuditLogStorage</a></dt>
|
|
27
|
+
<dd><p>Storage for audit logs with signatures chain</p>
|
|
28
|
+
</dd>
|
|
26
29
|
<dt><a href="#NotificationsStorage">NotificationsStorage</a></dt>
|
|
27
30
|
<dd></dd>
|
|
28
31
|
<dt><a href="#BaseStorage">BaseStorage</a></dt>
|
|
@@ -38,6 +41,30 @@ Contains storage for tokens, chat states, bot config and chat logs.
|
|
|
38
41
|
<dd></dd>
|
|
39
42
|
<dt><a href="#Token">Token</a> : <code>object</code></dt>
|
|
40
43
|
<dd></dd>
|
|
44
|
+
<dt><a href="#Db">Db</a> : <code>module:mongodb/lib/db</code></dt>
|
|
45
|
+
<dd></dd>
|
|
46
|
+
<dt><a href="#Db">Db</a> : <code>module:mongodb/lib/db</code></dt>
|
|
47
|
+
<dd></dd>
|
|
48
|
+
<dt><a href="#Collection">Collection</a> : <code>module:mongodb/lib/collection</code></dt>
|
|
49
|
+
<dd></dd>
|
|
50
|
+
<dt><a href="#Db">Db</a> : <code>module:mongodb/lib/db</code></dt>
|
|
51
|
+
<dd></dd>
|
|
52
|
+
<dt><a href="#TrackingEvent">TrackingEvent</a> : <code>object</code></dt>
|
|
53
|
+
<dd></dd>
|
|
54
|
+
<dt><a href="#User">User</a> : <code>object</code></dt>
|
|
55
|
+
<dd></dd>
|
|
56
|
+
<dt><a href="#Meta">Meta</a> : <code>object</code></dt>
|
|
57
|
+
<dd></dd>
|
|
58
|
+
<dt><a href="#LogEntry">LogEntry</a> : <code>object</code></dt>
|
|
59
|
+
<dd></dd>
|
|
60
|
+
<dt><a href="#JwtVerifier">JwtVerifier</a> ⇒ <code>Promise.<boolean></code></dt>
|
|
61
|
+
<dd><p>JWT Verifier</p>
|
|
62
|
+
</dd>
|
|
63
|
+
<dt><a href="#AuditLogEntry">AuditLogEntry</a> : <code>object</code></dt>
|
|
64
|
+
<dd></dd>
|
|
65
|
+
<dt><a href="#AuditLogCallback">AuditLogCallback</a> ⇒ <code>Promise</code></dt>
|
|
66
|
+
<dd><p>Audit Log Callback</p>
|
|
67
|
+
</dd>
|
|
41
68
|
<dt><a href="#Target">Target</a> : <code>Object</code></dt>
|
|
42
69
|
<dd></dd>
|
|
43
70
|
<dt><a href="#Subscribtion">Subscribtion</a> : <code>Object</code></dt>
|
|
@@ -46,6 +73,10 @@ Contains storage for tokens, chat states, bot config and chat logs.
|
|
|
46
73
|
<dd></dd>
|
|
47
74
|
<dt><a href="#Task">Task</a> : <code>Object</code></dt>
|
|
48
75
|
<dd></dd>
|
|
76
|
+
<dt><a href="#Db">Db</a> : <code>module:mongodb/lib/db</code></dt>
|
|
77
|
+
<dd></dd>
|
|
78
|
+
<dt><a href="#Collection">Collection</a> : <code>module:mongodb/lib/collection</code></dt>
|
|
79
|
+
<dd></dd>
|
|
49
80
|
</dl>
|
|
50
81
|
|
|
51
82
|
<a name="StateStorage"></a>
|
|
@@ -70,7 +101,7 @@ Storage for chat states
|
|
|
70
101
|
| Param | Type | Default | Description |
|
|
71
102
|
| --- | --- | --- | --- |
|
|
72
103
|
| mongoDb | <code>mongodb.Db</code> \| <code>Object</code> | | |
|
|
73
|
-
| collectionName | <code>string</code> | <code>"
|
|
104
|
+
| collectionName | <code>string</code> | <code>"states"</code> | |
|
|
74
105
|
| [log] | <code>Object</code> | | console like logger |
|
|
75
106
|
| isCosmo | <code>boolean</code> | <code>false</code> | |
|
|
76
107
|
|
|
@@ -195,24 +226,25 @@ Storage for conversation logs
|
|
|
195
226
|
**Kind**: global class
|
|
196
227
|
|
|
197
228
|
* [ChatLogStorage](#ChatLogStorage)
|
|
198
|
-
* [new ChatLogStorage(mongoDb, collectionName, [log], isCosmo)](#new_ChatLogStorage_new)
|
|
199
|
-
* [.getInteractions(senderId, pageId, [limit], [endAt], [startAt])](#ChatLogStorage+getInteractions)
|
|
229
|
+
* [new ChatLogStorage(mongoDb, collectionName, [log], [isCosmo], [secret])](#new_ChatLogStorage_new)
|
|
230
|
+
* [.getInteractions(senderId, pageId, [limit], [endAt], [startAt])](#ChatLogStorage+getInteractions) ⇒ <code>Promise.<Array.<object>></code>
|
|
200
231
|
* [.log(senderId, responses, request, [metadata])](#ChatLogStorage+log) ⇒ <code>Promise</code>
|
|
201
232
|
|
|
202
233
|
<a name="new_ChatLogStorage_new"></a>
|
|
203
234
|
|
|
204
|
-
### new ChatLogStorage(mongoDb, collectionName, [log], isCosmo)
|
|
235
|
+
### new ChatLogStorage(mongoDb, collectionName, [log], [isCosmo], [secret])
|
|
205
236
|
|
|
206
237
|
| Param | Type | Default | Description |
|
|
207
238
|
| --- | --- | --- | --- |
|
|
208
|
-
| mongoDb | <code>
|
|
239
|
+
| mongoDb | [<code>Db</code>](#Db) \| <code>Object</code> | | |
|
|
209
240
|
| collectionName | <code>string</code> | <code>"chatlogs"</code> | |
|
|
210
241
|
| [log] | <code>Object</code> | | console like logger |
|
|
211
|
-
| isCosmo | <code>boolean</code> | <code>false</code> | |
|
|
242
|
+
| [isCosmo] | <code>boolean</code> | <code>false</code> | |
|
|
243
|
+
| [secret] | <code>string</code> \| <code>Promise.<string></code> | <code>null</code> | |
|
|
212
244
|
|
|
213
245
|
<a name="ChatLogStorage+getInteractions"></a>
|
|
214
246
|
|
|
215
|
-
### chatLogStorage.getInteractions(senderId, pageId, [limit], [endAt], [startAt])
|
|
247
|
+
### chatLogStorage.getInteractions(senderId, pageId, [limit], [endAt], [startAt]) ⇒ <code>Promise.<Array.<object>></code>
|
|
216
248
|
Interate history
|
|
217
249
|
all limits are inclusive
|
|
218
250
|
|
|
@@ -249,8 +281,8 @@ Storage for wingbot.ai conversation config
|
|
|
249
281
|
|
|
250
282
|
* [BotConfigStorage](#BotConfigStorage)
|
|
251
283
|
* [new BotConfigStorage(mongoDb, collectionName)](#new_BotConfigStorage_new)
|
|
252
|
-
* [._collection](#BotConfigStorage+_collection) : <code>
|
|
253
|
-
* [._getCollection()](#BotConfigStorage+_getCollection) ⇒ <code>Promise.<
|
|
284
|
+
* [._collection](#BotConfigStorage+_collection) : [<code>Collection</code>](#Collection)
|
|
285
|
+
* [._getCollection()](#BotConfigStorage+_getCollection) ⇒ [<code>Promise.<Collection></code>](#Collection)
|
|
254
286
|
* [.api([onUpdate], [acl])](#BotConfigStorage+api) ⇒ <code>Object</code>
|
|
255
287
|
* [.invalidateConfig()](#BotConfigStorage+invalidateConfig) ⇒ <code>Promise</code>
|
|
256
288
|
* [.getConfigTimestamp()](#BotConfigStorage+getConfigTimestamp) ⇒ <code>Promise.<number></code>
|
|
@@ -264,16 +296,16 @@ Storage for wingbot.ai conversation config
|
|
|
264
296
|
|
|
265
297
|
| Param | Type | Default |
|
|
266
298
|
| --- | --- | --- |
|
|
267
|
-
| mongoDb | <code>
|
|
299
|
+
| mongoDb | [<code>Db</code>](#Db) \| <code>Object</code> | |
|
|
268
300
|
| collectionName | <code>string</code> | <code>"botconfig"</code> |
|
|
269
301
|
|
|
270
302
|
<a name="BotConfigStorage+_collection"></a>
|
|
271
303
|
|
|
272
|
-
### botConfigStorage.\_collection : <code>
|
|
304
|
+
### botConfigStorage.\_collection : [<code>Collection</code>](#Collection)
|
|
273
305
|
**Kind**: instance property of [<code>BotConfigStorage</code>](#BotConfigStorage)
|
|
274
306
|
<a name="BotConfigStorage+_getCollection"></a>
|
|
275
307
|
|
|
276
|
-
### botConfigStorage.\_getCollection() ⇒ <code>Promise.<
|
|
308
|
+
### botConfigStorage.\_getCollection() ⇒ [<code>Promise.<Collection></code>](#Collection)
|
|
277
309
|
**Kind**: instance method of [<code>BotConfigStorage</code>](#BotConfigStorage)
|
|
278
310
|
<a name="BotConfigStorage+api"></a>
|
|
279
311
|
|
|
@@ -376,6 +408,69 @@ Cache storage for Facebook attachments
|
|
|
376
408
|
| url | <code>string</code> |
|
|
377
409
|
| attachmentId | <code>number</code> |
|
|
378
410
|
|
|
411
|
+
<a name="AuditLogStorage"></a>
|
|
412
|
+
|
|
413
|
+
## AuditLogStorage
|
|
414
|
+
Storage for audit logs with signatures chain
|
|
415
|
+
|
|
416
|
+
**Kind**: global class
|
|
417
|
+
|
|
418
|
+
* [AuditLogStorage](#AuditLogStorage)
|
|
419
|
+
* [new AuditLogStorage(mongoDb, collectionName, [log], [isCosmo], [secret], [jwtVerifier])](#new_AuditLogStorage_new)
|
|
420
|
+
* [._jwtVerify](#AuditLogStorage+_jwtVerify) : [<code>JwtVerifier</code>](#JwtVerifier)
|
|
421
|
+
* [.callback](#AuditLogStorage+callback) : [<code>AuditLogCallback</code>](#AuditLogCallback)
|
|
422
|
+
* [.log(event, user, [meta], [wid], [type], [level], [date])](#AuditLogStorage+log) ⇒ <code>Promise</code>
|
|
423
|
+
* [.list([wid], [fromSeq], [limit])](#AuditLogStorage+list) ⇒ <code>Promise.<Array.<LogEntry>></code>
|
|
424
|
+
|
|
425
|
+
<a name="new_AuditLogStorage_new"></a>
|
|
426
|
+
|
|
427
|
+
### new AuditLogStorage(mongoDb, collectionName, [log], [isCosmo], [secret], [jwtVerifier])
|
|
428
|
+
|
|
429
|
+
| Param | Type | Default | Description |
|
|
430
|
+
| --- | --- | --- | --- |
|
|
431
|
+
| mongoDb | [<code>Db</code>](#Db) \| <code>Object</code> | | |
|
|
432
|
+
| collectionName | <code>string</code> | <code>"auditlog"</code> | |
|
|
433
|
+
| [log] | <code>Object</code> | | console like logger |
|
|
434
|
+
| [isCosmo] | <code>boolean</code> | <code>false</code> | |
|
|
435
|
+
| [secret] | <code>string</code> \| <code>Promise.<string></code> | <code>null</code> | |
|
|
436
|
+
| [jwtVerifier] | <code>string</code> \| <code>Promise.<string></code> | <code>null</code> | |
|
|
437
|
+
|
|
438
|
+
<a name="AuditLogStorage+_jwtVerify"></a>
|
|
439
|
+
|
|
440
|
+
### auditLogStorage.\_jwtVerify : [<code>JwtVerifier</code>](#JwtVerifier)
|
|
441
|
+
**Kind**: instance property of [<code>AuditLogStorage</code>](#AuditLogStorage)
|
|
442
|
+
<a name="AuditLogStorage+callback"></a>
|
|
443
|
+
|
|
444
|
+
### auditLogStorage.callback : [<code>AuditLogCallback</code>](#AuditLogCallback)
|
|
445
|
+
**Kind**: instance property of [<code>AuditLogStorage</code>](#AuditLogStorage)
|
|
446
|
+
<a name="AuditLogStorage+log"></a>
|
|
447
|
+
|
|
448
|
+
### auditLogStorage.log(event, user, [meta], [wid], [type], [level], [date]) ⇒ <code>Promise</code>
|
|
449
|
+
Add a log
|
|
450
|
+
|
|
451
|
+
**Kind**: instance method of [<code>AuditLogStorage</code>](#AuditLogStorage)
|
|
452
|
+
|
|
453
|
+
| Param | Type | Description |
|
|
454
|
+
| --- | --- | --- |
|
|
455
|
+
| event | [<code>TrackingEvent</code>](#TrackingEvent) | |
|
|
456
|
+
| user | [<code>User</code>](#User) | |
|
|
457
|
+
| [meta] | [<code>Meta</code>](#Meta) | |
|
|
458
|
+
| [wid] | <code>string</code> | workspace ID |
|
|
459
|
+
| [type] | <code>string</code> | |
|
|
460
|
+
| [level] | <code>string</code> | |
|
|
461
|
+
| [date] | <code>Date</code> | |
|
|
462
|
+
|
|
463
|
+
<a name="AuditLogStorage+list"></a>
|
|
464
|
+
|
|
465
|
+
### auditLogStorage.list([wid], [fromSeq], [limit]) ⇒ <code>Promise.<Array.<LogEntry>></code>
|
|
466
|
+
**Kind**: instance method of [<code>AuditLogStorage</code>](#AuditLogStorage)
|
|
467
|
+
|
|
468
|
+
| Param | Type | Default | Description |
|
|
469
|
+
| --- | --- | --- | --- |
|
|
470
|
+
| [wid] | <code>string</code> | | workspace id |
|
|
471
|
+
| [fromSeq] | <code>number</code> | <code>0</code> | for paging |
|
|
472
|
+
| [limit] | <code>number</code> | <code>40</code> | |
|
|
473
|
+
|
|
379
474
|
<a name="NotificationsStorage"></a>
|
|
380
475
|
|
|
381
476
|
## NotificationsStorage
|
|
@@ -647,21 +742,22 @@ Get last sent task from campaign
|
|
|
647
742
|
**Kind**: global class
|
|
648
743
|
|
|
649
744
|
* [BaseStorage](#BaseStorage)
|
|
650
|
-
* [new BaseStorage(mongoDb, collectionName, [log], isCosmo)](#new_BaseStorage_new)
|
|
651
|
-
* [._collection](#BaseStorage+_collection) : <code>Promise.<
|
|
745
|
+
* [new BaseStorage(mongoDb, collectionName, [log], [isCosmo])](#new_BaseStorage_new)
|
|
746
|
+
* [._collection](#BaseStorage+_collection) : [<code>Collection</code>](#Collection) \| [<code>Promise.<Collection></code>](#Collection)
|
|
747
|
+
* [.addFixtureDoc(...objects)](#BaseStorage+addFixtureDoc)
|
|
652
748
|
* [.addIndex(index, options)](#BaseStorage+addIndex)
|
|
653
|
-
* [._getCollection()](#BaseStorage+_getCollection) ⇒ <code>Promise.<
|
|
749
|
+
* [._getCollection()](#BaseStorage+_getCollection) ⇒ [<code>Promise.<Collection></code>](#Collection)
|
|
654
750
|
|
|
655
751
|
<a name="new_BaseStorage_new"></a>
|
|
656
752
|
|
|
657
|
-
### new BaseStorage(mongoDb, collectionName, [log], isCosmo)
|
|
753
|
+
### new BaseStorage(mongoDb, collectionName, [log], [isCosmo])
|
|
658
754
|
|
|
659
755
|
| Param | Type | Default | Description |
|
|
660
756
|
| --- | --- | --- | --- |
|
|
661
|
-
| mongoDb | <code>
|
|
757
|
+
| mongoDb | [<code>Db</code>](#Db) \| <code>Object</code> | | |
|
|
662
758
|
| collectionName | <code>string</code> | | |
|
|
663
759
|
| [log] | <code>Object</code> | | console like logger |
|
|
664
|
-
| isCosmo | <code>boolean</code> | <code>false</code> | |
|
|
760
|
+
| [isCosmo] | <code>boolean</code> | <code>false</code> | |
|
|
665
761
|
|
|
666
762
|
**Example**
|
|
667
763
|
```javascript
|
|
@@ -690,8 +786,19 @@ class MyCoolDataStorage extends BaseStorage {
|
|
|
690
786
|
```
|
|
691
787
|
<a name="BaseStorage+_collection"></a>
|
|
692
788
|
|
|
693
|
-
### baseStorage.\_collection : <code>Promise.<
|
|
789
|
+
### baseStorage.\_collection : [<code>Collection</code>](#Collection) \| [<code>Promise.<Collection></code>](#Collection)
|
|
694
790
|
**Kind**: instance property of [<code>BaseStorage</code>](#BaseStorage)
|
|
791
|
+
<a name="BaseStorage+addFixtureDoc"></a>
|
|
792
|
+
|
|
793
|
+
### baseStorage.addFixtureDoc(...objects)
|
|
794
|
+
Insert defalt document to DB
|
|
795
|
+
|
|
796
|
+
**Kind**: instance method of [<code>BaseStorage</code>](#BaseStorage)
|
|
797
|
+
|
|
798
|
+
| Param | Type |
|
|
799
|
+
| --- | --- |
|
|
800
|
+
| ...objects | <code>any</code> |
|
|
801
|
+
|
|
695
802
|
<a name="BaseStorage+addIndex"></a>
|
|
696
803
|
|
|
697
804
|
### baseStorage.addIndex(index, options)
|
|
@@ -706,7 +813,7 @@ Add custom indexing rule
|
|
|
706
813
|
|
|
707
814
|
<a name="BaseStorage+_getCollection"></a>
|
|
708
815
|
|
|
709
|
-
### baseStorage.\_getCollection() ⇒ <code>Promise.<
|
|
816
|
+
### baseStorage.\_getCollection() ⇒ [<code>Promise.<Collection></code>](#Collection)
|
|
710
817
|
Returns the collection to operate with
|
|
711
818
|
|
|
712
819
|
**Kind**: instance method of [<code>BaseStorage</code>](#BaseStorage)
|
|
@@ -744,6 +851,128 @@ Returns the collection to operate with
|
|
|
744
851
|
| pageId | <code>string</code> |
|
|
745
852
|
| token | <code>string</code> |
|
|
746
853
|
|
|
854
|
+
<a name="Db"></a>
|
|
855
|
+
|
|
856
|
+
## Db : <code>module:mongodb/lib/db</code>
|
|
857
|
+
**Kind**: global typedef
|
|
858
|
+
<a name="Db"></a>
|
|
859
|
+
|
|
860
|
+
## Db : <code>module:mongodb/lib/db</code>
|
|
861
|
+
**Kind**: global typedef
|
|
862
|
+
<a name="Collection"></a>
|
|
863
|
+
|
|
864
|
+
## Collection : <code>module:mongodb/lib/collection</code>
|
|
865
|
+
**Kind**: global typedef
|
|
866
|
+
<a name="Db"></a>
|
|
867
|
+
|
|
868
|
+
## Db : <code>module:mongodb/lib/db</code>
|
|
869
|
+
**Kind**: global typedef
|
|
870
|
+
<a name="TrackingEvent"></a>
|
|
871
|
+
|
|
872
|
+
## TrackingEvent : <code>object</code>
|
|
873
|
+
**Kind**: global typedef
|
|
874
|
+
**Properties**
|
|
875
|
+
|
|
876
|
+
| Name | Type | Default |
|
|
877
|
+
| --- | --- | --- |
|
|
878
|
+
| [type] | <code>string</code> | <code>"'audit'"</code> |
|
|
879
|
+
| category | <code>string</code> | |
|
|
880
|
+
| action | <code>string</code> | |
|
|
881
|
+
| [label] | <code>string</code> | |
|
|
882
|
+
| [payload] | <code>object</code> | |
|
|
883
|
+
|
|
884
|
+
<a name="User"></a>
|
|
885
|
+
|
|
886
|
+
## User : <code>object</code>
|
|
887
|
+
**Kind**: global typedef
|
|
888
|
+
**Properties**
|
|
889
|
+
|
|
890
|
+
| Name | Type | Description |
|
|
891
|
+
| --- | --- | --- |
|
|
892
|
+
| [id] | <code>string</code> | |
|
|
893
|
+
| [senderId] | <code>string</code> | |
|
|
894
|
+
| [pageId] | <code>string</code> | |
|
|
895
|
+
| [jwt] | <code>string</code> | jwt to check the authorship |
|
|
896
|
+
|
|
897
|
+
<a name="Meta"></a>
|
|
898
|
+
|
|
899
|
+
## Meta : <code>object</code>
|
|
900
|
+
**Kind**: global typedef
|
|
901
|
+
**Properties**
|
|
902
|
+
|
|
903
|
+
| Name | Type | Description |
|
|
904
|
+
| --- | --- | --- |
|
|
905
|
+
| [ip] | <code>string</code> | |
|
|
906
|
+
| [ua] | <code>string</code> | |
|
|
907
|
+
| [ro] | <code>string</code> | referrer || origin |
|
|
908
|
+
|
|
909
|
+
<a name="LogEntry"></a>
|
|
910
|
+
|
|
911
|
+
## LogEntry : <code>object</code>
|
|
912
|
+
**Kind**: global typedef
|
|
913
|
+
**Properties**
|
|
914
|
+
|
|
915
|
+
| Name | Type | Default | Description |
|
|
916
|
+
| --- | --- | --- | --- |
|
|
917
|
+
| date | <code>string</code> | | ISO date |
|
|
918
|
+
| delta | <code>number</code> | | time skew in ms if there was a write conflict |
|
|
919
|
+
| [eventType] | <code>string</code> | <code>"'audit'"</code> | |
|
|
920
|
+
| category | <code>string</code> | | |
|
|
921
|
+
| action | <code>string</code> | | |
|
|
922
|
+
| [label] | <code>string</code> | | |
|
|
923
|
+
| [payload] | <code>object</code> | | |
|
|
924
|
+
| level | <code>string</code> | | (Critical|Important|Debug) |
|
|
925
|
+
| ok | <code>boolean</code> | | signature matches |
|
|
926
|
+
| seq | <code>number</code> | | sequence number |
|
|
927
|
+
| type | <code>string</code> | | (Error|Warn|Info) |
|
|
928
|
+
| user | [<code>User</code>](#User) | | |
|
|
929
|
+
| wid | <code>string</code> | | workspace id |
|
|
930
|
+
| meta | [<code>Meta</code>](#Meta) | | |
|
|
931
|
+
|
|
932
|
+
<a name="JwtVerifier"></a>
|
|
933
|
+
|
|
934
|
+
## JwtVerifier ⇒ <code>Promise.<boolean></code>
|
|
935
|
+
JWT Verifier
|
|
936
|
+
|
|
937
|
+
**Kind**: global typedef
|
|
938
|
+
|
|
939
|
+
| Param | Type |
|
|
940
|
+
| --- | --- |
|
|
941
|
+
| token | <code>string</code> |
|
|
942
|
+
| userId | <code>string</code> |
|
|
943
|
+
| [user] | [<code>User</code>](#User) |
|
|
944
|
+
|
|
945
|
+
<a name="AuditLogEntry"></a>
|
|
946
|
+
|
|
947
|
+
## AuditLogEntry : <code>object</code>
|
|
948
|
+
**Kind**: global typedef
|
|
949
|
+
**Properties**
|
|
950
|
+
|
|
951
|
+
| Name | Type | Default | Description |
|
|
952
|
+
| --- | --- | --- | --- |
|
|
953
|
+
| date | <code>string</code> | | ISO date |
|
|
954
|
+
| [eventType] | <code>string</code> | <code>"'audit'"</code> | |
|
|
955
|
+
| category | <code>string</code> | | |
|
|
956
|
+
| action | <code>string</code> | | |
|
|
957
|
+
| [label] | <code>string</code> | | |
|
|
958
|
+
| [payload] | <code>object</code> | | |
|
|
959
|
+
| level | <code>string</code> | | (Critical|Important|Debug) |
|
|
960
|
+
| type | <code>string</code> | | (Error|Warn|Info) |
|
|
961
|
+
| user | [<code>User</code>](#User) | | |
|
|
962
|
+
| wid | <code>string</code> | | workspace id |
|
|
963
|
+
| meta | [<code>Meta</code>](#Meta) | | |
|
|
964
|
+
|
|
965
|
+
<a name="AuditLogCallback"></a>
|
|
966
|
+
|
|
967
|
+
## AuditLogCallback ⇒ <code>Promise</code>
|
|
968
|
+
Audit Log Callback
|
|
969
|
+
|
|
970
|
+
**Kind**: global typedef
|
|
971
|
+
|
|
972
|
+
| Param | Type |
|
|
973
|
+
| --- | --- |
|
|
974
|
+
| entry | [<code>AuditLogEntry</code>](#AuditLogEntry) |
|
|
975
|
+
|
|
747
976
|
<a name="Target"></a>
|
|
748
977
|
|
|
749
978
|
## Target : <code>Object</code>
|
|
@@ -817,3 +1046,11 @@ Returns the collection to operate with
|
|
|
817
1046
|
| [reaction] | <code>boolean</code> | user reacted |
|
|
818
1047
|
| [leaved] | <code>number</code> | time the event was not sent because user left |
|
|
819
1048
|
|
|
1049
|
+
<a name="Db"></a>
|
|
1050
|
+
|
|
1051
|
+
## Db : <code>module:mongodb/lib/db</code>
|
|
1052
|
+
**Kind**: global typedef
|
|
1053
|
+
<a name="Collection"></a>
|
|
1054
|
+
|
|
1055
|
+
## Collection : <code>module:mongodb/lib/collection</code>
|
|
1056
|
+
**Kind**: global typedef
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wingbot-mongodb",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.1",
|
|
4
4
|
"description": "MongoDB storage for wingbot.ai",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"eslint-plugin-mocha": "^9.0.0",
|
|
44
44
|
"eslint-plugin-react": "^7.26.1",
|
|
45
45
|
"jsdoc-to-markdown": "^7.1.0",
|
|
46
|
+
"jsdoc-tsimport-plugin": "^1.0.5",
|
|
46
47
|
"mocha": "^9.1.3",
|
|
47
48
|
"mongodb": "^3.7.3",
|
|
48
49
|
"nyc": "^15.1.0",
|
package/src/BaseStorage.js
CHANGED
|
@@ -151,24 +151,22 @@ class BaseStorage {
|
|
|
151
151
|
.filter((e) => !this.systemIndexes.includes(e.name)
|
|
152
152
|
&& !indexes.some((i) => e.name === i.options.name))
|
|
153
153
|
.reduce((p, e) => {
|
|
154
|
-
|
|
155
|
-
this._log.log(`dropping index ${e.name}`);
|
|
154
|
+
this._log.log(`DB.${this._collectionName} dropping index ${e.name}`);
|
|
156
155
|
return p
|
|
157
156
|
.then(() => collection.dropIndex(e.name))
|
|
158
157
|
.catch((err) => {
|
|
159
|
-
|
|
160
|
-
this._log.error(`dropping index ${e.name} FAILED`, err);
|
|
158
|
+
this._log.error(`DB.${this._collectionName} dropping index ${e.name} FAILED`, err);
|
|
161
159
|
});
|
|
162
160
|
}, Promise.resolve());
|
|
163
161
|
|
|
164
162
|
const updated = await indexes
|
|
165
163
|
.filter((i) => !existing.some((e) => e.name === i.options.name))
|
|
166
164
|
.reduce((p, i) => {
|
|
167
|
-
this._log.log(`creating index ${i.name}`);
|
|
165
|
+
this._log.log(`DB.${this._collectionName} creating index ${i.options.name}`);
|
|
168
166
|
return p
|
|
169
167
|
.then(() => collection.createIndex(i.index, i.options))
|
|
170
168
|
.catch((e) => {
|
|
171
|
-
this._log.error(`failed to create index ${i.options.name} on ${collection.collectionName}`, e);
|
|
169
|
+
this._log.error(`DB.${this._collectionName} failed to create index ${i.options.name} on ${collection.collectionName}`, e);
|
|
172
170
|
})
|
|
173
171
|
.then(() => true);
|
|
174
172
|
}, Promise.resolve(false));
|
|
@@ -178,10 +176,10 @@ class BaseStorage {
|
|
|
178
176
|
|
|
179
177
|
await this._fixtures.reduce((p, o) => p
|
|
180
178
|
.then(() => collection.insertOne(o))
|
|
181
|
-
.then(() => this._log.log(`DB
|
|
179
|
+
.then(() => this._log.log(`DB.${this._collectionName} Inserted fixture doc to "${this._collectionName}"`))
|
|
182
180
|
.catch((e) => {
|
|
183
181
|
if (e.code !== 11000) {
|
|
184
|
-
this._log.error(`DB
|
|
182
|
+
this._log.error(`DB.${this._collectionName} failed to insert fixture doc to "${this._collectionName}"`, e);
|
|
185
183
|
}
|
|
186
184
|
}),
|
|
187
185
|
Promise.resolve());
|