wingbot-mongodb 2.21.1 → 2.21.3-beta.2
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/8cd701fd-7d02-4d21-90bc-0f9eafe331ec.json +1 -0
- package/.nyc_output/processinfo/8cd701fd-7d02-4d21-90bc-0f9eafe331ec.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/package.json +2 -2
- package/src/NotificationsStorage.js +7 -1
- package/src/StateStorage.js +12 -2
- package/.nyc_output/32821199-22af-42bd-8e0d-c255510f3efa.json +0 -1
- package/.nyc_output/processinfo/32821199-22af-42bd-8e0d-c255510f3efa.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"processes":{"
|
|
1
|
+
{"processes":{"8cd701fd-7d02-4d21-90bc-0f9eafe331ec":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["8cd701fd-7d02-4d21-90bc-0f9eafe331ec"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["8cd701fd-7d02-4d21-90bc-0f9eafe331ec"],"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["8cd701fd-7d02-4d21-90bc-0f9eafe331ec"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["8cd701fd-7d02-4d21-90bc-0f9eafe331ec"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["8cd701fd-7d02-4d21-90bc-0f9eafe331ec"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["8cd701fd-7d02-4d21-90bc-0f9eafe331ec"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["8cd701fd-7d02-4d21-90bc-0f9eafe331ec"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["8cd701fd-7d02-4d21-90bc-0f9eafe331ec"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["8cd701fd-7d02-4d21-90bc-0f9eafe331ec"]},"externalIds":{}}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wingbot-mongodb",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.3-beta.2",
|
|
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
|
-
"test:unit": "mocha ./test/**/*.
|
|
8
|
+
"test:unit": "mocha ./test/**/*.js",
|
|
9
9
|
"test:unit:watch": "npm run test:unit -- --watch",
|
|
10
10
|
"test:cosmos": "cross-env DB_TYPE=cosmos mocha ./test",
|
|
11
11
|
"test:coverage": "nyc --reporter=html mocha ./test && nyc report",
|
package/src/StateStorage.js
CHANGED
|
@@ -9,6 +9,7 @@ const BaseStorage = require('./BaseStorage');
|
|
|
9
9
|
const USER_INDEX = 'senderId_1_pageId_1';
|
|
10
10
|
const LAST_INTERACTION_INDEX = 'lastInteraction_1';
|
|
11
11
|
const SEARCH = 'search-text';
|
|
12
|
+
const NAME = 'name_1';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @typedef {object} State
|
|
@@ -48,7 +49,12 @@ class StateStorage extends BaseStorage {
|
|
|
48
49
|
{ name: LAST_INTERACTION_INDEX }
|
|
49
50
|
);
|
|
50
51
|
|
|
51
|
-
if (
|
|
52
|
+
if (isCosmo) {
|
|
53
|
+
this.addIndex(
|
|
54
|
+
{ name: 1 },
|
|
55
|
+
{ name: NAME }
|
|
56
|
+
);
|
|
57
|
+
} else {
|
|
52
58
|
this.addIndex(
|
|
53
59
|
{ '$**': 'text' },
|
|
54
60
|
{ name: SEARCH }
|
|
@@ -156,8 +162,12 @@ class StateStorage extends BaseStorage {
|
|
|
156
162
|
|
|
157
163
|
if (searchStates) {
|
|
158
164
|
if (this._isCosmo) {
|
|
165
|
+
const $regex = `^${condition.search.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')}`;
|
|
159
166
|
Object.assign(useCondition, {
|
|
160
|
-
|
|
167
|
+
$or: [
|
|
168
|
+
{ senderId: { $regex } },
|
|
169
|
+
{ name: { $regex } }
|
|
170
|
+
]
|
|
161
171
|
});
|
|
162
172
|
} else {
|
|
163
173
|
Object.assign(useCondition, {
|