not-node 5.1.24 → 5.1.27
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/package.json +1 -1
- package/src/core/locales/en.json +3 -0
- package/src/core/locales/ru.json +3 -0
- package/src/exceptions/db.js +12 -0
- package/src/generic/logic.js +20 -0
- package/src/model/default.js +5 -0
- package/src/model/routine.js +9 -4
package/package.json
CHANGED
package/src/core/locales/en.json
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
"list_navigation_next_button_label": "Next",
|
|
7
7
|
"button_cancel_label": "Cancel",
|
|
8
8
|
"button_apply_label": "Apply",
|
|
9
|
+
"action_details_label": "Details",
|
|
10
|
+
"action_update_label": "Update",
|
|
11
|
+
"action_delete_label": "Delete",
|
|
9
12
|
"field_select_label": "Select",
|
|
10
13
|
"field_value_is_empty_placeholder": "Empty",
|
|
11
14
|
"loading_label": "Loading...",
|
package/src/core/locales/ru.json
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"loading_label": "Загрузка...",
|
|
12
12
|
"button_cancel_label": "Отмена",
|
|
13
13
|
"button_apply_label": "Применить",
|
|
14
|
+
"action_details_label": "Подробнее",
|
|
15
|
+
"action_update_label": "Изменить",
|
|
16
|
+
"action_delete_label": "Удалить",
|
|
14
17
|
"form_validation_error": "Форма заполнена с ошибками",
|
|
15
18
|
"field_active_label": "Активна",
|
|
16
19
|
"field_codeName_label": "Псевдоним",
|
package/src/exceptions/db.js
CHANGED
|
@@ -28,3 +28,15 @@ class DBExceptionDocumentIsNotFound extends notRequestError {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
module.exports.DBExceptionDocumentIsNotFound = DBExceptionDocumentIsNotFound;
|
|
31
|
+
|
|
32
|
+
class DBExceptionUpdateOneWasNotSuccessful extends notRequestError {
|
|
33
|
+
constructor({ params = {}, cause = null } = {}) {
|
|
34
|
+
super(
|
|
35
|
+
"DB Update One Was Not Successful",
|
|
36
|
+
{ code: 505, ...params },
|
|
37
|
+
cause
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
module.exports.DBExceptionUpdateOneWasNotSuccessful =
|
|
42
|
+
DBExceptionUpdateOneWasNotSuccessful;
|
package/src/generic/logic.js
CHANGED
|
@@ -536,6 +536,26 @@ module.exports = ({
|
|
|
536
536
|
return result;
|
|
537
537
|
}
|
|
538
538
|
|
|
539
|
+
static async listAll({ activeUser, ip, root }) {
|
|
540
|
+
return await this._listAll({
|
|
541
|
+
activeUser,
|
|
542
|
+
ip,
|
|
543
|
+
root,
|
|
544
|
+
action: "listAll",
|
|
545
|
+
shouldOwn: false,
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
static async listAllOwn({ activeUser, ip, root }) {
|
|
550
|
+
return await this._listAll({
|
|
551
|
+
activeUser,
|
|
552
|
+
ip,
|
|
553
|
+
root,
|
|
554
|
+
action: "listAllOwn",
|
|
555
|
+
shouldOwn: true,
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
|
|
539
559
|
static async _listAndCount({
|
|
540
560
|
query,
|
|
541
561
|
activeUser,
|
package/src/model/default.js
CHANGED
|
@@ -383,7 +383,12 @@ function close() {
|
|
|
383
383
|
return this.save();
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
+
function saveNewVersion() {
|
|
387
|
+
return routine.update(this, { _id: this._id }, this.toObject());
|
|
388
|
+
}
|
|
389
|
+
|
|
386
390
|
module.exports.thisMethods = {
|
|
387
391
|
getID,
|
|
388
392
|
close,
|
|
393
|
+
saveNewVersion,
|
|
389
394
|
};
|
package/src/model/routine.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** @module Model/Routine */
|
|
2
2
|
|
|
3
3
|
const incrementNext = require("./increment");
|
|
4
|
-
|
|
4
|
+
const { DBExceptionUpdateOneWasNotSuccessful } = require("../exceptions/db");
|
|
5
|
+
const { updateResponseSuccess } = require("./utils");
|
|
5
6
|
class ModelRoutine {
|
|
6
7
|
static incremental(model) {
|
|
7
8
|
return model.schema.statics.__incField;
|
|
@@ -63,10 +64,14 @@ class ModelRoutine {
|
|
|
63
64
|
static async updateWithVersion(model, filter, data) {
|
|
64
65
|
filter.__latest = true;
|
|
65
66
|
filter.__closed = false;
|
|
66
|
-
const
|
|
67
|
-
.
|
|
67
|
+
const result = await model
|
|
68
|
+
.updateOne(filter, data, { returnOriginal: false })
|
|
68
69
|
.exec();
|
|
69
|
-
|
|
70
|
+
if (updateResponseSuccess(result, 1)) {
|
|
71
|
+
return model.saveVersion(filter._id);
|
|
72
|
+
} else {
|
|
73
|
+
throw new DBExceptionUpdateOneWasNotSuccessful();
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
static async updateMany(model, filter, data) {
|