@nestia/core 4.2.0-dev.20241211 → 4.2.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.
- package/LICENSE +21 -21
- package/README.md +87 -87
- package/package.json +3 -3
- package/src/adaptors/WebSocketAdaptor.ts +426 -426
- package/src/decorators/DynamicModule.ts +43 -43
- package/src/decorators/EncryptedBody.ts +101 -101
- package/src/decorators/EncryptedController.ts +38 -38
- package/src/decorators/EncryptedModule.ts +100 -100
- package/src/decorators/EncryptedRoute.ts +219 -219
- package/src/decorators/NoTransformConfigurationError.ts +32 -32
- package/src/decorators/PlainBody.ts +79 -79
- package/src/decorators/SwaggerCustomizer.ts +115 -115
- package/src/decorators/SwaggerExample.ts +100 -100
- package/src/decorators/TypedBody.ts +59 -59
- package/src/decorators/TypedException.ts +128 -128
- package/src/decorators/TypedFormData.ts +195 -195
- package/src/decorators/TypedHeaders.ts +64 -64
- package/src/decorators/TypedParam.ts +66 -66
- package/src/decorators/TypedQuery.ts +245 -245
- package/src/decorators/TypedRoute.ts +214 -214
- package/src/decorators/WebSocketRoute.ts +242 -242
- package/src/decorators/internal/EncryptedConstant.ts +4 -4
- package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
- package/src/decorators/internal/NoTransformConfigureError.ts +2 -2
- package/src/decorators/internal/get_path_and_querify.ts +108 -108
- package/src/decorators/internal/get_path_and_stringify.ts +122 -122
- package/src/decorators/internal/get_text_body.ts +20 -20
- package/src/decorators/internal/headers_to_object.ts +13 -13
- package/src/decorators/internal/is_request_body_undefined.ts +14 -14
- package/src/decorators/internal/load_controller.ts +49 -49
- package/src/decorators/internal/route_error.ts +45 -45
- package/src/decorators/internal/validate_request_body.ts +74 -74
- package/src/decorators/internal/validate_request_form_data.ts +77 -77
- package/src/decorators/internal/validate_request_headers.ts +86 -86
- package/src/decorators/internal/validate_request_query.ts +74 -74
- package/src/index.ts +5 -5
- package/src/module.ts +21 -21
- package/src/options/INestiaTransformOptions.ts +24 -24
- package/src/options/INestiaTransformProject.ts +8 -8
- package/src/options/IRequestBodyValidator.ts +20 -20
- package/src/options/IRequestFormDataProps.ts +27 -27
- package/src/options/IRequestHeadersValidator.ts +22 -22
- package/src/options/IRequestQueryValidator.ts +20 -20
- package/src/options/IResponseBodyQuerifier.ts +25 -25
- package/src/options/IResponseBodyStringifier.ts +30 -30
- package/src/programmers/PlainBodyProgrammer.ts +70 -70
- package/src/programmers/TypedBodyProgrammer.ts +132 -132
- package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
- package/src/programmers/TypedHeadersProgrammer.ts +63 -63
- package/src/programmers/TypedParamProgrammer.ts +30 -30
- package/src/programmers/TypedQueryBodyProgrammer.ts +63 -63
- package/src/programmers/TypedQueryProgrammer.ts +65 -65
- package/src/programmers/TypedQueryRouteProgrammer.ts +56 -56
- package/src/programmers/TypedRouteProgrammer.ts +76 -76
- package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +72 -72
- package/src/programmers/http/HttpIsQuerifyProgrammer.ts +75 -75
- package/src/programmers/http/HttpQuerifyProgrammer.ts +108 -108
- package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +76 -76
- package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
- package/src/transform.ts +35 -35
- package/src/transformers/FileTransformer.ts +110 -110
- package/src/transformers/MethodTransformer.ts +103 -103
- package/src/transformers/NodeTransformer.ts +23 -23
- package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
- package/src/transformers/ParameterTransformer.ts +57 -57
- package/src/transformers/TypedRouteTransformer.ts +85 -85
- package/src/transformers/WebSocketRouteTransformer.ts +120 -120
- package/src/typings/Creator.ts +3 -3
- package/src/typings/get-function-location.d.ts +7 -7
- package/src/utils/ArrayUtil.ts +7 -7
- package/src/utils/ExceptionManager.ts +112 -112
- package/src/utils/Singleton.ts +20 -20
- package/src/utils/SourceFinder.ts +57 -57
- package/src/utils/VersioningStrategy.ts +27 -27
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
5
|
-
import { TypedQueryRouteProgrammer } from "../programmers/TypedQueryRouteProgrammer";
|
|
6
|
-
import { TypedRouteProgrammer } from "../programmers/TypedRouteProgrammer";
|
|
7
|
-
|
|
8
|
-
export namespace TypedRouteTransformer {
|
|
9
|
-
export const transform = (props: {
|
|
10
|
-
context: INestiaTransformContext;
|
|
11
|
-
decorator: ts.Decorator;
|
|
12
|
-
type: ts.Type;
|
|
13
|
-
}): ts.Decorator => {
|
|
14
|
-
if (!ts.isCallExpression(props.decorator.expression))
|
|
15
|
-
return props.decorator;
|
|
16
|
-
|
|
17
|
-
// CHECK SIGNATURE
|
|
18
|
-
const signature: ts.Signature | undefined =
|
|
19
|
-
props.context.checker.getResolvedSignature(props.decorator.expression);
|
|
20
|
-
if (!signature || !signature.declaration) return props.decorator;
|
|
21
|
-
|
|
22
|
-
// CHECK TO BE TRANSFORMED
|
|
23
|
-
const modulo = (() => {
|
|
24
|
-
// CHECK FILENAME
|
|
25
|
-
const location: string = path.resolve(
|
|
26
|
-
signature.declaration.getSourceFile().fileName,
|
|
27
|
-
);
|
|
28
|
-
if (LIB_PATHS.every((str) => location.indexOf(str) === -1)) return null;
|
|
29
|
-
|
|
30
|
-
// CHECK DUPLICATE BOOSTER
|
|
31
|
-
if (props.decorator.expression.arguments.length >= 2) return false;
|
|
32
|
-
else if (props.decorator.expression.arguments.length === 1) {
|
|
33
|
-
const last: ts.Expression =
|
|
34
|
-
props.decorator.expression.arguments[
|
|
35
|
-
props.decorator.expression.arguments.length - 1
|
|
36
|
-
];
|
|
37
|
-
const type: ts.Type = props.context.checker.getTypeAtLocation(last);
|
|
38
|
-
if (isObject(props.context.checker)(type)) return false;
|
|
39
|
-
}
|
|
40
|
-
return location.split(path.sep).at(-1)?.split(".")[0] === "TypedQuery"
|
|
41
|
-
? "TypedQuery"
|
|
42
|
-
: "TypedRoute";
|
|
43
|
-
})();
|
|
44
|
-
if (modulo === null) return props.decorator;
|
|
45
|
-
|
|
46
|
-
// CHECK TYPE NODE
|
|
47
|
-
const typeNode: ts.TypeNode | undefined =
|
|
48
|
-
props.context.checker.typeToTypeNode(props.type, undefined, undefined);
|
|
49
|
-
if (typeNode === undefined) return props.decorator;
|
|
50
|
-
|
|
51
|
-
// DO TRANSFORM
|
|
52
|
-
return ts.factory.createDecorator(
|
|
53
|
-
ts.factory.updateCallExpression(
|
|
54
|
-
props.decorator.expression,
|
|
55
|
-
props.decorator.expression.expression,
|
|
56
|
-
props.decorator.expression.typeArguments,
|
|
57
|
-
[
|
|
58
|
-
...props.decorator.expression.arguments,
|
|
59
|
-
(modulo === "TypedQuery"
|
|
60
|
-
? TypedQueryRouteProgrammer
|
|
61
|
-
: TypedRouteProgrammer
|
|
62
|
-
).generate({
|
|
63
|
-
context: props.context,
|
|
64
|
-
type: props.type,
|
|
65
|
-
modulo: props.decorator.expression.expression,
|
|
66
|
-
}),
|
|
67
|
-
],
|
|
68
|
-
),
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const isObject =
|
|
73
|
-
(checker: ts.TypeChecker) =>
|
|
74
|
-
(type: ts.Type): boolean =>
|
|
75
|
-
(type.getFlags() & ts.TypeFlags.Object) !== 0 &&
|
|
76
|
-
!(checker as any).isTupleType(type) &&
|
|
77
|
-
!(checker as any).isArrayType(type) &&
|
|
78
|
-
!(checker as any).isArrayLikeType(type);
|
|
79
|
-
|
|
80
|
-
const CLASSES: string[] = ["EncryptedRoute", "TypedRoute", "TypedQuery"];
|
|
81
|
-
const LIB_PATHS: string[] = CLASSES.map((cla) => [
|
|
82
|
-
path.join("@nestia", "core", "lib", "decorators", `${cla}.d.ts`),
|
|
83
|
-
path.join("packages", "core", "lib", "decorators", `${cla}.d.ts`),
|
|
84
|
-
]).flat();
|
|
85
|
-
}
|
|
1
|
+
import path from "path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
5
|
+
import { TypedQueryRouteProgrammer } from "../programmers/TypedQueryRouteProgrammer";
|
|
6
|
+
import { TypedRouteProgrammer } from "../programmers/TypedRouteProgrammer";
|
|
7
|
+
|
|
8
|
+
export namespace TypedRouteTransformer {
|
|
9
|
+
export const transform = (props: {
|
|
10
|
+
context: INestiaTransformContext;
|
|
11
|
+
decorator: ts.Decorator;
|
|
12
|
+
type: ts.Type;
|
|
13
|
+
}): ts.Decorator => {
|
|
14
|
+
if (!ts.isCallExpression(props.decorator.expression))
|
|
15
|
+
return props.decorator;
|
|
16
|
+
|
|
17
|
+
// CHECK SIGNATURE
|
|
18
|
+
const signature: ts.Signature | undefined =
|
|
19
|
+
props.context.checker.getResolvedSignature(props.decorator.expression);
|
|
20
|
+
if (!signature || !signature.declaration) return props.decorator;
|
|
21
|
+
|
|
22
|
+
// CHECK TO BE TRANSFORMED
|
|
23
|
+
const modulo = (() => {
|
|
24
|
+
// CHECK FILENAME
|
|
25
|
+
const location: string = path.resolve(
|
|
26
|
+
signature.declaration.getSourceFile().fileName,
|
|
27
|
+
);
|
|
28
|
+
if (LIB_PATHS.every((str) => location.indexOf(str) === -1)) return null;
|
|
29
|
+
|
|
30
|
+
// CHECK DUPLICATE BOOSTER
|
|
31
|
+
if (props.decorator.expression.arguments.length >= 2) return false;
|
|
32
|
+
else if (props.decorator.expression.arguments.length === 1) {
|
|
33
|
+
const last: ts.Expression =
|
|
34
|
+
props.decorator.expression.arguments[
|
|
35
|
+
props.decorator.expression.arguments.length - 1
|
|
36
|
+
];
|
|
37
|
+
const type: ts.Type = props.context.checker.getTypeAtLocation(last);
|
|
38
|
+
if (isObject(props.context.checker)(type)) return false;
|
|
39
|
+
}
|
|
40
|
+
return location.split(path.sep).at(-1)?.split(".")[0] === "TypedQuery"
|
|
41
|
+
? "TypedQuery"
|
|
42
|
+
: "TypedRoute";
|
|
43
|
+
})();
|
|
44
|
+
if (modulo === null) return props.decorator;
|
|
45
|
+
|
|
46
|
+
// CHECK TYPE NODE
|
|
47
|
+
const typeNode: ts.TypeNode | undefined =
|
|
48
|
+
props.context.checker.typeToTypeNode(props.type, undefined, undefined);
|
|
49
|
+
if (typeNode === undefined) return props.decorator;
|
|
50
|
+
|
|
51
|
+
// DO TRANSFORM
|
|
52
|
+
return ts.factory.createDecorator(
|
|
53
|
+
ts.factory.updateCallExpression(
|
|
54
|
+
props.decorator.expression,
|
|
55
|
+
props.decorator.expression.expression,
|
|
56
|
+
props.decorator.expression.typeArguments,
|
|
57
|
+
[
|
|
58
|
+
...props.decorator.expression.arguments,
|
|
59
|
+
(modulo === "TypedQuery"
|
|
60
|
+
? TypedQueryRouteProgrammer
|
|
61
|
+
: TypedRouteProgrammer
|
|
62
|
+
).generate({
|
|
63
|
+
context: props.context,
|
|
64
|
+
type: props.type,
|
|
65
|
+
modulo: props.decorator.expression.expression,
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const isObject =
|
|
73
|
+
(checker: ts.TypeChecker) =>
|
|
74
|
+
(type: ts.Type): boolean =>
|
|
75
|
+
(type.getFlags() & ts.TypeFlags.Object) !== 0 &&
|
|
76
|
+
!(checker as any).isTupleType(type) &&
|
|
77
|
+
!(checker as any).isArrayType(type) &&
|
|
78
|
+
!(checker as any).isArrayLikeType(type);
|
|
79
|
+
|
|
80
|
+
const CLASSES: string[] = ["EncryptedRoute", "TypedRoute", "TypedQuery"];
|
|
81
|
+
const LIB_PATHS: string[] = CLASSES.map((cla) => [
|
|
82
|
+
path.join("@nestia", "core", "lib", "decorators", `${cla}.d.ts`),
|
|
83
|
+
path.join("packages", "core", "lib", "decorators", `${cla}.d.ts`),
|
|
84
|
+
]).flat();
|
|
85
|
+
}
|
|
@@ -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
|
-
"lib",
|
|
118
|
-
"decorators",
|
|
119
|
-
`WebSocketRoute.d.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
|
+
"lib",
|
|
118
|
+
"decorators",
|
|
119
|
+
`WebSocketRoute.d.ts`,
|
|
120
|
+
);
|
package/src/typings/Creator.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type Creator<T extends object> = {
|
|
2
|
-
new (...args: any[]): T;
|
|
3
|
-
};
|
|
1
|
+
export type Creator<T extends object> = {
|
|
2
|
+
new (...args: any[]): T;
|
|
3
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare module "get-function-location" {
|
|
2
|
-
export default function (func: any): Promise<{
|
|
3
|
-
source: string;
|
|
4
|
-
line: number;
|
|
5
|
-
column: number;
|
|
6
|
-
}>;
|
|
7
|
-
}
|
|
1
|
+
declare module "get-function-location" {
|
|
2
|
+
export default function (func: any): Promise<{
|
|
3
|
+
source: string;
|
|
4
|
+
line: number;
|
|
5
|
+
column: number;
|
|
6
|
+
}>;
|
|
7
|
+
}
|
package/src/utils/ArrayUtil.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export namespace ArrayUtil {
|
|
2
|
-
export function has<T>(array: T[], ...items: T[]): boolean {
|
|
3
|
-
return items.every(
|
|
4
|
-
(elem) => array.find((org) => org === elem) !== undefined,
|
|
5
|
-
);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
export namespace ArrayUtil {
|
|
2
|
+
export function has<T>(array: T[], ...items: T[]): boolean {
|
|
3
|
+
return items.every(
|
|
4
|
+
(elem) => array.find((org) => org === elem) !== undefined,
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
}
|