not-node 6.3.61 → 6.3.63
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
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const notFilter = require("not-filter");
|
|
2
|
+
const notError = require("not-error/src/error.node.cjs");
|
|
3
|
+
|
|
4
|
+
module.exports = (prepared /*, req*/) => {
|
|
5
|
+
if (!prepared?.identity?.root && !prepared?.identity?.admin) {
|
|
6
|
+
if (prepared.identity?.uid) {
|
|
7
|
+
prepared.filter = notFilter.filter.modifyRules(prepared.filter, {
|
|
8
|
+
owner: prepared.identity.uid,
|
|
9
|
+
});
|
|
10
|
+
} else {
|
|
11
|
+
throw new notError("User identity has no uid in it", {
|
|
12
|
+
sid: prepared.identity?.sid,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return prepared;
|
|
17
|
+
};
|
|
@@ -10,25 +10,30 @@ const getApp = require("../../getApp");
|
|
|
10
10
|
module.exports = (form, req) => {
|
|
11
11
|
const MODULE_NAME = form.getModuleName();
|
|
12
12
|
const MODEL_NAME = form.getModelName(req);
|
|
13
|
+
let thisSchema;
|
|
13
14
|
if (MODEL_NAME && MODULE_NAME) {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
thisSchema = getApp().getModelSchema(`${MODULE_NAME}//${MODEL_NAME}`);
|
|
16
|
+
} else {
|
|
17
|
+
getApp().log(
|
|
18
|
+
`warning: Form '${form.FORM_NAME}' for model '${MODEL_NAME}' has no MODULE_NAME`
|
|
16
19
|
);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name: "query",
|
|
29
|
-
value: { skip, size, sorter, search, filter },
|
|
30
|
-
};
|
|
20
|
+
thisSchema = getApp().getModelSchema(`${MODEL_NAME}`);
|
|
21
|
+
}
|
|
22
|
+
if (thisSchema) {
|
|
23
|
+
let skip, size;
|
|
24
|
+
const pager = notFilter.pager.process(req), //skip,size
|
|
25
|
+
sorter = notFilter.sorter.process(req, thisSchema),
|
|
26
|
+
search = notFilter.search.process(req, thisSchema);
|
|
27
|
+
let filter = notFilter.filter.process(req, thisSchema);
|
|
28
|
+
if (pager) {
|
|
29
|
+
skip = pager.skip;
|
|
30
|
+
size = pager.size;
|
|
31
31
|
}
|
|
32
|
+
return {
|
|
33
|
+
name: "query",
|
|
34
|
+
value: { skip, size, sorter, search, filter },
|
|
35
|
+
};
|
|
32
36
|
}
|
|
37
|
+
|
|
33
38
|
return undefined;
|
|
34
39
|
};
|