@tsoa-next/runtime 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.MD +3 -0
  2. package/dist/config.d.ts +240 -0
  3. package/dist/config.js +3 -0
  4. package/dist/config.js.map +1 -0
  5. package/dist/decorators/customAttribute.d.ts +1 -0
  6. package/dist/decorators/customAttribute.js +9 -0
  7. package/dist/decorators/customAttribute.js.map +1 -0
  8. package/dist/decorators/deprecated.d.ts +4 -0
  9. package/dist/decorators/deprecated.js +12 -0
  10. package/dist/decorators/deprecated.js.map +1 -0
  11. package/dist/decorators/example.d.ts +1 -0
  12. package/dist/decorators/example.js +9 -0
  13. package/dist/decorators/example.js.map +1 -0
  14. package/dist/decorators/extension.d.ts +4 -0
  15. package/dist/decorators/extension.js +9 -0
  16. package/dist/decorators/extension.js.map +1 -0
  17. package/dist/decorators/methods.d.ts +7 -0
  18. package/dist/decorators/methods.js +45 -0
  19. package/dist/decorators/methods.js.map +1 -0
  20. package/dist/decorators/middlewares.d.ts +15 -0
  21. package/dist/decorators/middlewares.js +53 -0
  22. package/dist/decorators/middlewares.js.map +1 -0
  23. package/dist/decorators/operationid.d.ts +1 -0
  24. package/dist/decorators/operationid.js +9 -0
  25. package/dist/decorators/operationid.js.map +1 -0
  26. package/dist/decorators/parameter.d.ts +73 -0
  27. package/dist/decorators/parameter.js +141 -0
  28. package/dist/decorators/parameter.js.map +1 -0
  29. package/dist/decorators/response.d.ts +17 -0
  30. package/dist/decorators/response.js +38 -0
  31. package/dist/decorators/response.js.map +1 -0
  32. package/dist/decorators/route.d.ts +5 -0
  33. package/dist/decorators/route.js +18 -0
  34. package/dist/decorators/route.js.map +1 -0
  35. package/dist/decorators/security.d.ts +10 -0
  36. package/dist/decorators/security.js +21 -0
  37. package/dist/decorators/security.js.map +1 -0
  38. package/dist/decorators/tags.d.ts +1 -0
  39. package/dist/decorators/tags.js +9 -0
  40. package/dist/decorators/tags.js.map +1 -0
  41. package/dist/index.d.ts +24 -0
  42. package/dist/index.js +41 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/interfaces/controller.d.ts +16 -0
  45. package/dist/interfaces/controller.js +24 -0
  46. package/dist/interfaces/controller.js.map +1 -0
  47. package/dist/interfaces/file.d.ts +31 -0
  48. package/dist/interfaces/file.js +3 -0
  49. package/dist/interfaces/file.js.map +1 -0
  50. package/dist/interfaces/iocModule.d.ts +7 -0
  51. package/dist/interfaces/iocModule.js +3 -0
  52. package/dist/interfaces/iocModule.js.map +1 -0
  53. package/dist/interfaces/response.d.ts +5 -0
  54. package/dist/interfaces/response.js +3 -0
  55. package/dist/interfaces/response.js.map +1 -0
  56. package/dist/metadataGeneration/tsoa.d.ts +219 -0
  57. package/dist/metadataGeneration/tsoa.js +3 -0
  58. package/dist/metadataGeneration/tsoa.js.map +1 -0
  59. package/dist/routeGeneration/additionalProps.d.ts +6 -0
  60. package/dist/routeGeneration/additionalProps.js +3 -0
  61. package/dist/routeGeneration/additionalProps.js.map +1 -0
  62. package/dist/routeGeneration/templateHelpers.d.ts +203 -0
  63. package/dist/routeGeneration/templateHelpers.js +859 -0
  64. package/dist/routeGeneration/templateHelpers.js.map +1 -0
  65. package/dist/routeGeneration/templates/express/expressTemplateService.d.ts +29 -0
  66. package/dist/routeGeneration/templates/express/expressTemplateService.js +118 -0
  67. package/dist/routeGeneration/templates/express/expressTemplateService.js.map +1 -0
  68. package/dist/routeGeneration/templates/hapi/hapiTemplateService.d.ts +36 -0
  69. package/dist/routeGeneration/templates/hapi/hapiTemplateService.js +120 -0
  70. package/dist/routeGeneration/templates/hapi/hapiTemplateService.js.map +1 -0
  71. package/dist/routeGeneration/templates/index.d.ts +4 -0
  72. package/dist/routeGeneration/templates/index.js +21 -0
  73. package/dist/routeGeneration/templates/index.js.map +1 -0
  74. package/dist/routeGeneration/templates/koa/koaTemplateService.d.ts +29 -0
  75. package/dist/routeGeneration/templates/koa/koaTemplateService.js +116 -0
  76. package/dist/routeGeneration/templates/koa/koaTemplateService.js.map +1 -0
  77. package/dist/routeGeneration/templates/templateService.d.ts +15 -0
  78. package/dist/routeGeneration/templates/templateService.js +37 -0
  79. package/dist/routeGeneration/templates/templateService.js.map +1 -0
  80. package/dist/routeGeneration/tsoa-route.d.ts +56 -0
  81. package/dist/routeGeneration/tsoa-route.js +11 -0
  82. package/dist/routeGeneration/tsoa-route.js.map +1 -0
  83. package/dist/swagger/swagger.d.ts +550 -0
  84. package/dist/swagger/swagger.js +12 -0
  85. package/dist/swagger/swagger.js.map +1 -0
  86. package/dist/utils/assertNever.d.ts +4 -0
  87. package/dist/utils/assertNever.js +10 -0
  88. package/dist/utils/assertNever.js.map +1 -0
  89. package/dist/utils/isHeaderType.d.ts +5 -0
  90. package/dist/utils/isHeaderType.js +3 -0
  91. package/dist/utils/isHeaderType.js.map +1 -0
  92. package/package.json +64 -0
@@ -0,0 +1,219 @@
1
+ import { ExtensionType } from '../decorators/extension';
2
+ import type { Swagger } from '../swagger/swagger';
3
+ import { Validator } from '..';
4
+ export declare namespace Tsoa {
5
+ export interface Metadata {
6
+ controllers: Controller[];
7
+ referenceTypeMap: ReferenceTypeMap;
8
+ }
9
+ export interface Controller {
10
+ location: string;
11
+ methods: Method[];
12
+ name: string;
13
+ path: string;
14
+ produces?: string[];
15
+ }
16
+ export interface Method {
17
+ extensions: Extension[];
18
+ deprecated?: boolean;
19
+ description?: string;
20
+ method: 'get' | 'post' | 'put' | 'delete' | 'options' | 'head' | 'patch';
21
+ name: string;
22
+ parameters: Parameter[];
23
+ path: string;
24
+ produces?: string[];
25
+ consumes?: string;
26
+ type: Type;
27
+ tags?: string[];
28
+ responses: Response[];
29
+ successStatus?: number;
30
+ security: Security[];
31
+ summary?: string;
32
+ isHidden: boolean;
33
+ operationId?: string;
34
+ }
35
+ export interface Parameter {
36
+ parameterName: string;
37
+ example?: Array<{
38
+ [exampleName: string]: Swagger.Example3;
39
+ }>;
40
+ description?: string;
41
+ in: 'query' | 'queries' | 'header' | 'path' | 'formData' | 'body' | 'body-prop' | 'request' | 'request-prop' | 'res';
42
+ name: string;
43
+ required?: boolean;
44
+ type: Type;
45
+ default?: unknown;
46
+ validators: Validators;
47
+ deprecated: boolean;
48
+ exampleLabels?: Array<string | undefined>;
49
+ title?: string;
50
+ $ref?: Swagger.BaseSchema;
51
+ }
52
+ export interface ResParameter extends Response, Parameter {
53
+ in: 'res';
54
+ description: string;
55
+ }
56
+ export interface ArrayParameter extends Parameter {
57
+ type: ArrayType;
58
+ collectionFormat?: 'csv' | 'multi' | 'pipes' | 'ssv' | 'tsv';
59
+ }
60
+ type AllKeys<T> = T extends any ? keyof T : never;
61
+ export type ValidatorKey = AllKeys<Validator>;
62
+ export type SchemaValidatorKey = Exclude<ValidatorKey, `is${string}` | 'minDate' | 'maxDate'>;
63
+ export type Validators = Partial<Record<ValidatorKey, {
64
+ value?: unknown;
65
+ errorMsg?: string;
66
+ }>>;
67
+ export interface Security {
68
+ [key: string]: string[];
69
+ }
70
+ export interface Extension {
71
+ key: `x-${string}`;
72
+ value: ExtensionType | ExtensionType[];
73
+ }
74
+ export interface Response {
75
+ description: string;
76
+ name: string;
77
+ produces?: string[];
78
+ schema?: Type;
79
+ examples?: Array<{
80
+ [exampleName: string]: Swagger.Example3;
81
+ }>;
82
+ exampleLabels?: Array<string | undefined>;
83
+ headers?: HeaderType;
84
+ }
85
+ export interface Property {
86
+ default?: unknown;
87
+ description?: string;
88
+ format?: string;
89
+ example?: unknown;
90
+ name: string;
91
+ type: Type;
92
+ required: boolean;
93
+ validators: Validators;
94
+ deprecated: boolean;
95
+ extensions?: Extension[];
96
+ title?: string;
97
+ }
98
+ export type TypeStringLiteral = 'string' | 'boolean' | 'double' | 'float' | 'file' | 'integer' | 'long' | 'enum' | 'array' | 'datetime' | 'date' | 'binary' | 'buffer' | 'byte' | 'void' | 'object' | 'any' | 'refEnum' | 'refObject' | 'refAlias' | 'nestedObjectLiteral' | 'union' | 'intersection' | 'undefined' | 'tuple';
99
+ export type RefTypeLiteral = 'refObject' | 'refEnum' | 'refAlias';
100
+ export type PrimitiveTypeLiteral = Exclude<TypeStringLiteral, RefTypeLiteral | 'enum' | 'array' | 'void' | 'undefined' | 'nestedObjectLiteral' | 'union' | 'intersection' | 'tuple'>;
101
+ export interface TypeBase {
102
+ dataType: TypeStringLiteral;
103
+ }
104
+ export type PrimitiveType = StringType | BooleanType | DoubleType | FloatType | IntegerType | LongType | VoidType | UndefinedType;
105
+ /**
106
+ * This is one of the possible objects that tsoa creates that helps the code store information about the type it found in the code.
107
+ */
108
+ export type Type = PrimitiveType | ObjectsNoPropsType | EnumType | ArrayType | FileType | DateTimeType | DateType | BinaryType | BufferType | ByteType | AnyType | RefEnumType | RefObjectType | RefAliasType | NestedObjectLiteralType | UnionType | IntersectionType | TupleType;
109
+ export interface StringType extends TypeBase {
110
+ dataType: 'string';
111
+ }
112
+ export interface BooleanType extends TypeBase {
113
+ dataType: 'boolean';
114
+ }
115
+ /**
116
+ * This is the type that occurs when a developer writes `const foo: object = {}` since it can no longer have any properties added to it.
117
+ */
118
+ export interface ObjectsNoPropsType extends TypeBase {
119
+ dataType: 'object';
120
+ }
121
+ export interface DoubleType extends TypeBase {
122
+ dataType: 'double';
123
+ }
124
+ export interface FloatType extends TypeBase {
125
+ dataType: 'float';
126
+ }
127
+ export interface IntegerType extends TypeBase {
128
+ dataType: 'integer';
129
+ }
130
+ export interface LongType extends TypeBase {
131
+ dataType: 'long';
132
+ }
133
+ /**
134
+ * Not to be confused with `RefEnumType` which is a reusable enum which has a $ref name generated for it. This however, is an inline enum.
135
+ */
136
+ export interface EnumType extends TypeBase {
137
+ dataType: 'enum';
138
+ enums: Array<string | number | boolean | null>;
139
+ }
140
+ export interface ArrayType extends TypeBase {
141
+ dataType: 'array';
142
+ elementType: Type;
143
+ }
144
+ export interface DateType extends TypeBase {
145
+ dataType: 'date';
146
+ }
147
+ export interface FileType extends TypeBase {
148
+ dataType: 'file';
149
+ }
150
+ export interface DateTimeType extends TypeBase {
151
+ dataType: 'datetime';
152
+ }
153
+ export interface BinaryType extends TypeBase {
154
+ dataType: 'binary';
155
+ }
156
+ export interface BufferType extends TypeBase {
157
+ dataType: 'buffer';
158
+ }
159
+ export interface ByteType extends TypeBase {
160
+ dataType: 'byte';
161
+ }
162
+ export interface VoidType extends TypeBase {
163
+ dataType: 'void';
164
+ }
165
+ export interface UndefinedType extends TypeBase {
166
+ dataType: 'undefined';
167
+ }
168
+ export interface AnyType extends TypeBase {
169
+ dataType: 'any';
170
+ }
171
+ export interface NestedObjectLiteralType extends TypeBase {
172
+ dataType: 'nestedObjectLiteral';
173
+ properties: Property[];
174
+ additionalProperties?: Type;
175
+ }
176
+ export interface RefEnumType extends ReferenceTypeBase {
177
+ dataType: 'refEnum';
178
+ enums: Array<string | number>;
179
+ enumVarnames?: string[];
180
+ }
181
+ export interface RefObjectType extends ReferenceTypeBase {
182
+ dataType: 'refObject';
183
+ properties: Property[];
184
+ additionalProperties?: Type;
185
+ }
186
+ export interface RefAliasType extends Omit<Property, 'name' | 'required'>, ReferenceTypeBase {
187
+ dataType: 'refAlias';
188
+ }
189
+ export type ReferenceType = RefEnumType | RefObjectType | RefAliasType;
190
+ export interface ReferenceTypeBase extends TypeBase {
191
+ description?: string;
192
+ dataType: RefTypeLiteral;
193
+ refName: string;
194
+ example?: unknown;
195
+ deprecated: boolean;
196
+ title?: string;
197
+ }
198
+ export interface UnionType extends TypeBase {
199
+ dataType: 'union';
200
+ types: Type[];
201
+ }
202
+ export interface IntersectionType extends TypeBase {
203
+ dataType: 'intersection';
204
+ types: Type[];
205
+ }
206
+ export interface TupleType extends TypeBase {
207
+ dataType: 'tuple';
208
+ types: Type[];
209
+ restType?: Type;
210
+ }
211
+ export interface ReferenceTypeMap {
212
+ [refName: string]: Tsoa.ReferenceType;
213
+ }
214
+ export interface MethodsSignatureMap {
215
+ [signature: string]: string[];
216
+ }
217
+ export type HeaderType = Tsoa.NestedObjectLiteralType | Tsoa.RefObjectType;
218
+ export {};
219
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=tsoa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsoa.js","sourceRoot":"","sources":["../../src/metadataGeneration/tsoa.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { Config, RoutesConfig } from '../config';
2
+ export interface AdditionalProps {
3
+ noImplicitAdditionalProperties: Exclude<Config['noImplicitAdditionalProperties'], undefined>;
4
+ bodyCoercion: Exclude<RoutesConfig['bodyCoercion'], undefined>;
5
+ maxValidationErrorSize?: number;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=additionalProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"additionalProps.js","sourceRoot":"","sources":["../../src/routeGeneration/additionalProps.ts"],"names":[],"mappings":""}
@@ -0,0 +1,203 @@
1
+ import { AdditionalProps } from './additionalProps';
2
+ import { TsoaRoute } from './tsoa-route';
3
+ export declare function ValidateParam(property: TsoaRoute.PropertySchema, value: any, generatedModels: TsoaRoute.Models, name: string | undefined, fieldErrors: FieldErrors, isBodyParam: boolean, parent: string | undefined, config: AdditionalProps): any;
4
+ export declare class ValidationService {
5
+ private readonly models;
6
+ private readonly config;
7
+ private validationStack;
8
+ constructor(models: TsoaRoute.Models, config: AdditionalProps);
9
+ ValidateParam(property: TsoaRoute.PropertySchema, rawValue: any, name: string | undefined, fieldErrors: FieldErrors, isBodyParam: boolean, parent?: string): any;
10
+ hasCorrectJsType(value: any, type: 'object' | 'boolean' | 'number' | 'string', isBodyParam: boolean): boolean;
11
+ validateNestedObjectLiteral(name: string, value: any, fieldErrors: FieldErrors, isBodyParam: boolean, nestedProperties: {
12
+ [name: string]: TsoaRoute.PropertySchema;
13
+ } | undefined, additionalProperties: TsoaRoute.PropertySchema | boolean | undefined, parent: string): any;
14
+ validateInt(name: string, value: any, fieldErrors: FieldErrors, isBodyParam: boolean, validators?: IntegerValidator, parent?: string): number | undefined;
15
+ validateFloat(name: string, value: any, fieldErrors: FieldErrors, isBodyParam: boolean, validators?: FloatValidator, parent?: string): number | undefined;
16
+ validateEnum(name: string, value: unknown, fieldErrors: FieldErrors, members?: Array<string | number | boolean | null>, parent?: string): unknown;
17
+ validateDate(name: string, value: any, fieldErrors: FieldErrors, isBodyParam: boolean, validators?: DateValidator, parent?: string): Date | undefined;
18
+ validateDateTime(name: string, value: any, fieldErrors: FieldErrors, isBodyParam: boolean, validators?: DateTimeValidator, parent?: string): Date | undefined;
19
+ validateString(name: string, value: any, fieldErrors: FieldErrors, validators?: StringValidator, parent?: string): string | undefined;
20
+ validateBool(name: string, value: any, fieldErrors: FieldErrors, isBodyParam: boolean, validators?: BooleanValidator, parent?: string): any;
21
+ validateUndefined(name: string, value: any, fieldErrors: FieldErrors, parent?: string): undefined;
22
+ validateArray(name: string, value: any[], fieldErrors: FieldErrors, isBodyParam: boolean, schema?: TsoaRoute.PropertySchema, validators?: ArrayValidator, parent?: string): any[] | undefined;
23
+ validateBuffer(_name: string, value: string): Buffer<ArrayBuffer>;
24
+ validateUnion(name: string, value: any, fieldErrors: FieldErrors, isBodyParam: boolean, property: TsoaRoute.PropertySchema, parent?: string): any;
25
+ validateIntersection(name: string, value: any, fieldErrors: FieldErrors, isBodyParam: boolean, subSchemas: TsoaRoute.PropertySchema[] | undefined, parent?: string): any;
26
+ private toModelLike;
27
+ /**
28
+ * combine all schemas once, ignoring order ie
29
+ * input: [[value1], [value2]] should be [[value1, value2]]
30
+ * not [[value1, value2],[value2, value1]]
31
+ * and
32
+ * input: [[value1, value2], [value3, value4], [value5, value6]] should be [
33
+ * [value1, value3, value5],
34
+ * [value1, value3, value6],
35
+ * [value1, value4, value5],
36
+ * [value1, value4, value6],
37
+ * [value2, value3, value5],
38
+ * [value2, value3, value6],
39
+ * [value2, value4, value5],
40
+ * [value2, value4, value6],
41
+ * ]
42
+ * @param modelSchemass
43
+ */
44
+ private selfIntersectionCombinations;
45
+ private getAllCombinations;
46
+ private combineProperties;
47
+ private getExcessPropertiesFor;
48
+ validateModel(input: {
49
+ name: string;
50
+ value: any;
51
+ modelDefinition: TsoaRoute.ModelSchema;
52
+ fieldErrors: FieldErrors;
53
+ isBodyParam: boolean;
54
+ parent?: string;
55
+ }): any;
56
+ /**
57
+ * Creates a new ValidationService instance with specific configuration
58
+ * @param overrides Configuration overrides
59
+ * @returns New ValidationService instance
60
+ */
61
+ private createChildValidationService;
62
+ /**
63
+ * Deep clones an object without using JSON.stringify/parse to avoid:
64
+ * 1. Loss of undefined values
65
+ * 2. Loss of functions
66
+ * 3. Conversion of dates to strings
67
+ * 4. Exponential escaping issues with nested objects
68
+ */
69
+ private deepClone;
70
+ /**
71
+ * Adds a summarized error to the fieldErrors object
72
+ * @param fieldErrors The errors object to add to
73
+ * @param errorKey The key for the error
74
+ * @param prefix The error message prefix
75
+ * @param subErrors Array of sub-errors to summarize
76
+ * @param value The value that failed validation
77
+ */
78
+ private addSummarizedError;
79
+ /**
80
+ * Summarizes validation errors to prevent extremely large error messages
81
+ * @param errors Array of field errors from union/intersection validation
82
+ * @param maxLength Maximum length of the summarized message
83
+ * @returns Summarized error message
84
+ */
85
+ private summarizeValidationErrors;
86
+ }
87
+ export interface IntegerValidator {
88
+ isInt?: {
89
+ errorMsg?: string;
90
+ };
91
+ isLong?: {
92
+ errorMsg?: string;
93
+ };
94
+ minimum?: {
95
+ value: number;
96
+ errorMsg?: string;
97
+ };
98
+ maximum?: {
99
+ value: number;
100
+ errorMsg?: string;
101
+ };
102
+ }
103
+ export interface FloatValidator {
104
+ isFloat?: {
105
+ errorMsg?: string;
106
+ };
107
+ isDouble?: {
108
+ errorMsg?: string;
109
+ };
110
+ minimum?: {
111
+ value: number;
112
+ errorMsg?: string;
113
+ };
114
+ maximum?: {
115
+ value: number;
116
+ errorMsg?: string;
117
+ };
118
+ }
119
+ export interface DateValidator {
120
+ isDate?: {
121
+ errorMsg?: string;
122
+ };
123
+ minDate?: {
124
+ value: string;
125
+ errorMsg?: string;
126
+ };
127
+ maxDate?: {
128
+ value: string;
129
+ errorMsg?: string;
130
+ };
131
+ }
132
+ export interface DateTimeValidator {
133
+ isDateTime?: {
134
+ errorMsg?: string;
135
+ };
136
+ minDate?: {
137
+ value: string;
138
+ errorMsg?: string;
139
+ };
140
+ maxDate?: {
141
+ value: string;
142
+ errorMsg?: string;
143
+ };
144
+ }
145
+ export interface StringValidator {
146
+ isString?: {
147
+ errorMsg?: string;
148
+ };
149
+ minLength?: {
150
+ value: number;
151
+ errorMsg?: string;
152
+ };
153
+ maxLength?: {
154
+ value: number;
155
+ errorMsg?: string;
156
+ };
157
+ pattern?: {
158
+ value: string;
159
+ errorMsg?: string;
160
+ };
161
+ title?: {
162
+ value: string;
163
+ errorMsg?: string;
164
+ };
165
+ }
166
+ export interface BooleanValidator {
167
+ isBoolean?: {
168
+ errorMsg?: string;
169
+ };
170
+ }
171
+ export interface ArrayValidator {
172
+ isArray?: {
173
+ errorMsg?: string;
174
+ };
175
+ minItems?: {
176
+ value: number;
177
+ errorMsg?: string;
178
+ };
179
+ maxItems?: {
180
+ value: number;
181
+ errorMsg?: string;
182
+ };
183
+ uniqueItems?: {
184
+ errorMsg?: string;
185
+ };
186
+ }
187
+ export type Validator = IntegerValidator | FloatValidator | DateValidator | DateTimeValidator | StringValidator | BooleanValidator | ArrayValidator;
188
+ export interface FieldErrors {
189
+ [name: string]: {
190
+ message: string;
191
+ value?: any;
192
+ };
193
+ }
194
+ export interface Exception extends Error {
195
+ status: number;
196
+ }
197
+ export declare class ValidateError extends Error implements Exception {
198
+ fields: FieldErrors;
199
+ message: string;
200
+ status: number;
201
+ name: string;
202
+ constructor(fields: FieldErrors, message: string);
203
+ }