not-node 6.2.18 → 6.2.20
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/.husky/pre-commit +4 -0
- package/package.json +7 -4
- package/src/auth/roles.js +9 -1
- package/src/auth/rules.js +5 -5
- package/src/cli/actions/env.mjs +1 -1
- package/src/cli/actions/nginx.mjs +1 -1
- package/src/cli/actions/pm2.mjs +1 -1
- package/src/common.js +1 -1
- package/src/domain.js +36 -24
- package/src/form/env_extractors/index.js +2 -2
- package/src/form/extractors/index.js +1 -1
- package/src/identity/providers/session.js +3 -0
- package/src/manifest/batchRunner.js +5 -1
- package/src/manifest/registrator/fields.js +4 -4
- package/src/manifest/route.js +9 -0
- package/src/model/exceptions.js +3 -3
- package/src/model/versioning.js +2 -2
- package/test/auth/routes.js +34 -10
- package/test/fakes.js +52 -0
- package/test/identity/providers/session.js +14 -5
- package/test/identity/providers/token.js +1 -1
- package/test/init/additional.js +31 -33
- package/test/init/app.js +66 -10
- package/test/init/bodyparser.js +4 -1
- package/test/init/compression.js +4 -1
- package/test/init/cors.js +5 -1
- package/test/init/csp.js +2 -2
- package/test/init/db.js +5 -1
- package/test/init/env.js +12 -2
- package/test/init/express.js +4 -1
- package/test/init/fileupload.js +4 -1
- package/test/init/http.js +21 -4
- package/test/init/middleware.js +13 -1
- package/test/init/routes.js +1 -0
- package/test/init/sessions/mongoose.js +5 -1
- package/test/init/sessions/redis.js +5 -1
- package/test/init/sessions.js +21 -15
- package/test/init/static.js +4 -1
- package/test/init/template.js +5 -1
- package/test/model/versioning.js +3 -3
- package/test/module/fields.js +45 -20
- package/test/module/index.js +26 -15
- package/test/notApp.js +221 -187
- package/test/notDomain.js +799 -707
- package/test/notManifestFilter.js +385 -322
- package/test/notModule.js +689 -644
- package/test/notRoute.js +112 -99
- package/test/testies/module/fields/collection.js +16 -14
- package/test/testies/module/fields/single.js +11 -11
- package/tmpl/files/module.server/layers/forms/_data.ejs +29 -29
- package/tmpl/files/module.server/layers/forms/create.ejs +38 -38
- package/tmpl/files/module.server/layers/forms/listAll.ejs +3 -3
- package/tmpl/files/module.server/layers/forms/listAndCount.ejs +3 -3
- package/tmpl/files/module.server/layers/forms/update.ejs +31 -31
|
@@ -3,38 +3,38 @@ const Form = require("not-node").Form;
|
|
|
3
3
|
const getIP = require("not-node").Auth.getIP;
|
|
4
4
|
|
|
5
5
|
const FIELDS = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
["targetId", { required: true }, "not-node//objectId"],
|
|
7
|
+
["activeUser", "not-node//requiredObject"],
|
|
8
|
+
["data", `${MODULE_NAME}//_<%- ModelName %>_data`], //sub forms validators should start with underscore
|
|
9
9
|
["ip", "not-node//ip"],
|
|
10
|
-
];
|
|
11
|
-
const FORM_NAME = `${
|
|
10
|
+
];
|
|
11
|
+
const FORM_NAME = `${MODULE_NAME}:<%- ModelName %>UpdateForm`;
|
|
12
12
|
|
|
13
|
-
module.exports = class <%- ModelName %>UpdateForm extends Form {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
module.exports = class <%- ModelName %>UpdateForm extends Form {
|
|
14
|
+
constructor({ app }) {
|
|
15
|
+
super({ FIELDS, FORM_NAME, app });
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
extract(req) {
|
|
19
|
+
const instructions = {
|
|
20
20
|
<% if (fields && Array.isArray(fields)) { %>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
21
|
+
<% for(let field of fields){ %>
|
|
22
|
+
<%- field+': "extractFromBody" ,' -%>
|
|
23
|
+
<% } %>
|
|
24
|
+
<% } %>
|
|
25
|
+
owner: "fromBody",
|
|
26
|
+
ownerModel: "fromBody",
|
|
27
|
+
};
|
|
28
|
+
const data = this.extractByInstructions(req, instructions);
|
|
29
|
+
if (!req.user.isRoot() && !req.user.isAdmin()) {
|
|
30
|
+
data.owner = req.user._id;
|
|
31
|
+
data.ownerModel = "User";
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
targetId: req.params._id.toString(),
|
|
35
|
+
activeUser: req.user,
|
|
36
|
+
data,
|
|
37
|
+
ip: getIP(req),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|