@nestia/core 1.1.0-dev.20230420-2 → 1.1.0-dev.20230427
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.
- package/README.md +53 -101
- package/lib/decorators/TypedQuery.js +8 -4
- package/lib/decorators/TypedQuery.js.map +1 -1
- package/lib/programmers/TypedQueryProgrammer.js +7 -5
- package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
- package/package.json +4 -4
- package/src/decorators/TypedQuery.ts +10 -10
- package/src/programmers/TypedQueryProgrammer.ts +15 -9
package/README.md
CHANGED
|
@@ -1,103 +1,55 @@
|
|
|
1
|
-
# Nestia
|
|
1
|
+
# Nestia
|
|
2
|
+

|
|
3
|
+
|
|
2
4
|
[](https://github.com/samchon/nestia/blob/master/LICENSE)
|
|
3
5
|
[](https://www.npmjs.com/package/@nestia/core)
|
|
4
|
-
[.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## Features
|
|
67
|
-
```typescript
|
|
68
|
-
import { Controller } from "@nestjs/common";
|
|
69
|
-
import { TypedBody, TypedRoute } from "@nestia/core";
|
|
70
|
-
|
|
71
|
-
import { IBbsArticle } from "@bbs-api/structures/IBbsArticle";
|
|
72
|
-
|
|
73
|
-
@Controller("bbs/articles")
|
|
74
|
-
export class BbsArticlesController {
|
|
75
|
-
/**
|
|
76
|
-
* Store a new content.
|
|
77
|
-
*
|
|
78
|
-
* @param inupt Content to store
|
|
79
|
-
* @returns Newly archived article
|
|
80
|
-
*/
|
|
81
|
-
@TypedRoute.Put(":id") // 200x faster and safer JSON serialization
|
|
82
|
-
public async store(
|
|
83
|
-
@TypedParam("section", "string") section: string,
|
|
84
|
-
@TypedParam("id", "uuid") id: string,
|
|
85
|
-
@TypedBody() input: IBbsArticle.IUpdate // super-fast validator
|
|
86
|
-
): Promise<IBbsArticle.IContent>;
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
About detailed features, read [Guide Documents](https://github.com/samchon/nestia/wiki)
|
|
91
|
-
|
|
92
|
-
- Decorators
|
|
93
|
-
- [TypedRoute](https://github.com/samchon/nestia/wiki/Core-Library#typedroute)
|
|
94
|
-
- [TypedBody](https://github.com/samchon/nestia/wiki/Core-Library#typedbody)
|
|
95
|
-
- [TypedQuery](https://github.com/samchon/nestia/wiki/Core-Library#typedquery)
|
|
96
|
-
- [TypedParam](https://github.com/samchon/nestia/wiki/Core-Library#typedparam)
|
|
97
|
-
- Enhancements
|
|
98
|
-
- [Comment Tags](https://github.com/samchon/nestia/wiki/Core-Library#comment-tags)
|
|
99
|
-
- [Configuration](https://github.com/samchon/nestia/wiki/Core-Library#configuration)
|
|
100
|
-
- Advanced Usage
|
|
101
|
-
- [DynamicModule](https://github.com/samchon/nestia/wiki/Core-Library#dynamicmodule)
|
|
102
|
-
- [Encryption](https://github.com/samchon/nestia/wiki/Core-Library#encryption)
|
|
103
|
-
- [Inheritance](https://github.com/samchon/nestia/wiki/Core-Library#inheritance)
|
|
6
|
+
[](https://www.npmjs.com/package/nestia)
|
|
7
|
+
[](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
|
|
8
|
+
[](https://nestia.io/docs/)
|
|
9
|
+
|
|
10
|
+
Nestia is a set of helper libraries for NestJS, supporting below features:
|
|
11
|
+
|
|
12
|
+
- `@nestia/core`: super-fast decorators
|
|
13
|
+
- `@nestia/sdk`: evolved SDK and Swagger generator
|
|
14
|
+
- `nestia`: just CLI (command line interface) tool
|
|
15
|
+
|
|
16
|
+
> **Note**
|
|
17
|
+
>
|
|
18
|
+
> - **Only one line** required, with pure TypeScript type
|
|
19
|
+
> - Runtime validator is **20,000x faster** than `class-validator`
|
|
20
|
+
> - JSON serialization is **200x faster** than `class-transformer`
|
|
21
|
+
> - SDK is similar with [tRPC](https://trpc.io), but much advanced
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
> Left is server code, and right is client code utilizing SDK
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Sponsors and Backers
|
|
31
|
+
Thanks for your support.
|
|
32
|
+
|
|
33
|
+
Your donation would encourage `nestia` development.
|
|
34
|
+
|
|
35
|
+
[](https://opencollective.com/nestia)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Guide Documents
|
|
41
|
+
Check out the document in the [website](https://nestia.io/docs/):
|
|
42
|
+
|
|
43
|
+
### 🏠 Home
|
|
44
|
+
- [Introduction](https://nestia.io/docs/)
|
|
45
|
+
- [Setup](https://nestia.io/docs/setup/)
|
|
46
|
+
|
|
47
|
+
### 📖 Features
|
|
48
|
+
- Core Library
|
|
49
|
+
- [TypedRoute](https://nestia.io/docs/core/TypedRoute/)
|
|
50
|
+
- [TypedBody](https://nestia.io/docs/core/TypedBody/)
|
|
51
|
+
- [TypedParam](https://nestia.io/docs/core/TypedParam/)
|
|
52
|
+
- [TypedQuery](https://nestia.io/docs/core/TypedRoute/)
|
|
53
|
+
- SDK/Swagger Generator
|
|
54
|
+
- [SDK Library](https://nestia.io/docs/sdk/sdk/)
|
|
55
|
+
- [Swagger Documents](https://nestia.io/docs/sdk/swagger/)
|
|
@@ -73,19 +73,23 @@ exports.TypedQuery = TypedQuery;
|
|
|
73
73
|
*/
|
|
74
74
|
(function (TypedQuery) {
|
|
75
75
|
function boolean(str) {
|
|
76
|
-
|
|
76
|
+
if (str === null)
|
|
77
|
+
return undefined;
|
|
78
|
+
else if (str === "null")
|
|
79
|
+
return null;
|
|
80
|
+
return str.length ? Boolean(str) : true;
|
|
77
81
|
}
|
|
78
82
|
TypedQuery.boolean = boolean;
|
|
79
83
|
function number(str) {
|
|
80
|
-
return (str === null || str === void 0 ? void 0 : str.length) ? Number(str) : undefined;
|
|
84
|
+
return (str === null || str === void 0 ? void 0 : str.length) ? (str === "null" ? null : Number(str)) : undefined;
|
|
81
85
|
}
|
|
82
86
|
TypedQuery.number = number;
|
|
83
87
|
function bigint(str) {
|
|
84
|
-
return (str === null || str === void 0 ? void 0 : str.length) ? BigInt(str) : undefined;
|
|
88
|
+
return (str === null || str === void 0 ? void 0 : str.length) ? (str === "null" ? null : BigInt(str)) : undefined;
|
|
85
89
|
}
|
|
86
90
|
TypedQuery.bigint = bigint;
|
|
87
91
|
function string(str) {
|
|
88
|
-
return str
|
|
92
|
+
return str === null ? undefined : str === "null" ? null : str;
|
|
89
93
|
}
|
|
90
94
|
TypedQuery.string = string;
|
|
91
95
|
})(TypedQuery = exports.TypedQuery || (exports.TypedQuery = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedQuery.js","sourceRoot":"","sources":["../../src/decorators/TypedQuery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAwE;AAGxE,+BAA+B;AAE/B,4DAA2D;AAE3D;;;;;;;;;;;;GAYG;AACH,SAAgB,UAAU,CACtB,OAAwC;IAExC,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,IAAA,+BAAc,EAAC,YAAY,CAAC,CAAC;IAE9D,OAAO,IAAA,6BAAoB,EAAC,SAAe,UAAU,CACjD,QAAa,EACb,GAAqB;;;;gBAEf,OAAO,GAAoB,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;gBAC3D,MAAM,GAAoB,IAAI,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;gBACvE,sBAAO,OAAO,CAAC,MAAM,CAAC,EAAC;;;KAC1B,CAAC,EAAE,CAAC;AACT,CAAC;AAbD,gCAaC;AAED;;GAEG;AACH,WAAiB,UAAU;IACvB,SAAgB,OAAO,
|
|
1
|
+
{"version":3,"file":"TypedQuery.js","sourceRoot":"","sources":["../../src/decorators/TypedQuery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAwE;AAGxE,+BAA+B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,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3E,CAAC;IAFe,iBAAM,SAErB,CAAA;IACD,SAAgB,MAAM,CAAC,GAAkB;QACrC,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAClE,CAAC;IAFe,iBAAM,SAErB,CAAA;AACL,CAAC,EAfgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAe1B;AACD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,cAAM,CAAC,CAAC;AAElC;;GAEG;AACH,SAAS,IAAI,CAAC,GAAW;IACrB,IAAM,KAAK,GAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -103,9 +103,7 @@ var TypedQueryProgrammer;
|
|
|
103
103
|
return function (key) {
|
|
104
104
|
return function (value, depth) {
|
|
105
105
|
var e_2, _a, e_3, _b, e_4, _c, e_5, _d, e_6, _e;
|
|
106
|
-
if (value.
|
|
107
|
-
throw new Error(ErrorMessages.property(obj)(key)("nullable type is not allowed. Use undefindable type instead."));
|
|
108
|
-
else if (depth === 1 && value.required === false)
|
|
106
|
+
if (depth === 1 && value.required === false)
|
|
109
107
|
throw new Error(ErrorMessages.property(obj)(key)("optional type is not allowed in array."));
|
|
110
108
|
else if (value.maps.length ||
|
|
111
109
|
value.sets.length ||
|
|
@@ -138,9 +136,13 @@ var TypedQueryProgrammer;
|
|
|
138
136
|
}
|
|
139
137
|
finally { if (e_3) throw e_3.error; }
|
|
140
138
|
}
|
|
141
|
-
if (depth === 0) {
|
|
142
|
-
if (atom.length
|
|
139
|
+
if (depth === 0 && (value.arrays.length || value.arrays.length)) {
|
|
140
|
+
if (atom.length)
|
|
143
141
|
throw new Error(ErrorMessages.property(obj)(key)("union type is not allowed"));
|
|
142
|
+
else if (value.required === false)
|
|
143
|
+
throw new Error(ErrorMessages.property(obj)(key)("array type cannot be optional"));
|
|
144
|
+
else if (value.nullable === true)
|
|
145
|
+
throw new Error(ErrorMessages.property(obj)(key)("array type cannot be nullable"));
|
|
144
146
|
try {
|
|
145
147
|
for (var _k = __values(value.arrays), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
146
148
|
var elem = _l.value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedQueryProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedQueryProgrammer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4B;AAE5B,2EAA0E;AAC1E,6EAA4E;AAC5E,uEAAsE;AACtE,yEAAwE;AAIxE,2EAA0E;AAC1E,qFAAmF;AAKnF,IAAiB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"TypedQueryProgrammer.js","sourceRoot":"","sources":["../../src/programmers/TypedQueryProgrammer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4B;AAE5B,2EAA0E;AAC1E,6EAA4E;AAC5E,uEAAsE;AACtE,yEAAwE;AAIxE,2EAA0E;AAC1E,qFAAmF;AAKnF,IAAiB,oBAAoB,CA8NpC;AA9ND,WAAiB,oBAAoB;IACpB,6BAAQ,GACjB,UAAC,OAAgC,EAAE,MAAiC;QACpE,OAAA,UAAC,IAAa;YACV,IAAM,MAAM,GAAmB,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;YAChE,OAAO,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,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A,oBAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE;oBAC3D,KAAK;iBACR,CAAC;YAFF,CAEE;QAHN,CAGM;IAJN,CAIM,CAAC;AACf,CAAC,EA9NgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QA8NpC;AAED,IAAU,aAAa,CAStB;AATD,WAAU,aAAa;IACN,oBAAM,GAAG,UAAC,IAAc,IAAK,OAAA,UAAC,OAAe;QACtD,OAAA,0CAAmC,IAAI,kBAAQ,OAAO,CAAE;IAAxD,CAAwD,EADlB,CACkB,CAAC;IAEhD,sBAAQ,GACjB,UAAC,GAAmB,IAAK,OAAA,UAAC,GAAa,IAAK,OAAA,UAAC,OAAe;QACxD,OAAA,0CACI,GAAG,CAAC,IAAI,2BACK,GAAG,CAAC,OAAO,EAAE,gBAAM,OAAO,CAAE;IAF7C,CAE6C,EAHL,CAGK,EAHxB,CAGwB,CAAC;AAC1D,CAAC,EATS,aAAa,KAAb,aAAa,QAStB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/core",
|
|
3
|
-
"version": "1.1.0-dev.
|
|
3
|
+
"version": "1.1.0-dev.20230427",
|
|
4
4
|
"description": "Super-fast validation decorators of NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/samchon/nestia",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nestia/fetcher": "^1.1.
|
|
39
|
+
"@nestia/fetcher": "^1.1.2",
|
|
40
40
|
"@nestjs/common": ">= 7.0.1",
|
|
41
41
|
"@nestjs/core": ">= 7.0.1",
|
|
42
42
|
"@nestjs/platform-express": ">= 7.0.1",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"raw-body": ">= 2.0.0",
|
|
45
45
|
"reflect-metadata": ">= 0.1.12",
|
|
46
46
|
"rxjs": ">= 6.0.0",
|
|
47
|
-
"typia": "^3.8.
|
|
47
|
+
"typia": "^3.8.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"typescript": ">= 4.5.2"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@typescript-eslint/parser": "^5.46.1",
|
|
58
58
|
"commander": "^10.0.0",
|
|
59
59
|
"comment-json": "^4.2.3",
|
|
60
|
-
"eslint-plugin-deprecation": "^1.
|
|
60
|
+
"eslint-plugin-deprecation": "^1.4.1",
|
|
61
61
|
"git-last-commit": "^1.0.1",
|
|
62
62
|
"inquirer": "^8.2.5",
|
|
63
63
|
"prettier": "^2.8.7",
|
|
@@ -37,19 +37,19 @@ export function TypedQuery<T>(
|
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
39
39
|
export namespace TypedQuery {
|
|
40
|
-
export function boolean(
|
|
41
|
-
str
|
|
42
|
-
|
|
43
|
-
return str
|
|
40
|
+
export function boolean(str: string | null): boolean | null | undefined {
|
|
41
|
+
if (str === null) return undefined;
|
|
42
|
+
else if (str === "null") return null;
|
|
43
|
+
return str.length ? Boolean(str) : true;
|
|
44
44
|
}
|
|
45
|
-
export function number(str: string | null
|
|
46
|
-
return str?.length ? Number(str) : undefined;
|
|
45
|
+
export function number(str: string | null): number | null | undefined {
|
|
46
|
+
return str?.length ? (str === "null" ? null : Number(str)) : undefined;
|
|
47
47
|
}
|
|
48
|
-
export function bigint(str: string | null
|
|
49
|
-
return str?.length ? BigInt(str) : undefined;
|
|
48
|
+
export function bigint(str: string | null): bigint | null | undefined {
|
|
49
|
+
return str?.length ? (str === "null" ? null : BigInt(str)) : undefined;
|
|
50
50
|
}
|
|
51
|
-
export function string(str: string | null
|
|
52
|
-
return str
|
|
51
|
+
export function string(str: string | null): string | null | undefined {
|
|
52
|
+
return str === null ? undefined : str === "null" ? null : str;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
Object.assign(TypedQuery, assert);
|
|
@@ -61,13 +61,7 @@ export namespace TypedQueryProgrammer {
|
|
|
61
61
|
(obj: MetadataObject) =>
|
|
62
62
|
(key: Metadata) =>
|
|
63
63
|
(value: Metadata, depth: number): string[] => {
|
|
64
|
-
if (value.
|
|
65
|
-
throw new Error(
|
|
66
|
-
ErrorMessages.property(obj)(key)(
|
|
67
|
-
"nullable type is not allowed. Use undefindable type instead.",
|
|
68
|
-
),
|
|
69
|
-
);
|
|
70
|
-
else if (depth === 1 && value.required === false)
|
|
64
|
+
if (depth === 1 && value.required === false)
|
|
71
65
|
throw new Error(
|
|
72
66
|
ErrorMessages.property(obj)(key)(
|
|
73
67
|
"optional type is not allowed in array.",
|
|
@@ -88,13 +82,25 @@ export namespace TypedQueryProgrammer {
|
|
|
88
82
|
for (const type of value.atomics) atom.push(type);
|
|
89
83
|
for (const { type } of value.constants) atom.push(type);
|
|
90
84
|
|
|
91
|
-
if (depth === 0) {
|
|
92
|
-
if (atom.length
|
|
85
|
+
if (depth === 0 && (value.arrays.length || value.arrays.length)) {
|
|
86
|
+
if (atom.length)
|
|
93
87
|
throw new Error(
|
|
94
88
|
ErrorMessages.property(obj)(key)(
|
|
95
89
|
"union type is not allowed",
|
|
96
90
|
),
|
|
97
91
|
);
|
|
92
|
+
else if (value.required === false)
|
|
93
|
+
throw new Error(
|
|
94
|
+
ErrorMessages.property(obj)(key)(
|
|
95
|
+
"array type cannot be optional",
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
else if (value.nullable === true)
|
|
99
|
+
throw new Error(
|
|
100
|
+
ErrorMessages.property(obj)(key)(
|
|
101
|
+
"array type cannot be nullable",
|
|
102
|
+
),
|
|
103
|
+
);
|
|
98
104
|
for (const elem of value.arrays)
|
|
99
105
|
atom.push(...validate(obj)(key)(elem, depth + 1));
|
|
100
106
|
for (const tuple of value.tuples)
|