nestia 2.1.11 → 2.2.0-dev.20220625
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/README.md +28 -29
- package/lib/IConfiguration.d.ts +5 -6
- package/lib/NestiaApplication.d.ts +0 -1
- package/lib/NestiaApplication.js +12 -10
- package/lib/analyses/ControllerAnalyzer.d.ts +0 -1
- package/lib/analyses/ControllerAnalyzer.js +11 -5
- package/lib/analyses/GenericAnalyzer.d.ts +0 -1
- package/lib/analyses/GenericAnalyzer.js +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +2 -3
- package/lib/analyses/ImportAnalyzer.js +15 -5
- package/lib/analyses/ReflectAnalyzer.d.ts +0 -1
- package/lib/analyses/ReflectAnalyzer.js +19 -12
- package/lib/analyses/SourceFinder.d.ts +0 -1
- package/lib/executable/internal/CompilerOptions.d.ts +0 -1
- package/lib/executable/internal/CompilerOptions.js +3 -6
- package/lib/executable/internal/NestiaCommand.d.ts +0 -1
- package/lib/executable/internal/NestiaCommand.js +6 -6
- package/lib/executable/internal/NestiaConfig.d.ts +0 -1
- package/lib/executable/internal/NestiaConfig.js +574 -186
- package/lib/executable/internal/nestia.config.getter.d.ts +0 -1
- package/lib/executable/nestia.d.ts +0 -1
- package/lib/executable/nestia.js +1 -1
- package/lib/generates/FileGenerator.d.ts +0 -1
- package/lib/generates/FileGenerator.js +29 -24
- package/lib/generates/FunctionGenerator.d.ts +0 -1
- package/lib/generates/FunctionGenerator.js +69 -56
- package/lib/generates/SdkGenerator.d.ts +0 -1
- package/lib/generates/SwaggerGenerator.d.ts +0 -1
- package/lib/generates/SwaggerGenerator.js +89 -63
- package/lib/index.d.ts +0 -1
- package/lib/module.d.ts +0 -1
- package/lib/structures/IController.d.ts +0 -1
- package/lib/structures/IRoute.d.ts +3 -4
- package/lib/structures/ISwagger.d.ts +5 -1
- package/lib/structures/ITypeTuple.d.ts +5 -0
- package/lib/structures/{IMetadata.js → ITypeTuple.js} +1 -1
- package/lib/structures/MethodType.d.ts +0 -1
- package/lib/structures/MethodType.js +7 -1
- package/lib/structures/ParamCategory.d.ts +0 -1
- package/lib/structures/TypeEntry.d.ts +0 -1
- package/lib/structures/TypeEntry.js +3 -3
- package/lib/utils/ArrayUtil.d.ts +0 -1
- package/lib/utils/DirectoryUtil.d.ts +0 -1
- package/lib/utils/ImportDictionary.d.ts +0 -1
- package/lib/utils/ImportDictionary.js +4 -1
- package/lib/utils/MapUtil.d.ts +0 -1
- package/lib/utils/StringUtil.d.ts +0 -1
- package/package.json +11 -5
- package/lib/IConfiguration.d.ts.map +0 -1
- package/lib/NestiaApplication.d.ts.map +0 -1
- package/lib/analyses/ControllerAnalyzer.d.ts.map +0 -1
- package/lib/analyses/GenericAnalyzer.d.ts.map +0 -1
- package/lib/analyses/ImportAnalyzer.d.ts.map +0 -1
- package/lib/analyses/ReflectAnalyzer.d.ts.map +0 -1
- package/lib/analyses/SourceFinder.d.ts.map +0 -1
- package/lib/executable/internal/CompilerOptions.d.ts.map +0 -1
- package/lib/executable/internal/NestiaCommand.d.ts.map +0 -1
- package/lib/executable/internal/NestiaConfig.d.ts.map +0 -1
- package/lib/executable/internal/nestia.config.getter.d.ts.map +0 -1
- package/lib/executable/nestia.d.ts.map +0 -1
- package/lib/factories/TypeFactry.d.ts +0 -7
- package/lib/factories/TypeFactry.d.ts.map +0 -1
- package/lib/factories/TypeFactry.js +0 -76
- package/lib/generates/FileGenerator.d.ts.map +0 -1
- package/lib/generates/FunctionGenerator.d.ts.map +0 -1
- package/lib/generates/SdkGenerator.d.ts.map +0 -1
- package/lib/generates/SwaggerGenerator.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/module.d.ts.map +0 -1
- package/lib/structures/IController.d.ts.map +0 -1
- package/lib/structures/IMetadata.d.ts +0 -21
- package/lib/structures/IMetadata.d.ts.map +0 -1
- package/lib/structures/IRoute.d.ts.map +0 -1
- package/lib/structures/ISwagger.d.ts.map +0 -1
- package/lib/structures/IType.d.ts +0 -6
- package/lib/structures/IType.d.ts.map +0 -1
- package/lib/structures/IType.js +0 -3
- package/lib/structures/MethodType.d.ts.map +0 -1
- package/lib/structures/ParamCategory.d.ts.map +0 -1
- package/lib/structures/TypeEntry.d.ts.map +0 -1
- package/lib/utils/ArrayUtil.d.ts.map +0 -1
- package/lib/utils/DirectoryUtil.d.ts.map +0 -1
- package/lib/utils/ImportDictionary.d.ts.map +0 -1
- package/lib/utils/MapUtil.d.ts.map +0 -1
- package/lib/utils/StringUtil.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -421,11 +421,11 @@ Look at the below code and feel how powerful `nestia` is. It should be stated th
|
|
|
421
421
|
- 2nd sub-type controller, [`ConsumerSaleQuestionsController`](https://github.com/samchon/nestia/tree/master/demo/generic/src/controllers/ConsumerSaleQuestionsController.ts)
|
|
422
422
|
- Union controller, [`ConsumerSaleEntireArticlesController`](https://github.com/samchon/nestia/tree/master/demo/union/src/controllers/ConsumerSaleEntireArticlesController.ts)
|
|
423
423
|
|
|
424
|
-
> [typescript-
|
|
424
|
+
> [typescript-json](https://github.com/samchon/typescript-json) can replace the class-validator with only one line.
|
|
425
425
|
>
|
|
426
426
|
> ```typescript
|
|
427
427
|
> import * as nest from "@nestjs/common";
|
|
428
|
-
> import {
|
|
428
|
+
> import { assert } from "typescript-json";
|
|
429
429
|
>
|
|
430
430
|
> @nest.Controller("consumers/:section/sales/:saleId/questions")
|
|
431
431
|
> export class SaleQuestionsController
|
|
@@ -436,7 +436,7 @@ Look at the below code and feel how powerful `nestia` is. It should be stated th
|
|
|
436
436
|
> {
|
|
437
437
|
> public constructor()
|
|
438
438
|
> {
|
|
439
|
-
> super(input =>
|
|
439
|
+
> super(input => assert(input));
|
|
440
440
|
> }
|
|
441
441
|
> }
|
|
442
442
|
> ```
|
|
@@ -543,7 +543,7 @@ Furthermore, there's not any problem even when a generic typed controller class
|
|
|
543
543
|
//================================================================
|
|
544
544
|
import { Fetcher, Primitive } from "nestia-fetcher";
|
|
545
545
|
import type { IConnection } from "nestia-fetcher";
|
|
546
|
-
import
|
|
546
|
+
import TSON from "typescript-json";
|
|
547
547
|
|
|
548
548
|
import type { ISaleReview } from "./../../../../structures/ISaleReview";
|
|
549
549
|
import type { ISaleInquiry } from "./../../../../structures/ISaleInquiry";
|
|
@@ -600,7 +600,7 @@ export namespace store
|
|
|
600
600
|
{
|
|
601
601
|
return `/consumers/${section}/sales/${saleId}/reviews`;
|
|
602
602
|
}
|
|
603
|
-
export const stringify =
|
|
603
|
+
export const stringify = (input: Input) => TSON.stringify(input);
|
|
604
604
|
}
|
|
605
605
|
|
|
606
606
|
/**
|
|
@@ -660,7 +660,7 @@ export namespace update
|
|
|
660
660
|
{
|
|
661
661
|
return `/consumers/${section}/sales/${saleId}/reviews/${id}`;
|
|
662
662
|
}
|
|
663
|
-
export const stringify =
|
|
663
|
+
export const stringify = (input: Input) => TSON.stringify(input);
|
|
664
664
|
}
|
|
665
665
|
```
|
|
666
666
|
|
|
@@ -730,31 +730,31 @@ The detailed options are listed up to the `IConfiguration` interface. You can ut
|
|
|
730
730
|
*/
|
|
731
731
|
export interface IConfiguration {
|
|
732
732
|
/**
|
|
733
|
-
* List of files or directories containing the
|
|
733
|
+
* List of files or directories containing the NestJS controller classes.
|
|
734
734
|
*/
|
|
735
735
|
input: string | string[] | IConfiguration.IInput;
|
|
736
736
|
|
|
737
737
|
/**
|
|
738
738
|
* Output directory that SDK would be placed in.
|
|
739
|
-
*
|
|
739
|
+
*
|
|
740
740
|
* If not configured, you can't build the SDK library.
|
|
741
741
|
*/
|
|
742
742
|
output?: string;
|
|
743
743
|
|
|
744
744
|
/**
|
|
745
745
|
* Compiler options for the TypeScript.
|
|
746
|
-
*
|
|
746
|
+
*
|
|
747
747
|
* If you've omitted this property or the assigned property cannot fully cover the
|
|
748
748
|
* `tsconfig.json`, the properties from the `tsconfig.json` would be assigned to here.
|
|
749
|
-
* Otherwise, this property has been configured and it's detailed values are different
|
|
750
|
-
* with the `tsconfig.json`, this property values would be
|
|
751
|
-
*
|
|
749
|
+
* Otherwise, this property has been configured and it's detailed values are different
|
|
750
|
+
* with the `tsconfig.json`, this property values would be used instead.
|
|
751
|
+
*
|
|
752
752
|
* ```typescript
|
|
753
753
|
* import ts from "typescript";
|
|
754
|
-
*
|
|
754
|
+
*
|
|
755
755
|
* const tsconfig: ts.TsConfig;
|
|
756
756
|
* const nestiaConfig: IConfiguration;
|
|
757
|
-
*
|
|
757
|
+
*
|
|
758
758
|
* const compilerOptions: ts.CompilerOptions = {
|
|
759
759
|
* ...tsconfig.compilerOptions,
|
|
760
760
|
* ...(nestiaConfig.compilerOptions || {})
|
|
@@ -765,39 +765,38 @@ export interface IConfiguration {
|
|
|
765
765
|
|
|
766
766
|
/**
|
|
767
767
|
* Whether to assert parameter types or not.
|
|
768
|
-
*
|
|
768
|
+
*
|
|
769
769
|
* If you configure this property to be `true`, all of the function parameters would be
|
|
770
|
-
* checked through the [typescript-
|
|
771
|
-
* option would make your SDK library slower, but would
|
|
772
|
-
*
|
|
770
|
+
* checked through the [typescript-json](https://github.com/samchon/typescript-json#runtime-type-checkers).
|
|
771
|
+
* This option would make your SDK library slower, but would enahcne the type safety even
|
|
772
|
+
* in the runtime level.
|
|
773
773
|
*/
|
|
774
774
|
assert?: boolean;
|
|
775
775
|
|
|
776
776
|
/**
|
|
777
777
|
* Whether to optimize JSON string conversion 2x faster or not.
|
|
778
|
-
*
|
|
778
|
+
*
|
|
779
779
|
* If you configure this property to be `true`, the SDK library would utilize the
|
|
780
|
-
* [typescript-json](https://github.com/samchon/typescript-json)
|
|
781
|
-
* conversion speed really be 2x faster.
|
|
780
|
+
* [typescript-json](https://github.com/samchon/typescript-json#fastest-json-string-converter)
|
|
781
|
+
* and the JSON string conversion speed really be 2x faster.
|
|
782
782
|
*/
|
|
783
783
|
json?: boolean;
|
|
784
784
|
|
|
785
785
|
/**
|
|
786
786
|
* Building `swagger.json` is also possible.
|
|
787
|
-
*
|
|
787
|
+
*
|
|
788
788
|
* If not specified, you can't build the `swagger.json`.
|
|
789
789
|
*/
|
|
790
790
|
swagger?: IConfiguration.ISwagger;
|
|
791
791
|
}
|
|
792
|
-
export namespace IConfiguration
|
|
793
|
-
{
|
|
792
|
+
export namespace IConfiguration {
|
|
794
793
|
/**
|
|
795
|
-
* List of files or directories to include or exclude to specifying the
|
|
794
|
+
* List of files or directories to include or exclude to specifying the NestJS
|
|
796
795
|
* controllers.
|
|
797
796
|
*/
|
|
798
797
|
export interface IInput {
|
|
799
798
|
/**
|
|
800
|
-
* List of files or directories containing the
|
|
799
|
+
* List of files or directories containing the NestJS controller classes.
|
|
801
800
|
*/
|
|
802
801
|
include: string[];
|
|
803
802
|
|
|
@@ -813,9 +812,9 @@ export namespace IConfiguration
|
|
|
813
812
|
export interface ISwagger {
|
|
814
813
|
/**
|
|
815
814
|
* Output path of the `swagger.json`.
|
|
816
|
-
*
|
|
817
|
-
* If you've configured only directory, the file name would be the `swagger.json`.
|
|
818
|
-
* Otherwise you've configured the full path with file name and extension, the
|
|
815
|
+
*
|
|
816
|
+
* If you've configured only directory, the file name would be the `swagger.json`.
|
|
817
|
+
* Otherwise you've configured the full path with file name and extension, the
|
|
819
818
|
* `swagger.json` file would be renamed to it.
|
|
820
819
|
*/
|
|
821
820
|
output: string;
|
package/lib/IConfiguration.d.ts
CHANGED
|
@@ -40,17 +40,17 @@ export interface IConfiguration {
|
|
|
40
40
|
* Whether to assert parameter types or not.
|
|
41
41
|
*
|
|
42
42
|
* If you configure this property to be `true`, all of the function parameters would be
|
|
43
|
-
* checked through the [typescript-
|
|
44
|
-
* option would make your SDK library slower, but would enahcne the type safety even
|
|
45
|
-
* the runtime level.
|
|
43
|
+
* checked through the [typescript-json](https://github.com/samchon/typescript-json#runtime-type-checkers).
|
|
44
|
+
* This option would make your SDK library slower, but would enahcne the type safety even
|
|
45
|
+
* in the runtime level.
|
|
46
46
|
*/
|
|
47
47
|
assert?: boolean;
|
|
48
48
|
/**
|
|
49
49
|
* Whether to optimize JSON string conversion 2x faster or not.
|
|
50
50
|
*
|
|
51
51
|
* If you configure this property to be `true`, the SDK library would utilize the
|
|
52
|
-
* [typescript-json](https://github.com/samchon/typescript-json)
|
|
53
|
-
* conversion speed really be 2x faster.
|
|
52
|
+
* [typescript-json](https://github.com/samchon/typescript-json#fastest-json-string-converter)
|
|
53
|
+
* and the JSON string conversion speed really be 2x faster.
|
|
54
54
|
*/
|
|
55
55
|
json?: boolean;
|
|
56
56
|
/**
|
|
@@ -89,4 +89,3 @@ export declare namespace IConfiguration {
|
|
|
89
89
|
output: string;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
//# sourceMappingURL=IConfiguration.d.ts.map
|
package/lib/NestiaApplication.js
CHANGED
|
@@ -249,7 +249,7 @@ var NestiaApplication = /** @class */ (function () {
|
|
|
249
249
|
_f = [[]];
|
|
250
250
|
return [4 /*yield*/, ReflectAnalyzer_1.ReflectAnalyzer.analyze(unique, file)];
|
|
251
251
|
case 5:
|
|
252
|
-
_d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [_j.sent()]), false]))]));
|
|
252
|
+
_d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_j.sent())]), false]))]));
|
|
253
253
|
_j.label = 6;
|
|
254
254
|
case 6:
|
|
255
255
|
fileList_1_1 = fileList_1.next();
|
|
@@ -298,10 +298,13 @@ var NestiaApplication = /** @class */ (function () {
|
|
|
298
298
|
NestiaApplication.prototype.prepare = function () {
|
|
299
299
|
var _this = this;
|
|
300
300
|
// CONSTRUCT OPTIONS
|
|
301
|
-
var predicator = this.config_
|
|
302
|
-
|
|
301
|
+
var predicator = this.config_
|
|
302
|
+
.compilerOptions
|
|
303
|
+
? function () {
|
|
304
|
+
return CompilerOptions_1.CompilerOptions.emend(_this.config_.compilerOptions, !!_this.config_.assert);
|
|
305
|
+
}
|
|
303
306
|
: function () {
|
|
304
|
-
_this.config_.compilerOptions = CompilerOptions_1.CompilerOptions.DEFAULT_OPTIONS;
|
|
307
|
+
_this.config_.compilerOptions = (CompilerOptions_1.CompilerOptions.DEFAULT_OPTIONS);
|
|
305
308
|
return [false, false];
|
|
306
309
|
};
|
|
307
310
|
// MOUNT TS-NODE
|
|
@@ -310,9 +313,7 @@ var NestiaApplication = /** @class */ (function () {
|
|
|
310
313
|
emit: false,
|
|
311
314
|
compiler: transformed ? "ttypescript" : "typescript",
|
|
312
315
|
compilerOptions: this.config_.compilerOptions,
|
|
313
|
-
require: absoluted
|
|
314
|
-
? ["tsconfig-paths/register"]
|
|
315
|
-
: undefined
|
|
316
|
+
require: absoluted ? ["tsconfig-paths/register"] : undefined,
|
|
316
317
|
});
|
|
317
318
|
};
|
|
318
319
|
NestiaApplication.prototype.is_not_excluded = function (file) {
|
|
@@ -322,17 +323,18 @@ var NestiaApplication = /** @class */ (function () {
|
|
|
322
323
|
switch (_b.label) {
|
|
323
324
|
case 0:
|
|
324
325
|
if (!this.config_.output) return [3 /*break*/, 3];
|
|
325
|
-
_a = file.indexOf(path_1.default.join(this.config_.output, "functional")) ===
|
|
326
|
+
_a = file.indexOf(path_1.default.join(this.config_.output, "functional")) ===
|
|
327
|
+
-1;
|
|
326
328
|
if (!_a) return [3 /*break*/, 2];
|
|
327
329
|
return [4 /*yield*/, this.bundle_checker_.get()];
|
|
328
330
|
case 1:
|
|
329
331
|
_a = (_b.sent())(file) === false;
|
|
330
332
|
_b.label = 2;
|
|
331
|
-
case 2: return [2 /*return*/, _a];
|
|
333
|
+
case 2: return [2 /*return*/, (_a)];
|
|
332
334
|
case 3: return [4 /*yield*/, fs_1.default.promises.readFile(file, "utf8")];
|
|
333
335
|
case 4:
|
|
334
336
|
content = _b.sent();
|
|
335
|
-
return [2 /*return*/, content.indexOf(" * @nestia Generated by Nestia - https://github.com/samchon/nestia") === -1];
|
|
337
|
+
return [2 /*return*/, (content.indexOf(" * @nestia Generated by Nestia - https://github.com/samchon/nestia") === -1)];
|
|
336
338
|
}
|
|
337
339
|
});
|
|
338
340
|
});
|
|
@@ -63,7 +63,8 @@ var ControllerAnalyzer;
|
|
|
63
63
|
var ret = [];
|
|
64
64
|
typescript_1.default.forEachChild(sourceFile, function (node) {
|
|
65
65
|
var _a;
|
|
66
|
-
if (typescript_1.default.isClassDeclaration(node) &&
|
|
66
|
+
if (typescript_1.default.isClassDeclaration(node) &&
|
|
67
|
+
((_a = node.name) === null || _a === void 0 ? void 0 : _a.escapedText) === controller.name) {
|
|
67
68
|
// ANALYZE THE CONTROLLER
|
|
68
69
|
ret.push.apply(ret, __spreadArray([], __read(_Analyze_controller(checker, controller, node)), false));
|
|
69
70
|
return;
|
|
@@ -123,7 +124,9 @@ var ControllerAnalyzer;
|
|
|
123
124
|
throw new Error("Error on ControllerAnalyzer._Analyze_function(): unable to get the signature from the ".concat(controller.name, ".").concat(func.name, "()."));
|
|
124
125
|
var importDict = new HashMap_1.HashMap();
|
|
125
126
|
// EXPLORE CHILDREN TYPES
|
|
126
|
-
var parameters = func.parameters.map(function (param) {
|
|
127
|
+
var parameters = func.parameters.map(function (param) {
|
|
128
|
+
return _Analyze_parameter(checker, genericDict, importDict, controller, func.name, param, signature.getParameters()[param.index]);
|
|
129
|
+
});
|
|
127
130
|
var output = ImportAnalyzer_1.ImportAnalyzer.analyze(checker, genericDict, importDict, signature.getReturnType());
|
|
128
131
|
var imports = importDict
|
|
129
132
|
.toJSON()
|
|
@@ -138,7 +141,9 @@ var ControllerAnalyzer;
|
|
|
138
141
|
try {
|
|
139
142
|
for (var _e = (e_3 = void 0, __values(func.paths)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
140
143
|
var filePath = _f.value;
|
|
141
|
-
var path = path_1.default.join(controllerPath, filePath)
|
|
144
|
+
var path = path_1.default.join(controllerPath, filePath)
|
|
145
|
+
.split("\\")
|
|
146
|
+
.join("/");
|
|
142
147
|
pathList.push(_Normalize_path(path));
|
|
143
148
|
}
|
|
144
149
|
}
|
|
@@ -175,14 +180,15 @@ var ControllerAnalyzer;
|
|
|
175
180
|
var type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
176
181
|
var name = symbol.getEscapedName().toString();
|
|
177
182
|
// VALIDATE PARAMETERS
|
|
178
|
-
if ((param.category === "query" || param.category === "body") &&
|
|
183
|
+
if ((param.category === "query" || param.category === "body") &&
|
|
184
|
+
param.field !== undefined)
|
|
179
185
|
throw new Error("Error on ".concat(controller.name, ".").concat(funcName, "(): parameter ").concat(name, " is specifying a field ").concat(param.field, " of the request ").concat(param.category, " message, however, Nestia does not support the field specialization for the request ").concat(param.category, " message. Erase the ").concat(controller.name, ".").concat(funcName, "()#").concat(name, " parameter and re-define a new decorator accepting full structured message."));
|
|
180
186
|
return {
|
|
181
187
|
name: name,
|
|
182
188
|
category: param.category,
|
|
183
189
|
field: param.field,
|
|
184
190
|
encrypted: param.encrypted,
|
|
185
|
-
type: ImportAnalyzer_1.ImportAnalyzer.analyze(checker, genericDict, importDict, type)
|
|
191
|
+
type: ImportAnalyzer_1.ImportAnalyzer.analyze(checker, genericDict, importDict, type),
|
|
186
192
|
};
|
|
187
193
|
}
|
|
188
194
|
})(ControllerAnalyzer = exports.ControllerAnalyzer || (exports.ControllerAnalyzer = {}));
|
|
@@ -42,7 +42,7 @@ var GenericAnalyzer;
|
|
|
42
42
|
var parameters = superNode.typeParameters || [];
|
|
43
43
|
parameters.forEach(function (param, index) {
|
|
44
44
|
var paramType = checker.getTypeAtLocation(param);
|
|
45
|
-
var usageType =
|
|
45
|
+
var usageType = usages[index] !== undefined
|
|
46
46
|
? checker.getTypeAtLocation(usages[index])
|
|
47
47
|
: checker.getTypeAtLocation(param.default);
|
|
48
48
|
dict.set(paramType, usageType);
|
|
@@ -2,13 +2,12 @@ import ts from "typescript";
|
|
|
2
2
|
import { HashMap } from "tstl/container/HashMap";
|
|
3
3
|
import { HashSet } from "tstl/container/HashSet";
|
|
4
4
|
import { GenericAnalyzer } from "./GenericAnalyzer";
|
|
5
|
-
import {
|
|
5
|
+
import { ITypeTuple } from "../structures/ITypeTuple";
|
|
6
6
|
export declare namespace ImportAnalyzer {
|
|
7
7
|
interface IOutput {
|
|
8
8
|
features: [string, string[]][];
|
|
9
9
|
alias: string;
|
|
10
10
|
}
|
|
11
11
|
type Dictionary = HashMap<string, HashSet<string>>;
|
|
12
|
-
function analyze(checker: ts.TypeChecker, genericDict: GenericAnalyzer.Dictionary, importDict: Dictionary, type: ts.Type):
|
|
12
|
+
function analyze(checker: ts.TypeChecker, genericDict: GenericAnalyzer.Dictionary, importDict: Dictionary, type: ts.Type): ITypeTuple;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=ImportAnalyzer.d.ts.map
|
|
@@ -9,9 +9,10 @@ var HashSet_1 = require("tstl/container/HashSet");
|
|
|
9
9
|
var ImportAnalyzer;
|
|
10
10
|
(function (ImportAnalyzer) {
|
|
11
11
|
function analyze(checker, genericDict, importDict, type) {
|
|
12
|
+
type = get_type(checker, type);
|
|
12
13
|
return {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
type: type,
|
|
15
|
+
name: explore_escaped_name(checker, genericDict, importDict, type),
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
ImportAnalyzer.analyze = analyze;
|
|
@@ -48,9 +49,14 @@ var ImportAnalyzer;
|
|
|
48
49
|
if (symbol === undefined)
|
|
49
50
|
return checker.typeToString(type, undefined, undefined);
|
|
50
51
|
// UNION OR INTERSECT
|
|
51
|
-
else if (type.aliasSymbol === undefined &&
|
|
52
|
+
else if (type.aliasSymbol === undefined &&
|
|
53
|
+
type.isUnionOrIntersection()) {
|
|
52
54
|
var joiner = type.isIntersection() ? " & " : " | ";
|
|
53
|
-
return type.types
|
|
55
|
+
return type.types
|
|
56
|
+
.map(function (child) {
|
|
57
|
+
return explore_escaped_name(checker, genericDict, importDict, child);
|
|
58
|
+
})
|
|
59
|
+
.join(joiner);
|
|
54
60
|
}
|
|
55
61
|
//----
|
|
56
62
|
// SPECIALIZATION
|
|
@@ -66,7 +72,11 @@ var ImportAnalyzer;
|
|
|
66
72
|
return generic.length
|
|
67
73
|
? name === "Promise"
|
|
68
74
|
? explore_escaped_name(checker, genericDict, importDict, generic[0])
|
|
69
|
-
: "".concat(name, "<").concat(generic
|
|
75
|
+
: "".concat(name, "<").concat(generic
|
|
76
|
+
.map(function (child) {
|
|
77
|
+
return explore_escaped_name(checker, genericDict, importDict, child);
|
|
78
|
+
})
|
|
79
|
+
.join(", "), ">")
|
|
70
80
|
: name;
|
|
71
81
|
}
|
|
72
82
|
function explore_name(name, decl) {
|
|
@@ -149,7 +149,8 @@ var ReflectAnalyzer;
|
|
|
149
149
|
// VALIDATIONS
|
|
150
150
|
//----
|
|
151
151
|
// MUST BE TYPE OF A CREATOR WHO HAS THE CONSTRUCTOR
|
|
152
|
-
if (!(creator instanceof Function &&
|
|
152
|
+
if (!(creator instanceof Function &&
|
|
153
|
+
creator.constructor instanceof Function))
|
|
153
154
|
return null;
|
|
154
155
|
// MUST HAVE THOSE MATADATA
|
|
155
156
|
else if (ArrayUtil_1.ArrayUtil.has(Reflect.getMetadataKeys(creator), "path", "host", "scope:options") === false)
|
|
@@ -163,13 +164,14 @@ var ReflectAnalyzer;
|
|
|
163
164
|
file: file,
|
|
164
165
|
name: name,
|
|
165
166
|
paths: paths,
|
|
166
|
-
functions: []
|
|
167
|
+
functions: [],
|
|
167
168
|
};
|
|
168
169
|
try {
|
|
169
170
|
// PARSE CHILDREN DATA
|
|
170
171
|
for (var _b = __values(_Get_prototype_entries(creator)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
171
172
|
var tuple = _c.value;
|
|
172
|
-
var child = _Analyze_function.apply(void 0, __spreadArray([creator.prototype,
|
|
173
|
+
var child = _Analyze_function.apply(void 0, __spreadArray([creator.prototype,
|
|
174
|
+
meta], __read(tuple), false));
|
|
173
175
|
if (child !== null)
|
|
174
176
|
meta.functions.push(child);
|
|
175
177
|
}
|
|
@@ -186,7 +188,10 @@ var ReflectAnalyzer;
|
|
|
186
188
|
}
|
|
187
189
|
function _Get_prototype_entries(creator) {
|
|
188
190
|
var keyList = Object.getOwnPropertyNames(creator.prototype);
|
|
189
|
-
var entries = keyList.map(function (key) { return [
|
|
191
|
+
var entries = keyList.map(function (key) { return [
|
|
192
|
+
key,
|
|
193
|
+
creator.prototype[key],
|
|
194
|
+
]; });
|
|
190
195
|
var parent = Object.getPrototypeOf(creator);
|
|
191
196
|
if (parent.prototype !== undefined)
|
|
192
197
|
entries.push.apply(entries, __spreadArray([], __read(_Get_prototype_entries(parent)), false));
|
|
@@ -213,7 +218,8 @@ var ReflectAnalyzer;
|
|
|
213
218
|
if (!(proto instanceof Function))
|
|
214
219
|
return null;
|
|
215
220
|
// MUST HAVE THOSE METADATE
|
|
216
|
-
else if (ArrayUtil_1.ArrayUtil.has(Reflect.getMetadataKeys(proto), "path", "method") ===
|
|
221
|
+
else if (ArrayUtil_1.ArrayUtil.has(Reflect.getMetadataKeys(proto), "path", "method") ===
|
|
222
|
+
false)
|
|
217
223
|
return null;
|
|
218
224
|
//----
|
|
219
225
|
// CONSTRUCTION
|
|
@@ -224,8 +230,8 @@ var ReflectAnalyzer;
|
|
|
224
230
|
method: METHODS[Reflect.getMetadata("method", proto)],
|
|
225
231
|
paths: _Get_paths(Reflect.getMetadata("path", proto)),
|
|
226
232
|
parameters: [],
|
|
227
|
-
encrypted: Reflect.hasMetadata("__interceptors__", proto)
|
|
228
|
-
|
|
233
|
+
encrypted: Reflect.hasMetadata("__interceptors__", proto) &&
|
|
234
|
+
((_e = (_d = Reflect.getMetadata("__interceptors__", proto)[0]) === null || _d === void 0 ? void 0 : _d.constructor) === null || _e === void 0 ? void 0 : _e.name) === "EncryptedRouteInterceptor",
|
|
229
235
|
};
|
|
230
236
|
// PARSE CHILDREN DATA
|
|
231
237
|
var nestParameters = Reflect.getMetadata("__routeArguments__", classProto.constructor, name);
|
|
@@ -305,19 +311,20 @@ var ReflectAnalyzer;
|
|
|
305
311
|
category: type,
|
|
306
312
|
index: param.index,
|
|
307
313
|
field: param.data,
|
|
308
|
-
encrypted: false
|
|
314
|
+
encrypted: false,
|
|
309
315
|
};
|
|
310
316
|
}
|
|
311
317
|
function _Analyze_custom_parameter(param) {
|
|
312
318
|
if (param.factory === undefined)
|
|
313
319
|
return null;
|
|
314
|
-
else if (param.factory.name === "EncryptedBody" ||
|
|
320
|
+
else if (param.factory.name === "EncryptedBody" ||
|
|
321
|
+
param.factory.name === "PlainBody") {
|
|
315
322
|
return {
|
|
316
323
|
category: "body",
|
|
317
324
|
index: param.index,
|
|
318
325
|
name: param.name,
|
|
319
326
|
field: param.data,
|
|
320
|
-
encrypted: param.factory.name === "EncryptedBody"
|
|
327
|
+
encrypted: param.factory.name === "EncryptedBody",
|
|
321
328
|
};
|
|
322
329
|
}
|
|
323
330
|
else if (param.factory.name === "TypedParam")
|
|
@@ -326,7 +333,7 @@ var ReflectAnalyzer;
|
|
|
326
333
|
category: "param",
|
|
327
334
|
index: param.index,
|
|
328
335
|
field: param.data,
|
|
329
|
-
encrypted: false
|
|
336
|
+
encrypted: false,
|
|
330
337
|
};
|
|
331
338
|
else
|
|
332
339
|
return null;
|
|
@@ -343,7 +350,7 @@ var ReflectAnalyzer;
|
|
|
343
350
|
undefined,
|
|
344
351
|
undefined,
|
|
345
352
|
undefined,
|
|
346
|
-
undefined
|
|
353
|
+
undefined,
|
|
347
354
|
];
|
|
348
355
|
})(ReflectAnalyzer = exports.ReflectAnalyzer || (exports.ReflectAnalyzer = {}));
|
|
349
356
|
//# sourceMappingURL=ReflectAnalyzer.js.map
|
|
@@ -46,14 +46,11 @@ var CompilerOptions;
|
|
|
46
46
|
DEFAULT VALUES
|
|
47
47
|
----------------------------------------------------------- */
|
|
48
48
|
var ESSENTIAL_OPTIONS = {
|
|
49
|
-
types: [
|
|
50
|
-
"node",
|
|
51
|
-
"reflect-metadata"
|
|
52
|
-
],
|
|
49
|
+
types: ["node", "reflect-metadata"],
|
|
53
50
|
noEmit: true,
|
|
54
51
|
esModuleInterop: true,
|
|
55
52
|
experimentalDecorators: true,
|
|
56
|
-
emitDecoratorMetadata: true
|
|
53
|
+
emitDecoratorMetadata: true,
|
|
57
54
|
};
|
|
58
55
|
CompilerOptions.DEFAULT_OPTIONS = __assign(__assign({}, ESSENTIAL_OPTIONS), { target: "es5", module: "commonjs" });
|
|
59
56
|
function emend(options, assert) {
|
|
@@ -93,7 +90,7 @@ var CompilerOptions;
|
|
|
93
90
|
};
|
|
94
91
|
if (assert === true)
|
|
95
92
|
emplace({
|
|
96
|
-
transform: "typescript-
|
|
93
|
+
transform: "typescript-json/lib/transform",
|
|
97
94
|
});
|
|
98
95
|
if (options.paths && Object.entries(options.paths).length !== 0)
|
|
99
96
|
emplace({ transform: "typescript-transform-paths" });
|
|
@@ -97,7 +97,7 @@ var NestiaCommand;
|
|
|
97
97
|
function sdk(elements, pure) {
|
|
98
98
|
if (pure === void 0) { pure = true; }
|
|
99
99
|
return main(function (app) { return app.sdk(); }, {
|
|
100
|
-
assign: function (config, output) { return config.output = output; },
|
|
100
|
+
assign: function (config, output) { return (config.output = output); },
|
|
101
101
|
validate: function (config) { return !!config.output; },
|
|
102
102
|
location: function (config) { return config.output; },
|
|
103
103
|
}, elements, pure);
|
|
@@ -112,7 +112,9 @@ var NestiaCommand;
|
|
|
112
112
|
else
|
|
113
113
|
config.swagger.output = output;
|
|
114
114
|
},
|
|
115
|
-
validate: function (config) {
|
|
115
|
+
validate: function (config) {
|
|
116
|
+
return !!config.swagger && !!config.swagger.output;
|
|
117
|
+
},
|
|
116
118
|
location: function (config) { return config.swagger.output; },
|
|
117
119
|
}, elements, pure);
|
|
118
120
|
}
|
|
@@ -166,7 +168,7 @@ var NestiaCommand;
|
|
|
166
168
|
switch (_b.label) {
|
|
167
169
|
case 0: return [4 /*yield*/, get_nestia_config(output.validate)];
|
|
168
170
|
case 1:
|
|
169
|
-
config = (_a = _b.sent()) !== null && _a !== void 0 ? _a : parse_cli(include, command, output);
|
|
171
|
+
config = (_a = (_b.sent())) !== null && _a !== void 0 ? _a : parse_cli(include, command, output);
|
|
170
172
|
if (!(fs_1.default.existsSync("tsconfig.json") === true)) return [3 /*break*/, 3];
|
|
171
173
|
return [4 /*yield*/, fs_1.default.promises.readFile("tsconfig.json", "utf8")];
|
|
172
174
|
case 2:
|
|
@@ -216,9 +218,7 @@ var NestiaCommand;
|
|
|
216
218
|
var config = {
|
|
217
219
|
input: {
|
|
218
220
|
include: include,
|
|
219
|
-
exclude: command.exclude
|
|
220
|
-
? [command.exclude]
|
|
221
|
-
: undefined
|
|
221
|
+
exclude: command.exclude ? [command.exclude] : undefined,
|
|
222
222
|
},
|
|
223
223
|
};
|
|
224
224
|
output.assign(config, command.out);
|