Просмотр исходного кода

refactor: removes ignoreRequestDataSchema option

e22m4u 2 недель назад
Родитель
Сommit
3c889040b0
4 измененных файлов с 4 добавлено и 32 удалено
  1. 2 9
      README.md
  2. 1 7
      dist/cjs/index.cjs
  3. 0 1
      src/trie-router-data-mapper.d.ts
  4. 1 15
      src/trie-router-data-mapper.js

+ 2 - 9
README.md

@@ -140,15 +140,8 @@ import {TrieRouterDataMapper} from '@e22m4u/js-trie-router-data-mapper';
 const router = new TrieRouter();
 const router = new TrieRouter();
 
 
 router.useService(TrieRouterDataMapper, {
 router.useService(TrieRouterDataMapper, {
-  // игнорировать опцию "schema" для следующих источников:
-  //   HttpData.REQUEST_PARAMS
-  //   HttpData.REQUEST_QUERY
-  //   HttpData.REQUEST_HEADERS
-  //   HttpData.REQUEST_COOKIES
-  //   HttpData.REQUEST_BODY
-  ignoreRequestDataSchema: true,
-  // игнорировать опцию "schema" для следующих источников:
-  //   HttpData.RESPONSE_BODY
+  // игнорировать опцию "schema"
+  // для источника HttpData.RESPONSE_BODY
   ignoreResponseDataSchema: true,
   ignoreResponseDataSchema: true,
 });
 });
 ```
 ```

+ 1 - 7
dist/cjs/index.cjs

@@ -121,12 +121,6 @@ var _TrieRouterDataMapper = class _TrieRouterDataMapper extends import_js_servic
         options
         options
       );
       );
     }
     }
-    if (options.ignoreRequestDataSchema !== void 0 && typeof options.ignoreRequestDataSchema !== "boolean") {
-      throw new import_js_format2.InvalidArgumentError(
-        'Option "ignoreRequestDataSchema" must be a Boolean, but %v was given.',
-        options.ignoreRequestDataSchema
-      );
-    }
     if (options.ignoreResponseDataSchema !== void 0 && typeof options.ignoreResponseDataSchema !== "boolean") {
     if (options.ignoreResponseDataSchema !== void 0 && typeof options.ignoreResponseDataSchema !== "boolean") {
       throw new import_js_format2.InvalidArgumentError(
       throw new import_js_format2.InvalidArgumentError(
         'Option "ignoreResponseDataSchema" must be a Boolean, but %v was given.',
         'Option "ignoreResponseDataSchema" must be a Boolean, but %v was given.',
@@ -175,7 +169,7 @@ var _TrieRouterDataMapper = class _TrieRouterDataMapper extends import_js_servic
           );
           );
         }
         }
       }
       }
-      if (!this.options.ignoreRequestDataSchema && propOptions.schema !== void 0) {
+      if (propOptions.schema !== void 0) {
         const sourcePath = propOptions.property ? `request.${ctxProp}.${propOptions.property}` : `request.${ctxProp}`;
         const sourcePath = propOptions.property ? `request.${ctxProp}.${propOptions.property}` : `request.${ctxProp}`;
         if (import_js_data_schema.DATA_TYPE_LIST.includes(propOptions.schema)) {
         if (import_js_data_schema.DATA_TYPE_LIST.includes(propOptions.schema)) {
           const dataSchema = { type: propOptions.schema };
           const dataSchema = { type: propOptions.schema };

+ 0 - 1
src/trie-router-data-mapper.d.ts

@@ -6,7 +6,6 @@ import {Service, ServiceContainer} from '@e22m4u/js-service';
  * Trie router data mapper options.
  * Trie router data mapper options.
  */
  */
 export type TrieRouterDataMapperOptions = {
 export type TrieRouterDataMapperOptions = {
-  ignoreRequestDataSchema?: boolean;
   ignoreResponseDataSchema?: boolean;
   ignoreResponseDataSchema?: boolean;
 };
 };
 
 

+ 1 - 15
src/trie-router-data-mapper.js

@@ -8,7 +8,6 @@ import {validateDataMappingSchema} from './validate-data-mapping-schema.js';
 
 
 /**
 /**
  * @typedef {object} TrieRouterDataMapperOptions
  * @typedef {object} TrieRouterDataMapperOptions
- * @property {boolean} [ignoreRequestDataSchema]
  * @property {boolean} [ignoreResponseDataSchema]
  * @property {boolean} [ignoreResponseDataSchema]
  */
  */
 
 
@@ -58,16 +57,6 @@ export class TrieRouterDataMapper extends Service {
         options,
         options,
       );
       );
     }
     }
-    if (
-      options.ignoreRequestDataSchema !== undefined &&
-      typeof options.ignoreRequestDataSchema !== 'boolean'
-    ) {
-      throw new InvalidArgumentError(
-        'Option "ignoreRequestDataSchema" must be a Boolean, ' +
-          'but %v was given.',
-        options.ignoreRequestDataSchema,
-      );
-    }
     if (
     if (
       options.ignoreResponseDataSchema !== undefined &&
       options.ignoreResponseDataSchema !== undefined &&
       typeof options.ignoreResponseDataSchema !== 'boolean'
       typeof options.ignoreResponseDataSchema !== 'boolean'
@@ -137,10 +126,7 @@ export class TrieRouterDataMapper extends Service {
       }
       }
       // если определена схема данных,
       // если определена схема данных,
       // то выполняется разбор значения
       // то выполняется разбор значения
-      if (
-        !this.options.ignoreRequestDataSchema &&
-        propOptions.schema !== undefined
-      ) {
+      if (propOptions.schema !== undefined) {
         const sourcePath = propOptions.property
         const sourcePath = propOptions.property
           ? `request.${ctxProp}.${propOptions.property}`
           ? `request.${ctxProp}.${propOptions.property}`
           : `request.${ctxProp}`;
           : `request.${ctxProp}`;