diff --git a/benchmark/package.json b/benchmark/package.json index 7ecbd6e83..3767c30cf 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -42,7 +42,7 @@ "reflect-metadata": "^0.2.2", "tgrid": "^1.0.3", "tstl": "^3.0.0", - "typia": "^6.8.0" + "typia": "^6.9.0" }, "devDependencies": { "@types/autocannon": "^7.9.0", diff --git a/package.json b/package.json index 294a9668d..6f1ef1968 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@nestia/station", - "version": "3.11.1", + "version": "3.11.2", "description": "Nestia station", "scripts": { "build": "node build/index.js", diff --git a/packages/benchmark/package.json b/packages/benchmark/package.json index d0b8c70be..d6f006f34 100644 --- a/packages/benchmark/package.json +++ b/packages/benchmark/package.json @@ -34,7 +34,7 @@ "ts-patch": "^3.2.1", "typescript": "^5.5.4", "typescript-transform-paths": "^3.4.7", - "typia": "^6.8.0", + "typia": "^6.9.0", "uuid": "^10.0.0" }, "dependencies": { diff --git a/packages/core/package.json b/packages/core/package.json index 7ead73fd4..2a4dbd8c2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@nestia/core", - "version": "3.11.1", + "version": "3.11.2", "description": "Super-fast validation decorators of NestJS", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -36,10 +36,10 @@ }, "homepage": "https://nestia.io", "dependencies": { - "@nestia/fetcher": "^3.11.1", + "@nestia/fetcher": "^3.11.2", "@nestjs/common": ">=7.0.1", "@nestjs/core": ">=7.0.1", - "@samchon/openapi": "^0.4.5", + "@samchon/openapi": "^0.4.6", "detect-ts-node": "^1.0.5", "get-function-location": "^2.0.0", "glob": "^7.2.0", @@ -49,16 +49,16 @@ "reflect-metadata": ">=0.1.12", "rxjs": ">=6.0.3", "tgrid": "^1.0.0", - "typia": "^6.8.0", + "typia": "^6.9.0", "ws": "^7.5.3" }, "peerDependencies": { - "@nestia/fetcher": ">=3.11.1", + "@nestia/fetcher": ">=3.11.2", "@nestjs/common": ">=7.0.1", "@nestjs/core": ">=7.0.1", "reflect-metadata": ">=0.1.12", "rxjs": ">=6.0.3", - "typia": ">=6.8.0 <7.0.0" + "typia": ">=6.9.0 <7.0.0" }, "devDependencies": { "@fastify/multipart": "^8.1.0", diff --git a/packages/core/src/decorators/internal/load_controller.ts b/packages/core/src/decorators/internal/load_controller.ts index a295720a0..9874545d2 100644 --- a/packages/core/src/decorators/internal/load_controller.ts +++ b/packages/core/src/decorators/internal/load_controller.ts @@ -3,9 +3,6 @@ import is_ts_node from "detect-ts-node"; import { Creator } from "../../typings/Creator"; import { SourceFinder } from "../../utils/SourceFinder"; -/** - * @internal - */ export const load_controllers = async ( path: string | string[] | { include: string[]; exclude?: string[] }, isTsNode?: boolean, diff --git a/packages/e2e/package.json b/packages/e2e/package.json index f22254af6..f40d3385a 100644 --- a/packages/e2e/package.json +++ b/packages/e2e/package.json @@ -41,7 +41,7 @@ "ts-patch": "^3.2.1", "typescript": "^5.5.3", "typescript-transform-paths": "^3.4.7", - "typia": "^6.8.0" + "typia": "^6.9.0" }, "files": [ "lib", diff --git a/packages/fetcher/package.json b/packages/fetcher/package.json index 4e8d1e644..eacb7d120 100644 --- a/packages/fetcher/package.json +++ b/packages/fetcher/package.json @@ -1,6 +1,6 @@ { "name": "@nestia/fetcher", - "version": "3.11.1", + "version": "3.11.2", "description": "Fetcher library of Nestia SDK", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -43,6 +43,6 @@ "src" ], "dependencies": { - "@samchon/openapi": "^0.4.5" + "@samchon/openapi": "^0.4.6" } } \ No newline at end of file diff --git a/packages/migrate/package.json b/packages/migrate/package.json index 64d979ffd..113be734c 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -65,13 +65,13 @@ "typescript-transform-paths": "^3.4.6" }, "dependencies": { - "@samchon/openapi": "^0.4.5", + "@samchon/openapi": "^0.4.6", "commander": "10.0.0", "inquirer": "8.2.5", "prettier": "^3.2.5", "tstl": "^3.0.0", "typescript": "^5.5.4", - "typia": "^6.8.0" + "typia": "^6.9.0" }, "files": [ "lib", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 799c5956d..251322afe 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@nestia/sdk", - "version": "3.11.1", + "version": "3.11.2", "description": "Nestia SDK and Swagger generator", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -32,9 +32,9 @@ }, "homepage": "https://nestia.io", "dependencies": { - "@nestia/core": "^3.11.1", - "@nestia/fetcher": "^3.11.1", - "@samchon/openapi": "^0.4.5", + "@nestia/core": "^3.11.2", + "@nestia/fetcher": "^3.11.2", + "@samchon/openapi": "^0.4.6", "@wrtnio/openai-function-schema": "^0.2.3", "cli": "^1.0.1", "get-function-location": "^2.0.0", @@ -45,16 +45,16 @@ "tsconfck": "^2.1.2", "tsconfig-paths": "^4.1.1", "tstl": "^3.0.0", - "typia": "^6.8.0" + "typia": "^6.9.0" }, "peerDependencies": { - "@nestia/core": ">=3.11.1", - "@nestia/fetcher": ">=3.11.1", + "@nestia/core": ">=3.11.2", + "@nestia/fetcher": ">=3.11.2", "@nestjs/common": ">=7.0.1", "@nestjs/core": ">=7.0.1", "reflect-metadata": ">=0.1.12", "ts-node": ">=10.6.0", - "typia": ">=6.8.0 <7.0.0" + "typia": ">=6.9.0 <7.0.0" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.3.0", diff --git a/packages/sdk/src/analyses/ConfigAnalyzer.ts b/packages/sdk/src/analyses/ConfigAnalyzer.ts index 765d03d64..d9599d5d2 100644 --- a/packages/sdk/src/analyses/ConfigAnalyzer.ts +++ b/packages/sdk/src/analyses/ConfigAnalyzer.ts @@ -1,31 +1,56 @@ /// -import { DynamicModule } from "@nestia/core"; import { INestApplication, VersioningType } from "@nestjs/common"; import { MODULE_PATH } from "@nestjs/common/constants"; -import { NestContainer, NestFactory } from "@nestjs/core"; +import { NestContainer } from "@nestjs/core"; import { Module } from "@nestjs/core/injector/module"; +import fs from "fs"; import getFunctionLocation from "get-function-location"; -import { HashMap } from "tstl"; +import path from "path"; +import { HashMap, Pair, Singleton } from "tstl"; import { INestiaConfig } from "../INestiaConfig"; +import { SdkGenerator } from "../generates/SdkGenerator"; import { INestiaSdkInput } from "../structures/INestiaSdkInput"; +import { ArrayUtil } from "../utils/ArrayUtil"; import { MapUtil } from "../utils/MapUtil"; +import { SourceFinder } from "../utils/SourceFinder"; export namespace ConfigAnalyzer { export const input = async ( config: INestiaConfig, ): Promise => { return MapUtil.take(memory, config, async () => { - const app: INestApplication = - typeof config.input === "function" - ? await config.input() - : await NestFactory.create( - await DynamicModule.mount(config.input, {}, true as any), - { - logger: false, - }, - ); - return analyze_application(app); + if (typeof config.input === "function") + return analyze_application(await config.input()); + + const sources: string[] = await SourceFinder.find({ + include: Array.isArray(config.input) + ? config.input + : typeof config.input === "object" + ? config.input.include + : [config.input], + exclude: + typeof config.input === "object" && !Array.isArray(config.input) + ? config.input.exclude ?? [] + : [], + filter: filter(config), + }); + const controllers: INestiaSdkInput.IController[] = []; + for (const file of sources) { + const external: any[] = await import(file); + for (const key in external) { + const instance: Function = external[key]; + if (Reflect.getMetadata("path", instance) !== undefined) + controllers.push({ + class: instance, + location: file, + prefixes: [], + }); + } + } + return { + controllers, + }; }); }; @@ -66,7 +91,6 @@ export namespace ConfigAnalyzer { const versioning = (app as any).config?.versioningOptions; return { - application: app, controllers, globalPrefix: typeof (app as any).config?.globalPrefix === "string" @@ -99,3 +123,33 @@ const normalize_file = (str: string) => ? 7 : 0, ); + +const filter = + (config: INestiaConfig) => + async (location: string): Promise => + location.endsWith(".ts") && + !location.endsWith(".d.ts") && + (config.output === undefined || + (location.indexOf(path.join(config.output, "functional")) === -1 && + (await ( + await bundler.get(config.output) + )(location))) === false); + +const bundler = new Singleton(async (output: string) => { + const assets: string[] = await fs.promises.readdir(SdkGenerator.BUNDLE_PATH); + const tuples: Pair[] = await ArrayUtil.asyncMap( + assets, + async (file) => { + const relative: string = path.join(output, file); + const location: string = path.join(SdkGenerator.BUNDLE_PATH, file); + const stats: fs.Stats = await fs.promises.stat(location); + return new Pair(relative, stats.isDirectory()); + }, + ); + return async (file: string): Promise => { + for (const it of tuples) + if (it.second === false && file === it.first) return true; + else if (it.second === true && file.indexOf(it.first) === 0) return true; + return false; + }; +}); diff --git a/packages/sdk/src/structures/INestiaSdkInput.ts b/packages/sdk/src/structures/INestiaSdkInput.ts index 01a332334..c0175ccc4 100644 --- a/packages/sdk/src/structures/INestiaSdkInput.ts +++ b/packages/sdk/src/structures/INestiaSdkInput.ts @@ -1,11 +1,6 @@ -import { - INestApplication, - RouteInfo, - VersionValue, -} from "@nestjs/common/interfaces"; +import { RouteInfo, VersionValue } from "@nestjs/common/interfaces"; export interface INestiaSdkInput { - application: INestApplication; controllers: INestiaSdkInput.IController[]; globalPrefix?: { prefix: string; diff --git a/test/features/all/src/api/functional/health/index.ts b/test/features/all/src/api/functional/health/index.ts index 0218f7f3a..36ae23908 100644 --- a/test/features/all/src/api/functional/health/index.ts +++ b/test/features/all/src/api/functional/health/index.ts @@ -13,20 +13,11 @@ import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher"; * @nestia Generated by Nestia - https://github.com/samchon/nestia */ export async function get(connection: IConnection): Promise { - return PlainFetcher.fetch( - { - ...connection, - headers: { - ...connection.headers, - "Content-Type": "application/json", - }, - }, - { - ...get.METADATA, - template: get.METADATA.path, - path: get.path(), - }, - ); + return PlainFetcher.fetch(connection, { + ...get.METADATA, + template: get.METADATA.path, + path: get.path(), + }); } export namespace get { export const METADATA = { diff --git a/test/features/all/src/api/functional/performance/index.ts b/test/features/all/src/api/functional/performance/index.ts index 8cf10f2e5..847dacd57 100644 --- a/test/features/all/src/api/functional/performance/index.ts +++ b/test/features/all/src/api/functional/performance/index.ts @@ -15,20 +15,11 @@ import type { IPerformance } from "../../structures/IPerformance"; * @nestia Generated by Nestia - https://github.com/samchon/nestia */ export async function get(connection: IConnection): Promise { - return PlainFetcher.fetch( - { - ...connection, - headers: { - ...connection.headers, - "Content-Type": "application/json", - }, - }, - { - ...get.METADATA, - template: get.METADATA.path, - path: get.path(), - }, - ); + return PlainFetcher.fetch(connection, { + ...get.METADATA, + template: get.METADATA.path, + path: get.path(), + }); } export namespace get { export type Output = Primitive; diff --git a/test/features/all/swagger.json b/test/features/all/swagger.json index e750c86bd..b49ab01d7 100644 --- a/test/features/all/swagger.json +++ b/test/features/all/swagger.json @@ -7,7 +7,7 @@ } ], "info": { - "version": "3.11.0", + "version": "3.11.2", "title": "@samchon/nestia-test", "description": "Test program of Nestia", "license": { diff --git a/test/features/distribute-assert-json/packages/api/package.json b/test/features/distribute-assert-json/packages/api/package.json index e20be1db8..1df159664 100644 --- a/test/features/distribute-assert-json/packages/api/package.json +++ b/test/features/distribute-assert-json/packages/api/package.json @@ -33,6 +33,6 @@ }, "dependencies": { "@nestia/fetcher": "^3.11.0", - "typia": "^6.8.0" + "typia": "^6.9.0" } } \ No newline at end of file diff --git a/test/features/distribute-assert/packages/api/package.json b/test/features/distribute-assert/packages/api/package.json index e20be1db8..1df159664 100644 --- a/test/features/distribute-assert/packages/api/package.json +++ b/test/features/distribute-assert/packages/api/package.json @@ -33,6 +33,6 @@ }, "dependencies": { "@nestia/fetcher": "^3.11.0", - "typia": "^6.8.0" + "typia": "^6.9.0" } } \ No newline at end of file diff --git a/test/features/distribute-json/packages/api/package.json b/test/features/distribute-json/packages/api/package.json index e20be1db8..1df159664 100644 --- a/test/features/distribute-json/packages/api/package.json +++ b/test/features/distribute-json/packages/api/package.json @@ -33,6 +33,6 @@ }, "dependencies": { "@nestia/fetcher": "^3.11.0", - "typia": "^6.8.0" + "typia": "^6.9.0" } } \ No newline at end of file diff --git a/test/features/distribute/packages/api/package.json b/test/features/distribute/packages/api/package.json index e20be1db8..1df159664 100644 --- a/test/features/distribute/packages/api/package.json +++ b/test/features/distribute/packages/api/package.json @@ -33,6 +33,6 @@ }, "dependencies": { "@nestia/fetcher": "^3.11.0", - "typia": "^6.8.0" + "typia": "^6.9.0" } } \ No newline at end of file diff --git a/test/package.json b/test/package.json index 6c68c1eae..ba3a25972 100644 --- a/test/package.json +++ b/test/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@samchon/nestia-test", - "version": "3.11.1", + "version": "3.11.2", "description": "Test program of Nestia", "main": "index.js", "scripts": { @@ -26,9 +26,9 @@ }, "homepage": "https://nestia.io", "devDependencies": { - "@nestia/sdk": "^3.11.1", + "@nestia/sdk": "^3.11.2", "@nestjs/swagger": "^7.1.2", - "@samchon/openapi": "^0.4.5", + "@samchon/openapi": "^0.4.6", "@types/express": "^4.17.17", "@types/node": "20.11.16", "@types/uuid": "^9.0.8", @@ -40,16 +40,16 @@ }, "dependencies": { "@fastify/multipart": "^8.1.0", - "@nestia/core": "^3.11.1", + "@nestia/core": "^3.11.2", "@nestia/e2e": "^0.7.0", - "@nestia/fetcher": "^3.11.1", + "@nestia/fetcher": "^3.11.2", "@nestjs/common": "^10.3.5", "@nestjs/core": "^10.3.5", "@nestjs/platform-express": "^10.3.5", "@nestjs/platform-fastify": "^10.3.5", "tgrid": "^1.0.3", "tstl": "^3.0.0", - "typia": "6.8.0", + "typia": "6.9.0", "uuid": "^9.0.1" } } \ No newline at end of file diff --git a/website/package-lock.json b/website/package-lock.json index 4bf715bf3..98efead74 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -25,7 +25,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "react-mui-fileuploader": "^0.5.2", - "typia": "^6.8.0" + "typia": "^6.9.0" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.3.0", @@ -1088,7 +1088,7 @@ "prettier": "^3.2.5", "tstl": "^3.0.0", "typescript": "^5.5.4", - "typia": "^6.8.0" + "typia": "^6.9.0" }, "bin": { "migrate": "lib/executable/migrate.js" @@ -7854,8 +7854,8 @@ } }, "node_modules/typia": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/typia/-/typia-6.8.0.tgz", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/typia/-/typia-6.9.0.tgz", "integrity": "sha512-fsivAnRyOij2aTY/ZD+0c3zA99/+Z5lUvwrQsYR1/Q8LseVk7DNlxvWKKSb0t2x8UtXNERICLvWFw1WkKHpETw==", "dependencies": { "@samchon/openapi": "^0.4.4", diff --git a/website/package.json b/website/package.json index 0ad851203..a29888fef 100644 --- a/website/package.json +++ b/website/package.json @@ -34,7 +34,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "react-mui-fileuploader": "^0.5.2", - "typia": "^6.8.0" + "typia": "^6.9.0" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.3.0",