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,230 +1,230 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.ReflectAnalyzer = void 0;
36
- const module_1 = require("tstl/ranges/module");
37
- const ArrayUtil_1 = require("../utils/ArrayUtil");
38
- const PathAnalyzer_1 = require("./PathAnalyzer");
39
- var ReflectAnalyzer;
40
- (function (ReflectAnalyzer) {
41
- function analyze(unique, file) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const module = yield Promise.resolve().then(() => __importStar(require(file)));
44
- const ret = [];
45
- for (const tuple of Object.entries(module)) {
46
- if (unique.has(tuple[1]))
47
- continue;
48
- else
49
- unique.add(tuple[1]);
50
- const controller = _Analyze_controller(file, ...tuple);
51
- if (controller !== null)
52
- ret.push(controller);
53
- }
54
- return ret;
55
- });
56
- }
57
- ReflectAnalyzer.analyze = analyze;
58
- /* ---------------------------------------------------------
59
- CONTROLLER
60
- --------------------------------------------------------- */
61
- function _Analyze_controller(file, name, creator) {
62
- //----
63
- // VALIDATIONS
64
- //----
65
- // MUST BE TYPE OF A CREATOR WHO HAS THE CONSTRUCTOR
66
- if (!(creator instanceof Function &&
67
- creator.constructor instanceof Function))
68
- return null;
69
- // MUST HAVE THOSE MATADATA
70
- else if (ArrayUtil_1.ArrayUtil.has(Reflect.getMetadataKeys(creator), "path", "host", "scope:options") === false)
71
- return null;
72
- //----
73
- // CONSTRUCTION
74
- //----
75
- // BASIC INFO
76
- const paths = _Get_paths(Reflect.getMetadata("path", creator));
77
- const meta = {
78
- file,
79
- name,
80
- paths,
81
- functions: [],
82
- };
83
- // PARSE CHILDREN DATA
84
- for (const tuple of _Get_prototype_entries(creator)) {
85
- const child = _Analyze_function(creator.prototype, meta, ...tuple);
86
- if (child !== null)
87
- meta.functions.push(child);
88
- }
89
- // RETURNS
90
- return meta;
91
- }
92
- function _Get_prototype_entries(creator) {
93
- const keyList = Object.getOwnPropertyNames(creator.prototype);
94
- const entries = keyList.map((key) => [
95
- key,
96
- creator.prototype[key],
97
- ]);
98
- const parent = Object.getPrototypeOf(creator);
99
- if (parent.prototype !== undefined)
100
- entries.push(..._Get_prototype_entries(parent));
101
- return entries;
102
- }
103
- function _Get_paths(value) {
104
- if (typeof value === "string")
105
- return [value];
106
- else if (value.length === 0)
107
- return [""];
108
- else
109
- return value;
110
- }
111
- /* ---------------------------------------------------------
112
- FUNCTION
113
- --------------------------------------------------------- */
114
- function _Analyze_function(classProto, controller, name, proto) {
115
- var _a, _b;
116
- //----
117
- // VALIDATIONS
118
- //----
119
- // MUST BE TYPE OF A FUNCTION
120
- if (!(proto instanceof Function))
121
- return null;
122
- // MUST HAVE THOSE METADATE
123
- else if (ArrayUtil_1.ArrayUtil.has(Reflect.getMetadataKeys(proto), "path", "method") ===
124
- false)
125
- return null;
126
- //----
127
- // CONSTRUCTION
128
- //----
129
- // BASIC INFO
130
- const meta = {
131
- name,
132
- method: METHODS[Reflect.getMetadata("method", proto)],
133
- paths: _Get_paths(Reflect.getMetadata("path", proto)),
134
- parameters: [],
135
- encrypted: Reflect.hasMetadata("__interceptors__", proto) &&
136
- ((_b = (_a = Reflect.getMetadata("__interceptors__", proto)[0]) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) === "EncryptedRouteInterceptor",
137
- };
138
- // PARSE CHILDREN DATA
139
- const nestParameters = Reflect.getMetadata("__routeArguments__", classProto.constructor, name);
140
- if (nestParameters === undefined)
141
- meta.parameters = [];
142
- else {
143
- for (const tuple of Object.entries(nestParameters)) {
144
- const child = _Analyze_parameter(...tuple);
145
- if (child !== null)
146
- meta.parameters.push(child);
147
- }
148
- meta.parameters = meta.parameters.sort((x, y) => x.index - y.index);
149
- }
150
- // VALIDATE PATH ARGUMENTS
151
- for (const controllerLocation of controller.paths)
152
- for (const metaLocation of meta.paths) {
153
- // NORMALIZE LOCATION
154
- const location = PathAnalyzer_1.PathAnalyzer.join(controllerLocation, metaLocation);
155
- // LIST UP PARAMETERS
156
- const binded = PathAnalyzer_1.PathAnalyzer.parameters(location, () => `${controller.name}.${name}()`).sort();
157
- const parameters = meta.parameters
158
- .filter((param) => param.category === "param")
159
- .map((param) => param.field)
160
- .sort();
161
- // DO VALIDATE
162
- if ((0, module_1.equal)(binded, parameters) === false)
163
- throw new Error(`Error on ${controller.name}.${name}(): binded arguments in the "path" between function's decorator and parameters' decorators are different (function: [${binded.join(", ")}], parameters: [${parameters.join(", ")}])`);
164
- }
165
- // RETURNS
166
- return meta;
167
- }
168
- const METHODS = ["GET", "POST", "PUT", "DELETE", "PATCH"];
169
- /* ---------------------------------------------------------
170
- PARAMETER
171
- --------------------------------------------------------- */
172
- function _Analyze_parameter(key, param) {
173
- const symbol = key.split(":")[0];
174
- if (symbol.indexOf("__custom") !== -1)
175
- return _Analyze_custom_parameter(param);
176
- const typeIndex = Number(symbol[0]);
177
- if (isNaN(typeIndex) === true)
178
- return null;
179
- const type = NEST_PARAMETER_TYPES[typeIndex];
180
- if (type === undefined)
181
- return null;
182
- return {
183
- name: key,
184
- category: type,
185
- index: param.index,
186
- field: param.data,
187
- encrypted: false,
188
- };
189
- }
190
- function _Analyze_custom_parameter(param) {
191
- if (param.factory === undefined)
192
- return null;
193
- else if (param.factory.name === "TypedBody" ||
194
- param.factory.name === "EncryptedBody" ||
195
- param.factory.name === "PlainBody") {
196
- return {
197
- category: "body",
198
- index: param.index,
199
- name: param.name,
200
- field: param.data,
201
- encrypted: param.factory.name === "EncryptedBody",
202
- };
203
- }
204
- else if (param.factory.name === "TypedParam")
205
- return {
206
- name: param.name,
207
- category: "param",
208
- index: param.index,
209
- field: param.data,
210
- encrypted: false,
211
- };
212
- else
213
- return null;
214
- }
215
- const NEST_PARAMETER_TYPES = [
216
- undefined,
217
- undefined,
218
- undefined,
219
- "body",
220
- "query",
221
- "param",
222
- undefined,
223
- undefined,
224
- undefined,
225
- undefined,
226
- undefined,
227
- undefined,
228
- ];
229
- })(ReflectAnalyzer = exports.ReflectAnalyzer || (exports.ReflectAnalyzer = {}));
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.ReflectAnalyzer = void 0;
36
+ const module_1 = require("tstl/ranges/module");
37
+ const ArrayUtil_1 = require("../utils/ArrayUtil");
38
+ const PathAnalyzer_1 = require("./PathAnalyzer");
39
+ var ReflectAnalyzer;
40
+ (function (ReflectAnalyzer) {
41
+ function analyze(unique, file) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const module = yield Promise.resolve().then(() => __importStar(require(file)));
44
+ const ret = [];
45
+ for (const tuple of Object.entries(module)) {
46
+ if (unique.has(tuple[1]))
47
+ continue;
48
+ else
49
+ unique.add(tuple[1]);
50
+ const controller = _Analyze_controller(file, ...tuple);
51
+ if (controller !== null)
52
+ ret.push(controller);
53
+ }
54
+ return ret;
55
+ });
56
+ }
57
+ ReflectAnalyzer.analyze = analyze;
58
+ /* ---------------------------------------------------------
59
+ CONTROLLER
60
+ --------------------------------------------------------- */
61
+ function _Analyze_controller(file, name, creator) {
62
+ //----
63
+ // VALIDATIONS
64
+ //----
65
+ // MUST BE TYPE OF A CREATOR WHO HAS THE CONSTRUCTOR
66
+ if (!(creator instanceof Function &&
67
+ creator.constructor instanceof Function))
68
+ return null;
69
+ // MUST HAVE THOSE MATADATA
70
+ else if (ArrayUtil_1.ArrayUtil.has(Reflect.getMetadataKeys(creator), "path", "host", "scope:options") === false)
71
+ return null;
72
+ //----
73
+ // CONSTRUCTION
74
+ //----
75
+ // BASIC INFO
76
+ const paths = _Get_paths(Reflect.getMetadata("path", creator));
77
+ const meta = {
78
+ file,
79
+ name,
80
+ paths,
81
+ functions: [],
82
+ };
83
+ // PARSE CHILDREN DATA
84
+ for (const tuple of _Get_prototype_entries(creator)) {
85
+ const child = _Analyze_function(creator.prototype, meta, ...tuple);
86
+ if (child !== null)
87
+ meta.functions.push(child);
88
+ }
89
+ // RETURNS
90
+ return meta;
91
+ }
92
+ function _Get_prototype_entries(creator) {
93
+ const keyList = Object.getOwnPropertyNames(creator.prototype);
94
+ const entries = keyList.map((key) => [
95
+ key,
96
+ creator.prototype[key],
97
+ ]);
98
+ const parent = Object.getPrototypeOf(creator);
99
+ if (parent.prototype !== undefined)
100
+ entries.push(..._Get_prototype_entries(parent));
101
+ return entries;
102
+ }
103
+ function _Get_paths(value) {
104
+ if (typeof value === "string")
105
+ return [value];
106
+ else if (value.length === 0)
107
+ return [""];
108
+ else
109
+ return value;
110
+ }
111
+ /* ---------------------------------------------------------
112
+ FUNCTION
113
+ --------------------------------------------------------- */
114
+ function _Analyze_function(classProto, controller, name, proto) {
115
+ var _a, _b;
116
+ //----
117
+ // VALIDATIONS
118
+ //----
119
+ // MUST BE TYPE OF A FUNCTION
120
+ if (!(proto instanceof Function))
121
+ return null;
122
+ // MUST HAVE THOSE METADATE
123
+ else if (ArrayUtil_1.ArrayUtil.has(Reflect.getMetadataKeys(proto), "path", "method") ===
124
+ false)
125
+ return null;
126
+ //----
127
+ // CONSTRUCTION
128
+ //----
129
+ // BASIC INFO
130
+ const meta = {
131
+ name,
132
+ method: METHODS[Reflect.getMetadata("method", proto)],
133
+ paths: _Get_paths(Reflect.getMetadata("path", proto)),
134
+ parameters: [],
135
+ encrypted: Reflect.hasMetadata("__interceptors__", proto) &&
136
+ ((_b = (_a = Reflect.getMetadata("__interceptors__", proto)[0]) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) === "EncryptedRouteInterceptor",
137
+ };
138
+ // PARSE CHILDREN DATA
139
+ const nestParameters = Reflect.getMetadata("__routeArguments__", classProto.constructor, name);
140
+ if (nestParameters === undefined)
141
+ meta.parameters = [];
142
+ else {
143
+ for (const tuple of Object.entries(nestParameters)) {
144
+ const child = _Analyze_parameter(...tuple);
145
+ if (child !== null)
146
+ meta.parameters.push(child);
147
+ }
148
+ meta.parameters = meta.parameters.sort((x, y) => x.index - y.index);
149
+ }
150
+ // VALIDATE PATH ARGUMENTS
151
+ for (const controllerLocation of controller.paths)
152
+ for (const metaLocation of meta.paths) {
153
+ // NORMALIZE LOCATION
154
+ const location = PathAnalyzer_1.PathAnalyzer.join(controllerLocation, metaLocation);
155
+ // LIST UP PARAMETERS
156
+ const binded = PathAnalyzer_1.PathAnalyzer.parameters(location, () => `${controller.name}.${name}()`).sort();
157
+ const parameters = meta.parameters
158
+ .filter((param) => param.category === "param")
159
+ .map((param) => param.field)
160
+ .sort();
161
+ // DO VALIDATE
162
+ if ((0, module_1.equal)(binded, parameters) === false)
163
+ throw new Error(`Error on ${controller.name}.${name}(): binded arguments in the "path" between function's decorator and parameters' decorators are different (function: [${binded.join(", ")}], parameters: [${parameters.join(", ")}])`);
164
+ }
165
+ // RETURNS
166
+ return meta;
167
+ }
168
+ const METHODS = ["GET", "POST", "PUT", "DELETE", "PATCH"];
169
+ /* ---------------------------------------------------------
170
+ PARAMETER
171
+ --------------------------------------------------------- */
172
+ function _Analyze_parameter(key, param) {
173
+ const symbol = key.split(":")[0];
174
+ if (symbol.indexOf("__custom") !== -1)
175
+ return _Analyze_custom_parameter(param);
176
+ const typeIndex = Number(symbol[0]);
177
+ if (isNaN(typeIndex) === true)
178
+ return null;
179
+ const type = NEST_PARAMETER_TYPES[typeIndex];
180
+ if (type === undefined)
181
+ return null;
182
+ return {
183
+ name: key,
184
+ category: type,
185
+ index: param.index,
186
+ field: param.data,
187
+ encrypted: false,
188
+ };
189
+ }
190
+ function _Analyze_custom_parameter(param) {
191
+ if (param.factory === undefined)
192
+ return null;
193
+ else if (param.factory.name === "TypedBody" ||
194
+ param.factory.name === "EncryptedBody" ||
195
+ param.factory.name === "PlainBody") {
196
+ return {
197
+ category: "body",
198
+ index: param.index,
199
+ name: param.name,
200
+ field: param.data,
201
+ encrypted: param.factory.name === "EncryptedBody",
202
+ };
203
+ }
204
+ else if (param.factory.name === "TypedParam")
205
+ return {
206
+ name: param.name,
207
+ category: "param",
208
+ index: param.index,
209
+ field: param.data,
210
+ encrypted: false,
211
+ };
212
+ else
213
+ return null;
214
+ }
215
+ const NEST_PARAMETER_TYPES = [
216
+ undefined,
217
+ undefined,
218
+ undefined,
219
+ "body",
220
+ "query",
221
+ "param",
222
+ undefined,
223
+ undefined,
224
+ undefined,
225
+ undefined,
226
+ undefined,
227
+ undefined,
228
+ ];
229
+ })(ReflectAnalyzer = exports.ReflectAnalyzer || (exports.ReflectAnalyzer = {}));
230
230
  //# sourceMappingURL=ReflectAnalyzer.js.map
@@ -1,4 +1,4 @@
1
- import { IConfiguration } from "../IConfiguration";
2
- export declare namespace SourceFinder {
3
- function find(input: IConfiguration.IInput): Promise<string[]>;
4
- }
1
+ import { IConfiguration } from "../IConfiguration";
2
+ export declare namespace SourceFinder {
3
+ function find(input: IConfiguration.IInput): Promise<string[]>;
4
+ }
@@ -1,70 +1,70 @@
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.SourceFinder = void 0;
16
- const fs_1 = __importDefault(require("fs"));
17
- const glob_1 = __importDefault(require("glob"));
18
- const path_1 = __importDefault(require("path"));
19
- var SourceFinder;
20
- (function (SourceFinder) {
21
- function find(input) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- const dict = new Set();
24
- yield decode(input.include, (str) => dict.add(str));
25
- if (input.exclude)
26
- yield decode(input.exclude, (str) => dict.delete(str));
27
- return [...dict];
28
- });
29
- }
30
- SourceFinder.find = find;
31
- function decode(input, closure) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- for (const pattern of input)
34
- for (const location of yield _Glob(path_1.default.resolve(pattern))) {
35
- const stats = yield fs_1.default.promises.stat(location);
36
- if (stats.isDirectory() === true)
37
- yield iterate(closure, location);
38
- else if (stats.isFile() && _Is_ts_file(location))
39
- closure(location);
40
- }
41
- });
42
- }
43
- function iterate(closure, location) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const directory = yield fs_1.default.promises.readdir(location);
46
- for (const file of directory) {
47
- const next = path_1.default.resolve(`${location}/${file}`);
48
- const stats = yield fs_1.default.promises.stat(next);
49
- if (stats.isDirectory() === true)
50
- yield iterate(closure, next);
51
- else if (stats.isFile() && _Is_ts_file(file))
52
- closure(next);
53
- }
54
- });
55
- }
56
- function _Glob(pattern) {
57
- return new Promise((resolve, reject) => {
58
- (0, glob_1.default)(pattern, (err, matches) => {
59
- if (err)
60
- reject(err);
61
- else
62
- resolve(matches.map((str) => path_1.default.resolve(str)));
63
- });
64
- });
65
- }
66
- function _Is_ts_file(file) {
67
- return file.substr(-3) === ".ts" && file.substr(-5) !== ".d.ts";
68
- }
69
- })(SourceFinder = exports.SourceFinder || (exports.SourceFinder = {}));
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.SourceFinder = void 0;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const glob_1 = __importDefault(require("glob"));
18
+ const path_1 = __importDefault(require("path"));
19
+ var SourceFinder;
20
+ (function (SourceFinder) {
21
+ function find(input) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const dict = new Set();
24
+ yield decode(input.include, (str) => dict.add(str));
25
+ if (input.exclude)
26
+ yield decode(input.exclude, (str) => dict.delete(str));
27
+ return [...dict];
28
+ });
29
+ }
30
+ SourceFinder.find = find;
31
+ function decode(input, closure) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ for (const pattern of input)
34
+ for (const location of yield _Glob(path_1.default.resolve(pattern))) {
35
+ const stats = yield fs_1.default.promises.stat(location);
36
+ if (stats.isDirectory() === true)
37
+ yield iterate(closure, location);
38
+ else if (stats.isFile() && _Is_ts_file(location))
39
+ closure(location);
40
+ }
41
+ });
42
+ }
43
+ function iterate(closure, location) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const directory = yield fs_1.default.promises.readdir(location);
46
+ for (const file of directory) {
47
+ const next = path_1.default.resolve(`${location}/${file}`);
48
+ const stats = yield fs_1.default.promises.stat(next);
49
+ if (stats.isDirectory() === true)
50
+ yield iterate(closure, next);
51
+ else if (stats.isFile() && _Is_ts_file(file))
52
+ closure(next);
53
+ }
54
+ });
55
+ }
56
+ function _Glob(pattern) {
57
+ return new Promise((resolve, reject) => {
58
+ (0, glob_1.default)(pattern, (err, matches) => {
59
+ if (err)
60
+ reject(err);
61
+ else
62
+ resolve(matches.map((str) => path_1.default.resolve(str)));
63
+ });
64
+ });
65
+ }
66
+ function _Is_ts_file(file) {
67
+ return file.substr(-3) === ".ts" && file.substr(-5) !== ".d.ts";
68
+ }
69
+ })(SourceFinder = exports.SourceFinder || (exports.SourceFinder = {}));
70
70
  //# sourceMappingURL=SourceFinder.js.map
@@ -1,11 +1,11 @@
1
- export declare namespace CompilerOptions {
2
- const DEFAULT_OPTIONS: {
3
- target: string;
4
- module: string;
5
- types: string[];
6
- noEmit: boolean;
7
- esModuleInterop: boolean;
8
- experimentalDecorators: boolean;
9
- emitDecoratorMetadata: boolean;
10
- };
11
- }
1
+ export declare namespace CompilerOptions {
2
+ const DEFAULT_OPTIONS: {
3
+ target: string;
4
+ module: string;
5
+ types: string[];
6
+ noEmit: boolean;
7
+ esModuleInterop: boolean;
8
+ experimentalDecorators: boolean;
9
+ emitDecoratorMetadata: boolean;
10
+ };
11
+ }