Skip to content

Commit

Permalink
Merge pull request #840 from samchon/features/object
Browse files Browse the repository at this point in the history
Fix #837: critical API change from NestJS 10.3.4 update.
  • Loading branch information
samchon authored Mar 20, 2024
2 parents 899d615 + 2a44957 commit 4db68f0
Show file tree
Hide file tree
Showing 35 changed files with 109 additions and 94 deletions.
51 changes: 18 additions & 33 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,28 @@
version: 2
updates:
#######################################################
- package-ecosystem: 'npm'
directory: '/packages/test'
schedule:
interval: 'daily'
# versioning-strategy: increase
versioning-strategy: increase
open-pull-requests-limit: 25
allow:
- dependency-name: "@nestia/fetcher"
- dependency-name: "typia"
#######################################################
- package-ecosystem: 'npm'
directory: '/packages/e2e'
schedule:
interval: 'daily'
# versioning-strategy: increase
open-pull-requests-limit: 25
allow:
- dependency-name: "typia"
#######################################################
- package-ecosystem: 'npm'
directory: '/packages/sdk'
schedule:
interval: 'daily'
# versioning-strategy: increase
open-pull-requests-limit: 25
allow:
- dependency-name: "@nestia/fetcher"
- dependency-name: "tgrid"
- dependency-name: "tstl"
- dependency-name: "typia"
#######################################################
- package-ecosystem: 'npm'
directory: '/test'
schedule:
interval: 'daily'
# versioning-strategy: increase
open-pull-requests-limit: 25
allow:
- dependency-name: "typia"
#######################################################
- dependency-name: "@nestjs/*"
- dependency-name: ts-node
- dependency-name: ts-patch
- dependency-name: typescript
groups:
NestJS:
patterns:
- "@nestjs/*"
Samchon:
patterns:
- "tstl"
- "typia"
TypeScript:
patterns:
- "ts-node"
- "ts-patch"
- "typescript"
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ on:
- 'packages/*/src/**'
- 'packages/*/package.json'
- 'test/**'
- 'test/package.json'
pull_request:
paths:
- 'packages/*/src/**'
- 'packages/*/package.json'
- 'test/**'
- 'test/package.json'

jobs:
Ubuntu:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ on:
- master
paths:
- 'website/**'
pull_request:
branches:
- master
paths:
- 'website/**'
- 'website/package.json'
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@nestia/station",
"version": "2.5.16-dev.20240320",
"version": "2.5.16",
"description": "Nestia station",
"main": "prettier.config.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/core",
"version": "2.5.16-dev.20240320",
"version": "2.5.16",
"description": "Super-fast validation decorators of NestJS",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -36,7 +36,7 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/fetcher": "^2.5.16-dev.20240320",
"@nestia/fetcher": "^2.5.16",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"detect-ts-node": "^1.0.5",
Expand All @@ -48,7 +48,7 @@
"typia": "^5.5.3"
},
"peerDependencies": {
"@nestia/fetcher": ">=2.5.16-dev.20240320",
"@nestia/fetcher": ">=2.5.16",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"reflect-metadata": ">=0.1.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/fetcher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/fetcher",
"version": "2.5.16-dev.20240320",
"version": "2.5.16",
"description": "Fetcher library of Nestia SDK",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/sdk",
"version": "2.5.16-dev.20240320",
"version": "2.5.16",
"description": "Nestia SDK and Swagger generator",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -32,7 +32,7 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/fetcher": "^2.5.16-dev.20240320",
"@nestia/fetcher": "^2.5.16",
"cli": "^1.0.1",
"get-function-location": "^2.0.0",
"glob": "^7.2.0",
Expand All @@ -45,7 +45,7 @@
"typia": "^5.5.3"
},
"peerDependencies": {
"@nestia/fetcher": ">=2.5.16-dev.20240320",
"@nestia/fetcher": ">=2.5.16",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"reflect-metadata": ">=0.1.12",
Expand Down
64 changes: 48 additions & 16 deletions packages/sdk/src/analyses/ReflectAnalyzer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Constants from "@nestjs/common/constants";
import { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
import "reflect-metadata";
import { Singleton } from "tstl";
import { equal } from "tstl/ranges";

import { IController } from "../structures/IController";
Expand Down Expand Up @@ -361,7 +362,7 @@ export namespace ReflectAnalyzer {
const typeIndex: number = Number(symbol[0]);
if (isNaN(typeIndex) === true) return null;

const type: ParamCategory | undefined = NEST_PARAMETER_TYPES[typeIndex];
const type: ParamCategory | undefined = nestParameterType.get()[typeIndex];
if (type === undefined) return null;

return {
Expand Down Expand Up @@ -452,18 +453,49 @@ const METHODS = [
"HEAD",
];

// node_modules/@nestjs/common/lib/route-paramtypes.enum.ts
const NEST_PARAMETER_TYPES = [
undefined,
undefined,
undefined,
"body",
"query",
"param",
"headers",
undefined,
undefined,
undefined,
undefined,
undefined,
] as const;
// https://github.com/nestjs/nest/blob/master/packages/common/enums/route-paramtypes.enum.ts
const nestParameterType = new Singleton<Array<ParamCategory | undefined>>(
() => {
const { version } = require("@nestjs/common/package.json");
const [major, minor, patch] = version.split(".").map(Number);
const rawBody: boolean = [
major >= 10,
major > 10 || minor >= 3,
major > 10 ||
(major === 10 && minor > 3) ||
(major === 10 &&
minor === 3 &&
((isNaN(patch) && version.split(".")[2] >= "4") || patch >= 4)),
].every((b) => b);
return rawBody
? [
undefined,
undefined,
undefined,
"body",
undefined, // rawBody
"query",
"param",
"headers",
undefined,
undefined,
undefined,
undefined,
undefined,
]
: [
undefined,
undefined,
undefined,
"body",
"query",
"param",
"headers",
undefined,
undefined,
undefined,
undefined,
undefined,
];
},
);
2 changes: 1 addition & 1 deletion packages/sdk/src/structures/ParamCategory.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type ParamCategory = "param" | "query" | "body" | "headers";
export type ParamCategory = "param" | "query" | "body" | "rawBody" | "headers";
2 changes: 1 addition & 1 deletion test/features/all/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "2.5.15",
"version": "2.5.16-dev.20240320-2",
"title": "@nestia/test",
"description": "Test program of Nestia",
"license": {
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/features/app-globalPrefix-versionUri/swagger.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/features/app-globalPrefix/swagger.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/features/app-routerModule/swagger.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/features/app-versionHeader/swagger.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/features/app-versionUri/swagger.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/features/app/swagger.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/features/beautify-4/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "2.5.15",
"version": "2.5.16-dev.20240320-2",
"title": "@nestia/test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/beautify-false/swagger.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"openapi":"3.0.1","servers":[{"url":"https://github.com/samchon/nestia","description":"insert your server url"}],"info":{"version":"2.5.15","title":"@nestia/test","description":"Test program of Nestia","license":{"name":"MIT"}},"paths":{"/health":{"get":{"tags":["system","health"],"parameters":[],"responses":{"200":{"description":""}},"summary":"Health check API","description":"Health check API.\n\nJust for health checking API liveness."}},"/performance":{"get":{"tags":["system","performance"],"parameters":[],"responses":{"200":{"description":"Performance info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IPerformance"}}}}},"summary":"Get server performance info","description":"Get server performance info."}},"/body":{"post":{"tags":[],"parameters":[],"requestBody":{"description":"Content to store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IBbsArticle.IStore"}}},"required":true},"responses":{"201":{"description":"Newly archived article","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IBbsArticle"}}}}},"summary":"Store an article","description":"Store an article."}},"/body/{id}":{"put":{"tags":[],"parameters":[{"name":"id","in":"path","schema":{"type":"string","format":"uuid"},"description":"","required":true}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartialIBbsArticle.IStore"}}},"required":true},"responses":{"200":{"description":""}}}}},"components":{"schemas":{"IPerformance":{"type":"object","properties":{"cpu":{"$ref":"#/components/schemas/process.global.NodeJS.CpuUsage"},"memory":{"$ref":"#/components/schemas/process.global.NodeJS.MemoryUsage"},"resource":{"$ref":"#/components/schemas/process.global.NodeJS.ResourceUsage"}},"nullable":false,"required":["cpu","memory","resource"],"description":"Performance info."},"process.global.NodeJS.CpuUsage":{"type":"object","properties":{"user":{"type":"number"},"system":{"type":"number"}},"nullable":false,"required":["user","system"]},"process.global.NodeJS.MemoryUsage":{"type":"object","properties":{"rss":{"type":"number"},"heapTotal":{"type":"number"},"heapUsed":{"type":"number"},"external":{"type":"number"},"arrayBuffers":{"type":"number"}},"nullable":false,"required":["rss","heapTotal","heapUsed","external","arrayBuffers"]},"process.global.NodeJS.ResourceUsage":{"type":"object","properties":{"fsRead":{"type":"number"},"fsWrite":{"type":"number"},"involuntaryContextSwitches":{"type":"number"},"ipcReceived":{"type":"number"},"ipcSent":{"type":"number"},"majorPageFault":{"type":"number"},"maxRSS":{"type":"number"},"minorPageFault":{"type":"number"},"sharedMemorySize":{"type":"number"},"signalsCount":{"type":"number"},"swappedOut":{"type":"number"},"systemCPUTime":{"type":"number"},"unsharedDataSize":{"type":"number"},"unsharedStackSize":{"type":"number"},"userCPUTime":{"type":"number"},"voluntaryContextSwitches":{"type":"number"}},"nullable":false,"required":["fsRead","fsWrite","involuntaryContextSwitches","ipcReceived","ipcSent","majorPageFault","maxRSS","minorPageFault","sharedMemorySize","signalsCount","swappedOut","systemCPUTime","unsharedDataSize","unsharedStackSize","userCPUTime","voluntaryContextSwitches"]},"IBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","maxLength":50,"minLength":3},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"nullable":false,"required":["title","body","files"]},"IAttachmentFile":{"type":"object","properties":{"name":{"type":"string","maxLength":255,"nullable":true},"extension":{"type":"string","maxLength":8,"minLength":1,"nullable":true},"url":{"type":"string","format":"uri"}},"nullable":false,"required":["name","extension","url"]},"IBbsArticle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"created_at":{"type":"string","format":"date-time"},"title":{"type":"string","maxLength":50,"minLength":3},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"nullable":false,"required":["id","created_at","title","body","files"]},"PartialIBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","maxLength":50,"minLength":3},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"nullable":false,"description":"Make all properties in T optional"}},"securitySchemes":{"bearer":{"type":"apiKey","in":"header","name":"Authorization"}}}}
{"openapi":"3.0.1","servers":[{"url":"https://github.com/samchon/nestia","description":"insert your server url"}],"info":{"version":"2.5.16-dev.20240320-2","title":"@nestia/test","description":"Test program of Nestia","license":{"name":"MIT"}},"paths":{"/health":{"get":{"tags":["system","health"],"parameters":[],"responses":{"200":{"description":""}},"summary":"Health check API","description":"Health check API.\n\nJust for health checking API liveness."}},"/performance":{"get":{"tags":["system","performance"],"parameters":[],"responses":{"200":{"description":"Performance info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IPerformance"}}}}},"summary":"Get server performance info","description":"Get server performance info."}},"/body":{"post":{"tags":[],"parameters":[],"requestBody":{"description":"Content to store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IBbsArticle.IStore"}}},"required":true},"responses":{"201":{"description":"Newly archived article","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IBbsArticle"}}}}},"summary":"Store an article","description":"Store an article."}},"/body/{id}":{"put":{"tags":[],"parameters":[{"name":"id","in":"path","schema":{"type":"string","format":"uuid"},"description":"","required":true}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartialIBbsArticle.IStore"}}},"required":true},"responses":{"200":{"description":""}}}}},"components":{"schemas":{"IPerformance":{"type":"object","properties":{"cpu":{"$ref":"#/components/schemas/process.global.NodeJS.CpuUsage"},"memory":{"$ref":"#/components/schemas/process.global.NodeJS.MemoryUsage"},"resource":{"$ref":"#/components/schemas/process.global.NodeJS.ResourceUsage"}},"nullable":false,"required":["cpu","memory","resource"],"description":"Performance info."},"process.global.NodeJS.CpuUsage":{"type":"object","properties":{"user":{"type":"number"},"system":{"type":"number"}},"nullable":false,"required":["user","system"]},"process.global.NodeJS.MemoryUsage":{"type":"object","properties":{"rss":{"type":"number"},"heapTotal":{"type":"number"},"heapUsed":{"type":"number"},"external":{"type":"number"},"arrayBuffers":{"type":"number"}},"nullable":false,"required":["rss","heapTotal","heapUsed","external","arrayBuffers"]},"process.global.NodeJS.ResourceUsage":{"type":"object","properties":{"fsRead":{"type":"number"},"fsWrite":{"type":"number"},"involuntaryContextSwitches":{"type":"number"},"ipcReceived":{"type":"number"},"ipcSent":{"type":"number"},"majorPageFault":{"type":"number"},"maxRSS":{"type":"number"},"minorPageFault":{"type":"number"},"sharedMemorySize":{"type":"number"},"signalsCount":{"type":"number"},"swappedOut":{"type":"number"},"systemCPUTime":{"type":"number"},"unsharedDataSize":{"type":"number"},"unsharedStackSize":{"type":"number"},"userCPUTime":{"type":"number"},"voluntaryContextSwitches":{"type":"number"}},"nullable":false,"required":["fsRead","fsWrite","involuntaryContextSwitches","ipcReceived","ipcSent","majorPageFault","maxRSS","minorPageFault","sharedMemorySize","signalsCount","swappedOut","systemCPUTime","unsharedDataSize","unsharedStackSize","userCPUTime","voluntaryContextSwitches"]},"IBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","maxLength":50,"minLength":3},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"nullable":false,"required":["title","body","files"]},"IAttachmentFile":{"type":"object","properties":{"name":{"type":"string","maxLength":255,"nullable":true},"extension":{"type":"string","maxLength":8,"minLength":1,"nullable":true},"url":{"type":"string","format":"uri"}},"nullable":false,"required":["name","extension","url"]},"IBbsArticle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"created_at":{"type":"string","format":"date-time"},"title":{"type":"string","maxLength":50,"minLength":3},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"nullable":false,"required":["id","created_at","title","body","files"]},"PartialIBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","maxLength":50,"minLength":3},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"nullable":false,"description":"Make all properties in T optional"}},"securitySchemes":{"bearer":{"type":"apiKey","in":"header","name":"Authorization"}}}}
2 changes: 1 addition & 1 deletion test/features/beautify/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "2.5.15",
"version": "2.5.16-dev.20240320-2",
"title": "@nestia/test",
"description": "Test program of Nestia",
"license": {
Expand Down
Loading

0 comments on commit 4db68f0

Please sign in to comment.