not-node 6.5.15 → 6.5.17

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.5.15",
3
+ "version": "6.5.17",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -89,6 +89,7 @@ module.exports = ({
89
89
  MODULE_NAME,
90
90
  MODEL_NAME,
91
91
  actionName,
92
+ config,
92
93
  formProps,
93
94
  }) => {
94
95
  if (Object.keys(genericFormsGenerators).includes(actionName)) {
@@ -97,6 +98,7 @@ module.exports = ({
97
98
  MODULE_NAME,
98
99
  MODEL_NAME,
99
100
  actionName,
101
+ config,
100
102
  ...formProps,
101
103
  });
102
104
  return new formConstructor({
@@ -104,6 +106,7 @@ module.exports = ({
104
106
  MODULE_NAME,
105
107
  MODEL_NAME,
106
108
  actionName,
109
+ config,
107
110
  ...formProps,
108
111
  });
109
112
  } else {
@@ -112,6 +115,7 @@ module.exports = ({
112
115
  MODULE_NAME,
113
116
  MODEL_NAME,
114
117
  actionName,
118
+ config,
115
119
  ...formProps,
116
120
  });
117
121
  }
@@ -151,6 +155,7 @@ module.exports = ({
151
155
  MODEL_NAME,
152
156
  actionName,
153
157
  app: getApp(),
158
+ config,
154
159
  formProps: selectActionFormProps(formsProps, actionName),
155
160
  });
156
161
  //caching
package/src/form/form.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const Schema = require("mongoose").Schema;
2
2
  const validator = require("validator");
3
3
  const notPath = require("not-path");
4
+ const notConfig = require("not-config");
4
5
  const FormFabric = require("./fabric");
5
6
  const Auth = require("../auth");
6
7
  const { createSchemaFromFields } = require("../fields");
@@ -80,6 +81,10 @@ class Form {
80
81
  };
81
82
 
82
83
  #INSTRUCTIONS = undefined;
84
+ /**
85
+ * @prop {import('../types.js').notAppConfigReader} name of model
86
+ **/
87
+ #CONFIG;
83
88
 
84
89
  #rateLimiter = undefined;
85
90
  #rateLimiterIdGetter = (data) => data.identity.sid;
@@ -87,7 +92,7 @@ class Form {
87
92
  #rateLimiterClientName = InitRateLimiter.DEFAULT_CLIENT;
88
93
 
89
94
  /**
90
- *
95
+ * @memberof Form
91
96
  * @param {Object} options
92
97
  * @param {Array<string|Array<string>>} [options.FIELDS]
93
98
  * @param {string} [options.FORM_NAME]
@@ -95,6 +100,7 @@ class Form {
95
100
  * @param {string} options.MODULE_NAME
96
101
  * @param {string} options.actionName
97
102
  * @param {import('../app.js')} options.app
103
+ * @param {import('../types.js').notAppConfigReader} [options.config]
98
104
  * @param {Object.<string, Function>} [options.EXTRACTORS]
99
105
  * @param {Object.<string, Function>} [options.TRANSFORMERS]
100
106
  * @param {import('../types.js').notAppFormProcessingPipe} [options.INSTRUCTIONS]
@@ -109,6 +115,7 @@ class Form {
109
115
  MODULE_NAME,
110
116
  actionName,
111
117
  app,
118
+ config,
112
119
  EXTRACTORS = {},
113
120
  ENV_EXTRACTORS = {},
114
121
  TRANSFORMERS = {},
@@ -120,8 +127,8 @@ class Form {
120
127
  FORM_NAME ?? Form.createName(MODULE_NAME, MODEL_NAME, actionName);
121
128
  this.#MODEL_NAME = MODEL_NAME;
122
129
  this.#MODULE_NAME = MODULE_NAME;
130
+ config && this.#setConfig(config);
123
131
  this.#setFields(app, FIELDS);
124
-
125
132
  this.#createValidationSchema(app);
126
133
  this.#augmentValidationSchema();
127
134
  INSTRUCTIONS && this.#addInstructions(INSTRUCTIONS);
@@ -132,6 +139,34 @@ class Form {
132
139
  this.#createRateLimiter(rate);
133
140
  }
134
141
 
142
+ /**
143
+ *
144
+ * @param {import('../types.js').notAppConfigReader} config
145
+ * @memberof Form
146
+ */
147
+ #setConfig(config) {
148
+ this.#CONFIG = config;
149
+ }
150
+
151
+ /**
152
+ * Returns module config reader
153
+ * @readonly
154
+ * @returns {import('../types.js').notAppConfigReader}
155
+ * @memberof Form
156
+ */
157
+ get config() {
158
+ if (!this.#CONFIG) {
159
+ this.#CONFIG = notConfig.forModule(this.#MODULE_NAME);
160
+ }
161
+ return this.#CONFIG;
162
+ }
163
+
164
+ /**
165
+ *
166
+ * @param {import('../app.js')} app
167
+ * @param {Array<string|Array<string>>} FIELDS
168
+ * @returns
169
+ */
135
170
  #setFields(app, FIELDS = []) {
136
171
  try {
137
172
  const warning = () =>
package/src/types.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @typedef {object} notAppResponse
2
+ * @typedef {object} notAppResponse
3
3
  * @property {string} status 'ok' or 'error'
4
4
  * @property {string} message
5
5
  * @property {Array<string>|Object<string, Array<string>>} [errors]
@@ -18,9 +18,9 @@
18
18
 
19
19
  /**
20
20
  * @typedef {Object} PreparedData
21
- * @property {notAppIdentityData} [identity] user identity information
21
+ * @property {notAppIdentityData} [identity] user identity information
22
22
  * @property {Object} [data]
23
- * @property {string} [action]
23
+ * @property {string} [action]
24
24
  * @property {Query} [query]
25
25
  * @property {number} [targetID] target item ID
26
26
  * @property {Object} [activeUser] current user info
@@ -149,8 +149,9 @@
149
149
  /**
150
150
  * @typedef {object} notFieldSafety
151
151
  * @property {Array<string>} create
152
- * @property {Array<string>} update
153
152
  * @property {Array<string>} read
153
+ * @property {Array<string>} update
154
+ * @property {Array<string>} delete
154
155
  */
155
156
 
156
157
  /**
@@ -231,4 +232,10 @@
231
232
  * @typedef {import('mongoose').Document & notAppDocumentMethods} notAppDocument
232
233
  **/
233
234
 
235
+ /**
236
+ * @typedef {object} notAppConfigReader
237
+ * @property {function(string, [any]):string|number|object|undefined} get
238
+ * @property {function(string, string|number|object|undefined):notAppConfigReader} set
239
+ **/
240
+
234
241
  module.exports = {};