wingbot-mongodb 2.16.3 → 2.19.0
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/.mocharc.js +14 -0
- package/.nyc_output/8e3ceac5-95c5-4bf9-a069-da51cccc2525.json +1 -0
- package/.nyc_output/processinfo/8e3ceac5-95c5-4bf9-a069-da51cccc2525.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/README.md +58 -50
- package/package.json +21 -20
- package/src/AuditLogStorage.js +364 -0
- package/src/BaseStorage.js +73 -30
- package/src/BotConfigStorage.js +18 -7
- package/src/BotTokenStorage.js +3 -3
- package/src/ChatLogStorage.js +65 -34
- package/src/NotificationsStorage.js +37 -37
- package/src/StateStorage.js +36 -138
- package/src/main.js +3 -1
- package/.nyc_output/5a4dc5e6-8e98-4d63-a4fc-e2fe688626a9.json +0 -1
- package/.nyc_output/ccf7d45a-e479-43d4-862d-f3f229049ae1.json +0 -1
- package/.nyc_output/processinfo/5a4dc5e6-8e98-4d63-a4fc-e2fe688626a9.json +0 -1
- package/.nyc_output/processinfo/ccf7d45a-e479-43d4-862d-f3f229049ae1.json +0 -1
package/README.md
CHANGED
|
@@ -32,17 +32,17 @@ Contains storage for tokens, chat states, bot config and chat logs.
|
|
|
32
32
|
## Typedefs
|
|
33
33
|
|
|
34
34
|
<dl>
|
|
35
|
-
<dt><a href="#State">State</a> : <code>
|
|
35
|
+
<dt><a href="#State">State</a> : <code>object</code></dt>
|
|
36
36
|
<dd></dd>
|
|
37
|
-
<dt><a href="#StateCondition">StateCondition</a> : <code>
|
|
37
|
+
<dt><a href="#StateCondition">StateCondition</a> : <code>object</code></dt>
|
|
38
38
|
<dd></dd>
|
|
39
|
-
<dt><a href="#Token">Token</a> : <code>
|
|
39
|
+
<dt><a href="#Token">Token</a> : <code>object</code></dt>
|
|
40
40
|
<dd></dd>
|
|
41
41
|
<dt><a href="#Target">Target</a> : <code>Object</code></dt>
|
|
42
42
|
<dd></dd>
|
|
43
43
|
<dt><a href="#Subscribtion">Subscribtion</a> : <code>Object</code></dt>
|
|
44
44
|
<dd></dd>
|
|
45
|
-
<dt><a href="#Campaign">Campaign</a> : <code>
|
|
45
|
+
<dt><a href="#Campaign">Campaign</a> : <code>object</code></dt>
|
|
46
46
|
<dd></dd>
|
|
47
47
|
<dt><a href="#Task">Task</a> : <code>Object</code></dt>
|
|
48
48
|
<dd></dd>
|
|
@@ -57,13 +57,11 @@ Storage for chat states
|
|
|
57
57
|
|
|
58
58
|
* [StateStorage](#StateStorage)
|
|
59
59
|
* [new StateStorage(mongoDb, collectionName, [log], isCosmo)](#new_StateStorage_new)
|
|
60
|
-
* [.
|
|
61
|
-
* [.addCustomIndex(index, options)](#StateStorage+addCustomIndex)
|
|
62
|
-
* [._getCollection()](#StateStorage+_getCollection) ⇒ <code>Promise.<mongodb.Collection></code>
|
|
60
|
+
* ~~[.addCustomIndex(index, options)](#StateStorage+addCustomIndex)~~
|
|
63
61
|
* [.getState(senderId, pageId)](#StateStorage+getState) ⇒ <code>Promise.<(State\|null)></code>
|
|
64
|
-
* [.getOrCreateAndLock(senderId, pageId, [defaultState], [timeout])](#StateStorage+getOrCreateAndLock) ⇒ <code>Promise.<
|
|
62
|
+
* [.getOrCreateAndLock(senderId, pageId, [defaultState], [timeout])](#StateStorage+getOrCreateAndLock) ⇒ <code>Promise.<object></code>
|
|
65
63
|
* [.getStates(condition, limit, lastKey)](#StateStorage+getStates) ⇒ <code>Promise.<{Array.<data:State>, lastKey:string}></code>
|
|
66
|
-
* [.saveState(state)](#StateStorage+saveState) ⇒ <code>Promise.<
|
|
64
|
+
* [.saveState(state)](#StateStorage+saveState) ⇒ <code>Promise.<object></code>
|
|
67
65
|
|
|
68
66
|
<a name="new_StateStorage_new"></a>
|
|
69
67
|
|
|
@@ -72,31 +70,25 @@ Storage for chat states
|
|
|
72
70
|
| Param | Type | Default | Description |
|
|
73
71
|
| --- | --- | --- | --- |
|
|
74
72
|
| mongoDb | <code>mongodb.Db</code> \| <code>Object</code> | | |
|
|
75
|
-
| collectionName | <code>string</code> | <code>"
|
|
73
|
+
| collectionName | <code>string</code> | <code>"chatlogs"</code> | |
|
|
76
74
|
| [log] | <code>Object</code> | | console like logger |
|
|
77
75
|
| isCosmo | <code>boolean</code> | <code>false</code> | |
|
|
78
76
|
|
|
79
|
-
<a name="StateStorage+_collection"></a>
|
|
80
|
-
|
|
81
|
-
### stateStorage.\_collection : <code>Promise.<mongodb.Collection></code>
|
|
82
|
-
**Kind**: instance property of [<code>StateStorage</code>](#StateStorage)
|
|
83
77
|
<a name="StateStorage+addCustomIndex"></a>
|
|
84
78
|
|
|
85
|
-
### stateStorage.addCustomIndex(index, options)
|
|
79
|
+
### ~~stateStorage.addCustomIndex(index, options)~~
|
|
80
|
+
***Deprecated***
|
|
81
|
+
|
|
86
82
|
Add custom indexing rule
|
|
87
83
|
|
|
88
84
|
**Kind**: instance method of [<code>StateStorage</code>](#StateStorage)
|
|
89
85
|
|
|
90
86
|
| Param | Type |
|
|
91
87
|
| --- | --- |
|
|
92
|
-
| index | <code>
|
|
93
|
-
| options | <code>
|
|
88
|
+
| index | <code>object</code> |
|
|
89
|
+
| options | <code>object</code> |
|
|
94
90
|
| options.name | <code>string</code> |
|
|
95
91
|
|
|
96
|
-
<a name="StateStorage+_getCollection"></a>
|
|
97
|
-
|
|
98
|
-
### stateStorage.\_getCollection() ⇒ <code>Promise.<mongodb.Collection></code>
|
|
99
|
-
**Kind**: instance method of [<code>StateStorage</code>](#StateStorage)
|
|
100
92
|
<a name="StateStorage+getState"></a>
|
|
101
93
|
|
|
102
94
|
### stateStorage.getState(senderId, pageId) ⇒ <code>Promise.<(State\|null)></code>
|
|
@@ -109,17 +101,17 @@ Add custom indexing rule
|
|
|
109
101
|
|
|
110
102
|
<a name="StateStorage+getOrCreateAndLock"></a>
|
|
111
103
|
|
|
112
|
-
### stateStorage.getOrCreateAndLock(senderId, pageId, [defaultState], [timeout]) ⇒ <code>Promise.<
|
|
104
|
+
### stateStorage.getOrCreateAndLock(senderId, pageId, [defaultState], [timeout]) ⇒ <code>Promise.<object></code>
|
|
113
105
|
Load state from database and lock it to prevent another reads
|
|
114
106
|
|
|
115
107
|
**Kind**: instance method of [<code>StateStorage</code>](#StateStorage)
|
|
116
|
-
**Returns**: <code>Promise.<
|
|
108
|
+
**Returns**: <code>Promise.<object></code> - - conversation state
|
|
117
109
|
|
|
118
110
|
| Param | Type | Default | Description |
|
|
119
111
|
| --- | --- | --- | --- |
|
|
120
112
|
| senderId | <code>string</code> | | sender identifier |
|
|
121
113
|
| pageId | <code>string</code> | | page identifier |
|
|
122
|
-
| [defaultState] | <code>
|
|
114
|
+
| [defaultState] | <code>object</code> | | default state of the conversation |
|
|
123
115
|
| [timeout] | <code>number</code> | <code>300</code> | given default state |
|
|
124
116
|
|
|
125
117
|
<a name="StateStorage+getStates"></a>
|
|
@@ -135,14 +127,14 @@ Load state from database and lock it to prevent another reads
|
|
|
135
127
|
|
|
136
128
|
<a name="StateStorage+saveState"></a>
|
|
137
129
|
|
|
138
|
-
### stateStorage.saveState(state) ⇒ <code>Promise.<
|
|
130
|
+
### stateStorage.saveState(state) ⇒ <code>Promise.<object></code>
|
|
139
131
|
Save the state to database
|
|
140
132
|
|
|
141
133
|
**Kind**: instance method of [<code>StateStorage</code>](#StateStorage)
|
|
142
134
|
|
|
143
135
|
| Param | Type | Description |
|
|
144
136
|
| --- | --- | --- |
|
|
145
|
-
| state | <code>
|
|
137
|
+
| state | <code>object</code> | conversation state |
|
|
146
138
|
|
|
147
139
|
<a name="BotTokenStorage"></a>
|
|
148
140
|
|
|
@@ -244,9 +236,9 @@ Log single event
|
|
|
244
236
|
| Param | Type | Description |
|
|
245
237
|
| --- | --- | --- |
|
|
246
238
|
| senderId | <code>string</code> | |
|
|
247
|
-
| responses | <code>Array.<
|
|
248
|
-
| request | <code>
|
|
249
|
-
| [metadata] | <code>
|
|
239
|
+
| responses | <code>Array.<object></code> | list of sent responses |
|
|
240
|
+
| request | <code>object</code> | event request |
|
|
241
|
+
| [metadata] | <code>object</code> | request metadata |
|
|
250
242
|
|
|
251
243
|
<a name="BotConfigStorage"></a>
|
|
252
244
|
|
|
@@ -262,8 +254,9 @@ Storage for wingbot.ai conversation config
|
|
|
262
254
|
* [.api([onUpdate], [acl])](#BotConfigStorage+api) ⇒ <code>Object</code>
|
|
263
255
|
* [.invalidateConfig()](#BotConfigStorage+invalidateConfig) ⇒ <code>Promise</code>
|
|
264
256
|
* [.getConfigTimestamp()](#BotConfigStorage+getConfigTimestamp) ⇒ <code>Promise.<number></code>
|
|
265
|
-
* [.updateConfig(newConfig)](#BotConfigStorage+updateConfig) ⇒ <code>Promise.<T></code>
|
|
266
|
-
* [.
|
|
257
|
+
* [.updateConfig(newConfig, [id])](#BotConfigStorage+updateConfig) ⇒ <code>Promise.<T></code>
|
|
258
|
+
* [.setConfig(id, newConfig)](#BotConfigStorage+setConfig)
|
|
259
|
+
* [.getConfig([id])](#BotConfigStorage+getConfig) ⇒ <code>Promise.<(object\|null)></code>
|
|
267
260
|
|
|
268
261
|
<a name="new_BotConfigStorage_new"></a>
|
|
269
262
|
|
|
@@ -306,17 +299,33 @@ Invalidates current configuration
|
|
|
306
299
|
**Kind**: instance method of [<code>BotConfigStorage</code>](#BotConfigStorage)
|
|
307
300
|
<a name="BotConfigStorage+updateConfig"></a>
|
|
308
301
|
|
|
309
|
-
### botConfigStorage.updateConfig(newConfig) ⇒ <code>Promise.<T></code>
|
|
302
|
+
### botConfigStorage.updateConfig(newConfig, [id]) ⇒ <code>Promise.<T></code>
|
|
310
303
|
**Kind**: instance method of [<code>BotConfigStorage</code>](#BotConfigStorage)
|
|
311
304
|
|
|
312
305
|
| Param | Type |
|
|
313
306
|
| --- | --- |
|
|
314
307
|
| newConfig | <code>T</code> |
|
|
308
|
+
| [id] | <code>string</code> |
|
|
309
|
+
|
|
310
|
+
<a name="BotConfigStorage+setConfig"></a>
|
|
311
|
+
|
|
312
|
+
### botConfigStorage.setConfig(id, newConfig)
|
|
313
|
+
**Kind**: instance method of [<code>BotConfigStorage</code>](#BotConfigStorage)
|
|
314
|
+
|
|
315
|
+
| Param | Type |
|
|
316
|
+
| --- | --- |
|
|
317
|
+
| id | <code>string</code> |
|
|
318
|
+
| newConfig | <code>object</code> |
|
|
315
319
|
|
|
316
320
|
<a name="BotConfigStorage+getConfig"></a>
|
|
317
321
|
|
|
318
|
-
### botConfigStorage.getConfig() ⇒ <code>Promise.<(
|
|
322
|
+
### botConfigStorage.getConfig([id]) ⇒ <code>Promise.<(object\|null)></code>
|
|
319
323
|
**Kind**: instance method of [<code>BotConfigStorage</code>](#BotConfigStorage)
|
|
324
|
+
|
|
325
|
+
| Param | Type |
|
|
326
|
+
| --- | --- |
|
|
327
|
+
| [id] | <code>string</code> |
|
|
328
|
+
|
|
320
329
|
<a name="AttachmentCache"></a>
|
|
321
330
|
|
|
322
331
|
## AttachmentCache
|
|
@@ -428,7 +437,7 @@ Cache storage for Facebook attachments
|
|
|
428
437
|
|
|
429
438
|
| Param | Type |
|
|
430
439
|
| --- | --- |
|
|
431
|
-
| tasks | <code>
|
|
440
|
+
| tasks | <code>object</code> |
|
|
432
441
|
|
|
433
442
|
<a name="NotificationsStorage+getUnsuccessfulSubscribersByCampaign"></a>
|
|
434
443
|
|
|
@@ -460,7 +469,7 @@ Return Task By Id
|
|
|
460
469
|
| Param | Type |
|
|
461
470
|
| --- | --- |
|
|
462
471
|
| taskId | <code>string</code> |
|
|
463
|
-
| data | <code>
|
|
472
|
+
| data | <code>object</code> |
|
|
464
473
|
|
|
465
474
|
<a name="NotificationsStorage+getSentTask"></a>
|
|
466
475
|
|
|
@@ -506,8 +515,8 @@ Get last sent task from campaign
|
|
|
506
515
|
|
|
507
516
|
| Param | Type | Default |
|
|
508
517
|
| --- | --- | --- |
|
|
509
|
-
| campaign | <code>
|
|
510
|
-
| [updateCampaign] | <code>
|
|
518
|
+
| campaign | <code>object</code> | |
|
|
519
|
+
| [updateCampaign] | <code>object</code> | <code></code> |
|
|
511
520
|
|
|
512
521
|
<a name="NotificationsStorage+removeCampaign"></a>
|
|
513
522
|
|
|
@@ -526,7 +535,7 @@ Get last sent task from campaign
|
|
|
526
535
|
| Param | Type |
|
|
527
536
|
| --- | --- |
|
|
528
537
|
| campaignId | <code>string</code> |
|
|
529
|
-
| increment | <code>
|
|
538
|
+
| increment | <code>object</code> |
|
|
530
539
|
|
|
531
540
|
<a name="NotificationsStorage+updateCampaign"></a>
|
|
532
541
|
|
|
@@ -536,7 +545,7 @@ Get last sent task from campaign
|
|
|
536
545
|
| Param | Type |
|
|
537
546
|
| --- | --- |
|
|
538
547
|
| campaignId | <code>string</code> |
|
|
539
|
-
| data | <code>
|
|
548
|
+
| data | <code>object</code> |
|
|
540
549
|
|
|
541
550
|
<a name="NotificationsStorage+popCampaign"></a>
|
|
542
551
|
|
|
@@ -572,9 +581,9 @@ Get last sent task from campaign
|
|
|
572
581
|
|
|
573
582
|
| Param | Type | Default |
|
|
574
583
|
| --- | --- | --- |
|
|
575
|
-
| condition | <code>
|
|
584
|
+
| condition | <code>object</code> | |
|
|
576
585
|
| [limit] | <code>number</code> | <code></code> |
|
|
577
|
-
| [lastKey] | <code>
|
|
586
|
+
| [lastKey] | <code>object</code> | <code></code> |
|
|
578
587
|
|
|
579
588
|
<a name="NotificationsStorage+subscribe"></a>
|
|
580
589
|
|
|
@@ -692,9 +701,8 @@ Add custom indexing rule
|
|
|
692
701
|
|
|
693
702
|
| Param | Type |
|
|
694
703
|
| --- | --- |
|
|
695
|
-
| index | <code>
|
|
696
|
-
| options | <code>
|
|
697
|
-
| options.name | <code>string</code> |
|
|
704
|
+
| index | <code>object</code> |
|
|
705
|
+
| options | <code>mongodb.IndexOptions</code> |
|
|
698
706
|
|
|
699
707
|
<a name="BaseStorage+_getCollection"></a>
|
|
700
708
|
|
|
@@ -704,7 +712,7 @@ Returns the collection to operate with
|
|
|
704
712
|
**Kind**: instance method of [<code>BaseStorage</code>](#BaseStorage)
|
|
705
713
|
<a name="State"></a>
|
|
706
714
|
|
|
707
|
-
## State : <code>
|
|
715
|
+
## State : <code>object</code>
|
|
708
716
|
**Kind**: global typedef
|
|
709
717
|
**Properties**
|
|
710
718
|
|
|
@@ -712,11 +720,11 @@ Returns the collection to operate with
|
|
|
712
720
|
| --- | --- |
|
|
713
721
|
| senderId | <code>string</code> |
|
|
714
722
|
| pageId | <code>string</code> |
|
|
715
|
-
| state | <code>
|
|
723
|
+
| state | <code>object</code> |
|
|
716
724
|
|
|
717
725
|
<a name="StateCondition"></a>
|
|
718
726
|
|
|
719
|
-
## StateCondition : <code>
|
|
727
|
+
## StateCondition : <code>object</code>
|
|
720
728
|
**Kind**: global typedef
|
|
721
729
|
**Properties**
|
|
722
730
|
|
|
@@ -726,7 +734,7 @@ Returns the collection to operate with
|
|
|
726
734
|
|
|
727
735
|
<a name="Token"></a>
|
|
728
736
|
|
|
729
|
-
## Token : <code>
|
|
737
|
+
## Token : <code>object</code>
|
|
730
738
|
**Kind**: global typedef
|
|
731
739
|
**Properties**
|
|
732
740
|
|
|
@@ -761,7 +769,7 @@ Returns the collection to operate with
|
|
|
761
769
|
|
|
762
770
|
<a name="Campaign"></a>
|
|
763
771
|
|
|
764
|
-
## Campaign : <code>
|
|
772
|
+
## Campaign : <code>object</code>
|
|
765
773
|
**Kind**: global typedef
|
|
766
774
|
**Properties**
|
|
767
775
|
|
|
@@ -781,7 +789,7 @@ Returns the collection to operate with
|
|
|
781
789
|
| leaved | <code>number</code> | |
|
|
782
790
|
| queued | <code>number</code> | Interaction |
|
|
783
791
|
| action | <code>string</code> | |
|
|
784
|
-
| [data] | <code>
|
|
792
|
+
| [data] | <code>object</code> | Setup |
|
|
785
793
|
| sliding | <code>boolean</code> | |
|
|
786
794
|
| slide | <code>number</code> | |
|
|
787
795
|
| slideRound | <code>number</code> | |
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wingbot-mongodb",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "MongoDB storage for wingbot.ai",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "npm run test:lint && npm run test:coverage && npm run test:coverage:threshold",
|
|
8
8
|
"test:unit": "mocha ./test/**/*.test.js",
|
|
9
9
|
"test:unit:watch": "npm run test:unit -- --watch",
|
|
10
|
-
"test:cosmos": "cross-env DB_TYPE=cosmos mocha
|
|
11
|
-
"test:coverage": "nyc --reporter=html mocha
|
|
10
|
+
"test:cosmos": "cross-env DB_TYPE=cosmos mocha ./test",
|
|
11
|
+
"test:coverage": "nyc --reporter=html mocha ./test && nyc report",
|
|
12
12
|
"test:coverage:threshold": "nyc check-coverage --lines 80 --functions 79 --branches 75",
|
|
13
13
|
"test:lint": "eslint ./src/**/*.js ./bin/**/*.js ./test/**/*.js ",
|
|
14
14
|
"doc": "node ./bin/makeApiDoc.js"
|
|
@@ -34,24 +34,25 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/wingbotai/wingbot-mongodb#readme",
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"cross-env": "^
|
|
38
|
-
"eslint": "^
|
|
39
|
-
"eslint-config-airbnb": "^
|
|
40
|
-
"eslint-
|
|
41
|
-
"eslint-plugin-
|
|
42
|
-
"eslint-plugin-
|
|
43
|
-
"eslint-plugin-
|
|
44
|
-
"eslint-plugin-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"wingbot": "^2.10.0"
|
|
37
|
+
"cross-env": "^7.0.3",
|
|
38
|
+
"eslint": "^7.2.0",
|
|
39
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
40
|
+
"eslint-plugin-import": "^2.25.2",
|
|
41
|
+
"eslint-plugin-jsdoc": "^37.0.3",
|
|
42
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
43
|
+
"eslint-plugin-mocha": "^9.0.0",
|
|
44
|
+
"eslint-plugin-react": "^7.26.1",
|
|
45
|
+
"jsdoc-to-markdown": "^7.1.0",
|
|
46
|
+
"mocha": "^9.1.3",
|
|
47
|
+
"mongodb": "^3.7.3",
|
|
48
|
+
"nyc": "^15.1.0",
|
|
49
|
+
"wingbot": "^3.25.0"
|
|
51
50
|
},
|
|
52
51
|
"peerDependencies": {
|
|
53
|
-
"mongodb": "
|
|
54
|
-
"wingbot": "
|
|
52
|
+
"mongodb": "^3.0.0",
|
|
53
|
+
"wingbot": "^3.0.0"
|
|
55
54
|
},
|
|
56
|
-
"dependencies": {
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"jsonwebtoken": "^8.5.1"
|
|
57
|
+
}
|
|
57
58
|
}
|