not-node 5.1.9 → 5.1.10

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/index.js CHANGED
@@ -29,6 +29,7 @@ module.exports.Routine = require("./src/model/routine");
29
29
  module.exports.Common = require("./src/common");
30
30
  /** Fields library manager */
31
31
  module.exports.Fields = require("./src/fields");
32
+ module.exports.Forms = require("./src/form");
32
33
  /** Form validation template **/
33
34
  module.exports.Form = require("./src/form").Form;
34
35
  /** Form validation template fabric **/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "5.1.9",
3
+ "version": "5.1.10",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,30 @@
1
+ //DB related validation tools
2
+ const Form = require("../form/form");
3
+ const { firstLetterToUpper } = require("../common");
4
+ //not-node
5
+ const { getIP } = require("../auth");
6
+ //form
7
+ const FIELDS = [
8
+ ["targetId", { required: true }, "not-node//objectId"],
9
+ ["activeUserId", { required: true }, "not-node//objectId"],
10
+ ["activeUser", "not-node//requiredObject"],
11
+ ["ip", "not-node//ip"],
12
+ ];
13
+
14
+ module.exports = ({ MODULE_NAME, actionName }) => {
15
+ const FORM_NAME = `${MODULE_NAME}:${firstLetterToUpper(actionName)}Form`;
16
+ return class extends Form {
17
+ constructor({ app }) {
18
+ super({ FIELDS, FORM_NAME, app });
19
+ }
20
+
21
+ extract(req) {
22
+ return {
23
+ targetId: req.params._id,
24
+ activeUser: req.user,
25
+ activeUserId: req.user._id,
26
+ ip: getIP(req),
27
+ };
28
+ }
29
+ };
30
+ };
@@ -1,2 +1,3 @@
1
1
  module.exports.GenericLogic = require("./logic.js");
2
2
  module.exports.GenericRoute = require("./route.js");
3
+ module.exports.GenericGetByIdForm = require("./form.getById.js");
@@ -52,6 +52,8 @@ module.exports = ({
52
52
  static getModelSchema = getModelSchema;
53
53
  static getLogic = getLogic;
54
54
  static getModelUser = getModelUser;
55
+ static isOwner = isOwner;
56
+ static ownerFieldName = ownerFieldName;
55
57
 
56
58
  static async _create({
57
59
  action,