@e22m4u/ts-rest-router 0.6.9 → 0.6.10
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/README.md +1 -1
- package/dist/cjs/index.cjs +10 -10
- package/dist/esm/controller-registry.js +3 -3
- package/dist/esm/data-schema-types.d.ts +2 -2
- package/dist/esm/decorators/request-data/request-data-decorator.js +1 -1
- package/dist/esm/decorators/request-data/request-data-decorator.spec.js +1 -1
- package/dist/esm/decorators/response-body/response-body-decorator.spec.js +1 -1
- package/package.json +2 -2
- package/src/controller-registry.spec.ts +1 -1
- package/src/controller-registry.ts +4 -4
- package/src/data-schema-types.ts +2 -2
- package/src/decorators/request-data/request-data-decorator.spec.ts +1 -1
- package/src/decorators/request-data/request-data-decorator.ts +2 -2
- package/src/decorators/response-body/response-body-decorator.spec.ts +1 -1
package/README.md
CHANGED
|
@@ -407,7 +407,7 @@ class SystemController {
|
|
|
407
407
|
## Валидация данных
|
|
408
408
|
|
|
409
409
|
Модуль интегрирован с
|
|
410
|
-
[@e22m4u/
|
|
410
|
+
[@e22m4u/ts-data-schema](https://www.npmjs.com/package/@e22m4u/ts-data-schema)
|
|
411
411
|
для гибкой проверки данных. Это дает возможность определять типы данных
|
|
412
412
|
и сложные правила.
|
|
413
413
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -93,8 +93,8 @@ var import_js_trie_router3 = require("@e22m4u/js-trie-router");
|
|
|
93
93
|
// dist/esm/controller-registry.js
|
|
94
94
|
var import_js_format2 = require("@e22m4u/js-format");
|
|
95
95
|
var import_js_trie_router2 = require("@e22m4u/js-trie-router");
|
|
96
|
-
var
|
|
97
|
-
var
|
|
96
|
+
var import_ts_data_schema2 = require("@e22m4u/ts-data-schema");
|
|
97
|
+
var import_ts_data_schema3 = require("@e22m4u/ts-data-schema");
|
|
98
98
|
|
|
99
99
|
// dist/esm/errors/not-a-controller-error.js
|
|
100
100
|
var import_js_format = require("@e22m4u/js-format");
|
|
@@ -211,7 +211,7 @@ var RequestDataSource;
|
|
|
211
211
|
var REQUEST_DATA_METADATA_KEY = new import_ts_reflector5.MetadataKey("requestDataMetadataKey");
|
|
212
212
|
|
|
213
213
|
// dist/esm/decorators/request-data/request-data-decorator.js
|
|
214
|
-
var
|
|
214
|
+
var import_ts_data_schema = require("@e22m4u/ts-data-schema");
|
|
215
215
|
var import_ts_reflector7 = require("@e22m4u/ts-reflector");
|
|
216
216
|
var import_ts_reflector8 = require("@e22m4u/ts-reflector");
|
|
217
217
|
|
|
@@ -264,7 +264,7 @@ function createRequestDataDecoratorWithSource(source) {
|
|
|
264
264
|
} else if (typeof schemaInput === "string") {
|
|
265
265
|
schema = { type: schemaInput };
|
|
266
266
|
} else {
|
|
267
|
-
schema = { type:
|
|
267
|
+
schema = { type: import_ts_data_schema.DataType.ANY };
|
|
268
268
|
}
|
|
269
269
|
return requestData({ schema, source });
|
|
270
270
|
};
|
|
@@ -272,7 +272,7 @@ function createRequestDataDecoratorWithSource(source) {
|
|
|
272
272
|
__name(createRequestDataDecoratorWithSource, "createRequestDataDecoratorWithSource");
|
|
273
273
|
function createRequestDataPropertyDecoratorWithSource(source) {
|
|
274
274
|
return function(propertyKey, schemaInput) {
|
|
275
|
-
const rootSchema = { type:
|
|
275
|
+
const rootSchema = { type: import_ts_data_schema.DataType.OBJECT };
|
|
276
276
|
const properties = {};
|
|
277
277
|
let schemaOrFactory = rootSchema;
|
|
278
278
|
if (typeof schemaInput === "function") {
|
|
@@ -288,7 +288,7 @@ function createRequestDataPropertyDecoratorWithSource(source) {
|
|
|
288
288
|
properties[propertyKey] = { type: schemaInput };
|
|
289
289
|
rootSchema.properties = properties;
|
|
290
290
|
} else {
|
|
291
|
-
properties[propertyKey] = { type:
|
|
291
|
+
properties[propertyKey] = { type: import_ts_data_schema.DataType.ANY };
|
|
292
292
|
rootSchema.properties = properties;
|
|
293
293
|
}
|
|
294
294
|
return requestData({
|
|
@@ -579,7 +579,7 @@ function requestContainer() {
|
|
|
579
579
|
__name(requestContainer, "requestContainer");
|
|
580
580
|
|
|
581
581
|
// dist/esm/controller-registry.js
|
|
582
|
-
var
|
|
582
|
+
var import_ts_data_schema4 = require("@e22m4u/ts-data-schema");
|
|
583
583
|
var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
|
|
584
584
|
/**
|
|
585
585
|
* Controller map.
|
|
@@ -860,9 +860,9 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
|
|
|
860
860
|
const requestContextMetadataMap = RequestContextReflector.getMetadata(controllerCtor, actionName);
|
|
861
861
|
const requestDataMetadataMap = RequestDataReflector.getMetadata(controllerCtor, actionName);
|
|
862
862
|
const argsNumber = controllerCtor.prototype[actionName].length;
|
|
863
|
-
const defaultsApplier = this.getService(
|
|
864
|
-
const dataTypeCaster = this.getService(
|
|
865
|
-
const dataValidator = this.getService(
|
|
863
|
+
const defaultsApplier = this.getService(import_ts_data_schema4.DefaultValuesApplier);
|
|
864
|
+
const dataTypeCaster = this.getService(import_ts_data_schema3.DataTypeCaster);
|
|
865
|
+
const dataValidator = this.getService(import_ts_data_schema2.DataValidator);
|
|
866
866
|
return (requestContext2) => {
|
|
867
867
|
debug("Executing route handler for %s.%s.", controllerCtor.name, actionName);
|
|
868
868
|
const args = Array(argsNumber).fill(void 0).map((_, index) => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Errorf } from '@e22m4u/js-format';
|
|
2
2
|
import { TrieRouter } from '@e22m4u/js-trie-router';
|
|
3
|
-
import { DataValidator } from '@e22m4u/
|
|
4
|
-
import { DataTypeCaster } from '@e22m4u/
|
|
3
|
+
import { DataValidator } from '@e22m4u/ts-data-schema';
|
|
4
|
+
import { DataTypeCaster } from '@e22m4u/ts-data-schema';
|
|
5
5
|
import { NotAControllerError } from './errors/index.js';
|
|
6
6
|
import { RequestDataSource } from './decorators/index.js';
|
|
7
7
|
import { DebuggableService } from './debuggable-service.js';
|
|
8
8
|
import { RestActionReflector } from './decorators/index.js';
|
|
9
9
|
import { RequestDataReflector } from './decorators/index.js';
|
|
10
10
|
import { AfterActionReflector } from './decorators/index.js';
|
|
11
|
-
import { DefaultValuesApplier } from '@e22m4u/
|
|
11
|
+
import { DefaultValuesApplier } from '@e22m4u/ts-data-schema';
|
|
12
12
|
import { BeforeActionReflector } from './decorators/index.js';
|
|
13
13
|
import { RestControllerReflector } from './decorators/index.js';
|
|
14
14
|
import { RequestContextReflector } from './decorators/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataType } from '@e22m4u/
|
|
2
|
-
import { DataSchema } from '@e22m4u/
|
|
1
|
+
import { DataType } from '@e22m4u/ts-data-schema';
|
|
2
|
+
import { DataSchema } from '@e22m4u/ts-data-schema';
|
|
3
3
|
import { ServiceContainer } from '@e22m4u/js-service';
|
|
4
4
|
/**
|
|
5
5
|
* Data schema factory.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataType } from '@e22m4u/
|
|
1
|
+
import { DataType } from '@e22m4u/ts-data-schema';
|
|
2
2
|
import { DecoratorTargetType } from '@e22m4u/ts-reflector';
|
|
3
3
|
import { getDecoratorTargetType } from '@e22m4u/ts-reflector';
|
|
4
4
|
import { RequestDataSource } from './request-data-metadata.js';
|
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
14
14
|
import { expect } from 'chai';
|
|
15
|
-
import { DataType } from '@e22m4u/
|
|
15
|
+
import { DataType } from '@e22m4u/ts-data-schema';
|
|
16
16
|
import { requestData } from './request-data-decorator.js';
|
|
17
17
|
import { requestBody } from './request-data-decorator.js';
|
|
18
18
|
import { requestField } from './request-data-decorator.js';
|
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { expect } from 'chai';
|
|
11
|
-
import { DataType } from '@e22m4u/
|
|
11
|
+
import { DataType } from '@e22m4u/ts-data-schema';
|
|
12
12
|
import { responseBody } from './response-body-decorator.js';
|
|
13
13
|
import { ResponseBodyReflector } from './response-body-reflector.js';
|
|
14
14
|
describe('responseBody', function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e22m4u/ts-rest-router",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Декларативный REST-маршрутизатор на основе контроллеров для TypeScript",
|
|
5
5
|
"author": "Mikhail Evstropov <e22m4u@yandex.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"prepare": "husky"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@e22m4u/
|
|
44
|
+
"@e22m4u/ts-data-schema": "~0.4.9",
|
|
45
45
|
"@e22m4u/js-debug": "~0.3.3",
|
|
46
46
|
"@e22m4u/js-format": "~0.2.1",
|
|
47
47
|
"@e22m4u/js-service": "~0.4.6",
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
|
|
35
35
|
import {expect} from 'chai';
|
|
36
36
|
import {Service} from '@e22m4u/js-service';
|
|
37
|
-
import {DataType} from '@e22m4u/
|
|
37
|
+
import {DataType} from '@e22m4u/ts-data-schema';
|
|
38
38
|
import {ServiceContainer} from '@e22m4u/js-service';
|
|
39
39
|
import {DataSchemaFactory} from './data-schema-types.js';
|
|
40
40
|
import {ControllerRegistry} from './controller-registry.js';
|
|
@@ -2,10 +2,10 @@ import {AnyObject} from './types.js';
|
|
|
2
2
|
import {Constructor} from './types.js';
|
|
3
3
|
import {Errorf} from '@e22m4u/js-format';
|
|
4
4
|
import {TrieRouter} from '@e22m4u/js-trie-router';
|
|
5
|
-
import {DataSchema} from '@e22m4u/
|
|
5
|
+
import {DataSchema} from '@e22m4u/ts-data-schema';
|
|
6
6
|
import {RouteHandler} from '@e22m4u/js-trie-router';
|
|
7
|
-
import {DataValidator} from '@e22m4u/
|
|
8
|
-
import {DataTypeCaster} from '@e22m4u/
|
|
7
|
+
import {DataValidator} from '@e22m4u/ts-data-schema';
|
|
8
|
+
import {DataTypeCaster} from '@e22m4u/ts-data-schema';
|
|
9
9
|
import {NotAControllerError} from './errors/index.js';
|
|
10
10
|
import {RequestContext} from '@e22m4u/js-trie-router';
|
|
11
11
|
import {RoutePreHandler} from '@e22m4u/js-trie-router';
|
|
@@ -15,7 +15,7 @@ import {DebuggableService} from './debuggable-service.js';
|
|
|
15
15
|
import {RestActionReflector} from './decorators/index.js';
|
|
16
16
|
import {RequestDataReflector} from './decorators/index.js';
|
|
17
17
|
import {AfterActionReflector} from './decorators/index.js';
|
|
18
|
-
import {DefaultValuesApplier} from '@e22m4u/
|
|
18
|
+
import {DefaultValuesApplier} from '@e22m4u/ts-data-schema';
|
|
19
19
|
import {BeforeActionReflector} from './decorators/index.js';
|
|
20
20
|
import {RestControllerReflector} from './decorators/index.js';
|
|
21
21
|
import {RequestContextReflector} from './decorators/index.js';
|
package/src/data-schema-types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {DataType} from '@e22m4u/
|
|
2
|
-
import {DataSchema} from '@e22m4u/
|
|
1
|
+
import {DataType} from '@e22m4u/ts-data-schema';
|
|
2
|
+
import {DataSchema} from '@e22m4u/ts-data-schema';
|
|
3
3
|
import {ServiceContainer} from '@e22m4u/js-service';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import {expect} from 'chai';
|
|
3
|
-
import {DataType} from '@e22m4u/
|
|
3
|
+
import {DataType} from '@e22m4u/ts-data-schema';
|
|
4
4
|
import {ServiceContainer} from '@e22m4u/js-service';
|
|
5
5
|
import {requestData} from './request-data-decorator.js';
|
|
6
6
|
import {requestBody} from './request-data-decorator.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {NoUndef} from '../../types.js';
|
|
2
2
|
import {Prototype} from '../../types.js';
|
|
3
3
|
import {Constructor} from '../../types.js';
|
|
4
|
-
import {DataType} from '@e22m4u/
|
|
5
|
-
import {DataSchema} from '@e22m4u/
|
|
4
|
+
import {DataType} from '@e22m4u/ts-data-schema';
|
|
5
|
+
import {DataSchema} from '@e22m4u/ts-data-schema';
|
|
6
6
|
import {DecoratorTargetType} from '@e22m4u/ts-reflector';
|
|
7
7
|
import {getDecoratorTargetType} from '@e22m4u/ts-reflector';
|
|
8
8
|
import {RequestDataSource} from './request-data-metadata.js';
|