not-node 6.5.22 → 6.5.24
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/generic/logic.js +2 -2
- package/src/generic/route.js +2 -2
- package/src/logic/actions/index.js +3 -0
- package/src/logic/actions/standart.own.js +18 -0
- package/src/logic/actions.before/ownage/ownage.js +3 -34
- package/src/logic/actions.before/standart.queries.js +34 -0
- package/src/logic/generic.js +1 -1
package/package.json
CHANGED
package/src/generic/logic.js
CHANGED
|
@@ -321,12 +321,12 @@ module.exports = ({
|
|
|
321
321
|
* @param {import('../types').PreparedData} prepared
|
|
322
322
|
* @returns {Promise<Object>} requested document
|
|
323
323
|
**/
|
|
324
|
-
static async
|
|
324
|
+
static async getRawOwn({ targetId, identity }) {
|
|
325
325
|
return await this._getOneRaw({
|
|
326
326
|
targetId,
|
|
327
327
|
identity,
|
|
328
328
|
shouldOwn: true,
|
|
329
|
-
action: "
|
|
329
|
+
action: "getRawOwn",
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
|
package/src/generic/route.js
CHANGED
|
@@ -76,14 +76,14 @@ module.exports = ({ getLogic, before, after }) => {
|
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
78
|
if (this.rootAsUser) {
|
|
79
|
-
return await getLogic(prepared).
|
|
79
|
+
return await getLogic(prepared).getRawOwn(prepared);
|
|
80
80
|
} else {
|
|
81
81
|
return await getLogic(prepared).getRaw(prepared);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
static async getRaw(req, res, next, prepared) {
|
|
86
|
-
return await getLogic(prepared).
|
|
86
|
+
return await getLogic(prepared).getRawOwn(prepared);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
static async _update(req, res, next, prepared) {
|
|
@@ -3,6 +3,9 @@ const ActionsSetsLibrary = require("../actions.lib");
|
|
|
3
3
|
let actionsSetsLibrary = new ActionsSetsLibrary();
|
|
4
4
|
|
|
5
5
|
actionsSetsLibrary.add("standart", require("./standart"));
|
|
6
|
+
|
|
7
|
+
actionsSetsLibrary.add("standartOwn", require("./standart.own"));
|
|
8
|
+
|
|
6
9
|
actionsSetsLibrary.add("increment", require("./increment"));
|
|
7
10
|
|
|
8
11
|
module.exports = actionsSetsLibrary;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Duplicates standart set with names postpended with 'Own'
|
|
3
|
+
* Work with:
|
|
4
|
+
* beforeActionsOnCondition = [
|
|
5
|
+
* require("./actions.before/ownage/ownage.js").ifActionNameEndsWith_Own(),
|
|
6
|
+
* ],
|
|
7
|
+
* It modifies filtering queries before actions with names ended with 'Own'
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const standartSet = require("./standart");
|
|
11
|
+
|
|
12
|
+
const standartOwnSet = {};
|
|
13
|
+
Object.keys(standartSet).forEach((actionName) => {
|
|
14
|
+
standartOwnSet[`${actionName}Own`] = standartSet[actionName];
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
Object.freeze(standartOwnSet);
|
|
18
|
+
module.exports = standartOwnSet;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const notFilter = require("not-filter");
|
|
2
1
|
const {
|
|
3
2
|
DOCUMENT_OWNER_FIELD_NAME,
|
|
4
3
|
DOCUMENT_SESSION_FIELD_NAME,
|
|
@@ -6,7 +5,8 @@ const {
|
|
|
6
5
|
const {
|
|
7
6
|
OwnageExceptionIdentityUserIdIsNotDefined,
|
|
8
7
|
} = require("../../../exceptions/action.js");
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
const StandartQueriesBeforeAction = require("../standart.queries.js");
|
|
10
10
|
|
|
11
11
|
//checks that
|
|
12
12
|
module.exports = class OwnageBeforeAction {
|
|
@@ -21,37 +21,6 @@ module.exports = class OwnageBeforeAction {
|
|
|
21
21
|
return this.#sessionFieldName;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
static setOwnage(logic, actionName, args, ownageFilter) {
|
|
25
|
-
const { query, targetId, targetID } = args;
|
|
26
|
-
let { filter, search } = query;
|
|
27
|
-
if (filter) {
|
|
28
|
-
filter = notFilter.filter.modifyRules(filter, ownageFilter);
|
|
29
|
-
if (search) {
|
|
30
|
-
search = notFilter.filter.modifyRules(search, filter);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
args.defaultQueryById = {
|
|
34
|
-
_id: targetId,
|
|
35
|
-
...ownageFilter,
|
|
36
|
-
};
|
|
37
|
-
const Model = logic.getModel();
|
|
38
|
-
const incFieldName = ModelRoutine.incremental(Model);
|
|
39
|
-
if (incFieldName) {
|
|
40
|
-
args.defaultQueryByID = {
|
|
41
|
-
[incFieldName]: targetID,
|
|
42
|
-
...ownageFilter,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
args.defaultQueryMany = {
|
|
47
|
-
...ownageFilter,
|
|
48
|
-
};
|
|
49
|
-
//mark data as owned by
|
|
50
|
-
if (typeof args.data == "object" && args.data) {
|
|
51
|
-
Object.assign(args.data, ownageFilter);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
24
|
static createOwnageFilterForUser(identity) {
|
|
56
25
|
return Object.freeze({
|
|
57
26
|
[OwnageBeforeAction.ownerFieldName]: identity.uid,
|
|
@@ -105,7 +74,7 @@ module.exports = class OwnageBeforeAction {
|
|
|
105
74
|
args.identity
|
|
106
75
|
);
|
|
107
76
|
}
|
|
108
|
-
|
|
77
|
+
StandartQueriesBeforeAction.modifyQueries(args, ownageFilter);
|
|
109
78
|
}
|
|
110
79
|
|
|
111
80
|
static ifActionNameEndsWith_Own() {
|
|
@@ -1,7 +1,41 @@
|
|
|
1
|
+
const notFilter = require("not-filter");
|
|
1
2
|
const ModelRoutine = require("../../model/routine.js");
|
|
2
3
|
|
|
3
4
|
//adds to args object few basic queries
|
|
4
5
|
module.exports = class StandartQueriesBeforeAction {
|
|
6
|
+
static modifyQueries(args, modificationFilter) {
|
|
7
|
+
const { query } = args;
|
|
8
|
+
let { filter, search } = query;
|
|
9
|
+
if (filter) {
|
|
10
|
+
filter = notFilter.filter.modifyRules(filter, modificationFilter);
|
|
11
|
+
if (search) {
|
|
12
|
+
search = notFilter.filter.modifyRules(search, filter);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (args.defaultQueryById) {
|
|
16
|
+
args.defaultQueryById = notFilter.filter.modifyRules(
|
|
17
|
+
args.defaultQueryById,
|
|
18
|
+
modificationFilter
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (args.defaultQueryByID) {
|
|
22
|
+
args.defaultQueryByID = notFilter.filter.modifyRules(
|
|
23
|
+
args.defaultQueryByID,
|
|
24
|
+
modificationFilter
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
args.defaultQueryMany = notFilter.filter.modifyRules(
|
|
29
|
+
args.defaultQueryMany,
|
|
30
|
+
modificationFilter
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
//mark data as owned by
|
|
34
|
+
if (typeof args.data == "object" && args.data) {
|
|
35
|
+
Object.assign(args.data, modificationFilter);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
5
39
|
static async run(logic, actionName, args) {
|
|
6
40
|
try {
|
|
7
41
|
const { targetId, targetID } = args;
|
package/src/logic/generic.js
CHANGED