@tsed/schema 8.34.0 → 8.35.0
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/lib/esm/compat.js +8 -0
- package/lib/esm/components/index.js +37 -27
- package/lib/esm/components/{default → mappers/default}/anyMapper.js +5 -5
- package/lib/esm/components/{default → mappers/default}/classMapper.js +5 -5
- package/lib/esm/components/{default → mappers/default}/discriminatorMappingMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/enumsMapper.js +2 -2
- package/lib/esm/components/{default → mappers/default}/genericsMapper.js +7 -6
- package/lib/esm/components/{default → mappers/default}/inheritedClassMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/lazyRefMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/mapMapper.js +2 -2
- package/lib/esm/components/{default → mappers/default}/nextMapper.js +16 -16
- package/lib/esm/components/{default → mappers/default}/nullableMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/objectMapper.js +4 -4
- package/lib/esm/components/mappers/default/ofMapper.js +9 -0
- package/lib/esm/components/{default → mappers/default}/requiredMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/schemaMapper.js +11 -6
- package/lib/esm/components/mappers/open-spec/discriminatorMappingMapper.js +8 -0
- package/lib/esm/components/mappers/open-spec/enumsMapper.js +12 -0
- package/lib/esm/components/{open-spec → mappers/open-spec}/generate.js +3 -4
- package/lib/esm/components/{open-spec → mappers/open-spec}/nullableMapper.js +3 -4
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationInFilesMapper.js +2 -2
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationInParameterMapper.js +3 -3
- package/lib/esm/components/mappers/open-spec/operationInParametersMapper.js +5 -0
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationInQueryMapper.js +3 -3
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationMapper.js +4 -4
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationMediaMapper.js +2 -2
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationRequestBodyMapper.js +4 -4
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationResponseMapper.js +2 -2
- package/lib/esm/components/{open-spec → mappers/open-spec}/pathsMapper.js +10 -10
- package/lib/esm/{domain → components/stores}/JsonClassStore.js +8 -13
- package/lib/esm/{domain → components/stores}/JsonMethodStore.js +33 -28
- package/lib/esm/{domain → components/stores}/JsonParameterStore.js +14 -18
- package/lib/esm/{domain → components/stores}/JsonPropertyStore.js +15 -18
- package/lib/esm/components/types/arrayType.js +15 -0
- package/lib/esm/components/types/classType.js +8 -0
- package/lib/esm/components/types/genericType.js +8 -0
- package/lib/esm/components/types/mapType.js +15 -0
- package/lib/esm/components/types/primitiveType.js +21 -0
- package/lib/esm/components/types/setType.js +12 -0
- package/lib/esm/decorators/class/discriminatorValue.js +1 -1
- package/lib/esm/decorators/collections/collectionOf.js +2 -2
- package/lib/esm/decorators/collections/maxItems.js +1 -1
- package/lib/esm/decorators/collections/maxProperties.js +1 -1
- package/lib/esm/decorators/collections/minItems.js +1 -1
- package/lib/esm/decorators/collections/minProperties.js +1 -1
- package/lib/esm/decorators/collections/uniqueItems.js +1 -1
- package/lib/esm/decorators/common/defaultMsg.js +1 -1
- package/lib/esm/decorators/common/discriminatorKey.js +1 -1
- package/lib/esm/decorators/common/enum.js +1 -1
- package/lib/esm/decorators/common/exclusiveMaximum.js +1 -1
- package/lib/esm/decorators/common/exclusiveMinimum.js +1 -1
- package/lib/esm/decorators/common/format.js +1 -1
- package/lib/esm/decorators/common/jsonEntityFn.js +2 -2
- package/lib/esm/decorators/common/maxLength.js +1 -1
- package/lib/esm/decorators/common/maximum.js +1 -1
- package/lib/esm/decorators/common/minLength.js +1 -1
- package/lib/esm/decorators/common/minimum.js +1 -1
- package/lib/esm/decorators/common/multipleOf.js +1 -1
- package/lib/esm/decorators/common/name.js +1 -1
- package/lib/esm/decorators/common/nullable.js +2 -2
- package/lib/esm/decorators/common/pattern.js +1 -1
- package/lib/esm/decorators/common/required.js +1 -1
- package/lib/esm/decorators/common/requiredGroups.js +1 -1
- package/lib/esm/decorators/common/typeError.js +1 -1
- package/lib/esm/decorators/config/jsonEntityComponent.js +3 -2
- package/lib/esm/decorators/generics/genericOf.js +2 -2
- package/lib/esm/decorators/generics/generics.js +2 -3
- package/lib/esm/decorators/operations/consumes.js +1 -1
- package/lib/esm/decorators/operations/deprecated.js +1 -1
- package/lib/esm/decorators/operations/header.js +1 -1
- package/lib/esm/decorators/operations/in.js +5 -6
- package/lib/esm/decorators/operations/inFile.js +2 -2
- package/lib/esm/decorators/operations/operation.js +1 -1
- package/lib/esm/decorators/operations/produces.js +1 -1
- package/lib/esm/decorators/operations/publish.js +1 -1
- package/lib/esm/decorators/operations/returns.js +4 -4
- package/lib/esm/decorators/operations/route.js +1 -1
- package/lib/esm/decorators/operations/security.js +1 -1
- package/lib/esm/decorators/operations/subscribe.js +1 -1
- package/lib/esm/decorators/operations/tags.js +1 -1
- package/lib/esm/domain/DecoratorContext.js +2 -2
- package/lib/esm/domain/JsonEntityStore.js +7 -41
- package/lib/esm/domain/JsonLazyRef.js +1 -1
- package/lib/esm/domain/JsonMap.js +1 -1
- package/lib/esm/domain/JsonOperation.js +1 -1
- package/lib/esm/domain/JsonParameter.js +3 -3
- package/lib/esm/domain/JsonRequestBody.js +1 -1
- package/lib/esm/domain/JsonResponse.js +2 -2
- package/lib/esm/domain/JsonSchema.js +92 -137
- package/lib/esm/domain/index.js +26 -0
- package/lib/esm/{utils/getJsonSchema.js → fn/compile.js} +20 -7
- package/lib/esm/fn/enums.js +1 -1
- package/lib/esm/fn/from.js +32 -9
- package/lib/esm/fn/generic.js +9 -0
- package/lib/esm/fn/index.js +25 -4
- package/lib/esm/fn/lazyRef.js +3 -3
- package/lib/esm/fn/oas/compileSpec.js +9 -0
- package/lib/esm/{utils → fn/oas}/generateSpec.js +2 -2
- package/lib/esm/{utils → fn/oas}/getSpec.js +4 -4
- package/lib/esm/{utils → fn/oas}/getSpecType.js +1 -1
- package/lib/esm/{utils → fn/oas}/mapOpenSpec.js +1 -1
- package/lib/esm/hooks/alterOneOf.js +1 -1
- package/lib/esm/index.js +59 -48
- package/lib/esm/registries/JsonEntitiesContainer.js +38 -0
- package/lib/esm/registries/JsonSchemaMapperContainer.js +10 -1
- package/lib/esm/registries/JsonTypesContainer.js +18 -0
- package/lib/esm/utils/generics.js +15 -2
- package/lib/esm/utils/getInheritedStores.js +1 -1
- package/lib/esm/utils/getOperationsRoutes.js +3 -3
- package/lib/esm/utils/getOperationsStores.js +4 -4
- package/lib/esm/utils/getPropertiesStores.js +2 -2
- package/lib/esm/utils/ref.js +2 -2
- package/lib/types/compat.d.ts +17 -0
- package/lib/types/components/index.d.ts +37 -27
- package/lib/types/components/{default → mappers/default}/anyMapper.d.ts +1 -1
- package/lib/types/components/mappers/default/classMapper.d.ts +3 -0
- package/lib/types/components/{default → mappers/default}/discriminatorMappingMapper.d.ts +2 -2
- package/lib/types/components/mappers/default/enumsMapper.d.ts +3 -0
- package/lib/types/components/{default → mappers/default}/genericsMapper.d.ts +2 -2
- package/lib/types/components/{default → mappers/default}/inheritedClassMapper.d.ts +1 -1
- package/lib/types/components/mappers/default/lazyRefMapper.d.ts +3 -0
- package/lib/types/components/{default → mappers/default}/mapMapper.d.ts +1 -1
- package/lib/types/components/{default → mappers/default}/nextMapper.d.ts +2 -2
- package/lib/types/components/{default → mappers/default}/nullableMapper.d.ts +1 -1
- package/lib/types/components/{default → mappers/default}/objectMapper.d.ts +1 -1
- package/lib/types/components/mappers/default/ofMapper.d.ts +3 -0
- package/lib/types/components/mappers/default/requiredMapper.d.ts +3 -0
- package/lib/types/components/mappers/default/schemaMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/enumsMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/generate.d.ts +1 -0
- package/lib/types/components/mappers/open-spec/nullableMapper.d.ts +3 -0
- package/lib/types/components/{open-spec → mappers/open-spec}/operationInParameterMapper.d.ts +3 -3
- package/lib/types/components/mappers/open-spec/operationInParametersMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/operationMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/operationMediaMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/operationRequestBodyMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/operationResponseMapper.d.ts +3 -0
- package/lib/types/components/{open-spec → mappers/open-spec}/pathsMapper.d.ts +1 -1
- package/lib/types/{domain → components/stores}/JsonClassStore.d.ts +4 -4
- package/lib/types/{domain → components/stores}/JsonMethodStore.d.ts +33 -19
- package/lib/types/{domain → components/stores}/JsonParameterStore.d.ts +9 -5
- package/lib/types/{domain → components/stores}/JsonPropertyStore.d.ts +7 -4
- package/lib/types/components/types/arrayType.d.ts +2 -0
- package/lib/types/components/types/classType.d.ts +2 -0
- package/lib/types/components/types/genericType.d.ts +2 -0
- package/lib/types/components/types/mapType.d.ts +2 -0
- package/lib/types/components/types/primitiveType.d.ts +2 -0
- package/lib/types/components/types/setType.d.ts +2 -0
- package/lib/types/decorators/common/any.d.ts +1 -1
- package/lib/types/decorators/common/examples.d.ts +1 -1
- package/lib/types/decorators/common/format.d.ts +1 -1
- package/lib/types/decorators/common/ignore.d.ts +1 -1
- package/lib/types/decorators/common/jsonEntityFn.d.ts +1 -1
- package/lib/types/decorators/config/jsonEntityComponent.d.ts +2 -1
- package/lib/types/decorators/generics/genericOf.d.ts +1 -1
- package/lib/types/decorators/operations/header.d.ts +1 -1
- package/lib/types/decorators/operations/in.d.ts +1 -2
- package/lib/types/decorators/operations/location.d.ts +1 -1
- package/lib/types/decorators/operations/redirect.d.ts +1 -1
- package/lib/types/decorators/operations/returns.d.ts +3 -3
- package/lib/types/decorators/operations/status.d.ts +1 -1
- package/lib/types/domain/Generics.d.ts +6 -0
- package/lib/types/domain/JsonEntityStore.d.ts +8 -19
- package/lib/types/domain/JsonLazyRef.d.ts +1 -1
- package/lib/types/domain/JsonMap.d.ts +1 -1
- package/lib/types/domain/JsonMedia.d.ts +1 -1
- package/lib/types/domain/JsonOperation.d.ts +2 -2
- package/lib/types/domain/JsonOperationRoute.d.ts +3 -3
- package/lib/types/domain/JsonParameter.d.ts +3 -3
- package/lib/types/domain/JsonRequestBody.d.ts +1 -1
- package/lib/types/domain/JsonResponse.d.ts +1 -1
- package/lib/types/domain/JsonSchema.d.ts +28 -22
- package/lib/types/{interfaces → domain}/JsonSchemaOptions.d.ts +14 -6
- package/lib/types/domain/__fixtures__/inspectOperationsPaths.d.ts +1 -1
- package/lib/types/domain/index.d.ts +26 -0
- package/lib/types/domain/types.d.ts +1 -1
- package/lib/types/fn/any.d.ts +1 -1
- package/lib/types/fn/boolean.d.ts +1 -1
- package/lib/types/{utils → fn}/compile.d.ts +10 -3
- package/lib/types/fn/date.d.ts +3 -3
- package/lib/types/fn/email.d.ts +1 -1
- package/lib/types/fn/from.d.ts +31 -3
- package/lib/types/fn/generic.d.ts +10 -0
- package/lib/types/fn/index.d.ts +24 -3
- package/lib/types/fn/integer.d.ts +1 -1
- package/lib/types/fn/lazyRef.d.ts +1 -1
- package/lib/types/fn/number.d.ts +1 -1
- package/lib/types/fn/oas/compileSpec.d.ts +6 -0
- package/lib/types/{utils → fn/oas}/getSpec.d.ts +1 -1
- package/lib/types/{utils → fn/oas}/getSpecType.d.ts +1 -1
- package/lib/types/{utils → fn/oas}/transformToOS2.d.ts +1 -1
- package/lib/types/fn/object.d.ts +1 -1
- package/lib/types/fn/string.d.ts +1 -1
- package/lib/types/fn/uri.d.ts +1 -1
- package/lib/types/fn/url.d.ts +1 -1
- package/lib/types/hooks/alterOneOf.d.ts +1 -1
- package/lib/types/hooks/alterRequiredGroups.d.ts +1 -1
- package/lib/types/index.d.ts +59 -48
- package/lib/types/{utils/getJsonEntityStore.d.ts → registries/JsonEntitiesContainer.d.ts} +5 -10
- package/lib/types/registries/JsonSchemaMapperContainer.d.ts +7 -1
- package/lib/types/registries/JsonTypesContainer.d.ts +15 -0
- package/lib/types/registries/{enumRegistries.d.ts → enumRegistry.d.ts} +1 -1
- package/lib/types/utils/generics.d.ts +13 -5
- package/lib/types/utils/getInheritedStores.d.ts +1 -1
- package/lib/types/utils/getOperationsRoutes.d.ts +3 -3
- package/lib/types/utils/getOperationsStores.d.ts +1 -1
- package/lib/types/utils/getPropertiesStores.d.ts +1 -1
- package/lib/types/utils/mapHeaders.d.ts +1 -1
- package/lib/types/utils/operationIdFormatter.d.ts +1 -1
- package/lib/types/utils/ref.d.ts +1 -1
- package/lib/types/utils/removeHiddenOperation.d.ts +1 -1
- package/lib/types/utils/toJsonMapCollection.d.ts +1 -1
- package/package.json +18 -19
- package/lib/esm/components/default/ofMapper.js +0 -9
- package/lib/esm/components/open-spec/discriminatorMappingMapper.js +0 -6
- package/lib/esm/components/open-spec/enumsMapper.js +0 -14
- package/lib/esm/components/open-spec/operationInParametersMapper.js +0 -5
- package/lib/esm/utils/compile.js +0 -13
- package/lib/esm/utils/getJsonEntityStore.js +0 -13
- package/lib/types/components/default/classMapper.d.ts +0 -3
- package/lib/types/components/default/enumsMapper.d.ts +0 -3
- package/lib/types/components/default/lazyRefMapper.d.ts +0 -3
- package/lib/types/components/default/ofMapper.d.ts +0 -3
- package/lib/types/components/default/requiredMapper.d.ts +0 -3
- package/lib/types/components/default/schemaMapper.d.ts +0 -3
- package/lib/types/components/open-spec/enumsMapper.d.ts +0 -3
- package/lib/types/components/open-spec/nullableMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationInParametersMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationMediaMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationRequestBodyMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationResponseMapper.d.ts +0 -3
- package/lib/types/utils/getJsonSchema.d.ts +0 -6
- package/lib/esm/{interfaces/IgnoreCallback.js → domain/Generics.js} +0 -0
- package/lib/esm/{interfaces/JsonHookContext.js → domain/IgnoreCallback.js} +0 -0
- package/lib/esm/{interfaces/JsonOpenSpec.js → domain/JsonHookContext.js} +0 -0
- package/lib/esm/{interfaces/JsonSchemaOptions.js → domain/JsonOpenSpec.js} +0 -0
- package/lib/{types/components/open-spec/discriminatorMappingMapper.d.ts → esm/domain/JsonSchemaOptions.js} +0 -0
- package/lib/esm/{utils → fn/oas}/mapOpenSpec2.js +0 -0
- package/lib/esm/{utils → fn/oas}/mapOpenSpec3.js +0 -0
- package/lib/esm/{utils → fn/oas}/mapOpenSpecInfo.js +0 -0
- package/lib/esm/{utils → fn/oas}/mergeSpec.js +0 -0
- package/lib/esm/{utils → fn/oas}/transformToOS2.js +0 -0
- package/lib/esm/registries/{enumRegistries.js → enumRegistry.js} +0 -0
- package/lib/types/components/{open-spec/generate.d.ts → mappers/open-spec/discriminatorMappingMapper.d.ts} +0 -0
- package/lib/types/components/{open-spec → mappers/open-spec}/operationInFilesMapper.d.ts +0 -0
- package/lib/types/components/{open-spec → mappers/open-spec}/operationInQueryMapper.d.ts +0 -0
- package/lib/types/{interfaces → domain}/IgnoreCallback.d.ts +0 -0
- package/lib/types/{interfaces → domain}/JsonHookContext.d.ts +0 -0
- package/lib/types/{interfaces → domain}/JsonOpenSpec.d.ts +0 -0
- package/lib/types/{utils → fn/oas}/generateSpec.d.ts +1 -1
- /package/lib/types/{utils → fn/oas}/mapOpenSpec.d.ts +0 -0
- /package/lib/types/{utils → fn/oas}/mapOpenSpec2.d.ts +0 -0
- /package/lib/types/{utils → fn/oas}/mapOpenSpec3.d.ts +0 -0
- /package/lib/types/{utils → fn/oas}/mapOpenSpecInfo.d.ts +0 -0
- /package/lib/types/{utils → fn/oas}/mergeSpec.d.ts +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { JsonSchema } from "./JsonSchema.js";
|
|
1
|
+
import { DecoratorTypes, Store, deepMerge, descriptorOf, isFunction } from "@tsed/core";
|
|
2
|
+
import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
3
|
+
import { defineStore, getJsonEntityStore } from "../../registries/JsonEntitiesContainer.js";
|
|
4
|
+
import { JsonOperation } from "../../domain/JsonOperation.js";
|
|
5
|
+
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
6
|
+
import { isSuccessStatus } from "../../utils/isSuccessStatus.js";
|
|
8
7
|
/**
|
|
9
8
|
* Store for method metadata, operations, and parameter information.
|
|
10
9
|
*
|
|
@@ -24,7 +23,7 @@ import { JsonSchema } from "./JsonSchema.js";
|
|
|
24
23
|
*
|
|
25
24
|
* ```typescript
|
|
26
25
|
* // Get method store
|
|
27
|
-
* const methodStore =
|
|
26
|
+
* const methodStore = getJsonEntityStore(MyController, "myMethod");
|
|
28
27
|
*
|
|
29
28
|
* // Access operation for OpenAPI
|
|
30
29
|
* const operation = methodStore.operation;
|
|
@@ -61,14 +60,14 @@ import { JsonSchema } from "./JsonSchema.js";
|
|
|
61
60
|
*
|
|
62
61
|
* @public
|
|
63
62
|
*/
|
|
64
|
-
|
|
63
|
+
export class JsonMethodStore extends JsonEntityStore {
|
|
65
64
|
constructor(options) {
|
|
66
65
|
super({
|
|
67
66
|
store: Store.fromMethod(options.target, options.propertyKey),
|
|
68
67
|
descriptor: descriptorOf(options.target, options.propertyKey),
|
|
69
68
|
...options
|
|
70
69
|
});
|
|
71
|
-
this.parent =
|
|
70
|
+
this.parent = getJsonEntityStore(this.target);
|
|
72
71
|
this.middlewares = [];
|
|
73
72
|
this.beforeMiddlewares = [];
|
|
74
73
|
this.afterMiddlewares = [];
|
|
@@ -134,16 +133,6 @@ let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
|
|
|
134
133
|
}
|
|
135
134
|
return this._schema;
|
|
136
135
|
}
|
|
137
|
-
/**
|
|
138
|
-
* Get an endpoint.
|
|
139
|
-
* @param target
|
|
140
|
-
* @param propertyKey
|
|
141
|
-
* @param descriptor
|
|
142
|
-
*/
|
|
143
|
-
static get(target, propertyKey, descriptor) {
|
|
144
|
-
descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);
|
|
145
|
-
return JsonEntityStore.from(prototypeOf(target), propertyKey, descriptor);
|
|
146
|
-
}
|
|
147
136
|
/**
|
|
148
137
|
* TODO must be located on JsonOperation level directly
|
|
149
138
|
* @param status
|
|
@@ -165,7 +154,7 @@ let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
|
|
|
165
154
|
/**
|
|
166
155
|
* Append middlewares to the beforeMiddlewares list.
|
|
167
156
|
* @param args
|
|
168
|
-
* @returns {
|
|
157
|
+
* @returns {JsonMethodStore}
|
|
169
158
|
*/
|
|
170
159
|
before(args) {
|
|
171
160
|
this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);
|
|
@@ -174,7 +163,7 @@ let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
|
|
|
174
163
|
/**
|
|
175
164
|
* Append middlewares to the afterMiddlewares list.
|
|
176
165
|
* @param args
|
|
177
|
-
* @returns {
|
|
166
|
+
* @returns {JsonMethodStore}
|
|
178
167
|
*/
|
|
179
168
|
after(args) {
|
|
180
169
|
this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);
|
|
@@ -209,10 +198,26 @@ let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
|
|
|
209
198
|
build() {
|
|
210
199
|
this.parent.children.set(this.propertyName, this);
|
|
211
200
|
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* JsonMethodStore contains metadata about a controller and his method.
|
|
204
|
+
* Each annotation (@Get, @Body...) attached to a method are stored into endpoint.
|
|
205
|
+
* JsonMethodStore converts this metadata to an array which contain arguments to call an Express method.
|
|
206
|
+
*
|
|
207
|
+
* Example :
|
|
208
|
+
*
|
|
209
|
+
*```ts
|
|
210
|
+
* @Controller("/my-path")
|
|
211
|
+
* provide MyClass {
|
|
212
|
+
*
|
|
213
|
+
* @Get("/")
|
|
214
|
+
* @Authenticated()
|
|
215
|
+
* public myMethod(){}
|
|
216
|
+
* }
|
|
217
|
+
*```
|
|
218
|
+
*
|
|
219
|
+
* @alias JsonMethodStore
|
|
220
|
+
* @deprecated use s.store.method() to retrieve endpoint metadata or JsonMethodStore instead
|
|
221
|
+
*/
|
|
218
222
|
export const EndpointMetadata = JsonMethodStore;
|
|
223
|
+
defineStore(DecoratorTypes.METHOD, JsonMethodStore);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { JsonParameter } from "./JsonParameter.js";
|
|
1
|
+
import { DecoratorTypes, Metadata, ancestorsOf, isClass, isMethodDescriptor, prototypeOf } from "@tsed/core";
|
|
2
|
+
import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
3
|
+
import { defineStore, getJsonMethodStore } from "../../registries/JsonEntitiesContainer.js";
|
|
4
|
+
import { JsonParameter } from "../../domain/JsonParameter.js";
|
|
6
5
|
/**
|
|
7
6
|
* Store for method parameter metadata and schema information.
|
|
8
7
|
*
|
|
@@ -74,14 +73,14 @@ import { JsonParameter } from "./JsonParameter.js";
|
|
|
74
73
|
*
|
|
75
74
|
* @public
|
|
76
75
|
*/
|
|
77
|
-
|
|
76
|
+
export class JsonParameterStore extends JsonEntityStore {
|
|
78
77
|
constructor(options) {
|
|
79
78
|
super(options);
|
|
80
79
|
/**
|
|
81
80
|
* Ref to JsonParameter when the decorated object is a parameter.
|
|
82
81
|
*/
|
|
83
82
|
this.parameter = new JsonParameter();
|
|
84
|
-
this.parent =
|
|
83
|
+
this.parent = getJsonMethodStore(this.target, this.propertyKey);
|
|
85
84
|
this.pipes = options.pipes || [];
|
|
86
85
|
this.paramType = options.paramType || this.paramType;
|
|
87
86
|
this.expression = options.expression || this.expression;
|
|
@@ -108,19 +107,16 @@ let JsonParameterStore = class JsonParameterStore extends JsonEntityStore {
|
|
|
108
107
|
const klass = ancestorsOf(target)
|
|
109
108
|
.reverse()
|
|
110
109
|
.find((target) => {
|
|
111
|
-
return isMethodDescriptor(target, propertyKey) &&
|
|
110
|
+
return isMethodDescriptor(target, propertyKey) && getJsonMethodStore(target, propertyKey).children.size;
|
|
112
111
|
});
|
|
113
112
|
if (klass) {
|
|
114
|
-
|
|
113
|
+
getJsonMethodStore(klass, propertyKey).children.forEach((param, index) => {
|
|
115
114
|
params[+index] = param;
|
|
116
115
|
});
|
|
117
116
|
return params;
|
|
118
117
|
}
|
|
119
118
|
return [];
|
|
120
119
|
}
|
|
121
|
-
static get(target, propertyKey, index) {
|
|
122
|
-
return JsonEntityStore.from(prototypeOf(target), propertyKey, index);
|
|
123
|
-
}
|
|
124
120
|
/**
|
|
125
121
|
* Check precondition between value, required and allowedRequiredValues to know if the entity is required.
|
|
126
122
|
* @param value
|
|
@@ -147,10 +143,10 @@ let JsonParameterStore = class JsonParameterStore extends JsonEntityStore {
|
|
|
147
143
|
this.parameter.itemSchema().type(this._type);
|
|
148
144
|
}
|
|
149
145
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
export { JsonParameterStore };
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @alias JsonParameterStore
|
|
149
|
+
* @deprecated
|
|
150
|
+
*/
|
|
156
151
|
export const ParamMetadata = JsonParameterStore;
|
|
152
|
+
defineStore(DecoratorTypes.PARAM, JsonParameterStore);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { JsonSchema } from "./JsonSchema.js";
|
|
1
|
+
import { DecoratorTypes, Metadata, isClass, prototypeOf } from "@tsed/core";
|
|
2
|
+
import { defineStore, getJsonEntityStore } from "../../registries/JsonEntitiesContainer.js";
|
|
3
|
+
import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
4
|
+
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
6
5
|
/**
|
|
7
6
|
* Store for property metadata and schema information.
|
|
8
7
|
*
|
|
@@ -47,13 +46,10 @@ import { JsonSchema } from "./JsonSchema.js";
|
|
|
47
46
|
*
|
|
48
47
|
* @public
|
|
49
48
|
*/
|
|
50
|
-
|
|
49
|
+
export class JsonPropertyStore extends JsonEntityStore {
|
|
51
50
|
constructor() {
|
|
52
51
|
super(...arguments);
|
|
53
|
-
this.parent =
|
|
54
|
-
}
|
|
55
|
-
static get(target, propertyKey) {
|
|
56
|
-
return JsonEntityStore.from(prototypeOf(target), propertyKey);
|
|
52
|
+
this.parent = getJsonEntityStore(this.target);
|
|
57
53
|
}
|
|
58
54
|
build() {
|
|
59
55
|
if (!this._type) {
|
|
@@ -65,25 +61,26 @@ let JsonPropertyStore = class JsonPropertyStore extends JsonEntityStore {
|
|
|
65
61
|
if (!schema) {
|
|
66
62
|
this.parent.children.set(this.propertyName, this);
|
|
67
63
|
if (this.isCollection) {
|
|
68
|
-
schema = JsonSchema
|
|
64
|
+
schema = new JsonSchema({
|
|
69
65
|
type: this.collectionType
|
|
70
66
|
});
|
|
71
67
|
schema.itemSchema(this.type);
|
|
72
68
|
}
|
|
73
69
|
else if (isClass(this.type)) {
|
|
74
|
-
schema = JsonSchema
|
|
70
|
+
schema = new JsonSchema({ type: "object" });
|
|
75
71
|
schema.itemSchema(this.type);
|
|
76
72
|
}
|
|
77
73
|
else {
|
|
78
|
-
schema = JsonSchema
|
|
74
|
+
schema = new JsonSchema({ type: this.type });
|
|
79
75
|
}
|
|
80
76
|
}
|
|
81
77
|
this.parent.schema.addProperty(this.propertyName, schema);
|
|
82
78
|
this._schema = schema;
|
|
83
79
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @alias JsonPropertyStore
|
|
83
|
+
* @deprecated
|
|
84
|
+
*/
|
|
89
85
|
export const PropertyMetadata = JsonPropertyStore;
|
|
86
|
+
defineStore(DecoratorTypes.PROP, JsonPropertyStore);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineType } from "../../registries/JsonTypesContainer.js";
|
|
2
|
+
export default defineType({
|
|
3
|
+
name: "array",
|
|
4
|
+
priority: 1000,
|
|
5
|
+
isCollection: true,
|
|
6
|
+
match(type) {
|
|
7
|
+
return [Array, "array"].includes(type);
|
|
8
|
+
},
|
|
9
|
+
jsonType() {
|
|
10
|
+
return "array";
|
|
11
|
+
},
|
|
12
|
+
init(schema) {
|
|
13
|
+
return schema.toCollection().target(Array).items(schema.itemSchema({}), true);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineType } from "../../registries/JsonTypesContainer.js";
|
|
2
|
+
import { isClass, isFunction } from "@tsed/core";
|
|
3
|
+
export default defineType({
|
|
4
|
+
name: "class",
|
|
5
|
+
priority: 20,
|
|
6
|
+
match: (type) => isClass(type) || isFunction(type),
|
|
7
|
+
init: (schema, type) => schema.unsetType().target(type).properties({})
|
|
8
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineType } from "../../registries/JsonTypesContainer.js";
|
|
2
|
+
import { getJsonType } from "../../utils/getJsonType.js";
|
|
3
|
+
export default defineType({
|
|
4
|
+
name: "generic",
|
|
5
|
+
priority: 10,
|
|
6
|
+
match: (type) => getJsonType(type) === "generic",
|
|
7
|
+
init: (schema, type) => schema.genericLabel(type)
|
|
8
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineType } from "../../registries/JsonTypesContainer.js";
|
|
2
|
+
export default defineType({
|
|
3
|
+
name: "map",
|
|
4
|
+
priority: 1000,
|
|
5
|
+
isCollection: true,
|
|
6
|
+
match(type) {
|
|
7
|
+
return [Map, this.name].includes(type);
|
|
8
|
+
},
|
|
9
|
+
jsonType() {
|
|
10
|
+
return "object";
|
|
11
|
+
},
|
|
12
|
+
init(schema) {
|
|
13
|
+
return schema.toCollection().target(Map).additionalProperties({}, true);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineType } from "../../registries/JsonTypesContainer.js";
|
|
2
|
+
import { getJsonType } from "../../utils/getJsonType.js";
|
|
3
|
+
import { isTemporal } from "@tsed/core";
|
|
4
|
+
export default defineType({
|
|
5
|
+
name: "primitive",
|
|
6
|
+
priority: 500,
|
|
7
|
+
jsonType: getJsonType,
|
|
8
|
+
match(type) {
|
|
9
|
+
return ["number", "string", "boolean", "object", "integer", Object, Date, Boolean, Number, String].includes(type) || isTemporal(type);
|
|
10
|
+
},
|
|
11
|
+
init(schema, type) {
|
|
12
|
+
schema.target(type);
|
|
13
|
+
if (type === "integer") {
|
|
14
|
+
schema.integer();
|
|
15
|
+
}
|
|
16
|
+
if (!schema.has("properties") && [Object, "object"].includes(type)) {
|
|
17
|
+
schema.properties({});
|
|
18
|
+
}
|
|
19
|
+
return schema;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineType } from "../../registries/JsonTypesContainer.js";
|
|
2
|
+
export default defineType({
|
|
3
|
+
name: "set",
|
|
4
|
+
priority: 1000,
|
|
5
|
+
match(type) {
|
|
6
|
+
return [Set, "set"].includes(type);
|
|
7
|
+
},
|
|
8
|
+
jsonType() {
|
|
9
|
+
return "array";
|
|
10
|
+
},
|
|
11
|
+
init: (schema) => schema.toCollection().target(Set).uniqueItems(true).items({}, true)
|
|
12
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DecoratorTypes } from "@tsed/core";
|
|
2
|
-
import {
|
|
2
|
+
import { s } from "../../fn/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...
|
|
5
5
|
*
|
|
@@ -40,7 +40,7 @@ export function CollectionOf(type, collectionType) {
|
|
|
40
40
|
let contains = false;
|
|
41
41
|
const nestedGenerics = [];
|
|
42
42
|
const decorator = (...args) => {
|
|
43
|
-
const store =
|
|
43
|
+
const store = s.store(...args);
|
|
44
44
|
if (collectionType) {
|
|
45
45
|
store.collectionType = collectionType;
|
|
46
46
|
store.schema.type(collectionType);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
/**
|
|
4
4
|
* If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useDecorators } from "@tsed/core";
|
|
2
1
|
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
3
2
|
import { Property } from "./property.js";
|
|
3
|
+
import { useDecorators } from "@tsed/core";
|
|
4
4
|
/**
|
|
5
5
|
* Marks a property as the discriminator key for polymorphic type resolution.
|
|
6
6
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
function EnumFn(enumValue, ...enumValues) {
|
|
4
4
|
return JsonEntityFn((store) => {
|
|
5
5
|
store.itemSchema.enum(enumValue, ...enumValues);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { Maximum } from "./maximum.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
/**
|
|
4
4
|
* The value of `exclusiveMaximum` MUST be number, representing an exclusive upper limit for a numeric instance.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { Minimum } from "./minimum.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
/**
|
|
4
4
|
* The value of `exclusiveMinimum` MUST be number, representing an exclusive upper limit for a numeric instance.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
1
2
|
import { JsonFormatTypes } from "../../domain/JsonFormatTypes.js";
|
|
2
3
|
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
|
-
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
4
4
|
/**
|
|
5
5
|
* Applies a format validation to string properties using JSON Schema's `format` keyword.
|
|
6
6
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s } from "../../fn/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Decorator util to compose another decorator. See @@Description@@ decorator implementation for more details.
|
|
4
4
|
*
|
|
@@ -19,7 +19,7 @@ import { getJsonEntityStore } from "../../utils/getJsonEntityStore.js";
|
|
|
19
19
|
*/
|
|
20
20
|
export function JsonEntityFn(fn) {
|
|
21
21
|
return (...parameters) => {
|
|
22
|
-
const result = fn(
|
|
22
|
+
const result = fn(s.store(...parameters), parameters);
|
|
23
23
|
if (typeof result === "function") {
|
|
24
24
|
result(...parameters);
|
|
25
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
/**
|
|
4
4
|
* A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
/**
|
|
4
4
|
* The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
/**
|
|
4
4
|
* The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
/**
|
|
4
4
|
* A numeric instance is valid only if division by this keyword's value results in an integer.
|
|
5
5
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useDecorators } from "@tsed/core";
|
|
2
|
-
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
3
|
-
import { array } from "../../fn/collection.js";
|
|
4
2
|
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
3
|
+
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
5
4
|
import { OneOf } from "./oneOf.js";
|
|
6
5
|
import { Property } from "./property.js";
|
|
6
|
+
import { array } from "../../fn/collection.js";
|
|
7
7
|
/**
|
|
8
8
|
* Marks a property as nullable, allowing it to accept `null` in addition to its base type.
|
|
9
9
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
2
1
|
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
2
|
+
import { withErrorMsg } from "../../utils/withErrorMsg.js";
|
|
3
3
|
/**
|
|
4
4
|
* The pattern and Pattern Properties keywords use regular expressions to express constraints.
|
|
5
5
|
* The regular expression syntax used is from JavaScript (ECMA 262, specifically). However, that complete syntax is not widely supported, therefore it is recommended that you stick to the subset of that syntax described below.
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineStore } from "../../registries/JsonEntitiesContainer.js";
|
|
2
2
|
/**
|
|
3
3
|
* Declare a new JsonEntityStore class for a specific decorator type.
|
|
4
4
|
*
|
|
5
5
|
* @ignore
|
|
6
6
|
* @param type
|
|
7
7
|
* @decorator
|
|
8
|
+
* @deprecated
|
|
8
9
|
*/
|
|
9
10
|
export function JsonEntityComponent(type) {
|
|
10
11
|
return (target) => {
|
|
11
|
-
|
|
12
|
+
defineStore(type, target);
|
|
12
13
|
};
|
|
13
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DecoratorTypes } from "@tsed/core";
|
|
2
|
-
import {
|
|
2
|
+
import { s } from "../../fn/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Set the types of a Generic class.
|
|
5
5
|
*
|
|
@@ -69,7 +69,7 @@ import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
|
69
69
|
export function GenericOf(...generics) {
|
|
70
70
|
const nestedGenerics = [generics];
|
|
71
71
|
const decorator = (...args) => {
|
|
72
|
-
const store =
|
|
72
|
+
const store = s.store(...args);
|
|
73
73
|
if (store.is(DecoratorTypes.PARAM)) {
|
|
74
74
|
store.parameter.schema().genericOf(...nestedGenerics);
|
|
75
75
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s } from "../../fn/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Define generics list. This list is used by @@GenericOf@@ and the @@compile@@ function to build the correct JsonSchema.
|
|
4
4
|
*
|
|
@@ -14,7 +14,6 @@ import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export function Generics(...genericLabels) {
|
|
16
16
|
return (target) => {
|
|
17
|
-
|
|
18
|
-
storedSchema.schema.genericLabels(genericLabels);
|
|
17
|
+
s.get(target).genericLabels(genericLabels);
|
|
19
18
|
};
|
|
20
19
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DecoratorTypes, UnsupportedDecoratorType, decorateMethodsOf } from "@tsed/core";
|
|
2
2
|
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
3
3
|
/**
|
|
4
4
|
* Add consumes metadata on the decorated element.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DecoratorTypes, UnsupportedDecoratorType, decorateMethodsOf, decoratorTypeOf } from "@tsed/core";
|
|
2
2
|
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
3
3
|
/**
|
|
4
4
|
* Add deprecated metadata on the decorated element.
|