wingbot-mongodb 2.22.0-alpha.4 → 2.22.0-alpha.5

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.
@@ -1 +1 @@
1
- {"parent":null,"pid":15360,"argv":["/usr/local/bin/node","/Users/david/Development/wingbot-mongodb/node_modules/.bin/mocha","./test"],"execArgv":[],"cwd":"/Users/david/Development/wingbot-mongodb","time":1649858779773,"ppid":15359,"coverageFilename":"/Users/david/Development/wingbot-mongodb/.nyc_output/75b2d1cb-d4fe-472b-a674-acdcb631b536.json","externalId":"","uuid":"75b2d1cb-d4fe-472b-a674-acdcb631b536","files":["/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js","/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js","/Users/david/Development/wingbot-mongodb/src/BaseStorage.js","/Users/david/Development/wingbot-mongodb/src/defaultLogger.js","/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js","/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js","/Users/david/Development/wingbot-mongodb/src/tokenFactory.js","/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js","/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js","/Users/david/Development/wingbot-mongodb/src/StateStorage.js"]}
1
+ {"parent":null,"pid":83585,"argv":["/usr/local/bin/node","/Users/david/Development/wingbot-mongodb/node_modules/.bin/mocha","./test"],"execArgv":[],"cwd":"/Users/david/Development/wingbot-mongodb","time":1650546848107,"ppid":83584,"coverageFilename":"/Users/david/Development/wingbot-mongodb/.nyc_output/1f0c249b-861d-4ebb-a415-267bb18646dd.json","externalId":"","uuid":"1f0c249b-861d-4ebb-a415-267bb18646dd","files":["/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js","/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js","/Users/david/Development/wingbot-mongodb/src/BaseStorage.js","/Users/david/Development/wingbot-mongodb/src/defaultLogger.js","/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js","/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js","/Users/david/Development/wingbot-mongodb/src/tokenFactory.js","/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js","/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js","/Users/david/Development/wingbot-mongodb/src/StateStorage.js"]}
@@ -1 +1 @@
1
- {"processes":{"75b2d1cb-d4fe-472b-a674-acdcb631b536":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"],"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["75b2d1cb-d4fe-472b-a674-acdcb631b536"]},"externalIds":{}}
1
+ {"processes":{"1f0c249b-861d-4ebb-a415-267bb18646dd":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"]},"externalIds":{}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot-mongodb",
3
- "version": "2.22.0-alpha.4",
3
+ "version": "2.22.0-alpha.5",
4
4
  "description": "MongoDB storage for wingbot.ai",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
@@ -3,6 +3,7 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
+ const { ObjectId } = require('mongodb');
6
7
  const crypto = require('crypto');
7
8
  const defaultLogger = require('./defaultLogger');
8
9
 
@@ -89,6 +90,22 @@ class BaseStorage {
89
90
  });
90
91
  }
91
92
 
93
+ /**
94
+ * @example
95
+ * {
96
+ * _id: ObjectId.isValid(id) ? new ObjectId(input) : input
97
+ * }
98
+ *
99
+ * @protected
100
+ * @param {string} id
101
+ * @returns {string|ObjectId}
102
+ */
103
+ _id (id) {
104
+ return ObjectId.isValid(id) && `${id}`.length === 24
105
+ ? new ObjectId(id)
106
+ : id;
107
+ }
108
+
92
109
  /**
93
110
  *
94
111
  * @protected
@@ -6,7 +6,7 @@
6
6
  const mongodb = require('mongodb');
7
7
  const defaultLogger = require('./defaultLogger');
8
8
 
9
- const { ObjectID } = mongodb;
9
+ const { ObjectId } = mongodb;
10
10
 
11
11
  /**
12
12
  * @typedef Target {Object}
@@ -453,8 +453,8 @@ class NotificationsStorage {
453
453
  const c = await this._getCollection(this.taksCollection);
454
454
 
455
455
  const res = await c.findOne({
456
- _id: ObjectID.isValid(taskId)
457
- ? ObjectID.createFromHexString(taskId)
456
+ _id: ObjectId.isValid(taskId)
457
+ ? ObjectId.createFromHexString(taskId)
458
458
  : taskId
459
459
  });
460
460
 
@@ -470,8 +470,8 @@ class NotificationsStorage {
470
470
  const c = await this._getCollection(this.taksCollection);
471
471
 
472
472
  const res = await c.findOneAndUpdate({
473
- _id: ObjectID.isValid(taskId)
474
- ? ObjectID.createFromHexString(taskId)
473
+ _id: ObjectId.isValid(taskId)
474
+ ? ObjectId.createFromHexString(taskId)
475
475
  : taskId
476
476
  }, {
477
477
  $set: data
@@ -607,7 +607,7 @@ class NotificationsStorage {
607
607
  });
608
608
  ret = this._mapCampaign(res.value);
609
609
  } else {
610
- const id = new ObjectID();
610
+ const id = new ObjectId();
611
611
  ret = { id: id.toHexString(), _id: id, ...campaign };
612
612
  if (updateCampaign) {
613
613
  Object.assign(ret, updateCampaign);
@@ -740,7 +740,7 @@ class NotificationsStorage {
740
740
  useCondition = {
741
741
  ...useCondition,
742
742
  _id: {
743
- $lt: ObjectID.createFromHexString(key._id)
743
+ $lt: ObjectId.createFromHexString(key._id)
744
744
  }
745
745
  };
746
746
  }
@@ -899,7 +899,7 @@ class NotificationsStorage {
899
899
  condition = {
900
900
  ...condition,
901
901
  _id: {
902
- $gt: ObjectID.createFromHexString(key._id)
902
+ $gt: ObjectId.createFromHexString(key._id)
903
903
  }
904
904
  };
905
905
  }