@typia/interface 12.0.0-dev.20260307-2 → 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/ILlmApplication.d.ts +1 -1
- package/lib/schema/ILlmController.d.ts +2 -5
- package/lib/schema/ILlmFunction.d.ts +35 -9
- 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 -118
- 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/tags/Type.ts
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { TagBase } from "./TagBase";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Numeric precision and bit-width type constraint.
|
|
5
|
-
*
|
|
6
|
-
* `Type<Value>` is a type tag that constrains numeric values to specific
|
|
7
|
-
* bit-width representations. This is essential for Protocol Buffers
|
|
8
|
-
* serialization and ensures values fit within their specified ranges.
|
|
9
|
-
*
|
|
10
|
-
* Available types:
|
|
11
|
-
*
|
|
12
|
-
* - `"int32"`: Signed 32-bit integer (-2,147,483,648 to 2,147,483,647)
|
|
13
|
-
* - `"uint32"`: Unsigned 32-bit integer (0 to 4,294,967,295)
|
|
14
|
-
* - `"int64"`: Signed 64-bit integer (for `number` or `bigint`)
|
|
15
|
-
* - `"uint64"`: Unsigned 64-bit integer (for `number` or `bigint`)
|
|
16
|
-
* - `"float"`: 32-bit floating point
|
|
17
|
-
* - `"double"`: 64-bit floating point (default JavaScript number)
|
|
18
|
-
*
|
|
19
|
-
* For Protocol Buffers, integer types also determine the wire encoding. The
|
|
20
|
-
* constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
21
|
-
* `typia.validate()`. It generates appropriate `type` in JSON Schema.
|
|
22
|
-
*
|
|
23
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
24
|
-
* @example
|
|
25
|
-
* interface Message {
|
|
26
|
-
* // 32-bit unsigned integer
|
|
27
|
-
* id: number & Type<"uint32">;
|
|
28
|
-
* // 64-bit signed integer as bigint
|
|
29
|
-
* timestamp: bigint & Type<"int64">;
|
|
30
|
-
* // 32-bit float for memory efficiency
|
|
31
|
-
* score: number & Type<"float">;
|
|
32
|
-
* }
|
|
33
|
-
*
|
|
34
|
-
* @template Value Numeric type identifier
|
|
35
|
-
*/
|
|
36
|
-
export type Type<
|
|
37
|
-
Value extends "int32" | "uint32" | "int64" | "uint64" | "float" | "double",
|
|
38
|
-
> = TagBase<{
|
|
39
|
-
target: Value extends "int64" | "uint64" ? "bigint" | "number" : "number";
|
|
40
|
-
kind: "type";
|
|
41
|
-
value: Value;
|
|
42
|
-
validate: Value extends "int32"
|
|
43
|
-
? `$importInternal("isTypeInt32")($input)`
|
|
44
|
-
: Value extends "uint32"
|
|
45
|
-
? `$importInternal("isTypeUint32")($input)`
|
|
46
|
-
: Value extends "int64"
|
|
47
|
-
? {
|
|
48
|
-
number: `$importInternal("isTypeInt64")($input)`;
|
|
49
|
-
bigint: `true`;
|
|
50
|
-
}
|
|
51
|
-
: Value extends "uint64"
|
|
52
|
-
? {
|
|
53
|
-
number: `$importInternal("isTypeUint64")($input)`;
|
|
54
|
-
bigint: `BigInt(0) <= $input`;
|
|
55
|
-
}
|
|
56
|
-
: Value extends "float"
|
|
57
|
-
? `$importInternal("isTypeFloat")($input)`
|
|
58
|
-
: `true`;
|
|
59
|
-
exclusive: true;
|
|
60
|
-
schema: Value extends "uint32" | "uint64"
|
|
61
|
-
? {
|
|
62
|
-
type: "integer";
|
|
63
|
-
minimum: 0;
|
|
64
|
-
}
|
|
65
|
-
: {
|
|
66
|
-
type: Value extends "int32" | "uint32" | "int64" | "uint64"
|
|
67
|
-
? "integer"
|
|
68
|
-
: "number";
|
|
69
|
-
};
|
|
70
|
-
}>;
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Numeric precision and bit-width type constraint.
|
|
5
|
+
*
|
|
6
|
+
* `Type<Value>` is a type tag that constrains numeric values to specific
|
|
7
|
+
* bit-width representations. This is essential for Protocol Buffers
|
|
8
|
+
* serialization and ensures values fit within their specified ranges.
|
|
9
|
+
*
|
|
10
|
+
* Available types:
|
|
11
|
+
*
|
|
12
|
+
* - `"int32"`: Signed 32-bit integer (-2,147,483,648 to 2,147,483,647)
|
|
13
|
+
* - `"uint32"`: Unsigned 32-bit integer (0 to 4,294,967,295)
|
|
14
|
+
* - `"int64"`: Signed 64-bit integer (for `number` or `bigint`)
|
|
15
|
+
* - `"uint64"`: Unsigned 64-bit integer (for `number` or `bigint`)
|
|
16
|
+
* - `"float"`: 32-bit floating point
|
|
17
|
+
* - `"double"`: 64-bit floating point (default JavaScript number)
|
|
18
|
+
*
|
|
19
|
+
* For Protocol Buffers, integer types also determine the wire encoding. The
|
|
20
|
+
* constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
21
|
+
* `typia.validate()`. It generates appropriate `type` in JSON Schema.
|
|
22
|
+
*
|
|
23
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
24
|
+
* @example
|
|
25
|
+
* interface Message {
|
|
26
|
+
* // 32-bit unsigned integer
|
|
27
|
+
* id: number & Type<"uint32">;
|
|
28
|
+
* // 64-bit signed integer as bigint
|
|
29
|
+
* timestamp: bigint & Type<"int64">;
|
|
30
|
+
* // 32-bit float for memory efficiency
|
|
31
|
+
* score: number & Type<"float">;
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* @template Value Numeric type identifier
|
|
35
|
+
*/
|
|
36
|
+
export type Type<
|
|
37
|
+
Value extends "int32" | "uint32" | "int64" | "uint64" | "float" | "double",
|
|
38
|
+
> = TagBase<{
|
|
39
|
+
target: Value extends "int64" | "uint64" ? "bigint" | "number" : "number";
|
|
40
|
+
kind: "type";
|
|
41
|
+
value: Value;
|
|
42
|
+
validate: Value extends "int32"
|
|
43
|
+
? `$importInternal("isTypeInt32")($input)`
|
|
44
|
+
: Value extends "uint32"
|
|
45
|
+
? `$importInternal("isTypeUint32")($input)`
|
|
46
|
+
: Value extends "int64"
|
|
47
|
+
? {
|
|
48
|
+
number: `$importInternal("isTypeInt64")($input)`;
|
|
49
|
+
bigint: `true`;
|
|
50
|
+
}
|
|
51
|
+
: Value extends "uint64"
|
|
52
|
+
? {
|
|
53
|
+
number: `$importInternal("isTypeUint64")($input)`;
|
|
54
|
+
bigint: `BigInt(0) <= $input`;
|
|
55
|
+
}
|
|
56
|
+
: Value extends "float"
|
|
57
|
+
? `$importInternal("isTypeFloat")($input)`
|
|
58
|
+
: `true`;
|
|
59
|
+
exclusive: true;
|
|
60
|
+
schema: Value extends "uint32" | "uint64"
|
|
61
|
+
? {
|
|
62
|
+
type: "integer";
|
|
63
|
+
minimum: 0;
|
|
64
|
+
}
|
|
65
|
+
: {
|
|
66
|
+
type: Value extends "int32" | "uint32" | "int64" | "uint64"
|
|
67
|
+
? "integer"
|
|
68
|
+
: "number";
|
|
69
|
+
};
|
|
70
|
+
}>;
|
package/src/tags/UniqueItems.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { TagBase } from "./TagBase";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Array unique elements constraint.
|
|
5
|
-
*
|
|
6
|
-
* `UniqueItems` is a type tag that validates all elements in an array are
|
|
7
|
-
* unique (no duplicates). Apply it to array properties using TypeScript
|
|
8
|
-
* intersection types.
|
|
9
|
-
*
|
|
10
|
-
* Uniqueness is determined by:
|
|
11
|
-
*
|
|
12
|
-
* - **Primitives**: Strict equality (`===`)
|
|
13
|
-
* - **Objects**: Deep structural comparison
|
|
14
|
-
*
|
|
15
|
-
* This constraint is commonly combined with {@link MinItems} and {@link MaxItems}
|
|
16
|
-
* for comprehensive array validation. It's useful for modeling set-like data
|
|
17
|
-
* that must be represented as arrays in JSON.
|
|
18
|
-
*
|
|
19
|
-
* The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
20
|
-
* `typia.validate()`. It generates `uniqueItems: true` in JSON Schema.
|
|
21
|
-
*
|
|
22
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
23
|
-
* @example
|
|
24
|
-
* interface Preferences {
|
|
25
|
-
* // No duplicate tags allowed
|
|
26
|
-
* tags: (string & UniqueItems)[];
|
|
27
|
-
* // Unique user IDs
|
|
28
|
-
* favoriteUserIds: (number & UniqueItems)[];
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* @template Value Boolean flag, defaults to `true` (enable constraint)
|
|
32
|
-
*/
|
|
33
|
-
export type UniqueItems<Value extends boolean = true> = TagBase<{
|
|
34
|
-
target: "array";
|
|
35
|
-
kind: "uniqueItems";
|
|
36
|
-
value: Value;
|
|
37
|
-
validate: Value extends true
|
|
38
|
-
? `$importInternal("isUniqueItems")($input)`
|
|
39
|
-
: undefined;
|
|
40
|
-
exclusive: true;
|
|
41
|
-
schema: {
|
|
42
|
-
uniqueItems: true;
|
|
43
|
-
};
|
|
44
|
-
}>;
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Array unique elements constraint.
|
|
5
|
+
*
|
|
6
|
+
* `UniqueItems` is a type tag that validates all elements in an array are
|
|
7
|
+
* unique (no duplicates). Apply it to array properties using TypeScript
|
|
8
|
+
* intersection types.
|
|
9
|
+
*
|
|
10
|
+
* Uniqueness is determined by:
|
|
11
|
+
*
|
|
12
|
+
* - **Primitives**: Strict equality (`===`)
|
|
13
|
+
* - **Objects**: Deep structural comparison
|
|
14
|
+
*
|
|
15
|
+
* This constraint is commonly combined with {@link MinItems} and {@link MaxItems}
|
|
16
|
+
* for comprehensive array validation. It's useful for modeling set-like data
|
|
17
|
+
* that must be represented as arrays in JSON.
|
|
18
|
+
*
|
|
19
|
+
* The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
20
|
+
* `typia.validate()`. It generates `uniqueItems: true` in JSON Schema.
|
|
21
|
+
*
|
|
22
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
23
|
+
* @example
|
|
24
|
+
* interface Preferences {
|
|
25
|
+
* // No duplicate tags allowed
|
|
26
|
+
* tags: (string & UniqueItems)[];
|
|
27
|
+
* // Unique user IDs
|
|
28
|
+
* favoriteUserIds: (number & UniqueItems)[];
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* @template Value Boolean flag, defaults to `true` (enable constraint)
|
|
32
|
+
*/
|
|
33
|
+
export type UniqueItems<Value extends boolean = true> = TagBase<{
|
|
34
|
+
target: "array";
|
|
35
|
+
kind: "uniqueItems";
|
|
36
|
+
value: Value;
|
|
37
|
+
validate: Value extends true
|
|
38
|
+
? `$importInternal("isUniqueItems")($input)`
|
|
39
|
+
: undefined;
|
|
40
|
+
exclusive: true;
|
|
41
|
+
schema: {
|
|
42
|
+
uniqueItems: true;
|
|
43
|
+
};
|
|
44
|
+
}>;
|
package/src/tags/index.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export * from "./Constant";
|
|
2
|
-
export * from "./ContentMediaType";
|
|
3
|
-
export * from "./Default";
|
|
4
|
-
export * from "./Example";
|
|
5
|
-
export * from "./Examples";
|
|
6
|
-
export * from "./ExclusiveMaximum";
|
|
7
|
-
export * from "./ExclusiveMinimum";
|
|
8
|
-
export * from "./Format";
|
|
9
|
-
export * from "./JsonSchemaPlugin";
|
|
10
|
-
export * from "./Maximum";
|
|
11
|
-
export * from "./MaxItems";
|
|
12
|
-
export * from "./MaxLength";
|
|
13
|
-
export * from "./Minimum";
|
|
14
|
-
export * from "./MinItems";
|
|
15
|
-
export * from "./MinLength";
|
|
16
|
-
export * from "./MultipleOf";
|
|
17
|
-
export * from "./Pattern";
|
|
18
|
-
export * from "./Sequence";
|
|
19
|
-
export * from "./TagBase";
|
|
20
|
-
export * from "./Type";
|
|
21
|
-
export * from "./UniqueItems";
|
|
1
|
+
export * from "./Constant";
|
|
2
|
+
export * from "./ContentMediaType";
|
|
3
|
+
export * from "./Default";
|
|
4
|
+
export * from "./Example";
|
|
5
|
+
export * from "./Examples";
|
|
6
|
+
export * from "./ExclusiveMaximum";
|
|
7
|
+
export * from "./ExclusiveMinimum";
|
|
8
|
+
export * from "./Format";
|
|
9
|
+
export * from "./JsonSchemaPlugin";
|
|
10
|
+
export * from "./Maximum";
|
|
11
|
+
export * from "./MaxItems";
|
|
12
|
+
export * from "./MaxLength";
|
|
13
|
+
export * from "./Minimum";
|
|
14
|
+
export * from "./MinItems";
|
|
15
|
+
export * from "./MinLength";
|
|
16
|
+
export * from "./MultipleOf";
|
|
17
|
+
export * from "./Pattern";
|
|
18
|
+
export * from "./Sequence";
|
|
19
|
+
export * from "./TagBase";
|
|
20
|
+
export * from "./Type";
|
|
21
|
+
export * from "./UniqueItems";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type for assertion guard functions that narrow input type.
|
|
3
|
-
*
|
|
4
|
-
* `AssertionGuard<T>` is a function type that validates input at runtime and
|
|
5
|
-
* asserts it as type `T`. Unlike regular assertions that return the value,
|
|
6
|
-
* assertion guards return void but narrow the input parameter's type.
|
|
7
|
-
*
|
|
8
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
9
|
-
* @template T Target type to assert
|
|
10
|
-
* @throws {TypeGuardError} When validation fails
|
|
11
|
-
*/
|
|
12
|
-
export type AssertionGuard<T> = (input: unknown) => asserts input is T;
|
|
1
|
+
/**
|
|
2
|
+
* Type for assertion guard functions that narrow input type.
|
|
3
|
+
*
|
|
4
|
+
* `AssertionGuard<T>` is a function type that validates input at runtime and
|
|
5
|
+
* asserts it as type `T`. Unlike regular assertions that return the value,
|
|
6
|
+
* assertion guards return void but narrow the input parameter's type.
|
|
7
|
+
*
|
|
8
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
9
|
+
* @template T Target type to assert
|
|
10
|
+
* @throws {TypeGuardError} When validation fails
|
|
11
|
+
*/
|
|
12
|
+
export type AssertionGuard<T> = (input: unknown) => asserts input is T;
|
package/src/typings/Atomic.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Atomic (primitive) type utilities for typia's type system.
|
|
3
|
-
*
|
|
4
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
5
|
-
*/
|
|
6
|
-
export namespace Atomic {
|
|
7
|
-
/** Union of JavaScript primitive value types. */
|
|
8
|
-
export type Type = boolean | number | string | bigint;
|
|
9
|
-
|
|
10
|
-
/** String literal names for atomic types. */
|
|
11
|
-
export type Literal = "boolean" | "integer" | "number" | "string" | "bigint";
|
|
12
|
-
|
|
13
|
-
/** Maps literal type names to their corresponding value types. */
|
|
14
|
-
export type Mapper = {
|
|
15
|
-
boolean: boolean;
|
|
16
|
-
integer: number;
|
|
17
|
-
number: number;
|
|
18
|
-
string: string;
|
|
19
|
-
bigint: bigint;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Atomic (primitive) type utilities for typia's type system.
|
|
3
|
+
*
|
|
4
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
5
|
+
*/
|
|
6
|
+
export namespace Atomic {
|
|
7
|
+
/** Union of JavaScript primitive value types. */
|
|
8
|
+
export type Type = boolean | number | string | bigint;
|
|
9
|
+
|
|
10
|
+
/** String literal names for atomic types. */
|
|
11
|
+
export type Literal = "boolean" | "integer" | "number" | "string" | "bigint";
|
|
12
|
+
|
|
13
|
+
/** Maps literal type names to their corresponding value types. */
|
|
14
|
+
export type Mapper = {
|
|
15
|
+
boolean: boolean;
|
|
16
|
+
integer: number;
|
|
17
|
+
number: number;
|
|
18
|
+
string: string;
|
|
19
|
+
bigint: bigint;
|
|
20
|
+
};
|
|
21
|
+
}
|
package/src/typings/CamelCase.ts
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { Equal } from "./internal/Equal";
|
|
2
|
-
import { IsTuple } from "./internal/IsTuple";
|
|
3
|
-
import { NativeClass } from "./internal/NativeClass";
|
|
4
|
-
import { ValueOf } from "./internal/ValueOf";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Converts all object keys to camelCase.
|
|
8
|
-
*
|
|
9
|
-
* `CamelCase<T>` transforms object property names to camelCase format and
|
|
10
|
-
* erases methods like {@link Resolved}. Recursively processes nested
|
|
11
|
-
* structures.
|
|
12
|
-
*
|
|
13
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
14
|
-
* @template T Target type to transform
|
|
15
|
-
*/
|
|
16
|
-
export type CamelCase<T> =
|
|
17
|
-
Equal<T, CamelizeMain<T>> extends true ? T : CamelizeMain<T>;
|
|
18
|
-
|
|
19
|
-
type CamelizeMain<T> = T extends [never]
|
|
20
|
-
? never // special trick for (jsonable | null) type
|
|
21
|
-
: T extends { valueOf(): boolean | bigint | number | string }
|
|
22
|
-
? ValueOf<T>
|
|
23
|
-
: T extends Function
|
|
24
|
-
? never
|
|
25
|
-
: T extends object
|
|
26
|
-
? CamelizeObject<T>
|
|
27
|
-
: T;
|
|
28
|
-
|
|
29
|
-
type CamelizeObject<T extends object> =
|
|
30
|
-
T extends Array<infer U>
|
|
31
|
-
? IsTuple<T> extends true
|
|
32
|
-
? CamelizeTuple<T>
|
|
33
|
-
: CamelizeMain<U>[]
|
|
34
|
-
: T extends Set<infer U>
|
|
35
|
-
? Set<CamelizeMain<U>>
|
|
36
|
-
: T extends Map<infer K, infer V>
|
|
37
|
-
? Map<CamelizeMain<K>, CamelizeMain<V>>
|
|
38
|
-
: T extends WeakSet<any> | WeakMap<any, any>
|
|
39
|
-
? never
|
|
40
|
-
: T extends NativeClass
|
|
41
|
-
? T
|
|
42
|
-
: {
|
|
43
|
-
[Key in keyof T as CamelizeString<Key & string>]: CamelizeMain<
|
|
44
|
-
T[Key]
|
|
45
|
-
>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
type CamelizeTuple<T extends readonly any[]> = T extends []
|
|
49
|
-
? []
|
|
50
|
-
: T extends [infer F]
|
|
51
|
-
? [CamelizeMain<F>]
|
|
52
|
-
: T extends [infer F, ...infer Rest extends readonly any[]]
|
|
53
|
-
? [CamelizeMain<F>, ...CamelizeTuple<Rest>]
|
|
54
|
-
: T extends [(infer F)?]
|
|
55
|
-
? [CamelizeMain<F>?]
|
|
56
|
-
: T extends [(infer F)?, ...infer Rest extends readonly any[]]
|
|
57
|
-
? [CamelizeMain<F>?, ...CamelizeTuple<Rest>]
|
|
58
|
-
: [];
|
|
59
|
-
|
|
60
|
-
type CamelizeString<Key extends string> = Key extends `_${infer R}`
|
|
61
|
-
? `_${CamelizeString<R>}`
|
|
62
|
-
: Key extends `${infer _F}_${infer _R}`
|
|
63
|
-
? CamelizeSnakeString<Key>
|
|
64
|
-
: Key extends Uppercase<Key>
|
|
65
|
-
? Lowercase<Key>
|
|
66
|
-
: CamelizePascalString<Key>;
|
|
67
|
-
type CamelizePascalString<Key extends string> =
|
|
68
|
-
Key extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : Key;
|
|
69
|
-
type CamelizeSnakeString<Key extends string> = Key extends `_${infer R}`
|
|
70
|
-
? CamelizeSnakeString<R>
|
|
71
|
-
: Key extends `${infer F}_${infer M}${infer R}`
|
|
72
|
-
? M extends "_"
|
|
73
|
-
? CamelizeSnakeString<`${F}_${R}`>
|
|
74
|
-
: `${Lowercase<F>}${Uppercase<M>}${CamelizeSnakeString<R>}`
|
|
75
|
-
: Lowercase<Key>;
|
|
1
|
+
import { Equal } from "./internal/Equal";
|
|
2
|
+
import { IsTuple } from "./internal/IsTuple";
|
|
3
|
+
import { NativeClass } from "./internal/NativeClass";
|
|
4
|
+
import { ValueOf } from "./internal/ValueOf";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts all object keys to camelCase.
|
|
8
|
+
*
|
|
9
|
+
* `CamelCase<T>` transforms object property names to camelCase format and
|
|
10
|
+
* erases methods like {@link Resolved}. Recursively processes nested
|
|
11
|
+
* structures.
|
|
12
|
+
*
|
|
13
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
14
|
+
* @template T Target type to transform
|
|
15
|
+
*/
|
|
16
|
+
export type CamelCase<T> =
|
|
17
|
+
Equal<T, CamelizeMain<T>> extends true ? T : CamelizeMain<T>;
|
|
18
|
+
|
|
19
|
+
type CamelizeMain<T> = T extends [never]
|
|
20
|
+
? never // special trick for (jsonable | null) type
|
|
21
|
+
: T extends { valueOf(): boolean | bigint | number | string }
|
|
22
|
+
? ValueOf<T>
|
|
23
|
+
: T extends Function
|
|
24
|
+
? never
|
|
25
|
+
: T extends object
|
|
26
|
+
? CamelizeObject<T>
|
|
27
|
+
: T;
|
|
28
|
+
|
|
29
|
+
type CamelizeObject<T extends object> =
|
|
30
|
+
T extends Array<infer U>
|
|
31
|
+
? IsTuple<T> extends true
|
|
32
|
+
? CamelizeTuple<T>
|
|
33
|
+
: CamelizeMain<U>[]
|
|
34
|
+
: T extends Set<infer U>
|
|
35
|
+
? Set<CamelizeMain<U>>
|
|
36
|
+
: T extends Map<infer K, infer V>
|
|
37
|
+
? Map<CamelizeMain<K>, CamelizeMain<V>>
|
|
38
|
+
: T extends WeakSet<any> | WeakMap<any, any>
|
|
39
|
+
? never
|
|
40
|
+
: T extends NativeClass
|
|
41
|
+
? T
|
|
42
|
+
: {
|
|
43
|
+
[Key in keyof T as CamelizeString<Key & string>]: CamelizeMain<
|
|
44
|
+
T[Key]
|
|
45
|
+
>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type CamelizeTuple<T extends readonly any[]> = T extends []
|
|
49
|
+
? []
|
|
50
|
+
: T extends [infer F]
|
|
51
|
+
? [CamelizeMain<F>]
|
|
52
|
+
: T extends [infer F, ...infer Rest extends readonly any[]]
|
|
53
|
+
? [CamelizeMain<F>, ...CamelizeTuple<Rest>]
|
|
54
|
+
: T extends [(infer F)?]
|
|
55
|
+
? [CamelizeMain<F>?]
|
|
56
|
+
: T extends [(infer F)?, ...infer Rest extends readonly any[]]
|
|
57
|
+
? [CamelizeMain<F>?, ...CamelizeTuple<Rest>]
|
|
58
|
+
: [];
|
|
59
|
+
|
|
60
|
+
type CamelizeString<Key extends string> = Key extends `_${infer R}`
|
|
61
|
+
? `_${CamelizeString<R>}`
|
|
62
|
+
: Key extends `${infer _F}_${infer _R}`
|
|
63
|
+
? CamelizeSnakeString<Key>
|
|
64
|
+
: Key extends Uppercase<Key>
|
|
65
|
+
? Lowercase<Key>
|
|
66
|
+
: CamelizePascalString<Key>;
|
|
67
|
+
type CamelizePascalString<Key extends string> =
|
|
68
|
+
Key extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : Key;
|
|
69
|
+
type CamelizeSnakeString<Key extends string> = Key extends `_${infer R}`
|
|
70
|
+
? CamelizeSnakeString<R>
|
|
71
|
+
: Key extends `${infer F}_${infer M}${infer R}`
|
|
72
|
+
? M extends "_"
|
|
73
|
+
? CamelizeSnakeString<`${F}_${R}`>
|
|
74
|
+
: `${Lowercase<F>}${Uppercase<M>}${CamelizeSnakeString<R>}`
|
|
75
|
+
: Lowercase<Key>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { OmitNever } from "./OmitNever";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Extracts non-function properties from a class type.
|
|
5
|
-
*
|
|
6
|
-
* `ClassProperties<T>` filters out all method properties from a class, keeping
|
|
7
|
-
* only data properties. Useful for serialization where methods should be
|
|
8
|
-
* excluded.
|
|
9
|
-
*
|
|
10
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
11
|
-
* @template T Target class type
|
|
12
|
-
*/
|
|
13
|
-
export type ClassProperties<T extends object> = OmitNever<{
|
|
14
|
-
[K in keyof T]: T[K] extends Function ? never : T[K];
|
|
15
|
-
}>;
|
|
1
|
+
import { OmitNever } from "./OmitNever";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extracts non-function properties from a class type.
|
|
5
|
+
*
|
|
6
|
+
* `ClassProperties<T>` filters out all method properties from a class, keeping
|
|
7
|
+
* only data properties. Useful for serialization where methods should be
|
|
8
|
+
* excluded.
|
|
9
|
+
*
|
|
10
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
11
|
+
* @template T Target class type
|
|
12
|
+
*/
|
|
13
|
+
export type ClassProperties<T extends object> = OmitNever<{
|
|
14
|
+
[K in keyof T]: T[K] extends Function ? never : T[K];
|
|
15
|
+
}>;
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recursively makes all properties of a type optional.
|
|
3
|
-
*
|
|
4
|
-
* `DeepPartial<T>` transforms a type by making every property optional at all
|
|
5
|
-
* nesting levels. Unlike TypeScript's built-in `Partial<T>` which only affects
|
|
6
|
-
* the top level, this utility recursively applies optionality to nested objects
|
|
7
|
-
* and arrays.
|
|
8
|
-
*
|
|
9
|
-
* Used primarily in {@link IJsonParseResult.IFailure} to represent partially
|
|
10
|
-
* recovered data from malformed JSON, where some properties may be missing due
|
|
11
|
-
* to parsing errors.
|
|
12
|
-
*
|
|
13
|
-
* Behavior:
|
|
14
|
-
*
|
|
15
|
-
* - **Primitives** (`string`, `number`, `boolean`, `bigint`, `symbol`, `null`,
|
|
16
|
-
* `undefined`): returned as-is
|
|
17
|
-
* - **Functions**: returned as-is
|
|
18
|
-
* - **Arrays**: element type becomes `DeepPartial<U>`
|
|
19
|
-
* - **Objects**: all properties become optional with `DeepPartial` applied
|
|
20
|
-
*
|
|
21
|
-
* @author Michael - https://github.com/8471919
|
|
22
|
-
* @template T The type to make deeply partial
|
|
23
|
-
*/
|
|
24
|
-
export type DeepPartial<T> = T extends
|
|
25
|
-
| string
|
|
26
|
-
| number
|
|
27
|
-
| boolean
|
|
28
|
-
| bigint
|
|
29
|
-
| symbol
|
|
30
|
-
| null
|
|
31
|
-
| undefined
|
|
32
|
-
? T
|
|
33
|
-
: T extends (...args: unknown[]) => unknown
|
|
34
|
-
? T
|
|
35
|
-
: T extends Array<infer U>
|
|
36
|
-
? Array<DeepPartial<U>>
|
|
37
|
-
: T extends object
|
|
38
|
-
? { [P in keyof T]?: DeepPartial<T[P]> }
|
|
39
|
-
: T;
|
|
1
|
+
/**
|
|
2
|
+
* Recursively makes all properties of a type optional.
|
|
3
|
+
*
|
|
4
|
+
* `DeepPartial<T>` transforms a type by making every property optional at all
|
|
5
|
+
* nesting levels. Unlike TypeScript's built-in `Partial<T>` which only affects
|
|
6
|
+
* the top level, this utility recursively applies optionality to nested objects
|
|
7
|
+
* and arrays.
|
|
8
|
+
*
|
|
9
|
+
* Used primarily in {@link IJsonParseResult.IFailure} to represent partially
|
|
10
|
+
* recovered data from malformed JSON, where some properties may be missing due
|
|
11
|
+
* to parsing errors.
|
|
12
|
+
*
|
|
13
|
+
* Behavior:
|
|
14
|
+
*
|
|
15
|
+
* - **Primitives** (`string`, `number`, `boolean`, `bigint`, `symbol`, `null`,
|
|
16
|
+
* `undefined`): returned as-is
|
|
17
|
+
* - **Functions**: returned as-is
|
|
18
|
+
* - **Arrays**: element type becomes `DeepPartial<U>`
|
|
19
|
+
* - **Objects**: all properties become optional with `DeepPartial` applied
|
|
20
|
+
*
|
|
21
|
+
* @author Michael - https://github.com/8471919
|
|
22
|
+
* @template T The type to make deeply partial
|
|
23
|
+
*/
|
|
24
|
+
export type DeepPartial<T> = T extends
|
|
25
|
+
| string
|
|
26
|
+
| number
|
|
27
|
+
| boolean
|
|
28
|
+
| bigint
|
|
29
|
+
| symbol
|
|
30
|
+
| null
|
|
31
|
+
| undefined
|
|
32
|
+
? T
|
|
33
|
+
: T extends (...args: unknown[]) => unknown
|
|
34
|
+
? T
|
|
35
|
+
: T extends Array<infer U>
|
|
36
|
+
? Array<DeepPartial<U>>
|
|
37
|
+
: T extends object
|
|
38
|
+
? { [P in keyof T]?: DeepPartial<T[P]> }
|
|
39
|
+
: T;
|
package/src/typings/OmitNever.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { SpecialFields } from "./SpecialFields";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Omits properties with `never` type from an object type.
|
|
5
|
-
*
|
|
6
|
-
* `OmitNever<T>` removes all properties whose value type is `never`, producing
|
|
7
|
-
* a cleaner type without impossible properties.
|
|
8
|
-
*
|
|
9
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
10
|
-
* @template T Target object type
|
|
11
|
-
*/
|
|
12
|
-
export type OmitNever<T extends object> = Omit<T, SpecialFields<T, never>>;
|
|
1
|
+
import { SpecialFields } from "./SpecialFields";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Omits properties with `never` type from an object type.
|
|
5
|
+
*
|
|
6
|
+
* `OmitNever<T>` removes all properties whose value type is `never`, producing
|
|
7
|
+
* a cleaner type without impossible properties.
|
|
8
|
+
*
|
|
9
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
10
|
+
* @template T Target object type
|
|
11
|
+
*/
|
|
12
|
+
export type OmitNever<T extends object> = Omit<T, SpecialFields<T, never>>;
|