@nestia/core 11.0.0-dev.20260312 → 11.0.0-dev.20260313
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/package.json +8 -8
- package/src/decorators/DynamicModule.ts +44 -44
- package/src/decorators/PlainBody.ts +76 -76
- package/src/decorators/SwaggerExample.ts +100 -100
- package/src/decorators/TypedBody.ts +57 -57
- package/src/decorators/TypedException.ts +147 -147
- package/src/decorators/TypedHeaders.ts +66 -66
- package/src/decorators/TypedParam.ts +77 -77
- package/src/decorators/TypedQuery.ts +234 -234
- package/src/decorators/WebSocketRoute.ts +242 -242
- package/src/decorators/internal/EncryptedConstant.ts +2 -2
- 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 +94 -94
- package/src/decorators/internal/get_path_and_stringify.ts +110 -110
- package/src/decorators/internal/get_text_body.ts +16 -16
- package/src/decorators/internal/is_request_body_undefined.ts +12 -12
- package/src/decorators/internal/load_controller.ts +45 -45
- package/src/decorators/internal/route_error.ts +43 -43
- package/src/decorators/internal/validate_request_body.ts +64 -64
- package/src/decorators/internal/validate_request_form_data.ts +67 -67
- package/src/decorators/internal/validate_request_headers.ts +76 -76
- package/src/decorators/internal/validate_request_query.ts +64 -64
- package/src/index.ts +5 -5
- 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/transformers/NodeTransformer.ts +23 -23
- package/src/transformers/ParameterTransformer.ts +57 -57
- 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 +115 -115
- package/src/utils/Singleton.ts +16 -16
- package/src/utils/SourceFinder.ts +54 -54
- package/src/utils/VersioningStrategy.ts +27 -27
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { glob } from "glob";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
export namespace SourceFinder {
|
|
6
|
-
export const find = async (props: IProps): Promise<string[]> => {
|
|
7
|
-
const dict: Set<string> = new Set();
|
|
8
|
-
|
|
9
|
-
await emplace(props.filter)(props.include)((str) => dict.add(str));
|
|
10
|
-
if (props.exclude?.length)
|
|
11
|
-
await emplace(props.filter)(props.exclude)((str) => dict.delete(str));
|
|
12
|
-
|
|
13
|
-
return [...dict];
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const emplace =
|
|
17
|
-
(filter: (file: string) => boolean) =>
|
|
18
|
-
(input: string[]) =>
|
|
19
|
-
async (closure: (location: string) => void): Promise<void> => {
|
|
20
|
-
for (const pattern of input) {
|
|
21
|
-
for (const file of await _Glob(path.resolve(pattern))) {
|
|
22
|
-
const stats: fs.Stats = await fs.promises.stat(file);
|
|
23
|
-
if (stats.isDirectory() === true)
|
|
24
|
-
await iterate(filter)(closure)(file);
|
|
25
|
-
else if (stats.isFile() && filter(file)) closure(file);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const iterate =
|
|
31
|
-
(filter: (location: string) => boolean) =>
|
|
32
|
-
(closure: (location: string) => void) =>
|
|
33
|
-
async (location: string): Promise<void> => {
|
|
34
|
-
const directory: string[] = await fs.promises.readdir(location);
|
|
35
|
-
for (const file of directory) {
|
|
36
|
-
const next: string = path.resolve(`${location}/${file}`);
|
|
37
|
-
const stats: fs.Stats = await fs.promises.stat(next);
|
|
38
|
-
|
|
39
|
-
if (stats.isDirectory() === true) await iterate(filter)(closure)(next);
|
|
40
|
-
else if (stats.isFile() && filter(next)) closure(next);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const _Glob = async (pattern: string): Promise<string[]> => {
|
|
45
|
-
const matches = await glob(pattern);
|
|
46
|
-
return matches.map((str) => path.resolve(str));
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface IProps {
|
|
51
|
-
exclude?: string[];
|
|
52
|
-
include: string[];
|
|
53
|
-
filter: (location: string) => boolean;
|
|
54
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { glob } from "glob";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
export namespace SourceFinder {
|
|
6
|
+
export const find = async (props: IProps): Promise<string[]> => {
|
|
7
|
+
const dict: Set<string> = new Set();
|
|
8
|
+
|
|
9
|
+
await emplace(props.filter)(props.include)((str) => dict.add(str));
|
|
10
|
+
if (props.exclude?.length)
|
|
11
|
+
await emplace(props.filter)(props.exclude)((str) => dict.delete(str));
|
|
12
|
+
|
|
13
|
+
return [...dict];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const emplace =
|
|
17
|
+
(filter: (file: string) => boolean) =>
|
|
18
|
+
(input: string[]) =>
|
|
19
|
+
async (closure: (location: string) => void): Promise<void> => {
|
|
20
|
+
for (const pattern of input) {
|
|
21
|
+
for (const file of await _Glob(path.resolve(pattern))) {
|
|
22
|
+
const stats: fs.Stats = await fs.promises.stat(file);
|
|
23
|
+
if (stats.isDirectory() === true)
|
|
24
|
+
await iterate(filter)(closure)(file);
|
|
25
|
+
else if (stats.isFile() && filter(file)) closure(file);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const iterate =
|
|
31
|
+
(filter: (location: string) => boolean) =>
|
|
32
|
+
(closure: (location: string) => void) =>
|
|
33
|
+
async (location: string): Promise<void> => {
|
|
34
|
+
const directory: string[] = await fs.promises.readdir(location);
|
|
35
|
+
for (const file of directory) {
|
|
36
|
+
const next: string = path.resolve(`${location}/${file}`);
|
|
37
|
+
const stats: fs.Stats = await fs.promises.stat(next);
|
|
38
|
+
|
|
39
|
+
if (stats.isDirectory() === true) await iterate(filter)(closure)(next);
|
|
40
|
+
else if (stats.isFile() && filter(next)) closure(next);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const _Glob = async (pattern: string): Promise<string[]> => {
|
|
45
|
+
const matches = await glob(pattern);
|
|
46
|
+
return matches.map((str) => path.resolve(str));
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface IProps {
|
|
51
|
+
exclude?: string[];
|
|
52
|
+
include: string[];
|
|
53
|
+
filter: (location: string) => boolean;
|
|
54
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
|
|
2
|
-
|
|
3
|
-
export namespace VersioningStrategy {
|
|
4
|
-
export interface IConfig {
|
|
5
|
-
prefix: string;
|
|
6
|
-
defaultVersion?: VersionValue;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const cast = (
|
|
10
|
-
value: VersionValue | undefined,
|
|
11
|
-
): Array<string | typeof VERSION_NEUTRAL> =>
|
|
12
|
-
value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
13
|
-
|
|
14
|
-
export const merge =
|
|
15
|
-
(config: IConfig | undefined) =>
|
|
16
|
-
(values: Array<string | typeof VERSION_NEUTRAL>): string[] => {
|
|
17
|
-
if (config === undefined) return [""];
|
|
18
|
-
const set: Set<string | typeof VERSION_NEUTRAL> = new Set(values);
|
|
19
|
-
const array: Array<string | typeof VERSION_NEUTRAL> =
|
|
20
|
-
set.size === 0 ? cast(config.defaultVersion) : Array.from(set);
|
|
21
|
-
return !!array?.length
|
|
22
|
-
? array.map((x) =>
|
|
23
|
-
typeof x === "symbol" ? "" : `${config.prefix}${x}`,
|
|
24
|
-
)
|
|
25
|
-
: [];
|
|
26
|
-
};
|
|
27
|
-
}
|
|
1
|
+
import { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
|
|
2
|
+
|
|
3
|
+
export namespace VersioningStrategy {
|
|
4
|
+
export interface IConfig {
|
|
5
|
+
prefix: string;
|
|
6
|
+
defaultVersion?: VersionValue;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const cast = (
|
|
10
|
+
value: VersionValue | undefined,
|
|
11
|
+
): Array<string | typeof VERSION_NEUTRAL> =>
|
|
12
|
+
value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
13
|
+
|
|
14
|
+
export const merge =
|
|
15
|
+
(config: IConfig | undefined) =>
|
|
16
|
+
(values: Array<string | typeof VERSION_NEUTRAL>): string[] => {
|
|
17
|
+
if (config === undefined) return [""];
|
|
18
|
+
const set: Set<string | typeof VERSION_NEUTRAL> = new Set(values);
|
|
19
|
+
const array: Array<string | typeof VERSION_NEUTRAL> =
|
|
20
|
+
set.size === 0 ? cast(config.defaultVersion) : Array.from(set);
|
|
21
|
+
return !!array?.length
|
|
22
|
+
? array.map((x) =>
|
|
23
|
+
typeof x === "symbol" ? "" : `${config.prefix}${x}`,
|
|
24
|
+
)
|
|
25
|
+
: [];
|
|
26
|
+
};
|
|
27
|
+
}
|