@nestia/sdk 3.1.0-dev.20240426 → 3.1.0-dev.20240430

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 (58) hide show
  1. package/lib/analyses/TypedWebSocketOperationAnalyzer.js +1 -1
  2. package/lib/analyses/TypedWebSocketOperationAnalyzer.js.map +1 -1
  3. package/lib/executable/sdk.js +11 -11
  4. package/lib/generates/SwaggerGenerator.js +1 -1
  5. package/lib/generates/SwaggerGenerator.js.map +1 -1
  6. package/lib/generates/internal/SdkHttpFunctionProgrammer.js +18 -20
  7. package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
  8. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +30 -1
  9. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
  10. package/lib/structures/ITypedWebSocketRoute.d.ts +1 -0
  11. package/package.json +4 -4
  12. package/src/NestiaSdkApplication.ts +257 -257
  13. package/src/analyses/AccessorAnalyzer.ts +67 -67
  14. package/src/analyses/ConfigAnalyzer.ts +147 -147
  15. package/src/analyses/GenericAnalyzer.ts +51 -51
  16. package/src/analyses/PathAnalyzer.ts +69 -69
  17. package/src/analyses/SecurityAnalyzer.ts +25 -25
  18. package/src/analyses/TypedWebSocketOperationAnalyzer.ts +1 -0
  19. package/src/executable/internal/CommandParser.ts +15 -15
  20. package/src/executable/internal/NestiaConfigLoader.ts +67 -67
  21. package/src/executable/internal/NestiaSdkCommand.ts +60 -60
  22. package/src/executable/sdk.ts +73 -73
  23. package/src/generates/CloneGenerator.ts +64 -64
  24. package/src/generates/E2eGenerator.ts +64 -64
  25. package/src/generates/SdkGenerator.ts +91 -91
  26. package/src/generates/SwaggerGenerator.ts +1 -1
  27. package/src/generates/internal/E2eFileProgrammer.ts +178 -178
  28. package/src/generates/internal/FilePrinter.ts +53 -53
  29. package/src/generates/internal/SdkAliasCollection.ts +157 -157
  30. package/src/generates/internal/SdkDistributionComposer.ts +100 -100
  31. package/src/generates/internal/SdkFileProgrammer.ts +119 -119
  32. package/src/generates/internal/SdkHttpCloneProgrammer.ts +154 -154
  33. package/src/generates/internal/SdkHttpFunctionProgrammer.ts +298 -299
  34. package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +505 -505
  35. package/src/generates/internal/SdkHttpRouteProgrammer.ts +82 -82
  36. package/src/generates/internal/SdkHttpSimulationProgrammer.ts +363 -363
  37. package/src/generates/internal/SdkImportWizard.ts +55 -55
  38. package/src/generates/internal/SdkRouteDirectory.ts +18 -18
  39. package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +42 -1
  40. package/src/generates/internal/SwaggerSchemaValidator.ts +198 -198
  41. package/src/index.ts +4 -4
  42. package/src/module.ts +2 -2
  43. package/src/structures/IErrorReport.ts +6 -6
  44. package/src/structures/INestiaProject.ts +13 -13
  45. package/src/structures/INormalizedInput.ts +20 -20
  46. package/src/structures/IReflectController.ts +17 -17
  47. package/src/structures/ITypeTuple.ts +6 -6
  48. package/src/structures/ITypedHttpRoute.ts +55 -55
  49. package/src/structures/ITypedWebSocketRoute.ts +1 -0
  50. package/src/structures/MethodType.ts +5 -5
  51. package/src/structures/ParamCategory.ts +1 -1
  52. package/src/utils/ArrayUtil.ts +26 -26
  53. package/src/utils/FileRetriever.ts +22 -22
  54. package/src/utils/MapUtil.ts +14 -14
  55. package/src/utils/PathUtil.ts +10 -10
  56. package/src/utils/SourceFinder.ts +66 -66
  57. package/src/utils/StringUtil.ts +6 -6
  58. package/src/utils/StripEnums.ts +5 -5
@@ -1,20 +1,20 @@
1
- import { RouteInfo, VersionValue } from "@nestjs/common/interfaces";
2
-
3
- export interface INormalizedInput {
4
- include: INormalizedInput.IInput[];
5
- globalPrefix?: {
6
- prefix: string;
7
- exclude?: Array<string | RouteInfo>;
8
- };
9
- versioning?: {
10
- prefix: string;
11
- defaultVersion?: VersionValue;
12
- };
13
- }
14
- export namespace INormalizedInput {
15
- export interface IInput {
16
- paths: string[];
17
- file: string;
18
- controller?: Function;
19
- }
20
- }
1
+ import { RouteInfo, VersionValue } from "@nestjs/common/interfaces";
2
+
3
+ export interface INormalizedInput {
4
+ include: INormalizedInput.IInput[];
5
+ globalPrefix?: {
6
+ prefix: string;
7
+ exclude?: Array<string | RouteInfo>;
8
+ };
9
+ versioning?: {
10
+ prefix: string;
11
+ defaultVersion?: VersionValue;
12
+ };
13
+ }
14
+ export namespace INormalizedInput {
15
+ export interface IInput {
16
+ paths: string[];
17
+ file: string;
18
+ controller?: Function;
19
+ }
20
+ }
@@ -1,17 +1,17 @@
1
- import type { VERSION_NEUTRAL } from "@nestjs/common/interfaces";
2
-
3
- import { IReflectHttpOperation } from "./IReflectHttpOperation";
4
- import { IReflectWebSocketOperation } from "./IReflectWebSocketOperation";
5
-
6
- export interface IReflectController {
7
- constructor: Function;
8
- prototype: any;
9
- file: string;
10
- name: string;
11
- prefixes: string[];
12
- paths: string[];
13
- versions: Array<string | typeof VERSION_NEUTRAL> | undefined;
14
- operations: Array<IReflectHttpOperation | IReflectWebSocketOperation>;
15
- security: Record<string, string[]>[];
16
- swaggerTgas: string[];
17
- }
1
+ import type { VERSION_NEUTRAL } from "@nestjs/common/interfaces";
2
+
3
+ import { IReflectHttpOperation } from "./IReflectHttpOperation";
4
+ import { IReflectWebSocketOperation } from "./IReflectWebSocketOperation";
5
+
6
+ export interface IReflectController {
7
+ constructor: Function;
8
+ prototype: any;
9
+ file: string;
10
+ name: string;
11
+ prefixes: string[];
12
+ paths: string[];
13
+ versions: Array<string | typeof VERSION_NEUTRAL> | undefined;
14
+ operations: Array<IReflectHttpOperation | IReflectWebSocketOperation>;
15
+ security: Record<string, string[]>[];
16
+ swaggerTgas: string[];
17
+ }
@@ -1,6 +1,6 @@
1
- import ts from "typescript";
2
-
3
- export interface ITypeTuple {
4
- type: ts.Type;
5
- typeName: string;
6
- }
1
+ import ts from "typescript";
2
+
3
+ export interface ITypeTuple {
4
+ type: ts.Type;
5
+ typeName: string;
6
+ }
@@ -1,55 +1,55 @@
1
- import ts from "typescript";
2
- import { Metadata } from "typia/lib/schemas/metadata/Metadata";
3
-
4
- import { IReflectController } from "./IReflectController";
5
- import { IReflectHttpOperation } from "./IReflectHttpOperation";
6
-
7
- export interface ITypedHttpRoute {
8
- protocol: "http";
9
- controller: IReflectController;
10
- function: Function;
11
- name: string;
12
- method: string;
13
- path: string;
14
- encrypted: boolean;
15
- status?: number;
16
-
17
- accessors: string[];
18
- parameters: ITypedHttpRoute.IParameter[];
19
- imports: [string, string[]][];
20
- output: ITypedHttpRoute.IOutput;
21
-
22
- location: string;
23
- description?: string;
24
- operationId?: string;
25
- jsDocTags: ts.JSDocTagInfo[];
26
- setHeaders: Array<
27
- | { type: "setter"; source: string; target?: string }
28
- | { type: "assigner"; source: string }
29
- >;
30
- security: Record<string, string[]>[];
31
- exceptions: Record<
32
- number | "2XX" | "3XX" | "4XX" | "5XX",
33
- ITypedHttpRoute.IOutput
34
- >;
35
- swaggerTags: string[];
36
- }
37
-
38
- export namespace ITypedHttpRoute {
39
- export type IParameter = IReflectHttpOperation.IParameter & {
40
- optional: boolean;
41
- type: ts.Type;
42
- typeName: string;
43
- metadata?: Metadata;
44
- };
45
- export interface IOutput {
46
- type: ts.Type;
47
- typeName: string;
48
- metadata?: Metadata;
49
- description?: string;
50
- contentType:
51
- | "application/x-www-form-urlencoded"
52
- | "application/json"
53
- | "text/plain";
54
- }
55
- }
1
+ import ts from "typescript";
2
+ import { Metadata } from "typia/lib/schemas/metadata/Metadata";
3
+
4
+ import { IReflectController } from "./IReflectController";
5
+ import { IReflectHttpOperation } from "./IReflectHttpOperation";
6
+
7
+ export interface ITypedHttpRoute {
8
+ protocol: "http";
9
+ controller: IReflectController;
10
+ function: Function;
11
+ name: string;
12
+ method: string;
13
+ path: string;
14
+ encrypted: boolean;
15
+ status?: number;
16
+
17
+ accessors: string[];
18
+ parameters: ITypedHttpRoute.IParameter[];
19
+ imports: [string, string[]][];
20
+ output: ITypedHttpRoute.IOutput;
21
+
22
+ location: string;
23
+ description?: string;
24
+ operationId?: string;
25
+ jsDocTags: ts.JSDocTagInfo[];
26
+ setHeaders: Array<
27
+ | { type: "setter"; source: string; target?: string }
28
+ | { type: "assigner"; source: string }
29
+ >;
30
+ security: Record<string, string[]>[];
31
+ exceptions: Record<
32
+ number | "2XX" | "3XX" | "4XX" | "5XX",
33
+ ITypedHttpRoute.IOutput
34
+ >;
35
+ swaggerTags: string[];
36
+ }
37
+
38
+ export namespace ITypedHttpRoute {
39
+ export type IParameter = IReflectHttpOperation.IParameter & {
40
+ optional: boolean;
41
+ type: ts.Type;
42
+ typeName: string;
43
+ metadata?: Metadata;
44
+ };
45
+ export interface IOutput {
46
+ type: ts.Type;
47
+ typeName: string;
48
+ metadata?: Metadata;
49
+ description?: string;
50
+ contentType:
51
+ | "application/x-www-form-urlencoded"
52
+ | "application/json"
53
+ | "text/plain";
54
+ }
55
+ }
@@ -17,6 +17,7 @@ export interface ITypedWebSocketRoute {
17
17
 
18
18
  location: string;
19
19
  description?: string;
20
+ jsDocTags: ts.JSDocTagInfo[];
20
21
  }
21
22
  export namespace ITypedWebSocketRoute {
22
23
  export type IParameter =
@@ -1,5 +1,5 @@
1
- export type MethodType = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2
-
3
- export namespace MethodType {
4
- export const VALUES: MethodType[] = ["GET", "POST", "PUT", "PATCH", "DELETE"];
5
- }
1
+ export type MethodType = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2
+
3
+ export namespace MethodType {
4
+ export const VALUES: MethodType[] = ["GET", "POST", "PUT", "PATCH", "DELETE"];
5
+ }
@@ -1 +1 @@
1
- export type ParamCategory = "param" | "query" | "body" | "rawBody" | "headers";
1
+ export type ParamCategory = "param" | "query" | "body" | "rawBody" | "headers";
@@ -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<Input, Output>(
9
- array: Input[],
10
- closure: (input: Input) => Promise<Output>,
11
- ): Promise<Output[]> {
12
- const ret: Output[] = [];
13
- for (const elem of array) ret.push(await closure(elem));
14
- return ret;
15
- }
16
-
17
- export async function asyncFilter<Input>(
18
- array: Input[],
19
- closure: (input: Input) => Promise<boolean>,
20
- ): Promise<Input[]> {
21
- const ret: Input[] = [];
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<Input, Output>(
9
+ array: Input[],
10
+ closure: (input: Input) => Promise<Output>,
11
+ ): Promise<Output[]> {
12
+ const ret: Output[] = [];
13
+ for (const elem of array) ret.push(await closure(elem));
14
+ return ret;
15
+ }
16
+
17
+ export async function asyncFilter<Input>(
18
+ array: Input[],
19
+ closure: (input: Input) => Promise<boolean>,
20
+ ): Promise<Input[]> {
21
+ const ret: Input[] = [];
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
+ }
@@ -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
+ }
@@ -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,66 +1,66 @@
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 = (pattern: string): Promise<string[]> =>
55
- new Promise((resolve, reject) => {
56
- glob(pattern, (err, matches) => {
57
- if (err) reject(err);
58
- else resolve(matches.map((str) => path.resolve(str)));
59
- });
60
- });
61
-
62
- const _Is_file = (pattern: string): boolean =>
63
- pattern.endsWith(".ts") &&
64
- !pattern.endsWith(".d.ts") &&
65
- fs.existsSync(pattern);
66
- }
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 = (pattern: string): Promise<string[]> =>
55
+ new Promise((resolve, reject) => {
56
+ glob(pattern, (err, matches) => {
57
+ if (err) reject(err);
58
+ else resolve(matches.map((str) => path.resolve(str)));
59
+ });
60
+ });
61
+
62
+ const _Is_file = (pattern: string): boolean =>
63
+ pattern.endsWith(".ts") &&
64
+ !pattern.endsWith(".d.ts") &&
65
+ fs.existsSync(pattern);
66
+ }
@@ -1,6 +1,6 @@
1
- export namespace StringUtil {
2
- export const escapeDuplicate =
3
- (keep: string[]) =>
4
- (change: string): string =>
5
- keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
6
- }
1
+ export namespace StringUtil {
2
+ export const escapeDuplicate =
3
+ (keep: string[]) =>
4
+ (change: string): string =>
5
+ keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
6
+ }
@@ -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
+ };