typia 9.0.1 → 9.1.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/lib/functional.js +19 -27
- package/lib/functional.js.map +1 -1
- package/lib/functional.mjs +20 -27
- package/lib/http.js +27 -32
- package/lib/http.js.map +1 -1
- package/lib/http.mjs +28 -32
- package/lib/json.d.mts +66 -4
- package/lib/json.d.ts +66 -4
- package/lib/json.js +23 -21
- package/lib/json.js.map +1 -1
- package/lib/json.mjs +24 -22
- package/lib/llm.js +4 -9
- package/lib/llm.js.map +1 -1
- package/lib/llm.mjs +5 -9
- package/lib/misc.js +27 -23
- package/lib/misc.js.map +1 -1
- package/lib/misc.mjs +28 -23
- package/lib/module.d.mts +1 -0
- package/lib/module.d.ts +1 -0
- package/lib/module.js +20 -24
- package/lib/module.js.map +1 -1
- package/lib/module.mjs +19 -24
- package/lib/notations.js +25 -30
- package/lib/notations.js.map +1 -1
- package/lib/notations.mjs +26 -30
- package/lib/programmers/json/JsonSchemaProgrammer.d.mts +9 -0
- package/lib/programmers/json/JsonSchemaProgrammer.d.ts +9 -0
- package/lib/programmers/json/JsonSchemaProgrammer.js +20 -0
- package/lib/programmers/json/JsonSchemaProgrammer.js.map +1 -0
- package/lib/programmers/json/JsonSchemaProgrammer.mjs +20 -0
- package/lib/programmers/json/JsonSchemaProgrammer.mjs.map +1 -0
- package/lib/programmers/json/JsonSchemasProgrammer.js +1 -1
- package/lib/programmers/json/JsonSchemasProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonSchemasProgrammer.mjs +1 -1
- package/lib/protobuf.js +18 -23
- package/lib/protobuf.js.map +1 -1
- package/lib/protobuf.mjs +19 -23
- package/lib/reflect.js +3 -8
- package/lib/reflect.js.map +1 -1
- package/lib/reflect.mjs +4 -8
- package/lib/schemas/json/IJsonSchemaUnit.d.mts +26 -0
- package/lib/schemas/json/IJsonSchemaUnit.d.ts +26 -0
- package/lib/schemas/json/IJsonSchemaUnit.js +3 -0
- package/lib/schemas/json/IJsonSchemaUnit.js.map +1 -0
- package/lib/schemas/json/IJsonSchemaUnit.mjs +2 -0
- package/lib/schemas/json/IJsonSchemaUnit.mjs.map +1 -0
- package/lib/transformers/CallExpressionTransformer.js +2 -2
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/CallExpressionTransformer.mjs +2 -2
- package/lib/transformers/NoTransformConfigurationError.d.mts +1 -0
- package/lib/transformers/NoTransformConfigurationError.d.ts +1 -0
- package/lib/transformers/NoTransformConfigurationError.js +20 -0
- package/lib/transformers/NoTransformConfigurationError.js.map +1 -0
- package/lib/transformers/NoTransformConfigurationError.mjs +19 -0
- package/lib/transformers/NoTransformConfigurationError.mjs.map +1 -0
- package/lib/transformers/features/json/JsonSchemaTransformer.d.mts +5 -0
- package/lib/transformers/features/json/JsonSchemaTransformer.d.ts +5 -0
- package/lib/transformers/features/json/JsonSchemaTransformer.js +108 -0
- package/lib/transformers/features/json/JsonSchemaTransformer.js.map +1 -0
- package/lib/transformers/features/json/JsonSchemaTransformer.mjs +104 -0
- package/lib/transformers/features/json/JsonSchemaTransformer.mjs.map +1 -0
- package/lib/transformers/features/json/JsonSchemasTransformer.js +9 -9
- package/lib/transformers/features/json/JsonSchemasTransformer.js.map +1 -1
- package/lib/transformers/features/json/JsonSchemasTransformer.mjs +9 -9
- package/package.json +1 -1
- package/src/functional.ts +20 -30
- package/src/http.ts +28 -35
- package/src/json.ts +73 -73
- package/src/llm.ts +5 -12
- package/src/misc.ts +19 -26
- package/src/module.ts +21 -27
- package/src/notations.ts +26 -33
- package/src/programmers/json/JsonSchemaProgrammer.ts +26 -0
- package/src/programmers/json/JsonSchemasProgrammer.ts +1 -1
- package/src/protobuf.ts +19 -26
- package/src/reflect.ts +4 -11
- package/src/schemas/json/IJsonSchemaUnit.ts +32 -0
- package/src/transformers/CallExpressionTransformer.ts +2 -2
- package/src/transformers/NoTransformConfigurationError.ts +18 -0
- package/src/transformers/features/json/JsonSchemaTransformer.ts +135 -0
- package/src/transformers/features/json/JsonSchemasTransformer.ts +9 -9
package/lib/http.mjs
CHANGED
|
@@ -1,164 +1,160 @@
|
|
|
1
|
+
import { NoTransformConfigurationError } from './transformers/NoTransformConfigurationError.mjs';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @internal
|
|
3
5
|
*/
|
|
4
6
|
function formData() {
|
|
5
|
-
|
|
7
|
+
NoTransformConfigurationError("http.formData");
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* @internal
|
|
9
11
|
*/
|
|
10
12
|
function assertFormData() {
|
|
11
|
-
|
|
13
|
+
NoTransformConfigurationError("http.assertFormData");
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* @internal
|
|
15
17
|
*/
|
|
16
18
|
function isFormData() {
|
|
17
|
-
|
|
19
|
+
NoTransformConfigurationError("http.isFormData");
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* @internal
|
|
21
23
|
*/
|
|
22
24
|
function validateFormData() {
|
|
23
|
-
|
|
25
|
+
NoTransformConfigurationError("http.validateFormData");
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* @internal
|
|
27
29
|
*/
|
|
28
30
|
function query() {
|
|
29
|
-
|
|
31
|
+
NoTransformConfigurationError("http.query");
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* @internal
|
|
33
35
|
*/
|
|
34
36
|
function assertQuery() {
|
|
35
|
-
|
|
37
|
+
NoTransformConfigurationError("http.assertQuery");
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* @internal
|
|
39
41
|
*/
|
|
40
42
|
function isQuery() {
|
|
41
|
-
|
|
43
|
+
NoTransformConfigurationError("http.isQuery");
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
44
46
|
* @internal
|
|
45
47
|
*/
|
|
46
48
|
function validateQuery() {
|
|
47
|
-
|
|
49
|
+
NoTransformConfigurationError("http.validateQuery");
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* @internal
|
|
51
53
|
*/
|
|
52
54
|
function headers() {
|
|
53
|
-
|
|
55
|
+
NoTransformConfigurationError("http.headers");
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* @internal
|
|
57
59
|
*/
|
|
58
60
|
function assertHeaders() {
|
|
59
|
-
|
|
61
|
+
NoTransformConfigurationError("http.assertHeaders");
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
64
|
* @internal
|
|
63
65
|
*/
|
|
64
66
|
function isHeaders() {
|
|
65
|
-
|
|
67
|
+
NoTransformConfigurationError("http.isHeaders");
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* @internal
|
|
69
71
|
*/
|
|
70
72
|
function validateHeaders() {
|
|
71
|
-
|
|
73
|
+
NoTransformConfigurationError("http.validateHeaders");
|
|
72
74
|
}
|
|
73
75
|
/**
|
|
74
76
|
* @internal
|
|
75
77
|
*/
|
|
76
78
|
function parameter() {
|
|
77
|
-
|
|
79
|
+
NoTransformConfigurationError("http.parameter");
|
|
78
80
|
}
|
|
79
81
|
/**
|
|
80
82
|
* @internal
|
|
81
83
|
*/
|
|
82
84
|
function createFormData() {
|
|
83
|
-
|
|
85
|
+
NoTransformConfigurationError("http.createFormData");
|
|
84
86
|
}
|
|
85
87
|
/**
|
|
86
88
|
* @internal
|
|
87
89
|
*/
|
|
88
90
|
function createAssertFormData() {
|
|
89
|
-
|
|
91
|
+
NoTransformConfigurationError("http.createAssertFormData");
|
|
90
92
|
}
|
|
91
93
|
/**
|
|
92
94
|
* @internal
|
|
93
95
|
*/
|
|
94
96
|
function createIsFormData() {
|
|
95
|
-
|
|
97
|
+
NoTransformConfigurationError("http.createIsFormData");
|
|
96
98
|
}
|
|
97
99
|
/**
|
|
98
100
|
* @internal
|
|
99
101
|
*/
|
|
100
102
|
function createValidateFormData() {
|
|
101
|
-
|
|
103
|
+
NoTransformConfigurationError("http.createValidateFormData");
|
|
102
104
|
}
|
|
103
105
|
/**
|
|
104
106
|
* @internal
|
|
105
107
|
*/
|
|
106
108
|
function createQuery() {
|
|
107
|
-
|
|
109
|
+
NoTransformConfigurationError("http.createQuery");
|
|
108
110
|
}
|
|
109
111
|
/**
|
|
110
112
|
* @internal
|
|
111
113
|
*/
|
|
112
114
|
function createAssertQuery() {
|
|
113
|
-
|
|
115
|
+
NoTransformConfigurationError("http.createAssertQuery");
|
|
114
116
|
}
|
|
115
117
|
/**
|
|
116
118
|
* @internal
|
|
117
119
|
*/
|
|
118
120
|
function createIsQuery() {
|
|
119
|
-
|
|
121
|
+
NoTransformConfigurationError("http.createIsQuery");
|
|
120
122
|
}
|
|
121
123
|
/**
|
|
122
124
|
* @internal
|
|
123
125
|
*/
|
|
124
126
|
function createValidateQuery() {
|
|
125
|
-
|
|
127
|
+
NoTransformConfigurationError("http.createValidateQuery");
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
128
130
|
* @internal
|
|
129
131
|
*/
|
|
130
132
|
function createHeaders() {
|
|
131
|
-
|
|
133
|
+
NoTransformConfigurationError("http.createHeaders");
|
|
132
134
|
}
|
|
133
135
|
/**
|
|
134
136
|
* @internal
|
|
135
137
|
*/
|
|
136
138
|
function createAssertHeaders() {
|
|
137
|
-
|
|
139
|
+
NoTransformConfigurationError("http.createAssertHeaders");
|
|
138
140
|
}
|
|
139
141
|
/**
|
|
140
142
|
* @internal
|
|
141
143
|
*/
|
|
142
144
|
function createIsHeaders() {
|
|
143
|
-
|
|
145
|
+
NoTransformConfigurationError("http.createIsHeaders");
|
|
144
146
|
}
|
|
145
147
|
/**
|
|
146
148
|
* @internal
|
|
147
149
|
*/
|
|
148
150
|
function createValidateHeaders() {
|
|
149
|
-
|
|
151
|
+
NoTransformConfigurationError("http.createValidateHeaders");
|
|
150
152
|
}
|
|
151
153
|
/**
|
|
152
154
|
* @internal
|
|
153
155
|
*/
|
|
154
156
|
function createParameter() {
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* @internal
|
|
159
|
-
*/
|
|
160
|
-
function halt(name) {
|
|
161
|
-
throw new Error(`Error on typia.http.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`);
|
|
157
|
+
NoTransformConfigurationError("http.createParameter");
|
|
162
158
|
}
|
|
163
159
|
|
|
164
160
|
export { assertFormData, assertHeaders, assertQuery, createAssertFormData, createAssertHeaders, createAssertQuery, createFormData, createHeaders, createIsFormData, createIsHeaders, createIsQuery, createParameter, createQuery, createValidateFormData, createValidateHeaders, createValidateQuery, formData, headers, isFormData, isHeaders, isQuery, parameter, query, validateFormData, validateHeaders, validateQuery };
|
package/lib/json.d.mts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IJsonSchemaCollection } from "./schemas/json/IJsonSchemaCollection";
|
|
2
|
+
import { IJsonSchemaUnit } from "./schemas/json/IJsonSchemaUnit";
|
|
2
3
|
import { IValidation } from "./IValidation";
|
|
3
4
|
import { Primitive } from "./Primitive";
|
|
4
5
|
import { TypeGuardError } from "./TypeGuardError";
|
|
5
6
|
/**
|
|
6
7
|
* > You must configure the generic argument `Types`.
|
|
7
8
|
*
|
|
8
|
-
* JSON Schemas
|
|
9
|
+
* JSON Schemas Generator.
|
|
9
10
|
*
|
|
10
11
|
* Creates a JSON schema list which contains both main JSON schemas
|
|
11
12
|
* and components. Note that, all of the named types are stored in the
|
|
@@ -17,13 +18,13 @@ import { TypeGuardError } from "./TypeGuardError";
|
|
|
17
18
|
*
|
|
18
19
|
* @template Types Tuple of target types
|
|
19
20
|
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
20
|
-
* @return JSON schema
|
|
21
|
+
* @return JSON schema collection
|
|
21
22
|
*
|
|
22
23
|
* @author Jeongho Nam - https://github.com/samchon
|
|
23
24
|
*/
|
|
24
25
|
export declare function schemas(): never;
|
|
25
26
|
/**
|
|
26
|
-
* JSON Schemas
|
|
27
|
+
* JSON Schemas Generator.
|
|
27
28
|
*
|
|
28
29
|
* Creates a JSON schema list which contains both main JSON schemas
|
|
29
30
|
* and components. Note that, all of the named types are stored in the
|
|
@@ -35,11 +36,72 @@ export declare function schemas(): never;
|
|
|
35
36
|
*
|
|
36
37
|
* @template Types Tuple of target types
|
|
37
38
|
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
38
|
-
* @return JSON schema
|
|
39
|
+
* @return JSON schema collection
|
|
39
40
|
*
|
|
40
41
|
* @author Jeongho Nam - https://github.com/samchon
|
|
41
42
|
*/
|
|
42
43
|
export declare function schemas<Types extends unknown[], Version extends "3.0" | "3.1" = "3.1">(): IJsonSchemaCollection<Version, Types>;
|
|
44
|
+
/**
|
|
45
|
+
* > You must configure the generic argument `Type`.
|
|
46
|
+
*
|
|
47
|
+
* JSON schema generator.
|
|
48
|
+
*
|
|
49
|
+
* Creates a JSON schema unit which contains a main JSON schema and
|
|
50
|
+
* its components. Note that, all of the named types are stored in the
|
|
51
|
+
* {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
|
|
52
|
+
*
|
|
53
|
+
* Also, you can specify the OpenAPI version by configuring the second
|
|
54
|
+
* generic argument `Version`. For reference, the default version is `"3.1"`,
|
|
55
|
+
* and key different of `"3.0"` and `"3.1"` is whether supporting the
|
|
56
|
+
* tuple type or not.
|
|
57
|
+
*
|
|
58
|
+
* @template Type Target type
|
|
59
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
60
|
+
* @return JSON schema unit
|
|
61
|
+
*
|
|
62
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
63
|
+
*/
|
|
64
|
+
export declare function schema(): never;
|
|
65
|
+
/**
|
|
66
|
+
* JSON schema generator.
|
|
67
|
+
*
|
|
68
|
+
* Creates a JSON schema unit which contains a main JSON schema and
|
|
69
|
+
* its components. Note that, all of the named types are stored in the
|
|
70
|
+
* {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
|
|
71
|
+
*
|
|
72
|
+
* Also, you can specify the OpenAPI version by configuring the second
|
|
73
|
+
* generic argument `Version`. For reference, the default version is `"3.1"`,
|
|
74
|
+
* and key different of `"3.0"` and `"3.1"` is whether supporting the
|
|
75
|
+
* tuple type or not.
|
|
76
|
+
*
|
|
77
|
+
* @template Type Target type
|
|
78
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
79
|
+
* @return JSON schema unit
|
|
80
|
+
*
|
|
81
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
82
|
+
*/
|
|
83
|
+
export declare function schema<Type extends unknown, Version extends "3.0" | "3.1" = "3.1">(): IJsonSchemaUnit<Version, Type>;
|
|
84
|
+
/**
|
|
85
|
+
* > You must configure the generic argument `T`.
|
|
86
|
+
*
|
|
87
|
+
* Safe `JSON.parse()` function with type assertion.
|
|
88
|
+
*
|
|
89
|
+
* `typia.json.assertParse()` is a combination function of `JSON.parse()` and
|
|
90
|
+
* {@link assert}. Therefore, it converts a JSON (JavaScript Object Notation) string
|
|
91
|
+
* to a `T` typed instance with type assertion.
|
|
92
|
+
*
|
|
93
|
+
* In such reason, when parsed JSON string value is not matched with the type `T`, it
|
|
94
|
+
* throws {@link TypeGuardError} or custom error generated by *errorFactory*. Otherwise,
|
|
95
|
+
* there's no problem on the parsed value, the parsed value would be returned.
|
|
96
|
+
*
|
|
97
|
+
* @template T Expected type of parsed value
|
|
98
|
+
* @param input JSON string
|
|
99
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
100
|
+
* @returns Parsed value
|
|
101
|
+
*
|
|
102
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
103
|
+
*/
|
|
104
|
+
export declare function assertParse(input: string, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): never;
|
|
43
105
|
/**
|
|
44
106
|
* Safe `JSON.parse()` function with type assertion.
|
|
45
107
|
*
|
package/lib/json.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IJsonSchemaCollection } from "./schemas/json/IJsonSchemaCollection";
|
|
2
|
+
import { IJsonSchemaUnit } from "./schemas/json/IJsonSchemaUnit";
|
|
2
3
|
import { IValidation } from "./IValidation";
|
|
3
4
|
import { Primitive } from "./Primitive";
|
|
4
5
|
import { TypeGuardError } from "./TypeGuardError";
|
|
5
6
|
/**
|
|
6
7
|
* > You must configure the generic argument `Types`.
|
|
7
8
|
*
|
|
8
|
-
* JSON Schemas
|
|
9
|
+
* JSON Schemas Generator.
|
|
9
10
|
*
|
|
10
11
|
* Creates a JSON schema list which contains both main JSON schemas
|
|
11
12
|
* and components. Note that, all of the named types are stored in the
|
|
@@ -17,13 +18,13 @@ import { TypeGuardError } from "./TypeGuardError";
|
|
|
17
18
|
*
|
|
18
19
|
* @template Types Tuple of target types
|
|
19
20
|
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
20
|
-
* @return JSON schema
|
|
21
|
+
* @return JSON schema collection
|
|
21
22
|
*
|
|
22
23
|
* @author Jeongho Nam - https://github.com/samchon
|
|
23
24
|
*/
|
|
24
25
|
export declare function schemas(): never;
|
|
25
26
|
/**
|
|
26
|
-
* JSON Schemas
|
|
27
|
+
* JSON Schemas Generator.
|
|
27
28
|
*
|
|
28
29
|
* Creates a JSON schema list which contains both main JSON schemas
|
|
29
30
|
* and components. Note that, all of the named types are stored in the
|
|
@@ -35,11 +36,72 @@ export declare function schemas(): never;
|
|
|
35
36
|
*
|
|
36
37
|
* @template Types Tuple of target types
|
|
37
38
|
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
38
|
-
* @return JSON schema
|
|
39
|
+
* @return JSON schema collection
|
|
39
40
|
*
|
|
40
41
|
* @author Jeongho Nam - https://github.com/samchon
|
|
41
42
|
*/
|
|
42
43
|
export declare function schemas<Types extends unknown[], Version extends "3.0" | "3.1" = "3.1">(): IJsonSchemaCollection<Version, Types>;
|
|
44
|
+
/**
|
|
45
|
+
* > You must configure the generic argument `Type`.
|
|
46
|
+
*
|
|
47
|
+
* JSON schema generator.
|
|
48
|
+
*
|
|
49
|
+
* Creates a JSON schema unit which contains a main JSON schema and
|
|
50
|
+
* its components. Note that, all of the named types are stored in the
|
|
51
|
+
* {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
|
|
52
|
+
*
|
|
53
|
+
* Also, you can specify the OpenAPI version by configuring the second
|
|
54
|
+
* generic argument `Version`. For reference, the default version is `"3.1"`,
|
|
55
|
+
* and key different of `"3.0"` and `"3.1"` is whether supporting the
|
|
56
|
+
* tuple type or not.
|
|
57
|
+
*
|
|
58
|
+
* @template Type Target type
|
|
59
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
60
|
+
* @return JSON schema unit
|
|
61
|
+
*
|
|
62
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
63
|
+
*/
|
|
64
|
+
export declare function schema(): never;
|
|
65
|
+
/**
|
|
66
|
+
* JSON schema generator.
|
|
67
|
+
*
|
|
68
|
+
* Creates a JSON schema unit which contains a main JSON schema and
|
|
69
|
+
* its components. Note that, all of the named types are stored in the
|
|
70
|
+
* {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
|
|
71
|
+
*
|
|
72
|
+
* Also, you can specify the OpenAPI version by configuring the second
|
|
73
|
+
* generic argument `Version`. For reference, the default version is `"3.1"`,
|
|
74
|
+
* and key different of `"3.0"` and `"3.1"` is whether supporting the
|
|
75
|
+
* tuple type or not.
|
|
76
|
+
*
|
|
77
|
+
* @template Type Target type
|
|
78
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
79
|
+
* @return JSON schema unit
|
|
80
|
+
*
|
|
81
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
82
|
+
*/
|
|
83
|
+
export declare function schema<Type extends unknown, Version extends "3.0" | "3.1" = "3.1">(): IJsonSchemaUnit<Version, Type>;
|
|
84
|
+
/**
|
|
85
|
+
* > You must configure the generic argument `T`.
|
|
86
|
+
*
|
|
87
|
+
* Safe `JSON.parse()` function with type assertion.
|
|
88
|
+
*
|
|
89
|
+
* `typia.json.assertParse()` is a combination function of `JSON.parse()` and
|
|
90
|
+
* {@link assert}. Therefore, it converts a JSON (JavaScript Object Notation) string
|
|
91
|
+
* to a `T` typed instance with type assertion.
|
|
92
|
+
*
|
|
93
|
+
* In such reason, when parsed JSON string value is not matched with the type `T`, it
|
|
94
|
+
* throws {@link TypeGuardError} or custom error generated by *errorFactory*. Otherwise,
|
|
95
|
+
* there's no problem on the parsed value, the parsed value would be returned.
|
|
96
|
+
*
|
|
97
|
+
* @template T Expected type of parsed value
|
|
98
|
+
* @param input JSON string
|
|
99
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
100
|
+
* @returns Parsed value
|
|
101
|
+
*
|
|
102
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
103
|
+
*/
|
|
104
|
+
export declare function assertParse(input: string, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): never;
|
|
43
105
|
/**
|
|
44
106
|
* Safe `JSON.parse()` function with type assertion.
|
|
45
107
|
*
|
package/lib/json.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.schemas = schemas;
|
|
4
|
+
exports.schema = schema;
|
|
4
5
|
exports.assertParse = assertParse;
|
|
5
6
|
exports.isParse = isParse;
|
|
6
7
|
exports.validateParse = validateParse;
|
|
@@ -15,100 +16,101 @@ exports.createStringify = createStringify;
|
|
|
15
16
|
exports.createAssertStringify = createAssertStringify;
|
|
16
17
|
exports.createIsStringify = createIsStringify;
|
|
17
18
|
exports.createValidateStringify = createValidateStringify;
|
|
19
|
+
const NoTransformConfigurationError_1 = require("./transformers/NoTransformConfigurationError");
|
|
18
20
|
/**
|
|
19
21
|
* @internal
|
|
20
22
|
*/
|
|
21
23
|
function schemas() {
|
|
22
|
-
|
|
24
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.schemas");
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
function schema() {
|
|
30
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.schema");
|
|
23
31
|
}
|
|
24
32
|
/**
|
|
25
33
|
* @internal
|
|
26
34
|
*/
|
|
27
35
|
function assertParse() {
|
|
28
|
-
|
|
36
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.assertParse");
|
|
29
37
|
}
|
|
30
38
|
/**
|
|
31
39
|
* @internal
|
|
32
40
|
*/
|
|
33
41
|
function isParse() {
|
|
34
|
-
|
|
42
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.isParse");
|
|
35
43
|
}
|
|
36
44
|
/**
|
|
37
45
|
* @internal
|
|
38
46
|
*/
|
|
39
47
|
function validateParse() {
|
|
40
|
-
|
|
48
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.validateParse");
|
|
41
49
|
}
|
|
42
50
|
/**
|
|
43
51
|
* @internal
|
|
44
52
|
*/
|
|
45
53
|
function stringify() {
|
|
46
|
-
|
|
54
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.stringify");
|
|
47
55
|
}
|
|
48
56
|
/**
|
|
49
57
|
* @internal
|
|
50
58
|
*/
|
|
51
59
|
function assertStringify() {
|
|
52
|
-
|
|
60
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.assertStringify");
|
|
53
61
|
}
|
|
54
62
|
/**
|
|
55
63
|
* @internal
|
|
56
64
|
*/
|
|
57
65
|
function isStringify() {
|
|
58
|
-
|
|
66
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.isStringify");
|
|
59
67
|
}
|
|
60
68
|
/**
|
|
61
69
|
* @internal
|
|
62
70
|
*/
|
|
63
71
|
function validateStringify() {
|
|
64
|
-
|
|
72
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.validateStringify");
|
|
65
73
|
}
|
|
66
74
|
/**
|
|
67
75
|
* @internal
|
|
68
76
|
*/
|
|
69
77
|
function createIsParse() {
|
|
70
|
-
|
|
78
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.createIsParse");
|
|
71
79
|
}
|
|
72
80
|
/**
|
|
73
81
|
* @internal
|
|
74
82
|
*/
|
|
75
83
|
function createAssertParse() {
|
|
76
|
-
|
|
84
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.createAssertParse");
|
|
77
85
|
}
|
|
78
86
|
/**
|
|
79
87
|
* @internal
|
|
80
88
|
*/
|
|
81
89
|
function createValidateParse() {
|
|
82
|
-
|
|
90
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.createValidateParse");
|
|
83
91
|
}
|
|
84
92
|
/**
|
|
85
93
|
* @internal
|
|
86
94
|
*/
|
|
87
95
|
function createStringify() {
|
|
88
|
-
|
|
96
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.createStringify");
|
|
89
97
|
}
|
|
90
98
|
/**
|
|
91
99
|
* @internal
|
|
92
100
|
*/
|
|
93
101
|
function createAssertStringify() {
|
|
94
|
-
|
|
102
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.createAssertStringify");
|
|
95
103
|
}
|
|
96
104
|
/**
|
|
97
105
|
* @internal
|
|
98
106
|
*/
|
|
99
107
|
function createIsStringify() {
|
|
100
|
-
|
|
108
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.createIsStringify");
|
|
101
109
|
}
|
|
102
110
|
/**
|
|
103
111
|
* @internal
|
|
104
112
|
*/
|
|
105
113
|
function createValidateStringify() {
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* @internal
|
|
110
|
-
*/
|
|
111
|
-
function halt(name) {
|
|
112
|
-
throw new Error(`Error on typia.json.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`);
|
|
114
|
+
(0, NoTransformConfigurationError_1.NoTransformConfigurationError)("json.createValidateStringify");
|
|
113
115
|
}
|
|
114
116
|
//# sourceMappingURL=json.js.map
|
package/lib/json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;AAgEA,0BAEC;AAkDD,wBAEC;AAyDD,kCAEC;AA6CD,0BAEC;AA+CD,sCAEC;AAgCD,8BAEC;AA2DD,0CAEC;AAmDD,kCAEC;AAqDD,8CAEC;AA6BD,sCAEC;AAgCD,8CAEC;AA4BD,kDAIC;AA0BD,0CAEC;AAgCD,sDAEC;AA0BD,8CAEC;AA4BD,0DAIC;AAprBD,gGAA6F;AA0D7F;;GAEG;AACH,SAAgB,OAAO;IACrB,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AA+CD;;GAEG;AACH,SAAgB,MAAM;IACpB,IAAA,6DAA6B,EAAC,aAAa,CAAC,CAAC;AAC/C,CAAC;AAsDD;;GAEG;AACH,SAAgB,WAAW;IACzB,IAAA,6DAA6B,EAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC;AA0CD;;GAEG;AACH,SAAgB,OAAO;IACrB,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AA4CD;;GAEG;AACH,SAAgB,aAAa;IAC3B,IAAA,6DAA6B,EAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AA6BD;;GAEG;AACH,SAAgB,SAAS;IACvB,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,CAAC;AAClD,CAAC;AAwDD;;GAEG;AACH,SAAgB,eAAe;IAC7B,IAAA,6DAA6B,EAAC,sBAAsB,CAAC,CAAC;AACxD,CAAC;AAgDD;;GAEG;AACH,SAAgB,WAAW;IACzB,IAAA,6DAA6B,EAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC;AAkDD;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,IAAA,6DAA6B,EAAC,wBAAwB,CAAC,CAAC;AAC1D,CAAC;AA0BD;;GAEG;AACH,SAAgB,aAAa;IAC3B,IAAA,6DAA6B,EAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AA6BD;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,IAAA,6DAA6B,EAAC,wBAAwB,CAAC,CAAC;AAC1D,CAAC;AAyBD;;GAEG;AACH,SAAgB,mBAAmB;IAGjC,IAAA,6DAA6B,EAAC,0BAA0B,CAAC,CAAC;AAC5D,CAAC;AAuBD;;GAEG;AACH,SAAgB,eAAe;IAC7B,IAAA,6DAA6B,EAAC,sBAAsB,CAAC,CAAC;AACxD,CAAC;AA6BD;;GAEG;AACH,SAAgB,qBAAqB;IACnC,IAAA,6DAA6B,EAAC,4BAA4B,CAAC,CAAC;AAC9D,CAAC;AAuBD;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,IAAA,6DAA6B,EAAC,wBAAwB,CAAC,CAAC;AAC1D,CAAC;AAyBD;;GAEG;AACH,SAAgB,uBAAuB;IAGrC,IAAA,6DAA6B,EAAC,8BAA8B,CAAC,CAAC;AAChE,CAAC"}
|
package/lib/json.mjs
CHANGED
|
@@ -1,99 +1,101 @@
|
|
|
1
|
+
import { NoTransformConfigurationError } from './transformers/NoTransformConfigurationError.mjs';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @internal
|
|
3
5
|
*/
|
|
4
6
|
function schemas() {
|
|
5
|
-
|
|
7
|
+
NoTransformConfigurationError("json.schemas");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function schema() {
|
|
13
|
+
NoTransformConfigurationError("json.schema");
|
|
6
14
|
}
|
|
7
15
|
/**
|
|
8
16
|
* @internal
|
|
9
17
|
*/
|
|
10
18
|
function assertParse() {
|
|
11
|
-
|
|
19
|
+
NoTransformConfigurationError("json.assertParse");
|
|
12
20
|
}
|
|
13
21
|
/**
|
|
14
22
|
* @internal
|
|
15
23
|
*/
|
|
16
24
|
function isParse() {
|
|
17
|
-
|
|
25
|
+
NoTransformConfigurationError("json.isParse");
|
|
18
26
|
}
|
|
19
27
|
/**
|
|
20
28
|
* @internal
|
|
21
29
|
*/
|
|
22
30
|
function validateParse() {
|
|
23
|
-
|
|
31
|
+
NoTransformConfigurationError("json.validateParse");
|
|
24
32
|
}
|
|
25
33
|
/**
|
|
26
34
|
* @internal
|
|
27
35
|
*/
|
|
28
36
|
function stringify() {
|
|
29
|
-
|
|
37
|
+
NoTransformConfigurationError("json.stringify");
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* @internal
|
|
33
41
|
*/
|
|
34
42
|
function assertStringify() {
|
|
35
|
-
|
|
43
|
+
NoTransformConfigurationError("json.assertStringify");
|
|
36
44
|
}
|
|
37
45
|
/**
|
|
38
46
|
* @internal
|
|
39
47
|
*/
|
|
40
48
|
function isStringify() {
|
|
41
|
-
|
|
49
|
+
NoTransformConfigurationError("json.isStringify");
|
|
42
50
|
}
|
|
43
51
|
/**
|
|
44
52
|
* @internal
|
|
45
53
|
*/
|
|
46
54
|
function validateStringify() {
|
|
47
|
-
|
|
55
|
+
NoTransformConfigurationError("json.validateStringify");
|
|
48
56
|
}
|
|
49
57
|
/**
|
|
50
58
|
* @internal
|
|
51
59
|
*/
|
|
52
60
|
function createIsParse() {
|
|
53
|
-
|
|
61
|
+
NoTransformConfigurationError("json.createIsParse");
|
|
54
62
|
}
|
|
55
63
|
/**
|
|
56
64
|
* @internal
|
|
57
65
|
*/
|
|
58
66
|
function createAssertParse() {
|
|
59
|
-
|
|
67
|
+
NoTransformConfigurationError("json.createAssertParse");
|
|
60
68
|
}
|
|
61
69
|
/**
|
|
62
70
|
* @internal
|
|
63
71
|
*/
|
|
64
72
|
function createValidateParse() {
|
|
65
|
-
|
|
73
|
+
NoTransformConfigurationError("json.createValidateParse");
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
68
76
|
* @internal
|
|
69
77
|
*/
|
|
70
78
|
function createStringify() {
|
|
71
|
-
|
|
79
|
+
NoTransformConfigurationError("json.createStringify");
|
|
72
80
|
}
|
|
73
81
|
/**
|
|
74
82
|
* @internal
|
|
75
83
|
*/
|
|
76
84
|
function createAssertStringify() {
|
|
77
|
-
|
|
85
|
+
NoTransformConfigurationError("json.createAssertStringify");
|
|
78
86
|
}
|
|
79
87
|
/**
|
|
80
88
|
* @internal
|
|
81
89
|
*/
|
|
82
90
|
function createIsStringify() {
|
|
83
|
-
|
|
91
|
+
NoTransformConfigurationError("json.createIsStringify");
|
|
84
92
|
}
|
|
85
93
|
/**
|
|
86
94
|
* @internal
|
|
87
95
|
*/
|
|
88
96
|
function createValidateStringify() {
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* @internal
|
|
93
|
-
*/
|
|
94
|
-
function halt(name) {
|
|
95
|
-
throw new Error(`Error on typia.json.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`);
|
|
97
|
+
NoTransformConfigurationError("json.createValidateStringify");
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
export { assertParse, assertStringify, createAssertParse, createAssertStringify, createIsParse, createIsStringify, createStringify, createValidateParse, createValidateStringify, isParse, isStringify, schemas, stringify, validateParse, validateStringify };
|
|
100
|
+
export { assertParse, assertStringify, createAssertParse, createAssertStringify, createIsParse, createIsStringify, createStringify, createValidateParse, createValidateStringify, isParse, isStringify, schema, schemas, stringify, validateParse, validateStringify };
|
|
99
101
|
//# sourceMappingURL=json.mjs.map
|