wingbot-mongodb 4.0.0-alpha.4 → 4.0.0-alpha.7
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/596e9b84-51c8-44b2-b5a0-e9ba553853e7.json +1 -0
- package/.nyc_output/processinfo/{c5005d32-ad45-472c-811c-860ccef899fe.json → 596e9b84-51c8-44b2-b5a0-e9ba553853e7.json} +1 -1
- package/.nyc_output/processinfo/index.json +1 -1
- package/package.json +1 -1
- package/src/BaseStorage.js +14 -5
- package/.nyc_output/c5005d32-ad45-472c-811c-860ccef899fe.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"parent":null,"pid":
|
|
1
|
+
{"parent":null,"pid":64241,"argv":["/usr/local/bin/node","/Users/david/Development/wingbot-mongodb/node_modules/.bin/mocha","./test"],"execArgv":[],"cwd":"/Users/david/Development/wingbot-mongodb","time":1697029132487,"ppid":64240,"coverageFilename":"/Users/david/Development/wingbot-mongodb/.nyc_output/596e9b84-51c8-44b2-b5a0-e9ba553853e7.json","externalId":"","uuid":"596e9b84-51c8-44b2-b5a0-e9ba553853e7","files":["/Users/david/Development/wingbot-mongodb/src/BaseStorage.js","/Users/david/Development/wingbot-mongodb/src/defaultLogger.js","/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js","/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.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":{"596e9b84-51c8-44b2-b5a0-e9ba553853e7":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"],"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["596e9b84-51c8-44b2-b5a0-e9ba553853e7"]},"externalIds":{}}
|
package/package.json
CHANGED
package/src/BaseStorage.js
CHANGED
|
@@ -37,10 +37,16 @@ function getNestedObjects (obj, nested, attr = null, ret = {}) {
|
|
|
37
37
|
* @template T
|
|
38
38
|
* @param {string} k
|
|
39
39
|
* @param {T} v
|
|
40
|
-
* @returns {T|null}
|
|
40
|
+
* @returns {T|null|string}
|
|
41
41
|
*/
|
|
42
42
|
function signReplacer (k, v) {
|
|
43
|
-
|
|
43
|
+
if (v === undefined) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (v instanceof Date) {
|
|
47
|
+
return v.toISOString();
|
|
48
|
+
}
|
|
49
|
+
return v;
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
class BaseStorage {
|
|
@@ -422,7 +428,6 @@ class BaseStorage {
|
|
|
422
428
|
}
|
|
423
429
|
const secret = await Promise.resolve(this._secret);
|
|
424
430
|
const objToSign = this._objectToSign(object);
|
|
425
|
-
console.log('_SIGN', objToSign);
|
|
426
431
|
const sign = this._signWithSecret(objToSign, secret);
|
|
427
432
|
|
|
428
433
|
return Object.assign(objToSign, {
|
|
@@ -443,11 +448,15 @@ class BaseStorage {
|
|
|
443
448
|
|
|
444
449
|
entries.sort();
|
|
445
450
|
|
|
451
|
+
const objectClone = typeof structuredClone === 'function'
|
|
452
|
+
? (val) => structuredClone(val)
|
|
453
|
+
: (val) => JSON.parse(JSON.stringify(val, signReplacer));
|
|
454
|
+
|
|
446
455
|
// @ts-ignore
|
|
447
456
|
return entries.reduce((o, key) => {
|
|
448
457
|
let val = object[key];
|
|
449
|
-
if (val
|
|
450
|
-
val = val
|
|
458
|
+
if (val !== null && typeof val === 'object') {
|
|
459
|
+
val = objectClone(val);
|
|
451
460
|
}
|
|
452
461
|
return Object.assign(o, { [key]: val });
|
|
453
462
|
}, {});
|