build(deps): bump mongodb from 4.7.0 to 4.8.0
MODIFY
package-lock.json
package-lock.json
"moment-timezone": "^0.5.34",
"mongo-sanitize": "^1.1.0",
"mongo-uri-builder": "^4.0.0",
- "mongodb": "^4.7.0",
+ "mongodb": "^4.8.0",
"morgan": "^1.10.0",
"mustache": "^4.2.0",
"nanoid": "^3.2.0",
}
},
"node_modules/bson": {
- "version": "4.6.4",
- "resolved": "https://registry.npmjs.org/bson/-/bson-4.6.4.tgz",
- "integrity": "sha512-TdQ3FzguAu5HKPPlr0kYQCyrYUYh8tFM+CMTpxjNzVzxeiJY00Rtuj3LXLHSgiGvmaWlZ8PE+4KyM2thqE38pQ==",
+ "version": "4.6.5",
+ "resolved": "https://registry.npmjs.org/bson/-/bson-4.6.5.tgz",
+ "integrity": "sha512-uqrgcjyOaZsHfz7ea8zLRCLe1u+QGUSzMZmvXqO24CDW7DWoW1qiN9folSwa7hSneTSgM2ykDIzF5kcQQ8cwNw==",
"dependencies": {
"buffer": "^5.6.0"
},
}
},
"node_modules/mongodb": {
- "version": "4.7.0",
- "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.7.0.tgz",
- "integrity": "sha512-HhVar6hsUeMAVlIbwQwWtV36iyjKd9qdhY+s4wcU8K6TOj4Q331iiMy+FoPuxEntDIijTYWivwFJkLv8q/ZgvA==",
+ "version": "4.8.0",
+ "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.8.0.tgz",
+ "integrity": "sha512-a0eVzm1e1kxwnzJV1wZXIS54KegM2y6wXTXOGTSAxr/E2YOUkl/zGBHNSI4z+6z+YQtVdzDqy1nJ4n5MxYJRnQ==",
"dependencies": {
- "bson": "^4.6.3",
+ "bson": "^4.6.5",
"denque": "^2.0.1",
"mongodb-connection-string-url": "^2.5.2",
"socks": "^2.6.2"
}
},
"bson": {
- "version": "4.6.4",
- "resolved": "https://registry.npmjs.org/bson/-/bson-4.6.4.tgz",
- "integrity": "sha512-TdQ3FzguAu5HKPPlr0kYQCyrYUYh8tFM+CMTpxjNzVzxeiJY00Rtuj3LXLHSgiGvmaWlZ8PE+4KyM2thqE38pQ==",
+ "version": "4.6.5",
+ "resolved": "https://registry.npmjs.org/bson/-/bson-4.6.5.tgz",
+ "integrity": "sha512-uqrgcjyOaZsHfz7ea8zLRCLe1u+QGUSzMZmvXqO24CDW7DWoW1qiN9folSwa7hSneTSgM2ykDIzF5kcQQ8cwNw==",
"requires": {
"buffer": "^5.6.0"
},
"integrity": "sha512-zkZQtutNRzcMfY09Scl7iP0CcJjUIDQObX77K5TP2oidHDnQ0SjNP3nsBlpLIruVE0OSZ3I10yhKaf9nVNvvwA=="
},
"mongodb": {
- "version": "4.7.0",
- "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.7.0.tgz",
- "integrity": "sha512-HhVar6hsUeMAVlIbwQwWtV36iyjKd9qdhY+s4wcU8K6TOj4Q331iiMy+FoPuxEntDIijTYWivwFJkLv8q/ZgvA==",
+ "version": "4.8.0",
+ "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.8.0.tgz",
+ "integrity": "sha512-a0eVzm1e1kxwnzJV1wZXIS54KegM2y6wXTXOGTSAxr/E2YOUkl/zGBHNSI4z+6z+YQtVdzDqy1nJ4n5MxYJRnQ==",
"requires": {
- "bson": "^4.6.3",
+ "bson": "^4.6.5",
"denque": "^2.0.1",
"mongodb-connection-string-url": "^2.5.2",
"saslprep": "^1.0.3",

MODIFY
package.json
package.json
"moment-timezone": "^0.5.34",
"mongo-sanitize": "^1.1.0",
"mongo-uri-builder": "^4.0.0",
- "mongodb": "^4.7.0",
+ "mongodb": "^4.8.0",
"morgan": "^1.10.0",
"mustache": "^4.2.0",
"nanoid": "^3.2.0",

MODIFY
src/migration/tasks/OCPIEndpointCleanUpTask.ts
src/migration/tasks/OCPIEndpointCleanUpTask.ts
@@ -6,7 +6,7 @@ export default class OCPIEndpointCleanUpTask extends TenantMigrationTask {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public async migrateTenant(tenant: Tenant) {
// Clean up
- await global.database.getCollection(tenant.id, 'ocpiendpoints').updateMany(
+ await global.database.getCollection<any>(tenant.id, 'ocpiendpoints').updateMany(
{}, { $unset: { lastPatchJobOn: '', lastPatchJobResult: '' } });
}

MODIFY
src/migration/tasks/RemoveLogoFromTenantTask.ts
src/migration/tasks/RemoveLogoFromTenantTask.ts
@@ -5,7 +5,7 @@ import global from '../../types/GlobalType';
export default class RemoveLogoFromTenantTask extends MigrationTask {
public async migrate() {
// Clean up
- await global.database.getCollection(Constants.DEFAULT_TENANT_ID, 'tenants').updateMany(
+ await global.database.getCollection<any>(Constants.DEFAULT_TENANT_ID, 'tenants').updateMany(
{},
{ $unset: { logo: '' } }
);

MODIFY
src/migration/tasks/UserCleanUpTask.ts
src/migration/tasks/UserCleanUpTask.ts
@@ -6,7 +6,7 @@ export default class UserCleanUpTask extends TenantMigrationTask {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public async migrateTenant(tenant: Tenant) {
// Clean up
- await global.database.getCollection(tenant.id, 'users').updateMany(
+ await global.database.getCollection<any>(tenant.id, 'users').updateMany(
{}, { $unset: { lastSelectedCarID: '', lastSelectedCar: '' } });
}

MODIFY
src/scheduler/tasks/LoggingDatabaseTableCleanupTask.ts
src/scheduler/tasks/LoggingDatabaseTableCleanupTask.ts
@@ -3,8 +3,8 @@ import { LoggingDatabaseTableCleanupTaskConfig, TaskConfig } from '../../types/T
import Constants from '../../utils/Constants';
import { LockEntity } from '../../types/Locking';
import LockingManager from '../../locking/LockingManager';
-import Logging from '../../utils/Logging';
import LogStorage from '../../storage/mongodb/LogStorage';
+import Logging from '../../utils/Logging';
import PerformanceStorage from '../../storage/mongodb/PerformanceStorage';
import { ServerAction } from '../../types/Server';
import Tenant from '../../types/Tenant';
@@ -32,7 +32,7 @@ export default class LoggingDatabaseTableCleanupTask extends TenantSchedulerTask
const logsCleanUpLock = LockingManager.createExclusiveLock(tenant.id, LockEntity.LOG, 'cleanup');
if (await LockingManager.acquire(logsCleanUpLock)) {
try {
- const lastLogMDB = global.database.getCollection(tenant.id, 'logs').find({})
+ const lastLogMDB = global.database.getCollection<any>(tenant.id, 'logs').find({})
.sort({ timestamp: -1 })
.skip(10 * 1000 * 1000)
.limit(1)
@@ -75,7 +75,7 @@ export default class LoggingDatabaseTableCleanupTask extends TenantSchedulerTask
const performanceCleanUpLock = LockingManager.createExclusiveLock(tenant.id, LockEntity.PERFORMANCE, 'cleanup');
if (await LockingManager.acquire(performanceCleanUpLock)) {
try {
- const lastLogMDB = global.database.getCollection(tenant.id, 'performances').find({})
+ const lastLogMDB = global.database.getCollection<any>(tenant.id, 'performances').find({})
.sort({ timestamp: -1 })
.skip(25 * 1000 * 1000)
.limit(1)

MODIFY
src/storage/mongodb/CarStorage.ts
src/storage/mongodb/CarStorage.ts
@@ -165,7 +165,7 @@ export default class CarStorage {
public static async deleteCarCatalogImages(id: number): Promise<void> {
const startTime = Logging.traceDatabaseRequestStart();
// Delete car catalogs images
- await global.database.getCollection(Constants.DEFAULT_TENANT_ID, 'carcatalogimages').deleteMany(
+ await global.database.getCollection<any>(Constants.DEFAULT_TENANT_ID, 'carcatalogimages').deleteMany(
{ carID: id }
);
await Logging.traceDatabaseRequestEnd(Constants.DEFAULT_TENANT_OBJECT, MODULE_NAME, 'deleteCarImages', startTime, { carID: id });
@@ -553,7 +553,7 @@ export default class CarStorage {
public static async deleteCar(tenant: Tenant, carID: string): Promise<void> {
const startTime = Logging.traceDatabaseRequestStart();
// Delete singular site area
- await global.database.getCollection(tenant.id, 'cars')
+ await global.database.getCollection<any>(tenant.id, 'cars')
.deleteOne({ '_id': DatabaseUtils.convertToObjectID(carID) });
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'deleteCar', startTime, { carID });
}

MODIFY
src/storage/mongodb/OCPPStorage.ts
src/storage/mongodb/OCPPStorage.ts
@@ -25,7 +25,7 @@ export default class OCPPStorage {
timezone: authorize.timezone
};
// Insert
- await global.database.getCollection(tenant.id, 'authorizes')
+ await global.database.getCollection<any>(tenant.id, 'authorizes')
.insertOne(authorizeMDB);
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'saveAuthorize', startTime, authorizeMDB);
}
@@ -105,7 +105,7 @@ export default class OCPPStorage {
timestamp: timestamp,
timezone: heartbeat.timezone
};
- await global.database.getCollection(tenant.id, 'heartbeats')
+ await global.database.getCollection<any>(tenant.id, 'heartbeats')
.insertOne(heartBeatMDB);
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'saveHeartbeat', startTime, heartBeatMDB);
}
@@ -244,7 +244,7 @@ export default class OCPPStorage {
vendorErrorCode: statusNotificationToSave.vendorErrorCode
};
// Insert
- await global.database.getCollection(tenant.id, 'statusnotifications')
+ await global.database.getCollection<any>(tenant.id, 'statusnotifications')
.insertOne(statusNotificationMDB);
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'saveStatusNotification', startTime, statusNotificationMDB);
}
@@ -263,7 +263,7 @@ export default class OCPPStorage {
timestamp: timestamp,
timezone: dataTransfer.timezone
};
- await global.database.getCollection(tenant.id, 'datatransfers')
+ await global.database.getCollection<any>(tenant.id, 'datatransfers')
.insertOne(dataTransferMDB);
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'saveDataTransfer', startTime, dataTransferMDB);
}
@@ -286,7 +286,7 @@ export default class OCPPStorage {
endpoint: bootNotification.endpoint,
timestamp: timestamp
};
- await global.database.getCollection(tenant.id, 'bootnotifications')
+ await global.database.getCollection<any>(tenant.id, 'bootnotifications')
.insertOne(bootNotificationMDB);
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'saveBootNotification', startTime, bootNotificationMDB);
}
@@ -361,7 +361,7 @@ export default class OCPPStorage {
timestamp: timestamp,
timezone: diagnosticsStatusNotification.timezone
};
- await global.database.getCollection(tenant.id, 'diagnosticsstatusnotifications')
+ await global.database.getCollection<any>(tenant.id, 'diagnosticsstatusnotifications')
.insertOne(diagnosticsStatusNotificationMDB);
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'saveDiagnosticsStatusNotification', startTime, diagnosticsStatusNotificationMDB);
}
@@ -378,7 +378,7 @@ export default class OCPPStorage {
timestamp: timestamp,
timezone: firmwareStatusNotification.timezone
};
- await global.database.getCollection(tenant.id, 'firmwarestatusnotifications')
+ await global.database.getCollection<any>(tenant.id, 'firmwarestatusnotifications')
.insertOne(firmwareStatusNotificationMDB);
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'saveFirmwareStatusNotification', startTime, firmwareStatusNotificationMDB);
}
@@ -399,7 +399,7 @@ export default class OCPPStorage {
attribute: meterValueToSave.attribute,
};
// Execute
- await global.database.getCollection(tenant.id, 'metervalues').insertOne(meterValueMDB);
+ await global.database.getCollection<any>(tenant.id, 'metervalues').insertOne(meterValueMDB);
}
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'saveMeterValues', startTime, meterValuesToSave);
}

MODIFY
src/storage/mongodb/PerformanceStorage.ts
src/storage/mongodb/PerformanceStorage.ts
@@ -21,7 +21,7 @@ export default class PerformanceStorage {
// Validate
performanceRecord = PerformanceValidatorStorage.getInstance().validatePerformance(performanceRecord);
// Insert
- const result = await global.database.getCollection(Constants.DEFAULT_TENANT_ID, 'performances')
+ const result = await global.database.getCollection<any>(Constants.DEFAULT_TENANT_ID, 'performances')
.insertOne(performanceRecord);
// Set
performanceRecord.id = result.insertedId.toString();
@@ -37,7 +37,7 @@ export default class PerformanceStorage {
// Convert to ObjectID
DatabaseUtils.switchIDToMongoDBID(performanceRecordMDB);
// Update
- await global.database.getCollection(Constants.DEFAULT_TENANT_ID, 'performances').findOneAndUpdate(
+ await global.database.getCollection<PerformanceRecord>(Constants.DEFAULT_TENANT_ID, 'performances').findOneAndUpdate(
{ _id: performanceRecordMDB['_id'] },
{ $set: performanceRecordMDB },
{ upsert: true, returnDocument: 'after' }

MODIFY
src/storage/mongodb/RegistrationTokenStorage.ts
src/storage/mongodb/RegistrationTokenStorage.ts
@@ -27,7 +27,7 @@ export default class RegistrationTokenStorage {
// Add Last Changed/Created props
DatabaseUtils.addLastChangedCreatedProps(registrationTokenMDB, registrationToken);
// Modify
- await global.database.getCollection(tenant.id, 'registrationtokens').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'registrationtokens').findOneAndUpdate(
{ _id: registrationTokenMDB._id },
{ $set: registrationTokenMDB },
{ upsert: true, returnDocument: 'after' }

MODIFY
src/storage/mongodb/SiteStorage.ts
src/storage/mongodb/SiteStorage.ts
@@ -296,7 +296,7 @@ export default class SiteStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Modify
- await global.database.getCollection(tenant.id, 'siteimages').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'siteimages').findOneAndUpdate(
{ _id: DatabaseUtils.convertToObjectID(siteID) },
{ $set: { image: siteImageToSave } },
{ upsert: true, returnDocument: 'after' }

MODIFY
src/storage/mongodb/TenantStorage.ts
src/storage/mongodb/TenantStorage.ts
@@ -45,9 +45,9 @@ export default class TenantStorage {
// Add Last Changed/Created props
DatabaseUtils.addLastChangedCreatedProps(tenantMDB, tenantToSave);
// Modify
- await global.database.getCollection<any>(Constants.DEFAULT_TENANT_ID, 'tenants').findOneAndUpdate(
+ await global.database.getCollection<Tenant>(Constants.DEFAULT_TENANT_ID, 'tenants').findOneAndUpdate(
{ _id: tenantMDB['_id'] },
- { $set: tenantMDB },
+ { $set: { ...tenantMDB } },
{ upsert: true, returnDocument: 'after' });
// Save Logo
if (saveLogo) {

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -483,11 +483,11 @@ export default class UserStorage {
}
};
// Modify and return the modified document
- await global.database.getCollection(tenant.id, 'users').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'users').findOneAndUpdate(
{ '_id': DatabaseUtils.convertToObjectID(userID) },
{ $set: updatedUserMDB });
} else {
- await global.database.getCollection(tenant.id, 'users').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'users').findOneAndUpdate(
{ '_id': DatabaseUtils.convertToObjectID(userID) },
{ $unset: { billingData: '' } }); // This removes the field from the document
}

build(deps): bump mongodb from 4.7.0 to 4.8.0