@nestia/sdk 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/assets/bundle/distribute/package.json +1 -1
- package/lib/INestiaConfig.d.ts +2 -2
- package/lib/NestiaSwaggerComposer.d.ts +1 -2
- package/lib/NestiaSwaggerComposer.js +6 -2
- package/lib/NestiaSwaggerComposer.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.js +8 -63
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/sdk.js +12 -12
- package/lib/generates/SwaggerGenerator.js +6 -5
- package/lib/generates/SwaggerGenerator.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/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/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
|
@@ -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,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
|
+
}
|