not-node 6.2.19 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.2.19",
3
+ "version": "6.2.20",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,10 +3,10 @@
3
3
  */
4
4
 
5
5
  module.exports = {
6
- _id: require("./_id.js"),
7
6
  ID: require("./ID.js"),
7
+ _id: require("./_id.js"),
8
8
  activeUser: require("./activeUser.js"),
9
9
  ip: require("./ip.js"),
10
- query: require("./query.js"),
11
10
  modelNameID: require("./modelNameID.js"),
11
+ query: require("./query.js"),
12
12
  };
@@ -5,6 +5,6 @@ module.exports = {
5
5
  activeUserId: require("./activeUserId.js"),
6
6
  activeUserModelName: require("./activeUserModelName.js"),
7
7
  fromBody: require("./fromBody.js"),
8
- fromQuery: require("./fromQuery.js"),
9
8
  fromParams: require("./fromParams.js"),
9
+ fromQuery: require("./fromQuery.js"),
10
10
  };
@@ -191,6 +191,14 @@ class notRoute {
191
191
  prepared,
192
192
  ]);
193
193
  //filter result IF actionData.return specified
194
+ if (typeof result.toObject === "function") {
195
+ result = result.toObject();
196
+ }
197
+ if (Array.isArray(result)) {
198
+ result = result.map((itm) =>
199
+ itm.toObject ? itm.toObject() : itm
200
+ );
201
+ }
194
202
  notManifestRouteResultFilter.filter(req.notRouteData, result);
195
203
  //run after with results, continue without waiting when it finished
196
204
  return this.executeFunction(modRoute, CONST_AFTER_ACTION, [
@@ -3,33 +3,33 @@ const { MODULE_NAME } = require("../const");
3
3
  const Form = require("not-node").Form;
4
4
 
5
5
  const FIELDS = [
6
- <% if (fields && Array.isArray(fields)) { %>
6
+ <% if (fields && Array.isArray(fields)) { %>
7
7
  <% for(let field of fields){ %>
8
- <%- `"${field}",` -%>
9
- <% } %>
10
- <% } %>
11
- ["owner", "not-node//owner"],
12
- ["ownerModel", "not-node//ownerModel"],
13
- ];
14
-
15
- const FORM_NAME = `${MODULE_NAME}:_<%- ModelName %>DataForm`;
16
-
17
-
18
- //const validateTitle = require("./validators/title.js");
19
-
20
- module.exports = class _DataForm extends Form {
21
- constructor({ app }) {
22
- super({ FIELDS, FORM_NAME, app });
23
- }
24
-
25
- extract(data) {
26
- return data;
27
- }
28
-
29
- getFormValidationRules() {
30
- return [
31
- //add validators here
32
- //validateTitle,
33
- ];
34
- }
35
- };
8
+ <%- `"${field}",` -%>
9
+ <% } %>
10
+ <% } %>
11
+ ["owner", "not-node//owner"],
12
+ ["ownerModel", "not-node//ownerModel"],
13
+ ];
14
+
15
+ const FORM_NAME = `${MODULE_NAME}:_<%- ModelName %>DataForm`;
16
+
17
+
18
+ //const validateTitle = require("./validators/title.js");
19
+
20
+ module.exports = class _DataForm extends Form {
21
+ constructor({ app }) {
22
+ super({ FIELDS, FORM_NAME, app });
23
+ }
24
+
25
+ extract(data) {
26
+ return data;
27
+ }
28
+
29
+ getFormValidationRules() {
30
+ return [
31
+ //add validators here
32
+ //validateTitle,
33
+ ];
34
+ }
35
+ };
@@ -3,45 +3,45 @@ const { MODULE_NAME } = require("../const");
3
3
  //DB related validation tools
4
4
  const Form = require("not-node").Form;
5
5
  //form
6
- const FIELDS = [
7
- <% if (fields && Array.isArray(fields)) { %>
6
+ const FIELDS = [
7
+ <% if (fields && Array.isArray(fields)) { %>
8
8
  <% for(let field of fields){ %>
9
- "<%- field %>",
10
- <% } %>
11
- <% } %>
12
- ];
9
+ "<%- field %>",
10
+ <% } %>
11
+ <% } %>
12
+ ];
13
13
 
14
- const FORM_NAME = `${MODULE_NAME}:<%- ModelName %>CreateForm`;
14
+ const FORM_NAME = `${MODULE_NAME}:<%- ModelName %>CreateForm`;
15
15
 
16
- /**
17
- *
18
- **/
19
- module.exports = class <%- ModelName %>CreateForm extends Form {
20
- constructor({ app }) {
21
- super({ FIELDS, FORM_NAME, app });
22
- }
16
+ /**
17
+ *
18
+ **/
19
+ module.exports = class <%- ModelName %>CreateForm extends Form {
20
+ constructor({ app }) {
21
+ super({ FIELDS, FORM_NAME, app });
22
+ }
23
23
 
24
- /**
25
- * Extracts data
26
- * @param {ExpressRequest} req expressjs request object
27
- * @return {Object} forma data
28
- **/
29
- extract(req) {
30
- const ip = getIP(req);
31
- const instructions = {
32
- <% if (fields && Array.isArray(fields)) { %>
33
- <% for(let field of fields){ %>
34
- <%- field+': "extractFromBody",' -%>
35
- <% } %>
36
- <% } %>
37
- owner: "activeUserId",
38
- ownerModel: "activeUserModelName",
39
- };
40
- const data = this.extractByInstructions(req, instructions);
41
- return {
42
- activeUser: req.user,
43
- ip,
44
- data,
45
- };
46
- }
47
- };
24
+ /**
25
+ * Extracts data
26
+ * @param {ExpressRequest} req expressjs request object
27
+ * @return {Object} forma data
28
+ **/
29
+ extract(req) {
30
+ const ip = getIP(req);
31
+ const instructions = {
32
+ <% if (fields && Array.isArray(fields)) { %>
33
+ <% for(let field of fields){ %>
34
+ <%- field+': "extractFromBody" ,' -%>
35
+ <% } %>
36
+ <% } %>
37
+ owner: "activeUserId",
38
+ ownerModel: "activeUserModelName",
39
+ };
40
+ const data = this.extractByInstructions(req, instructions);
41
+ return {
42
+ activeUser: req.user,
43
+ ip,
44
+ data,
45
+ };
46
+ }
47
+ };
@@ -2,7 +2,7 @@ const notNode = require("not-node");
2
2
  const { MODULE_NAME } = require("../const");
3
3
 
4
4
  module.exports = notNode.Generic.GenericListAndCountForm({
5
- MODULE_NAME,
6
- MODEL_NAME: "<%- ModelName %>",
5
+ MODULE_NAME,
6
+ MODEL_NAME: "<%- ModelName %>",
7
7
  actionName: "listAll",
8
- });
8
+ });
@@ -2,7 +2,7 @@ const notNode = require("not-node");
2
2
  const { MODULE_NAME } = require("../const");
3
3
 
4
4
  module.exports = notNode.Generic.GenericListAndCountForm({
5
- MODULE_NAME,
6
- MODEL_NAME: "<%- ModelName %>",
5
+ MODULE_NAME,
6
+ MODEL_NAME: "<%- ModelName %>",
7
7
  actionName: "listAndCount",
8
- });
8
+ });
@@ -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
- ["targetId", { required: true }, "not-node//objectId"],
7
- ["activeUser", "not-node//requiredObject"],
8
- ["data", `${ModuleName}//_${ModelName}_data`], //sub forms validators should start with underscore
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 = `${ModuleName}:<%- ModelName %>UpdateForm`;
10
+ ];
11
+ const FORM_NAME = `${MODULE_NAME}:<%- ModelName %>UpdateForm`;
12
12
 
13
- module.exports = class <%- ModelName %>UpdateForm extends Form {
14
- constructor({ app }) {
15
- super({ FIELDS, FORM_NAME, app });
16
- }
13
+ module.exports = class <%- ModelName %>UpdateForm extends Form {
14
+ constructor({ app }) {
15
+ super({ FIELDS, FORM_NAME, app });
16
+ }
17
17
 
18
- extract(req) {
19
- const instructions = {
18
+ extract(req) {
19
+ const instructions = {
20
20
  <% if (fields && Array.isArray(fields)) { %>
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
- };
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
+ };