@nestia/core 10.0.2 → 11.0.0-dev.20260305

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 (155) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +93 -93
  3. package/lib/adaptors/WebSocketAdaptor.js.map +1 -1
  4. package/lib/decorators/DynamicModule.js +54 -10
  5. package/lib/decorators/DynamicModule.js.map +1 -1
  6. package/lib/decorators/EncryptedBody.js +2 -2
  7. package/lib/decorators/EncryptedBody.js.map +1 -1
  8. package/lib/decorators/EncryptedController.d.ts +1 -1
  9. package/lib/decorators/EncryptedModule.d.ts +1 -1
  10. package/lib/decorators/EncryptedModule.js +54 -10
  11. package/lib/decorators/EncryptedModule.js.map +1 -1
  12. package/lib/decorators/EncryptedRoute.js +2 -2
  13. package/lib/decorators/EncryptedRoute.js.map +1 -1
  14. package/lib/decorators/HumanRoute.d.ts +1 -2
  15. package/lib/decorators/HumanRoute.js +1 -2
  16. package/lib/decorators/HumanRoute.js.map +1 -1
  17. package/lib/decorators/NoTransformConfigurationError.js +1 -1
  18. package/lib/decorators/NoTransformConfigurationError.js.map +1 -1
  19. package/lib/decorators/SwaggerCustomizer.d.ts +1 -1
  20. package/lib/decorators/TypedFormData.js.map +1 -1
  21. package/lib/decorators/TypedParam.js +1 -1
  22. package/lib/decorators/TypedParam.js.map +1 -1
  23. package/lib/decorators/internal/get_path_and_querify.js +1 -1
  24. package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
  25. package/lib/decorators/internal/get_path_and_stringify.js +1 -1
  26. package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
  27. package/lib/decorators/internal/headers_to_object.js.map +1 -1
  28. package/lib/decorators/internal/validate_request_body.js +1 -1
  29. package/lib/decorators/internal/validate_request_body.js.map +1 -1
  30. package/lib/decorators/internal/validate_request_form_data.js +1 -1
  31. package/lib/decorators/internal/validate_request_form_data.js.map +1 -1
  32. package/lib/decorators/internal/validate_request_headers.js +1 -1
  33. package/lib/decorators/internal/validate_request_headers.js.map +1 -1
  34. package/lib/decorators/internal/validate_request_query.js +1 -1
  35. package/lib/decorators/internal/validate_request_query.js.map +1 -1
  36. package/lib/module.d.ts +1 -0
  37. package/lib/module.js +1 -0
  38. package/lib/module.js.map +1 -1
  39. package/lib/options/INestiaTransformProject.d.ts +1 -1
  40. package/lib/programmers/PlainBodyProgrammer.js +5 -8
  41. package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
  42. package/lib/programmers/TypedBodyProgrammer.js +13 -21
  43. package/lib/programmers/TypedBodyProgrammer.js.map +1 -1
  44. package/lib/programmers/TypedFormDataBodyProgrammer.js +11 -20
  45. package/lib/programmers/TypedFormDataBodyProgrammer.js.map +1 -1
  46. package/lib/programmers/TypedHeadersProgrammer.js +4 -6
  47. package/lib/programmers/TypedHeadersProgrammer.js.map +1 -1
  48. package/lib/programmers/TypedParamProgrammer.js +2 -2
  49. package/lib/programmers/TypedParamProgrammer.js.map +1 -1
  50. package/lib/programmers/TypedQueryBodyProgrammer.js +9 -16
  51. package/lib/programmers/TypedQueryBodyProgrammer.js.map +1 -1
  52. package/lib/programmers/TypedQueryProgrammer.js +9 -16
  53. package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
  54. package/lib/programmers/TypedQueryRouteProgrammer.js +6 -10
  55. package/lib/programmers/TypedQueryRouteProgrammer.js.map +1 -1
  56. package/lib/programmers/TypedRouteProgrammer.js +8 -13
  57. package/lib/programmers/TypedRouteProgrammer.js.map +1 -1
  58. package/lib/programmers/http/HttpAssertQuerifyProgrammer.d.ts +1 -1
  59. package/lib/programmers/http/HttpAssertQuerifyProgrammer.js +5 -7
  60. package/lib/programmers/http/HttpAssertQuerifyProgrammer.js.map +1 -1
  61. package/lib/programmers/http/HttpIsQuerifyProgrammer.d.ts +1 -1
  62. package/lib/programmers/http/HttpIsQuerifyProgrammer.js +5 -7
  63. package/lib/programmers/http/HttpIsQuerifyProgrammer.js.map +1 -1
  64. package/lib/programmers/http/HttpQuerifyProgrammer.d.ts +1 -1
  65. package/lib/programmers/http/HttpQuerifyProgrammer.js +13 -19
  66. package/lib/programmers/http/HttpQuerifyProgrammer.js.map +1 -1
  67. package/lib/programmers/http/HttpValidateQuerifyProgrammer.d.ts +1 -1
  68. package/lib/programmers/http/HttpValidateQuerifyProgrammer.js +6 -8
  69. package/lib/programmers/http/HttpValidateQuerifyProgrammer.js.map +1 -1
  70. package/lib/programmers/internal/CoreMetadataUtil.d.ts +3 -3
  71. package/lib/programmers/internal/CoreMetadataUtil.js.map +1 -1
  72. package/lib/transform.d.ts +1 -1
  73. package/lib/transform.js.map +1 -1
  74. package/lib/transformers/FileTransformer.js +2 -2
  75. package/lib/transformers/FileTransformer.js.map +1 -1
  76. package/lib/transformers/MethodTransformer.js.map +1 -1
  77. package/lib/transformers/ParameterDecoratorTransformer.js +1 -1
  78. package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
  79. package/lib/transformers/TypedRouteTransformer.js +1 -1
  80. package/lib/transformers/TypedRouteTransformer.js.map +1 -1
  81. package/lib/transformers/WebSocketRouteTransformer.js +1 -1
  82. package/lib/transformers/WebSocketRouteTransformer.js.map +1 -1
  83. package/package.json +34 -26
  84. package/src/adaptors/WebSocketAdaptor.ts +429 -429
  85. package/src/decorators/DynamicModule.ts +44 -44
  86. package/src/decorators/EncryptedBody.ts +96 -97
  87. package/src/decorators/EncryptedController.ts +40 -40
  88. package/src/decorators/EncryptedModule.ts +98 -98
  89. package/src/decorators/EncryptedRoute.ts +212 -213
  90. package/src/decorators/HumanRoute.ts +21 -22
  91. package/src/decorators/NoTransformConfigurationError.ts +34 -34
  92. package/src/decorators/PlainBody.ts +76 -76
  93. package/src/decorators/SwaggerCustomizer.ts +97 -97
  94. package/src/decorators/SwaggerExample.ts +100 -100
  95. package/src/decorators/TypedBody.ts +57 -57
  96. package/src/decorators/TypedException.ts +147 -147
  97. package/src/decorators/TypedFormData.ts +187 -195
  98. package/src/decorators/TypedHeaders.ts +66 -66
  99. package/src/decorators/TypedParam.ts +77 -77
  100. package/src/decorators/TypedQuery.ts +234 -234
  101. package/src/decorators/TypedRoute.ts +196 -196
  102. package/src/decorators/WebSocketRoute.ts +242 -242
  103. package/src/decorators/internal/EncryptedConstant.ts +2 -2
  104. package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
  105. package/src/decorators/internal/NoTransformConfigureError.ts +2 -2
  106. package/src/decorators/internal/get_path_and_querify.ts +94 -94
  107. package/src/decorators/internal/get_path_and_stringify.ts +110 -110
  108. package/src/decorators/internal/get_text_body.ts +16 -16
  109. package/src/decorators/internal/headers_to_object.ts +11 -11
  110. package/src/decorators/internal/is_request_body_undefined.ts +12 -12
  111. package/src/decorators/internal/load_controller.ts +45 -45
  112. package/src/decorators/internal/route_error.ts +43 -43
  113. package/src/decorators/internal/validate_request_body.ts +64 -64
  114. package/src/decorators/internal/validate_request_form_data.ts +67 -67
  115. package/src/decorators/internal/validate_request_headers.ts +76 -76
  116. package/src/decorators/internal/validate_request_query.ts +64 -64
  117. package/src/index.ts +5 -5
  118. package/src/module.ts +23 -22
  119. package/src/options/INestiaTransformOptions.ts +34 -34
  120. package/src/options/INestiaTransformProject.ts +10 -8
  121. package/src/options/IRequestBodyValidator.ts +20 -20
  122. package/src/options/IRequestFormDataProps.ts +27 -27
  123. package/src/options/IRequestHeadersValidator.ts +22 -22
  124. package/src/options/IRequestQueryValidator.ts +20 -20
  125. package/src/options/IResponseBodyQuerifier.ts +25 -25
  126. package/src/options/IResponseBodyStringifier.ts +30 -30
  127. package/src/programmers/PlainBodyProgrammer.ts +72 -70
  128. package/src/programmers/TypedBodyProgrammer.ts +144 -142
  129. package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
  130. package/src/programmers/TypedHeadersProgrammer.ts +65 -63
  131. package/src/programmers/TypedParamProgrammer.ts +33 -33
  132. package/src/programmers/TypedQueryBodyProgrammer.ts +111 -109
  133. package/src/programmers/TypedQueryProgrammer.ts +113 -111
  134. package/src/programmers/TypedQueryRouteProgrammer.ts +104 -102
  135. package/src/programmers/TypedRouteProgrammer.ts +96 -94
  136. package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +74 -72
  137. package/src/programmers/http/HttpIsQuerifyProgrammer.ts +77 -75
  138. package/src/programmers/http/HttpQuerifyProgrammer.ts +110 -108
  139. package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +78 -76
  140. package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
  141. package/src/transform.ts +35 -35
  142. package/src/transformers/FileTransformer.ts +109 -110
  143. package/src/transformers/MethodTransformer.ts +103 -103
  144. package/src/transformers/NodeTransformer.ts +23 -23
  145. package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
  146. package/src/transformers/ParameterTransformer.ts +57 -57
  147. package/src/transformers/TypedRouteTransformer.ts +85 -85
  148. package/src/transformers/WebSocketRouteTransformer.ts +120 -120
  149. package/src/typings/Creator.ts +3 -3
  150. package/src/typings/get-function-location.d.ts +7 -7
  151. package/src/utils/ArrayUtil.ts +7 -7
  152. package/src/utils/ExceptionManager.ts +115 -115
  153. package/src/utils/Singleton.ts +16 -16
  154. package/src/utils/SourceFinder.ts +54 -54
  155. package/src/utils/VersioningStrategy.ts +27 -27
@@ -1,34 +1,34 @@
1
- export interface INestiaTransformOptions {
2
- validate?: INestiaTransformOptions.Validate;
3
- stringify?: INestiaTransformOptions.Stringify | null;
4
- llm?: INestiaTransformOptions.ILlm;
5
- throws?: boolean;
6
- }
7
- export namespace INestiaTransformOptions {
8
- export type Validate =
9
- // NORMAL
10
- | "assert"
11
- | "is"
12
- | "validate"
13
- // STRICT
14
- | "assertEquals"
15
- | "equals"
16
- | "validateEquals"
17
- // CLONE
18
- | "assertClone"
19
- | "validateClone"
20
- // PRUNE
21
- | "assertPrune"
22
- | "validatePrune";
23
-
24
- export type Stringify =
25
- | "stringify"
26
- | "assert"
27
- | "is"
28
- | "validate"
29
- | "validate.log";
30
-
31
- export interface ILlm {
32
- strict?: boolean;
33
- }
34
- }
1
+ export interface INestiaTransformOptions {
2
+ validate?: INestiaTransformOptions.Validate;
3
+ stringify?: INestiaTransformOptions.Stringify | null;
4
+ llm?: INestiaTransformOptions.ILlm;
5
+ throws?: boolean;
6
+ }
7
+ export namespace INestiaTransformOptions {
8
+ export type Validate =
9
+ // NORMAL
10
+ | "assert"
11
+ | "is"
12
+ | "validate"
13
+ // STRICT
14
+ | "assertEquals"
15
+ | "equals"
16
+ | "validateEquals"
17
+ // CLONE
18
+ | "assertClone"
19
+ | "validateClone"
20
+ // PRUNE
21
+ | "assertPrune"
22
+ | "validatePrune";
23
+
24
+ export type Stringify =
25
+ | "stringify"
26
+ | "assert"
27
+ | "is"
28
+ | "validate"
29
+ | "validate.log";
30
+
31
+ export interface ILlm {
32
+ strict?: boolean;
33
+ }
34
+ }
@@ -1,8 +1,10 @@
1
- import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
2
-
3
- import { INestiaTransformOptions } from "./INestiaTransformOptions";
4
-
5
- export interface INestiaTransformContext
6
- extends Omit<ITypiaContext, "options"> {
7
- options: INestiaTransformOptions;
8
- }
1
+ import { ITypiaContext } from "@typia/core";
2
+
3
+ import { INestiaTransformOptions } from "./INestiaTransformOptions";
4
+
5
+ export interface INestiaTransformContext extends Omit<
6
+ ITypiaContext,
7
+ "options"
8
+ > {
9
+ options: INestiaTransformOptions;
10
+ }
@@ -1,20 +1,20 @@
1
- import { IValidation } from "typia";
2
-
3
- export type IRequestBodyValidator<T> =
4
- | IRequestBodyValidator.IAssert<T>
5
- | IRequestBodyValidator.IIs<T>
6
- | IRequestBodyValidator.IValidate<T>;
7
- export namespace IRequestBodyValidator {
8
- export interface IAssert<T> {
9
- type: "assert";
10
- assert: (input: T) => T;
11
- }
12
- export interface IIs<T> {
13
- type: "is";
14
- is: (input: T) => boolean;
15
- }
16
- export interface IValidate<T> {
17
- type: "validate";
18
- validate: (input: T) => IValidation<T>;
19
- }
20
- }
1
+ import { IValidation } from "typia";
2
+
3
+ export type IRequestBodyValidator<T> =
4
+ | IRequestBodyValidator.IAssert<T>
5
+ | IRequestBodyValidator.IIs<T>
6
+ | IRequestBodyValidator.IValidate<T>;
7
+ export namespace IRequestBodyValidator {
8
+ export interface IAssert<T> {
9
+ type: "assert";
10
+ assert: (input: T) => T;
11
+ }
12
+ export interface IIs<T> {
13
+ type: "is";
14
+ is: (input: T) => boolean;
15
+ }
16
+ export interface IValidate<T> {
17
+ type: "validate";
18
+ validate: (input: T) => IValidation<T>;
19
+ }
20
+ }
@@ -1,27 +1,27 @@
1
- import { IValidation } from "typia";
2
-
3
- export interface IRequestFormDataProps<T> {
4
- files: Array<IRequestFormDataProps.IFile>;
5
- validator:
6
- | IRequestFormDataProps.IAssert<T>
7
- | IRequestFormDataProps.IIs<T>
8
- | IRequestFormDataProps.IValidate<T>;
9
- }
10
- export namespace IRequestFormDataProps {
11
- export interface IAssert<T> {
12
- type: "assert";
13
- assert: (input: FormData) => T;
14
- }
15
- export interface IIs<T> {
16
- type: "is";
17
- is: (input: FormData) => T | null;
18
- }
19
- export interface IValidate<T> {
20
- type: "validate";
21
- validate: (input: FormData) => IValidation<T>;
22
- }
23
- export interface IFile {
24
- name: string;
25
- limit: number | null;
26
- }
27
- }
1
+ import { IValidation } from "typia";
2
+
3
+ export interface IRequestFormDataProps<T> {
4
+ files: Array<IRequestFormDataProps.IFile>;
5
+ validator:
6
+ | IRequestFormDataProps.IAssert<T>
7
+ | IRequestFormDataProps.IIs<T>
8
+ | IRequestFormDataProps.IValidate<T>;
9
+ }
10
+ export namespace IRequestFormDataProps {
11
+ export interface IAssert<T> {
12
+ type: "assert";
13
+ assert: (input: FormData) => T;
14
+ }
15
+ export interface IIs<T> {
16
+ type: "is";
17
+ is: (input: FormData) => T | null;
18
+ }
19
+ export interface IValidate<T> {
20
+ type: "validate";
21
+ validate: (input: FormData) => IValidation<T>;
22
+ }
23
+ export interface IFile {
24
+ name: string;
25
+ limit: number | null;
26
+ }
27
+ }
@@ -1,22 +1,22 @@
1
- import { IValidation } from "typia";
2
-
3
- export type IRequestHeadersValidator<T> =
4
- | IRequestHeadersValidator.IAssert<T>
5
- | IRequestHeadersValidator.IIs<T>
6
- | IRequestHeadersValidator.IValidate<T>;
7
- export namespace IRequestHeadersValidator {
8
- export interface IAssert<T> {
9
- type: "assert";
10
- assert: (input: Record<string, string | string[] | undefined>) => T;
11
- }
12
- export interface IIs<T> {
13
- type: "is";
14
- is: (input: Record<string, string | string[] | undefined>) => T | null;
15
- }
16
- export interface IValidate<T> {
17
- type: "validate";
18
- validate: (
19
- input: Record<string, string | string[] | undefined>,
20
- ) => IValidation<T>;
21
- }
22
- }
1
+ import { IValidation } from "typia";
2
+
3
+ export type IRequestHeadersValidator<T> =
4
+ | IRequestHeadersValidator.IAssert<T>
5
+ | IRequestHeadersValidator.IIs<T>
6
+ | IRequestHeadersValidator.IValidate<T>;
7
+ export namespace IRequestHeadersValidator {
8
+ export interface IAssert<T> {
9
+ type: "assert";
10
+ assert: (input: Record<string, string | string[] | undefined>) => T;
11
+ }
12
+ export interface IIs<T> {
13
+ type: "is";
14
+ is: (input: Record<string, string | string[] | undefined>) => T | null;
15
+ }
16
+ export interface IValidate<T> {
17
+ type: "validate";
18
+ validate: (
19
+ input: Record<string, string | string[] | undefined>,
20
+ ) => IValidation<T>;
21
+ }
22
+ }
@@ -1,20 +1,20 @@
1
- import { IValidation } from "typia";
2
-
3
- export type IRequestQueryValidator<T> =
4
- | IRequestQueryValidator.IAssert<T>
5
- | IRequestQueryValidator.IIs<T>
6
- | IRequestQueryValidator.IValidate<T>;
7
- export namespace IRequestQueryValidator {
8
- export interface IAssert<T> {
9
- type: "assert";
10
- assert: (input: URLSearchParams) => T;
11
- }
12
- export interface IIs<T> {
13
- type: "is";
14
- is: (input: URLSearchParams) => T | null;
15
- }
16
- export interface IValidate<T> {
17
- type: "validate";
18
- validate: (input: URLSearchParams) => IValidation<T>;
19
- }
20
- }
1
+ import { IValidation } from "typia";
2
+
3
+ export type IRequestQueryValidator<T> =
4
+ | IRequestQueryValidator.IAssert<T>
5
+ | IRequestQueryValidator.IIs<T>
6
+ | IRequestQueryValidator.IValidate<T>;
7
+ export namespace IRequestQueryValidator {
8
+ export interface IAssert<T> {
9
+ type: "assert";
10
+ assert: (input: URLSearchParams) => T;
11
+ }
12
+ export interface IIs<T> {
13
+ type: "is";
14
+ is: (input: URLSearchParams) => T | null;
15
+ }
16
+ export interface IValidate<T> {
17
+ type: "validate";
18
+ validate: (input: URLSearchParams) => IValidation<T>;
19
+ }
20
+ }
@@ -1,25 +1,25 @@
1
- import { IValidation } from "typia";
2
-
3
- export type IResponseBodyQuerifier<T> =
4
- | IResponseBodyquerifier.IStringify<T>
5
- | IResponseBodyquerifier.IIs<T>
6
- | IResponseBodyquerifier.IAssert<T>
7
- | IResponseBodyquerifier.IValidate<T>;
8
- export namespace IResponseBodyquerifier {
9
- export interface IStringify<T> {
10
- type: "stringify";
11
- stringify: (input: T) => URLSearchParams;
12
- }
13
- export interface IIs<T> {
14
- type: "is";
15
- is: (input: T) => URLSearchParams | null;
16
- }
17
- export interface IAssert<T> {
18
- type: "assert";
19
- assert: (input: T) => URLSearchParams;
20
- }
21
- export interface IValidate<T> {
22
- type: "validate";
23
- validate: (input: T) => IValidation<URLSearchParams>;
24
- }
25
- }
1
+ import { IValidation } from "typia";
2
+
3
+ export type IResponseBodyQuerifier<T> =
4
+ | IResponseBodyquerifier.IStringify<T>
5
+ | IResponseBodyquerifier.IIs<T>
6
+ | IResponseBodyquerifier.IAssert<T>
7
+ | IResponseBodyquerifier.IValidate<T>;
8
+ export namespace IResponseBodyquerifier {
9
+ export interface IStringify<T> {
10
+ type: "stringify";
11
+ stringify: (input: T) => URLSearchParams;
12
+ }
13
+ export interface IIs<T> {
14
+ type: "is";
15
+ is: (input: T) => URLSearchParams | null;
16
+ }
17
+ export interface IAssert<T> {
18
+ type: "assert";
19
+ assert: (input: T) => URLSearchParams;
20
+ }
21
+ export interface IValidate<T> {
22
+ type: "validate";
23
+ validate: (input: T) => IValidation<URLSearchParams>;
24
+ }
25
+ }
@@ -1,30 +1,30 @@
1
- import { IValidation } from "typia";
2
-
3
- export type IResponseBodyStringifier<T> =
4
- | IResponseBodyStringifier.IStringify<T>
5
- | IResponseBodyStringifier.IIs<T>
6
- | IResponseBodyStringifier.IAssert<T>
7
- | IResponseBodyStringifier.IValidate<T>
8
- | IResponseBodyStringifier.IValidateLog<T>;
9
- export namespace IResponseBodyStringifier {
10
- export interface IStringify<T> {
11
- type: "stringify";
12
- stringify: (input: T) => string;
13
- }
14
- export interface IIs<T> {
15
- type: "is";
16
- is: (input: T) => string | null;
17
- }
18
- export interface IAssert<T> {
19
- type: "assert";
20
- assert: (input: T) => string;
21
- }
22
- export interface IValidate<T> {
23
- type: "validate";
24
- validate: (input: T) => IValidation<string>;
25
- }
26
- export interface IValidateLog<T> {
27
- type: "validate.log";
28
- validate: (input: T) => IValidation<string>;
29
- }
30
- }
1
+ import { IValidation } from "typia";
2
+
3
+ export type IResponseBodyStringifier<T> =
4
+ | IResponseBodyStringifier.IStringify<T>
5
+ | IResponseBodyStringifier.IIs<T>
6
+ | IResponseBodyStringifier.IAssert<T>
7
+ | IResponseBodyStringifier.IValidate<T>
8
+ | IResponseBodyStringifier.IValidateLog<T>;
9
+ export namespace IResponseBodyStringifier {
10
+ export interface IStringify<T> {
11
+ type: "stringify";
12
+ stringify: (input: T) => string;
13
+ }
14
+ export interface IIs<T> {
15
+ type: "is";
16
+ is: (input: T) => string | null;
17
+ }
18
+ export interface IAssert<T> {
19
+ type: "assert";
20
+ assert: (input: T) => string;
21
+ }
22
+ export interface IValidate<T> {
23
+ type: "validate";
24
+ validate: (input: T) => IValidation<string>;
25
+ }
26
+ export interface IValidateLog<T> {
27
+ type: "validate.log";
28
+ validate: (input: T) => IValidation<string>;
29
+ }
30
+ }
@@ -1,70 +1,72 @@
1
- import ts from "typescript";
2
- import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
3
- import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
4
- import { AssertProgrammer } from "typia/lib/programmers/AssertProgrammer";
5
- import { Metadata } from "typia/lib/schemas/metadata/Metadata";
6
- import { TransformerError } from "typia/lib/transformers/TransformerError";
7
-
8
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
9
-
10
- export namespace PlainBodyProgrammer {
11
- export const generate = (props: {
12
- context: INestiaTransformContext;
13
- modulo: ts.LeftHandSideExpression;
14
- type: ts.Type;
15
- }): ts.Expression => {
16
- const result = MetadataFactory.analyze({
17
- checker: props.context.checker,
18
- transformer: props.context.transformer,
19
- options: {
20
- escape: false,
21
- constant: true,
22
- absorb: true,
23
- validate,
24
- },
25
- collection: new MetadataCollection(),
26
- type: props.type,
27
- });
28
- if (result.success === false)
29
- throw TransformerError.from({
30
- code: "nestia.core.TypedParam",
31
- errors: result.errors,
32
- });
33
- return AssertProgrammer.write({
34
- context: {
35
- ...props.context,
36
- options: {
37
- numeric: false,
38
- finite: false,
39
- functional: false,
40
- },
41
- },
42
- modulo: props.modulo,
43
- config: {
44
- equals: false,
45
- guard: false,
46
- },
47
- type: props.type,
48
- name: undefined,
49
- });
50
- };
51
- }
52
-
53
- const validate = (metadata: Metadata): string[] => {
54
- const errors: string[] = [];
55
- const insert = (msg: string) => errors.push(msg);
56
-
57
- const expected: number =
58
- (metadata.atomics.some((a) => a.type === "string") ? 1 : 0) +
59
- metadata.templates.length +
60
- metadata.constants
61
- .filter((c) => c.type === "string")
62
- .map((c) => c.values.length)
63
- .reduce((a, b) => a + b, 0);
64
- if (expected === 0 || expected !== metadata.size())
65
- insert(`only string type is allowed`);
66
- if (metadata.nullable === true) insert(`do not allow nullable type`);
67
- else if (metadata.any === true) insert(`do not allow any type`);
68
-
69
- return errors;
70
- };
1
+ import {
2
+ AssertProgrammer,
3
+ MetadataCollection,
4
+ MetadataFactory,
5
+ MetadataSchema,
6
+ TransformerError,
7
+ } from "@typia/core";
8
+ import ts from "typescript";
9
+
10
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
11
+
12
+ export namespace PlainBodyProgrammer {
13
+ export const generate = (props: {
14
+ context: INestiaTransformContext;
15
+ modulo: ts.LeftHandSideExpression;
16
+ type: ts.Type;
17
+ }): ts.Expression => {
18
+ const result = MetadataFactory.analyze({
19
+ checker: props.context.checker,
20
+ transformer: props.context.transformer,
21
+ options: {
22
+ escape: false,
23
+ constant: true,
24
+ absorb: true,
25
+ validate,
26
+ },
27
+ components: new MetadataCollection(),
28
+ type: props.type,
29
+ });
30
+ if (result.success === false)
31
+ throw TransformerError.from({
32
+ code: "nestia.core.TypedParam",
33
+ errors: result.errors,
34
+ });
35
+ return AssertProgrammer.write({
36
+ context: {
37
+ ...props.context,
38
+ options: {
39
+ numeric: false,
40
+ finite: false,
41
+ functional: false,
42
+ },
43
+ },
44
+ modulo: props.modulo,
45
+ config: {
46
+ equals: false,
47
+ guard: false,
48
+ },
49
+ type: props.type,
50
+ name: undefined,
51
+ });
52
+ };
53
+ }
54
+
55
+ const validate = (metadata: MetadataSchema): string[] => {
56
+ const errors: string[] = [];
57
+ const insert = (msg: string) => errors.push(msg);
58
+
59
+ const expected: number =
60
+ (metadata.atomics.some((a) => a.type === "string") ? 1 : 0) +
61
+ metadata.templates.length +
62
+ metadata.constants
63
+ .filter((c) => c.type === "string")
64
+ .map((c) => c.values.length)
65
+ .reduce((a, b) => a + b, 0);
66
+ if (expected === 0 || expected !== metadata.size())
67
+ insert(`only string type is allowed`);
68
+ if (metadata.nullable === true) insert(`do not allow nullable type`);
69
+ else if (metadata.any === true) insert(`do not allow any type`);
70
+
71
+ return errors;
72
+ };