nestia 3.0.15 → 3.0.16-dev.20220930

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 (64) hide show
  1. package/lib/IConfiguration.d.ts +110 -110
  2. package/lib/IConfiguration.js +2 -2
  3. package/lib/NestiaApplication.d.ts +11 -11
  4. package/lib/NestiaApplication.js +155 -155
  5. package/lib/analyses/ControllerAnalyzer.d.ts +6 -6
  6. package/lib/analyses/ControllerAnalyzer.js +105 -105
  7. package/lib/analyses/GenericAnalyzer.d.ts +5 -5
  8. package/lib/analyses/GenericAnalyzer.js +40 -40
  9. package/lib/analyses/ImportAnalyzer.d.ts +13 -13
  10. package/lib/analyses/ImportAnalyzer.js +83 -83
  11. package/lib/analyses/PathAnalyzer.d.ts +5 -5
  12. package/lib/analyses/PathAnalyzer.js +50 -50
  13. package/lib/analyses/ReflectAnalyzer.d.ts +4 -4
  14. package/lib/analyses/ReflectAnalyzer.js +229 -229
  15. package/lib/analyses/SourceFinder.d.ts +4 -4
  16. package/lib/analyses/SourceFinder.js +69 -69
  17. package/lib/executable/internal/CompilerOptions.d.ts +11 -11
  18. package/lib/executable/internal/CompilerOptions.js +17 -17
  19. package/lib/executable/internal/NestiaCommand.d.ts +4 -4
  20. package/lib/executable/internal/NestiaCommand.js +127 -127
  21. package/lib/executable/internal/NestiaConfig.d.ts +4 -4
  22. package/lib/executable/internal/NestiaConfig.js +521 -521
  23. package/lib/executable/internal/nestia.config.getter.d.ts +1 -1
  24. package/lib/executable/internal/nestia.config.getter.js +23 -23
  25. package/lib/executable/nestia.d.ts +2 -2
  26. package/lib/executable/nestia.js +54 -54
  27. package/lib/generates/FileGenerator.d.ts +5 -5
  28. package/lib/generates/FileGenerator.js +136 -136
  29. package/lib/generates/FunctionGenerator.d.ts +5 -5
  30. package/lib/generates/FunctionGenerator.js +203 -203
  31. package/lib/generates/SdkGenerator.d.ts +7 -7
  32. package/lib/generates/SdkGenerator.js +46 -46
  33. package/lib/generates/SwaggerGenerator.d.ts +6 -6
  34. package/lib/generates/SwaggerGenerator.js +235 -235
  35. package/lib/index.d.ts +2 -2
  36. package/lib/index.js +27 -27
  37. package/lib/module.d.ts +2 -2
  38. package/lib/module.js +18 -18
  39. package/lib/structures/IController.d.ts +23 -23
  40. package/lib/structures/IController.js +2 -2
  41. package/lib/structures/IRoute.d.ts +24 -24
  42. package/lib/structures/IRoute.js +2 -2
  43. package/lib/structures/ISwagger.d.ts +48 -48
  44. package/lib/structures/ISwagger.js +2 -2
  45. package/lib/structures/ITypeTuple.d.ts +5 -5
  46. package/lib/structures/ITypeTuple.js +2 -2
  47. package/lib/structures/MethodType.d.ts +4 -4
  48. package/lib/structures/MethodType.js +13 -13
  49. package/lib/structures/ParamCategory.d.ts +1 -1
  50. package/lib/structures/ParamCategory.js +2 -2
  51. package/lib/structures/TypeEntry.d.ts +9 -9
  52. package/lib/structures/TypeEntry.js +20 -20
  53. package/lib/utils/ArrayUtil.d.ts +5 -5
  54. package/lib/utils/ArrayUtil.js +38 -38
  55. package/lib/utils/DirectoryUtil.d.ts +5 -5
  56. package/lib/utils/DirectoryUtil.js +61 -61
  57. package/lib/utils/ImportDictionary.d.ts +6 -6
  58. package/lib/utils/ImportDictionary.js +49 -49
  59. package/lib/utils/MapUtil.d.ts +3 -3
  60. package/lib/utils/MapUtil.js +15 -15
  61. package/lib/utils/StripEnums.d.ts +3 -3
  62. package/lib/utils/StripEnums.js +2 -2
  63. package/package.json +1 -1
  64. package/preliminaries/nestia.config.ts +70 -70
@@ -1,204 +1,204 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FunctionGenerator = void 0;
4
- const Escaper_1 = require("typescript-json/lib/utils/Escaper");
5
- const Pair_1 = require("tstl/utility/Pair");
6
- const Vector_1 = require("tstl/container/Vector");
7
- var FunctionGenerator;
8
- (function (FunctionGenerator) {
9
- function generate(config, route) {
10
- const query = route.parameters.find((param) => param.category === "query" && param.field === undefined);
11
- const input = route.parameters.find((param) => param.category === "body");
12
- return [head, body, tail]
13
- .map((closure) => closure(route, query, input, config))
14
- .filter((str) => !!str)
15
- .join("\n");
16
- }
17
- FunctionGenerator.generate = generate;
18
- /* ---------------------------------------------------------
19
- BODY
20
- --------------------------------------------------------- */
21
- function body(route, query, input, config) {
22
- // FETCH ARGUMENTS WITH REQUST BODY
23
- const parameters = filter_parameters(route, query);
24
- const fetchArguments = [
25
- "connection",
26
- `${route.name}.ENCRYPTED`,
27
- `${route.name}.METHOD`,
28
- `${route.name}.path(${parameters.map((p) => p.name).join(", ")})`,
29
- ];
30
- if (input !== undefined) {
31
- fetchArguments.push(input.name);
32
- if (config.json === true)
33
- fetchArguments.push(`${route.name}.stringify`);
34
- }
35
- const assertions = config.assert === true && route.parameters.length !== 0
36
- ? route.parameters
37
- .map((param) => ` TSON.assertType<typeof ${param.name}>(${param.name});`)
38
- .join("\n") + "\n\n"
39
- : "";
40
- // RETURNS WITH FINALIZATION
41
- return ("{\n" +
42
- assertions +
43
- " return Fetcher.fetch\n" +
44
- " (\n" +
45
- fetchArguments.map((param) => ` ${param}`).join(",\n") +
46
- "\n" +
47
- " );\n" +
48
- "}");
49
- }
50
- function filter_parameters(route, query) {
51
- const parameters = route.parameters.filter((param) => param.category === "param" ||
52
- (param.category === "query" && param.field !== undefined));
53
- if (query)
54
- parameters.push(query);
55
- return parameters;
56
- }
57
- /* ---------------------------------------------------------
58
- HEAD & TAIL
59
- --------------------------------------------------------- */
60
- function head(route, query, input, config) {
61
- //----
62
- // CONSTRUCT COMMENT
63
- //----
64
- // MAIN DESCRIPTION
65
- const comments = route.comments
66
- .map((part) => `${part.kind === "linkText" ? " " : ""}${part.text}`)
67
- .map((str) => str.split("\r\n").join("\n"))
68
- .join("")
69
- .split("\n")
70
- .filter((str, i, array) => str !== "" || i !== array.length - 1);
71
- if (comments.length)
72
- comments.push("");
73
- // FILTER TAGS (VULNERABLE PARAMETERS WOULD BE REMOVED)
74
- const tagList = route.tags.filter((tag) => tag.text !== undefined);
75
- if (tagList.length !== 0) {
76
- const index = tagList.findIndex((t) => t.name === "param");
77
- if (index !== -1) {
78
- const capsule = Vector_1.Vector.wrap(tagList);
79
- capsule.insert(capsule.nth(index), {
80
- name: "param",
81
- text: [
82
- {
83
- kind: "parameterName",
84
- text: "connection",
85
- },
86
- {
87
- kind: "space",
88
- text: " ",
89
- },
90
- {
91
- kind: "text",
92
- text: "connection Information of the remote HTTP(s) server with headers (+encryption password)",
93
- },
94
- ],
95
- });
96
- }
97
- comments.push(...tagList.map((tag) => `@${tag.name} ${tag
98
- .text.map((elem) => elem.text)
99
- .join("")}`), "");
100
- }
101
- // COMPLETE THE COMMENT
102
- comments.push(`@controller ${route.symbol}`, `@path ${route.method} ${route.path}`, `@nestia Generated by Nestia - https://github.com/samchon/nestia`);
103
- //----
104
- // FINALIZATION
105
- //----
106
- // REFORM PARAMETERS TEXT
107
- const parameters = [
108
- "connection: IConnection",
109
- ...route.parameters.map((param) => {
110
- const type = config.primitive !== false &&
111
- (param === query || param === input)
112
- ? `Primitive<${route.name}.${param === query ? "Query" : "Input"}>`
113
- : param.type.name;
114
- return `${param.name}: ${type}`;
115
- }),
116
- ];
117
- // OUTPUT TYPE
118
- const output = route.output.name === "void" ? "void" : `${route.name}.Output`;
119
- // RETURNS WITH CONSTRUCTION
120
- return ("" +
121
- "/**\n" +
122
- comments.map((str) => ` * ${str}`).join("\n") +
123
- "\n" +
124
- " */\n" +
125
- `export function ${route.name}\n` +
126
- ` (\n` +
127
- `${parameters.map((str) => ` ${str}`).join(",\n")}\n` +
128
- ` ): Promise<${output}>`);
129
- }
130
- function tail(route, query, input, config) {
131
- // LIST UP TYPES
132
- const types = [];
133
- if (query !== undefined)
134
- types.push(new Pair_1.Pair("Query", query.type.name));
135
- if (input !== undefined)
136
- types.push(new Pair_1.Pair("Input", input.type.name));
137
- if (route.output.name !== "void")
138
- types.push(new Pair_1.Pair("Output", route.output.name));
139
- // PATH WITH PARAMETERS
140
- const parameters = filter_parameters(route, query);
141
- const path = compute_path(query, parameters, route.path);
142
- return (`export namespace ${route.name}\n` +
143
- "{\n" +
144
- (types.length !== 0
145
- ? types
146
- .map((tuple) => ` export type ${tuple.first} = ${config.primitive !== false
147
- ? `Primitive<${tuple.second}>`
148
- : tuple.second};`)
149
- .join("\n") + "\n"
150
- : "") +
151
- "\n" +
152
- ` export const METHOD = "${route.method}" as const;\n` +
153
- ` export const PATH: string = "${route.path}";\n` +
154
- ` export const ENCRYPTED: Fetcher.IEncrypted = {\n` +
155
- ` request: ${input !== undefined && input.encrypted},\n` +
156
- ` response: ${route.encrypted},\n` +
157
- ` };\n` +
158
- "\n" +
159
- ` export function path(${parameters
160
- .map((param) => `${param.name}: ${param.type.name}`)
161
- .join(", ")}): string\n` +
162
- ` {\n` +
163
- ` return ${path};\n` +
164
- ` }\n` +
165
- (config.json === true &&
166
- (route.method === "POST" ||
167
- route.method === "PUT" ||
168
- route.method === "PATCH")
169
- ? ` export const stringify = (input: Input) => TSON.stringify(input);\n`
170
- : "") +
171
- "}");
172
- }
173
- function compute_path(query, parameters, path) {
174
- for (const param of parameters)
175
- if (param.category === "param")
176
- path = path.replace(`:${param.field}`, `\${encodeURIComponent(${param.name})}`);
177
- const queryParams = parameters.filter((param) => param.category === "query" && param.field !== undefined);
178
- if (query === undefined && queryParams.length === 0)
179
- return `\`${path}\``;
180
- const wrapper = (str) => `\`${path}?\${new URLSearchParams(${str}).toString()}\``;
181
- if (query !== undefined && queryParams.length === 0)
182
- return wrapper(`${query.name} as any`);
183
- else if (query === undefined)
184
- return wrapper(`
185
- {
186
- ${rest_query_parameters(queryParams)}
187
- } as any`);
188
- return wrapper(`
189
- {
190
- ...${query.name},
191
- ${rest_query_parameters(queryParams)},
192
- } as any`);
193
- }
194
- function rest_query_parameters(parameters) {
195
- return parameters
196
- .map((param) => param.name === param.field
197
- ? param.name
198
- : `${Escaper_1.Escaper.variable(param.field)
199
- ? param.field
200
- : JSON.stringify(param.field)}: ${param.name}`)
201
- .join(`,\n${" ".repeat(12)}`);
202
- }
203
- })(FunctionGenerator = exports.FunctionGenerator || (exports.FunctionGenerator = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FunctionGenerator = void 0;
4
+ const Escaper_1 = require("typescript-json/lib/utils/Escaper");
5
+ const Pair_1 = require("tstl/utility/Pair");
6
+ const Vector_1 = require("tstl/container/Vector");
7
+ var FunctionGenerator;
8
+ (function (FunctionGenerator) {
9
+ function generate(config, route) {
10
+ const query = route.parameters.find((param) => param.category === "query" && param.field === undefined);
11
+ const input = route.parameters.find((param) => param.category === "body");
12
+ return [head, body, tail]
13
+ .map((closure) => closure(route, query, input, config))
14
+ .filter((str) => !!str)
15
+ .join("\n");
16
+ }
17
+ FunctionGenerator.generate = generate;
18
+ /* ---------------------------------------------------------
19
+ BODY
20
+ --------------------------------------------------------- */
21
+ function body(route, query, input, config) {
22
+ // FETCH ARGUMENTS WITH REQUST BODY
23
+ const parameters = filter_parameters(route, query);
24
+ const fetchArguments = [
25
+ "connection",
26
+ `${route.name}.ENCRYPTED`,
27
+ `${route.name}.METHOD`,
28
+ `${route.name}.path(${parameters.map((p) => p.name).join(", ")})`,
29
+ ];
30
+ if (input !== undefined) {
31
+ fetchArguments.push(input.name);
32
+ if (config.json === true)
33
+ fetchArguments.push(`${route.name}.stringify`);
34
+ }
35
+ const assertions = config.assert === true && route.parameters.length !== 0
36
+ ? route.parameters
37
+ .map((param) => ` TSON.assertType<typeof ${param.name}>(${param.name});`)
38
+ .join("\n") + "\n\n"
39
+ : "";
40
+ // RETURNS WITH FINALIZATION
41
+ return ("{\n" +
42
+ assertions +
43
+ " return Fetcher.fetch\n" +
44
+ " (\n" +
45
+ fetchArguments.map((param) => ` ${param}`).join(",\n") +
46
+ "\n" +
47
+ " );\n" +
48
+ "}");
49
+ }
50
+ function filter_parameters(route, query) {
51
+ const parameters = route.parameters.filter((param) => param.category === "param" ||
52
+ (param.category === "query" && param.field !== undefined));
53
+ if (query)
54
+ parameters.push(query);
55
+ return parameters;
56
+ }
57
+ /* ---------------------------------------------------------
58
+ HEAD & TAIL
59
+ --------------------------------------------------------- */
60
+ function head(route, query, input, config) {
61
+ //----
62
+ // CONSTRUCT COMMENT
63
+ //----
64
+ // MAIN DESCRIPTION
65
+ const comments = route.comments
66
+ .map((part) => `${part.kind === "linkText" ? " " : ""}${part.text}`)
67
+ .map((str) => str.split("\r\n").join("\n"))
68
+ .join("")
69
+ .split("\n")
70
+ .filter((str, i, array) => str !== "" || i !== array.length - 1);
71
+ if (comments.length)
72
+ comments.push("");
73
+ // FILTER TAGS (VULNERABLE PARAMETERS WOULD BE REMOVED)
74
+ const tagList = route.tags.filter((tag) => tag.text !== undefined);
75
+ if (tagList.length !== 0) {
76
+ const index = tagList.findIndex((t) => t.name === "param");
77
+ if (index !== -1) {
78
+ const capsule = Vector_1.Vector.wrap(tagList);
79
+ capsule.insert(capsule.nth(index), {
80
+ name: "param",
81
+ text: [
82
+ {
83
+ kind: "parameterName",
84
+ text: "connection",
85
+ },
86
+ {
87
+ kind: "space",
88
+ text: " ",
89
+ },
90
+ {
91
+ kind: "text",
92
+ text: "connection Information of the remote HTTP(s) server with headers (+encryption password)",
93
+ },
94
+ ],
95
+ });
96
+ }
97
+ comments.push(...tagList.map((tag) => `@${tag.name} ${tag
98
+ .text.map((elem) => elem.text)
99
+ .join("")}`), "");
100
+ }
101
+ // COMPLETE THE COMMENT
102
+ comments.push(`@controller ${route.symbol}`, `@path ${route.method} ${route.path}`, `@nestia Generated by Nestia - https://github.com/samchon/nestia`);
103
+ //----
104
+ // FINALIZATION
105
+ //----
106
+ // REFORM PARAMETERS TEXT
107
+ const parameters = [
108
+ "connection: IConnection",
109
+ ...route.parameters.map((param) => {
110
+ const type = config.primitive !== false &&
111
+ (param === query || param === input)
112
+ ? `Primitive<${route.name}.${param === query ? "Query" : "Input"}>`
113
+ : param.type.name;
114
+ return `${param.name}: ${type}`;
115
+ }),
116
+ ];
117
+ // OUTPUT TYPE
118
+ const output = route.output.name === "void" ? "void" : `${route.name}.Output`;
119
+ // RETURNS WITH CONSTRUCTION
120
+ return ("" +
121
+ "/**\n" +
122
+ comments.map((str) => ` * ${str}`).join("\n") +
123
+ "\n" +
124
+ " */\n" +
125
+ `export function ${route.name}\n` +
126
+ ` (\n` +
127
+ `${parameters.map((str) => ` ${str}`).join(",\n")}\n` +
128
+ ` ): Promise<${output}>`);
129
+ }
130
+ function tail(route, query, input, config) {
131
+ // LIST UP TYPES
132
+ const types = [];
133
+ if (query !== undefined)
134
+ types.push(new Pair_1.Pair("Query", query.type.name));
135
+ if (input !== undefined)
136
+ types.push(new Pair_1.Pair("Input", input.type.name));
137
+ if (route.output.name !== "void")
138
+ types.push(new Pair_1.Pair("Output", route.output.name));
139
+ // PATH WITH PARAMETERS
140
+ const parameters = filter_parameters(route, query);
141
+ const path = compute_path(query, parameters, route.path);
142
+ return (`export namespace ${route.name}\n` +
143
+ "{\n" +
144
+ (types.length !== 0
145
+ ? types
146
+ .map((tuple) => ` export type ${tuple.first} = ${config.primitive !== false
147
+ ? `Primitive<${tuple.second}>`
148
+ : tuple.second};`)
149
+ .join("\n") + "\n"
150
+ : "") +
151
+ "\n" +
152
+ ` export const METHOD = "${route.method}" as const;\n` +
153
+ ` export const PATH: string = "${route.path}";\n` +
154
+ ` export const ENCRYPTED: Fetcher.IEncrypted = {\n` +
155
+ ` request: ${input !== undefined && input.encrypted},\n` +
156
+ ` response: ${route.encrypted},\n` +
157
+ ` };\n` +
158
+ "\n" +
159
+ ` export function path(${parameters
160
+ .map((param) => `${param.name}: ${param.type.name}`)
161
+ .join(", ")}): string\n` +
162
+ ` {\n` +
163
+ ` return ${path};\n` +
164
+ ` }\n` +
165
+ (config.json === true &&
166
+ (route.method === "POST" ||
167
+ route.method === "PUT" ||
168
+ route.method === "PATCH")
169
+ ? ` export const stringify = (input: Input) => TSON.stringify(input);\n`
170
+ : "") +
171
+ "}");
172
+ }
173
+ function compute_path(query, parameters, path) {
174
+ for (const param of parameters)
175
+ if (param.category === "param")
176
+ path = path.replace(`:${param.field}`, `\${encodeURIComponent(${param.name})}`);
177
+ const queryParams = parameters.filter((param) => param.category === "query" && param.field !== undefined);
178
+ if (query === undefined && queryParams.length === 0)
179
+ return `\`${path}\``;
180
+ const wrapper = (str) => `\`${path}?\${new URLSearchParams(${str}).toString()}\``;
181
+ if (query !== undefined && queryParams.length === 0)
182
+ return wrapper(`${query.name} as any`);
183
+ else if (query === undefined)
184
+ return wrapper(`
185
+ {
186
+ ${rest_query_parameters(queryParams)}
187
+ } as any`);
188
+ return wrapper(`
189
+ {
190
+ ...${query.name},
191
+ ${rest_query_parameters(queryParams)},
192
+ } as any`);
193
+ }
194
+ function rest_query_parameters(parameters) {
195
+ return parameters
196
+ .map((param) => param.name === param.field
197
+ ? param.name
198
+ : `${Escaper_1.Escaper.variable(param.field)
199
+ ? param.field
200
+ : JSON.stringify(param.field)}: ${param.name}`)
201
+ .join(`,\n${" ".repeat(12)}`);
202
+ }
203
+ })(FunctionGenerator = exports.FunctionGenerator || (exports.FunctionGenerator = {}));
204
204
  //# sourceMappingURL=FunctionGenerator.js.map
@@ -1,7 +1,7 @@
1
- import ts from "typescript";
2
- import { IRoute } from "../structures/IRoute";
3
- import { IConfiguration } from "../IConfiguration";
4
- export declare namespace SdkGenerator {
5
- function generate(_checker: ts.TypeChecker, config: IConfiguration, routeList: IRoute[]): Promise<void>;
6
- const BUNDLE_PATH: string;
7
- }
1
+ import ts from "typescript";
2
+ import { IRoute } from "../structures/IRoute";
3
+ import { IConfiguration } from "../IConfiguration";
4
+ export declare namespace SdkGenerator {
5
+ function generate(_checker: ts.TypeChecker, config: IConfiguration, routeList: IRoute[]): Promise<void>;
6
+ const BUNDLE_PATH: string;
7
+ }
@@ -1,47 +1,47 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.SdkGenerator = void 0;
16
- const fs_1 = __importDefault(require("fs"));
17
- const path_1 = __importDefault(require("path"));
18
- const DirectoryUtil_1 = require("../utils/DirectoryUtil");
19
- const FileGenerator_1 = require("./FileGenerator");
20
- var SdkGenerator;
21
- (function (SdkGenerator) {
22
- function generate(_checker, config, routeList) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- // PREPARE NEW DIRECTORIES
25
- try {
26
- yield fs_1.default.promises.mkdir(config.output);
27
- }
28
- catch (_a) { }
29
- // BUNDLING
30
- const bundle = yield fs_1.default.promises.readdir(SdkGenerator.BUNDLE_PATH);
31
- for (const file of bundle) {
32
- const current = `${SdkGenerator.BUNDLE_PATH}/${file}`;
33
- const stats = yield fs_1.default.promises.stat(current);
34
- if (stats.isFile() === true) {
35
- const content = yield fs_1.default.promises.readFile(current, "utf8");
36
- yield fs_1.default.promises.writeFile(`${config.output}/${file}`, content, "utf8");
37
- }
38
- }
39
- yield DirectoryUtil_1.DirectoryUtil.copy(SdkGenerator.BUNDLE_PATH + "/__internal", config.output + "/__internal");
40
- // FUNCTIONAL
41
- yield FileGenerator_1.FileGenerator.generate(config, routeList);
42
- });
43
- }
44
- SdkGenerator.generate = generate;
45
- SdkGenerator.BUNDLE_PATH = path_1.default.join(__dirname, "..", "..", "bundle");
46
- })(SdkGenerator = exports.SdkGenerator || (exports.SdkGenerator = {}));
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SdkGenerator = void 0;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const DirectoryUtil_1 = require("../utils/DirectoryUtil");
19
+ const FileGenerator_1 = require("./FileGenerator");
20
+ var SdkGenerator;
21
+ (function (SdkGenerator) {
22
+ function generate(_checker, config, routeList) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ // PREPARE NEW DIRECTORIES
25
+ try {
26
+ yield fs_1.default.promises.mkdir(config.output);
27
+ }
28
+ catch (_a) { }
29
+ // BUNDLING
30
+ const bundle = yield fs_1.default.promises.readdir(SdkGenerator.BUNDLE_PATH);
31
+ for (const file of bundle) {
32
+ const current = `${SdkGenerator.BUNDLE_PATH}/${file}`;
33
+ const stats = yield fs_1.default.promises.stat(current);
34
+ if (stats.isFile() === true) {
35
+ const content = yield fs_1.default.promises.readFile(current, "utf8");
36
+ yield fs_1.default.promises.writeFile(`${config.output}/${file}`, content, "utf8");
37
+ }
38
+ }
39
+ yield DirectoryUtil_1.DirectoryUtil.copy(SdkGenerator.BUNDLE_PATH + "/__internal", config.output + "/__internal");
40
+ // FUNCTIONAL
41
+ yield FileGenerator_1.FileGenerator.generate(config, routeList);
42
+ });
43
+ }
44
+ SdkGenerator.generate = generate;
45
+ SdkGenerator.BUNDLE_PATH = path_1.default.join(__dirname, "..", "..", "bundle");
46
+ })(SdkGenerator = exports.SdkGenerator || (exports.SdkGenerator = {}));
47
47
  //# sourceMappingURL=SdkGenerator.js.map
@@ -1,6 +1,6 @@
1
- import ts from "typescript";
2
- import { IConfiguration } from "../IConfiguration";
3
- import { IRoute } from "../structures/IRoute";
4
- export declare namespace SwaggerGenerator {
5
- function generate(checker: ts.TypeChecker, config: IConfiguration.ISwagger, routeList: IRoute[]): Promise<void>;
6
- }
1
+ import ts from "typescript";
2
+ import { IConfiguration } from "../IConfiguration";
3
+ import { IRoute } from "../structures/IRoute";
4
+ export declare namespace SwaggerGenerator {
5
+ function generate(checker: ts.TypeChecker, config: IConfiguration.ISwagger, routeList: IRoute[]): Promise<void>;
6
+ }