* chore(node): upgrade to version 12

* update package-lock.json

* upgrade bcrypt

* upgrade node-sass

* update deps

* fix deprecation

* downgrade amplitude

* fix client side tests

* fix common and integration tests, upgrade mongoose
This commit is contained in:
Matteo Pagliazzi
2019-08-19 22:43:17 +02:00
committed by GitHub
parent 8b5129cd4f
commit e621e781ed
9 changed files with 3654 additions and 2479 deletions

View File

@@ -37,6 +37,23 @@ export const taskIsGroupOrChallengeQuery = {
],
};
const reminderSchema = new Schema({
_id: false,
id: {$type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], default: shared.uuid, required: true},
startDate: {$type: Date},
time: {$type: Date, required: true},
}, {
strict: true,
minimize: false, // So empty objects are returned
_id: false,
typeKey: '$type', // So that we can use a field named `type`
});
reminderSchema.plugin(baseModel, {
noSet: ['_id', 'id'],
_id: false,
});
// Important
// When something changes here remember to update the client side model at common/script/libs/taskDefaults
export let TaskSchema = new Schema({
@@ -57,20 +74,14 @@ export let TaskSchema = new Schema({
},
msg: 'Task short names cannot be uuids.',
}, {
validator (alias) {
return new Promise((resolve, reject) => {
Task.findOne({ // eslint-disable-line no-use-before-define
_id: { $ne: this._id },
userId: this.userId,
alias,
}).exec().then((task) => {
let aliasAvailable = !task;
async validator (alias) {
const taskDuplicated = await Task.findOne({ // eslint-disable-line no-use-before-define
_id: { $ne: this._id },
userId: this.userId,
alias,
}).exec();
return aliasAvailable ? resolve() : reject();
}).catch(() => {
reject();
});
});
return taskDuplicated ? false : true;
},
msg: 'Task alias already used on another task.',
}],
@@ -116,12 +127,7 @@ export let TaskSchema = new Schema({
sharedCompletion: {$type: String, enum: _.values(SHARED_COMPLETION), default: SHARED_COMPLETION.single},
},
reminders: [{
_id: false,
id: {$type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], default: shared.uuid, required: true},
startDate: {$type: Date},
time: {$type: Date, required: true},
}],
reminders: [reminderSchema],
}, _.defaults({
minimize: false, // So empty objects are returned
strict: true,