@nestia/sdk 2.5.0-dev.20240131 → 2.5.0-dev.20240201

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 (65) hide show
  1. package/lib/executable/sdk.js +11 -11
  2. package/lib/generates/SdkGenerator.js +0 -8
  3. package/lib/generates/SdkGenerator.js.map +1 -1
  4. package/lib/generates/internal/SdkAliasCollection.js +5 -4
  5. package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
  6. package/lib/generates/internal/SdkFileProgrammer.js +0 -7
  7. package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
  8. package/lib/generates/internal/SdkFunctionProgrammer.d.ts +1 -1
  9. package/lib/generates/internal/SdkFunctionProgrammer.js +3 -3
  10. package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
  11. package/lib/generates/internal/SdkNamespaceProgrammer.js +1 -1
  12. package/lib/generates/internal/SdkNamespaceProgrammer.js.map +1 -1
  13. package/lib/generates/internal/SdkRouteProgrammer.js +2 -2
  14. package/lib/generates/internal/SdkRouteProgrammer.js.map +1 -1
  15. package/lib/generates/internal/SdkSimulationProgrammer.js +3 -3
  16. package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
  17. package/package.json +3 -3
  18. package/src/analyses/AccessorAnalyzer.ts +60 -60
  19. package/src/analyses/ConfigAnalyzer.ts +147 -147
  20. package/src/analyses/GenericAnalyzer.ts +51 -51
  21. package/src/analyses/ImportAnalyzer.ts +138 -138
  22. package/src/analyses/PathAnalyzer.ts +110 -110
  23. package/src/analyses/ReflectAnalyzer.ts +464 -464
  24. package/src/analyses/SecurityAnalyzer.ts +20 -20
  25. package/src/executable/internal/CommandParser.ts +15 -15
  26. package/src/executable/internal/NestiaConfigLoader.ts +67 -67
  27. package/src/executable/internal/NestiaSdkCommand.ts +60 -60
  28. package/src/executable/sdk.ts +73 -73
  29. package/src/generates/SdkGenerator.ts +0 -12
  30. package/src/generates/internal/SdkAliasCollection.ts +4 -3
  31. package/src/generates/internal/SdkDistributionComposer.ts +91 -91
  32. package/src/generates/internal/SdkFileProgrammer.ts +0 -9
  33. package/src/generates/internal/SdkFunctionProgrammer.ts +3 -3
  34. package/src/generates/internal/SdkImportWizard.ts +55 -55
  35. package/src/generates/internal/SdkNamespaceProgrammer.ts +1 -1
  36. package/src/generates/internal/SdkRouteDirectory.ts +17 -17
  37. package/src/generates/internal/SdkRouteProgrammer.ts +2 -2
  38. package/src/generates/internal/SdkSimulationProgrammer.ts +3 -3
  39. package/src/generates/internal/SwaggerSchemaGenerator.ts +444 -444
  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/IController.ts +91 -91
  44. package/src/structures/IErrorReport.ts +6 -6
  45. package/src/structures/INestiaProject.ts +13 -13
  46. package/src/structures/INormalizedInput.ts +20 -20
  47. package/src/structures/IRoute.ts +52 -52
  48. package/src/structures/ISwaggerComponents.ts +29 -29
  49. package/src/structures/ISwaggerError.ts +8 -8
  50. package/src/structures/ISwaggerInfo.ts +80 -80
  51. package/src/structures/ISwaggerLazyProperty.ts +7 -7
  52. package/src/structures/ISwaggerLazySchema.ts +7 -7
  53. package/src/structures/ISwaggerRoute.ts +51 -51
  54. package/src/structures/ISwaggerSecurityScheme.ts +65 -65
  55. package/src/structures/ITypeTuple.ts +6 -6
  56. package/src/structures/MethodType.ts +5 -5
  57. package/src/structures/ParamCategory.ts +1 -1
  58. package/src/structures/TypeEntry.ts +22 -22
  59. package/src/utils/ArrayUtil.ts +26 -26
  60. package/src/utils/FileRetriever.ts +22 -22
  61. package/src/utils/MapUtil.ts +14 -14
  62. package/src/utils/PathUtil.ts +10 -10
  63. package/src/utils/SourceFinder.ts +66 -66
  64. package/src/utils/StripEnums.ts +5 -5
  65. package/assets/bundle/api/utils/NestiaSimulator.ts +0 -70
@@ -1,110 +1,110 @@
1
- import { RequestMethod } from "@nestjs/common";
2
- import path from "path";
3
- import { Token, parse } from "path-to-regexp";
4
-
5
- import { INormalizedInput } from "../structures/INormalizedInput";
6
-
7
- export namespace PathAnalyzer {
8
- export const combinate =
9
- (globalPrefix: INormalizedInput["globalPrefix"]) =>
10
- (versions: Array<string | null>) =>
11
- (props: { path: string; method: string }): string[] => {
12
- const out = (str: string) =>
13
- versions.map((v) => (v === null ? str : join(v, str)));
14
- if (!globalPrefix?.prefix.length) return out(props.path);
15
- else if (!globalPrefix.exclude?.length)
16
- return out(props.path).map((str) => join(globalPrefix.prefix, str));
17
- return globalPrefix.exclude.some((exclude) =>
18
- typeof exclude === "string"
19
- ? RegExp(exclude).test(props.path)
20
- : METHOD(exclude.method) === props.method &&
21
- RegExp(exclude.path).test(props.path),
22
- )
23
- ? out(props.path)
24
- : out(props.path).map((str) => join(globalPrefix.prefix, str));
25
- };
26
-
27
- export const join = (...args: string[]) =>
28
- "/" +
29
- _Trim(
30
- path
31
- .join(...args.filter((s) => !!s.length))
32
- .split("\\")
33
- .join("/"),
34
- );
35
-
36
- export const escape = (str: string): string | null => {
37
- const args = _Parse(str);
38
- if (args === null) return null;
39
- return (
40
- "/" +
41
- args
42
- .map((arg) => (arg.type === "param" ? `:${arg.value}` : arg.value))
43
- .join("/")
44
- );
45
- };
46
-
47
- export const parameters = (str: string): string[] | null => {
48
- const args = _Parse(str);
49
- if (args === null) return null;
50
- return args.filter((arg) => arg.type === "param").map((arg) => arg.value);
51
- };
52
-
53
- function _Parse(str: string): IArgument[] | null {
54
- const tokens: Token[] | null = (() => {
55
- try {
56
- return parse(path.join(str).split("\\").join("/"));
57
- } catch {
58
- return null;
59
- }
60
- })();
61
- if (tokens === null) return null;
62
-
63
- const output: IArgument[] = [];
64
- for (const key of tokens) {
65
- if (typeof key === "string")
66
- output.push({
67
- type: "path",
68
- value: _Trim(key),
69
- });
70
- else if (typeof key.name === "number" || _Trim(key.name) === "")
71
- return null;
72
- else
73
- output.push({
74
- type: "param",
75
- value: _Trim(key.name),
76
- });
77
- }
78
- return output;
79
- }
80
-
81
- function _Trim(str: string): string {
82
- if (str[0] === "/") str = str.substring(1);
83
- if (str[str.length - 1] === "/") str = str.substring(0, str.length - 1);
84
- return str;
85
- }
86
-
87
- interface IArgument {
88
- type: "param" | "path";
89
- value: string;
90
- }
91
- }
92
-
93
- const METHOD = (value: RequestMethod) =>
94
- value === RequestMethod.ALL
95
- ? "all"
96
- : value === RequestMethod.DELETE
97
- ? "delete"
98
- : value === RequestMethod.GET
99
- ? "get"
100
- : value === RequestMethod.HEAD
101
- ? "head"
102
- : value === RequestMethod.OPTIONS
103
- ? "options"
104
- : value === RequestMethod.PATCH
105
- ? "patch"
106
- : value === RequestMethod.POST
107
- ? "post"
108
- : value === RequestMethod.PUT
109
- ? "put"
110
- : "unknown";
1
+ import { RequestMethod } from "@nestjs/common";
2
+ import path from "path";
3
+ import { Token, parse } from "path-to-regexp";
4
+
5
+ import { INormalizedInput } from "../structures/INormalizedInput";
6
+
7
+ export namespace PathAnalyzer {
8
+ export const combinate =
9
+ (globalPrefix: INormalizedInput["globalPrefix"]) =>
10
+ (versions: Array<string | null>) =>
11
+ (props: { path: string; method: string }): string[] => {
12
+ const out = (str: string) =>
13
+ versions.map((v) => (v === null ? str : join(v, str)));
14
+ if (!globalPrefix?.prefix.length) return out(props.path);
15
+ else if (!globalPrefix.exclude?.length)
16
+ return out(props.path).map((str) => join(globalPrefix.prefix, str));
17
+ return globalPrefix.exclude.some((exclude) =>
18
+ typeof exclude === "string"
19
+ ? RegExp(exclude).test(props.path)
20
+ : METHOD(exclude.method) === props.method &&
21
+ RegExp(exclude.path).test(props.path),
22
+ )
23
+ ? out(props.path)
24
+ : out(props.path).map((str) => join(globalPrefix.prefix, str));
25
+ };
26
+
27
+ export const join = (...args: string[]) =>
28
+ "/" +
29
+ _Trim(
30
+ path
31
+ .join(...args.filter((s) => !!s.length))
32
+ .split("\\")
33
+ .join("/"),
34
+ );
35
+
36
+ export const escape = (str: string): string | null => {
37
+ const args = _Parse(str);
38
+ if (args === null) return null;
39
+ return (
40
+ "/" +
41
+ args
42
+ .map((arg) => (arg.type === "param" ? `:${arg.value}` : arg.value))
43
+ .join("/")
44
+ );
45
+ };
46
+
47
+ export const parameters = (str: string): string[] | null => {
48
+ const args = _Parse(str);
49
+ if (args === null) return null;
50
+ return args.filter((arg) => arg.type === "param").map((arg) => arg.value);
51
+ };
52
+
53
+ function _Parse(str: string): IArgument[] | null {
54
+ const tokens: Token[] | null = (() => {
55
+ try {
56
+ return parse(path.join(str).split("\\").join("/"));
57
+ } catch {
58
+ return null;
59
+ }
60
+ })();
61
+ if (tokens === null) return null;
62
+
63
+ const output: IArgument[] = [];
64
+ for (const key of tokens) {
65
+ if (typeof key === "string")
66
+ output.push({
67
+ type: "path",
68
+ value: _Trim(key),
69
+ });
70
+ else if (typeof key.name === "number" || _Trim(key.name) === "")
71
+ return null;
72
+ else
73
+ output.push({
74
+ type: "param",
75
+ value: _Trim(key.name),
76
+ });
77
+ }
78
+ return output;
79
+ }
80
+
81
+ function _Trim(str: string): string {
82
+ if (str[0] === "/") str = str.substring(1);
83
+ if (str[str.length - 1] === "/") str = str.substring(0, str.length - 1);
84
+ return str;
85
+ }
86
+
87
+ interface IArgument {
88
+ type: "param" | "path";
89
+ value: string;
90
+ }
91
+ }
92
+
93
+ const METHOD = (value: RequestMethod) =>
94
+ value === RequestMethod.ALL
95
+ ? "all"
96
+ : value === RequestMethod.DELETE
97
+ ? "delete"
98
+ : value === RequestMethod.GET
99
+ ? "get"
100
+ : value === RequestMethod.HEAD
101
+ ? "head"
102
+ : value === RequestMethod.OPTIONS
103
+ ? "options"
104
+ : value === RequestMethod.PATCH
105
+ ? "patch"
106
+ : value === RequestMethod.POST
107
+ ? "post"
108
+ : value === RequestMethod.PUT
109
+ ? "put"
110
+ : "unknown";