@nestia/core 8.0.8 → 9.0.0-dev.20251107

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 (75) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +93 -93
  3. package/package.json +7 -8
  4. package/src/adaptors/WebSocketAdaptor.ts +429 -429
  5. package/src/decorators/DynamicModule.ts +44 -44
  6. package/src/decorators/EncryptedBody.ts +97 -97
  7. package/src/decorators/EncryptedController.ts +40 -40
  8. package/src/decorators/EncryptedModule.ts +98 -98
  9. package/src/decorators/EncryptedRoute.ts +213 -213
  10. package/src/decorators/HumanRoute.ts +22 -22
  11. package/src/decorators/NoTransformConfigurationError.ts +34 -34
  12. package/src/decorators/PlainBody.ts +76 -76
  13. package/src/decorators/SwaggerCustomizer.ts +97 -97
  14. package/src/decorators/SwaggerExample.ts +100 -100
  15. package/src/decorators/TypedBody.ts +57 -57
  16. package/src/decorators/TypedException.ts +147 -147
  17. package/src/decorators/TypedFormData.ts +195 -195
  18. package/src/decorators/TypedHeaders.ts +66 -66
  19. package/src/decorators/TypedParam.ts +77 -77
  20. package/src/decorators/TypedQuery.ts +234 -234
  21. package/src/decorators/TypedRoute.ts +196 -196
  22. package/src/decorators/WebSocketRoute.ts +242 -242
  23. package/src/decorators/internal/EncryptedConstant.ts +2 -2
  24. package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
  25. package/src/decorators/internal/NoTransformConfigureError.ts +2 -2
  26. package/src/decorators/internal/get_path_and_querify.ts +94 -94
  27. package/src/decorators/internal/get_path_and_stringify.ts +110 -110
  28. package/src/decorators/internal/get_text_body.ts +16 -16
  29. package/src/decorators/internal/headers_to_object.ts +11 -11
  30. package/src/decorators/internal/is_request_body_undefined.ts +12 -12
  31. package/src/decorators/internal/load_controller.ts +45 -45
  32. package/src/decorators/internal/route_error.ts +43 -43
  33. package/src/decorators/internal/validate_request_body.ts +64 -64
  34. package/src/decorators/internal/validate_request_form_data.ts +67 -67
  35. package/src/decorators/internal/validate_request_headers.ts +76 -76
  36. package/src/decorators/internal/validate_request_query.ts +64 -64
  37. package/src/index.ts +5 -5
  38. package/src/module.ts +22 -22
  39. package/src/options/INestiaTransformOptions.ts +38 -38
  40. package/src/options/INestiaTransformProject.ts +8 -8
  41. package/src/options/IRequestBodyValidator.ts +20 -20
  42. package/src/options/IRequestFormDataProps.ts +27 -27
  43. package/src/options/IRequestHeadersValidator.ts +22 -22
  44. package/src/options/IRequestQueryValidator.ts +20 -20
  45. package/src/options/IResponseBodyQuerifier.ts +25 -25
  46. package/src/options/IResponseBodyStringifier.ts +30 -30
  47. package/src/programmers/PlainBodyProgrammer.ts +70 -70
  48. package/src/programmers/TypedBodyProgrammer.ts +142 -142
  49. package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
  50. package/src/programmers/TypedHeadersProgrammer.ts +63 -63
  51. package/src/programmers/TypedParamProgrammer.ts +33 -33
  52. package/src/programmers/TypedQueryBodyProgrammer.ts +112 -112
  53. package/src/programmers/TypedQueryProgrammer.ts +114 -114
  54. package/src/programmers/TypedQueryRouteProgrammer.ts +105 -105
  55. package/src/programmers/TypedRouteProgrammer.ts +94 -94
  56. package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +72 -72
  57. package/src/programmers/http/HttpIsQuerifyProgrammer.ts +75 -75
  58. package/src/programmers/http/HttpQuerifyProgrammer.ts +108 -108
  59. package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +76 -76
  60. package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
  61. package/src/transform.ts +35 -35
  62. package/src/transformers/FileTransformer.ts +110 -110
  63. package/src/transformers/MethodTransformer.ts +103 -103
  64. package/src/transformers/NodeTransformer.ts +23 -23
  65. package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
  66. package/src/transformers/ParameterTransformer.ts +57 -57
  67. package/src/transformers/TypedRouteTransformer.ts +85 -85
  68. package/src/transformers/WebSocketRouteTransformer.ts +120 -120
  69. package/src/typings/Creator.ts +3 -3
  70. package/src/typings/get-function-location.d.ts +7 -7
  71. package/src/utils/ArrayUtil.ts +7 -7
  72. package/src/utils/ExceptionManager.ts +115 -115
  73. package/src/utils/Singleton.ts +16 -16
  74. package/src/utils/SourceFinder.ts +54 -54
  75. package/src/utils/VersioningStrategy.ts +27 -27
@@ -1,38 +1,38 @@
1
- import { ILlmSchema } from "@samchon/openapi";
2
-
3
- export interface INestiaTransformOptions {
4
- validate?: INestiaTransformOptions.Validate;
5
- stringify?: INestiaTransformOptions.Stringify | null;
6
- llm?: INestiaTransformOptions.ILlm<"chatgpt" | "gemini" | "3.0">;
7
- throws?: boolean;
8
- }
9
- export namespace INestiaTransformOptions {
10
- export type Validate =
11
- // NORMAL
12
- | "assert"
13
- | "is"
14
- | "validate"
15
- // STRICT
16
- | "assertEquals"
17
- | "equals"
18
- | "validateEquals"
19
- // CLONE
20
- | "assertClone"
21
- | "validateClone"
22
- // PRUNE
23
- | "assertPrune"
24
- | "validatePrune";
25
-
26
- export type Stringify =
27
- | "stringify"
28
- | "assert"
29
- | "is"
30
- | "validate"
31
- | "validate.log";
32
-
33
- export interface ILlm<Model extends ILlmSchema.Model> {
34
- model: Model;
35
- strict?: Model extends "chatgpt" ? boolean : never;
36
- recursive?: Model extends "gemini" | "3.0" ? false | number : never;
37
- }
38
- }
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ export interface INestiaTransformOptions {
4
+ validate?: INestiaTransformOptions.Validate;
5
+ stringify?: INestiaTransformOptions.Stringify | null;
6
+ llm?: INestiaTransformOptions.ILlm<"chatgpt" | "gemini" | "3.0">;
7
+ throws?: boolean;
8
+ }
9
+ export namespace INestiaTransformOptions {
10
+ export type Validate =
11
+ // NORMAL
12
+ | "assert"
13
+ | "is"
14
+ | "validate"
15
+ // STRICT
16
+ | "assertEquals"
17
+ | "equals"
18
+ | "validateEquals"
19
+ // CLONE
20
+ | "assertClone"
21
+ | "validateClone"
22
+ // PRUNE
23
+ | "assertPrune"
24
+ | "validatePrune";
25
+
26
+ export type Stringify =
27
+ | "stringify"
28
+ | "assert"
29
+ | "is"
30
+ | "validate"
31
+ | "validate.log";
32
+
33
+ export interface ILlm<Model extends ILlmSchema.Model> {
34
+ model: Model;
35
+ strict?: Model extends "chatgpt" ? boolean : never;
36
+ recursive?: Model extends "gemini" | "3.0" ? false | number : never;
37
+ }
38
+ }
@@ -1,8 +1,8 @@
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/lib/transformers/ITypiaContext";
2
+
3
+ import { INestiaTransformOptions } from "./INestiaTransformOptions";
4
+
5
+ export interface INestiaTransformContext
6
+ extends Omit<ITypiaContext, "options"> {
7
+ options: INestiaTransformOptions;
8
+ }
@@ -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,70 @@
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 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
+ };