@nestia/core 11.0.0-dev.20260316 → 11.0.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 (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +93 -93
  3. package/lib/decorators/NoTransformConfigurationError.d.ts +1 -24
  4. package/lib/decorators/NoTransformConfigurationError.js +2 -0
  5. package/lib/decorators/NoTransformConfigurationError.js.map +1 -1
  6. package/lib/decorators/doNotThrowTransformError.d.ts +1 -0
  7. package/lib/decorators/doNotThrowTransformError.js +9 -0
  8. package/lib/decorators/doNotThrowTransformError.js.map +1 -0
  9. package/lib/module.d.ts +1 -1
  10. package/lib/module.js +1 -1
  11. package/lib/module.js.map +1 -1
  12. package/package.json +8 -8
  13. package/src/adaptors/WebSocketAdaptor.ts +429 -429
  14. package/src/decorators/EncryptedBody.ts +96 -96
  15. package/src/decorators/EncryptedController.ts +40 -40
  16. package/src/decorators/EncryptedModule.ts +98 -98
  17. package/src/decorators/EncryptedRoute.ts +212 -212
  18. package/src/decorators/HumanRoute.ts +21 -21
  19. package/src/decorators/NoTransformConfigurationError.ts +37 -34
  20. package/src/decorators/SwaggerCustomizer.ts +97 -97
  21. package/src/decorators/TypedFormData.ts +187 -187
  22. package/src/decorators/TypedRoute.ts +196 -196
  23. package/src/decorators/doNotThrowTransformError.ts +5 -0
  24. package/src/decorators/internal/headers_to_object.ts +11 -11
  25. package/src/module.ts +23 -23
  26. package/src/options/INestiaTransformOptions.ts +34 -34
  27. package/src/options/INestiaTransformProject.ts +10 -10
  28. package/src/programmers/PlainBodyProgrammer.ts +72 -72
  29. package/src/programmers/TypedBodyProgrammer.ts +148 -148
  30. package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
  31. package/src/programmers/TypedHeadersProgrammer.ts +65 -65
  32. package/src/programmers/TypedParamProgrammer.ts +33 -33
  33. package/src/programmers/TypedQueryBodyProgrammer.ts +113 -113
  34. package/src/programmers/TypedQueryProgrammer.ts +115 -115
  35. package/src/programmers/TypedQueryRouteProgrammer.ts +107 -107
  36. package/src/programmers/TypedRouteProgrammer.ts +103 -103
  37. package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +74 -74
  38. package/src/programmers/http/HttpIsQuerifyProgrammer.ts +77 -77
  39. package/src/programmers/http/HttpQuerifyProgrammer.ts +110 -110
  40. package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +78 -78
  41. package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
  42. package/src/transform.ts +35 -35
  43. package/src/transformers/FileTransformer.ts +109 -109
  44. package/src/transformers/MethodTransformer.ts +103 -103
  45. package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
  46. package/src/transformers/TypedRouteTransformer.ts +85 -85
  47. package/src/transformers/WebSocketRouteTransformer.ts +120 -120
@@ -1,120 +1,120 @@
1
- import path from "path";
2
- import ts from "typescript";
3
-
4
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
5
-
6
- export namespace WebSocketRouteTransformer {
7
- export const validate = (props: {
8
- context: INestiaTransformContext;
9
- decorator: ts.Decorator;
10
- method: ts.MethodDeclaration;
11
- }): ts.Decorator => {
12
- if (!ts.isCallExpression(props.decorator.expression))
13
- return props.decorator;
14
-
15
- // CHECK SIGNATURE
16
- const signature: ts.Signature | undefined =
17
- props.context.checker.getResolvedSignature(props.decorator.expression);
18
- if (!signature || !signature.declaration) return props.decorator;
19
- else if (isLocated(signature) === false) return props.decorator;
20
-
21
- const errors: ts.DiagnosticWithLocation[] = [];
22
- let accepted: boolean = false;
23
-
24
- const report = (node: ts.Node, message: string) => {
25
- errors.push(
26
- (ts as any).createDiagnosticForNode(node, {
27
- category: ts.DiagnosticCategory.Error,
28
- key: "nestia.core.WebSocketRoute",
29
- code: "(nestia.core.WebSocketRoute)" as any,
30
- message,
31
- }),
32
- );
33
- };
34
- props.method.parameters.forEach((param) => {
35
- const paramDecos: ts.Decorator[] = (param.modifiers ?? []).filter((m) =>
36
- ts.isDecorator(m),
37
- ) as ts.Decorator[];
38
- const category: string | null = (() => {
39
- if (paramDecos.length !== 1) return null;
40
- const decorator: ts.Decorator = paramDecos[0]!;
41
- const signature: ts.Signature | undefined = ts.isCallExpression(
42
- decorator.expression,
43
- )
44
- ? props.context.checker.getResolvedSignature(decorator.expression)
45
- : undefined;
46
- if (signature === undefined || isLocated(signature) === false)
47
- return null;
48
- return (
49
- decorator.expression.getText().split(".").at(-1)?.split("(")[0] ??
50
- null
51
- );
52
- })();
53
- if (category === null)
54
- report(
55
- param,
56
- `parameter ${JSON.stringify(param.name.getText())} is not decorated with nested function of WebSocketRoute module.`,
57
- );
58
- else if (category === "Acceptor") {
59
- accepted = true;
60
- if (
61
- param.type
62
- ?.getText()
63
- .split("<")[0]
64
- ?.split(".")
65
- .at(-1)
66
- ?.startsWith("WebSocketAcceptor") !== true
67
- )
68
- report(
69
- param,
70
- `parameter ${JSON.stringify(param.name.getText())} must have WebSocketAcceptor<Header, Provider, Listener> type.`,
71
- );
72
- } else if (category === "Driver") {
73
- if (
74
- param.type
75
- ?.getText()
76
- .split("<")[0]
77
- ?.split(".")
78
- .at(-1)
79
- ?.startsWith("Driver") !== true
80
- )
81
- report(
82
- param,
83
- `parameter ${JSON.stringify(param.name.getText())} must have Driver<Listener> type.`,
84
- );
85
- }
86
- });
87
- if (accepted === false)
88
- report(
89
- props.method,
90
- `method ${JSON.stringify(props.method.name.getText())} must have at least one parameter decorated by @WebSocketRoute.Acceptor().`,
91
- );
92
- for (const e of errors) props.context.extras.addDiagnostic(e);
93
- return props.decorator;
94
- };
95
- }
96
-
97
- const isLocated = (signature: ts.Signature) => {
98
- if (!signature.declaration) return false;
99
- const location: string = path.resolve(
100
- signature.declaration.getSourceFile().fileName,
101
- );
102
- return (
103
- location.indexOf(LIB_PATH) !== -1 || location.indexOf(MONO_PATH) !== -1
104
- );
105
- };
106
-
107
- const LIB_PATH = path.join(
108
- "@nestia",
109
- "core",
110
- "lib",
111
- "decorators",
112
- `WebSocketRoute.d.ts`,
113
- );
114
- const MONO_PATH = path.join(
115
- "packages",
116
- "core",
117
- "src",
118
- "decorators",
119
- `WebSocketRoute.ts`,
120
- );
1
+ import path from "path";
2
+ import ts from "typescript";
3
+
4
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
5
+
6
+ export namespace WebSocketRouteTransformer {
7
+ export const validate = (props: {
8
+ context: INestiaTransformContext;
9
+ decorator: ts.Decorator;
10
+ method: ts.MethodDeclaration;
11
+ }): ts.Decorator => {
12
+ if (!ts.isCallExpression(props.decorator.expression))
13
+ return props.decorator;
14
+
15
+ // CHECK SIGNATURE
16
+ const signature: ts.Signature | undefined =
17
+ props.context.checker.getResolvedSignature(props.decorator.expression);
18
+ if (!signature || !signature.declaration) return props.decorator;
19
+ else if (isLocated(signature) === false) return props.decorator;
20
+
21
+ const errors: ts.DiagnosticWithLocation[] = [];
22
+ let accepted: boolean = false;
23
+
24
+ const report = (node: ts.Node, message: string) => {
25
+ errors.push(
26
+ (ts as any).createDiagnosticForNode(node, {
27
+ category: ts.DiagnosticCategory.Error,
28
+ key: "nestia.core.WebSocketRoute",
29
+ code: "(nestia.core.WebSocketRoute)" as any,
30
+ message,
31
+ }),
32
+ );
33
+ };
34
+ props.method.parameters.forEach((param) => {
35
+ const paramDecos: ts.Decorator[] = (param.modifiers ?? []).filter((m) =>
36
+ ts.isDecorator(m),
37
+ ) as ts.Decorator[];
38
+ const category: string | null = (() => {
39
+ if (paramDecos.length !== 1) return null;
40
+ const decorator: ts.Decorator = paramDecos[0]!;
41
+ const signature: ts.Signature | undefined = ts.isCallExpression(
42
+ decorator.expression,
43
+ )
44
+ ? props.context.checker.getResolvedSignature(decorator.expression)
45
+ : undefined;
46
+ if (signature === undefined || isLocated(signature) === false)
47
+ return null;
48
+ return (
49
+ decorator.expression.getText().split(".").at(-1)?.split("(")[0] ??
50
+ null
51
+ );
52
+ })();
53
+ if (category === null)
54
+ report(
55
+ param,
56
+ `parameter ${JSON.stringify(param.name.getText())} is not decorated with nested function of WebSocketRoute module.`,
57
+ );
58
+ else if (category === "Acceptor") {
59
+ accepted = true;
60
+ if (
61
+ param.type
62
+ ?.getText()
63
+ .split("<")[0]
64
+ ?.split(".")
65
+ .at(-1)
66
+ ?.startsWith("WebSocketAcceptor") !== true
67
+ )
68
+ report(
69
+ param,
70
+ `parameter ${JSON.stringify(param.name.getText())} must have WebSocketAcceptor<Header, Provider, Listener> type.`,
71
+ );
72
+ } else if (category === "Driver") {
73
+ if (
74
+ param.type
75
+ ?.getText()
76
+ .split("<")[0]
77
+ ?.split(".")
78
+ .at(-1)
79
+ ?.startsWith("Driver") !== true
80
+ )
81
+ report(
82
+ param,
83
+ `parameter ${JSON.stringify(param.name.getText())} must have Driver<Listener> type.`,
84
+ );
85
+ }
86
+ });
87
+ if (accepted === false)
88
+ report(
89
+ props.method,
90
+ `method ${JSON.stringify(props.method.name.getText())} must have at least one parameter decorated by @WebSocketRoute.Acceptor().`,
91
+ );
92
+ for (const e of errors) props.context.extras.addDiagnostic(e);
93
+ return props.decorator;
94
+ };
95
+ }
96
+
97
+ const isLocated = (signature: ts.Signature) => {
98
+ if (!signature.declaration) return false;
99
+ const location: string = path.resolve(
100
+ signature.declaration.getSourceFile().fileName,
101
+ );
102
+ return (
103
+ location.indexOf(LIB_PATH) !== -1 || location.indexOf(MONO_PATH) !== -1
104
+ );
105
+ };
106
+
107
+ const LIB_PATH = path.join(
108
+ "@nestia",
109
+ "core",
110
+ "lib",
111
+ "decorators",
112
+ `WebSocketRoute.d.ts`,
113
+ );
114
+ const MONO_PATH = path.join(
115
+ "packages",
116
+ "core",
117
+ "src",
118
+ "decorators",
119
+ `WebSocketRoute.ts`,
120
+ );