not-node 6.3.88 → 6.3.90

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.3.88",
3
+ "version": "6.3.90",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,6 +6,6 @@ module.exports = {
6
6
  model: {
7
7
  type: Boolean,
8
8
  default: false,
9
- required: true,
9
+ required: true
10
10
  },
11
11
  };
@@ -6,6 +6,6 @@ module.exports = {
6
6
  model: {
7
7
  type: Boolean,
8
8
  default: false,
9
- required: true,
9
+ required: true
10
10
  },
11
11
  };
@@ -7,5 +7,6 @@ module.exports = {
7
7
  model: {
8
8
  type: String,
9
9
  required: true,
10
+ transformers: ['xss']
10
11
  },
11
12
  };
@@ -9,5 +9,6 @@ module.exports = {
9
9
  required: true,
10
10
  searchable: true,
11
11
  sortable: true,
12
+ transformers: ['xss']
12
13
  },
13
14
  };
@@ -7,5 +7,6 @@ module.exports = {
7
7
  model: {
8
8
  type: String,
9
9
  required: true,
10
+ transformers: ['xss']
10
11
  },
11
12
  };
@@ -8,5 +8,6 @@ module.exports = {
8
8
  type: String,
9
9
  searchable: true,
10
10
  required: true,
11
+ transformers: ['xss']
11
12
  },
12
13
  };
@@ -6,6 +6,7 @@ module.exports = {
6
6
  update: ["@owner", "root", "admin"],
7
7
  read: ["@owner", "root", "admin"],
8
8
  },
9
+ transformers: ['xss']
9
10
  },
10
11
  ui: {
11
12
  component: "UIHidden",
@@ -8,5 +8,6 @@ module.exports = {
8
8
  type: String,
9
9
  searchable: true,
10
10
  required: true,
11
+ transformers: ['xss']
11
12
  },
12
13
  };
@@ -7,5 +7,6 @@ module.exports = {
7
7
  model: {
8
8
  type: String,
9
9
  required: true,
10
+ transformers: ['xss']
10
11
  },
11
12
  };
@@ -13,5 +13,6 @@ module.exports = {
13
13
  update: ["@owner", "root", "admin"],
14
14
  read: ["@owner", "root", "admin"],
15
15
  },
16
+ transformers: ['xss']
16
17
  },
17
18
  };
@@ -9,5 +9,6 @@ module.exports = {
9
9
  type: String,
10
10
  searchable: true,
11
11
  required: true,
12
+ transformers: ['xss']
12
13
  },
13
14
  };
package/src/form/form.js CHANGED
@@ -87,6 +87,7 @@ class Form {
87
87
  * @param {string} options.FORM_NAME
88
88
  * @param {string} options.MODEL_NAME
89
89
  * @param {string} options.MODULE_NAME
90
+ * @param {string} options.actionName
90
91
  * @param {import('../app.js')} options.app
91
92
  * @param {Object.<string, Function>} options.EXTRACTORS
92
93
  * @param {Object.<string, Function>} options.TRANSFORMERS
@@ -100,6 +101,7 @@ class Form {
100
101
  FORM_NAME,
101
102
  MODEL_NAME,
102
103
  MODULE_NAME,
104
+ actionName,
103
105
  app,
104
106
  EXTRACTORS = {},
105
107
  ENV_EXTRACTORS = {},
@@ -108,7 +110,7 @@ class Form {
108
110
  AFTER_EXTRACT_TRANSFORMERS = [],
109
111
  rate,
110
112
  }) {
111
- this.#FORM_NAME = FORM_NAME;
113
+ this.#FORM_NAME = FORM_NAME ?? this.createName(MODULE_NAME, MODEL_NAME, actionName);
112
114
  this.#MODEL_NAME = MODEL_NAME;
113
115
  this.#MODULE_NAME = MODULE_NAME;
114
116
  this.#PROTO_FIELDS = FIELDS;
@@ -130,10 +132,10 @@ class Form {
130
132
  * Creates model name string used in logging
131
133
  * @param {string} MODULE_NAME
132
134
  * @param {string|undefined} MODEL_NAME
133
- * @param {string} actionName
135
+ * @param {string} actionName = 'data'
134
136
  * @returns {string}
135
137
  */
136
- static createName(MODULE_NAME, MODEL_NAME, actionName) {
138
+ static createName(MODULE_NAME, MODEL_NAME, actionName = 'data') {
137
139
  if (MODEL_NAME) {
138
140
  return `${MODULE_NAME}:${MODEL_NAME}:${firstLetterToUpper(
139
141
  actionName
@@ -660,6 +662,9 @@ class Form {
660
662
  if (typeof schemaField === "undefined" || schemaField === null) {
661
663
  return [];
662
664
  }
665
+ if(schemaField.transformers && Array.isArray(schemaField.transformers)){
666
+ return schemaField.transformers;
667
+ }
663
668
  switch (schemaField.type) {
664
669
  case String:
665
670
  case Schema.Types.String:
package/src/types.js CHANGED
@@ -159,13 +159,14 @@
159
159
 
160
160
  /**
161
161
  * @typedef {object} notFieldModel
162
- * @property {notFieldModelType} type
163
- * @property {any} default default value
164
- * @property {boolean} [sortable] if field is sortable
165
- * @property {boolean} [required] if required to be defined
166
- * @property {notFieldSafety} [safe] safety requirements
167
- * @property {string} [ref] mongoose model name, if type is ObjectId
168
- * @property {string} [refPath] path to field with name of mongoose model this field value of ObjectId type reference to
162
+ * @property {notFieldModelType} type
163
+ * @property {Array<string>} [transformers] list of transformers names to pipe down aka ['xss', 'trim', 'removeDots', 'maxLength1000'], used in Form as default transforming pipeline on data extraction stage
164
+ * @property {any} default default value
165
+ * @property {boolean} [sortable] if field is sortable
166
+ * @property {boolean} [required] if required to be defined
167
+ * @property {notFieldSafety} [safe] safety requirements
168
+ * @property {string} [ref] mongoose model name, if type is ObjectId
169
+ * @property {string} [refPath] path to field with name of mongoose model this field value of ObjectId type reference to
169
170
  */
170
171
 
171
172
  /**
@@ -1,16 +1,18 @@
1
1
  const { MODULE_NAME } = require("../const");
2
+ const MODEL_NAME = '<%- ModelName %>';
3
+ const actionName = '_data';
2
4
 
3
5
  const Form = require("not-node").Form;
4
6
 
5
7
  const FIELDS = [<% if (fields && Array.isArray(fields)) { %><% for(let field of fields){ %>["<%- field[0] %>", "<%- field[1] %>"],
6
8
  <% } %><% } %>];
7
9
 
8
- const FORM_NAME = Form.createName();
10
+ const FORM_NAME = Form.createName(MODULE_NAME, MODEL_NAME, actionName);
9
11
 
10
12
  //const validateTitle = require("./validators/title.js");
11
13
  class _<%- ModelName %>Form extends Form {
12
14
  constructor({ app }) {
13
- super({ FIELDS, FORM_NAME, app });
15
+ super({MODULE_NAME,MODEL_NAME,actionName, FIELDS, FORM_NAME, app });
14
16
  }
15
17
 
16
18
  //could do something with data, before validation