not-node 6.3.63 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/form/form.js +23 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.3.63",
3
+ "version": "6.3.64",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
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);
@@ -223,10 +228,18 @@ class Form {
223
228
  async extract(req) {
224
229
  return {
225
230
  ...this.extractRequestEnvs(req),
226
- data: this.extractByInstructionsFromRouteActionFields(req),
231
+ data: this.#extractByBestInstructions(req),
227
232
  };
228
233
  }
229
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
+
230
243
  /**
231
244
  * Chance to edit prepared data
232
245
  *
@@ -417,6 +430,15 @@ class Form {
417
430
  static fabric() {
418
431
  return FormFabric;
419
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
+ }
420
442
 
421
443
  /**
422
444
  * Object with named extractor functions