typia 3.4.9 → 3.4.10
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 +37 -95
- package/lib/executable/typia.js +0 -0
- package/lib/factories/ExpressionFactory.d.ts +1 -1
- package/lib/factories/ExpressionFactory.js +4 -5
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/ValueFactory.d.ts +1 -1
- package/package.json +1 -1
- package/src/factories/ExpressionFactory.ts +13 -5
package/README.md
CHANGED
|
@@ -41,6 +41,16 @@ Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
## Sponsors and Backers
|
|
45
|
+
Thanks for your support.
|
|
46
|
+
|
|
47
|
+
Your donation would encourage `typia` development.
|
|
48
|
+
|
|
49
|
+
[](https://opencollective.com/typia)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
44
54
|
## Setup
|
|
45
55
|
### Setup Wizard
|
|
46
56
|
```bash
|
|
@@ -78,7 +88,7 @@ If you want to install and setup `typia` manually, read [Guide Documents - Setup
|
|
|
78
88
|
|
|
79
89
|
Also, the [Guide Documents - Setup](https://github.com/samchon/typia/wiki/Setup), you can learn how to use pure TypeScript compiler `tsc` instead of installing the `ttypescript` compiler with `ttsc` command.
|
|
80
90
|
|
|
81
|
-
###
|
|
91
|
+
### Vite
|
|
82
92
|
When you want to setup `typia` on your frontend project with [`vite`](https://vitejs.dev/), just configure `vite.config.ts` like below.
|
|
83
93
|
|
|
84
94
|
For reference, don't forget running [Setup Wizard](#setup-wizard) before.
|
|
@@ -203,104 +213,36 @@ export function createAssertStringify<T>(): (input: T) => string;
|
|
|
203
213
|
|
|
204
214
|
## Appendix
|
|
205
215
|
### Nestia
|
|
206
|
-
https://github.com/samchon/nestia
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
Reading below table and example code, feel how the "compilation level" makes `nestia` stronger.
|
|
213
|
-
|
|
214
|
-
Components | `nestia`::SDK | `nestia`::swagger | `@nestjs/swagger`
|
|
215
|
-
-----------|---|---|---
|
|
216
|
-
Pure DTO interface | ✔ | ✔ | ❌
|
|
217
|
-
Description comments | ✔ | ✔ | ❌
|
|
218
|
-
Simple structure | ✔ | ✔ | ✔
|
|
219
|
-
Generic type | ✔ | ✔ | ❌
|
|
220
|
-
Union type | ✔ | ✔ | ▲
|
|
221
|
-
Intersection type | ✔ | ✔ | ▲
|
|
222
|
-
Conditional type | ✔ | ▲ | ❌
|
|
223
|
-
Auto completion | ✔ | ❌ | ❌
|
|
224
|
-
Type hints | ✔ | ❌ | ❌
|
|
225
|
-
5x faster `JSON.stringify()` | ✔ | ❌ | ❌
|
|
226
|
-
Ensure type safety | ✅ | ❌ | ❌
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
// IMPORT SDK LIBRARY GENERATED BY NESTIA
|
|
230
|
-
import api from "@samchon/shopping-api";
|
|
231
|
-
import { IPage } from "@samchon/shopping-api/lib/structures/IPage";
|
|
232
|
-
import { ISale } from "@samchon/shopping-api/lib/structures/ISale";
|
|
233
|
-
import { ISaleArticleComment } from "@samchon/shopping-api/lib/structures/ISaleArticleComment";
|
|
234
|
-
import { ISaleQuestion } from "@samchon/shopping-api/lib/structures/ISaleQuestion";
|
|
235
|
-
|
|
236
|
-
export async function trace_sale_question_and_comment
|
|
237
|
-
(connection: api.IConnection): Promise<void>
|
|
238
|
-
{
|
|
239
|
-
// LIST UP SALE SUMMARIES
|
|
240
|
-
const index: IPage<ISale.ISummary> = await api.functional.shoppings.sales.index
|
|
241
|
-
(
|
|
242
|
-
connection,
|
|
243
|
-
"general",
|
|
244
|
-
{ limit: 100, page: 1 }
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
// PICK A SALE
|
|
248
|
-
const sale: ISale = await api.functional.shoppings.sales.at
|
|
249
|
-
(
|
|
250
|
-
connection,
|
|
251
|
-
index.data[0].id
|
|
252
|
-
);
|
|
253
|
-
console.log("sale", sale);
|
|
254
|
-
|
|
255
|
-
// WRITE A QUESTION
|
|
256
|
-
const question: ISaleQuestion = await api.functional.shoppings.sales.questions.store
|
|
257
|
-
(
|
|
258
|
-
connection,
|
|
259
|
-
"general",
|
|
260
|
-
sale.id,
|
|
261
|
-
{
|
|
262
|
-
title: "How to use this product?",
|
|
263
|
-
body: "The description is not fully enough. Can you introduce me more?",
|
|
264
|
-
files: []
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
console.log("question", question);
|
|
268
|
-
|
|
269
|
-
// WRITE A COMMENT
|
|
270
|
-
const comment: ISaleArticleComment = await api.functional.shoppings.sales.comments.store
|
|
271
|
-
(
|
|
272
|
-
connection,
|
|
273
|
-
"general",
|
|
274
|
-
sale.id,
|
|
275
|
-
question.id,
|
|
276
|
-
{
|
|
277
|
-
body: "p.s) Can you send me a detailed catalogue?",
|
|
278
|
-
anonymous: false
|
|
279
|
-
}
|
|
280
|
-
);
|
|
281
|
-
console.log("comment", comment);
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
### Nestia-Helper
|
|
286
|
-
https://github.com/samchon/nestia-helper
|
|
216
|
+
[](https://github.com/samchon/nestia/blob/master/LICENSE)
|
|
217
|
+
[](https://www.npmjs.com/package/@nestia/core)
|
|
218
|
+
[](https://www.npmjs.com/package/@nestia/core)
|
|
219
|
+
[](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
|
|
220
|
+
[](https://github.com/samchon/nestia/wiki)
|
|
287
221
|
|
|
288
|
-
|
|
222
|
+
[Nestia](https://github.com/samchon/nestia) is a helper library set for `NestJS`, supporting below features:
|
|
289
223
|
|
|
290
|
-
|
|
224
|
+
- [`@nestia/core`](https://github.com/samchon/nestia#nestiacore): **15,000x times faster** validation decorator using `typia`
|
|
225
|
+
- [`@nestia/sdk`](https://github.com/samchon/nestia#nestiasdk): evolved **SDK** and **Swagger** generator for `@nestia/core`
|
|
226
|
+
- `nestia`: just CLI (command line interface) tool
|
|
291
227
|
|
|
292
228
|
```typescript
|
|
293
|
-
import
|
|
294
|
-
import
|
|
295
|
-
|
|
296
|
-
@
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
229
|
+
import { Controller } from "@nestjs/common";
|
|
230
|
+
import { TypedBody, TypedRoute } from "@nestia/core";
|
|
231
|
+
|
|
232
|
+
import { IBbsArticle } from "@bbs-api/structures/IBbsArticle";
|
|
233
|
+
|
|
234
|
+
@Controller("bbs/articles")
|
|
235
|
+
export class BbsArticlesController {
|
|
236
|
+
/**
|
|
237
|
+
* Store a new content.
|
|
238
|
+
*
|
|
239
|
+
* @param inupt Content to store
|
|
240
|
+
* @returns Newly archived article
|
|
241
|
+
*/
|
|
242
|
+
@TypedRoute.Post() // 10x faster and safer JSON.stringify()
|
|
243
|
+
public async store(
|
|
244
|
+
// super-fast validator
|
|
245
|
+
@TypedBody() input: IBbsArticle.IStore
|
|
304
246
|
): Promise<IBbsArticle>;
|
|
305
247
|
}
|
|
306
248
|
```
|
package/lib/executable/typia.js
CHANGED
|
File without changes
|
|
@@ -2,6 +2,6 @@ import ts from "typescript";
|
|
|
2
2
|
export declare namespace ExpressionFactory {
|
|
3
3
|
function isRequired(input: ts.Expression): ts.Expression;
|
|
4
4
|
function isArray(input: ts.Expression): ts.Expression;
|
|
5
|
-
function isObject(input: ts.Expression,
|
|
5
|
+
function isObject(input: ts.Expression, checkNull: boolean): ts.Expression;
|
|
6
6
|
function isInstanceOf(input: ts.Expression, type: string): ts.Expression;
|
|
7
7
|
}
|
|
@@ -15,15 +15,14 @@ var ExpressionFactory;
|
|
|
15
15
|
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Array.isArray"), undefined, [input]);
|
|
16
16
|
}
|
|
17
17
|
ExpressionFactory.isArray = isArray;
|
|
18
|
-
function isObject(input,
|
|
18
|
+
function isObject(input, checkNull) {
|
|
19
19
|
var conditions = [
|
|
20
20
|
typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createStringLiteral("object"), typescript_1.default.factory.createTypeOfExpression(input)),
|
|
21
21
|
];
|
|
22
|
-
if (
|
|
22
|
+
if (checkNull === true)
|
|
23
23
|
conditions.push(typescript_1.default.factory.createStrictInequality(typescript_1.default.factory.createNull(), input));
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
: conditions.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); });
|
|
24
|
+
conditions.push(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createFalse(), typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Array.isArray"), undefined, [input])));
|
|
25
|
+
return conditions.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); });
|
|
27
26
|
}
|
|
28
27
|
ExpressionFactory.isObject = isObject;
|
|
29
28
|
function isInstanceOf(input, type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionFactory.js","sourceRoot":"","sources":["../../src/factories/ExpressionFactory.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,IAAiB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ExpressionFactory.js","sourceRoot":"","sources":["../../src/factories/ExpressionFactory.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,IAAiB,iBAAiB,CAyDjC;AAzDD,WAAiB,iBAAiB;IAC9B,SAAgB,UAAU,CAAC,KAAoB;QAC3C,OAAO,oBAAE,CAAC,OAAO,CAAC,sBAAsB,CACpC,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,EACxC,KAAK,CACR,CAAC;IACN,CAAC;IALe,4BAAU,aAKzB,CAAA;IAED,SAAgB,OAAO,CAAC,KAAoB;QACxC,OAAO,oBAAE,CAAC,OAAO,CAAC,oBAAoB,CAClC,oBAAE,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,CAAC,IAAI,CAAC,CACpC,CAAC;IACN,CAAC;IATe,8BAAY,eAS3B,CAAA;AACL,CAAC,EAzDgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAyDjC"}
|
|
@@ -2,7 +2,7 @@ import ts from "typescript";
|
|
|
2
2
|
export declare namespace ValueFactory {
|
|
3
3
|
const NULL: () => ts.NullLiteral;
|
|
4
4
|
const UNDEFINED: () => ts.Identifier;
|
|
5
|
-
const BOOLEAN: (value: boolean) => ts.
|
|
5
|
+
const BOOLEAN: (value: boolean) => ts.FalseLiteral | ts.TrueLiteral;
|
|
6
6
|
const INPUT: (str?: string) => ts.Identifier;
|
|
7
7
|
const TYPEOF: (input: ts.Expression) => ts.TypeOfExpression;
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ export namespace ExpressionFactory {
|
|
|
18
18
|
|
|
19
19
|
export function isObject(
|
|
20
20
|
input: ts.Expression,
|
|
21
|
-
|
|
21
|
+
checkNull: boolean,
|
|
22
22
|
): ts.Expression {
|
|
23
23
|
const conditions: ts.Expression[] = [
|
|
24
24
|
ts.factory.createStrictEquality(
|
|
@@ -26,17 +26,25 @@ export namespace ExpressionFactory {
|
|
|
26
26
|
ts.factory.createTypeOfExpression(input),
|
|
27
27
|
),
|
|
28
28
|
];
|
|
29
|
-
if (
|
|
29
|
+
if (checkNull === true)
|
|
30
30
|
conditions.push(
|
|
31
31
|
ts.factory.createStrictInequality(
|
|
32
32
|
ts.factory.createNull(),
|
|
33
33
|
input,
|
|
34
34
|
),
|
|
35
35
|
);
|
|
36
|
+
conditions.push(
|
|
37
|
+
ts.factory.createStrictEquality(
|
|
38
|
+
ts.factory.createFalse(),
|
|
39
|
+
ts.factory.createCallExpression(
|
|
40
|
+
ts.factory.createIdentifier("Array.isArray"),
|
|
41
|
+
undefined,
|
|
42
|
+
[input],
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
);
|
|
36
46
|
|
|
37
|
-
return conditions.
|
|
38
|
-
? conditions[0]!
|
|
39
|
-
: conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y));
|
|
47
|
+
return conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y));
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
export function isInstanceOf(
|