wingbot-mongodb 2.22.0-alpha.2 → 2.22.0-alpha.3
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/75b2d1cb-d4fe-472b-a674-acdcb631b536.json +1 -0
- package/.nyc_output/processinfo/{28ee104d-8ece-4824-bb02-ada068f4d2d3.json → 75b2d1cb-d4fe-472b-a674-acdcb631b536.json} +1 -1
- package/.nyc_output/processinfo/index.json +1 -1
- package/package.json +1 -1
- package/src/AuditLogStorage.js +2 -1
- package/src/BaseStorage.js +2 -1
- package/src/ChatLogStorage.js +2 -1
- package/src/NotificationsStorage.js +2 -1
- package/src/StateStorage.js +2 -1
- package/src/defaultLogger.js +19 -0
- package/.nyc_output/28ee104d-8ece-4824-bb02-ada068f4d2d3.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"parent":null,"pid":
|
|
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 +1 @@
|
|
|
1
|
-
{"processes":{"
|
|
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":{}}
|
package/package.json
CHANGED
package/src/AuditLogStorage.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
const jsonwebtoken = require('jsonwebtoken');
|
|
7
7
|
const BaseStorage = require('./BaseStorage');
|
|
8
|
+
const defaultLogger = require('./defaultLogger');
|
|
8
9
|
|
|
9
10
|
const LEVEL_CRITICAL = 'Critical';
|
|
10
11
|
const LEVEL_IMPORTANT = 'Important';
|
|
@@ -106,7 +107,7 @@ class AuditLogStorage extends BaseStorage {
|
|
|
106
107
|
* @param {string|Promise<string>} [secret]
|
|
107
108
|
* @param {string|Promise<string>} [jwtVerifier]
|
|
108
109
|
*/
|
|
109
|
-
constructor (mongoDb, collectionName = 'auditlog', log =
|
|
110
|
+
constructor (mongoDb, collectionName = 'auditlog', log = defaultLogger, isCosmo = false, secret = null, jwtVerifier = null) {
|
|
110
111
|
super(mongoDb, collectionName, log, isCosmo);
|
|
111
112
|
|
|
112
113
|
this.addIndex({
|
package/src/BaseStorage.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
const mongodb = require('mongodb'); // eslint-disable-line no-unused-vars
|
|
7
7
|
const crypto = require('crypto');
|
|
8
|
+
const defaultLogger = require('./defaultLogger');
|
|
8
9
|
|
|
9
10
|
/** @typedef {import('mongodb').Db} Db */
|
|
10
11
|
/** @typedef {import('mongodb').Collection} Collection */
|
|
@@ -43,7 +44,7 @@ class BaseStorage {
|
|
|
43
44
|
*
|
|
44
45
|
* }
|
|
45
46
|
*/
|
|
46
|
-
constructor (mongoDb, collectionName, log =
|
|
47
|
+
constructor (mongoDb, collectionName, log = defaultLogger, isCosmo = false) {
|
|
47
48
|
this._mongoDb = mongoDb;
|
|
48
49
|
this._collectionName = collectionName;
|
|
49
50
|
this._isCosmo = isCosmo;
|
package/src/ChatLogStorage.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
6
|
const BaseStorage = require('./BaseStorage');
|
|
7
|
+
const defaultLogger = require('./defaultLogger');
|
|
7
8
|
|
|
8
9
|
const PAGE_SENDER_TIMESTAMP = 'pageId_1_senderId_1_timestamp_-1';
|
|
9
10
|
const TIMESTAMP = 'timestamp_1';
|
|
@@ -25,7 +26,7 @@ class ChatLogStorage extends BaseStorage {
|
|
|
25
26
|
* @param {boolean} [isCosmo]
|
|
26
27
|
* @param {string|Promise<string>} [secret]
|
|
27
28
|
*/
|
|
28
|
-
constructor (mongoDb, collectionName = 'chatlogs', log =
|
|
29
|
+
constructor (mongoDb, collectionName = 'chatlogs', log = defaultLogger, isCosmo = false, secret = null) {
|
|
29
30
|
super(mongoDb, collectionName, log, isCosmo);
|
|
30
31
|
|
|
31
32
|
this.addIndex({
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
6
|
const mongodb = require('mongodb');
|
|
7
|
+
const defaultLogger = require('./defaultLogger');
|
|
7
8
|
|
|
8
9
|
const { ObjectID } = mongodb;
|
|
9
10
|
|
|
@@ -84,7 +85,7 @@ class NotificationsStorage {
|
|
|
84
85
|
* @param {{error:Function,log:Function}} [log] - console like logger
|
|
85
86
|
* @param {boolean} isCosmo
|
|
86
87
|
*/
|
|
87
|
-
constructor (mongoDb, collectionsPrefix = '', log =
|
|
88
|
+
constructor (mongoDb, collectionsPrefix = '', log = defaultLogger, isCosmo = false) {
|
|
88
89
|
this._mongoDb = mongoDb;
|
|
89
90
|
|
|
90
91
|
this.taksCollection = `${collectionsPrefix}notification-tasks`;
|
package/src/StateStorage.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
6
|
const BaseStorage = require('./BaseStorage');
|
|
7
|
+
const defaultLogger = require('./defaultLogger');
|
|
7
8
|
|
|
8
9
|
const USER_INDEX = 'senderId_1_pageId_1';
|
|
9
10
|
const LAST_INTERACTION_INDEX = 'lastInteraction_1';
|
|
@@ -37,7 +38,7 @@ class StateStorage extends BaseStorage {
|
|
|
37
38
|
* @param {{error:Function,log:Function}} [log] - console like logger
|
|
38
39
|
* @param {boolean} isCosmo
|
|
39
40
|
*/
|
|
40
|
-
constructor (mongoDb, collectionName = 'states', log =
|
|
41
|
+
constructor (mongoDb, collectionName = 'states', log = defaultLogger, isCosmo = false) {
|
|
41
42
|
super(mongoDb, collectionName, log, isCosmo);
|
|
42
43
|
|
|
43
44
|
this.addIndex(
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author {David Menger}
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
function log (...args) {
|
|
7
|
+
const mapped = args.map((a) => (typeof a === 'string' ? a : JSON.stringify(a, null, 2)));
|
|
8
|
+
process.stderr.write(` + ${mapped.join(' ')}\n`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const defaultLogger = {
|
|
12
|
+
log,
|
|
13
|
+
error: (...args) => log('ERROR:', ...args),
|
|
14
|
+
info: log,
|
|
15
|
+
warn: (...args) => log('WARN:', ...args),
|
|
16
|
+
debug: log
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = defaultLogger;
|