@nestia/sdk 11.0.0-dev.20260313-4 → 11.0.0-dev.20260316
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/assets/bundle/distribute/package.json +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/executable/sdk.js +12 -12
- package/lib/transformers/TextPlainValidator.d.ts +3 -1
- package/lib/transformers/TextPlainValidator.js +6 -6
- package/lib/transformers/TextPlainValidator.js.map +1 -1
- package/lib/validators/HttpHeadersValidator.d.ts +4 -1
- package/lib/validators/HttpHeadersValidator.js +17 -13
- package/lib/validators/HttpHeadersValidator.js.map +1 -1
- package/lib/validators/HttpQueryValidator.d.ts +4 -1
- package/lib/validators/HttpQueryValidator.js +17 -13
- package/lib/validators/HttpQueryValidator.js.map +1 -1
- package/package.json +8 -8
- package/src/analyses/ConfigAnalyzer.ts +155 -155
- package/src/analyses/ExceptionAnalyzer.ts +154 -154
- package/src/analyses/GenericAnalyzer.ts +49 -49
- package/src/analyses/PathAnalyzer.ts +69 -69
- package/src/analyses/ReflectControllerAnalyzer.ts +105 -105
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +2 -2
- package/src/analyses/ReflectMetadataAnalyzer.ts +44 -44
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +172 -172
- package/src/analyses/SecurityAnalyzer.ts +25 -25
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +33 -33
- package/src/decorators/OperationMetadata.ts +15 -15
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/sdk.ts +75 -75
- package/src/generates/CloneGenerator.ts +66 -66
- package/src/generates/E2eGenerator.ts +32 -32
- package/src/generates/SdkGenerator.ts +160 -160
- package/src/generates/internal/SdkDistributionComposer.ts +103 -103
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +178 -178
- package/src/generates/internal/SdkRouteDirectory.ts +18 -18
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +87 -87
- package/src/generates/internal/SwaggerDescriptionComposer.ts +64 -64
- package/src/index.ts +4 -4
- package/src/structures/INestiaProject.ts +13 -13
- package/src/structures/INestiaSdkInput.ts +20 -20
- package/src/structures/IReflectApplication.ts +8 -8
- package/src/structures/IReflectController.ts +15 -15
- package/src/structures/IReflectHttpOperation.ts +26 -26
- package/src/structures/IReflectImport.ts +6 -6
- package/src/structures/IReflectOperationError.ts +26 -26
- package/src/structures/IReflectType.ts +4 -4
- package/src/structures/IReflectWebSocketOperation.ts +17 -17
- package/src/structures/IReflectWebSocketOperationParameter.ts +36 -36
- package/src/structures/ITypedHttpRoute.ts +41 -41
- package/src/structures/ITypedWebSocketRoute.ts +24 -24
- package/src/structures/ITypedWebSocketRouteParameter.ts +3 -3
- package/src/structures/MethodType.ts +5 -5
- package/src/structures/ParamCategory.ts +1 -1
- package/src/structures/TypeEntry.ts +22 -22
- package/src/transform.ts +9 -9
- package/src/transformers/TextPlainValidator.ts +6 -6
- package/src/typings/get-function-location.d.ts +7 -7
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PathUtil.ts +10 -10
- package/src/utils/SourceFinder.ts +63 -63
- package/src/utils/StringUtil.ts +17 -17
- package/src/utils/StripEnums.ts +5 -5
- package/src/utils/VersioningStrategy.ts +28 -28
- package/src/validators/HttpHeadersValidator.ts +20 -16
- package/src/validators/HttpQueryValidator.ts +20 -16
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { hash } from "tstl";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
export class TypeEntry {
|
|
5
|
-
public constructor(
|
|
6
|
-
public readonly type: ts.Type,
|
|
7
|
-
public readonly nullable: boolean,
|
|
8
|
-
public readonly required: boolean,
|
|
9
|
-
) {}
|
|
10
|
-
|
|
11
|
-
public equals(obj: TypeEntry): boolean {
|
|
12
|
-
return (
|
|
13
|
-
this.type === obj.type &&
|
|
14
|
-
this.nullable === obj.nullable &&
|
|
15
|
-
this.required === obj.required
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public hashCode(): number {
|
|
20
|
-
return hash(this.type, this.nullable, this.required);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
import { hash } from "tstl";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
export class TypeEntry {
|
|
5
|
+
public constructor(
|
|
6
|
+
public readonly type: ts.Type,
|
|
7
|
+
public readonly nullable: boolean,
|
|
8
|
+
public readonly required: boolean,
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
public equals(obj: TypeEntry): boolean {
|
|
12
|
+
return (
|
|
13
|
+
this.type === obj.type &&
|
|
14
|
+
this.nullable === obj.nullable &&
|
|
15
|
+
this.required === obj.required
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public hashCode(): number {
|
|
20
|
+
return hash(this.type, this.nullable, this.required);
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/transform.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { SdkOperationTransformer } from "./transformers/SdkOperationTransformer";
|
|
4
|
-
|
|
5
|
-
export const transform = (
|
|
6
|
-
program: ts.Program,
|
|
7
|
-
): ts.TransformerFactory<ts.SourceFile> =>
|
|
8
|
-
SdkOperationTransformer.iterateFile(program.getTypeChecker());
|
|
9
|
-
export default transform;
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { SdkOperationTransformer } from "./transformers/SdkOperationTransformer";
|
|
4
|
+
|
|
5
|
+
export const transform = (
|
|
6
|
+
program: ts.Program,
|
|
7
|
+
): ts.TransformerFactory<ts.SourceFile> =>
|
|
8
|
+
SdkOperationTransformer.iterateFile(program.getTypeChecker());
|
|
9
|
+
export default transform;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { MetadataSchema } from "@typia/core";
|
|
2
2
|
|
|
3
3
|
export namespace TextPlainValidator {
|
|
4
|
-
export const validate = (metadata: MetadataSchema): string[] => {
|
|
4
|
+
export const validate = (props: { metadata: MetadataSchema }): string[] => {
|
|
5
5
|
const expected: number =
|
|
6
|
-
metadata.atomics.filter((a) => a.type === "string").length +
|
|
7
|
-
metadata.constants
|
|
6
|
+
props.metadata.atomics.filter((a) => a.type === "string").length +
|
|
7
|
+
props.metadata.constants
|
|
8
8
|
.filter((c) => c.type === "string")
|
|
9
9
|
.map((c) => c.values.length)
|
|
10
10
|
.reduce((a, b) => a + b, 0) +
|
|
11
|
-
metadata.templates.length +
|
|
12
|
-
metadata.natives.filter((n) => n.name === "String").length;
|
|
13
|
-
if (metadata.size() === 0 || metadata.size() !== expected)
|
|
11
|
+
props.metadata.templates.length +
|
|
12
|
+
props.metadata.natives.filter((n) => n.name === "String").length;
|
|
13
|
+
if (props.metadata.size() === 0 || props.metadata.size() !== expected)
|
|
14
14
|
return [`Only string type is allowed in the "text/plain" content type.`];
|
|
15
15
|
return [];
|
|
16
16
|
};
|
|
@@ -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,26 +1,26 @@
|
|
|
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
|
-
|
|
8
|
-
export async function asyncMap<X, Y>(
|
|
9
|
-
array: X[],
|
|
10
|
-
closure: (input: X) => Promise<Y>,
|
|
11
|
-
): Promise<Y[]> {
|
|
12
|
-
const ret: Y[] = [];
|
|
13
|
-
for (const elem of array) ret.push(await closure(elem));
|
|
14
|
-
return ret;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function asyncFilter<T>(
|
|
18
|
-
array: T[],
|
|
19
|
-
closure: (input: T) => Promise<boolean>,
|
|
20
|
-
): Promise<T[]> {
|
|
21
|
-
const ret: T[] = [];
|
|
22
|
-
for (const elem of array)
|
|
23
|
-
if ((await closure(elem)) === true) ret.push(elem);
|
|
24
|
-
return ret;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
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
|
+
|
|
8
|
+
export async function asyncMap<X, Y>(
|
|
9
|
+
array: X[],
|
|
10
|
+
closure: (input: X) => Promise<Y>,
|
|
11
|
+
): Promise<Y[]> {
|
|
12
|
+
const ret: Y[] = [];
|
|
13
|
+
for (const elem of array) ret.push(await closure(elem));
|
|
14
|
+
return ret;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function asyncFilter<T>(
|
|
18
|
+
array: T[],
|
|
19
|
+
closure: (input: T) => Promise<boolean>,
|
|
20
|
+
): Promise<T[]> {
|
|
21
|
+
const ret: T[] = [];
|
|
22
|
+
for (const elem of array)
|
|
23
|
+
if ((await closure(elem)) === true) ret.push(elem);
|
|
24
|
+
return ret;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
export namespace FileRetriever {
|
|
5
|
-
export const directory =
|
|
6
|
-
(name: string) =>
|
|
7
|
-
(dir: string, depth: number = 0): string | null => {
|
|
8
|
-
const location: string = path.join(dir, name);
|
|
9
|
-
if (fs.existsSync(location)) return dir;
|
|
10
|
-
else if (depth > 2) return null;
|
|
11
|
-
return directory(name)(path.join(dir, ".."), depth + 1);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const file =
|
|
15
|
-
(name: string) =>
|
|
16
|
-
(directory: string, depth: number = 0): string | null => {
|
|
17
|
-
const location: string = path.join(directory, name);
|
|
18
|
-
if (fs.existsSync(location)) return location;
|
|
19
|
-
else if (depth > 2) return null;
|
|
20
|
-
return file(name)(path.join(directory, ".."), depth + 1);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export namespace FileRetriever {
|
|
5
|
+
export const directory =
|
|
6
|
+
(name: string) =>
|
|
7
|
+
(dir: string, depth: number = 0): string | null => {
|
|
8
|
+
const location: string = path.join(dir, name);
|
|
9
|
+
if (fs.existsSync(location)) return dir;
|
|
10
|
+
else if (depth > 2) return null;
|
|
11
|
+
return directory(name)(path.join(dir, ".."), depth + 1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const file =
|
|
15
|
+
(name: string) =>
|
|
16
|
+
(directory: string, depth: number = 0): string | null => {
|
|
17
|
+
const location: string = path.join(directory, name);
|
|
18
|
+
if (fs.existsSync(location)) return location;
|
|
19
|
+
else if (depth > 2) return null;
|
|
20
|
+
return file(name)(path.join(directory, ".."), depth + 1);
|
|
21
|
+
};
|
|
22
|
+
}
|
package/src/utils/MapUtil.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export namespace MapUtil {
|
|
2
|
-
export function take<Key, T>(
|
|
3
|
-
dict: Map<Key, T>,
|
|
4
|
-
key: Key,
|
|
5
|
-
generator: () => T,
|
|
6
|
-
): T {
|
|
7
|
-
const oldbie: T | undefined = dict.get(key);
|
|
8
|
-
if (oldbie) return oldbie;
|
|
9
|
-
|
|
10
|
-
const value: T = generator();
|
|
11
|
-
dict.set(key, value);
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
export namespace MapUtil {
|
|
2
|
+
export function take<Key, T>(
|
|
3
|
+
dict: Map<Key, T>,
|
|
4
|
+
key: Key,
|
|
5
|
+
generator: () => T,
|
|
6
|
+
): T {
|
|
7
|
+
const oldbie: T | undefined = dict.get(key);
|
|
8
|
+
if (oldbie) return oldbie;
|
|
9
|
+
|
|
10
|
+
const value: T = generator();
|
|
11
|
+
dict.set(key, value);
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/utils/PathUtil.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export namespace PathUtil {
|
|
2
|
-
export const accessors = (path: string) =>
|
|
3
|
-
path
|
|
4
|
-
.split("/")
|
|
5
|
-
.filter((str) => str.length && str[0] !== ":")
|
|
6
|
-
.map(normalize);
|
|
7
|
-
|
|
8
|
-
const normalize = (str: string) =>
|
|
9
|
-
str.split("-").join("_").split(".").join("_");
|
|
10
|
-
}
|
|
1
|
+
export namespace PathUtil {
|
|
2
|
+
export const accessors = (path: string) =>
|
|
3
|
+
path
|
|
4
|
+
.split("/")
|
|
5
|
+
.filter((str) => str.length && str[0] !== ":")
|
|
6
|
+
.map(normalize);
|
|
7
|
+
|
|
8
|
+
const normalize = (str: string) =>
|
|
9
|
+
str.split("-").join("_").split(".").join("_");
|
|
10
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { glob } from "glob";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
export namespace SourceFinder {
|
|
6
|
-
interface IProps {
|
|
7
|
-
exclude?: string[];
|
|
8
|
-
include: string[];
|
|
9
|
-
filter: (location: string) => Promise<boolean>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const find = async (props: IProps): Promise<string[]> => {
|
|
13
|
-
const dict: Set<string> = new Set();
|
|
14
|
-
|
|
15
|
-
await emplace(props.filter)(props.include)((str) => dict.add(str));
|
|
16
|
-
if (props.exclude?.length)
|
|
17
|
-
await emplace(props.filter)(props.exclude)((str) => dict.delete(str));
|
|
18
|
-
|
|
19
|
-
return [...dict];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const emplace =
|
|
23
|
-
(filter: (file: string) => Promise<boolean>) =>
|
|
24
|
-
(input: string[]) =>
|
|
25
|
-
async (closure: (location: string) => void): Promise<void> => {
|
|
26
|
-
for (const pattern of input) {
|
|
27
|
-
if (_Is_file(pattern)) {
|
|
28
|
-
closure(path.resolve(pattern));
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
for (const file of await _Glob(pattern)) {
|
|
32
|
-
const stats: fs.Stats = await fs.promises.stat(file);
|
|
33
|
-
if (stats.isDirectory() === true)
|
|
34
|
-
await iterate(filter)(closure)(file);
|
|
35
|
-
else if (stats.isFile() && (await filter(file))) closure(file);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const iterate =
|
|
41
|
-
(filter: (location: string) => Promise<boolean>) =>
|
|
42
|
-
(closure: (location: string) => void) =>
|
|
43
|
-
async (location: string): Promise<void> => {
|
|
44
|
-
const directory: string[] = await fs.promises.readdir(location);
|
|
45
|
-
for (const file of directory) {
|
|
46
|
-
const next: string = path.resolve(`${location}/${file}`);
|
|
47
|
-
const stats: fs.Stats = await fs.promises.stat(next);
|
|
48
|
-
|
|
49
|
-
if (stats.isDirectory() === true) await iterate(filter)(closure)(next);
|
|
50
|
-
else if (stats.isFile() && (await filter(next))) closure(next);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const _Glob = async (pattern: string): Promise<string[]> => {
|
|
55
|
-
const matches = await glob(pattern);
|
|
56
|
-
return matches.map((str) => path.resolve(str));
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const _Is_file = (pattern: string): boolean =>
|
|
60
|
-
pattern.endsWith(".ts") &&
|
|
61
|
-
!pattern.endsWith(".d.ts") &&
|
|
62
|
-
fs.existsSync(pattern);
|
|
63
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { glob } from "glob";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
export namespace SourceFinder {
|
|
6
|
+
interface IProps {
|
|
7
|
+
exclude?: string[];
|
|
8
|
+
include: string[];
|
|
9
|
+
filter: (location: string) => Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const find = async (props: IProps): Promise<string[]> => {
|
|
13
|
+
const dict: Set<string> = new Set();
|
|
14
|
+
|
|
15
|
+
await emplace(props.filter)(props.include)((str) => dict.add(str));
|
|
16
|
+
if (props.exclude?.length)
|
|
17
|
+
await emplace(props.filter)(props.exclude)((str) => dict.delete(str));
|
|
18
|
+
|
|
19
|
+
return [...dict];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const emplace =
|
|
23
|
+
(filter: (file: string) => Promise<boolean>) =>
|
|
24
|
+
(input: string[]) =>
|
|
25
|
+
async (closure: (location: string) => void): Promise<void> => {
|
|
26
|
+
for (const pattern of input) {
|
|
27
|
+
if (_Is_file(pattern)) {
|
|
28
|
+
closure(path.resolve(pattern));
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
for (const file of await _Glob(pattern)) {
|
|
32
|
+
const stats: fs.Stats = await fs.promises.stat(file);
|
|
33
|
+
if (stats.isDirectory() === true)
|
|
34
|
+
await iterate(filter)(closure)(file);
|
|
35
|
+
else if (stats.isFile() && (await filter(file))) closure(file);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const iterate =
|
|
41
|
+
(filter: (location: string) => Promise<boolean>) =>
|
|
42
|
+
(closure: (location: string) => void) =>
|
|
43
|
+
async (location: string): Promise<void> => {
|
|
44
|
+
const directory: string[] = await fs.promises.readdir(location);
|
|
45
|
+
for (const file of directory) {
|
|
46
|
+
const next: string = path.resolve(`${location}/${file}`);
|
|
47
|
+
const stats: fs.Stats = await fs.promises.stat(next);
|
|
48
|
+
|
|
49
|
+
if (stats.isDirectory() === true) await iterate(filter)(closure)(next);
|
|
50
|
+
else if (stats.isFile() && (await filter(next))) closure(next);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const _Glob = async (pattern: string): Promise<string[]> => {
|
|
55
|
+
const matches = await glob(pattern);
|
|
56
|
+
return matches.map((str) => path.resolve(str));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const _Is_file = (pattern: string): boolean =>
|
|
60
|
+
pattern.endsWith(".ts") &&
|
|
61
|
+
!pattern.endsWith(".d.ts") &&
|
|
62
|
+
fs.existsSync(pattern);
|
|
63
|
+
}
|
package/src/utils/StringUtil.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export namespace StringUtil {
|
|
2
|
-
export const capitalize = (text: string): string =>
|
|
3
|
-
text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
|
4
|
-
|
|
5
|
-
export const escapeDuplicate =
|
|
6
|
-
(keep: string[]) =>
|
|
7
|
-
(change: string): string =>
|
|
8
|
-
keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
|
|
9
|
-
|
|
10
|
-
export const isImplicit = (str: string) =>
|
|
11
|
-
str === "object" ||
|
|
12
|
-
str === "__type" ||
|
|
13
|
-
str === "__object" ||
|
|
14
|
-
str.startsWith("__type.") ||
|
|
15
|
-
str.startsWith("__object.") ||
|
|
16
|
-
str.includes("readonly [");
|
|
17
|
-
}
|
|
1
|
+
export namespace StringUtil {
|
|
2
|
+
export const capitalize = (text: string): string =>
|
|
3
|
+
text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
|
4
|
+
|
|
5
|
+
export const escapeDuplicate =
|
|
6
|
+
(keep: string[]) =>
|
|
7
|
+
(change: string): string =>
|
|
8
|
+
keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
|
|
9
|
+
|
|
10
|
+
export const isImplicit = (str: string) =>
|
|
11
|
+
str === "object" ||
|
|
12
|
+
str === "__type" ||
|
|
13
|
+
str === "__object" ||
|
|
14
|
+
str.startsWith("__type.") ||
|
|
15
|
+
str.startsWith("__object.") ||
|
|
16
|
+
str.includes("readonly [");
|
|
17
|
+
}
|
package/src/utils/StripEnums.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type StripEnums<T extends Record<string, any>> = {
|
|
2
|
-
[Key in keyof T]: T[Key] extends string | boolean | object | undefined | any[]
|
|
3
|
-
? T[Key]
|
|
4
|
-
: any;
|
|
5
|
-
};
|
|
1
|
+
export type StripEnums<T extends Record<string, any>> = {
|
|
2
|
+
[Key in keyof T]: T[Key] extends string | boolean | object | undefined | any[]
|
|
3
|
+
? T[Key]
|
|
4
|
+
: any;
|
|
5
|
+
};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
|
|
2
|
-
|
|
3
|
-
import { INestiaProject } from "../structures/INestiaProject";
|
|
4
|
-
|
|
5
|
-
export namespace VersioningStrategy {
|
|
6
|
-
export const cast = (
|
|
7
|
-
value: VersionValue | undefined,
|
|
8
|
-
): Array<string | typeof VERSION_NEUTRAL> =>
|
|
9
|
-
value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
10
|
-
|
|
11
|
-
export const merge =
|
|
12
|
-
(project: Omit<INestiaProject, "config">) =>
|
|
13
|
-
(values: Array<string | typeof VERSION_NEUTRAL>): string[] => {
|
|
14
|
-
if (project.input.versioning === undefined) return [""];
|
|
15
|
-
const set: Set<string | typeof VERSION_NEUTRAL> = new Set(values);
|
|
16
|
-
const array: Array<string | typeof VERSION_NEUTRAL> =
|
|
17
|
-
set.size === 0
|
|
18
|
-
? cast(project.input.versioning?.defaultVersion)
|
|
19
|
-
: Array.from(set);
|
|
20
|
-
return !!array?.length
|
|
21
|
-
? array.map((x) =>
|
|
22
|
-
typeof x === "symbol"
|
|
23
|
-
? ""
|
|
24
|
-
: `${project.input.versioning!.prefix}${x}`,
|
|
25
|
-
)
|
|
26
|
-
: [];
|
|
27
|
-
};
|
|
28
|
-
}
|
|
1
|
+
import { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
|
|
2
|
+
|
|
3
|
+
import { INestiaProject } from "../structures/INestiaProject";
|
|
4
|
+
|
|
5
|
+
export namespace VersioningStrategy {
|
|
6
|
+
export const cast = (
|
|
7
|
+
value: VersionValue | undefined,
|
|
8
|
+
): Array<string | typeof VERSION_NEUTRAL> =>
|
|
9
|
+
value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
10
|
+
|
|
11
|
+
export const merge =
|
|
12
|
+
(project: Omit<INestiaProject, "config">) =>
|
|
13
|
+
(values: Array<string | typeof VERSION_NEUTRAL>): string[] => {
|
|
14
|
+
if (project.input.versioning === undefined) return [""];
|
|
15
|
+
const set: Set<string | typeof VERSION_NEUTRAL> = new Set(values);
|
|
16
|
+
const array: Array<string | typeof VERSION_NEUTRAL> =
|
|
17
|
+
set.size === 0
|
|
18
|
+
? cast(project.input.versioning?.defaultVersion)
|
|
19
|
+
: Array.from(set);
|
|
20
|
+
return !!array?.length
|
|
21
|
+
? array.map((x) =>
|
|
22
|
+
typeof x === "symbol"
|
|
23
|
+
? ""
|
|
24
|
+
: `${project.input.versioning!.prefix}${x}`,
|
|
25
|
+
)
|
|
26
|
+
: [];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -5,30 +5,34 @@ import {
|
|
|
5
5
|
} from "@typia/core";
|
|
6
6
|
|
|
7
7
|
export namespace HttpHeadersValidator {
|
|
8
|
-
export const validate = (
|
|
9
|
-
|
|
10
|
-
explore: MetadataFactory.IExplore
|
|
11
|
-
): string[] => {
|
|
8
|
+
export const validate = (props: {
|
|
9
|
+
metadata: MetadataSchema;
|
|
10
|
+
explore: MetadataFactory.IExplore;
|
|
11
|
+
}): string[] => {
|
|
12
12
|
const errors: string[] = [];
|
|
13
13
|
const insert = (msg: string) => errors.push(msg);
|
|
14
14
|
|
|
15
|
-
if (explore.top === true) {
|
|
15
|
+
if (props.explore.top === true) {
|
|
16
16
|
const expected: number =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
props.metadata.atomics.length +
|
|
18
|
+
props.metadata.templates.length +
|
|
19
|
+
props.metadata.constants
|
|
20
|
+
.map((c) => c.values.length)
|
|
21
|
+
.reduce((a, b) => a + b, 0) +
|
|
22
|
+
props.metadata.arrays.length;
|
|
23
|
+
if (props.metadata.size() !== expected)
|
|
22
24
|
insert("Only atomic or array of atomic types are allowed.");
|
|
23
25
|
} else if (
|
|
24
|
-
explore.nested !== null &&
|
|
25
|
-
explore.nested instanceof MetadataArrayType
|
|
26
|
+
props.explore.nested !== null &&
|
|
27
|
+
props.explore.nested instanceof MetadataArrayType
|
|
26
28
|
) {
|
|
27
29
|
const expected: number =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
props.metadata.atomics.length +
|
|
31
|
+
props.metadata.templates.length +
|
|
32
|
+
props.metadata.constants
|
|
33
|
+
.map((c) => c.values.length)
|
|
34
|
+
.reduce((a, b) => a + b, 0);
|
|
35
|
+
if (props.metadata.size() !== expected)
|
|
32
36
|
insert("Only atomic types are allowed in array.");
|
|
33
37
|
}
|
|
34
38
|
return errors;
|
|
@@ -5,30 +5,34 @@ import {
|
|
|
5
5
|
} from "@typia/core";
|
|
6
6
|
|
|
7
7
|
export namespace HttpQueryValidator {
|
|
8
|
-
export const validate = (
|
|
9
|
-
|
|
10
|
-
explore: MetadataFactory.IExplore
|
|
11
|
-
): string[] => {
|
|
8
|
+
export const validate = (props: {
|
|
9
|
+
metadata: MetadataSchema;
|
|
10
|
+
explore: MetadataFactory.IExplore;
|
|
11
|
+
}): string[] => {
|
|
12
12
|
const errors: string[] = [];
|
|
13
13
|
const insert = (msg: string) => errors.push(msg);
|
|
14
14
|
|
|
15
|
-
if (explore.top === true) {
|
|
15
|
+
if (props.explore.top === true) {
|
|
16
16
|
const expected: number =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
props.metadata.atomics.length +
|
|
18
|
+
props.metadata.templates.length +
|
|
19
|
+
props.metadata.constants
|
|
20
|
+
.map((c) => c.values.length)
|
|
21
|
+
.reduce((a, b) => a + b, 0) +
|
|
22
|
+
props.metadata.arrays.length;
|
|
23
|
+
if (props.metadata.size() !== expected)
|
|
22
24
|
insert("Only atomic or array of atomic types are allowed.");
|
|
23
25
|
} else if (
|
|
24
|
-
explore.nested !== null &&
|
|
25
|
-
explore.nested instanceof MetadataArrayType
|
|
26
|
+
props.explore.nested !== null &&
|
|
27
|
+
props.explore.nested instanceof MetadataArrayType
|
|
26
28
|
) {
|
|
27
29
|
const expected: number =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
props.metadata.atomics.length +
|
|
31
|
+
props.metadata.templates.length +
|
|
32
|
+
props.metadata.constants
|
|
33
|
+
.map((c) => c.values.length)
|
|
34
|
+
.reduce((a, b) => a + b, 0);
|
|
35
|
+
if (props.metadata.size() !== expected)
|
|
32
36
|
insert("Only atomic types are allowed in array.");
|
|
33
37
|
}
|
|
34
38
|
return errors;
|