@nestia/sdk 3.11.1 → 3.11.2
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.
|
@@ -1,4 +1,27 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,23 +37,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
38
|
exports.ConfigAnalyzer = void 0;
|
|
16
39
|
/// <reference path="../typings/get-function-location.d.ts" />
|
|
17
|
-
const core_1 = require("@nestia/core");
|
|
18
40
|
const common_1 = require("@nestjs/common");
|
|
19
41
|
const constants_1 = require("@nestjs/common/constants");
|
|
20
|
-
const
|
|
42
|
+
const fs_1 = __importDefault(require("fs"));
|
|
21
43
|
const get_function_location_1 = __importDefault(require("get-function-location"));
|
|
44
|
+
const path_1 = __importDefault(require("path"));
|
|
22
45
|
const tstl_1 = require("tstl");
|
|
46
|
+
const SdkGenerator_1 = require("../generates/SdkGenerator");
|
|
47
|
+
const ArrayUtil_1 = require("../utils/ArrayUtil");
|
|
23
48
|
const MapUtil_1 = require("../utils/MapUtil");
|
|
49
|
+
const SourceFinder_1 = require("../utils/SourceFinder");
|
|
24
50
|
var ConfigAnalyzer;
|
|
25
51
|
(function (ConfigAnalyzer) {
|
|
26
52
|
ConfigAnalyzer.input = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
27
53
|
return MapUtil_1.MapUtil.take(memory, config, () => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
54
|
+
var _a;
|
|
55
|
+
if (typeof config.input === "function")
|
|
56
|
+
return analyze_application(yield config.input());
|
|
57
|
+
const sources = yield SourceFinder_1.SourceFinder.find({
|
|
58
|
+
include: Array.isArray(config.input)
|
|
59
|
+
? config.input
|
|
60
|
+
: typeof config.input === "object"
|
|
61
|
+
? config.input.include
|
|
62
|
+
: [config.input],
|
|
63
|
+
exclude: typeof config.input === "object" && !Array.isArray(config.input)
|
|
64
|
+
? (_a = config.input.exclude) !== null && _a !== void 0 ? _a : []
|
|
65
|
+
: [],
|
|
66
|
+
filter: filter(config),
|
|
67
|
+
});
|
|
68
|
+
const controllers = [];
|
|
69
|
+
for (const file of sources) {
|
|
70
|
+
const external = yield Promise.resolve(`${file}`).then(s => __importStar(require(s)));
|
|
71
|
+
for (const key in external) {
|
|
72
|
+
const instance = external[key];
|
|
73
|
+
if (Reflect.getMetadata("path", instance) !== undefined)
|
|
74
|
+
controllers.push({
|
|
75
|
+
class: instance,
|
|
76
|
+
location: file,
|
|
77
|
+
prefixes: [],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
controllers,
|
|
83
|
+
};
|
|
34
84
|
}));
|
|
35
85
|
});
|
|
36
86
|
const analyze_application = (app) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -60,7 +110,6 @@ var ConfigAnalyzer;
|
|
|
60
110
|
}
|
|
61
111
|
const versioning = (_e = app.config) === null || _e === void 0 ? void 0 : _e.versioningOptions;
|
|
62
112
|
return {
|
|
63
|
-
application: app,
|
|
64
113
|
controllers,
|
|
65
114
|
globalPrefix: typeof ((_f = app.config) === null || _f === void 0 ? void 0 : _f.globalPrefix) === "string"
|
|
66
115
|
? {
|
|
@@ -87,4 +136,28 @@ const normalize_file = (str) => str.substring(str.startsWith("file:///")
|
|
|
87
136
|
: str.startsWith("file://")
|
|
88
137
|
? 7
|
|
89
138
|
: 0);
|
|
139
|
+
const filter = (config) => (location) => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
return location.endsWith(".ts") &&
|
|
141
|
+
!location.endsWith(".d.ts") &&
|
|
142
|
+
(config.output === undefined ||
|
|
143
|
+
(location.indexOf(path_1.default.join(config.output, "functional")) === -1 &&
|
|
144
|
+
(yield (yield bundler.get(config.output))(location))) === false);
|
|
145
|
+
});
|
|
146
|
+
const bundler = new tstl_1.Singleton((output) => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
const assets = yield fs_1.default.promises.readdir(SdkGenerator_1.SdkGenerator.BUNDLE_PATH);
|
|
148
|
+
const tuples = yield ArrayUtil_1.ArrayUtil.asyncMap(assets, (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
+
const relative = path_1.default.join(output, file);
|
|
150
|
+
const location = path_1.default.join(SdkGenerator_1.SdkGenerator.BUNDLE_PATH, file);
|
|
151
|
+
const stats = yield fs_1.default.promises.stat(location);
|
|
152
|
+
return new tstl_1.Pair(relative, stats.isDirectory());
|
|
153
|
+
}));
|
|
154
|
+
return (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
for (const it of tuples)
|
|
156
|
+
if (it.second === false && file === it.first)
|
|
157
|
+
return true;
|
|
158
|
+
else if (it.second === true && file.indexOf(it.first) === 0)
|
|
159
|
+
return true;
|
|
160
|
+
return false;
|
|
161
|
+
});
|
|
162
|
+
}));
|
|
90
163
|
//# sourceMappingURL=ConfigAnalyzer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigAnalyzer.js","sourceRoot":"","sources":["../../src/analyses/ConfigAnalyzer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConfigAnalyzer.js","sourceRoot":"","sources":["../../src/analyses/ConfigAnalyzer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAA8D;AAC9D,2CAAkE;AAClE,wDAAuD;AAGvD,4CAAoB;AACpB,kFAAwD;AACxD,gDAAwB;AACxB,+BAAgD;AAGhD,4DAAyD;AAEzD,kDAA+C;AAC/C,8CAA2C;AAC3C,wDAAqD;AAErD,IAAiB,cAAc,CAgG9B;AAhGD,WAAiB,cAAc;IAChB,oBAAK,GAAG,CACnB,MAAqB,EACK,EAAE;QAC5B,OAAO,iBAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAS,EAAE;;YAC7C,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU;gBACpC,OAAO,mBAAmB,CAAC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YAEnD,MAAM,OAAO,GAAa,MAAM,2BAAY,CAAC,IAAI,CAAC;gBAChD,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK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I,EAAE,CAAC,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,CAAC,CAAA,CAAC;AACJ,CAAC,CAAA,CAAC,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RouteInfo, VersionValue } from "@nestjs/common/interfaces";
|
|
2
2
|
export interface INestiaSdkInput {
|
|
3
|
-
application: INestApplication;
|
|
4
3
|
controllers: INestiaSdkInput.IController[];
|
|
5
4
|
globalPrefix?: {
|
|
6
5
|
prefix: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/sdk",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.2",
|
|
4
4
|
"description": "Nestia SDK and Swagger generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://nestia.io",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nestia/core": "^3.11.
|
|
36
|
-
"@nestia/fetcher": "^3.11.
|
|
37
|
-
"@samchon/openapi": "^0.4.
|
|
35
|
+
"@nestia/core": "^3.11.2",
|
|
36
|
+
"@nestia/fetcher": "^3.11.2",
|
|
37
|
+
"@samchon/openapi": "^0.4.6",
|
|
38
38
|
"@wrtnio/openai-function-schema": "^0.2.3",
|
|
39
39
|
"cli": "^1.0.1",
|
|
40
40
|
"get-function-location": "^2.0.0",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"tsconfck": "^2.1.2",
|
|
46
46
|
"tsconfig-paths": "^4.1.1",
|
|
47
47
|
"tstl": "^3.0.0",
|
|
48
|
-
"typia": "^6.
|
|
48
|
+
"typia": "^6.9.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@nestia/core": ">=3.11.
|
|
52
|
-
"@nestia/fetcher": ">=3.11.
|
|
51
|
+
"@nestia/core": ">=3.11.2",
|
|
52
|
+
"@nestia/fetcher": ">=3.11.2",
|
|
53
53
|
"@nestjs/common": ">=7.0.1",
|
|
54
54
|
"@nestjs/core": ">=7.0.1",
|
|
55
55
|
"reflect-metadata": ">=0.1.12",
|
|
56
56
|
"ts-node": ">=10.6.0",
|
|
57
|
-
"typia": ">=6.
|
|
57
|
+
"typia": ">=6.9.0 <7.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
@@ -1,31 +1,56 @@
|
|
|
1
1
|
/// <reference path="../typings/get-function-location.d.ts" />
|
|
2
|
-
import { DynamicModule } from "@nestia/core";
|
|
3
2
|
import { INestApplication, VersioningType } from "@nestjs/common";
|
|
4
3
|
import { MODULE_PATH } from "@nestjs/common/constants";
|
|
5
|
-
import { NestContainer
|
|
4
|
+
import { NestContainer } from "@nestjs/core";
|
|
6
5
|
import { Module } from "@nestjs/core/injector/module";
|
|
6
|
+
import fs from "fs";
|
|
7
7
|
import getFunctionLocation from "get-function-location";
|
|
8
|
-
import
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { HashMap, Pair, Singleton } from "tstl";
|
|
9
10
|
|
|
10
11
|
import { INestiaConfig } from "../INestiaConfig";
|
|
12
|
+
import { SdkGenerator } from "../generates/SdkGenerator";
|
|
11
13
|
import { INestiaSdkInput } from "../structures/INestiaSdkInput";
|
|
14
|
+
import { ArrayUtil } from "../utils/ArrayUtil";
|
|
12
15
|
import { MapUtil } from "../utils/MapUtil";
|
|
16
|
+
import { SourceFinder } from "../utils/SourceFinder";
|
|
13
17
|
|
|
14
18
|
export namespace ConfigAnalyzer {
|
|
15
19
|
export const input = async (
|
|
16
20
|
config: INestiaConfig,
|
|
17
21
|
): Promise<INestiaSdkInput> => {
|
|
18
22
|
return MapUtil.take(memory, config, async () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
if (typeof config.input === "function")
|
|
24
|
+
return analyze_application(await config.input());
|
|
25
|
+
|
|
26
|
+
const sources: string[] = await SourceFinder.find({
|
|
27
|
+
include: Array.isArray(config.input)
|
|
28
|
+
? config.input
|
|
29
|
+
: typeof config.input === "object"
|
|
30
|
+
? config.input.include
|
|
31
|
+
: [config.input],
|
|
32
|
+
exclude:
|
|
33
|
+
typeof config.input === "object" && !Array.isArray(config.input)
|
|
34
|
+
? config.input.exclude ?? []
|
|
35
|
+
: [],
|
|
36
|
+
filter: filter(config),
|
|
37
|
+
});
|
|
38
|
+
const controllers: INestiaSdkInput.IController[] = [];
|
|
39
|
+
for (const file of sources) {
|
|
40
|
+
const external: any[] = await import(file);
|
|
41
|
+
for (const key in external) {
|
|
42
|
+
const instance: Function = external[key];
|
|
43
|
+
if (Reflect.getMetadata("path", instance) !== undefined)
|
|
44
|
+
controllers.push({
|
|
45
|
+
class: instance,
|
|
46
|
+
location: file,
|
|
47
|
+
prefixes: [],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
controllers,
|
|
53
|
+
};
|
|
29
54
|
});
|
|
30
55
|
};
|
|
31
56
|
|
|
@@ -66,7 +91,6 @@ export namespace ConfigAnalyzer {
|
|
|
66
91
|
|
|
67
92
|
const versioning = (app as any).config?.versioningOptions;
|
|
68
93
|
return {
|
|
69
|
-
application: app,
|
|
70
94
|
controllers,
|
|
71
95
|
globalPrefix:
|
|
72
96
|
typeof (app as any).config?.globalPrefix === "string"
|
|
@@ -99,3 +123,33 @@ const normalize_file = (str: string) =>
|
|
|
99
123
|
? 7
|
|
100
124
|
: 0,
|
|
101
125
|
);
|
|
126
|
+
|
|
127
|
+
const filter =
|
|
128
|
+
(config: INestiaConfig) =>
|
|
129
|
+
async (location: string): Promise<boolean> =>
|
|
130
|
+
location.endsWith(".ts") &&
|
|
131
|
+
!location.endsWith(".d.ts") &&
|
|
132
|
+
(config.output === undefined ||
|
|
133
|
+
(location.indexOf(path.join(config.output, "functional")) === -1 &&
|
|
134
|
+
(await (
|
|
135
|
+
await bundler.get(config.output)
|
|
136
|
+
)(location))) === false);
|
|
137
|
+
|
|
138
|
+
const bundler = new Singleton(async (output: string) => {
|
|
139
|
+
const assets: string[] = await fs.promises.readdir(SdkGenerator.BUNDLE_PATH);
|
|
140
|
+
const tuples: Pair<string, boolean>[] = await ArrayUtil.asyncMap(
|
|
141
|
+
assets,
|
|
142
|
+
async (file) => {
|
|
143
|
+
const relative: string = path.join(output, file);
|
|
144
|
+
const location: string = path.join(SdkGenerator.BUNDLE_PATH, file);
|
|
145
|
+
const stats: fs.Stats = await fs.promises.stat(location);
|
|
146
|
+
return new Pair(relative, stats.isDirectory());
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
return async (file: string): Promise<boolean> => {
|
|
150
|
+
for (const it of tuples)
|
|
151
|
+
if (it.second === false && file === it.first) return true;
|
|
152
|
+
else if (it.second === true && file.indexOf(it.first) === 0) return true;
|
|
153
|
+
return false;
|
|
154
|
+
};
|
|
155
|
+
});
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
INestApplication,
|
|
3
|
-
RouteInfo,
|
|
4
|
-
VersionValue,
|
|
5
|
-
} from "@nestjs/common/interfaces";
|
|
1
|
+
import { RouteInfo, VersionValue } from "@nestjs/common/interfaces";
|
|
6
2
|
|
|
7
3
|
export interface INestiaSdkInput {
|
|
8
|
-
application: INestApplication;
|
|
9
4
|
controllers: INestiaSdkInput.IController[];
|
|
10
5
|
globalPrefix?: {
|
|
11
6
|
prefix: string;
|