@e22m4u/ts-rest-router 0.6.3 → 0.6.4
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 +2 -2
- 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 +6 -6
- 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
@@ -18,7 +18,7 @@
|
|
18
18
|
аргументам методов.
|
19
19
|
- **Встроенная валидация**
|
20
20
|
Использование схем данных из
|
21
|
-
[@e22m4u/
|
21
|
+
[@e22m4u/js-data-schema](https://www.npmjs.com/package/@e22m4u/js-data-schema)
|
22
22
|
для описания сложных правил проверки.
|
23
23
|
- **Хуки (`@beforeAction`, `@afterAction`)**
|
24
24
|
Поддержка хуков для выполнения сквозной логики (например, аутентификация
|
@@ -326,7 +326,7 @@ class SystemController {
|
|
326
326
|
## Валидация и схемы данных
|
327
327
|
|
328
328
|
Модуль интегрирован с
|
329
|
-
[@e22m4u/
|
329
|
+
[@e22m4u/js-data-schema](https://www.npmjs.com/package/@e22m4u/js-data-schema)
|
330
330
|
для гибкой проверки данных. Это дает возможность определять типы данных
|
331
331
|
и сложные правила.
|
332
332
|
|
package/dist/cjs/index.cjs
CHANGED
@@ -92,8 +92,8 @@ var DebuggableService = _DebuggableService;
|
|
92
92
|
// dist/esm/controller-registry.js
|
93
93
|
var import_js_format2 = require("@e22m4u/js-format");
|
94
94
|
var import_js_trie_router2 = require("@e22m4u/js-trie-router");
|
95
|
-
var
|
96
|
-
var
|
95
|
+
var import_js_data_schema2 = require("@e22m4u/js-data-schema");
|
96
|
+
var import_js_data_schema3 = require("@e22m4u/js-data-schema");
|
97
97
|
|
98
98
|
// dist/esm/errors/not-a-controller-error.js
|
99
99
|
var import_js_format = require("@e22m4u/js-format");
|
@@ -210,7 +210,7 @@ var RequestDataSource;
|
|
210
210
|
var REQUEST_DATA_METADATA_KEY = new import_ts_reflector5.MetadataKey("requestDataMetadataKey");
|
211
211
|
|
212
212
|
// dist/esm/decorators/request-data/request-data-decorator.js
|
213
|
-
var
|
213
|
+
var import_js_data_schema = require("@e22m4u/js-data-schema");
|
214
214
|
var import_ts_reflector7 = require("@e22m4u/ts-reflector");
|
215
215
|
var import_ts_reflector8 = require("@e22m4u/ts-reflector");
|
216
216
|
|
@@ -263,7 +263,7 @@ function createRequestDataDecoratorWithSource(source) {
|
|
263
263
|
} else if (typeof schemaInput === "string") {
|
264
264
|
schema = { type: schemaInput };
|
265
265
|
} else {
|
266
|
-
schema = { type:
|
266
|
+
schema = { type: import_js_data_schema.DataType.ANY };
|
267
267
|
}
|
268
268
|
return requestData({ schema, source });
|
269
269
|
};
|
@@ -271,7 +271,7 @@ function createRequestDataDecoratorWithSource(source) {
|
|
271
271
|
__name(createRequestDataDecoratorWithSource, "createRequestDataDecoratorWithSource");
|
272
272
|
function createRequestDataPropertyDecoratorWithSource(source) {
|
273
273
|
return function(propertyKey, schemaInput) {
|
274
|
-
const rootSchema = { type:
|
274
|
+
const rootSchema = { type: import_js_data_schema.DataType.OBJECT };
|
275
275
|
const properties = {};
|
276
276
|
let schemaOrFactory = rootSchema;
|
277
277
|
if (typeof schemaInput === "function") {
|
@@ -287,7 +287,7 @@ function createRequestDataPropertyDecoratorWithSource(source) {
|
|
287
287
|
properties[propertyKey] = { type: schemaInput };
|
288
288
|
rootSchema.properties = properties;
|
289
289
|
} else {
|
290
|
-
properties[propertyKey] = { type:
|
290
|
+
properties[propertyKey] = { type: import_js_data_schema.DataType.ANY };
|
291
291
|
rootSchema.properties = properties;
|
292
292
|
}
|
293
293
|
return requestData({
|
@@ -578,7 +578,7 @@ function requestContainer() {
|
|
578
578
|
__name(requestContainer, "requestContainer");
|
579
579
|
|
580
580
|
// dist/esm/controller-registry.js
|
581
|
-
var
|
581
|
+
var import_js_data_schema4 = require("@e22m4u/js-data-schema");
|
582
582
|
var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
|
583
583
|
/**
|
584
584
|
* Controller map.
|
@@ -859,9 +859,9 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
|
|
859
859
|
const requestContextMetadataMap = RequestContextReflector.getMetadata(controllerCtor, actionName);
|
860
860
|
const requestDataMetadataMap = RequestDataReflector.getMetadata(controllerCtor, actionName);
|
861
861
|
const argsNumber = controllerCtor.prototype[actionName].length;
|
862
|
-
const defaultsApplier = this.getService(
|
863
|
-
const dataTypeCaster = this.getService(
|
864
|
-
const dataValidator = this.getService(
|
862
|
+
const defaultsApplier = this.getService(import_js_data_schema4.DefaultValuesApplier);
|
863
|
+
const dataTypeCaster = this.getService(import_js_data_schema3.DataTypeCaster);
|
864
|
+
const dataValidator = this.getService(import_js_data_schema2.DataValidator);
|
865
865
|
return (requestContext2) => {
|
866
866
|
debug("Executing route handler for %s.%s.", controllerCtor.name, actionName);
|
867
867
|
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/js-data-schema';
|
4
|
+
import { DataTypeCaster } from '@e22m4u/js-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/js-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/js-data-schema';
|
2
|
+
import { DataSchema } from '@e22m4u/js-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/js-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/js-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/js-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.4",
|
4
4
|
"description": "Декларативный REST-маршрутизатор на основе контроллеров для TypeScript",
|
5
5
|
"author": "Mikhail Evstropov <e22m4u@yandex.ru>",
|
6
6
|
"license": "MIT",
|
@@ -43,9 +43,9 @@
|
|
43
43
|
"dependencies": {
|
44
44
|
"@e22m4u/js-debug": "~0.3.1",
|
45
45
|
"@e22m4u/js-format": "~0.2.0",
|
46
|
-
"@e22m4u/js-service": "~0.4.
|
47
|
-
"@e22m4u/js-trie-router": "~0.3.
|
48
|
-
"@e22m4u/
|
46
|
+
"@e22m4u/js-service": "~0.4.3",
|
47
|
+
"@e22m4u/js-trie-router": "~0.3.2",
|
48
|
+
"@e22m4u/js-data-schema": "~0.4.6",
|
49
49
|
"@e22m4u/ts-reflector": "~0.1.8",
|
50
50
|
"http-errors": "~2.0.0"
|
51
51
|
},
|
@@ -57,7 +57,7 @@
|
|
57
57
|
"@types/debug": "~4.1.12",
|
58
58
|
"@types/http-errors": "~2.0.5",
|
59
59
|
"@types/mocha": "~10.0.10",
|
60
|
-
"@types/node": "~24.7.
|
60
|
+
"@types/node": "~24.7.2",
|
61
61
|
"c8": "~10.1.3",
|
62
62
|
"chai": "~6.2.0",
|
63
63
|
"esbuild": "~0.25.10",
|
@@ -71,6 +71,6 @@
|
|
71
71
|
"rimraf": "~6.0.1",
|
72
72
|
"tsx": "~4.20.6",
|
73
73
|
"typescript": "~5.9.3",
|
74
|
-
"typescript-eslint": "~8.46.
|
74
|
+
"typescript-eslint": "~8.46.1"
|
75
75
|
}
|
76
76
|
}
|
@@ -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/js-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/js-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/js-data-schema';
|
8
|
+
import {DataTypeCaster} from '@e22m4u/js-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/js-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/js-data-schema';
|
2
|
+
import {DataSchema} from '@e22m4u/js-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/js-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/js-data-schema';
|
5
|
+
import {DataSchema} from '@e22m4u/js-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';
|