@typia/interface 12.0.0-dev.20260309 → 12.0.0-dev.20260310
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/http/IHttpLlmController.d.ts +5 -5
- package/lib/schema/IJsonParseResult.d.ts +1 -3
- package/lib/schema/ILlmController.d.ts +2 -5
- package/package.json +1 -1
- package/src/http/IHttpConnection.ts +200 -200
- package/src/http/IHttpLlmApplication.ts +72 -72
- package/src/http/IHttpLlmController.ts +96 -96
- package/src/http/IHttpLlmFunction.ts +34 -34
- package/src/http/IHttpMigrateApplication.ts +48 -48
- package/src/http/IHttpMigrateRoute.ts +165 -165
- package/src/http/IHttpResponse.ts +42 -42
- package/src/http/index.ts +7 -7
- package/src/index.ts +9 -9
- package/src/metadata/IJsDocTagInfo.ts +25 -25
- package/src/metadata/IMetadataComponents.ts +24 -24
- package/src/metadata/IMetadataSchema.ts +293 -293
- package/src/metadata/IMetadataSchemaCollection.ts +20 -20
- package/src/metadata/IMetadataSchemaUnit.ts +20 -20
- package/src/metadata/IMetadataTypeTag.ts +39 -39
- package/src/metadata/index.ts +6 -6
- package/src/openapi/OpenApi.ts +643 -643
- package/src/openapi/OpenApiV3.ts +655 -655
- package/src/openapi/OpenApiV3_1.ts +735 -735
- package/src/openapi/SwaggerV2.ts +559 -559
- package/src/openapi/index.ts +4 -4
- package/src/protobuf/ProtobufWire.ts +51 -51
- package/src/protobuf/index.ts +1 -1
- package/src/schema/IJsonParseResult.ts +134 -136
- package/src/schema/IJsonSchemaApplication.ts +274 -274
- package/src/schema/IJsonSchemaAttribute.ts +158 -158
- package/src/schema/IJsonSchemaCollection.ts +123 -123
- package/src/schema/IJsonSchemaTransformError.ts +86 -86
- package/src/schema/IJsonSchemaUnit.ts +120 -120
- package/src/schema/ILlmApplication.ts +99 -99
- package/src/schema/ILlmController.ts +54 -57
- package/src/schema/ILlmFunction.ts +145 -145
- package/src/schema/ILlmSchema.ts +484 -484
- package/src/schema/IResult.ts +84 -84
- package/src/schema/IValidation.ts +134 -134
- package/src/schema/index.ts +14 -14
- package/src/tags/Constant.ts +49 -49
- package/src/tags/ContentMediaType.ts +40 -40
- package/src/tags/Default.ts +50 -50
- package/src/tags/Example.ts +48 -48
- package/src/tags/Examples.ts +50 -50
- package/src/tags/ExclusiveMaximum.ts +46 -46
- package/src/tags/ExclusiveMinimum.ts +46 -46
- package/src/tags/Format.ts +76 -76
- package/src/tags/JsonSchemaPlugin.ts +45 -45
- package/src/tags/MaxItems.ts +39 -39
- package/src/tags/MaxLength.ts +37 -37
- package/src/tags/Maximum.ts +44 -44
- package/src/tags/MinItems.ts +39 -39
- package/src/tags/MinLength.ts +37 -37
- package/src/tags/Minimum.ts +44 -44
- package/src/tags/MultipleOf.ts +54 -54
- package/src/tags/Pattern.ts +59 -59
- package/src/tags/Sequence.ts +43 -43
- package/src/tags/TagBase.ts +131 -131
- package/src/tags/Type.ts +70 -70
- package/src/tags/UniqueItems.ts +44 -44
- package/src/tags/index.ts +21 -21
- package/src/typings/AssertionGuard.ts +12 -12
- package/src/typings/Atomic.ts +21 -21
- package/src/typings/CamelCase.ts +75 -75
- package/src/typings/ClassProperties.ts +15 -15
- package/src/typings/DeepPartial.ts +39 -39
- package/src/typings/OmitNever.ts +12 -12
- package/src/typings/PascalCase.ts +71 -71
- package/src/typings/Primitive.ts +71 -71
- package/src/typings/ProtobufAtomic.ts +30 -30
- package/src/typings/Resolved.ts +58 -58
- package/src/typings/SnakeCase.ts +126 -126
- package/src/typings/SpecialFields.ts +13 -13
- package/src/typings/ValidationPipe.ts +20 -20
- package/src/typings/index.ts +14 -14
- package/src/typings/internal/Equal.ts +14 -14
- package/src/typings/internal/IsTuple.ts +17 -17
- package/src/typings/internal/NativeClass.ts +31 -31
- package/src/typings/internal/ValueOf.ts +29 -29
- package/src/utils/IRandomGenerator.ts +105 -105
- package/src/utils/IReadableURLSearchParams.ts +25 -25
- package/src/utils/index.ts +2 -2
package/src/typings/SnakeCase.ts
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
import { Equal } from "./internal/Equal";
|
|
2
|
-
import { NativeClass } from "./internal/NativeClass";
|
|
3
|
-
import { ValueOf } from "./internal/ValueOf";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Converts all object keys to snake_case.
|
|
7
|
-
*
|
|
8
|
-
* `SnakeCase<T>` transforms object property names to snake_case format and
|
|
9
|
-
* erases methods like {@link Resolved}. Recursively processes nested
|
|
10
|
-
* structures.
|
|
11
|
-
*
|
|
12
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
13
|
-
* @template T Target type to transform
|
|
14
|
-
*/
|
|
15
|
-
export type SnakeCase<T> =
|
|
16
|
-
Equal<T, SnakageMain<T>> extends true ? T : SnakageMain<T>;
|
|
17
|
-
|
|
18
|
-
/* -----------------------------------------------------------
|
|
19
|
-
OBJECT CONVERSION
|
|
20
|
-
----------------------------------------------------------- */
|
|
21
|
-
|
|
22
|
-
type SnakageMain<T> = T extends [never]
|
|
23
|
-
? never // special trick for (jsonable | null) type
|
|
24
|
-
: T extends { valueOf(): boolean | bigint | number | string }
|
|
25
|
-
? ValueOf<T>
|
|
26
|
-
: T extends Function
|
|
27
|
-
? never
|
|
28
|
-
: T extends object
|
|
29
|
-
? SnakageObject<T>
|
|
30
|
-
: T;
|
|
31
|
-
|
|
32
|
-
type SnakageObject<T extends object> =
|
|
33
|
-
T extends Array<infer U>
|
|
34
|
-
? IsTuple<T> extends true
|
|
35
|
-
? SnakageTuple<T>
|
|
36
|
-
: SnakageMain<U>[]
|
|
37
|
-
: T extends Set<infer U>
|
|
38
|
-
? Set<SnakageMain<U>>
|
|
39
|
-
: T extends Map<infer K, infer V>
|
|
40
|
-
? Map<SnakageMain<K>, SnakageMain<V>>
|
|
41
|
-
: T extends WeakSet<any> | WeakMap<any, any>
|
|
42
|
-
? never
|
|
43
|
-
: T extends NativeClass
|
|
44
|
-
? T
|
|
45
|
-
: {
|
|
46
|
-
[Key in keyof T as SnakageString<Key & string>]: SnakageMain<
|
|
47
|
-
T[Key]
|
|
48
|
-
>;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/* -----------------------------------------------------------
|
|
52
|
-
SPECIAL CASES
|
|
53
|
-
----------------------------------------------------------- */
|
|
54
|
-
type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
|
|
55
|
-
never,
|
|
56
|
-
]
|
|
57
|
-
? false
|
|
58
|
-
: T extends readonly any[]
|
|
59
|
-
? number extends T["length"]
|
|
60
|
-
? false
|
|
61
|
-
: true
|
|
62
|
-
: false;
|
|
63
|
-
type SnakageTuple<T extends readonly any[]> = T extends []
|
|
64
|
-
? []
|
|
65
|
-
: T extends [infer F]
|
|
66
|
-
? [SnakageMain<F>]
|
|
67
|
-
: T extends [infer F, ...infer Rest extends readonly any[]]
|
|
68
|
-
? [SnakageMain<F>, ...SnakageTuple<Rest>]
|
|
69
|
-
: T extends [(infer F)?]
|
|
70
|
-
? [SnakageMain<F>?]
|
|
71
|
-
: T extends [(infer F)?, ...infer Rest extends readonly any[]]
|
|
72
|
-
? [SnakageMain<F>?, ...SnakageTuple<Rest>]
|
|
73
|
-
: [];
|
|
74
|
-
|
|
75
|
-
/* -----------------------------------------------------------
|
|
76
|
-
STRING CONVERTER
|
|
77
|
-
----------------------------------------------------------- */
|
|
78
|
-
type SnakageString<Key extends string> = Key extends `${infer _}`
|
|
79
|
-
? SnakageStringRepeatedly<Key, "">
|
|
80
|
-
: Key;
|
|
81
|
-
type SnakageStringRepeatedly<
|
|
82
|
-
S extends string,
|
|
83
|
-
Previous extends string,
|
|
84
|
-
> = S extends `${infer First}${infer Second}${infer Rest}`
|
|
85
|
-
? `${Underscore<Previous, First>}${Lowercase<First>}${Underscore<
|
|
86
|
-
First,
|
|
87
|
-
Second
|
|
88
|
-
>}${Lowercase<Second>}${SnakageStringRepeatedly<Rest, Second>}`
|
|
89
|
-
: S extends `${infer First}`
|
|
90
|
-
? `${Underscore<Previous, First>}${Lowercase<First>}`
|
|
91
|
-
: "";
|
|
92
|
-
type Underscore<First extends string, Second extends string> = First extends
|
|
93
|
-
| UpperAlphabetic
|
|
94
|
-
| ""
|
|
95
|
-
| "_"
|
|
96
|
-
? ""
|
|
97
|
-
: Second extends UpperAlphabetic
|
|
98
|
-
? "_"
|
|
99
|
-
: "";
|
|
100
|
-
type UpperAlphabetic =
|
|
101
|
-
| "A"
|
|
102
|
-
| "B"
|
|
103
|
-
| "C"
|
|
104
|
-
| "D"
|
|
105
|
-
| "E"
|
|
106
|
-
| "F"
|
|
107
|
-
| "G"
|
|
108
|
-
| "H"
|
|
109
|
-
| "I"
|
|
110
|
-
| "J"
|
|
111
|
-
| "K"
|
|
112
|
-
| "L"
|
|
113
|
-
| "M"
|
|
114
|
-
| "N"
|
|
115
|
-
| "O"
|
|
116
|
-
| "P"
|
|
117
|
-
| "Q"
|
|
118
|
-
| "R"
|
|
119
|
-
| "S"
|
|
120
|
-
| "T"
|
|
121
|
-
| "U"
|
|
122
|
-
| "V"
|
|
123
|
-
| "W"
|
|
124
|
-
| "X"
|
|
125
|
-
| "Y"
|
|
126
|
-
| "Z";
|
|
1
|
+
import { Equal } from "./internal/Equal";
|
|
2
|
+
import { NativeClass } from "./internal/NativeClass";
|
|
3
|
+
import { ValueOf } from "./internal/ValueOf";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts all object keys to snake_case.
|
|
7
|
+
*
|
|
8
|
+
* `SnakeCase<T>` transforms object property names to snake_case format and
|
|
9
|
+
* erases methods like {@link Resolved}. Recursively processes nested
|
|
10
|
+
* structures.
|
|
11
|
+
*
|
|
12
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
13
|
+
* @template T Target type to transform
|
|
14
|
+
*/
|
|
15
|
+
export type SnakeCase<T> =
|
|
16
|
+
Equal<T, SnakageMain<T>> extends true ? T : SnakageMain<T>;
|
|
17
|
+
|
|
18
|
+
/* -----------------------------------------------------------
|
|
19
|
+
OBJECT CONVERSION
|
|
20
|
+
----------------------------------------------------------- */
|
|
21
|
+
|
|
22
|
+
type SnakageMain<T> = T extends [never]
|
|
23
|
+
? never // special trick for (jsonable | null) type
|
|
24
|
+
: T extends { valueOf(): boolean | bigint | number | string }
|
|
25
|
+
? ValueOf<T>
|
|
26
|
+
: T extends Function
|
|
27
|
+
? never
|
|
28
|
+
: T extends object
|
|
29
|
+
? SnakageObject<T>
|
|
30
|
+
: T;
|
|
31
|
+
|
|
32
|
+
type SnakageObject<T extends object> =
|
|
33
|
+
T extends Array<infer U>
|
|
34
|
+
? IsTuple<T> extends true
|
|
35
|
+
? SnakageTuple<T>
|
|
36
|
+
: SnakageMain<U>[]
|
|
37
|
+
: T extends Set<infer U>
|
|
38
|
+
? Set<SnakageMain<U>>
|
|
39
|
+
: T extends Map<infer K, infer V>
|
|
40
|
+
? Map<SnakageMain<K>, SnakageMain<V>>
|
|
41
|
+
: T extends WeakSet<any> | WeakMap<any, any>
|
|
42
|
+
? never
|
|
43
|
+
: T extends NativeClass
|
|
44
|
+
? T
|
|
45
|
+
: {
|
|
46
|
+
[Key in keyof T as SnakageString<Key & string>]: SnakageMain<
|
|
47
|
+
T[Key]
|
|
48
|
+
>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/* -----------------------------------------------------------
|
|
52
|
+
SPECIAL CASES
|
|
53
|
+
----------------------------------------------------------- */
|
|
54
|
+
type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
|
|
55
|
+
never,
|
|
56
|
+
]
|
|
57
|
+
? false
|
|
58
|
+
: T extends readonly any[]
|
|
59
|
+
? number extends T["length"]
|
|
60
|
+
? false
|
|
61
|
+
: true
|
|
62
|
+
: false;
|
|
63
|
+
type SnakageTuple<T extends readonly any[]> = T extends []
|
|
64
|
+
? []
|
|
65
|
+
: T extends [infer F]
|
|
66
|
+
? [SnakageMain<F>]
|
|
67
|
+
: T extends [infer F, ...infer Rest extends readonly any[]]
|
|
68
|
+
? [SnakageMain<F>, ...SnakageTuple<Rest>]
|
|
69
|
+
: T extends [(infer F)?]
|
|
70
|
+
? [SnakageMain<F>?]
|
|
71
|
+
: T extends [(infer F)?, ...infer Rest extends readonly any[]]
|
|
72
|
+
? [SnakageMain<F>?, ...SnakageTuple<Rest>]
|
|
73
|
+
: [];
|
|
74
|
+
|
|
75
|
+
/* -----------------------------------------------------------
|
|
76
|
+
STRING CONVERTER
|
|
77
|
+
----------------------------------------------------------- */
|
|
78
|
+
type SnakageString<Key extends string> = Key extends `${infer _}`
|
|
79
|
+
? SnakageStringRepeatedly<Key, "">
|
|
80
|
+
: Key;
|
|
81
|
+
type SnakageStringRepeatedly<
|
|
82
|
+
S extends string,
|
|
83
|
+
Previous extends string,
|
|
84
|
+
> = S extends `${infer First}${infer Second}${infer Rest}`
|
|
85
|
+
? `${Underscore<Previous, First>}${Lowercase<First>}${Underscore<
|
|
86
|
+
First,
|
|
87
|
+
Second
|
|
88
|
+
>}${Lowercase<Second>}${SnakageStringRepeatedly<Rest, Second>}`
|
|
89
|
+
: S extends `${infer First}`
|
|
90
|
+
? `${Underscore<Previous, First>}${Lowercase<First>}`
|
|
91
|
+
: "";
|
|
92
|
+
type Underscore<First extends string, Second extends string> = First extends
|
|
93
|
+
| UpperAlphabetic
|
|
94
|
+
| ""
|
|
95
|
+
| "_"
|
|
96
|
+
? ""
|
|
97
|
+
: Second extends UpperAlphabetic
|
|
98
|
+
? "_"
|
|
99
|
+
: "";
|
|
100
|
+
type UpperAlphabetic =
|
|
101
|
+
| "A"
|
|
102
|
+
| "B"
|
|
103
|
+
| "C"
|
|
104
|
+
| "D"
|
|
105
|
+
| "E"
|
|
106
|
+
| "F"
|
|
107
|
+
| "G"
|
|
108
|
+
| "H"
|
|
109
|
+
| "I"
|
|
110
|
+
| "J"
|
|
111
|
+
| "K"
|
|
112
|
+
| "L"
|
|
113
|
+
| "M"
|
|
114
|
+
| "N"
|
|
115
|
+
| "O"
|
|
116
|
+
| "P"
|
|
117
|
+
| "Q"
|
|
118
|
+
| "R"
|
|
119
|
+
| "S"
|
|
120
|
+
| "T"
|
|
121
|
+
| "U"
|
|
122
|
+
| "V"
|
|
123
|
+
| "W"
|
|
124
|
+
| "X"
|
|
125
|
+
| "Y"
|
|
126
|
+
| "Z";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts property keys whose value type extends the target type.
|
|
3
|
-
*
|
|
4
|
-
* `SpecialFields<Instance, Target>` returns a union of property names from
|
|
5
|
-
* `Instance` where the property value extends `Target`.
|
|
6
|
-
*
|
|
7
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
8
|
-
* @template Instance Source object type
|
|
9
|
-
* @template Target Target value type to match
|
|
10
|
-
*/
|
|
11
|
-
export type SpecialFields<Instance extends object, Target> = {
|
|
12
|
-
[P in keyof Instance]: Instance[P] extends Target ? P : never;
|
|
13
|
-
}[keyof Instance & string];
|
|
1
|
+
/**
|
|
2
|
+
* Extracts property keys whose value type extends the target type.
|
|
3
|
+
*
|
|
4
|
+
* `SpecialFields<Instance, Target>` returns a union of property names from
|
|
5
|
+
* `Instance` where the property value extends `Target`.
|
|
6
|
+
*
|
|
7
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
8
|
+
* @template Instance Source object type
|
|
9
|
+
* @template Target Target value type to match
|
|
10
|
+
*/
|
|
11
|
+
export type SpecialFields<Instance extends object, Target> = {
|
|
12
|
+
[P in keyof Instance]: Instance[P] extends Target ? P : never;
|
|
13
|
+
}[keyof Instance & string];
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Discriminated union for validation results.
|
|
3
|
-
*
|
|
4
|
-
* `ValidationPipe<T, E>` represents either a successful validation with data of
|
|
5
|
-
* type `T`, or a failed validation with an array of errors of type `E`. Use the
|
|
6
|
-
* `success` discriminant to narrow the type.
|
|
7
|
-
*
|
|
8
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
9
|
-
* @template T Success data type
|
|
10
|
-
* @template E Error type
|
|
11
|
-
*/
|
|
12
|
-
export type ValidationPipe<T, E> =
|
|
13
|
-
| {
|
|
14
|
-
success: true;
|
|
15
|
-
data: T;
|
|
16
|
-
}
|
|
17
|
-
| {
|
|
18
|
-
success: false;
|
|
19
|
-
errors: E[];
|
|
20
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Discriminated union for validation results.
|
|
3
|
+
*
|
|
4
|
+
* `ValidationPipe<T, E>` represents either a successful validation with data of
|
|
5
|
+
* type `T`, or a failed validation with an array of errors of type `E`. Use the
|
|
6
|
+
* `success` discriminant to narrow the type.
|
|
7
|
+
*
|
|
8
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
9
|
+
* @template T Success data type
|
|
10
|
+
* @template E Error type
|
|
11
|
+
*/
|
|
12
|
+
export type ValidationPipe<T, E> =
|
|
13
|
+
| {
|
|
14
|
+
success: true;
|
|
15
|
+
data: T;
|
|
16
|
+
}
|
|
17
|
+
| {
|
|
18
|
+
success: false;
|
|
19
|
+
errors: E[];
|
|
20
|
+
};
|
package/src/typings/index.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * from "./AssertionGuard";
|
|
2
|
-
export * from "./CamelCase";
|
|
3
|
-
export * from "./PascalCase";
|
|
4
|
-
export * from "./Primitive";
|
|
5
|
-
export * from "./Resolved";
|
|
6
|
-
export * from "./SnakeCase";
|
|
7
|
-
|
|
8
|
-
export * from "./Atomic";
|
|
9
|
-
export * from "./ClassProperties";
|
|
10
|
-
export * from "./DeepPartial";
|
|
11
|
-
export * from "./OmitNever";
|
|
12
|
-
export * from "./ProtobufAtomic";
|
|
13
|
-
export * from "./SpecialFields";
|
|
14
|
-
export * from "./ValidationPipe";
|
|
1
|
+
export * from "./AssertionGuard";
|
|
2
|
+
export * from "./CamelCase";
|
|
3
|
+
export * from "./PascalCase";
|
|
4
|
+
export * from "./Primitive";
|
|
5
|
+
export * from "./Resolved";
|
|
6
|
+
export * from "./SnakeCase";
|
|
7
|
+
|
|
8
|
+
export * from "./Atomic";
|
|
9
|
+
export * from "./ClassProperties";
|
|
10
|
+
export * from "./DeepPartial";
|
|
11
|
+
export * from "./OmitNever";
|
|
12
|
+
export * from "./ProtobufAtomic";
|
|
13
|
+
export * from "./SpecialFields";
|
|
14
|
+
export * from "./ValidationPipe";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if two types are exactly equal.
|
|
3
|
-
*
|
|
4
|
-
* `Equal<X, Y>` returns `true` if types X and Y are identical, `false`
|
|
5
|
-
* otherwise. Works with any TypeScript types including unions.
|
|
6
|
-
*
|
|
7
|
-
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
8
|
-
* @template X First type to compare
|
|
9
|
-
* @template Y Second type to compare
|
|
10
|
-
*/
|
|
11
|
-
export type Equal<X, Y> =
|
|
12
|
-
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
|
|
13
|
-
? true
|
|
14
|
-
: false;
|
|
1
|
+
/**
|
|
2
|
+
* Checks if two types are exactly equal.
|
|
3
|
+
*
|
|
4
|
+
* `Equal<X, Y>` returns `true` if types X and Y are identical, `false`
|
|
5
|
+
* otherwise. Works with any TypeScript types including unions.
|
|
6
|
+
*
|
|
7
|
+
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
8
|
+
* @template X First type to compare
|
|
9
|
+
* @template Y Second type to compare
|
|
10
|
+
*/
|
|
11
|
+
export type Equal<X, Y> =
|
|
12
|
+
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
|
|
13
|
+
? true
|
|
14
|
+
: false;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if an array type is a tuple (fixed length) or regular array.
|
|
3
|
-
*
|
|
4
|
-
* Returns `true` for tuple types like `[string, number]` where length is fixed,
|
|
5
|
-
* and `false` for array types like `string[]` where length is variable.
|
|
6
|
-
*
|
|
7
|
-
* @template T Array or tuple type to check
|
|
8
|
-
*/
|
|
9
|
-
export type IsTuple<T extends readonly any[] | { length: number }> = [
|
|
10
|
-
T,
|
|
11
|
-
] extends [never]
|
|
12
|
-
? false
|
|
13
|
-
: T extends readonly any[]
|
|
14
|
-
? number extends T["length"]
|
|
15
|
-
? false
|
|
16
|
-
: true
|
|
17
|
-
: false;
|
|
1
|
+
/**
|
|
2
|
+
* Checks if an array type is a tuple (fixed length) or regular array.
|
|
3
|
+
*
|
|
4
|
+
* Returns `true` for tuple types like `[string, number]` where length is fixed,
|
|
5
|
+
* and `false` for array types like `string[]` where length is variable.
|
|
6
|
+
*
|
|
7
|
+
* @template T Array or tuple type to check
|
|
8
|
+
*/
|
|
9
|
+
export type IsTuple<T extends readonly any[] | { length: number }> = [
|
|
10
|
+
T,
|
|
11
|
+
] extends [never]
|
|
12
|
+
? false
|
|
13
|
+
: T extends readonly any[]
|
|
14
|
+
? number extends T["length"]
|
|
15
|
+
? false
|
|
16
|
+
: true
|
|
17
|
+
: false;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Union of JavaScript built-in class types.
|
|
3
|
-
*
|
|
4
|
-
* `NativeClass` includes Date, collections (Set, Map, WeakSet, WeakMap), typed
|
|
5
|
-
* arrays (Uint8Array, Int32Array, etc.), binary data types (ArrayBuffer,
|
|
6
|
-
* DataView, Blob, File), and RegExp. These types receive special handling in
|
|
7
|
-
* typia's serialization and validation.
|
|
8
|
-
*/
|
|
9
|
-
export type NativeClass =
|
|
10
|
-
| Date
|
|
11
|
-
| Set<any>
|
|
12
|
-
| Map<any, any>
|
|
13
|
-
| WeakSet<any>
|
|
14
|
-
| WeakMap<any, any>
|
|
15
|
-
| Uint8Array
|
|
16
|
-
| Uint8ClampedArray
|
|
17
|
-
| Uint16Array
|
|
18
|
-
| Uint32Array
|
|
19
|
-
| BigUint64Array
|
|
20
|
-
| Int8Array
|
|
21
|
-
| Int16Array
|
|
22
|
-
| Int32Array
|
|
23
|
-
| BigInt64Array
|
|
24
|
-
| Float32Array
|
|
25
|
-
| Float64Array
|
|
26
|
-
| ArrayBuffer
|
|
27
|
-
| SharedArrayBuffer
|
|
28
|
-
| DataView
|
|
29
|
-
| Blob
|
|
30
|
-
| File
|
|
31
|
-
| RegExp;
|
|
1
|
+
/**
|
|
2
|
+
* Union of JavaScript built-in class types.
|
|
3
|
+
*
|
|
4
|
+
* `NativeClass` includes Date, collections (Set, Map, WeakSet, WeakMap), typed
|
|
5
|
+
* arrays (Uint8Array, Int32Array, etc.), binary data types (ArrayBuffer,
|
|
6
|
+
* DataView, Blob, File), and RegExp. These types receive special handling in
|
|
7
|
+
* typia's serialization and validation.
|
|
8
|
+
*/
|
|
9
|
+
export type NativeClass =
|
|
10
|
+
| Date
|
|
11
|
+
| Set<any>
|
|
12
|
+
| Map<any, any>
|
|
13
|
+
| WeakSet<any>
|
|
14
|
+
| WeakMap<any, any>
|
|
15
|
+
| Uint8Array
|
|
16
|
+
| Uint8ClampedArray
|
|
17
|
+
| Uint16Array
|
|
18
|
+
| Uint32Array
|
|
19
|
+
| BigUint64Array
|
|
20
|
+
| Int8Array
|
|
21
|
+
| Int16Array
|
|
22
|
+
| Int32Array
|
|
23
|
+
| BigInt64Array
|
|
24
|
+
| Float32Array
|
|
25
|
+
| Float64Array
|
|
26
|
+
| ArrayBuffer
|
|
27
|
+
| SharedArrayBuffer
|
|
28
|
+
| DataView
|
|
29
|
+
| Blob
|
|
30
|
+
| File
|
|
31
|
+
| RegExp;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts the primitive value type from boxed primitives.
|
|
3
|
-
*
|
|
4
|
-
* `ValueOf<Instance>` converts boxed primitive types (Boolean, Number, String)
|
|
5
|
-
* to their primitive equivalents (boolean, number, string). Non-boxed types are
|
|
6
|
-
* returned unchanged.
|
|
7
|
-
*
|
|
8
|
-
* @template Instance Type to extract primitive from
|
|
9
|
-
*/
|
|
10
|
-
export type ValueOf<Instance> =
|
|
11
|
-
IsValueOf<Instance, Boolean> extends true
|
|
12
|
-
? boolean
|
|
13
|
-
: IsValueOf<Instance, Number> extends true
|
|
14
|
-
? number
|
|
15
|
-
: IsValueOf<Instance, String> extends true
|
|
16
|
-
? string
|
|
17
|
-
: Instance;
|
|
18
|
-
|
|
19
|
-
type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
|
|
20
|
-
? Object extends IValueOf<infer Primitive>
|
|
21
|
-
? Instance extends Primitive
|
|
22
|
-
? false
|
|
23
|
-
: true // not Primitive, but Object
|
|
24
|
-
: false // cannot be
|
|
25
|
-
: false;
|
|
26
|
-
|
|
27
|
-
interface IValueOf<T> {
|
|
28
|
-
valueOf(): T;
|
|
29
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the primitive value type from boxed primitives.
|
|
3
|
+
*
|
|
4
|
+
* `ValueOf<Instance>` converts boxed primitive types (Boolean, Number, String)
|
|
5
|
+
* to their primitive equivalents (boolean, number, string). Non-boxed types are
|
|
6
|
+
* returned unchanged.
|
|
7
|
+
*
|
|
8
|
+
* @template Instance Type to extract primitive from
|
|
9
|
+
*/
|
|
10
|
+
export type ValueOf<Instance> =
|
|
11
|
+
IsValueOf<Instance, Boolean> extends true
|
|
12
|
+
? boolean
|
|
13
|
+
: IsValueOf<Instance, Number> extends true
|
|
14
|
+
? number
|
|
15
|
+
: IsValueOf<Instance, String> extends true
|
|
16
|
+
? string
|
|
17
|
+
: Instance;
|
|
18
|
+
|
|
19
|
+
type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
|
|
20
|
+
? Object extends IValueOf<infer Primitive>
|
|
21
|
+
? Instance extends Primitive
|
|
22
|
+
? false
|
|
23
|
+
: true // not Primitive, but Object
|
|
24
|
+
: false // cannot be
|
|
25
|
+
: false;
|
|
26
|
+
|
|
27
|
+
interface IValueOf<T> {
|
|
28
|
+
valueOf(): T;
|
|
29
|
+
}
|