Skip to content

Commit

Permalink
Publish v2.2 with @nestia/migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Oct 10, 2023
1 parent 569e6a7 commit 0208b32
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 24 deletions.
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.2.0-dev.20231010",
"version": "2.2.0",
"description": "Super-fast validation decorators of NestJS",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -34,7 +34,7 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/fetcher": "^2.2.0-dev.20231010",
"@nestia/fetcher": "^2.2.0",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"@nestjs/platform-express": ">=7.0.1",
Expand All @@ -47,7 +47,7 @@
"typia": ">=5.2.0 <6.0.0"
},
"peerDependencies": {
"@nestia/fetcher": ">=2.2.0-dev.20231010",
"@nestia/fetcher": ">=2.2.0",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"@nestjs/platform-express": ">=7.0.1",
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.2.0-dev.20231010",
"version": "2.2.0",
"description": "Fetcher library of Nestia SDK",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
24 changes: 17 additions & 7 deletions packages/fetcher/src/internal/IFetchRoute.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Properties of remote API route.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IFetchRoute<
Method extends "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE",
> {
Expand All @@ -15,13 +20,13 @@ export interface IFetchRoute<
* Request body data info.
*/
request: Method extends "DELETE" | "POST" | "PUT" | "PATCH"
? IRoute.IBody | null
? IFetchRoute.IBody | null
: null;

/**
* Response body data info.
*/
response: Method extends "HEAD" ? null : IRoute.IBody;
response: Method extends "HEAD" ? null : IFetchRoute.IBody;

/**
* When special status code being used.
Expand All @@ -32,15 +37,20 @@ export interface IFetchRoute<
* Parser of the query string.
*
* If content type of response body is `application/x-www-form-urlencoded`,
* then this `query` function would be called.
* then this `parseQuery` function would be called.
*
* If you've forgotten to configuring this property about the
* `application/x-www-form-urlencoded` typed response body data,
* then `URLSearchParams` instance would be returned instead.
* If you've forgotten to configuring this `parseQuery` property about the
* `application/x-www-form-urlencoded` typed response body data, then
* only the `URLSearchParams` typed instance would be returned instead.
*/
parseQuery?(input: URLSearchParams): any;
}
export namespace IRoute {
export namespace IFetchRoute {
/**
* Metadata of body.
*
* Describes how content-type being used in body, and whether encrypted or not.
*/
export interface IBody {
type:
| "application/json"
Expand Down
6 changes: 3 additions & 3 deletions packages/migrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/migrate",
"version": "0.4.2",
"version": "0.4.3",
"description": "Migration program from swagger to NestJS",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -30,8 +30,8 @@
},
"homepage": "https://github.com/samchon/nestia#readme",
"devDependencies": {
"@nestia/core": "^2.1.5",
"@nestia/fetcher": "^2.1.5",
"@nestia/core": "^2.2.0-dev.20231010",
"@nestia/fetcher": "^2.2.0-dev.20231010",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/node": "^20.3.3",
"prettier": "^2.8.8",
Expand Down
32 changes: 30 additions & 2 deletions packages/migrate/src/programmers/RouteProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export namespace RouteProgrammer {
console.log(
`Failed to migrate ${props.method.toUpperCase()} ${
props.path
}: @nestia/migrate supports only application/json or text/plain format yet.`,
}: @nestia/migrate supports only application/json, application/x-www-form-urlencoded or text/plain format yet.`,
);
return null;
} else if (
Expand Down Expand Up @@ -296,7 +296,6 @@ export namespace RouteProgrammer {
e[0].includes("application/json")
: e[0].includes("application/json"),
);

if (json) {
const { schema } = json[1];
return {
Expand All @@ -308,6 +307,19 @@ export namespace RouteProgrammer {
};
}

const query = entries.find((e) =>
e[0].includes("application/x-www-form-urlencoded"),
);
if (query) {
const { schema } = query[1];
return {
type: "application/x-www-form-urlencoded",
schema: isNotObjectLiteral(schema)
? schema
: emplacer(schema),
};
}

const text = entries.find((e) => e[0].includes("text/plain"));
if (text) return { type: "text/plain", schema: { type: "string" } };
return false;
Expand Down Expand Up @@ -356,6 +368,13 @@ export namespace RouteProgrammer {
external("@nestjs/common")(str),
)}`,
]
: route.success?.type ===
"application/x-www-form-urlencoded"
? [
`@${external("@nestia/core")(
"TypedQuery",
)}.${methoder((str) => str)}`,
]
: route.method === "head"
? [
`@${external("@nestjs/common")("Head")}${methoder(
Expand Down Expand Up @@ -429,6 +448,15 @@ export namespace RouteProgrammer {
references,
)(importer)(route.body.schema)},`,
]
: route.body.type ===
"application/x-www-form-urlencoded"
? [
` @${external("@nestia/core")(
"TypedQuery",
)}.Body() body: ${SchemaProgrammer.write(
components,
)(references)(importer)(route.body.schema)},`,
]
: [
` @${external("@nestia/core")(
"PlainBody",
Expand Down
5 changes: 4 additions & 1 deletion packages/migrate/src/structures/IMigrateRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export namespace IMigrateRoute {
description?: string;
}
export interface IBody {
type: "text/plain" | "application/json";
type:
| "text/plain"
| "application/json"
| "application/x-www-form-urlencoded";
schema: ISwaggerSchema;
"x-nestia-encrypted"?: boolean;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/migrate/src/structures/ISwaggerRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ export namespace ISwaggerRoute {
"application/json"?: {
schema: ISwaggerSchema;
};
"application/x-www-form-urlencoded"?: {
schema: ISwaggerSchema;
};
}
}
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.2.0-dev.20231010",
"version": "2.2.0",
"description": "Nestia SDK and Swagger generator",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -35,7 +35,7 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/fetcher": "^2.2.0-dev.20231010",
"@nestia/fetcher": "^2.2.0",
"cli": "^1.0.1",
"glob": "^7.2.0",
"path-to-regexp": "^6.2.1",
Expand All @@ -47,7 +47,7 @@
"typia": "^5.2.0"
},
"peerDependencies": {
"@nestia/fetcher": ">=2.2.0-dev.20231010",
"@nestia/fetcher": ">=2.2.0",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"reflect-metadata": ">=0.1.12",
Expand Down
8 changes: 4 additions & 4 deletions test/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@nestia/test",
"version": "2.2.0-dev.20231010",
"version": "2.2.0",
"description": "Test program of Nestia",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -37,9 +37,9 @@
"typia": "^5.2.0",
"uuid": "^9.0.0",
"nestia": "^4.5.0",
"@nestia/core": "^2.2.0-dev.20231010",
"@nestia/core": "^2.2.0",
"@nestia/e2e": "^0.3.6",
"@nestia/fetcher": "^2.2.0-dev.20231010",
"@nestia/sdk": "^2.2.0-dev.20231010"
"@nestia/fetcher": "^2.2.0",
"@nestia/sdk": "^2.2.0"
}
}

0 comments on commit 0208b32

Please sign in to comment.