typia 12.0.0-dev.20260316 → 12.0.0

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Jeongho Nam
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Jeongho Nam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,154 +1,154 @@
1
- # Typia
2
- ![Typia Logo](https://typia.io/logo.png)
3
-
4
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/typia/blob/master/LICENSE)
5
- [![NPM Version](https://img.shields.io/npm/v/typia.svg)](https://www.npmjs.com/package/typia)
6
- [![NPM Downloads](https://img.shields.io/npm/dm/typia.svg)](https://www.npmjs.com/package/typia)
7
- [![Build Status](https://github.com/samchon/typia/workflows/test/badge.svg)](https://github.com/samchon/typia/actions?query=workflow%3Atest)
8
- [![Guide Documents](https://img.shields.io/badge/Guide-Documents-forestgreen)](https://typia.io/docs/)
9
- [![Gurubase](https://img.shields.io/badge/Gurubase-Document%20Chatbot-006BFF)](https://gurubase.io/g/typia)
10
- [![Discord Badge](https://img.shields.io/badge/discord-samchon-d91965?style=flat&labelColor=5866f2&logo=discord&logoColor=white&link=https://discord.gg/E94XhzrUCZ)](https://discord.gg/E94XhzrUCZ)
11
-
12
- ```typescript
13
- // RUNTIME VALIDATORS
14
- export function is<T>(input: unknown): input is T; // returns boolean
15
- export function assert<T>(input: unknown): T; // throws TypeGuardError
16
- export function assertGuard<T>(input: unknown): asserts input is T;
17
- export function validate<T>(input: unknown): IValidation<T>; // detailed
18
-
19
- // JSON FUNCTIONS
20
- export namespace json {
21
- export function schema<T>(): IJsonSchemaUnit<T>; // JSON schema
22
- export function assertParse<T>(input: string): T; // type safe parser
23
- export function assertStringify<T>(input: T): string; // safe and faster
24
- }
25
-
26
- // AI FUNCTION CALLING SCHEMA
27
- export namespace llm {
28
- // collection of function calling schemas + validators/parsers
29
- export function application<Class>(): ILlmApplication<Class>;
30
- export function structuredOutput<P>(): ILlmStructuredOutput;
31
- // lenient json parser + type corecion
32
- export function parse<T>(str: string): T;
33
- }
34
-
35
- // PROTOCOL BUFFER
36
- export namespace protobuf {
37
- export function message<T>(): string; // Protocol Buffer message
38
- export function assertDecode<T>(buffer: Uint8Array): T; // safe decoder
39
- export function assertEncode<T>(input: T): Uint8Array; // safe encoder
40
- }
41
-
42
- // RANDOM GENERATOR
43
- export function random<T>(g?: Partial<IRandomGenerator>): T;
44
- ```
45
-
46
- `typia` is a transformer library supporting below features:
47
-
48
- - Super-fast Runtime Validators
49
- - Enhanced JSON schema and serde functions
50
- - LLM function calling schema and structured output
51
- - Protocol Buffer encoder and decoder
52
- - Random data generator
53
-
54
- > [!NOTE]
55
- >
56
- > - **Only one line** required, with pure TypeScript type
57
- > - Runtime validator is **20,000x faster** than `class-validator`
58
- > - JSON serialization is **200x faster** than `class-transformer`
59
-
60
- ## Transformation
61
- If you call `typia` function, it would be compiled like below.
62
-
63
- This is the key concept of `typia`, transforming TypeScript type to a runtime function. The `typia.is<T>()` function is transformed to a dedicated type checker by analyzing the target type `T` in the compilation level.
64
-
65
- This feature enables developers to ensure type safety in their applications, leveraging TypeScript's static typing while also providing runtime validation. Instead of defining additional schemas, you can simply utilize the pure TypeScript type itself.
66
-
67
- ```typescript
68
- //----
69
- // examples/checkString.ts
70
- //----
71
- import typia, { tags } from "typia";
72
- export const checkString = typia.createIs<string>();
73
-
74
- //----
75
- // examples/checkString.js
76
- //----
77
- import typia from "typia";
78
- export const checkString = (() => {
79
- return (input) => "string" === typeof input;
80
- })();
81
- ```
82
-
83
-
84
-
85
- ## Sponsors
86
- Thanks for your support.
87
-
88
- Your donation encourages `typia` development.
89
-
90
- Also, `typia` is re-distributing half of donations to core contributors of `typia`.
91
-
92
- - [`nonara/ts-patch`](https://github.com/nonara/ts-patch)
93
- - [`ryoppippi/unplugin-typia`](https://github.com/ryoppippi/unplugin-typia)
94
-
95
- [![Sponsors](https://opencollective.com/typia/badge.svg?avatarHeight=75&width=600)](https://opencollective.com/typia)
96
-
97
-
98
-
99
-
100
- ## Playground
101
- You can experience how typia works by [playground website](https://typia.io/playground):
102
-
103
- - 💻 https://typia.io/playground
104
-
105
-
106
-
107
-
108
- ## Guide Documents
109
- Check out the document in the [website](https://typia.io/docs/):
110
-
111
- ### 🏠 Home
112
- - [Introduction](https://typia.io/docs/)
113
- - [Setup](https://typia.io/docs/setup/)
114
- - [Pure TypeScript](https://typia.io/docs/pure/)
115
-
116
- ### 📖 Features
117
- - Runtime Validators
118
- - [`assert()` function](https://typia.io/docs/validators/assert/)
119
- - [`is()` function](https://typia.io/docs/validators/is/)
120
- - [`validate()` function](https://typia.io/docs/validators/validate/)
121
- - [Functional Module](https://typia.io/docs/validators/functional)
122
- - [Special Tags](https://typia.io/docs/validators/tags/)
123
- - Enhanced JSON
124
- - [JSON Schema](https://typia.io/docs/json/schema/)
125
- - [`stringify()` functions](https://typia.io/docs/json/stringify/)
126
- - [`parse()` functions](https://typia.io/docs/json/parse/)
127
- - LLM Function Calling
128
- - [`application()` function](https://typia.io/docs/llm/application/)
129
- - [`structuredOutput()` function](https://typia.io/docs/llm/structuredOutput/)
130
- - [`LlmJson` module](https://typia.io/docs/llm/json/)
131
- - [MCP (Model Context Protocol)](https://typia.io/docs/llm/mcp/)
132
- - [Vercel AI SDK](https://typia.io/docs/llm/vercel/)
133
- - [LangChain](https://typia.io/docs/llm/langchain/)
134
- - Protocol Buffer
135
- - [Message Schema](https://typia.io/docs/protobuf/message)
136
- - [`decode()` functions](https://typia.io/docs/protobuf/decode/)
137
- - [`encode()` functions](https://typia.io/docs/protobuf/encode/)
138
- - [Random Generator](https://typia.io/docs/random/)
139
- - [Miscellaneous](https://typia.io/docs/misc/)
140
-
141
- ### 🔗 Appendix
142
- - [API Documents](https://typia.io/api)
143
- - Utilization Cases
144
- - [NestJS](https://typia.io/docs/utilization/nestjs/)
145
- - [tRPC](https://typia.io/docs/utilization/trpc/)
146
- - [⇲ Benchmark Result](https://github.com/samchon/typia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
147
- - [⇲ `dev.to` Articles](https://dev.to/samchon/series/22474)
148
-
149
-
150
-
151
-
152
- ## References
153
- - inspired by [`typescript-is`](https://github.com/woutervh-/typescript-is)
154
- - inspired by [`ts-patch`](https://github.com/nonara/ts-patch)
1
+ # Typia
2
+ ![Typia Logo](https://typia.io/logo.png)
3
+
4
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/typia/blob/master/LICENSE)
5
+ [![NPM Version](https://img.shields.io/npm/v/typia.svg)](https://www.npmjs.com/package/typia)
6
+ [![NPM Downloads](https://img.shields.io/npm/dm/typia.svg)](https://www.npmjs.com/package/typia)
7
+ [![Build Status](https://github.com/samchon/typia/workflows/test/badge.svg)](https://github.com/samchon/typia/actions?query=workflow%3Atest)
8
+ [![Guide Documents](https://img.shields.io/badge/Guide-Documents-forestgreen)](https://typia.io/docs/)
9
+ [![Gurubase](https://img.shields.io/badge/Gurubase-Document%20Chatbot-006BFF)](https://gurubase.io/g/typia)
10
+ [![Discord Badge](https://img.shields.io/badge/discord-samchon-d91965?style=flat&labelColor=5866f2&logo=discord&logoColor=white&link=https://discord.gg/E94XhzrUCZ)](https://discord.gg/E94XhzrUCZ)
11
+
12
+ ```typescript
13
+ // RUNTIME VALIDATORS
14
+ export function is<T>(input: unknown): input is T; // returns boolean
15
+ export function assert<T>(input: unknown): T; // throws TypeGuardError
16
+ export function assertGuard<T>(input: unknown): asserts input is T;
17
+ export function validate<T>(input: unknown): IValidation<T>; // detailed
18
+
19
+ // JSON FUNCTIONS
20
+ export namespace json {
21
+ export function schema<T>(): IJsonSchemaUnit<T>; // JSON schema
22
+ export function assertParse<T>(input: string): T; // type safe parser
23
+ export function assertStringify<T>(input: T): string; // safe and faster
24
+ }
25
+
26
+ // AI FUNCTION CALLING SCHEMA
27
+ export namespace llm {
28
+ // collection of function calling schemas + validators/parsers
29
+ export function application<Class>(): ILlmApplication<Class>;
30
+ export function structuredOutput<P>(): ILlmStructuredOutput;
31
+ // lenient json parser + type corecion
32
+ export function parse<T>(str: string): T;
33
+ }
34
+
35
+ // PROTOCOL BUFFER
36
+ export namespace protobuf {
37
+ export function message<T>(): string; // Protocol Buffer message
38
+ export function assertDecode<T>(buffer: Uint8Array): T; // safe decoder
39
+ export function assertEncode<T>(input: T): Uint8Array; // safe encoder
40
+ }
41
+
42
+ // RANDOM GENERATOR
43
+ export function random<T>(g?: Partial<IRandomGenerator>): T;
44
+ ```
45
+
46
+ `typia` is a transformer library supporting below features:
47
+
48
+ - Super-fast Runtime Validators
49
+ - Enhanced JSON schema and serde functions
50
+ - LLM function calling schema and structured output
51
+ - Protocol Buffer encoder and decoder
52
+ - Random data generator
53
+
54
+ > [!NOTE]
55
+ >
56
+ > - **Only one line** required, with pure TypeScript type
57
+ > - Runtime validator is **20,000x faster** than `class-validator`
58
+ > - JSON serialization is **200x faster** than `class-transformer`
59
+
60
+ ## Transformation
61
+ If you call `typia` function, it would be compiled like below.
62
+
63
+ This is the key concept of `typia`, transforming TypeScript type to a runtime function. The `typia.is<T>()` function is transformed to a dedicated type checker by analyzing the target type `T` in the compilation level.
64
+
65
+ This feature enables developers to ensure type safety in their applications, leveraging TypeScript's static typing while also providing runtime validation. Instead of defining additional schemas, you can simply utilize the pure TypeScript type itself.
66
+
67
+ ```typescript
68
+ //----
69
+ // examples/checkString.ts
70
+ //----
71
+ import typia, { tags } from "typia";
72
+ export const checkString = typia.createIs<string>();
73
+
74
+ //----
75
+ // examples/checkString.js
76
+ //----
77
+ import typia from "typia";
78
+ export const checkString = (() => {
79
+ return (input) => "string" === typeof input;
80
+ })();
81
+ ```
82
+
83
+
84
+
85
+ ## Sponsors
86
+ Thanks for your support.
87
+
88
+ Your donation encourages `typia` development.
89
+
90
+ Also, `typia` is re-distributing half of donations to core contributors of `typia`.
91
+
92
+ - [`nonara/ts-patch`](https://github.com/nonara/ts-patch)
93
+ - [`ryoppippi/unplugin-typia`](https://github.com/ryoppippi/unplugin-typia)
94
+
95
+ [![Sponsors](https://opencollective.com/typia/badge.svg?avatarHeight=75&width=600)](https://opencollective.com/typia)
96
+
97
+
98
+
99
+
100
+ ## Playground
101
+ You can experience how typia works by [playground website](https://typia.io/playground):
102
+
103
+ - 💻 https://typia.io/playground
104
+
105
+
106
+
107
+
108
+ ## Guide Documents
109
+ Check out the document in the [website](https://typia.io/docs/):
110
+
111
+ ### 🏠 Home
112
+ - [Introduction](https://typia.io/docs/)
113
+ - [Setup](https://typia.io/docs/setup/)
114
+ - [Pure TypeScript](https://typia.io/docs/pure/)
115
+
116
+ ### 📖 Features
117
+ - Runtime Validators
118
+ - [`assert()` function](https://typia.io/docs/validators/assert/)
119
+ - [`is()` function](https://typia.io/docs/validators/is/)
120
+ - [`validate()` function](https://typia.io/docs/validators/validate/)
121
+ - [Functional Module](https://typia.io/docs/validators/functional)
122
+ - [Special Tags](https://typia.io/docs/validators/tags/)
123
+ - Enhanced JSON
124
+ - [JSON Schema](https://typia.io/docs/json/schema/)
125
+ - [`stringify()` functions](https://typia.io/docs/json/stringify/)
126
+ - [`parse()` functions](https://typia.io/docs/json/parse/)
127
+ - LLM Function Calling
128
+ - [`application()` function](https://typia.io/docs/llm/application/)
129
+ - [`structuredOutput()` function](https://typia.io/docs/llm/structuredOutput/)
130
+ - [`LlmJson` module](https://typia.io/docs/llm/json/)
131
+ - [MCP (Model Context Protocol)](https://typia.io/docs/llm/mcp/)
132
+ - [Vercel AI SDK](https://typia.io/docs/llm/vercel/)
133
+ - [LangChain](https://typia.io/docs/llm/langchain/)
134
+ - Protocol Buffer
135
+ - [Message Schema](https://typia.io/docs/protobuf/message)
136
+ - [`decode()` functions](https://typia.io/docs/protobuf/decode/)
137
+ - [`encode()` functions](https://typia.io/docs/protobuf/encode/)
138
+ - [Random Generator](https://typia.io/docs/random/)
139
+ - [Miscellaneous](https://typia.io/docs/misc/)
140
+
141
+ ### 🔗 Appendix
142
+ - [API Documents](https://typia.io/api)
143
+ - Utilization Cases
144
+ - [NestJS](https://typia.io/docs/utilization/nestjs/)
145
+ - [tRPC](https://typia.io/docs/utilization/trpc/)
146
+ - [⇲ Benchmark Result](https://github.com/samchon/typia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
147
+ - [⇲ `dev.to` Articles](https://dev.to/samchon/series/22474)
148
+
149
+
150
+
151
+
152
+ ## References
153
+ - inspired by [`typescript-is`](https://github.com/woutervh-/typescript-is)
154
+ - inspired by [`ts-patch`](https://github.com/nonara/ts-patch)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "12.0.0-dev.20260316",
3
+ "version": "12.0.0",
4
4
  "description": "Superfast runtime validators with only one line",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -46,10 +46,10 @@
46
46
  "inquirer": "^8.2.5",
47
47
  "package-manager-detector": "^0.2.0",
48
48
  "randexp": "^0.5.3",
49
- "@typia/transform": "^12.0.0-dev.20260316",
50
- "@typia/core": "^12.0.0-dev.20260316",
51
- "@typia/interface": "^12.0.0-dev.20260316",
52
- "@typia/utils": "^12.0.0-dev.20260316"
49
+ "@typia/core": "^12.0.0",
50
+ "@typia/interface": "^12.0.0",
51
+ "@typia/utils": "^12.0.0",
52
+ "@typia/transform": "^12.0.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "typescript": ">=4.8.0 <5.10.0"
@@ -1,2 +1,2 @@
1
- export const _jsonStringifyNumber = (value: number): number | null =>
2
- isFinite(value) ? value : null;
1
+ export const _jsonStringifyNumber = (value: number): number | null =>
2
+ isFinite(value) ? value : null;