Skip to content

Commit

Permalink
Merge pull request #1126 from samchon/feat/use
Browse files Browse the repository at this point in the history
Fix samchon/typia#1410: `"use server"` case
  • Loading branch information
samchon authored Dec 3, 2024
2 parents 4b47ed6 + 386e6b6 commit ca38ade
Show file tree
Hide file tree
Showing 101 changed files with 259 additions and 195 deletions.
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"reflect-metadata": "^0.2.2",
"tgrid": "^1.0.3",
"tstl": "^3.0.0",
"typia": "^7.0.0"
"typia": "^7.0.1"
},
"devDependencies": {
"@types/autocannon": "^7.9.0",
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": "4.0.0",
"version": "4.0.1",
"description": "Nestia station",
"scripts": {
"build": "node build/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"ts-patch": "^3.2.1",
"typescript": "~5.6.3",
"typescript-transform-paths": "^3.4.7",
"typia": "^7.0.0",
"typia": "^7.0.1",
"uuid": "^10.0.0"
},
"dependencies": {
Expand Down
10 changes: 5 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/core",
"version": "4.0.0",
"version": "4.0.1",
"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": "../fetcher/nestia-fetcher-4.0.0.tgz",
"@nestia/fetcher": "^4.0.1",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"@samchon/openapi": "^2.0.0",
Expand All @@ -48,16 +48,16 @@
"reflect-metadata": ">=0.1.12",
"rxjs": ">=6.0.3",
"tgrid": "^1.0.0",
"typia": "^7.0.0",
"typia": "^7.0.1",
"ws": "^7.5.3"
},
"peerDependencies": {
"@nestia/fetcher": ">=4.0.0",
"@nestia/fetcher": ">=4.0.1",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"reflect-metadata": ">=0.1.12",
"rxjs": ">=6.0.3",
"typia": ">=7.0.0 <8.0.0"
"typia": ">=7.0.1 <8.0.0"
},
"devDependencies": {
"@nestjs/common": "^10.3.3",
Expand Down
22 changes: 21 additions & 1 deletion packages/core/src/transformers/FileTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ export namespace FileTransformer {
}),
transformer,
);
const index: number = find_import_injection_index(file);
return ts.factory.updateSourceFile(
file,
[...importer.toStatements(), ...file.statements],
[
...file.statements.slice(0, index),
...importer.toStatements(),
...file.statements.slice(index),
],
false,
file.referencedFiles,
file.typeReferenceDirectives,
Expand Down Expand Up @@ -80,6 +85,21 @@ export namespace FileTransformer {
return null;
}
};

const find_import_injection_index = (file: ts.SourceFile): number => {
let i: number = 0;
for (; i < file.statements.length; ++i) {
const stmt: ts.Statement = file.statements[i]!;
if (
ts.isExpressionStatement(stmt) &&
ts.isStringLiteralLike(stmt.expression) &&
stmt.expression.text.startsWith("use ")
)
continue;
break;
}
return i;
};
}

const isTransformerError = (error: any): error is TransformerError =>
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"ts-patch": "^3.2.1",
"typescript": "~5.6.3",
"typescript-transform-paths": "^3.4.7",
"typia": "^7.0.0"
"typia": "^7.0.1"
},
"files": [
"lib",
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/editor",
"version": "0.9.0",
"version": "0.9.1",
"typings": "lib/index.d.ts",
"main": "lib/index.js",
"module": "lib/index.mjs",
Expand Down Expand Up @@ -34,12 +34,12 @@
"homepage": "https://nestia.io",
"dependencies": {
"@mui/material": "^5.15.6",
"@nestia/migrate": "^0.21.0",
"@nestia/migrate": "^0.21.1",
"@stackblitz/sdk": "^1.11.0",
"js-yaml": "^4.1.0",
"prettier": "3.3.3",
"react-mui-fileuploader": "^0.5.2",
"typia": "^7.0.0"
"typia": "^7.0.1"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/fetcher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/fetcher",
"version": "4.0.0",
"version": "4.0.1",
"description": "Fetcher library of Nestia SDK",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand All @@ -27,7 +27,7 @@
"homepage": "https://nestia.io",
"dependencies": {
"@samchon/openapi": "^2.0.0",
"typia": "^7.0.0"
"typia": "^7.0.1"
},
"peerDependencies": {
"typescript": ">= 4.8.0"
Expand All @@ -38,7 +38,7 @@
"@typescript-eslint/parser": "^5.46.1",
"rimraf": "^3.0.2",
"typescript": "~5.6.3",
"typia": "^7.0.0"
"typia": "^7.0.1"
},
"files": [
"README.md",
Expand Down
10 changes: 5 additions & 5 deletions packages/migrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/migrate",
"version": "0.21.0",
"version": "0.21.1",
"description": "Migration program from swagger to NestJS",
"typings": "lib/index.d.ts",
"main": "lib/index.js",
Expand Down Expand Up @@ -38,9 +38,9 @@
"homepage": "https://nestia.io",
"devDependencies": {
"@nestia/benchmark": "^0.3.0",
"@nestia/core": "^4.0.0",
"@nestia/core": "^4.0.1",
"@nestia/e2e": "^0.7.0",
"@nestia/fetcher": "^4.0.0",
"@nestia/fetcher": "^4.0.1",
"@nestjs/common": "^10.3.8",
"@nestjs/core": "^10.3.8",
"@nestjs/platform-express": "^10.3.8",
Expand Down Expand Up @@ -71,14 +71,14 @@
"typescript-transform-paths": "^3.5.2"
},
"dependencies": {
"@nestia/sdk": "^4.0.0",
"@nestia/sdk": "^4.0.1",
"@samchon/openapi": "^2.0.0",
"commander": "10.0.0",
"inquirer": "8.2.5",
"prettier": "^3.2.5",
"tstl": "^3.0.0",
"typescript": "~5.6.3",
"typia": "^7.0.0"
"typia": "^7.0.1"
},
"files": [
"lib",
Expand Down
14 changes: 7 additions & 7 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/sdk",
"version": "4.0.0",
"version": "4.0.1",
"description": "Nestia SDK and Swagger generator",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -32,8 +32,8 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/core": "../core/nestia-core-4.0.0.tgz",
"@nestia/fetcher": "../fetcher/nestia-fetcher-4.0.0.tgz",
"@nestia/core": "^4.0.1",
"@nestia/fetcher": "^4.0.1",
"@samchon/openapi": "^2.0.0",
"cli": "^1.0.1",
"get-function-location": "^2.0.0",
Expand All @@ -44,16 +44,16 @@
"tsconfck": "^2.1.2",
"tsconfig-paths": "^4.1.1",
"tstl": "^3.0.0",
"typia": "^7.0.0"
"typia": "^7.0.1"
},
"peerDependencies": {
"@nestia/core": ">=4.0.0",
"@nestia/fetcher": ">=4.0.0",
"@nestia/core": ">=4.0.1",
"@nestia/fetcher": ">=4.0.1",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"reflect-metadata": ">=0.1.12",
"ts-node": ">=10.6.0",
"typia": ">=7.0.0 <8.0.0"
"typia": ">=7.0.1 <8.0.0"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
Expand Down
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": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-globalPrefix-versionUri/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-globalPrefix/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-routerModule/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-versionHeader/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-versionUri/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
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": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/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.1.0","servers":[{"url":"https://github.com/samchon/nestia","description":"insert your server url"}],"info":{"version":"4.0.0","title":"@samchon/nestia-test","description":"Test program of Nestia","license":{"name":"MIT"}},"paths":{"/health":{"get":{"summary":"Health check API","description":"Health check API.\n\nJust for health checking API liveness.","tags":["system","health"],"parameters":[],"responses":{"200":{"description":"","content":{"application/json":{}}}}}},"/performance":{"get":{"summary":"Get server performance info","description":"Get server performance info.","tags":["system","performance"],"parameters":[],"responses":{"200":{"description":"Performance info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IPerformance"}}}}}}},"/body":{"post":{"summary":"Store an article","description":"Store an article.","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"}}}}}}},"/body/{id}":{"put":{"tags":[],"parameters":[{"name":"id","in":"path","schema":{"type":"string","format":"uuid"},"required":true}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartialIBbsArticle.IStore"}}},"required":true},"responses":{"200":{"description":"","content":{"application/json":{}}}}}}},"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"}},"required":["cpu","memory","resource"],"description":"Performance info."},"process.global.NodeJS.CpuUsage":{"type":"object","properties":{"user":{"type":"number"},"system":{"type":"number"}},"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"}},"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"}},"required":["fsRead","fsWrite","involuntaryContextSwitches","ipcReceived","ipcSent","majorPageFault","maxRSS","minorPageFault","sharedMemorySize","signalsCount","swappedOut","systemCPUTime","unsharedDataSize","unsharedStackSize","userCPUTime","voluntaryContextSwitches"]},"IBbsArticle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"created_at":{"type":"string","format":"date-time"},"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":["id","created_at","title","body","files"]},"IAttachmentFile":{"type":"object","properties":{"name":{"oneOf":[{"type":"null"},{"type":"string","maxLength":255}]},"extension":{"oneOf":[{"type":"null"},{"type":"string","minLength":1,"maxLength":8}]},"url":{"type":"string","format":"uri"}},"required":["name","extension","url"]},"IBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":["title","body","files"]},"PartialIBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":[],"description":"Make all properties in T optional"}},"securitySchemes":{"bearer":{"type":"apiKey"}}},"tags":[{"name":"system"},{"name":"health"},{"name":"performance"}],"x-samchon-emended":true}
{"openapi":"3.1.0","servers":[{"url":"https://github.com/samchon/nestia","description":"insert your server url"}],"info":{"version":"4.0.1-dev.20241203","title":"@samchon/nestia-test","description":"Test program of Nestia","license":{"name":"MIT"}},"paths":{"/health":{"get":{"summary":"Health check API","description":"Health check API.\n\nJust for health checking API liveness.","tags":["system","health"],"parameters":[],"responses":{"200":{"description":"","content":{"application/json":{}}}}}},"/performance":{"get":{"summary":"Get server performance info","description":"Get server performance info.","tags":["system","performance"],"parameters":[],"responses":{"200":{"description":"Performance info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IPerformance"}}}}}}},"/body":{"post":{"summary":"Store an article","description":"Store an article.","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"}}}}}}},"/body/{id}":{"put":{"tags":[],"parameters":[{"name":"id","in":"path","schema":{"type":"string","format":"uuid"},"required":true}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartialIBbsArticle.IStore"}}},"required":true},"responses":{"200":{"description":"","content":{"application/json":{}}}}}}},"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"}},"required":["cpu","memory","resource"],"description":"Performance info."},"process.global.NodeJS.CpuUsage":{"type":"object","properties":{"user":{"type":"number"},"system":{"type":"number"}},"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"}},"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"}},"required":["fsRead","fsWrite","involuntaryContextSwitches","ipcReceived","ipcSent","majorPageFault","maxRSS","minorPageFault","sharedMemorySize","signalsCount","swappedOut","systemCPUTime","unsharedDataSize","unsharedStackSize","userCPUTime","voluntaryContextSwitches"]},"IBbsArticle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"created_at":{"type":"string","format":"date-time"},"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":["id","created_at","title","body","files"]},"IAttachmentFile":{"type":"object","properties":{"name":{"oneOf":[{"type":"null"},{"type":"string","maxLength":255}]},"extension":{"oneOf":[{"type":"null"},{"type":"string","minLength":1,"maxLength":8}]},"url":{"type":"string","format":"uri"}},"required":["name","extension","url"]},"IBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":["title","body","files"]},"PartialIBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":[],"description":"Make all properties in T optional"}},"securitySchemes":{"bearer":{"type":"apiKey"}}},"tags":[{"name":"system"},{"name":"health"},{"name":"performance"}],"x-samchon-emended":true}
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": "4.0.0",
"version": "4.0.1-dev.20241203",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
Loading

0 comments on commit ca38ade

Please sign in to comment.