@tsed/schema 7.0.0-beta.1 → 7.0.0-beta.12
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/jest.config.js +4 -4
- package/lib/cjs/components/schemaMapper.js +1 -3
- package/lib/cjs/components/schemaMapper.js.map +1 -1
- package/lib/cjs/constants/httpStatusMessages.js +12 -96
- package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
- package/lib/cjs/decorators/common/description.js.map +1 -1
- package/lib/cjs/decorators/common/enum.js +1 -20
- package/lib/cjs/decorators/common/enum.js.map +1 -1
- package/lib/cjs/decorators/common/ignore.js.map +1 -1
- package/lib/cjs/decorators/common/jsonEntityFn.js.map +1 -1
- package/lib/cjs/decorators/common/recordOf.js +63 -0
- package/lib/cjs/decorators/common/recordOf.js.map +1 -0
- package/lib/cjs/decorators/operations/acceptMime.js +28 -0
- package/lib/cjs/decorators/operations/acceptMime.js.map +1 -0
- package/lib/cjs/decorators/operations/in.js +6 -4
- package/lib/cjs/decorators/operations/in.js.map +1 -1
- package/lib/cjs/decorators/operations/view.js +31 -0
- package/lib/cjs/decorators/operations/view.js.map +1 -0
- package/lib/cjs/domain/DecoratorContext.js.map +1 -1
- package/lib/cjs/domain/JsonClassStore.js +1 -1
- package/lib/cjs/domain/JsonMap.js.map +1 -1
- package/lib/cjs/domain/JsonMethodStore.js +66 -24
- package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
- package/lib/cjs/domain/JsonOperation.js +11 -26
- package/lib/cjs/domain/JsonOperation.js.map +1 -1
- package/lib/cjs/domain/JsonOperationRoute.js +4 -0
- package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
- package/lib/cjs/domain/JsonParameter.js +36 -74
- package/lib/cjs/domain/JsonParameter.js.map +1 -1
- package/lib/cjs/domain/JsonParameterStore.js +14 -5
- package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
- package/lib/cjs/domain/JsonPropertyStore.js +6 -2
- package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
- package/lib/cjs/domain/JsonResponse.js +1 -11
- package/lib/cjs/domain/JsonResponse.js.map +1 -1
- package/lib/cjs/domain/JsonSchema.js +47 -54
- package/lib/cjs/domain/JsonSchema.js.map +1 -1
- package/lib/cjs/domain/SpecTypes.js +0 -3
- package/lib/cjs/domain/SpecTypes.js.map +1 -1
- package/lib/cjs/index.js +150 -20
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/utils/from.js +9 -8
- package/lib/cjs/utils/from.js.map +1 -1
- package/lib/cjs/utils/generateSpec.js +46 -0
- package/lib/cjs/utils/generateSpec.js.map +1 -0
- package/lib/cjs/utils/generics.js.map +1 -1
- package/lib/cjs/utils/getJsonPathParameters.js +20 -6
- package/lib/cjs/utils/getJsonPathParameters.js.map +1 -1
- package/lib/cjs/utils/getJsonSchema.js +11 -1
- package/lib/cjs/utils/getJsonSchema.js.map +1 -1
- package/lib/cjs/utils/getJsonType.js +1 -1
- package/lib/cjs/utils/getJsonType.js.map +1 -1
- package/lib/cjs/utils/getOperationsRoutes.js +2 -1
- package/lib/cjs/utils/getOperationsRoutes.js.map +1 -1
- package/lib/cjs/utils/getSpec.js +58 -43
- package/lib/cjs/utils/getSpec.js.map +1 -1
- package/lib/cjs/utils/getSpecType.js +21 -0
- package/lib/cjs/utils/getSpecType.js.map +1 -0
- package/lib/cjs/utils/mapNullableType.js +1 -6
- package/lib/cjs/utils/mapNullableType.js.map +1 -1
- package/lib/cjs/utils/mapOpenSpec.js +41 -0
- package/lib/cjs/utils/mapOpenSpec.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec2.js +34 -0
- package/lib/cjs/utils/mapOpenSpec2.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec3.js +26 -0
- package/lib/cjs/utils/mapOpenSpec3.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpecInfo.js +21 -0
- package/lib/cjs/utils/mapOpenSpecInfo.js.map +1 -0
- package/lib/cjs/utils/matchGroups.js +1 -1
- package/lib/cjs/utils/matchGroups.js.map +1 -1
- package/lib/cjs/utils/mergeOperation.js +1 -0
- package/lib/cjs/utils/mergeOperation.js.map +1 -1
- package/lib/cjs/utils/ref.js +0 -8
- package/lib/cjs/utils/ref.js.map +1 -1
- package/lib/cjs/utils/serializeEnumValues.js +26 -0
- package/lib/cjs/utils/serializeEnumValues.js.map +1 -0
- package/lib/cjs/utils/transformToOS2.js +510 -0
- package/lib/cjs/utils/transformToOS2.js.map +1 -0
- package/lib/esm/components/anyMapper.js +4 -4
- package/lib/esm/components/classMapper.js +4 -4
- package/lib/esm/components/genericsMapper.js +4 -4
- package/lib/esm/components/inheritedClassMapper.js +2 -2
- package/lib/esm/components/itemMapper.js +1 -1
- package/lib/esm/components/lazyRefMapper.js +3 -3
- package/lib/esm/components/mapMapper.js +2 -2
- package/lib/esm/components/objectMapper.js +3 -3
- package/lib/esm/components/ofMapper.js +1 -1
- package/lib/esm/components/propertiesMapper.js +1 -1
- package/lib/esm/components/schemaMapper.js +7 -9
- package/lib/esm/components/schemaMapper.js.map +1 -1
- package/lib/esm/constants/httpStatusMessages.js +11 -96
- package/lib/esm/constants/httpStatusMessages.js.map +1 -1
- package/lib/esm/decorators/class/children.js +1 -1
- package/lib/esm/decorators/collections/collectionContains.js +1 -1
- package/lib/esm/decorators/collections/collectionOf.js +1 -1
- 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/additionalProperties.js +1 -1
- package/lib/esm/decorators/common/allOf.js +1 -1
- package/lib/esm/decorators/common/allow.js +2 -2
- package/lib/esm/decorators/common/any.js +1 -1
- package/lib/esm/decorators/common/anyOf.js +1 -1
- package/lib/esm/decorators/common/const.js +1 -1
- package/lib/esm/decorators/common/customKey.js +1 -1
- package/lib/esm/decorators/common/default.js +1 -1
- package/lib/esm/decorators/common/description.js +1 -1
- package/lib/esm/decorators/common/description.js.map +1 -1
- package/lib/esm/decorators/common/enum.js +2 -21
- package/lib/esm/decorators/common/enum.js.map +1 -1
- package/lib/esm/decorators/common/example.js +1 -1
- package/lib/esm/decorators/common/examples.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 +2 -2
- package/lib/esm/decorators/common/forwardGroups.js +1 -1
- package/lib/esm/decorators/common/groups.js +2 -2
- package/lib/esm/decorators/common/ignore.js +1 -1
- package/lib/esm/decorators/common/ignore.js.map +1 -1
- package/lib/esm/decorators/common/integer.js +1 -1
- package/lib/esm/decorators/common/jsonEntityFn.js +1 -1
- package/lib/esm/decorators/common/jsonEntityFn.js.map +1 -1
- 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/oneOf.js +1 -1
- package/lib/esm/decorators/common/optional.js +1 -1
- package/lib/esm/decorators/common/pattern.js +1 -1
- package/lib/esm/decorators/common/property.js +1 -1
- package/lib/esm/decorators/common/readOnly.js +1 -1
- package/lib/esm/decorators/common/recordOf.js +59 -0
- package/lib/esm/decorators/common/recordOf.js.map +1 -0
- package/lib/esm/decorators/common/required.js +2 -2
- package/lib/esm/decorators/common/requiredGroups.js +2 -2
- package/lib/esm/decorators/common/schema.js +1 -1
- package/lib/esm/decorators/common/title.js +1 -1
- package/lib/esm/decorators/common/writeOnly.js +1 -1
- package/lib/esm/decorators/config/jsonEntityComponent.js +1 -1
- package/lib/esm/decorators/generics/genericOf.js +2 -2
- package/lib/esm/decorators/generics/generics.js +1 -1
- package/lib/esm/decorators/operations/acceptMime.js +24 -0
- package/lib/esm/decorators/operations/acceptMime.js.map +1 -0
- package/lib/esm/decorators/operations/consumes.js +1 -1
- package/lib/esm/decorators/operations/contentType.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 +3 -1
- package/lib/esm/decorators/operations/in.js.map +1 -1
- package/lib/esm/decorators/operations/inFile.js +5 -5
- package/lib/esm/decorators/operations/location.js +1 -1
- package/lib/esm/decorators/operations/operationId.js +1 -1
- package/lib/esm/decorators/operations/operationPath.js +1 -1
- package/lib/esm/decorators/operations/partial.js +1 -1
- package/lib/esm/decorators/operations/path.js +1 -1
- package/lib/esm/decorators/operations/produces.js +1 -1
- package/lib/esm/decorators/operations/redirect.js +2 -2
- package/lib/esm/decorators/operations/returns.js +8 -8
- package/lib/esm/decorators/operations/route.js +3 -3
- package/lib/esm/decorators/operations/security.js +1 -1
- package/lib/esm/decorators/operations/status.js +1 -1
- package/lib/esm/decorators/operations/summary.js +1 -1
- package/lib/esm/decorators/operations/tags.js +1 -1
- package/lib/esm/decorators/operations/view.js +27 -0
- package/lib/esm/decorators/operations/view.js.map +1 -0
- package/lib/esm/domain/DecoratorContext.js +1 -1
- package/lib/esm/domain/DecoratorContext.js.map +1 -1
- package/lib/esm/domain/JsonClassStore.js +3 -3
- package/lib/esm/domain/JsonLazyRef.js +2 -2
- package/lib/esm/domain/JsonMap.js +1 -1
- package/lib/esm/domain/JsonMap.js.map +1 -1
- package/lib/esm/domain/JsonMethodStore.js +68 -26
- package/lib/esm/domain/JsonMethodStore.js.map +1 -1
- package/lib/esm/domain/JsonOperation.js +10 -25
- package/lib/esm/domain/JsonOperation.js.map +1 -1
- package/lib/esm/domain/JsonOperationPathsMap.js +1 -1
- package/lib/esm/domain/JsonOperationRoute.js +5 -1
- package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
- package/lib/esm/domain/JsonParameter.js +40 -78
- package/lib/esm/domain/JsonParameter.js.map +1 -1
- package/lib/esm/domain/JsonParameterStore.js +17 -8
- package/lib/esm/domain/JsonParameterStore.js.map +1 -1
- package/lib/esm/domain/JsonPropertyStore.js +7 -3
- package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
- package/lib/esm/domain/JsonRequestBody.js +2 -2
- package/lib/esm/domain/JsonResponse.js +4 -14
- package/lib/esm/domain/JsonResponse.js.map +1 -1
- package/lib/esm/domain/JsonSchema.js +9 -16
- package/lib/esm/domain/JsonSchema.js.map +1 -1
- package/lib/esm/domain/SpecTypes.js +0 -3
- package/lib/esm/domain/SpecTypes.js.map +1 -1
- package/lib/esm/index.js +150 -20
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/utils/from.js +5 -4
- package/lib/esm/utils/from.js.map +1 -1
- package/lib/esm/utils/generateSpec.js +41 -0
- package/lib/esm/utils/generateSpec.js.map +1 -0
- package/lib/esm/utils/generics.js.map +1 -1
- package/lib/esm/utils/getInheritedStores.js +1 -1
- package/lib/esm/utils/getJsonEntityStore.js +5 -5
- package/lib/esm/utils/getJsonPathParameters.js +20 -6
- package/lib/esm/utils/getJsonPathParameters.js.map +1 -1
- package/lib/esm/utils/getJsonSchema.js +14 -4
- package/lib/esm/utils/getJsonSchema.js.map +1 -1
- package/lib/esm/utils/getJsonType.js +2 -2
- package/lib/esm/utils/getJsonType.js.map +1 -1
- package/lib/esm/utils/getOperationsRoutes.js +5 -4
- package/lib/esm/utils/getOperationsRoutes.js.map +1 -1
- package/lib/esm/utils/getOperationsStores.js +4 -4
- package/lib/esm/utils/getPropertiesStores.js +3 -3
- package/lib/esm/utils/getRequiredProperties.js +1 -1
- package/lib/esm/utils/getSpec.js +65 -50
- package/lib/esm/utils/getSpec.js.map +1 -1
- package/lib/esm/utils/getSpecType.js +16 -0
- package/lib/esm/utils/getSpecType.js.map +1 -0
- package/lib/esm/utils/mapNullableType.js +2 -7
- package/lib/esm/utils/mapNullableType.js.map +1 -1
- package/lib/esm/utils/mapOpenSpec.js +37 -0
- package/lib/esm/utils/mapOpenSpec.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec2.js +30 -0
- package/lib/esm/utils/mapOpenSpec2.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec3.js +22 -0
- package/lib/esm/utils/mapOpenSpec3.js.map +1 -0
- package/lib/esm/utils/mapOpenSpecInfo.js +17 -0
- package/lib/esm/utils/mapOpenSpecInfo.js.map +1 -0
- package/lib/esm/utils/mapRouteOptions.js +1 -1
- package/lib/esm/utils/mergeOperation.js +4 -3
- package/lib/esm/utils/mergeOperation.js.map +1 -1
- package/lib/esm/utils/ref.js +1 -9
- package/lib/esm/utils/ref.js.map +1 -1
- package/lib/esm/utils/serializeEnumValues.js +21 -0
- package/lib/esm/utils/serializeEnumValues.js.map +1 -0
- package/lib/esm/utils/toJsonMapCollection.js +1 -1
- package/lib/esm/utils/transformToOS2.js +504 -0
- package/lib/esm/utils/transformToOS2.js.map +1 -0
- package/lib/types/constants/httpStatusMessages.d.ts +2 -263
- package/lib/types/decorators/common/ignore.d.ts +1 -1
- package/lib/types/decorators/common/jsonEntityFn.d.ts +1 -1
- package/lib/types/decorators/common/recordOf.d.ts +46 -0
- package/lib/types/decorators/operations/acceptMime.d.ts +19 -0
- package/lib/types/decorators/operations/in.d.ts +1 -1
- package/lib/types/decorators/operations/view.d.ts +23 -0
- package/lib/types/domain/JsonMap.d.ts +1 -1
- package/lib/types/domain/JsonMethodStore.d.ts +51 -2
- package/lib/types/domain/JsonOperation.d.ts +2 -1
- package/lib/types/domain/JsonOperationRoute.d.ts +5 -3
- package/lib/types/domain/JsonParameter.d.ts +2 -1
- package/lib/types/domain/JsonParameterStore.d.ts +23 -1
- package/lib/types/domain/JsonPropertyStore.d.ts +7 -0
- package/lib/types/domain/JsonResponse.d.ts +2 -1
- package/lib/types/domain/JsonSchema.d.ts +2 -2
- package/lib/types/domain/SpecTypes.d.ts +0 -3
- package/lib/types/index.d.ts +143 -13
- package/lib/types/utils/generateSpec.d.ts +16 -0
- package/lib/types/utils/generics.d.ts +1 -1
- package/lib/types/utils/getJsonSchema.d.ts +12 -2
- package/lib/types/utils/getOperationsRoutes.d.ts +2 -2
- package/lib/types/utils/getSpec.d.ts +6 -25
- package/lib/types/utils/getSpecType.d.ts +12 -0
- package/lib/types/utils/mapNullableType.d.ts +1 -1
- package/lib/types/utils/mapOpenSpec.d.ts +10 -0
- package/lib/types/utils/mapOpenSpec2.d.ts +9 -0
- package/lib/types/utils/mapOpenSpec3.d.ts +8 -0
- package/lib/types/utils/mapOpenSpecInfo.d.ts +6 -0
- package/lib/types/utils/serializeEnumValues.d.ts +5 -0
- package/lib/types/utils/transformToOS2.d.ts +25 -0
- package/package.json +34 -16
- package/readme.md +3 -1
- package/tsconfig.compile.esm.json +2 -12
- package/benchmark/cold-start.js +0 -17
- package/lib/cjs/components/index.js +0 -15
- package/lib/cjs/components/index.js.map +0 -1
- package/lib/cjs/decorators/index.js +0 -77
- package/lib/cjs/decorators/index.js.map +0 -1
- package/lib/cjs/domain/index.js +0 -20
- package/lib/cjs/domain/index.js.map +0 -1
- package/lib/cjs/interfaces/index.js +0 -8
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/esm/components/index.js +0 -12
- package/lib/esm/components/index.js.map +0 -1
- package/lib/esm/decorators/index.js +0 -74
- package/lib/esm/decorators/index.js.map +0 -1
- package/lib/esm/domain/index.js +0 -17
- package/lib/esm/domain/index.js.map +0 -1
- package/lib/esm/interfaces/index.js +0 -5
- package/lib/esm/interfaces/index.js.map +0 -1
- package/lib/types/components/index.d.ts +0 -11
- package/lib/types/decorators/index.d.ts +0 -68
- package/lib/types/domain/index.d.ts +0 -16
- package/lib/types/interfaces/index.d.ts +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mapGenericsOptions } from "../utils/generics";
|
|
2
|
-
import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
|
|
1
|
+
import { mapGenericsOptions } from "../utils/generics.js";
|
|
2
|
+
import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
3
3
|
/**
|
|
4
4
|
* Serialize class which inherit from Map like JsonMap, JsonOperation, JsonParameter.
|
|
5
5
|
* @param input
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isArray } from "@tsed/core";
|
|
2
|
-
import { alterIgnore } from "../hooks/alterIgnore";
|
|
3
|
-
import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
|
|
4
|
-
import { mapNullableType } from "../utils/mapNullableType";
|
|
2
|
+
import { alterIgnore } from "../hooks/alterIgnore.js";
|
|
3
|
+
import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
4
|
+
import { mapNullableType } from "../utils/mapNullableType.js";
|
|
5
5
|
/**
|
|
6
6
|
* Serialize Any object to a json schema
|
|
7
7
|
* @param input
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
|
|
1
|
+
import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
2
2
|
export function ofMapper(input, options, parent) {
|
|
3
3
|
return input.map((value) => {
|
|
4
4
|
return execMapper("item", value, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
|
|
1
|
+
import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
2
2
|
export function propertiesMapper(input, options, parent) {
|
|
3
3
|
if (input.isClass) {
|
|
4
4
|
return execMapper("class", input, options);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isObject } from "@tsed/core";
|
|
2
|
-
import { mapAliasedProperties } from "../domain/JsonAliasMap";
|
|
3
|
-
import { SpecTypes } from "../domain/SpecTypes";
|
|
4
|
-
import { execMapper, hasMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
|
|
5
|
-
import { getRequiredProperties } from "../utils/getRequiredProperties";
|
|
6
|
-
import { alterOneOf } from "../hooks/alterOneOf";
|
|
7
|
-
import { mapNullableType } from "../utils/mapNullableType";
|
|
2
|
+
import { mapAliasedProperties } from "../domain/JsonAliasMap.js";
|
|
3
|
+
import { SpecTypes } from "../domain/SpecTypes.js";
|
|
4
|
+
import { execMapper, hasMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
5
|
+
import { getRequiredProperties } from "../utils/getRequiredProperties.js";
|
|
6
|
+
import { alterOneOf } from "../hooks/alterOneOf.js";
|
|
7
|
+
import { mapNullableType } from "../utils/mapNullableType.js";
|
|
8
8
|
/**
|
|
9
9
|
* @ignore
|
|
10
10
|
*/
|
|
@@ -13,7 +13,6 @@ const IGNORES = ["name", "$required", "$hooks", "_nestedGenerics", SpecTypes.OPE
|
|
|
13
13
|
* @ignore
|
|
14
14
|
*/
|
|
15
15
|
const IGNORES_OPENSPEC = ["const"];
|
|
16
|
-
const IGNORES_OS2 = ["writeOnly", "readOnly"];
|
|
17
16
|
/**
|
|
18
17
|
* @ignore
|
|
19
18
|
*/
|
|
@@ -32,11 +31,10 @@ function shouldMapAlias(key, value, useAlias) {
|
|
|
32
31
|
function shouldSkipKey(key, { specType = SpecTypes.JSON, customKeys = false }) {
|
|
33
32
|
return (IGNORES.includes(key) ||
|
|
34
33
|
(key.startsWith("#") && (customKeys === false || specType !== SpecTypes.JSON)) ||
|
|
35
|
-
(specType === SpecTypes.SWAGGER && IGNORES_OS2.includes(key)) ||
|
|
36
34
|
(specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key)));
|
|
37
35
|
}
|
|
38
36
|
function isExample(key, value, options) {
|
|
39
|
-
return key === "examples" && isObject(value) &&
|
|
37
|
+
return key === "examples" && isObject(value) && SpecTypes.OPENAPI === options.specType;
|
|
40
38
|
}
|
|
41
39
|
export function schemaMapper(schema, options) {
|
|
42
40
|
const { useAlias = true, schemas = {} } = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaMapper.js","sourceRoot":"","sources":["../../../src/components/schemaMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AACxG,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;AACzH;;GAEG;AACH,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"schemaMapper.js","sourceRoot":"","sources":["../../../src/components/schemaMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AACxG,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAC,UAAU,EAAC,MAAM,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apAliasedProperties} from \"../domain/JsonAliasMap\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, hasMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getRequiredProperties} from \"../utils/getRequiredProperties\";\nimport {alterOneOf} from \"../hooks/alterOneOf\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * @ignore\n */\nconst IGNORES = [\"name\", \"$required\", \"$hooks\", \"_nestedGenerics\", SpecTypes.OPENAPI, SpecTypes.SWAGGER, SpecTypes.JSON];\n/**\n * @ignore\n */\nconst IGNORES_OPENSPEC = [\"const\"];\n\n/**\n * @ignore\n */\nfunction isEmptyProperties(key: string, value: any) {\n return typeof value === \"object\" && [\"items\", \"properties\", \"additionalProperties\"].includes(key) && Object.keys(value).length === 0;\n}\n\n/**\n * @ignore\n */\nfunction shouldMapAlias(key: string, value: any, useAlias: boolean) {\n return typeof value === \"object\" && useAlias && [\"properties\", \"additionalProperties\"].includes(key);\n}\n\n/**\n * @ignore\n */\nfunction shouldSkipKey(key: string, {specType = SpecTypes.JSON, customKeys = false}: JsonSchemaOptions) {\n return (\n IGNORES.includes(key) ||\n (key.startsWith(\"#\") && (customKeys === false || specType !== SpecTypes.JSON)) ||\n (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key))\n );\n}\n\nfunction isExample(key: string, value: any, options: JsonSchemaOptions) {\n return key === \"examples\" && isObject(value) && SpecTypes.OPENAPI === options.specType!;\n}\n\nexport function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any {\n const {useAlias = true, schemas = {}} = options;\n options = {\n ...options,\n useAlias,\n schemas\n };\n\n let obj: any = [...schema.keys()]\n .filter((key) => !shouldSkipKey(key, options))\n .reduce((item: any, key) => {\n let value = schema.get(key);\n\n key = key.replace(/^#/, \"\");\n\n if (key === \"type\") {\n return {\n ...item,\n [key]: schema.getJsonType()\n };\n }\n\n if (isExample(key, value, options)) {\n key = \"example\";\n value = Object.values(value)[0];\n }\n\n if (value && typeof value === \"object\" && hasMapper(key)) {\n value = execMapper(key, value, options, schema);\n\n if (isEmptyProperties(key, value)) {\n return item;\n }\n\n if (shouldMapAlias(key, value, useAlias)) {\n value = mapAliasedProperties(value, schema.alias);\n }\n }\n\n return {\n ...item,\n [key]: value\n };\n }, {});\n\n if (schema.isClass) {\n obj = execMapper(\"inheritedClass\", obj, {...options, root: false, schemas, target: schema.getComputedType()});\n }\n\n obj = execMapper(\"generics\", obj, {...options, root: false, schemas} as any);\n\n if (schema.has(options.specType as string)) {\n obj = {\n ...obj,\n ...schema.get(options.specType as string).toJSON(options)\n };\n }\n\n obj = getRequiredProperties(obj, schema, {...options, useAlias});\n obj = mapNullableType(obj, schema, options);\n obj = alterOneOf(obj, schema, options);\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"schema\", schemaMapper);\n"]}
|
|
@@ -1,99 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
"204": { label: "No Content", code: "NO_CONTENT" },
|
|
14
|
-
"205": { label: "Reset Content", code: "RESET_CONTENT" },
|
|
15
|
-
"206": { label: "Partial Content", code: "PARTIAL_CONTENT" },
|
|
16
|
-
"207": { label: "Multi-Status", code: "MULTI_STATUS" },
|
|
17
|
-
"208": { label: "Already Reported", code: "ALREADY_REPORTED" },
|
|
18
|
-
"226": { label: "IM Used", code: "IM_USED" },
|
|
19
|
-
"300": { label: "Multiple Choices", code: "MULTIPLE_CHOICES" },
|
|
20
|
-
"301": { label: "Moved Permanently", code: "MOVED_PERMANENTLY" },
|
|
21
|
-
"302": { label: "Found", code: "FOUND" },
|
|
22
|
-
"303": { label: "See Other", code: "SEE_OTHER" },
|
|
23
|
-
"304": { label: "Not Modified", code: "NOT_MODIFIED" },
|
|
24
|
-
"305": { label: "Use Proxy", code: "USE_PROXY" },
|
|
25
|
-
"306": { label: "(Unused)", code: "UNUSED" },
|
|
26
|
-
"307": { label: "Temporary Redirect", code: "TEMPORARY_REDIRECT" },
|
|
27
|
-
"308": { label: "Permanent Redirect", code: "PERMANENT_REDIRECT" },
|
|
28
|
-
"310": { label: "Too Many Redirects", code: "TOO_MANY_REDIRECTS" },
|
|
29
|
-
"400": { label: "Bad Request", code: "BAD_REQUEST" },
|
|
30
|
-
"401": { label: "Unauthorized", code: "UNAUTHORIZED" },
|
|
31
|
-
"402": { label: "Payment Required", code: "PAYMENT_REQUIRED" },
|
|
32
|
-
"403": { label: "Forbidden", code: "FORBIDDEN" },
|
|
33
|
-
"404": { label: "Not Found", code: "NOT_FOUND" },
|
|
34
|
-
"405": { label: "Method Not Allowed", code: "METHOD_NOT_ALLOWED" },
|
|
35
|
-
"406": { label: "Not Acceptable", code: "NOT_ACCEPTABLE" },
|
|
36
|
-
"407": {
|
|
37
|
-
label: "Proxy Authentication Required",
|
|
38
|
-
code: "PROXY_AUTHENTICATION_REQUIRED"
|
|
39
|
-
},
|
|
40
|
-
"408": { label: "Request Timeout", code: "REQUEST_TIMEOUT" },
|
|
41
|
-
"409": { label: "Conflict", code: "CONFLICT" },
|
|
42
|
-
"410": { label: "Gone", code: "GONE" },
|
|
43
|
-
"411": { label: "Length Required", code: "LENGTH_REQUIRED" },
|
|
44
|
-
"412": { label: "Precondition Failed", code: "PRECONDITION_FAILED" },
|
|
45
|
-
"413": {
|
|
46
|
-
label: "Request Entity Too Large",
|
|
47
|
-
code: "REQUEST_ENTITY_TOO_LARGE"
|
|
48
|
-
},
|
|
49
|
-
"414": { label: "Request URI Too Long", code: "REQUEST_URI_TOO_LONG" },
|
|
50
|
-
"415": { label: "Unsupported Media Type", code: "UNSUPPORTED_MEDIA_TYPE" },
|
|
51
|
-
"416": {
|
|
52
|
-
label: "Request Range Unsatisfiable",
|
|
53
|
-
code: "REQUEST_RANGE_UNSATISFIABLE"
|
|
54
|
-
},
|
|
55
|
-
"417": { label: "Expectation Failed", code: "EXPECTATION_FAILED" },
|
|
56
|
-
"418": { label: "I'm a Teapot", code: "I_M_A_TEAPOT" },
|
|
57
|
-
"421": { label: "Misdirected Request", code: "MISDIRECTED_REQUEST" },
|
|
58
|
-
"422": { label: "Unprocessable Entity", code: "UNPROCESSABLE_ENTITY" },
|
|
59
|
-
"423": { label: "Locked", code: "LOCKED" },
|
|
60
|
-
"424": { label: "Failed Dependency", code: "FAILED_DEPENDENCY" },
|
|
61
|
-
"425": { label: "Too Early", code: "TOO_EARLY" },
|
|
62
|
-
"426": { label: "Upgrade Required", code: "UPGRADE_REQUIRED" },
|
|
63
|
-
"427": { label: "Unassigned", code: "UNASSIGNED" },
|
|
64
|
-
"428": { label: "Precondition Required", code: "PRECONDITION_REQUIRED" },
|
|
65
|
-
"429": { label: "Too Many Requests", code: "TOO_MANY_REQUESTS" },
|
|
66
|
-
"430": { label: "Unassigned", code: "UNASSIGNED" },
|
|
67
|
-
"431": {
|
|
68
|
-
label: "Request Header Fields Too Large",
|
|
69
|
-
code: "REQUEST_HEADER_FIELDS_TOO_LARGE"
|
|
70
|
-
},
|
|
71
|
-
"451": {
|
|
72
|
-
label: "Unavailable For Legal Reasons",
|
|
73
|
-
code: "UNAVAILABLE_FOR_LEGAL_REASONS"
|
|
74
|
-
},
|
|
75
|
-
"500": { label: "Internal Server Error", code: "INTERNAL_SERVER_ERROR" },
|
|
76
|
-
"501": { label: "Not Implemented", code: "NOT_IMPLEMENTED" },
|
|
77
|
-
"502": { label: "Bad Gateway", code: "BAD_GATEWAY" },
|
|
78
|
-
"503": { label: "Service Unavailable", code: "SERVICE_UNAVAILABLE" },
|
|
79
|
-
"504": { label: "Gateway Timeout", code: "GATEWAY_TIMEOUT" },
|
|
80
|
-
"505": {
|
|
81
|
-
label: "HTTP Version Not Supported",
|
|
82
|
-
code: "HTTP_VERSION_NOT_SUPPORTED"
|
|
83
|
-
},
|
|
84
|
-
"506": { label: "Variant Also Negotiates", code: "VARIANT_ALSO_NEGOTIATES" },
|
|
85
|
-
"507": { label: "Insufficient Storage", code: "INSUFFICIENT_STORAGE" },
|
|
86
|
-
"508": { label: "Loop Detected", code: "LOOP_DETECTED" },
|
|
87
|
-
"509": {
|
|
88
|
-
label: "Bandwidth Limit Exceeded",
|
|
89
|
-
code: "BANDWIDTH_LIMIT_EXCEEDED"
|
|
90
|
-
},
|
|
91
|
-
"510": { label: "Not Extended", code: "NOT_EXTENDED" },
|
|
92
|
-
"511": {
|
|
93
|
-
label: "Network Authentication Required",
|
|
94
|
-
code: "NETWORK_AUTHENTICATION_REQUIRED"
|
|
95
|
-
}
|
|
96
|
-
};
|
|
1
|
+
import statuses from "statuses";
|
|
2
|
+
import { constantCase } from "change-case";
|
|
3
|
+
export const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map, code) => {
|
|
4
|
+
const message = String(statuses(code));
|
|
5
|
+
return {
|
|
6
|
+
...map,
|
|
7
|
+
[String(code)]: { label: message, code: constantCase(message) }
|
|
8
|
+
};
|
|
9
|
+
}, {});
|
|
10
|
+
HTTP_STATUS_MESSAGES["200"].label = "Success";
|
|
11
|
+
HTTP_STATUS_MESSAGES["200"].code = "SUCCESS";
|
|
97
12
|
export function getStatusConstant(status) {
|
|
98
13
|
var _a;
|
|
99
14
|
return (_a = HTTP_STATUS_MESSAGES[status]) === null || _a === void 0 ? void 0 : _a.code;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpStatusMessages.js","sourceRoot":"","sources":["../../../src/constants/httpStatusMessages.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"httpStatusMessages.js","sourceRoot":"","sources":["../../../src/constants/httpStatusMessages.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAkD,EAAE,IAAY,EAAE,EAAE;IAC7H,MAAM,OAAO,GAAW,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,OAAO;QACL,GAAG,GAAG;QACN,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,EAAC;KAC9D,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,oBAAoB,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC;AAC9C,oBAAoB,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC;AAE7C,MAAM,UAAU,iBAAiB,CAAC,MAAuB;;IACvD,OAAO,MAAC,oBAA4B,CAAC,MAAM,CAAC,0CAAE,IAAI,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAuB;;IACtD,OAAO,MAAC,oBAA4B,CAAC,MAAM,CAAC,0CAAE,KAAK,CAAC;AACtD,CAAC","sourcesContent":["import statuses from \"statuses\";\nimport {constantCase} from \"change-case\";\n\nexport const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map: Record<string, {label: string; code: string}>, code: number) => {\n const message: string = String(statuses(code));\n return {\n ...map,\n [String(code)]: {label: message, code: constantCase(message)}\n };\n}, {});\n\nHTTP_STATUS_MESSAGES[\"200\"].label = \"Success\";\nHTTP_STATUS_MESSAGES[\"200\"].code = \"SUCCESS\";\n\nexport function getStatusConstant(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.code;\n}\n\nexport function getStatusMessage(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.label;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonEntityFn } from "../common/jsonEntityFn";
|
|
1
|
+
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
2
2
|
/**
|
|
3
3
|
* 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.
|
|
4
4
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DecoratorTypes, isClass, useDecorators } from "@tsed/core";
|
|
2
|
-
import { JsonEntityFn } from "./jsonEntityFn";
|
|
3
|
-
import { Property } from "./property";
|
|
2
|
+
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
3
|
+
import { Property } from "./property.js";
|
|
4
4
|
/**
|
|
5
5
|
* Add allowed values when the property or parameters is required.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"description.js","sourceRoot":"","sources":["../../../../src/decorators/common/description.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAEhF,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"description.js","sourceRoot":"","sources":["../../../../src/decorators/common/description.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAEhF,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,WAAW,CAAC,WAAgB;IAC1C,OAAO,YAAY,CAAC,CAAC,KAAsB,EAAE,IAAyB,EAAE,EAAE;;QACxE,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,IAAI,CAAC;YACzB,KAAK,cAAc,CAAC,KAAK;gBACvB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACtC,MAAM;YAER,KAAK,cAAc,CAAC,KAAK;gBACtB,KAA4B,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACjE,MAAM;YAER,KAAK,cAAc,CAAC,MAAM;gBACxB,MAAC,KAAyB,CAAC,SAAS,0CAAE,WAAW,CAAC,WAAW,CAAC,CAAC;gBAC/D,MAAM;SACT;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {DecoratorParameters, decoratorTypeOf, DecoratorTypes} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\nimport type {JsonMethodStore} from \"../../domain/JsonMethodStore\";\nimport type {JsonParameterStore} from \"../../domain/JsonParameterStore\";\n\n/**\n * Add a description to the class, method or property\n *\n * ## Examples\n * ### On class\n *\n * ```typescript\n * @Description(\"description\")\n * class Model {\n *\n * }\n * ```\n *\n * ### On method\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * @Description(\"description\")\n * async method() {}\n * }\n * ```\n *\n * ### On parameter\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * async method(@Description(\"description\") @PathParam(\"id\") id: string) {}\n * }\n * ```\n *\n * ### On property\n *\n * ```typescript\n * class Model {\n * @Description(\"description\")\n * id: string;\n * }\n * ```\n *\n * @param {string} description\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @classDecorator\n * @methodDecorator\n * @propertyDecorator\n * @parameterDecorator\n */\nexport function Description(description: any) {\n return JsonEntityFn((store: JsonEntityStore, args: DecoratorParameters) => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PROP:\n case DecoratorTypes.CLASS:\n store.schema.description(description);\n break;\n\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.description(description);\n break;\n\n case DecoratorTypes.METHOD:\n (store as JsonMethodStore).operation?.description(description);\n break;\n }\n });\n}\n"]}
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JsonEntityFn } from "./jsonEntityFn";
|
|
3
|
-
const transformTsEnum = (enumValue) => {
|
|
4
|
-
return Object.keys(enumValue).reduce((acc, key) => {
|
|
5
|
-
if (isNaN(+key)) {
|
|
6
|
-
const value = enumValue[key];
|
|
7
|
-
return acc.concat(value);
|
|
8
|
-
}
|
|
9
|
-
return acc;
|
|
10
|
-
}, []);
|
|
11
|
-
};
|
|
1
|
+
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
12
2
|
export function Enum(enumValue, ...enumValues) {
|
|
13
3
|
return JsonEntityFn((store) => {
|
|
14
|
-
|
|
15
|
-
if (isObject(value) && value !== null) {
|
|
16
|
-
value = transformTsEnum(value);
|
|
17
|
-
}
|
|
18
|
-
return acc.concat(value);
|
|
19
|
-
}, []);
|
|
20
|
-
const types = values.reduce((set, value) => {
|
|
21
|
-
return set.add(value === null ? "null" : typeof value);
|
|
22
|
-
}, new Set());
|
|
23
|
-
store.itemSchema.enum(values).any(...types);
|
|
4
|
+
store.itemSchema.enum(enumValue, ...enumValues);
|
|
24
5
|
});
|
|
25
6
|
}
|
|
26
7
|
//# sourceMappingURL=enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/decorators/common/enum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/decorators/common/enum.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAmG5C,MAAM,UAAU,IAAI,CAAC,SAAgC,EAAE,GAAG,UAA6B;IACrF,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,UAAU,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {JSONSchema6Type} from \"json-schema\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * The enum keyword is used to restrict a value to a fixed set of values.\n * It must be an array with at least one element, where each element is unique.\n *\n * Elements in the array might be of any value, including null.\n *\n * ::: warning\n * For v6 user, use @@Enum@@ from @tsed/schema instead of @tsed/common.\n * :::\n *\n * ## Example\n * ### With primitive type\n *\n * ```typescript\n * class Model {\n * @Enum(\"value1\", \"value2\")\n * property: \"value1\" | \"value2\";\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"enum\": [\"value1\", \"value2\"]\n * }\n * }\n * }\n * ```\n *\n * ### With array type\n *\n * ```typescript\n * class Model {\n * @Enum(\"value1\", \"value2\")\n * property: (\"value1\" | \"value2\")[];\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"array\",\n * \"items\": {\n * \"type\": \"string\",\n * \"enum\": [\"value1\", \"value2\"]\n * }\n * }\n * }\n * }\n * ```\n *\n * ### With Typescript Enum\n *\n * ```typescript\n * enum SomeEnum {\n * ENUM_1 = \"enum1\",\n * ENUM_2 = \"enum2\"\n * }\n *\n * class Model {\n * @Enum(SomeEnum)\n * property: SomeEnum;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"property\": {\n * \"type\": \"string\",\n * \"enum\": [\"enum1\", \"enum2\"]\n * }\n * }\n * }\n * ```\n *\n * @param {string | number | boolean | {}} enumValue\n * @param enumValues\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function Enum(...enumValues: (JSONSchema6Type | any)[]): Function;\nexport function Enum(enumValue: JSONSchema6Type | any, ...enumValues: JSONSchema6Type[]) {\n return JsonEntityFn((store) => {\n store.itemSchema.enum(enumValue, ...enumValues);\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JsonFormatTypes } from "../../domain/JsonFormatTypes";
|
|
2
|
-
import { JsonEntityFn } from "./jsonEntityFn";
|
|
1
|
+
import { JsonFormatTypes } from "../../domain/JsonFormatTypes.js";
|
|
2
|
+
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
3
3
|
/**
|
|
4
4
|
* The following formats are supported for string validation with `format` keyword:
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DecoratorTypes } from "@tsed/core";
|
|
2
|
-
import { matchGroups } from "../../utils/matchGroups";
|
|
3
|
-
import { JsonEntityFn } from "./jsonEntityFn";
|
|
2
|
+
import { matchGroups } from "../../utils/matchGroups.js";
|
|
3
|
+
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
4
4
|
/**
|
|
5
5
|
* @ignore
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ignore.js","sourceRoot":"","sources":["../../../../src/decorators/common/ignore.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;GAEG;AACH,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,UAAU,MAAM,CAAC,KAA+B,SAAS;IAC7D,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {IgnoreCallback} from \"../../interfaces\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * @ignore\n */\nconst defaultCB = (value: any, ctx: any) => ctx.mongoose !== true;\n\n/**\n * Ignore the property when JsonMapper serialize the class to a Plain Object JavaScript.\n *\n * ::: warning\n * Swagger will not generate documentation for the ignored property.\n * :::\n *\n * ```typescript\n * class User {\n * @Ignore()\n * _id: string;\n *\n * @Property()\n * firstName: string;\n *\n * @Property()\n * lastName: string;\n *\n * @Ignore((value, ctx) => !ctx.mongoose) // don't ignore prop only if mongoose\n * password: string;\n * }\n * ```\n *\n * The controller:\n * ```typescript\n * import {Post, Controller, BodyParams} from \"@tsed/common\";\n * import {Person} from \"../models/Person\";\n *\n * @Controller(\"/\")\n * export class UsersCtrl {\n * @Get(\"/\")\n * get(): User {\n * const user = new User();\n * user._id = \"12345\";\n * user.firstName = \"John\";\n * user.lastName = \"Doe\";\n * user.password = \"secretpassword\";\n * return\n * }\n * }\n * ```\n *\n * The expected json object:\n *\n * ```json\n * {\n * \"firstName\": \"John\",\n * \"lastName\": \"Doe\"\n * }\n * ```\n * @param cb Callback to know if the property must be ignored\n * @decorator\n * @validation\n * @swagger\n * @schema\n */\nexport function Ignore(cb: boolean | IgnoreCallback = defaultCB) {\n return JsonEntityFn((store) => {\n store.schema.ignore(cb);\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ignore.js","sourceRoot":"","sources":["../../../../src/decorators/common/ignore.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;GAEG;AACH,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,UAAU,MAAM,CAAC,KAA+B,SAAS;IAC7D,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {IgnoreCallback} from \"../../interfaces/IgnoreCallback\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * @ignore\n */\nconst defaultCB = (value: any, ctx: any) => ctx.mongoose !== true;\n\n/**\n * Ignore the property when JsonMapper serialize the class to a Plain Object JavaScript.\n *\n * ::: warning\n * Swagger will not generate documentation for the ignored property.\n * :::\n *\n * ```typescript\n * class User {\n * @Ignore()\n * _id: string;\n *\n * @Property()\n * firstName: string;\n *\n * @Property()\n * lastName: string;\n *\n * @Ignore((value, ctx) => !ctx.mongoose) // don't ignore prop only if mongoose\n * password: string;\n * }\n * ```\n *\n * The controller:\n * ```typescript\n * import {Post, Controller, BodyParams} from \"@tsed/common\";\n * import {Person} from \"../models/Person\";\n *\n * @Controller(\"/\")\n * export class UsersCtrl {\n * @Get(\"/\")\n * get(): User {\n * const user = new User();\n * user._id = \"12345\";\n * user.firstName = \"John\";\n * user.lastName = \"Doe\";\n * user.password = \"secretpassword\";\n * return\n * }\n * }\n * ```\n *\n * The expected json object:\n *\n * ```json\n * {\n * \"firstName\": \"John\",\n * \"lastName\": \"Doe\"\n * }\n * ```\n * @param cb Callback to know if the property must be ignored\n * @decorator\n * @validation\n * @swagger\n * @schema\n */\nexport function Ignore(cb: boolean | IgnoreCallback = defaultCB) {\n return JsonEntityFn((store) => {\n store.schema.ignore(cb);\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonEntityFn.js","sourceRoot":"","sources":["../../../../src/decorators/common/jsonEntityFn.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAC1B,EAAuD;IAEvD,OAAO,CAAC,GAAG,UAA+B,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAQ,EAAE,CAAC,kBAAkB,CAAI,GAAG,UAAU,CAAM,EAAE,UAAU,CAAC,CAAC;QAC9E,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;YAChC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC;SACvB;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {DecoratorParameters} from \"@tsed/core\";\nimport type {JsonEntityStore} from \"../../domain\";\nimport {getJsonEntityStore} from \"../../utils/getJsonEntityStore\";\n\n/**\n * Decorator util to compose another decorator. See @@Description@@ decorator implementation for more details.\n *\n * ## Usage\n *\n * ```typescript\n * export function Description(description: any) {\n * return JsonEntityFn((entity: JsonEntityStore, args: DecoratorParameters) => {\n * entity.itemSchema.description(description)\n * });\n * }\n * ```\n *\n * @param fn\n * @decorator\n * @utils\n * @model\n */\nexport function JsonEntityFn<T extends JsonEntityStore = JsonEntityStore>(\n fn: (entity: T, parameters: DecoratorParameters) => any\n): (...args: any[]) => any {\n return (...parameters: DecoratorParameters) => {\n const result: any = fn(getJsonEntityStore<T>(...parameters) as T, parameters);\n if (typeof result === \"function\") {\n result(...parameters);\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jsonEntityFn.js","sourceRoot":"","sources":["../../../../src/decorators/common/jsonEntityFn.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAC1B,EAAuD;IAEvD,OAAO,CAAC,GAAG,UAA+B,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAQ,EAAE,CAAC,kBAAkB,CAAI,GAAG,UAAU,CAAM,EAAE,UAAU,CAAC,CAAC;QAC9E,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;YAChC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC;SACvB;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {DecoratorParameters} from \"@tsed/core\";\nimport type {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {getJsonEntityStore} from \"../../utils/getJsonEntityStore\";\n\n/**\n * Decorator util to compose another decorator. See @@Description@@ decorator implementation for more details.\n *\n * ## Usage\n *\n * ```typescript\n * export function Description(description: any) {\n * return JsonEntityFn((entity: JsonEntityStore, args: DecoratorParameters) => {\n * entity.itemSchema.description(description)\n * });\n * }\n * ```\n *\n * @param fn\n * @decorator\n * @utils\n * @model\n */\nexport function JsonEntityFn<T extends JsonEntityStore = JsonEntityStore>(\n fn: (entity: T, parameters: DecoratorParameters) => any\n): (...args: any[]) => any {\n return (...parameters: DecoratorParameters) => {\n const result: any = fn(getJsonEntityStore<T>(...parameters) as T, parameters);\n if (typeof result === \"function\") {\n result(...parameters);\n }\n };\n}\n"]}
|