not-node 6.3.62 → 6.3.64

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.62",
3
+ "version": "6.3.64",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,25 +10,30 @@ const getApp = require("../../getApp");
10
10
  module.exports = (form, req) => {
11
11
  const MODULE_NAME = form.getModuleName();
12
12
  const MODEL_NAME = form.getModelName(req);
13
+ let thisSchema;
13
14
  if (MODEL_NAME && MODULE_NAME) {
14
- const thisSchema = getApp().getModelSchema(
15
- `${MODULE_NAME}//${MODEL_NAME}`
15
+ thisSchema = getApp().getModelSchema(`${MODULE_NAME}//${MODEL_NAME}`);
16
+ } else {
17
+ getApp().log(
18
+ `warning: Form '${form.FORM_NAME}' for model '${MODEL_NAME}' has no MODULE_NAME`
16
19
  );
17
- if (thisSchema) {
18
- let skip, size;
19
- const pager = notFilter.pager.process(req), //skip,size
20
- sorter = notFilter.sorter.process(req, thisSchema),
21
- search = notFilter.search.process(req, thisSchema);
22
- let filter = notFilter.filter.process(req, thisSchema);
23
- if (pager) {
24
- skip = pager.skip;
25
- size = pager.size;
26
- }
27
- return {
28
- name: "query",
29
- value: { skip, size, sorter, search, filter },
30
- };
20
+ thisSchema = getApp().getModelSchema(`${MODEL_NAME}`);
21
+ }
22
+ if (thisSchema) {
23
+ let skip, size;
24
+ const pager = notFilter.pager.process(req), //skip,size
25
+ sorter = notFilter.sorter.process(req, thisSchema),
26
+ search = notFilter.search.process(req, thisSchema);
27
+ let filter = notFilter.filter.process(req, thisSchema);
28
+ if (pager) {
29
+ skip = pager.skip;
30
+ size = pager.size;
31
31
  }
32
+ return {
33
+ name: "query",
34
+ value: { skip, size, sorter, search, filter },
35
+ };
32
36
  }
37
+
33
38
  return undefined;
34
39
  };
package/src/form/form.js CHANGED
@@ -72,6 +72,8 @@ class Form {
72
72
  ...DEFAULT_AFTER_EXTRACT_TRANSFORMERS,
73
73
  };
74
74
 
75
+ #INSTRUCTIONS = null;
76
+
75
77
  #rateLimiter = null;
76
78
  #rateLimiterIdGetter = (data) => data.identity.sid;
77
79
  #rateLimiterException = FormExceptionTooManyRequests;
@@ -87,6 +89,7 @@ class Form {
87
89
  * @param {import('../app.js')} options.app
88
90
  * @param {Object.<string, Function>} options.EXTRACTORS
89
91
  * @param {Object.<string, Function>} options.TRANSFORMERS
92
+ * @param {import('../types.js').notAppFormProcessingPipe|null} options.INSTRUCTIONS
90
93
  * @param {Array<Function>} options.AFTER_EXTRACT_TRANSFORMERS
91
94
  * @param {Object.<string, import('../types.js').notAppFormEnvExtractor>} options.ENV_EXTRACTORS
92
95
  * @param {import('../types.js').notAppFormRateLimiterOptions} options.rate
@@ -100,6 +103,7 @@ class Form {
100
103
  EXTRACTORS = {},
101
104
  ENV_EXTRACTORS = {},
102
105
  TRANSFORMERS = {},
106
+ INSTRUCTIONS = null,
103
107
  AFTER_EXTRACT_TRANSFORMERS = [],
104
108
  rate,
105
109
  }) {
@@ -109,6 +113,7 @@ class Form {
109
113
  this.#PROTO_FIELDS = FIELDS;
110
114
  this.#createValidationSchema(app);
111
115
  this.#augmentValidationSchema();
116
+ this.#addInstructions(INSTRUCTIONS);
112
117
  this.#addExtractors(EXTRACTORS);
113
118
  this.#addEnvExtractors(ENV_EXTRACTORS);
114
119
  this.#addTransformers(TRANSFORMERS);
@@ -116,6 +121,10 @@ class Form {
116
121
  this.#createRateLimiter(rate);
117
122
  }
118
123
 
124
+ get FORM_NAME() {
125
+ return this.#FORM_NAME;
126
+ }
127
+
119
128
  /**
120
129
  * Creates model name string used in logging
121
130
  * @param {string} MODULE_NAME
@@ -219,10 +228,18 @@ class Form {
219
228
  async extract(req) {
220
229
  return {
221
230
  ...this.extractRequestEnvs(req),
222
- data: this.extractByInstructionsFromRouteActionFields(req),
231
+ data: this.#extractByBestInstructions(req),
223
232
  };
224
233
  }
225
234
 
235
+ #extractByBestInstructions(req) {
236
+ if (this.#INSTRUCTIONS) {
237
+ return this.extractByInstructions(req, this.#INSTRUCTIONS);
238
+ } else {
239
+ return this.extractByInstructionsFromRouteActionFields(req);
240
+ }
241
+ }
242
+
226
243
  /**
227
244
  * Chance to edit prepared data
228
245
  *
@@ -413,6 +430,15 @@ class Form {
413
430
  static fabric() {
414
431
  return FormFabric;
415
432
  }
433
+ /**
434
+ * Object with named extractor functions
435
+ * @param {import('../types.js').notAppFormProcessingPipe|null} instructions
436
+ */
437
+ #addInstructions(instructions = null) {
438
+ if (instructions) {
439
+ this.#INSTRUCTIONS = { ...instructions };
440
+ }
441
+ }
416
442
 
417
443
  /**
418
444
  * Object with named extractor functions