@tsed/schema 6.92.1 → 6.95.1

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.
Files changed (131) hide show
  1. package/.mocharc.js +5 -0
  2. package/.nycrc +27 -0
  3. package/lib/cjs/components/anyMapper.js +0 -1
  4. package/lib/cjs/components/anyMapper.js.map +1 -1
  5. package/lib/cjs/components/classMapper.d.ts +1 -1
  6. package/lib/cjs/components/classMapper.js +1 -1
  7. package/lib/cjs/components/classMapper.js.map +1 -1
  8. package/lib/cjs/components/index.d.ts +2 -0
  9. package/lib/cjs/components/index.js +2 -0
  10. package/lib/cjs/components/index.js.map +1 -1
  11. package/lib/cjs/components/inheritedClassMapper.d.ts +1 -1
  12. package/lib/cjs/components/inheritedClassMapper.js +1 -1
  13. package/lib/cjs/components/inheritedClassMapper.js.map +1 -1
  14. package/lib/cjs/components/mapMapper.d.ts +1 -1
  15. package/lib/cjs/components/mapMapper.js +1 -1
  16. package/lib/cjs/components/mapMapper.js.map +1 -1
  17. package/lib/cjs/components/objectMapper.js +4 -1
  18. package/lib/cjs/components/objectMapper.js.map +1 -1
  19. package/lib/cjs/components/ofMapper.d.ts +3 -0
  20. package/lib/cjs/components/ofMapper.js +17 -0
  21. package/lib/cjs/components/ofMapper.js.map +1 -0
  22. package/lib/cjs/components/propertiesMapper.d.ts +3 -0
  23. package/lib/cjs/components/propertiesMapper.js +25 -0
  24. package/lib/cjs/components/propertiesMapper.js.map +1 -0
  25. package/lib/cjs/components/schemaMapper.d.ts +1 -1
  26. package/lib/cjs/components/schemaMapper.js +31 -34
  27. package/lib/cjs/components/schemaMapper.js.map +1 -1
  28. package/lib/cjs/decorators/common/oneOf.js +1 -0
  29. package/lib/cjs/decorators/common/oneOf.js.map +1 -1
  30. package/lib/cjs/decorators/common/requiredGroups.d.ts +1 -1
  31. package/lib/cjs/decorators/common/requiredGroups.js +6 -9
  32. package/lib/cjs/decorators/common/requiredGroups.js.map +1 -1
  33. package/lib/cjs/decorators/index.d.ts +1 -0
  34. package/lib/cjs/decorators/index.js +1 -0
  35. package/lib/cjs/decorators/index.js.map +1 -1
  36. package/lib/cjs/decorators/operations/inFile.d.ts +25 -0
  37. package/lib/cjs/decorators/operations/inFile.js +45 -0
  38. package/lib/cjs/decorators/operations/inFile.js.map +1 -0
  39. package/lib/cjs/decorators/operations/returns.d.ts +16 -1
  40. package/lib/cjs/decorators/operations/returns.js +38 -1
  41. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  42. package/lib/cjs/decorators/operations/route.d.ts +3 -0
  43. package/lib/cjs/decorators/operations/route.js +10 -8
  44. package/lib/cjs/decorators/operations/route.js.map +1 -1
  45. package/lib/cjs/domain/JsonEntityStore.d.ts +3 -0
  46. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  47. package/lib/cjs/domain/JsonMethodStore.d.ts +22 -1
  48. package/lib/cjs/domain/JsonMethodStore.js +42 -5
  49. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  50. package/lib/cjs/hooks/alterOneOf.d.ts +3 -0
  51. package/lib/cjs/hooks/alterOneOf.js +14 -0
  52. package/lib/cjs/hooks/alterOneOf.js.map +1 -0
  53. package/lib/cjs/index.d.ts +1 -0
  54. package/lib/cjs/index.js +1 -0
  55. package/lib/cjs/index.js.map +1 -1
  56. package/lib/cjs/registries/JsonSchemaMapperContainer.d.ts +3 -2
  57. package/lib/cjs/registries/JsonSchemaMapperContainer.js +7 -3
  58. package/lib/cjs/registries/JsonSchemaMapperContainer.js.map +1 -1
  59. package/lib/cjs/utils/getJsonEntityStore.d.ts +0 -4
  60. package/lib/cjs/utils/getJsonEntityStore.js +1 -8
  61. package/lib/cjs/utils/getJsonEntityStore.js.map +1 -1
  62. package/lib/cjs/utils/getRequiredProperties.js +1 -2
  63. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  64. package/lib/cjs/utils/mapRouteOptions.d.ts +1 -1
  65. package/lib/cjs/utils/mapRouteOptions.js +1 -1
  66. package/lib/cjs/utils/mapRouteOptions.js.map +1 -1
  67. package/lib/esm/components/anyMapper.js +0 -1
  68. package/lib/esm/components/anyMapper.js.map +1 -1
  69. package/lib/esm/components/classMapper.js +1 -1
  70. package/lib/esm/components/classMapper.js.map +1 -1
  71. package/lib/esm/components/index.js +2 -0
  72. package/lib/esm/components/index.js.map +1 -1
  73. package/lib/esm/components/inheritedClassMapper.js +1 -1
  74. package/lib/esm/components/inheritedClassMapper.js.map +1 -1
  75. package/lib/esm/components/mapMapper.js +1 -1
  76. package/lib/esm/components/mapMapper.js.map +1 -1
  77. package/lib/esm/components/objectMapper.js +4 -1
  78. package/lib/esm/components/objectMapper.js.map +1 -1
  79. package/lib/esm/components/ofMapper.js +13 -0
  80. package/lib/esm/components/ofMapper.js.map +1 -0
  81. package/lib/esm/components/propertiesMapper.js +21 -0
  82. package/lib/esm/components/propertiesMapper.js.map +1 -0
  83. package/lib/esm/components/schemaMapper.js +32 -35
  84. package/lib/esm/components/schemaMapper.js.map +1 -1
  85. package/lib/esm/decorators/common/oneOf.js +1 -0
  86. package/lib/esm/decorators/common/oneOf.js.map +1 -1
  87. package/lib/esm/decorators/common/requiredGroups.js +6 -9
  88. package/lib/esm/decorators/common/requiredGroups.js.map +1 -1
  89. package/lib/esm/decorators/index.js +1 -0
  90. package/lib/esm/decorators/index.js.map +1 -1
  91. package/lib/esm/decorators/operations/inFile.js +41 -0
  92. package/lib/esm/decorators/operations/inFile.js.map +1 -0
  93. package/lib/esm/decorators/operations/returns.js +39 -2
  94. package/lib/esm/decorators/operations/returns.js.map +1 -1
  95. package/lib/esm/decorators/operations/route.js +10 -8
  96. package/lib/esm/decorators/operations/route.js.map +1 -1
  97. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  98. package/lib/esm/domain/JsonMethodStore.js +44 -7
  99. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  100. package/lib/esm/hooks/alterOneOf.js +10 -0
  101. package/lib/esm/hooks/alterOneOf.js.map +1 -0
  102. package/lib/esm/index.js +1 -0
  103. package/lib/esm/index.js.map +1 -1
  104. package/lib/esm/registries/JsonSchemaMapperContainer.js +5 -2
  105. package/lib/esm/registries/JsonSchemaMapperContainer.js.map +1 -1
  106. package/lib/esm/utils/getJsonEntityStore.js +0 -6
  107. package/lib/esm/utils/getJsonEntityStore.js.map +1 -1
  108. package/lib/esm/utils/getRequiredProperties.js +1 -2
  109. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  110. package/lib/esm/utils/mapRouteOptions.js +1 -1
  111. package/lib/esm/utils/mapRouteOptions.js.map +1 -1
  112. package/lib/types/components/classMapper.d.ts +1 -1
  113. package/lib/types/components/index.d.ts +2 -0
  114. package/lib/types/components/inheritedClassMapper.d.ts +1 -1
  115. package/lib/types/components/mapMapper.d.ts +1 -1
  116. package/lib/types/components/ofMapper.d.ts +3 -0
  117. package/lib/types/components/propertiesMapper.d.ts +3 -0
  118. package/lib/types/components/schemaMapper.d.ts +1 -1
  119. package/lib/types/decorators/common/requiredGroups.d.ts +1 -1
  120. package/lib/types/decorators/index.d.ts +1 -0
  121. package/lib/types/decorators/operations/inFile.d.ts +25 -0
  122. package/lib/types/decorators/operations/returns.d.ts +16 -1
  123. package/lib/types/decorators/operations/route.d.ts +3 -0
  124. package/lib/types/domain/JsonEntityStore.d.ts +3 -0
  125. package/lib/types/domain/JsonMethodStore.d.ts +22 -1
  126. package/lib/types/hooks/alterOneOf.d.ts +3 -0
  127. package/lib/types/index.d.ts +1 -0
  128. package/lib/types/registries/JsonSchemaMapperContainer.d.ts +3 -2
  129. package/lib/types/utils/getJsonEntityStore.d.ts +0 -4
  130. package/lib/types/utils/mapRouteOptions.d.ts +1 -1
  131. package/package.json +7 -6
@@ -1,3 +1,3 @@
1
1
  import { JsonSchema } from "../domain/JsonSchema";
2
2
  import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
3
- export declare function classMapper(value: JsonSchema, options?: JsonSchemaOptions): any;
3
+ export declare function classMapper(value: JsonSchema, options: JsonSchemaOptions): any;
@@ -7,3 +7,5 @@ export * from "./lazyRefMapper";
7
7
  export * from "./mapMapper";
8
8
  export * from "./objectMapper";
9
9
  export * from "./schemaMapper";
10
+ export * from "./ofMapper";
11
+ export * from "./propertiesMapper";
@@ -2,4 +2,4 @@ import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
2
2
  /**
3
3
  * @ignore
4
4
  */
5
- export declare function inheritedClassMapper(obj: any, { target, ...options }?: JsonSchemaOptions): any;
5
+ export declare function inheritedClassMapper(obj: any, { target, ...options }: JsonSchemaOptions): any;
@@ -6,4 +6,4 @@ import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
6
6
  * @param options
7
7
  * @ignore
8
8
  */
9
- export declare function mapMapper(input: Map<string, any>, { ignore, ...options }?: JsonSchemaOptions): any;
9
+ export declare function mapMapper(input: Map<string, any>, { ignore, ...options }: JsonSchemaOptions): any;
@@ -0,0 +1,3 @@
1
+ import type { JsonSchema } from "../domain/JsonSchema";
2
+ import type { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
3
+ export declare function ofMapper(input: (any | JsonSchema)[], options: JsonSchemaOptions, parent: JsonSchema): any[];
@@ -0,0 +1,3 @@
1
+ import type { JsonSchema } from "../domain/JsonSchema";
2
+ import type { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
3
+ export declare function propertiesMapper(input: any | JsonSchema, options: JsonSchemaOptions, parent: JsonSchema): any;
@@ -1,3 +1,3 @@
1
1
  import { JsonSchema } from "../domain/JsonSchema";
2
2
  import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
3
- export declare function schemaMapper(schema: JsonSchema, options?: JsonSchemaOptions): any;
3
+ export declare function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any;
@@ -7,4 +7,4 @@
7
7
  * @schema
8
8
  * @input
9
9
  */
10
- export declare function RequiredGroups(...groups: string[]): Function;
10
+ export declare function RequiredGroups(...groups: string[]): PropertyDecorator;
@@ -12,6 +12,7 @@ export * from "./operations/deprecated";
12
12
  export * from "./operations/consumes";
13
13
  export * from "./operations/contentType";
14
14
  export * from "./operations/in";
15
+ export * from "./operations/inFile";
15
16
  export * from "./operations/operationId";
16
17
  export * from "./operations/operationPath";
17
18
  export * from "./operations/path";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Add a input file parameter.
3
+ *
4
+ * ::: warning
5
+ * Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.
6
+ * But you can use this decorator on Method, to add extra in parameters like Authorization header.
7
+ *
8
+ * ```typescript
9
+ * @Controller("/")
10
+ * class MyController {
11
+ * @Post("/")
12
+ * method(@InFile("file1") file: any) {
13
+ * }
14
+ * }
15
+ * ```
16
+ * :::
17
+ *
18
+ * @decorator
19
+ * @swagger
20
+ * @schema
21
+ * @input
22
+ * @operation
23
+ * @param name
24
+ */
25
+ export declare function InFile(name: string): ParameterDecorator;
@@ -40,6 +40,21 @@ export interface ReturnsChainedDecorators {
40
40
  * @param types
41
41
  */
42
42
  Of(...types: GenericValue[]): this;
43
+ /**
44
+ * Add the nested types
45
+ * @param types
46
+ */
47
+ OneOf(...types: GenericValue[]): this;
48
+ /**
49
+ * Add the nested types
50
+ * @param types
51
+ */
52
+ AllOf(...types: GenericValue[]): this;
53
+ /**
54
+ * Add the nested types
55
+ * @param types
56
+ */
57
+ AnyOf(...types: GenericValue[]): this;
43
58
  /**
44
59
  * Declare a nested generic models
45
60
  * @param generics
@@ -235,4 +250,4 @@ export interface ReturnsChainedDecorators {
235
250
  * @response
236
251
  * @operation
237
252
  */
238
- export declare function Returns(status?: string | number, model?: Type<any>): ReturnsChainedDecorators;
253
+ export declare function Returns(status?: string | number, model?: Type<any> | Type<any>[]): ReturnsChainedDecorators;
@@ -32,6 +32,9 @@ export interface RouteChainedDecorators {
32
32
  * @param Summary
33
33
  */
34
34
  Summary(Summary: string): this;
35
+ Use(...args: any[]): this;
36
+ UseAfter(...args: any[]): this;
37
+ UseBefore(...args: any[]): this;
35
38
  }
36
39
  /**
37
40
  * Describe a new route with a method and path.
@@ -16,6 +16,9 @@ export interface JsonEntityStoreOptions {
16
16
  descriptor?: any;
17
17
  type?: Type<any>;
18
18
  collectionType?: Type<any>;
19
+ beforeMiddlewares?: Function[];
20
+ middlewares?: Function[];
21
+ afterMiddlewares?: Function[];
19
22
  [key: string]: any;
20
23
  }
21
24
  export declare abstract class JsonEntityStore implements JsonEntityStoreOptions {
@@ -1,9 +1,13 @@
1
- import { JsonEntityStore } from "./JsonEntityStore";
1
+ import { JsonEntityStore, JsonEntityStoreOptions } from "./JsonEntityStore";
2
2
  import { JsonOperation } from "./JsonOperation";
3
3
  import type { JsonParameterStore } from "./JsonParameterStore";
4
4
  import type { JsonClassStore } from "./JsonClassStore";
5
5
  export declare class JsonMethodStore extends JsonEntityStore {
6
6
  readonly parent: JsonClassStore;
7
+ middlewares: any[];
8
+ beforeMiddlewares: any[];
9
+ afterMiddlewares: any[];
10
+ constructor(options: JsonEntityStoreOptions);
7
11
  /**
8
12
  * Ref to JsonOperation when the decorated object is a method.
9
13
  */
@@ -16,4 +20,21 @@ export declare class JsonMethodStore extends JsonEntityStore {
16
20
  get operationPaths(): Map<string, import("./JsonOperation").JsonMethodPath>;
17
21
  getResponseOptions(status: number, contentType?: string): undefined | any;
18
22
  protected build(): void;
23
+ /**
24
+ * Append middlewares to the beforeMiddlewares list.
25
+ * @param args
26
+ * @returns {EndpointMetadata}
27
+ */
28
+ before(args: Function[]): this;
29
+ /**
30
+ * Append middlewares to the afterMiddlewares list.
31
+ * @param args
32
+ * @returns {EndpointMetadata}
33
+ */
34
+ after(args: Function[]): this;
35
+ /**
36
+ * Store all arguments collected via Annotation.
37
+ * @param args
38
+ */
39
+ use(args: Function[]): this;
19
40
  }
@@ -0,0 +1,3 @@
1
+ import type { JsonSchema } from "../domain/JsonSchema";
2
+ import type { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
3
+ export declare function alterOneOf(obj: any, schema: JsonSchema, options: JsonSchemaOptions): any;
@@ -9,6 +9,7 @@ export * from "./utils/getSpec";
9
9
  export * from "./utils/mergeSpec";
10
10
  export * from "./utils/generics";
11
11
  export * from "./utils/mapHeaders";
12
+ export * from "./utils/matchGroups";
12
13
  export * from "./utils/isSuccessStatus";
13
14
  export * from "./utils/from";
14
15
  export * from "./utils/concatPath";
@@ -2,7 +2,7 @@
2
2
  * @ignore
3
3
  */
4
4
  export interface JsonSchemaMapper {
5
- (schema: any, options: any): any;
5
+ (schema: any, options: any, parent?: any): any;
6
6
  }
7
7
  /**
8
8
  * @ignore
@@ -15,4 +15,5 @@ export declare function getJsonSchemaMapper(type: string): JsonSchemaMapper;
15
15
  /**
16
16
  * @ignore
17
17
  */
18
- export declare function execMapper(type: string, schema: any, options: any): any;
18
+ export declare function execMapper(type: string, schema: any, options: any, parent?: any): any;
19
+ export declare function hasMapper(type: string): boolean;
@@ -4,10 +4,6 @@ import { JsonClassStore } from "../domain/JsonClassStore";
4
4
  import { JsonPropertyStore } from "../domain/JsonPropertyStore";
5
5
  import { JsonParameterStore } from "../domain/JsonParameterStore";
6
6
  import { JsonMethodStore } from "../domain/JsonMethodStore";
7
- /**
8
- * @ignore
9
- */
10
- export declare function isJsonEntityStore(model: any): model is JsonEntityStore;
11
7
  /**
12
8
  * Get entity store from decorator args
13
9
  * @param target
@@ -1,5 +1,5 @@
1
1
  export declare function mapRouteOptions(args: any[]): {
2
2
  path: undefined;
3
3
  method: undefined;
4
- handlers: any[];
4
+ use: any[];
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/schema",
3
- "version": "6.92.1",
3
+ "version": "6.95.1",
4
4
  "description": "JsonSchema module for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -15,7 +15,8 @@
15
15
  "scripts": {
16
16
  "build": "yarn run build:esm && yarn run build:cjs",
17
17
  "build:cjs": "tsc --build tsconfig.compile.json",
18
- "build:esm": "tsc --build tsconfig.compile.esm.json"
18
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
19
+ "test": "cross-env NODE_ENV=test nyc mocha"
19
20
  },
20
21
  "keywords": [
21
22
  "TypeScript",
@@ -28,8 +29,8 @@
28
29
  "tsed"
29
30
  ],
30
31
  "dependencies": {
31
- "@tsed/core": "6.92.1",
32
- "@tsed/openspec": "6.92.1",
32
+ "@tsed/core": "6.95.1",
33
+ "@tsed/openspec": "6.95.1",
33
34
  "camel-case": "4.1.2",
34
35
  "json-schema": "0.4.0",
35
36
  "micromatch": "4.0.2",
@@ -44,8 +45,8 @@
44
45
  "fs-extra": "9.0.1"
45
46
  },
46
47
  "peerDependencies": {
47
- "@tsed/core": "^6.92.1",
48
- "@tsed/openspec": "^6.92.1"
48
+ "@tsed/core": "^6.95.1",
49
+ "@tsed/openspec": "^6.95.1"
49
50
  },
50
51
  "repository": "https://github.com/tsedio/tsed",
51
52
  "bugs": {