@tsed/schema 7.0.0-beta.3 → 7.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.js +4 -4
- package/lib/cjs/components/schemaMapper.js +1 -1
- 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/anyOf.js +4 -0
- package/lib/cjs/decorators/common/anyOf.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/oneOf.js +4 -0
- package/lib/cjs/decorators/common/oneOf.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 +38 -44
- 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 +1 -0
- package/lib/cjs/domain/SpecTypes.js.map +1 -1
- package/lib/cjs/index.js +149 -20
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/JsonSchemaOptions.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 +55 -0
- package/lib/cjs/utils/generateSpec.js.map +1 -0
- package/lib/cjs/utils/generics.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 -1
- 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/mergeSpec.js.map +1 -1
- package/lib/cjs/utils/serializeEnumValues.js +26 -0
- package/lib/cjs/utils/serializeEnumValues.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 -7
- 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 +5 -1
- package/lib/esm/decorators/common/anyOf.js.map +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 +5 -1
- package/lib/esm/decorators/common/oneOf.js.map +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 +42 -48
- 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 +1 -0
- package/lib/esm/domain/SpecTypes.js.map +1 -1
- package/lib/esm/index.js +149 -20
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/JsonSchemaOptions.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 +50 -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/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 -2
- 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/mergeSpec.js.map +1 -1
- package/lib/esm/utils/ref.js +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/types/constants/httpStatusMessages.d.ts +2 -263
- package/lib/types/decorators/common/anyOf.d.ts +4 -0
- 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/oneOf.d.ts +4 -0
- 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 +1 -0
- package/lib/types/index.d.ts +142 -13
- package/lib/types/interfaces/JsonSchemaOptions.d.ts +2 -2
- 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 +5 -4
- 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/mergeSpec.d.ts +2 -2
- package/lib/types/utils/serializeEnumValues.d.ts +5 -0
- package/package.json +30 -15
- package/readme.md +1 -0
- 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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Schema } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Constructs a json schema object type whose property keys are keys and whose property values are type.
|
|
4
|
+
*
|
|
5
|
+
* ## Example
|
|
6
|
+
*
|
|
7
|
+
* ```typescript
|
|
8
|
+
* type keys = 'one' | 'two';
|
|
9
|
+
*
|
|
10
|
+
* class Part {
|
|
11
|
+
* prop: string;
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* type Parts = Record<keys, Part>;
|
|
15
|
+
*
|
|
16
|
+
* class Test {
|
|
17
|
+
* @RecordOf(Part, 'one', 'two')
|
|
18
|
+
* parts: Parts;
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Will produce:
|
|
23
|
+
*
|
|
24
|
+
* ```json
|
|
25
|
+
* {
|
|
26
|
+
* "type": "object",
|
|
27
|
+
* "properties": {
|
|
28
|
+
* "one": {
|
|
29
|
+
* "$ref": "#/components/schemas/Part"
|
|
30
|
+
* },
|
|
31
|
+
* "two": {
|
|
32
|
+
* "$ref": "#/components/schemas/Part"
|
|
33
|
+
* },
|
|
34
|
+
* },
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param model
|
|
39
|
+
* @param keys
|
|
40
|
+
* @decorator
|
|
41
|
+
* @validation
|
|
42
|
+
* @swagger
|
|
43
|
+
* @schema
|
|
44
|
+
* @classDecorator
|
|
45
|
+
* @input
|
|
46
|
+
*/
|
|
47
|
+
export function RecordOf(model, ...keys) {
|
|
48
|
+
return Schema({
|
|
49
|
+
properties: {
|
|
50
|
+
...keys.reduce((initial, key) => {
|
|
51
|
+
return {
|
|
52
|
+
...initial,
|
|
53
|
+
[key]: model
|
|
54
|
+
};
|
|
55
|
+
}, {})
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=recordOf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordOf.js","sourceRoot":"","sources":["../../../../src/decorators/common/recordOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAU,EAAE,GAAG,IAAc;IACpD,OAAO,MAAM,CAAC;QACZ,UAAU,EAAE;YACV,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;gBAC9B,OAAO;oBACL,GAAG,OAAO;oBACV,CAAC,GAAG,CAAC,EAAE,KAAK;iBACb,CAAC;YACJ,CAAC,EAAE,EAAE,CAAC;SACP;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Schema} from \"./schema\";\n\n/**\n * Constructs a json schema object type whose property keys are keys and whose property values are type.\n *\n * ## Example\n *\n * ```typescript\n * type keys = 'one' | 'two';\n *\n * class Part {\n * prop: string;\n * }\n *\n * type Parts = Record<keys, Part>;\n *\n * class Test {\n * @RecordOf(Part, 'one', 'two')\n * parts: Parts;\n * }\n * ```\n *\n * Will produce:\n *\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"one\": {\n * \"$ref\": \"#/components/schemas/Part\"\n * },\n * \"two\": {\n * \"$ref\": \"#/components/schemas/Part\"\n * },\n * },\n * }\n * ```\n *\n * @param model\n * @param keys\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @classDecorator\n * @input\n */\nexport function RecordOf(model: any, ...keys: string[]) {\n return Schema({\n properties: {\n ...keys.reduce((initial, key) => {\n return {\n ...initial,\n [key]: model\n };\n }, {})\n }\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { matchGroups } from "../../utils/matchGroups";
|
|
2
|
-
import { JsonEntityFn } from "./jsonEntityFn";
|
|
1
|
+
import { matchGroups } from "../../utils/matchGroups.js";
|
|
2
|
+
import { JsonEntityFn } from "./jsonEntityFn.js";
|
|
3
3
|
/**
|
|
4
4
|
* Apply groups validation strategy for required property.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isObject } from "@tsed/core";
|
|
2
|
-
import { JsonEntityStore } from "../../domain/JsonEntityStore";
|
|
3
|
-
import { string } from "../../utils/from";
|
|
2
|
+
import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
3
|
+
import { string } from "../../utils/from.js";
|
|
4
4
|
/**
|
|
5
5
|
* @ignore
|
|
6
6
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StoreSet, useDecorators } from "@tsed/core";
|
|
2
|
+
import { Produces } from "./produces.js";
|
|
3
|
+
/**
|
|
4
|
+
* Set a mime list which are acceptable and checks if the specified content types are acceptable, based on the request’s Accept HTTP header field.
|
|
5
|
+
*
|
|
6
|
+
* ```typescript
|
|
7
|
+
* @Controller('/mypath')
|
|
8
|
+
* export class MyCtrl {
|
|
9
|
+
*
|
|
10
|
+
* @Get('/')
|
|
11
|
+
* @AcceptMime('application/json')
|
|
12
|
+
* public getResource(){}
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param mimes
|
|
17
|
+
* @decorator
|
|
18
|
+
* @operation
|
|
19
|
+
* @response
|
|
20
|
+
*/
|
|
21
|
+
export function AcceptMime(...mimes) {
|
|
22
|
+
return useDecorators(Produces(...mimes), StoreSet("acceptMimes", mimes));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=acceptMime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acceptMime.js","sourceRoot":"","sources":["../../../../src/decorators/operations/acceptMime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAAe;IAC3C,OAAO,aAAa,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,EAAE,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import {StoreSet, useDecorators} from \"@tsed/core\";\nimport {Produces} from \"./produces\";\n\n/**\n * Set a mime list which are acceptable and checks if the specified content types are acceptable, based on the request’s Accept HTTP header field.\n *\n * ```typescript\n * @Controller('/mypath')\n * export class MyCtrl {\n *\n * @Get('/')\n * @AcceptMime('application/json')\n * public getResource(){}\n * }\n * ```\n *\n * @param mimes\n * @decorator\n * @operation\n * @response\n */\nexport function AcceptMime(...mimes: string[]): Function {\n return useDecorators(Produces(...mimes), StoreSet(\"acceptMimes\", mimes));\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Returns } from "./returns";
|
|
1
|
+
import { Returns } from "./returns.js";
|
|
2
2
|
/**
|
|
3
3
|
* Sets the Content-Type HTTP header to the MIME type as determined by mime.lookup() for the specified type.
|
|
4
4
|
* If type contains the “/” character, then it sets the `Content-Type` to type.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
|
|
2
|
-
import { JsonEntityFn } from "../common/jsonEntityFn";
|
|
2
|
+
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
3
3
|
/**
|
|
4
4
|
* Add deprecated metadata on the decorated element.
|
|
5
5
|
*
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
|
|
2
|
-
import { JsonEntityStore
|
|
2
|
+
import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
3
|
+
import { JsonParameter } from "../../domain/JsonParameter.js";
|
|
4
|
+
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
3
5
|
/**
|
|
4
6
|
* Add a input parameter.
|
|
5
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in.js","sourceRoot":"","sources":["../../../../src/decorators/operations/in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAQ,wBAAwB,EAAC,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"in.js","sourceRoot":"","sources":["../../../../src/decorators/operations/in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAQ,wBAAwB,EAAC,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAC,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AA8CrE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,EAAE,CAAC,MAAmC;IACpD,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;IAC1C,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,MAAM,SAAS,GAAG,CAAC,MAAW,EAAE,WAA6B,EAAE,KAAmC,EAAE,EAAE;QACpG,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;QAE/D,QAAQ,KAAK,CAAC,aAAa,EAAE;YAC3B,KAAK,cAAc,CAAC,KAAK;gBACtB,KAA4B,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;gBACnD,MAAM;YACR,KAAK,cAAc,CAAC,MAAM;gBACxB,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;gBACxB,KAAyB,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CA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AAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {decorateMethodsOf, DecoratorTypes, Type, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonMethodStore} from \"../../domain/JsonMethodStore\";\nimport {JsonParameter} from \"../../domain/JsonParameter\";\nimport {JsonParameterStore} from \"../../domain/JsonParameterStore\";\nimport {JsonParameterTypes} from \"../../domain/JsonParameterTypes\";\nimport {JsonSchema, JsonSchemaObject} from \"../../domain/JsonSchema\";\n\nexport interface InChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n (target: Object, propertyKey: string | symbol, parameterIndex: number): void;\n\n (target: Function): void;\n\n /**\n * Type of this in parameter\n * @param type\n */\n Type(type: Type<any>): this;\n\n /**\n *\n * @param name\n */\n Name(name: string): this;\n\n /**\n *\n * @param description\n */\n Description(description: string): this;\n\n /**\n *\n * @param required\n */\n Required(required?: boolean): this;\n\n /**\n * Add pattern constraint. Only available for OPENAPI.\n * @param pattern\n */\n Pattern(pattern: string | RegExp): this;\n\n /**\n * Add custom schema.\n * @param schema\n */\n Schema(schema: Partial<JsonSchemaObject>): this;\n}\n\n/**\n * Add a input parameter.\n *\n * ::: warning\n * Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.\n * But you can use this decorator on Method, to add extra in parameters like Authorization header.\n *\n * ```typescript\n * @Controller(\"/\")\n * class MyController {\n * @Get(\"/\")\n * @In(\"header\").Type(String).Name(\"Authorization\").Required()\n * method() {\n * }\n * }\n * ```\n * :::\n *\n * @param inType\n * @decorator\n * @swagger\n * @schema\n * @input\n * @operation\n */\nexport function In(inType: JsonParameterTypes | string): InChainedDecorators {\n const jsonParameter = new JsonParameter();\n const schema: any = {};\n\n const decorator = (target: any, propertyKey?: string | symbol, index?: PropertyDescriptor | number) => {\n const store = JsonEntityStore.from(target, propertyKey, index);\n\n switch (store.decoratorType) {\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.in(inType);\n break;\n case DecoratorTypes.METHOD:\n jsonParameter.in(inType);\n (store as JsonMethodStore).operation.addParameter(-1, jsonParameter);\n\n jsonParameter.schema(JsonSchema.from(schema));\n break;\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(target, decorator);\n break;\n\n default:\n throw new UnsupportedDecoratorType(In, [target, propertyKey, index]);\n }\n };\n\n decorator.Type = (type: Type<any>) => {\n schema.type = type;\n\n return decorator;\n };\n\n decorator.Name = (name: string) => {\n jsonParameter.name(name);\n\n return decorator;\n };\n\n decorator.Description = (description: string) => {\n jsonParameter.description(description);\n\n return decorator;\n };\n\n decorator.Required = (required: boolean = true) => {\n jsonParameter.required(required);\n\n return decorator;\n };\n\n decorator.Pattern = (pattern: string | RegExp) => {\n return decorator.Schema({pattern: pattern.toString()});\n };\n\n decorator.Schema = (_schema: any) => {\n Object.assign(schema, _schema);\n\n return decorator;\n };\n\n return decorator;\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Metadata, useDecorators, useMethodDecorators } from "@tsed/core";
|
|
2
|
-
import { In } from "./in";
|
|
3
|
-
import { JsonParameterTypes } from "../../domain/JsonParameterTypes";
|
|
4
|
-
import { Returns } from "./returns";
|
|
5
|
-
import { Name } from "../common/name";
|
|
6
|
-
import { Consumes } from "./consumes";
|
|
2
|
+
import { In } from "./in.js";
|
|
3
|
+
import { JsonParameterTypes } from "../../domain/JsonParameterTypes.js";
|
|
4
|
+
import { Returns } from "./returns.js";
|
|
5
|
+
import { Name } from "../common/name.js";
|
|
6
|
+
import { Consumes } from "./consumes.js";
|
|
7
7
|
/**
|
|
8
8
|
* Add a input file parameter.
|
|
9
9
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNumber, isString, useDecorators } from "@tsed/core";
|
|
2
|
-
import { JsonEntityFn } from "../common/jsonEntityFn";
|
|
3
|
-
import { Returns } from "./returns";
|
|
2
|
+
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
3
|
+
import { Returns } from "./returns.js";
|
|
4
4
|
export function Redirect(...args) {
|
|
5
5
|
const { status, url, meta } = args.reduce((options, value) => {
|
|
6
6
|
if (isNumber(value)) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, isArray, isCollection, isObject, isPlainObject, isPrimitiveOrPrimitiveClass, isString } from "@tsed/core";
|
|
2
|
-
import { getStatusMessage } from "../../constants/httpStatusMessages";
|
|
3
|
-
import { DecoratorContext } from "../../domain/DecoratorContext";
|
|
4
|
-
import { JsonEntityStore } from "../../domain/JsonEntityStore";
|
|
5
|
-
import { JsonSchema } from "../../domain/JsonSchema";
|
|
6
|
-
import { getStatusModel } from "../../utils/defineStatusModel";
|
|
7
|
-
import { string } from "../../utils/from";
|
|
8
|
-
import { isSuccessStatus } from "../../utils/isSuccessStatus";
|
|
9
|
-
import { mapHeaders } from "../../utils/mapHeaders";
|
|
2
|
+
import { getStatusMessage } from "../../constants/httpStatusMessages.js";
|
|
3
|
+
import { DecoratorContext } from "../../domain/DecoratorContext.js";
|
|
4
|
+
import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
5
|
+
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
6
|
+
import { getStatusModel } from "../../utils/defineStatusModel.js";
|
|
7
|
+
import { string } from "../../utils/from.js";
|
|
8
|
+
import { isSuccessStatus } from "../../utils/isSuccessStatus.js";
|
|
9
|
+
import { mapHeaders } from "../../utils/mapHeaders.js";
|
|
10
10
|
/**
|
|
11
11
|
* @ignore
|
|
12
12
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DecoratorContext } from "../../domain/DecoratorContext";
|
|
2
|
-
import { mapRouteOptions } from "../../utils/mapRouteOptions";
|
|
3
|
-
import { OperationMethods } from "../../constants/httpMethods";
|
|
1
|
+
import { DecoratorContext } from "../../domain/DecoratorContext.js";
|
|
2
|
+
import { mapRouteOptions } from "../../utils/mapRouteOptions.js";
|
|
3
|
+
import { OperationMethods } from "../../constants/httpMethods.js";
|
|
4
4
|
class RouteDecoratorContext extends DecoratorContext {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
|
|
2
|
-
import { JsonEntityFn } from "../common/jsonEntityFn";
|
|
2
|
+
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
3
3
|
function mapTags(tags) {
|
|
4
4
|
return tags.map((tag) => {
|
|
5
5
|
if (typeof tag === "string") {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StoreSet } from "@tsed/core";
|
|
2
|
+
/**
|
|
3
|
+
* Use a view and sends the rendered HTML string to the client. Optional parameter:
|
|
4
|
+
*
|
|
5
|
+
* * viewOptions, an object whose properties define local variables for the view.
|
|
6
|
+
*
|
|
7
|
+
* The view argument is a string that is the file path of the view file to render.
|
|
8
|
+
* This can be an absolute path, or a path relative to the views setting.
|
|
9
|
+
* If the path does not contain a file extension, then the view engine setting determines the file extension.
|
|
10
|
+
* If the path does contain a file extension, then Express will load the module for the specified template engine (via require())
|
|
11
|
+
* and render it using the loaded module’s __express function.
|
|
12
|
+
*
|
|
13
|
+
* For more information, see [Using template engines with Express](http://expressjs.com/guide/using-template-engines.html).
|
|
14
|
+
*
|
|
15
|
+
* > NOTE: The view argument performs file system operations like reading a file from disk and evaluating Node.js modules,
|
|
16
|
+
* and as so for security reasons should not contain input from the end-user.
|
|
17
|
+
*
|
|
18
|
+
* @param path Relative path to the view file.
|
|
19
|
+
* @param options Additional options
|
|
20
|
+
* @decorator
|
|
21
|
+
* @operation
|
|
22
|
+
* @response
|
|
23
|
+
*/
|
|
24
|
+
export function View(path, options) {
|
|
25
|
+
return StoreSet("view", { path, options });
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../../../src/decorators/operations/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,OAAgB;IACjD,OAAO,QAAQ,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,OAAO,EAAC,CAAQ,CAAC;AAClD,CAAC","sourcesContent":["import {StoreSet} from \"@tsed/core\";\n\n/**\n * Use a view and sends the rendered HTML string to the client. Optional parameter:\n *\n * * viewOptions, an object whose properties define local variables for the view.\n *\n * The view argument is a string that is the file path of the view file to render.\n * This can be an absolute path, or a path relative to the views setting.\n * If the path does not contain a file extension, then the view engine setting determines the file extension.\n * If the path does contain a file extension, then Express will load the module for the specified template engine (via require())\n * and render it using the loaded module’s __express function.\n *\n * For more information, see [Using template engines with Express](http://expressjs.com/guide/using-template-engines.html).\n *\n * > NOTE: The view argument performs file system operations like reading a file from disk and evaluating Node.js modules,\n * and as so for security reasons should not contain input from the end-user.\n *\n * @param path Relative path to the view file.\n * @param options Additional options\n * @decorator\n * @operation\n * @response\n */\nexport function View(path: string, options?: Object): MethodDecorator {\n return StoreSet(\"view\", {path, options}) as any;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecoratorContext.js","sourceRoot":"","sources":["../../../src/domain/DecoratorContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAC,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AASlD;;GAEG;AACH,MAAM,OAAgB,gBAA0B,SAAQ,GAAgB;IAMtE,YAAY,OAAY,EAAE;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AAC;IACnB,CAAC;IAES,MAAM,CAAC,IAAyB,EAAE,SAAc;QACxD,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC1B,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC;IAES,QAAQ,CAAC,GAAW,EAAE,KAAU;QACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAES,UAAU;QAClB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;YACnC,MAAM,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAES,UAAU,KAAI,CAAC;IAEf,SAAS,KAAI,CAAC;CACzB","sourcesContent":["import {DecoratorParameters, DecoratorTypes} from \"@tsed/core\";\nimport {pascalCase} from \"pascal-case\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\n\n/**\n * @ignore\n */\nexport interface DecoratorActionHandler {\n (ctx: Map<string, any>): void;\n}\n\n/**\n * @ignore\n */\nexport abstract class DecoratorContext<T = any> extends Map<string, any> {\n readonly methods: string[];\n protected decoratorType: DecoratorTypes;\n protected entity: JsonEntityStore;\n protected actions: DecoratorActionHandler[] = [];\n\n constructor(opts: any = {}) {\n super();\n\n Object.entries(opts).forEach(([key, value]) => {\n this.set(key, value);\n });\n }\n\n addAction(cb: DecoratorActionHandler) {\n this.actions.push(cb);\n return this;\n }\n\n build(): T {\n const decorator: any = (...args: DecoratorParameters) => this.bind(args, decorator);\n\n const wrap = (cb: any) => {\n return (...args: any[]) => {\n cb(...args);\n return decorator;\n };\n };\n\n const wrapKey = (key: string) => {\n return wrap((...values: any[]) => {\n key in this ? (this as any)[key](...values) : this.set(key, values[0]);\n });\n };\n\n this.methods.forEach((name) => {\n decorator[pascalCase(name)] = wrapKey(name);\n });\n\n return decorator as unknown as T;\n }\n\n toObject(): any {\n return [...this.entries()].reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: value\n };\n }, {});\n }\n\n getMergedKey(key: string, defaultValue: any) {\n let value = this.get(key) || defaultValue;\n\n if (!value) {\n return;\n }\n\n if (this.decoratorType === DecoratorTypes.CLASS) {\n value = {\n ...value,\n ...(defaultValue || {})\n };\n }\n\n return {\n ...(defaultValue || {}),\n ...value\n };\n }\n\n protected bind(args: DecoratorParameters, decorator: any) {\n this.entity = JsonEntityStore.from(...args);\n\n this.beforeInit();\n this.onInit(args, decorator);\n this.afterInit();\n }\n\n protected onInit(args: DecoratorParameters, decorator: any): void {\n this.forEach((value, key) => {\n this.onMapKey(key, value);\n });\n }\n\n protected onMapKey(key: string, value: any): void {\n this.entity.set(key, value);\n }\n\n protected runActions() {\n this.actions.forEach((action: any) => {\n action(this);\n });\n\n return this;\n }\n\n protected beforeInit() {}\n\n protected afterInit() {}\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { DecoratorTypes } from "@tsed/core";
|
|
3
|
-
import { JsonEntityStore } from "./JsonEntityStore";
|
|
4
|
-
import { JsonSchema } from "./JsonSchema";
|
|
5
|
-
import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent";
|
|
3
|
+
import { JsonEntityStore } from "./JsonEntityStore.js";
|
|
4
|
+
import { JsonSchema } from "./JsonSchema.js";
|
|
5
|
+
import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent.js";
|
|
6
6
|
let JsonClassStore = class JsonClassStore extends JsonEntityStore {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nameOf } from "@tsed/core";
|
|
2
|
-
import { execMapper } from "../registries/JsonSchemaMapperContainer";
|
|
3
|
-
import { getJsonEntityStore } from "../utils/getJsonEntityStore";
|
|
2
|
+
import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
3
|
+
import { getJsonEntityStore } from "../utils/getJsonEntityStore.js";
|
|
4
4
|
export class JsonLazyRef {
|
|
5
5
|
constructor(getType) {
|
|
6
6
|
this.getType = getType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonMap.js","sourceRoot":"","sources":["../../../src/domain/JsonMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AAEnE,MAAM,OAAO,OAAW,SAAQ,GAAgB;IAG9C,YAAY,MAAkB,EAAE;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,MAAwB,EAAE;QAC/B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC3C,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;aAClB;iBAAM;gBACL,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import {isFunction} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\n\nexport class JsonMap<T> extends Map<string, any> {\n [key: string]: any;\n\n constructor(obj: Partial<T> = {}) {\n super();\n\n this.assign(obj);\n }\n\n assign(obj: Partial<T> & any = {}) {\n Object.entries(obj).forEach(([key, value]) => {\n if (isFunction(this[key])) {\n this[key](value);\n } else {\n this.set(key, value);\n }\n });\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n return execMapper(\"map\", this, options);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"JsonMap.js","sourceRoot":"","sources":["../../../src/domain/JsonMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AAEnE,MAAM,OAAO,OAAW,SAAQ,GAAgB;IAG9C,YAAY,MAAkB,EAAE;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,MAAwB,EAAE;QAC/B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC3C,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;aAClB;iBAAM;gBACL,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import {isFunction} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\n\nexport class JsonMap<T> extends Map<string, any> {\n [key: string]: any;\n\n constructor(obj: Partial<T> = {}) {\n super();\n\n this.assign(obj);\n }\n\n assign(obj: Partial<T> & any = {}) {\n Object.entries(obj).forEach(([key, value]) => {\n if (isFunction(this[key])) {\n this[key](value);\n } else {\n this.set(key, value);\n }\n });\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n return execMapper(\"map\", this, options);\n }\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { DecoratorTypes, descriptorOf, isCollection, isFunction, isPromise, Metadata, Store } from "@tsed/core";
|
|
3
|
-
import { JsonEntityStore } from "./JsonEntityStore";
|
|
4
|
-
import { JsonOperation } from "./JsonOperation";
|
|
5
|
-
import { JsonSchema } from "./JsonSchema";
|
|
6
|
-
import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent";
|
|
2
|
+
import { DecoratorTypes, deepMerge, descriptorOf, isCollection, isFunction, isPromise, Metadata, prototypeOf, Store } from "@tsed/core";
|
|
3
|
+
import { JsonEntityStore } from "./JsonEntityStore.js";
|
|
4
|
+
import { JsonOperation } from "./JsonOperation.js";
|
|
5
|
+
import { JsonSchema } from "./JsonSchema.js";
|
|
6
|
+
import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent.js";
|
|
7
7
|
let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
|
|
8
8
|
constructor(options) {
|
|
9
9
|
super({
|
|
@@ -28,12 +28,37 @@ let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
|
|
|
28
28
|
this.before(beforeMiddlewares);
|
|
29
29
|
this.use(middlewares);
|
|
30
30
|
}
|
|
31
|
+
get params() {
|
|
32
|
+
return this.parameters;
|
|
33
|
+
}
|
|
34
|
+
get view() {
|
|
35
|
+
return this.store.get("view");
|
|
36
|
+
}
|
|
37
|
+
set view(view) {
|
|
38
|
+
this.store.set("view", view);
|
|
39
|
+
}
|
|
40
|
+
get acceptMimes() {
|
|
41
|
+
return this.store.get("acceptMimes", []);
|
|
42
|
+
}
|
|
43
|
+
set acceptMimes(mimes) {
|
|
44
|
+
this.store.set("acceptMimes", mimes);
|
|
45
|
+
}
|
|
31
46
|
get parameters() {
|
|
32
47
|
return [...this.children.values()];
|
|
33
48
|
}
|
|
34
49
|
get operationPaths() {
|
|
35
50
|
return this.operation.operationPaths;
|
|
36
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Get an endpoint.
|
|
54
|
+
* @param target
|
|
55
|
+
* @param propertyKey
|
|
56
|
+
* @param descriptor
|
|
57
|
+
*/
|
|
58
|
+
static get(target, propertyKey, descriptor) {
|
|
59
|
+
descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);
|
|
60
|
+
return JsonEntityStore.from(prototypeOf(target), propertyKey, descriptor);
|
|
61
|
+
}
|
|
37
62
|
getResponseOptions(status, contentType = "application/json") {
|
|
38
63
|
const media = this.operation.getResponseOf(status).getMedia(contentType, false);
|
|
39
64
|
if (media && media.has("schema")) {
|
|
@@ -42,27 +67,6 @@ let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
|
|
|
42
67
|
}
|
|
43
68
|
return { type: this.type };
|
|
44
69
|
}
|
|
45
|
-
build() {
|
|
46
|
-
if (!this._type) {
|
|
47
|
-
let type = Metadata.getReturnType(this.target, this.propertyKey);
|
|
48
|
-
type = isPromise(type) ? undefined : type;
|
|
49
|
-
this.buildType(type);
|
|
50
|
-
}
|
|
51
|
-
this._type = this._type || Object;
|
|
52
|
-
this.parent.children.set(this.propertyName, this);
|
|
53
|
-
if (isCollection(this._type)) {
|
|
54
|
-
this.collectionType = this._type;
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
delete this._type;
|
|
57
|
-
}
|
|
58
|
-
this._schema = JsonSchema.from({
|
|
59
|
-
type: this.collectionType || this.type
|
|
60
|
-
});
|
|
61
|
-
if (this.collectionType) {
|
|
62
|
-
this._schema.itemSchema(this.type);
|
|
63
|
-
}
|
|
64
|
-
this.parent.schema.addProperty(this.propertyName, this.schema);
|
|
65
|
-
}
|
|
66
70
|
/**
|
|
67
71
|
* Append middlewares to the beforeMiddlewares list.
|
|
68
72
|
* @param args
|
|
@@ -89,10 +93,48 @@ let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
|
|
|
89
93
|
this.middlewares = this.middlewares.concat(args).filter(isFunction);
|
|
90
94
|
return this;
|
|
91
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Find the value at the controller level. Let this value be extended or overridden by the endpoint itself.
|
|
98
|
+
*
|
|
99
|
+
* @param key
|
|
100
|
+
* @returns {any}
|
|
101
|
+
*/
|
|
102
|
+
get(key) {
|
|
103
|
+
const ctrlValue = Store.from(this.target).get(key);
|
|
104
|
+
return deepMerge(ctrlValue, this.store.get(key));
|
|
105
|
+
}
|
|
106
|
+
getParamTypes() {
|
|
107
|
+
return [...this.children.values()].reduce((obj, item) => ({
|
|
108
|
+
...obj,
|
|
109
|
+
[item.paramType]: true
|
|
110
|
+
}), {});
|
|
111
|
+
}
|
|
112
|
+
build() {
|
|
113
|
+
if (!this._type) {
|
|
114
|
+
let type = Metadata.getReturnType(this.target, this.propertyKey);
|
|
115
|
+
type = isPromise(type) ? undefined : type;
|
|
116
|
+
this.buildType(type);
|
|
117
|
+
}
|
|
118
|
+
this._type = this._type || Object;
|
|
119
|
+
this.parent.children.set(this.propertyName, this);
|
|
120
|
+
if (isCollection(this._type)) {
|
|
121
|
+
this.collectionType = this._type;
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
delete this._type;
|
|
124
|
+
}
|
|
125
|
+
this._schema = JsonSchema.from({
|
|
126
|
+
type: this.collectionType || this.type
|
|
127
|
+
});
|
|
128
|
+
if (this.collectionType) {
|
|
129
|
+
this._schema.itemSchema(this.type);
|
|
130
|
+
}
|
|
131
|
+
this.parent.schema.addProperty(this.propertyName, this.schema);
|
|
132
|
+
}
|
|
92
133
|
};
|
|
93
134
|
JsonMethodStore = __decorate([
|
|
94
135
|
JsonEntityComponent(DecoratorTypes.METHOD),
|
|
95
136
|
__metadata("design:paramtypes", [Object])
|
|
96
137
|
], JsonMethodStore);
|
|
97
138
|
export { JsonMethodStore };
|
|
139
|
+
export const EndpointMetadata = JsonMethodStore;
|
|
98
140
|
//# sourceMappingURL=JsonMethodStore.js.map
|