New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wingbot-mongodb

Package Overview
Dependencies
Maintainers
2
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wingbot-mongodb - npm Package Compare versions

Comparing version 3.2.6 to 4.0.0-alpha.1

.nyc_output/c5005d32-ad45-472c-811c-860ccef899fe.json

2

.nyc_output/processinfo/index.json

@@ -1,1 +0,1 @@

{"processes":{"1091dc07-773b-48f1-9817-b8048f05d575":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"]},"externalIds":{}}
{"processes":{"c5005d32-ad45-472c-811c-860ccef899fe":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["c5005d32-ad45-472c-811c-860ccef899fe"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["c5005d32-ad45-472c-811c-860ccef899fe"],"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["c5005d32-ad45-472c-811c-860ccef899fe"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["c5005d32-ad45-472c-811c-860ccef899fe"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["c5005d32-ad45-472c-811c-860ccef899fe"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["c5005d32-ad45-472c-811c-860ccef899fe"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["c5005d32-ad45-472c-811c-860ccef899fe"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["c5005d32-ad45-472c-811c-860ccef899fe"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["c5005d32-ad45-472c-811c-860ccef899fe"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["c5005d32-ad45-472c-811c-860ccef899fe"]},"externalIds":{}}
{
"name": "wingbot-mongodb",
"version": "3.2.6",
"version": "4.0.0-alpha.1",
"description": "MongoDB storage for wingbot.ai",

@@ -30,3 +30,3 @@ "main": "src/main.js",

"engines": {
"node": ">=12.0.0"
"node": ">=14.0.0"
},

@@ -49,3 +49,3 @@ "bugs": {

"mocha": "^10.1.0",
"mongodb": "^4.12.1",
"mongodb": "^6.1.0",
"nyc": "^15.1.0",

@@ -55,3 +55,3 @@ "wingbot": "^3.46.3"

"peerDependencies": {
"mongodb": "^4.0.0"
"mongodb": "^6.0.0"
},

@@ -58,0 +58,0 @@ "optionalDependencies": {

@@ -7,2 +7,3 @@ /**

const { ObjectId } = require('mongodb');
const { default: assert } = require('assert');
const crypto = require('crypto');

@@ -134,2 +135,5 @@ const defaultLogger = require('./defaultLogger');

}
this._indexing = null;
this._shouldIndexBeforeRead = null;
}

@@ -183,3 +187,3 @@

*
* @param {...any} objects
* @param {...{ _id: string|number|ObjectId }} objects
*/

@@ -262,4 +266,14 @@ addFixtureDoc (...objects) {

await this._ensureIndexes(this._indexes, collection);
this._shouldIndexBeforeRead = this._fixtures.length !== 0;
this._indexing = this._ensureIndexes(this._indexes, collection)
.then(() => {
this._indexing = false;
})
.catch((e) => {
this._collection = null;
this._log.log(`DB.${this._collectionName} - init failed`, e);
return e;
});
return collection;

@@ -272,5 +286,6 @@ }

* @protected
* @param {boolean} [forRead]
* @returns {Promise<Collection>}
*/
async _getCollection () {
async _getCollection (forRead = false) {
if (this._collection === null) {

@@ -288,2 +303,9 @@ let c;

}
if (this._indexing && (!forRead || this._shouldIndexBeforeRead)) {
const err = await this._indexing;
this._indexing = false;
if (err) throw err;
}
return this._collection;

@@ -299,8 +321,6 @@ }

async _ensureIndexes (indexes, collection) {
let existing;
try {
existing = await collection.indexes();
} catch (e) {
existing = [];
}
const [existing, fixtures] = await Promise.all([
this._checkExistingIndexes(collection),
this._checkFixtures(collection)
]);

@@ -319,3 +339,3 @@ await existing

let updated = await indexes
await indexes
.filter((i) => !existing.some((e) => e.name === i.options.name))

@@ -335,27 +355,3 @@ .reduce((p, i) => {

if (!updated) {
updated = existing.every((i) => this.systemIndexes.includes(i.name));
}
let fixtures = this._fixtures;
const $in = fixtures
.map((f) => f._id)
.filter((f) => !!f);
if (!updated && $in.length !== 0) {
const found = await collection
.find({ _id: { $in } })
.project({ _id: 1 })
.map((doc) => doc._id.toString())
.toArray();
if (found.length !== $in.length) {
updated = true;
fixtures = fixtures
.filter((f) => !f._id || !found.includes(f._id.toString()));
}
}
if (!updated || fixtures.length === 0) {
if (fixtures.length === 0) {
return;

@@ -379,2 +375,41 @@ }

async _checkExistingIndexes (collection) {
let existing;
try {
existing = await collection.indexes();
} catch (e) {
existing = [];
}
return existing;
}
async _checkFixtures (collection) {
if (this._fixtures.length === 0) {
return this._fixtures;
}
const fixtures = this._fixtures
.map((f) => {
assert(f._id, `DB.${this._collectionName} fixture must have _id property`);
return {
...f,
_id: this._id(f._id)
};
});
const $in = fixtures.map((f) => f._id);
const found = await collection
.find({ _id: { $in } })
.project({ _id: 1 })
.map((doc) => doc._id.toString())
.toArray();
if (found.length === $in.length) {
return [];
}
return fixtures.filter((f) => !found.includes(f._id.toString()));
}
/**

@@ -381,0 +416,0 @@ *

@@ -138,5 +138,2 @@ /*

// @ts-ignore
res = res.value;
// @ts-ignore
if (res.token === temporaryInsecureToken) {

@@ -143,0 +140,0 @@

@@ -406,4 +406,4 @@ /**

});
if (found.value) {
pop.push(this._mapGenericObject(found.value));
if (found) {
pop.push(this._mapGenericObject(found));
go = pop.length < limit;

@@ -502,3 +502,3 @@ } else {

return this._mapGenericObject(res.value);
return this._mapGenericObject(res);
}

@@ -595,3 +595,3 @@

return result
.map((res) => (res.value ? this._mapGenericObject(res.value) : null))
.map((res) => (res ? this._mapGenericObject(res) : null))
.filter((r) => r !== null);

@@ -630,3 +630,3 @@ }

});
ret = this._mapCampaign(res.value);
ret = this._mapCampaign(res);
} else {

@@ -691,3 +691,3 @@ const id = new ObjectId();

return this._mapCampaign(res.value);
return this._mapCampaign(res);
}

@@ -712,3 +712,3 @@

return this._mapCampaign(res.value);
return this._mapCampaign(res);
}

@@ -854,5 +854,5 @@

if (res.value) {
if (res) {
ret.push(tag);
removeWholeSubscribtion = res.value.subs.length === 0;
removeWholeSubscribtion = res.subs.length === 0;
} else {

@@ -865,4 +865,4 @@ return [];

const res = await c.findOneAndDelete({ pageId, senderId });
if (res.value) {
ret.push(...res.value.subs);
if (res) {
ret.push(...res.subs);
}

@@ -869,0 +869,0 @@ }

@@ -140,3 +140,3 @@ /*

if (this._uniqueIndexFailed && !res.value.lastInteraction) {
if (this._uniqueIndexFailed && !res.lastInteraction) {
// check if there was a locked state

@@ -159,3 +159,3 @@ const existing = await c.find({

this._log[logLevel]('StateStorage: unique index workaround DETECTED', {
v: res.value, existing, $in: $in.map((i) => i.toString())
v: res, existing, $in: $in.map((i) => i.toString())
});

@@ -169,7 +169,7 @@

} else {
this._log.log('StateStorage: unique index workaround OK', res.value);
this._log.log('StateStorage: unique index workaround OK', res);
}
}
return res.value;
return res;
}

@@ -176,0 +176,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc