not-node 6.2.20 → 6.2.21

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.20",
3
+ "version": "6.2.21",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -191,15 +191,17 @@ 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
- );
194
+ if (typeof result !== "undefined" && result) {
195
+ if (typeof result.toObject === "function") {
196
+ result = result.toObject();
197
+ }
198
+ if (Array.isArray(result)) {
199
+ result = result.map((itm) =>
200
+ itm.toObject ? itm.toObject() : itm
201
+ );
202
+ }
203
+ notManifestRouteResultFilter.filter(req.notRouteData, result);
201
204
  }
202
- notManifestRouteResultFilter.filter(req.notRouteData, result);
203
205
  //run after with results, continue without waiting when it finished
204
206
  return this.executeFunction(modRoute, CONST_AFTER_ACTION, [
205
207
  req,
@@ -4,44 +4,42 @@ const { MODULE_NAME } = require("../const");
4
4
  const Form = require("not-node").Form;
5
5
  //form
6
6
  const FIELDS = [
7
- <% if (fields && Array.isArray(fields)) { %>
8
- <% for(let field of fields){ %>
9
- "<%- field %>",
10
- <% } %>
11
- <% } %>
12
- ];
7
+ ["activeUser", "not-node//requiredObject"],
8
+ ["data", `${MODULE_NAME}//_<%- ModelName %>_data`],
9
+ ["ip", "not-node//ip"],
10
+ ];
13
11
 
14
- const FORM_NAME = `${MODULE_NAME}:<%- ModelName %>CreateForm`;
12
+ const FORM_NAME = `${MODULE_NAME}:<%- ModelName %>CreateForm`;
15
13
 
16
- /**
17
- *
18
- **/
19
- module.exports = class <%- ModelName %>CreateForm extends Form {
20
- constructor({ app }) {
21
- super({ FIELDS, FORM_NAME, app });
22
- }
14
+ /**
15
+ *
16
+ **/
17
+ module.exports = class <%- ModelName %>CreateForm extends Form {
18
+ constructor({ app }) {
19
+ super({ FIELDS, FORM_NAME, app });
20
+ }
23
21
 
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
- };
22
+ /**
23
+ * Extracts data
24
+ * @param {ExpressRequest} req expressjs request object
25
+ * @return {Object} forma data
26
+ **/
27
+ extract(req) {
28
+ const ip = getIP(req);
29
+ const instructions = {
30
+ <% if (fields && Array.isArray(fields)) { %>
31
+ <% for(let field of fields){ %>
32
+ <%- field+': fromBody" ,' -%>
33
+ <% } %>
34
+ <% } %>
35
+ owner: "activeUserId",
36
+ ownerModel: "activeUserModelName",
37
+ };
38
+ const data = this.extractByInstructions(req, instructions);
39
+ return {
40
+ activeUser: req.user,
41
+ ip,
42
+ data,
43
+ };
44
+ }
45
+ };
@@ -19,7 +19,7 @@ const FIELDS = [
19
19
  const instructions = {
20
20
  <% if (fields && Array.isArray(fields)) { %>
21
21
  <% for(let field of fields){ %>
22
- <%- field+': "extractFromBody" ,' -%>
22
+ <%- field+': "fromBody" ,' -%>
23
23
  <% } %>
24
24
  <% } %>
25
25
  owner: "fromBody",
@@ -2,31 +2,31 @@ const notNode = require("not-node");
2
2
  const { notValidationError } = require("not-error");
3
3
 
4
4
  module.exports = async (
5
- /**
6
- * Values to validate in form
7
- */
8
- {owner, ownerModel, vals, to , validate },
9
- /**
10
- * special container to pass around global validation libs, CONSTs and inject other entities
11
- */
12
- validationEnvs
13
- ) => {
14
- //some preparations
15
- if (
16
- //vals checks
17
- ) {
18
- throw new notValidationError(
19
- "<%- ModuleName %>:validation_error",
20
- {
21
- //vals: ["%- ModuleName %>:vals_should_be_valid"],
22
- },
23
- undefined, //no source error, its custom exception
24
- {
25
- //information
26
- //vals,
27
- //owner,
28
- //ownerModel
29
- }
30
- );
5
+ /**
6
+ * Values to validate in form
7
+ */
8
+ {owner, ownerModel, vals, to , validate },
9
+ /**
10
+ * special container to pass around global validation libs, CONSTs and inject other entities
11
+ */
12
+ validationEnvs
13
+ ) => {
14
+ //some preparations
15
+ if (
16
+ //vals checks
17
+ ) {
18
+ throw new notValidationError(
19
+ "<%- ModuleName %>:validation_error",
20
+ {
21
+ //vals: ["%- ModuleName %>:vals_should_be_valid"],
22
+ },
23
+ undefined, //no source error, its custom exception
24
+ {
25
+ //information
26
+ //vals,
27
+ //owner,
28
+ //ownerModel
31
29
  }
32
- };
30
+ );
31
+ }
32
+ };