@tsed/schema 7.79.3 → 7.80.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/browser/schema.umd.min.js.map +1 -1
- package/lib/cjs/components/default/inlineEnumsMapper.js +2 -2
- package/lib/cjs/components/default/inlineEnumsMapper.js.map +1 -1
- package/lib/cjs/components/default/nullableMapper.js +4 -4
- package/lib/cjs/components/default/nullableMapper.js.map +1 -1
- package/lib/cjs/components/default/requiredMapper.js +4 -4
- package/lib/cjs/components/default/requiredMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/nullableMapper.js +4 -4
- package/lib/cjs/components/open-spec/nullableMapper.js.map +1 -1
- package/lib/cjs/utils/generateSpec.js +1 -24
- package/lib/cjs/utils/generateSpec.js.map +1 -1
- package/lib/esm/components/default/inlineEnumsMapper.js.map +1 -1
- package/lib/esm/components/default/nullableMapper.js.map +1 -1
- package/lib/esm/components/default/requiredMapper.js.map +1 -1
- package/lib/esm/components/open-spec/nullableMapper.js.map +1 -1
- package/lib/esm/utils/getJsonSchema.js +1 -1
- package/lib/types/components/default/inlineEnumsMapper.d.ts +2 -2
- package/lib/types/components/default/nullableMapper.d.ts +1 -1
- package/lib/types/components/default/requiredMapper.d.ts +2 -2
- package/lib/types/components/open-spec/nullableMapper.d.ts +1 -1
- package/lib/types-esm/components/async-api/channelsMapper.d.ts +2 -0
- package/lib/types-esm/components/async-api/generate.d.ts +1 -0
- package/lib/types-esm/components/async-api/messageMapper.d.ts +6 -0
- package/lib/types-esm/components/async-api/payloadMapper.d.ts +4 -0
- package/lib/types-esm/components/async-api/responseMapper.d.ts +6 -0
- package/lib/types-esm/components/default/anyMapper.d.ts +2 -0
- package/lib/types-esm/components/default/classMapper.d.ts +3 -0
- package/lib/types-esm/components/default/genericsMapper.d.ts +5 -0
- package/lib/types-esm/components/default/inheritedClassMapper.d.ts +5 -0
- package/lib/types-esm/components/default/inlineEnumsMapper.d.ts +3 -0
- package/lib/types-esm/components/default/itemMapper.d.ts +2 -0
- package/lib/types-esm/components/default/lazyRefMapper.d.ts +3 -0
- package/lib/types-esm/components/default/mapMapper.d.ts +9 -0
- package/lib/types-esm/components/default/nullableMapper.d.ts +2 -0
- package/lib/types-esm/components/default/objectMapper.d.ts +8 -0
- package/lib/types-esm/components/default/ofMapper.d.ts +3 -0
- package/lib/types-esm/components/default/propertiesMapper.d.ts +3 -0
- package/lib/types-esm/components/default/requiredMapper.d.ts +3 -0
- package/lib/types-esm/components/default/schemaMapper.d.ts +3 -0
- package/lib/types-esm/components/index.d.ts +33 -0
- package/lib/types-esm/components/open-spec/generate.d.ts +1 -0
- package/lib/types-esm/components/open-spec/nullableMapper.d.ts +2 -0
- package/lib/types-esm/components/open-spec/operationInFilesMapper.d.ts +2 -0
- package/lib/types-esm/components/open-spec/operationInParameterMapper.d.ts +10 -0
- package/lib/types-esm/components/open-spec/operationInParametersMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationInQueryMapper.d.ts +2 -0
- package/lib/types-esm/components/open-spec/operationMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationMediaMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationRequestBodyMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationResponseMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/pathsMapper.d.ts +2 -0
- package/lib/types-esm/constants/OperationVerbs.d.ts +20 -0
- package/lib/types-esm/constants/httpStatusMessages.d.ts +11 -0
- package/lib/types-esm/constants/jsonSchemaProperties.d.ts +7 -0
- package/lib/types-esm/decorators/class/children.d.ts +11 -0
- package/lib/types-esm/decorators/class/discriminatorValue.d.ts +42 -0
- package/lib/types-esm/decorators/collections/collectionContains.d.ts +21 -0
- package/lib/types-esm/decorators/collections/collectionOf.d.ts +101 -0
- package/lib/types-esm/decorators/collections/maxItems.d.ts +48 -0
- package/lib/types-esm/decorators/collections/maxProperties.d.ts +71 -0
- package/lib/types-esm/decorators/collections/minItems.d.ts +52 -0
- package/lib/types-esm/decorators/collections/minProperties.d.ts +70 -0
- package/lib/types-esm/decorators/collections/uniqueItems.d.ts +51 -0
- package/lib/types-esm/decorators/common/additionalProperties.d.ts +11 -0
- package/lib/types-esm/decorators/common/allOf.d.ts +13 -0
- package/lib/types-esm/decorators/common/allow.d.ts +28 -0
- package/lib/types-esm/decorators/common/any.d.ts +38 -0
- package/lib/types-esm/decorators/common/anyOf.d.ts +17 -0
- package/lib/types-esm/decorators/common/const.d.ts +61 -0
- package/lib/types-esm/decorators/common/customKey.d.ts +26 -0
- package/lib/types-esm/decorators/common/default.d.ts +41 -0
- package/lib/types-esm/decorators/common/defaultMsg.d.ts +32 -0
- package/lib/types-esm/decorators/common/description.d.ts +53 -0
- package/lib/types-esm/decorators/common/discriminatorKey.d.ts +1 -0
- package/lib/types-esm/decorators/common/enum.d.ts +101 -0
- package/lib/types-esm/decorators/common/errorMsg.d.ts +6 -0
- package/lib/types-esm/decorators/common/example.d.ts +11 -0
- package/lib/types-esm/decorators/common/examples.d.ts +12 -0
- package/lib/types-esm/decorators/common/exclusiveMaximum.d.ts +70 -0
- package/lib/types-esm/decorators/common/exclusiveMinimum.d.ts +70 -0
- package/lib/types-esm/decorators/common/format.d.ts +466 -0
- package/lib/types-esm/decorators/common/forwardGroups.d.ts +10 -0
- package/lib/types-esm/decorators/common/groups.d.ts +12 -0
- package/lib/types-esm/decorators/common/hidden.d.ts +32 -0
- package/lib/types-esm/decorators/common/ignore.d.ts +59 -0
- package/lib/types-esm/decorators/common/integer.d.ts +61 -0
- package/lib/types-esm/decorators/common/jsonEntityFn.d.ts +21 -0
- package/lib/types-esm/decorators/common/maxLength.d.ts +77 -0
- package/lib/types-esm/decorators/common/maximum.d.ts +139 -0
- package/lib/types-esm/decorators/common/minLength.d.ts +78 -0
- package/lib/types-esm/decorators/common/minimum.d.ts +137 -0
- package/lib/types-esm/decorators/common/multipleOf.d.ts +69 -0
- package/lib/types-esm/decorators/common/name.d.ts +32 -0
- package/lib/types-esm/decorators/common/nullable.d.ts +25 -0
- package/lib/types-esm/decorators/common/oneOf.d.ts +17 -0
- package/lib/types-esm/decorators/common/optional.d.ts +10 -0
- package/lib/types-esm/decorators/common/pattern.d.ts +94 -0
- package/lib/types-esm/decorators/common/property.d.ts +11 -0
- package/lib/types-esm/decorators/common/readOnly.d.ts +11 -0
- package/lib/types-esm/decorators/common/recordOf.d.ts +46 -0
- package/lib/types-esm/decorators/common/required.d.ts +44 -0
- package/lib/types-esm/decorators/common/requiredGroups.d.ts +10 -0
- package/lib/types-esm/decorators/common/schema.d.ts +53 -0
- package/lib/types-esm/decorators/common/title.d.ts +39 -0
- package/lib/types-esm/decorators/common/typeError.d.ts +8 -0
- package/lib/types-esm/decorators/common/writeOnly.d.ts +11 -0
- package/lib/types-esm/decorators/config/jsonEntityComponent.d.ts +10 -0
- package/lib/types-esm/decorators/generics/genericOf.d.ts +76 -0
- package/lib/types-esm/decorators/generics/generics.d.ts +14 -0
- package/lib/types-esm/decorators/operations/acceptMime.d.ts +19 -0
- package/lib/types-esm/decorators/operations/consumes.d.ts +19 -0
- package/lib/types-esm/decorators/operations/contentType.d.ts +20 -0
- package/lib/types-esm/decorators/operations/deprecated.d.ts +23 -0
- package/lib/types-esm/decorators/operations/header.d.ts +49 -0
- package/lib/types-esm/decorators/operations/in.d.ts +64 -0
- package/lib/types-esm/decorators/operations/inFile.d.ts +25 -0
- package/lib/types-esm/decorators/operations/location.d.ts +22 -0
- package/lib/types-esm/decorators/operations/operation.d.ts +60 -0
- package/lib/types-esm/decorators/operations/operationId.d.ts +10 -0
- package/lib/types-esm/decorators/operations/operationPath.d.ts +21 -0
- package/lib/types-esm/decorators/operations/partial.d.ts +10 -0
- package/lib/types-esm/decorators/operations/path.d.ts +15 -0
- package/lib/types-esm/decorators/operations/produces.d.ts +26 -0
- package/lib/types-esm/decorators/operations/publish.d.ts +1 -0
- package/lib/types-esm/decorators/operations/redirect.d.ts +52 -0
- package/lib/types-esm/decorators/operations/returns.d.ts +267 -0
- package/lib/types-esm/decorators/operations/route.d.ts +133 -0
- package/lib/types-esm/decorators/operations/security.d.ts +23 -0
- package/lib/types-esm/decorators/operations/status.d.ts +127 -0
- package/lib/types-esm/decorators/operations/subscribe.d.ts +1 -0
- package/lib/types-esm/decorators/operations/summary.d.ts +20 -0
- package/lib/types-esm/decorators/operations/tags.d.ts +23 -0
- package/lib/types-esm/decorators/operations/view.d.ts +23 -0
- package/lib/types-esm/domain/DecoratorContext.d.ts +28 -0
- package/lib/types-esm/domain/JsonAliasMap.d.ts +12 -0
- package/lib/types-esm/domain/JsonClassStore.d.ts +12 -0
- package/lib/types-esm/domain/JsonDiscriminator.d.ts +18 -0
- package/lib/types-esm/domain/JsonEntityStore.d.ts +110 -0
- package/lib/types-esm/domain/JsonFormatTypes.d.ts +17 -0
- package/lib/types-esm/domain/JsonLazyRef.d.ts +9 -0
- package/lib/types-esm/domain/JsonMap.d.ts +9 -0
- package/lib/types-esm/domain/JsonMedia.d.ts +11 -0
- package/lib/types-esm/domain/JsonMethodStore.d.ts +92 -0
- package/lib/types-esm/domain/JsonOperation.d.ts +51 -0
- package/lib/types-esm/domain/JsonOperationPathsMap.d.ts +7 -0
- package/lib/types-esm/domain/JsonOperationRoute.d.ts +25 -0
- package/lib/types-esm/domain/JsonParameter.d.ts +22 -0
- package/lib/types-esm/domain/JsonParameterStore.d.ts +52 -0
- package/lib/types-esm/domain/JsonParameterTypes.d.ts +16 -0
- package/lib/types-esm/domain/JsonPropertyStore.d.ts +32 -0
- package/lib/types-esm/domain/JsonRequestBody.d.ts +12 -0
- package/lib/types-esm/domain/JsonResponse.d.ts +18 -0
- package/lib/types-esm/domain/JsonSchema.d.ts +340 -0
- package/lib/types-esm/domain/SpecTypes.d.ts +6 -0
- package/lib/types-esm/hooks/alterIgnore.d.ts +10 -0
- package/lib/types-esm/hooks/alterOneOf.d.ts +3 -0
- package/lib/types-esm/hooks/alterRequiredGroups.d.ts +6 -0
- package/lib/types-esm/index.d.ts +182 -0
- package/lib/types-esm/interfaces/IgnoreCallback.d.ts +4 -0
- package/lib/types-esm/interfaces/JsonHookContext.d.ts +17 -0
- package/lib/types-esm/interfaces/JsonOpenSpec.d.ts +9 -0
- package/lib/types-esm/interfaces/JsonSchemaOptions.d.ts +30 -0
- package/lib/types-esm/registries/JsonSchemaMapperContainer.d.ts +21 -0
- package/lib/types-esm/registries/enumRegistries.d.ts +2 -0
- package/lib/types-esm/utils/buildPath.d.ts +6 -0
- package/lib/types-esm/utils/concatParameters.d.ts +4 -0
- package/lib/types-esm/utils/concatPath.d.ts +1 -0
- package/lib/types-esm/utils/defineStatusModel.d.ts +3 -0
- package/lib/types-esm/utils/from.d.ts +190 -0
- package/lib/types-esm/utils/generateSpec.d.ts +16 -0
- package/lib/types-esm/utils/generics.d.ts +50 -0
- package/lib/types-esm/utils/getComputedType.d.ts +5 -0
- package/lib/types-esm/utils/getInheritedStores.d.ts +8 -0
- package/lib/types-esm/utils/getJsonEntityStore.d.ts +15 -0
- package/lib/types-esm/utils/getJsonPathParameters.d.ts +7 -0
- package/lib/types-esm/utils/getJsonSchema.d.ts +4 -0
- package/lib/types-esm/utils/getJsonType.d.ts +5 -0
- package/lib/types-esm/utils/getOperationsRoutes.d.ts +10 -0
- package/lib/types-esm/utils/getOperationsStores.d.ts +6 -0
- package/lib/types-esm/utils/getPropertiesStores.d.ts +20 -0
- package/lib/types-esm/utils/getSpec.d.ts +34 -0
- package/lib/types-esm/utils/getSpecType.d.ts +12 -0
- package/lib/types-esm/utils/isSuccessStatus.d.ts +2 -0
- package/lib/types-esm/utils/mapHeaders.d.ts +9 -0
- package/lib/types-esm/utils/mapOpenSpec.d.ts +10 -0
- package/lib/types-esm/utils/mapOpenSpec2.d.ts +9 -0
- package/lib/types-esm/utils/mapOpenSpec3.d.ts +8 -0
- package/lib/types-esm/utils/mapOpenSpecInfo.d.ts +6 -0
- package/lib/types-esm/utils/mapOperationOptions.d.ts +5 -0
- package/lib/types-esm/utils/matchGroups.d.ts +4 -0
- package/lib/types-esm/utils/mergeSpec.d.ts +23 -0
- package/lib/types-esm/utils/operationIdFormatter.d.ts +6 -0
- package/lib/types-esm/utils/ref.d.ts +14 -0
- package/lib/types-esm/utils/removeHiddenOperation.d.ts +2 -0
- package/lib/types-esm/utils/serializeEnumValues.d.ts +5 -0
- package/lib/types-esm/utils/somethingOf.d.ts +1 -0
- package/lib/types-esm/utils/toJsonMapCollection.d.ts +7 -0
- package/lib/types-esm/utils/toJsonRegex.d.ts +5 -0
- package/lib/types-esm/utils/transformToOS2.d.ts +25 -0
- package/lib/types-esm/utils/withErrorMsg.d.ts +6 -0
- package/package.json +21 -17
- package/vitest.config.mts +21 -0
- package/jest.config.js +0 -21
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
- package/tsconfig.esm.json +0 -36
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { ValueOf } from "@tsed/core";
|
|
2
|
+
import { JsonFormatTypes } from "../../domain/JsonFormatTypes.js";
|
|
3
|
+
/**
|
|
4
|
+
* The following formats are supported for string validation with `format` keyword:
|
|
5
|
+
*
|
|
6
|
+
* - **date**: full-date according to [RFC3339](https://json-schema.org/latest/json-schema-validation.html#RFC3339).
|
|
7
|
+
* - **time**: time with optional time-zone.
|
|
8
|
+
* - **date-time**: date-time from the same source (time-zone is mandatory).
|
|
9
|
+
* - **uri**: full uri with optional protocol.
|
|
10
|
+
* - **email**: email address.
|
|
11
|
+
* - **hostname**: host name according to [RFC1034](https://tools.ietf.org/html/rfc1034#section-3.1).
|
|
12
|
+
* - **ipv4**: IP address v4.
|
|
13
|
+
* - **ipv6**: IP address v6.
|
|
14
|
+
* - **regex**: tests whether a string is a valid regular expression by passing it to RegExp constructor.
|
|
15
|
+
*
|
|
16
|
+
* ::: warning
|
|
17
|
+
* For v6 user, use @@Format@@ from @tsed/schema instead of @tsed/common.
|
|
18
|
+
* :::
|
|
19
|
+
*
|
|
20
|
+
* ## Example
|
|
21
|
+
* ### With primitive type
|
|
22
|
+
*
|
|
23
|
+
* ```typescript
|
|
24
|
+
* class Model {
|
|
25
|
+
* @Format("email")
|
|
26
|
+
* property: string;
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ```json
|
|
31
|
+
* {
|
|
32
|
+
* "type": "object",
|
|
33
|
+
* "properties": {
|
|
34
|
+
* "property": {
|
|
35
|
+
* "type": "string",
|
|
36
|
+
* "format": "email"
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* ### With array type
|
|
43
|
+
*
|
|
44
|
+
* ```typescript
|
|
45
|
+
* class Model {
|
|
46
|
+
* @Format("email")
|
|
47
|
+
* @CollectionOf(String)
|
|
48
|
+
* property: string[];
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Will produce:
|
|
53
|
+
*
|
|
54
|
+
* ```json
|
|
55
|
+
* {
|
|
56
|
+
* "type": "object",
|
|
57
|
+
* "properties": {
|
|
58
|
+
* "property": {
|
|
59
|
+
* "type": "array",
|
|
60
|
+
* "items": {
|
|
61
|
+
* "type": "string",
|
|
62
|
+
* "format": "email"
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param {string} format
|
|
70
|
+
* @decorator
|
|
71
|
+
* @validation
|
|
72
|
+
* @swagger
|
|
73
|
+
* @schema
|
|
74
|
+
* @input
|
|
75
|
+
* @ajv-errors
|
|
76
|
+
*/
|
|
77
|
+
export declare const Format: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => (...args: any[]) => any>;
|
|
78
|
+
/**
|
|
79
|
+
* Apply an email validation on property.
|
|
80
|
+
*
|
|
81
|
+
* ::: warning
|
|
82
|
+
* For v6 user, use @@Email@@ from @tsed/schema instead of @tsed/common.
|
|
83
|
+
* :::
|
|
84
|
+
*
|
|
85
|
+
* ## Example
|
|
86
|
+
* ### With primitive type
|
|
87
|
+
*
|
|
88
|
+
* ```typescript
|
|
89
|
+
* class Model {
|
|
90
|
+
* @Email()
|
|
91
|
+
* property: string;
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* Will produce:
|
|
96
|
+
*
|
|
97
|
+
* ```json
|
|
98
|
+
* {
|
|
99
|
+
* "type": "object",
|
|
100
|
+
* "properties": {
|
|
101
|
+
* "property": {
|
|
102
|
+
* "type": "string",
|
|
103
|
+
* "format": "email"
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* ### With array type
|
|
110
|
+
*
|
|
111
|
+
* ```typescript
|
|
112
|
+
* class Model {
|
|
113
|
+
* @Email()
|
|
114
|
+
* @CollectionOf(String)
|
|
115
|
+
* property: string[];
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* Will produce:
|
|
120
|
+
*
|
|
121
|
+
* ```json
|
|
122
|
+
* {
|
|
123
|
+
* "type": "object",
|
|
124
|
+
* "properties": {
|
|
125
|
+
* "property": {
|
|
126
|
+
* "type": "array",
|
|
127
|
+
* "items": {
|
|
128
|
+
* "type": "string",
|
|
129
|
+
* "format": "email"
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* }
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* > See [Format](api/common/jsonschema/schema) decorator.
|
|
137
|
+
* @returns {Function}
|
|
138
|
+
* @decorator
|
|
139
|
+
* @validation
|
|
140
|
+
* @schema
|
|
141
|
+
* @swagger
|
|
142
|
+
* @input
|
|
143
|
+
* @ajv-errors
|
|
144
|
+
*/
|
|
145
|
+
export declare const Email: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<() => import("../../utils/withErrorMsg.js").ErrorChainedMethods<(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => (...args: any[]) => any>>;
|
|
146
|
+
/**
|
|
147
|
+
* Apply a date-time validation on property.
|
|
148
|
+
*
|
|
149
|
+
* ## Example
|
|
150
|
+
* ### With primitive type
|
|
151
|
+
*
|
|
152
|
+
* ```typescript
|
|
153
|
+
* class Model {
|
|
154
|
+
* @DateTime()
|
|
155
|
+
* property: string;
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* Will produce:
|
|
160
|
+
*
|
|
161
|
+
* ```json
|
|
162
|
+
* {
|
|
163
|
+
* "type": "object",
|
|
164
|
+
* "properties": {
|
|
165
|
+
* "property": {
|
|
166
|
+
* "type": "string",
|
|
167
|
+
* "format": "date-time"
|
|
168
|
+
* }
|
|
169
|
+
* }
|
|
170
|
+
* }
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* ### With array type
|
|
174
|
+
*
|
|
175
|
+
* ```typescript
|
|
176
|
+
* class Model {
|
|
177
|
+
* @DateTime()
|
|
178
|
+
* @CollectionOf(String)
|
|
179
|
+
* property: string[];
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* Will produce:
|
|
184
|
+
*
|
|
185
|
+
* ```json
|
|
186
|
+
* {
|
|
187
|
+
* "type": "object",
|
|
188
|
+
* "properties": {
|
|
189
|
+
* "property": {
|
|
190
|
+
* "type": "array",
|
|
191
|
+
* "items": {
|
|
192
|
+
* "type": "string",
|
|
193
|
+
* "format": "date-time"
|
|
194
|
+
* }
|
|
195
|
+
* }
|
|
196
|
+
* }
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* > See [Format](api/common/jsonschema/schema) decorator.
|
|
201
|
+
* @returns {Function}
|
|
202
|
+
* @decorator
|
|
203
|
+
* @validation
|
|
204
|
+
* @property
|
|
205
|
+
* @parameter
|
|
206
|
+
* @schema
|
|
207
|
+
* @auto-map The data will be stored on the right place according to the type and collectionType (primitive or collection).
|
|
208
|
+
* @ajv-errors
|
|
209
|
+
*/
|
|
210
|
+
export declare const DateTime: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<() => import("../../utils/withErrorMsg.js").ErrorChainedMethods<(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => (...args: any[]) => any>>;
|
|
211
|
+
/**
|
|
212
|
+
* Apply a time validation on property.
|
|
213
|
+
*
|
|
214
|
+
* ## Example
|
|
215
|
+
* ### With primitive type
|
|
216
|
+
*
|
|
217
|
+
* ```typescript
|
|
218
|
+
* class Model {
|
|
219
|
+
* @Time()
|
|
220
|
+
* property: string;
|
|
221
|
+
* }
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* Will produce:
|
|
225
|
+
*
|
|
226
|
+
* ```json
|
|
227
|
+
* {
|
|
228
|
+
* "type": "object",
|
|
229
|
+
* "properties": {
|
|
230
|
+
* "property": {
|
|
231
|
+
* "type": "string",
|
|
232
|
+
* "format": "time"
|
|
233
|
+
* }
|
|
234
|
+
* }
|
|
235
|
+
* }
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* ### With array type
|
|
239
|
+
*
|
|
240
|
+
* ```typescript
|
|
241
|
+
* class Model {
|
|
242
|
+
* @Time()
|
|
243
|
+
* @CollectionOf(String)
|
|
244
|
+
* property: string[];
|
|
245
|
+
* }
|
|
246
|
+
* ```
|
|
247
|
+
*
|
|
248
|
+
* Will produce:
|
|
249
|
+
*
|
|
250
|
+
* ```json
|
|
251
|
+
* {
|
|
252
|
+
* "type": "object",
|
|
253
|
+
* "properties": {
|
|
254
|
+
* "property": {
|
|
255
|
+
* "type": "array",
|
|
256
|
+
* "items": {
|
|
257
|
+
* "type": "string",
|
|
258
|
+
* "format": "time"
|
|
259
|
+
* }
|
|
260
|
+
* }
|
|
261
|
+
* }
|
|
262
|
+
* }
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* > See [Format](api/common/jsonschema/schema) decorator.
|
|
266
|
+
* @returns {Function}
|
|
267
|
+
* @decorator
|
|
268
|
+
* @validation
|
|
269
|
+
* @property
|
|
270
|
+
* @parameter
|
|
271
|
+
* @schema
|
|
272
|
+
* @ajv-errors
|
|
273
|
+
*/
|
|
274
|
+
export declare const DateFormat: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<() => import("../../utils/withErrorMsg.js").ErrorChainedMethods<(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => (...args: any[]) => any>>;
|
|
275
|
+
/**
|
|
276
|
+
* Apply a time validation on property.
|
|
277
|
+
*
|
|
278
|
+
* ## Example
|
|
279
|
+
* ### With primitive type
|
|
280
|
+
*
|
|
281
|
+
* ```typescript
|
|
282
|
+
* class Model {
|
|
283
|
+
* @TimeFormat()
|
|
284
|
+
* property: string;
|
|
285
|
+
* }
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
288
|
+
* Will produce:
|
|
289
|
+
*
|
|
290
|
+
* ```json
|
|
291
|
+
* {
|
|
292
|
+
* "type": "object",
|
|
293
|
+
* "properties": {
|
|
294
|
+
* "property": {
|
|
295
|
+
* "type": "string",
|
|
296
|
+
* "format": "time"
|
|
297
|
+
* }
|
|
298
|
+
* }
|
|
299
|
+
* }
|
|
300
|
+
* ```
|
|
301
|
+
*
|
|
302
|
+
* ### With array type
|
|
303
|
+
*
|
|
304
|
+
* ```typescript
|
|
305
|
+
* class Model {
|
|
306
|
+
* @TimeFormat()
|
|
307
|
+
* @CollectionOf(String)
|
|
308
|
+
* property: string[];
|
|
309
|
+
* }
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* Will produce:
|
|
313
|
+
*
|
|
314
|
+
* ```json
|
|
315
|
+
* {
|
|
316
|
+
* "type": "object",
|
|
317
|
+
* "properties": {
|
|
318
|
+
* "property": {
|
|
319
|
+
* "type": "array",
|
|
320
|
+
* "items": {
|
|
321
|
+
* "type": "string",
|
|
322
|
+
* "format": "time"
|
|
323
|
+
* }
|
|
324
|
+
* }
|
|
325
|
+
* }
|
|
326
|
+
* }
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* > See [Format](api/common/jsonschema/schema) decorator.
|
|
330
|
+
* @returns {Function}
|
|
331
|
+
* @decorator
|
|
332
|
+
* @validation
|
|
333
|
+
* @property
|
|
334
|
+
* @parameter
|
|
335
|
+
* @schema
|
|
336
|
+
* @ajv-errors
|
|
337
|
+
*/
|
|
338
|
+
export declare const TimeFormat: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<() => import("../../utils/withErrorMsg.js").ErrorChainedMethods<(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => (...args: any[]) => any>>;
|
|
339
|
+
/**
|
|
340
|
+
* Apply a uri validation on property.
|
|
341
|
+
*
|
|
342
|
+
* ## Example
|
|
343
|
+
* ### With primitive type
|
|
344
|
+
*
|
|
345
|
+
* ```typescript
|
|
346
|
+
* class Model {
|
|
347
|
+
* @Uri()
|
|
348
|
+
* property: string;
|
|
349
|
+
* }
|
|
350
|
+
* ```
|
|
351
|
+
*
|
|
352
|
+
* Will produce:
|
|
353
|
+
*
|
|
354
|
+
* ```json
|
|
355
|
+
* {
|
|
356
|
+
* "type": "object",
|
|
357
|
+
* "properties": {
|
|
358
|
+
* "property": {
|
|
359
|
+
* "type": "string",
|
|
360
|
+
* "format": "uri"
|
|
361
|
+
* }
|
|
362
|
+
* }
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* ### With array type
|
|
367
|
+
*
|
|
368
|
+
* ```typescript
|
|
369
|
+
* class Model {
|
|
370
|
+
* @Uri()
|
|
371
|
+
* @CollectionOf(String)
|
|
372
|
+
* property: string[];
|
|
373
|
+
* }
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* Will produce:
|
|
377
|
+
*
|
|
378
|
+
* ```json
|
|
379
|
+
* {
|
|
380
|
+
* "type": "object",
|
|
381
|
+
* "properties": {
|
|
382
|
+
* "property": {
|
|
383
|
+
* "type": "array",
|
|
384
|
+
* "items": {
|
|
385
|
+
* "type": "string",
|
|
386
|
+
* "format": "uri"
|
|
387
|
+
* }
|
|
388
|
+
* }
|
|
389
|
+
* }
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*
|
|
393
|
+
* > See [Format](api/common/jsonschema/schema) decorator.
|
|
394
|
+
* @returns {Function}
|
|
395
|
+
* @decorator
|
|
396
|
+
* @validation
|
|
397
|
+
* @property
|
|
398
|
+
* @parameter
|
|
399
|
+
* @schema
|
|
400
|
+
* @ajv-errors
|
|
401
|
+
*/
|
|
402
|
+
export declare const Uri: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<() => import("../../utils/withErrorMsg.js").ErrorChainedMethods<(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => (...args: any[]) => any>>;
|
|
403
|
+
/**
|
|
404
|
+
* Apply a url validation on property.
|
|
405
|
+
*
|
|
406
|
+
* ## Example
|
|
407
|
+
* ### With primitive type
|
|
408
|
+
*
|
|
409
|
+
* ```typescript
|
|
410
|
+
* class Model {
|
|
411
|
+
* @Url()
|
|
412
|
+
* property: string;
|
|
413
|
+
* }
|
|
414
|
+
* ```
|
|
415
|
+
*
|
|
416
|
+
* Will produce:
|
|
417
|
+
*
|
|
418
|
+
* ```json
|
|
419
|
+
* {
|
|
420
|
+
* "type": "object",
|
|
421
|
+
* "properties": {
|
|
422
|
+
* "property": {
|
|
423
|
+
* "type": "string",
|
|
424
|
+
* "format": "url"
|
|
425
|
+
* }
|
|
426
|
+
* }
|
|
427
|
+
* }
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
430
|
+
* ### With array type
|
|
431
|
+
*
|
|
432
|
+
* ```typescript
|
|
433
|
+
* class Model {
|
|
434
|
+
* @Url()
|
|
435
|
+
* @CollectionOf(String)
|
|
436
|
+
* property: string[];
|
|
437
|
+
* }
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
440
|
+
* Will produce:
|
|
441
|
+
*
|
|
442
|
+
* ```json
|
|
443
|
+
* {
|
|
444
|
+
* "type": "object",
|
|
445
|
+
* "properties": {
|
|
446
|
+
* "property": {
|
|
447
|
+
* "type": "array",
|
|
448
|
+
* "items": {
|
|
449
|
+
* "type": "string",
|
|
450
|
+
* "format": "url"
|
|
451
|
+
* }
|
|
452
|
+
* }
|
|
453
|
+
* }
|
|
454
|
+
* }
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* > See [Format](api/common/jsonschema/schema) decorator.
|
|
458
|
+
* @returns {Function}
|
|
459
|
+
* @decorator
|
|
460
|
+
* @validation
|
|
461
|
+
* @property
|
|
462
|
+
* @parameter
|
|
463
|
+
* @schema
|
|
464
|
+
* @ajv-errors
|
|
465
|
+
*/
|
|
466
|
+
export declare const Url: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<() => import("../../utils/withErrorMsg.js").ErrorChainedMethods<(format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => (...args: any[]) => any>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply groups validation strategy
|
|
3
|
+
*
|
|
4
|
+
* @decorator
|
|
5
|
+
* @validation
|
|
6
|
+
* @swagger
|
|
7
|
+
* @schema
|
|
8
|
+
* @input
|
|
9
|
+
*/
|
|
10
|
+
export declare function Groups<T>(groupsDefinition: Record<string, (keyof T)[]>): ClassDecorator;
|
|
11
|
+
export declare function Groups<T>(groupName: string, groups: string[]): ParameterDecorator;
|
|
12
|
+
export declare function Groups(...groups: string[]): Function;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disable documentation for the class and his endpoint.
|
|
3
|
+
*
|
|
4
|
+
* ````typescript
|
|
5
|
+
* @Controller('/')
|
|
6
|
+
* export class Ctrl {
|
|
7
|
+
*
|
|
8
|
+
* @Get('/')
|
|
9
|
+
* @Hidden()
|
|
10
|
+
* hiddenRoute(){
|
|
11
|
+
*
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* @Controller('/')
|
|
16
|
+
* @Hidden()
|
|
17
|
+
* export class Ctrl {
|
|
18
|
+
* @Get('/')
|
|
19
|
+
* hiddenRoute() {
|
|
20
|
+
*
|
|
21
|
+
* }
|
|
22
|
+
* @Get('/2')
|
|
23
|
+
* hiddenRoute2() {
|
|
24
|
+
*
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @decorator
|
|
30
|
+
* @ignore
|
|
31
|
+
*/
|
|
32
|
+
export declare function Hidden(): Function;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { IgnoreCallback } from "../../interfaces/IgnoreCallback.js";
|
|
2
|
+
/**
|
|
3
|
+
* Ignore the property when JsonMapper serialize the class to a Plain Object JavaScript.
|
|
4
|
+
*
|
|
5
|
+
* ::: warning
|
|
6
|
+
* Swagger will not generate documentation for the ignored property.
|
|
7
|
+
* :::
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* class User {
|
|
11
|
+
* @Ignore()
|
|
12
|
+
* _id: string;
|
|
13
|
+
*
|
|
14
|
+
* @Property()
|
|
15
|
+
* firstName: string;
|
|
16
|
+
*
|
|
17
|
+
* @Property()
|
|
18
|
+
* lastName: string;
|
|
19
|
+
*
|
|
20
|
+
* @Ignore((value, ctx) => !ctx.endpoint)
|
|
21
|
+
* password: string;
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* The controller:
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import {Post, Controller, BodyParams} from "@tsed/common";
|
|
28
|
+
* import {Person} from "../models/Person.js";
|
|
29
|
+
*
|
|
30
|
+
* @Controller("/")
|
|
31
|
+
* export class UsersCtrl {
|
|
32
|
+
* @Get("/")
|
|
33
|
+
* get(): User {
|
|
34
|
+
* const user = new User();
|
|
35
|
+
* user._id = "12345";
|
|
36
|
+
* user.firstName = "John";
|
|
37
|
+
* user.lastName = "Doe";
|
|
38
|
+
* user.password = "secretpassword";
|
|
39
|
+
* return
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* The expected json object:
|
|
45
|
+
*
|
|
46
|
+
* ```json
|
|
47
|
+
* {
|
|
48
|
+
* "firstName": "John",
|
|
49
|
+
* "lastName": "Doe"
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
* @param cb Callback to know if the property must be ignored
|
|
53
|
+
* @decorator
|
|
54
|
+
* @validation
|
|
55
|
+
* @swagger
|
|
56
|
+
* @schema
|
|
57
|
+
* @deprecated Since v7. Use @Groups decorator instead of and enable `jsonMapper.strictGroups` in your configuration.
|
|
58
|
+
*/
|
|
59
|
+
export declare function Ignore(cb?: boolean | IgnoreCallback): (...args: any[]) => any;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set integer type.
|
|
3
|
+
*
|
|
4
|
+
* ::: warning
|
|
5
|
+
* For v6 user, use @@Integer@@ from @tsed/schema instead of @@Integer@@ from @tsed/common.
|
|
6
|
+
* :::
|
|
7
|
+
*
|
|
8
|
+
* ## Example
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* class Model {
|
|
12
|
+
* @Integer()
|
|
13
|
+
* property: number;
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Will produce:
|
|
18
|
+
*
|
|
19
|
+
* ```json
|
|
20
|
+
* {
|
|
21
|
+
* "type": "object",
|
|
22
|
+
* "properties": {
|
|
23
|
+
* "property": {
|
|
24
|
+
* "type": "integer"
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ### With array of multiple types
|
|
31
|
+
*
|
|
32
|
+
* ```typescript
|
|
33
|
+
* class Model {
|
|
34
|
+
* @Integer()
|
|
35
|
+
* property: number[];
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Will produce:
|
|
40
|
+
*
|
|
41
|
+
* ```json
|
|
42
|
+
* {
|
|
43
|
+
* "type": "object",
|
|
44
|
+
* "properties": {
|
|
45
|
+
* "property": {
|
|
46
|
+
* "type": "array",
|
|
47
|
+
* "items": {
|
|
48
|
+
* "type": "integer"
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @decorator
|
|
56
|
+
* @validation
|
|
57
|
+
* @swagger
|
|
58
|
+
* @schema
|
|
59
|
+
* @input
|
|
60
|
+
*/
|
|
61
|
+
export declare function Integer(): (...args: any[]) => any;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DecoratorParameters } from "@tsed/core";
|
|
2
|
+
import type { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
3
|
+
/**
|
|
4
|
+
* Decorator util to compose another decorator. See @@Description@@ decorator implementation for more details.
|
|
5
|
+
*
|
|
6
|
+
* ## Usage
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* export function Description(description: any) {
|
|
10
|
+
* return JsonEntityFn((entity: JsonEntityStore, args: DecoratorParameters) => {
|
|
11
|
+
* entity.itemSchema.description(description)
|
|
12
|
+
* });
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param fn
|
|
17
|
+
* @decorator
|
|
18
|
+
* @utils
|
|
19
|
+
* @model
|
|
20
|
+
*/
|
|
21
|
+
export declare function JsonEntityFn<T extends JsonEntityStore = JsonEntityStore>(fn: (entity: T, parameters: DecoratorParameters) => any): (...args: any[]) => any;
|