typia 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/executable/setup/PluginConfigurator.js +3 -3
- package/lib/executable/setup/PluginConfigurator.mjs +3 -3
- package/lib/executable/setup/PluginConfigurator.mjs.map +1 -1
- package/lib/executable/typia.js +15 -15
- package/lib/executable/typia.mjs +15 -15
- package/package.json +5 -5
- package/src/TypeGuardError.ts +145 -145
- package/src/executable/TypiaGenerateWizard.ts +82 -82
- package/src/executable/TypiaPatchWizard.ts +45 -45
- package/src/executable/TypiaSetupWizard.ts +171 -171
- package/src/executable/setup/ArgumentParser.ts +42 -42
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/executable/setup/FileRetriever.ts +19 -19
- package/src/executable/setup/PackageManager.ts +87 -87
- package/src/executable/setup/PluginConfigurator.ts +74 -74
- package/src/executable/typia.ts +55 -55
- package/src/functional.ts +600 -600
- package/src/http.ts +843 -843
- package/src/index.ts +4 -4
- package/src/internal/_IProtobufWriter.ts +18 -18
- package/src/internal/_ProtobufReader.ts +187 -187
- package/src/internal/_ProtobufSizer.ts +137 -137
- package/src/internal/_ProtobufWriter.ts +135 -135
- package/src/internal/_accessExpressionAsString.ts +46 -46
- package/src/internal/_assertGuard.ts +13 -13
- package/src/internal/_coerceLlmArguments.ts +7 -7
- package/src/internal/_createStandardSchema.ts +133 -133
- package/src/internal/_functionalTypeGuardErrorFactory.ts +4 -4
- package/src/internal/_httpFormDataReadArray.ts +4 -4
- package/src/internal/_httpFormDataReadBigint.ts +18 -18
- package/src/internal/_httpFormDataReadBlob.ts +10 -10
- package/src/internal/_httpFormDataReadBoolean.ts +16 -16
- package/src/internal/_httpFormDataReadFile.ts +10 -10
- package/src/internal/_httpFormDataReadNumber.ts +15 -15
- package/src/internal/_httpFormDataReadString.ts +10 -10
- package/src/internal/_httpHeaderReadBigint.ts +10 -10
- package/src/internal/_httpHeaderReadBoolean.ts +8 -8
- package/src/internal/_httpHeaderReadNumber.ts +7 -7
- package/src/internal/_httpParameterReadBigint.ts +10 -10
- package/src/internal/_httpParameterReadBoolean.ts +8 -8
- package/src/internal/_httpParameterReadNumber.ts +7 -7
- package/src/internal/_httpParameterReadString.ts +2 -2
- package/src/internal/_httpQueryParseURLSearchParams.ts +12 -12
- package/src/internal/_httpQueryReadArray.ts +4 -4
- package/src/internal/_httpQueryReadBigint.ts +12 -12
- package/src/internal/_httpQueryReadBoolean.ts +14 -14
- package/src/internal/_httpQueryReadNumber.ts +9 -9
- package/src/internal/_httpQueryReadString.ts +4 -4
- package/src/internal/_isBetween.ts +2 -2
- package/src/internal/_isBigintString.ts +8 -8
- package/src/internal/_isFormatByte.ts +7 -7
- package/src/internal/_isFormatDate.ts +3 -3
- package/src/internal/_isFormatDateTime.ts +4 -4
- package/src/internal/_isFormatDuration.ts +4 -4
- package/src/internal/_isFormatEmail.ts +4 -4
- package/src/internal/_isFormatHostname.ts +4 -4
- package/src/internal/_isFormatIdnEmail.ts +4 -4
- package/src/internal/_isFormatIdnHostname.ts +4 -4
- package/src/internal/_isFormatIpv4.ts +4 -4
- package/src/internal/_isFormatIpv6.ts +4 -4
- package/src/internal/_isFormatIri.ts +3 -3
- package/src/internal/_isFormatIriReference.ts +4 -4
- package/src/internal/_isFormatJsonPointer.ts +3 -3
- package/src/internal/_isFormatPassword.ts +1 -1
- package/src/internal/_isFormatRegex.ts +8 -8
- package/src/internal/_isFormatRelativeJsonPointer.ts +4 -4
- package/src/internal/_isFormatTime.ts +4 -4
- package/src/internal/_isFormatUri.ts +6 -6
- package/src/internal/_isFormatUriReference.ts +5 -5
- package/src/internal/_isFormatUriTemplate.ts +4 -4
- package/src/internal/_isFormatUrl.ts +4 -4
- package/src/internal/_isFormatUuid.ts +3 -3
- package/src/internal/_isTypeFloat.ts +5 -5
- package/src/internal/_isTypeInt32.ts +5 -5
- package/src/internal/_isTypeInt64.ts +5 -5
- package/src/internal/_isTypeUint32.ts +5 -5
- package/src/internal/_isTypeUint64.ts +5 -5
- package/src/internal/_isUniqueItems.ts +159 -159
- package/src/internal/_jsonStringifyNumber.ts +12 -12
- package/src/internal/_jsonStringifyRest.ts +3 -3
- package/src/internal/_jsonStringifyString.ts +42 -42
- package/src/internal/_jsonStringifyTail.ts +2 -2
- package/src/internal/_llmApplicationFinalize.ts +24 -24
- package/src/internal/_miscCloneAny.ts +46 -46
- package/src/internal/_notationAny.ts +37 -37
- package/src/internal/_notationCamel.ts +13 -13
- package/src/internal/_notationPascal.ts +8 -8
- package/src/internal/_notationSnake.ts +43 -43
- package/src/internal/_parseLlmArguments.ts +7 -7
- package/src/internal/_randomArray.ts +21 -21
- package/src/internal/_randomBigint.ts +6 -6
- package/src/internal/_randomBoolean.ts +1 -1
- package/src/internal/_randomFormatByte.ts +3 -3
- package/src/internal/_randomFormatDate.ts +18 -18
- package/src/internal/_randomFormatDatetime.ts +16 -16
- package/src/internal/_randomFormatDuration.ts +27 -27
- package/src/internal/_randomFormatEmail.ts +11 -11
- package/src/internal/_randomFormatHostname.ts +6 -6
- package/src/internal/_randomFormatIdnEmail.ts +3 -3
- package/src/internal/_randomFormatIdnHostname.ts +3 -3
- package/src/internal/_randomFormatIpv4.ts +11 -11
- package/src/internal/_randomFormatIpv6.ts +11 -11
- package/src/internal/_randomFormatIri.ts +3 -3
- package/src/internal/_randomFormatIriReference.ts +3 -3
- package/src/internal/_randomFormatJsonPointer.ts +7 -7
- package/src/internal/_randomFormatPassword.ts +8 -8
- package/src/internal/_randomFormatRegex.ts +4 -4
- package/src/internal/_randomFormatRelativeJsonPointer.ts +8 -8
- package/src/internal/_randomFormatTime.ts +14 -14
- package/src/internal/_randomFormatUri.ts +3 -3
- package/src/internal/_randomFormatUriReference.ts +3 -3
- package/src/internal/_randomFormatUriTemplate.ts +3 -3
- package/src/internal/_randomFormatUrl.ts +11 -11
- package/src/internal/_randomFormatUuid.ts +6 -6
- package/src/internal/_randomInteger.ts +53 -53
- package/src/internal/_randomNumber.ts +80 -80
- package/src/internal/_randomPattern.ts +10 -10
- package/src/internal/_randomPick.ts +9 -9
- package/src/internal/_randomString.ts +24 -24
- package/src/internal/_throwTypeGuardError.ts +5 -5
- package/src/internal/_validateReport.ts +21 -21
- package/src/internal/private/__notationCapitalize.ts +2 -2
- package/src/internal/private/__notationUnsnake.ts +24 -24
- package/src/json.ts +553 -553
- package/src/llm.ts +408 -408
- package/src/misc.ts +448 -448
- package/src/module.ts +811 -811
- package/src/notations.ts +624 -624
- package/src/programmers/TypiaProgrammer.ts +8 -8
- package/src/protobuf.ts +499 -499
- package/src/re-exports.ts +33 -33
- package/src/reflect.ts +75 -75
- package/src/transform.ts +5 -5
- package/src/transformers/NoTransformConfigurationError.ts +16 -16
|
@@ -50,9 +50,9 @@ var PluginConfigurator;
|
|
|
50
50
|
if (strict === undefined && strictNullChecks === undefined)
|
|
51
51
|
compilerOptions.strict = true;
|
|
52
52
|
if (oldbie === undefined)
|
|
53
|
-
plugins.push(comment_json_1.default.parse(`
|
|
54
|
-
{
|
|
55
|
-
"transform": "typia/lib/transform"
|
|
53
|
+
plugins.push(comment_json_1.default.parse(`
|
|
54
|
+
{
|
|
55
|
+
"transform": "typia/lib/transform"
|
|
56
56
|
}`));
|
|
57
57
|
yield fs_1.default.promises.writeFile(args.project, comment_json_1.default.stringify(config, null, 2));
|
|
58
58
|
});
|
|
@@ -35,9 +35,9 @@ var PluginConfigurator;
|
|
|
35
35
|
if (strict === undefined && strictNullChecks === undefined)
|
|
36
36
|
compilerOptions.strict = true;
|
|
37
37
|
if (oldbie === undefined)
|
|
38
|
-
plugins.push(comments.parse(`
|
|
39
|
-
{
|
|
40
|
-
"transform": "typia/lib/transform"
|
|
38
|
+
plugins.push(comments.parse(`
|
|
39
|
+
{
|
|
40
|
+
"transform": "typia/lib/transform"
|
|
41
41
|
}`));
|
|
42
42
|
await fs.promises.writeFile(args.project, comments.stringify(config, null, 2));
|
|
43
43
|
}
|
|
@@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|
42
42
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
|
-
const USAGE = `Wrong command has been detected. Use like below:
|
|
46
|
-
|
|
47
|
-
npx typia setup \\
|
|
48
|
-
--manager (npm|pnpm|yarn) \\
|
|
49
|
-
--project {tsconfig.json file path}
|
|
50
|
-
|
|
51
|
-
- npx typia setup
|
|
52
|
-
- npx typia setup --manager pnpm
|
|
53
|
-
- npx typia setup --project tsconfig.test.json
|
|
54
|
-
|
|
55
|
-
npx typia generate
|
|
56
|
-
--input {directory} \\
|
|
57
|
-
--output {directory}
|
|
58
|
-
|
|
59
|
-
--npx typia generate --input src/templates --output src/functional
|
|
45
|
+
const USAGE = `Wrong command has been detected. Use like below:
|
|
46
|
+
|
|
47
|
+
npx typia setup \\
|
|
48
|
+
--manager (npm|pnpm|yarn) \\
|
|
49
|
+
--project {tsconfig.json file path}
|
|
50
|
+
|
|
51
|
+
- npx typia setup
|
|
52
|
+
- npx typia setup --manager pnpm
|
|
53
|
+
- npx typia setup --project tsconfig.test.json
|
|
54
|
+
|
|
55
|
+
npx typia generate
|
|
56
|
+
--input {directory} \\
|
|
57
|
+
--output {directory}
|
|
58
|
+
|
|
59
|
+
--npx typia generate --input src/templates --output src/functional
|
|
60
60
|
`;
|
|
61
61
|
const halt = (desc) => {
|
|
62
62
|
console.error(desc);
|
package/lib/executable/typia.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const USAGE = `Wrong command has been detected. Use like below:
|
|
3
|
-
|
|
4
|
-
npx typia setup \\
|
|
5
|
-
--manager (npm|pnpm|yarn) \\
|
|
6
|
-
--project {tsconfig.json file path}
|
|
7
|
-
|
|
8
|
-
- npx typia setup
|
|
9
|
-
- npx typia setup --manager pnpm
|
|
10
|
-
- npx typia setup --project tsconfig.test.json
|
|
11
|
-
|
|
12
|
-
npx typia generate
|
|
13
|
-
--input {directory} \\
|
|
14
|
-
--output {directory}
|
|
15
|
-
|
|
16
|
-
--npx typia generate --input src/templates --output src/functional
|
|
2
|
+
const USAGE = `Wrong command has been detected. Use like below:
|
|
3
|
+
|
|
4
|
+
npx typia setup \\
|
|
5
|
+
--manager (npm|pnpm|yarn) \\
|
|
6
|
+
--project {tsconfig.json file path}
|
|
7
|
+
|
|
8
|
+
- npx typia setup
|
|
9
|
+
- npx typia setup --manager pnpm
|
|
10
|
+
- npx typia setup --project tsconfig.test.json
|
|
11
|
+
|
|
12
|
+
npx typia generate
|
|
13
|
+
--input {directory} \\
|
|
14
|
+
--output {directory}
|
|
15
|
+
|
|
16
|
+
--npx typia generate --input src/templates --output src/functional
|
|
17
17
|
`;
|
|
18
18
|
const halt = (desc) => {
|
|
19
19
|
console.error(desc);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typia",
|
|
3
|
-
"version": "12.0.0-dev.
|
|
3
|
+
"version": "12.0.0-dev.20260310",
|
|
4
4
|
"description": "Superfast runtime validators with only one line",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"inquirer": "^8.2.5",
|
|
51
51
|
"package-manager-detector": "^0.2.0",
|
|
52
52
|
"randexp": "^0.5.3",
|
|
53
|
-
"@typia/interface": "^12.0.0-dev.
|
|
54
|
-
"@typia/utils": "^12.0.0-dev.
|
|
55
|
-
"@typia/
|
|
56
|
-
"@typia/
|
|
53
|
+
"@typia/interface": "^12.0.0-dev.20260310",
|
|
54
|
+
"@typia/utils": "^12.0.0-dev.20260310",
|
|
55
|
+
"@typia/core": "^12.0.0-dev.20260310",
|
|
56
|
+
"@typia/transform": "^12.0.0-dev.20260310"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"typescript": ">=4.8.0 <5.10.0"
|
package/src/TypeGuardError.ts
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error thrown when type assertion fails.
|
|
3
|
-
*
|
|
4
|
-
* Thrown by {@link assert}, {@link assertGuard}, and other assert-family
|
|
5
|
-
* functions when input doesn't match expected type `T`. Contains detailed
|
|
6
|
-
* information about the first assertion failure:
|
|
7
|
-
*
|
|
8
|
-
* - `method`: Which typia function threw (e.g., `"typia.assert"`)
|
|
9
|
-
* - `path`: Property path where error occurred (e.g., `"input.user.age"`)
|
|
10
|
-
* - `expected`: Expected type string (e.g., `"number & ExclusiveMinimum<19>"`)
|
|
11
|
-
* - `value`: Actual value that failed validation
|
|
12
|
-
*
|
|
13
|
-
* @template T Expected type (for type safety)
|
|
14
|
-
*/
|
|
15
|
-
export class TypeGuardError<T = any> extends Error {
|
|
16
|
-
/**
|
|
17
|
-
* Name of the typia method that threw this error.
|
|
18
|
-
*
|
|
19
|
-
* E.g., `"typia.assert"`, `"typia.assertEquals"`, `"typia.assertGuard"`.
|
|
20
|
-
*/
|
|
21
|
-
public readonly method: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Property path where assertion failed.
|
|
25
|
-
*
|
|
26
|
-
* Uses dot notation for nested properties. `undefined` if error occurred at
|
|
27
|
-
* root level.
|
|
28
|
-
*
|
|
29
|
-
* E.g., `"input.age"`, `"input.profile.email"`, `"input[0].name"`.
|
|
30
|
-
*/
|
|
31
|
-
public readonly path: string | undefined;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* String representation of expected type.
|
|
35
|
-
*
|
|
36
|
-
* E.g., `"string"`, `"number & ExclusiveMinimum<19>"`, `"{ name: string; age:
|
|
37
|
-
* number }"`.
|
|
38
|
-
*/
|
|
39
|
-
public readonly expected: string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Actual value that failed assertion.
|
|
43
|
-
*
|
|
44
|
-
* The raw value at the error path, useful for debugging.
|
|
45
|
-
*/
|
|
46
|
-
public readonly value: unknown;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Optional human-readable error description.
|
|
50
|
-
*
|
|
51
|
-
* Primarily for AI agent libraries or custom validation scenarios needing
|
|
52
|
-
* additional context. Standard assertions rely on `path`, `expected`, and
|
|
53
|
-
* `value` for error reporting.
|
|
54
|
-
*/
|
|
55
|
-
public readonly description?: string | undefined;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Phantom property for TypeScript type safety.
|
|
59
|
-
*
|
|
60
|
-
* Not used at runtime—exists only to preserve generic type `T` in the type
|
|
61
|
-
* system. Always `undefined`.
|
|
62
|
-
*
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
protected readonly fake_expected_typed_value_?: T | undefined;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Creates a new TypeGuardError instance.
|
|
69
|
-
*
|
|
70
|
-
* @param props Error properties
|
|
71
|
-
*/
|
|
72
|
-
public constructor(props: TypeGuardError.IProps) {
|
|
73
|
-
// MESSAGE CONSTRUCTION
|
|
74
|
-
// Use custom message if provided, otherwise generate default format
|
|
75
|
-
super(
|
|
76
|
-
props.message ||
|
|
77
|
-
`Error on ${props.method}(): invalid type${
|
|
78
|
-
props.path ? ` on ${props.path}` : ""
|
|
79
|
-
}, expect to be ${props.expected}`,
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
// INHERITANCE POLYFILL
|
|
83
|
-
// Set up prototype for compatibility across different JavaScript environments
|
|
84
|
-
const proto = new.target.prototype;
|
|
85
|
-
if (Object.setPrototypeOf) Object.setPrototypeOf(this, proto);
|
|
86
|
-
else (this as any).__proto__ = proto;
|
|
87
|
-
|
|
88
|
-
// ASSIGN MEMBERS
|
|
89
|
-
this.method = props.method;
|
|
90
|
-
this.path = props.path;
|
|
91
|
-
this.expected = props.expected;
|
|
92
|
-
this.value = props.value;
|
|
93
|
-
if (props.description || props.value === undefined)
|
|
94
|
-
this.description =
|
|
95
|
-
props.description ??
|
|
96
|
-
[
|
|
97
|
-
"The value at this path is `undefined`.",
|
|
98
|
-
"",
|
|
99
|
-
`Please fill the \`${props.expected}\` typed value next time.`,
|
|
100
|
-
].join("\n");
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export namespace TypeGuardError {
|
|
105
|
-
/** Properties for constructing a TypeGuardError. */
|
|
106
|
-
export interface IProps {
|
|
107
|
-
/**
|
|
108
|
-
* Name of the typia method that threw the error.
|
|
109
|
-
*
|
|
110
|
-
* E.g., `"typia.assert"`, `"typia.assertEquals"`.
|
|
111
|
-
*/
|
|
112
|
-
method: string;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Property path where assertion failed (optional).
|
|
116
|
-
*
|
|
117
|
-
* E.g., `"input.age"`, `"input.profile.email"`.
|
|
118
|
-
*/
|
|
119
|
-
path?: undefined | string;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* String representation of expected type.
|
|
123
|
-
*
|
|
124
|
-
* E.g., `"string"`, `"number & ExclusiveMinimum<19>"`.
|
|
125
|
-
*/
|
|
126
|
-
expected: string;
|
|
127
|
-
|
|
128
|
-
/** Actual value that failed assertion. */
|
|
129
|
-
value: unknown;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Optional human-readable error description.
|
|
133
|
-
*
|
|
134
|
-
* For AI agent libraries or custom validation needing additional context.
|
|
135
|
-
*/
|
|
136
|
-
description?: string;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Custom error message (optional).
|
|
140
|
-
*
|
|
141
|
-
* If not provided, a default message is generated from other properties.
|
|
142
|
-
*/
|
|
143
|
-
message?: undefined | string;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when type assertion fails.
|
|
3
|
+
*
|
|
4
|
+
* Thrown by {@link assert}, {@link assertGuard}, and other assert-family
|
|
5
|
+
* functions when input doesn't match expected type `T`. Contains detailed
|
|
6
|
+
* information about the first assertion failure:
|
|
7
|
+
*
|
|
8
|
+
* - `method`: Which typia function threw (e.g., `"typia.assert"`)
|
|
9
|
+
* - `path`: Property path where error occurred (e.g., `"input.user.age"`)
|
|
10
|
+
* - `expected`: Expected type string (e.g., `"number & ExclusiveMinimum<19>"`)
|
|
11
|
+
* - `value`: Actual value that failed validation
|
|
12
|
+
*
|
|
13
|
+
* @template T Expected type (for type safety)
|
|
14
|
+
*/
|
|
15
|
+
export class TypeGuardError<T = any> extends Error {
|
|
16
|
+
/**
|
|
17
|
+
* Name of the typia method that threw this error.
|
|
18
|
+
*
|
|
19
|
+
* E.g., `"typia.assert"`, `"typia.assertEquals"`, `"typia.assertGuard"`.
|
|
20
|
+
*/
|
|
21
|
+
public readonly method: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Property path where assertion failed.
|
|
25
|
+
*
|
|
26
|
+
* Uses dot notation for nested properties. `undefined` if error occurred at
|
|
27
|
+
* root level.
|
|
28
|
+
*
|
|
29
|
+
* E.g., `"input.age"`, `"input.profile.email"`, `"input[0].name"`.
|
|
30
|
+
*/
|
|
31
|
+
public readonly path: string | undefined;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* String representation of expected type.
|
|
35
|
+
*
|
|
36
|
+
* E.g., `"string"`, `"number & ExclusiveMinimum<19>"`, `"{ name: string; age:
|
|
37
|
+
* number }"`.
|
|
38
|
+
*/
|
|
39
|
+
public readonly expected: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Actual value that failed assertion.
|
|
43
|
+
*
|
|
44
|
+
* The raw value at the error path, useful for debugging.
|
|
45
|
+
*/
|
|
46
|
+
public readonly value: unknown;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Optional human-readable error description.
|
|
50
|
+
*
|
|
51
|
+
* Primarily for AI agent libraries or custom validation scenarios needing
|
|
52
|
+
* additional context. Standard assertions rely on `path`, `expected`, and
|
|
53
|
+
* `value` for error reporting.
|
|
54
|
+
*/
|
|
55
|
+
public readonly description?: string | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Phantom property for TypeScript type safety.
|
|
59
|
+
*
|
|
60
|
+
* Not used at runtime—exists only to preserve generic type `T` in the type
|
|
61
|
+
* system. Always `undefined`.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
protected readonly fake_expected_typed_value_?: T | undefined;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new TypeGuardError instance.
|
|
69
|
+
*
|
|
70
|
+
* @param props Error properties
|
|
71
|
+
*/
|
|
72
|
+
public constructor(props: TypeGuardError.IProps) {
|
|
73
|
+
// MESSAGE CONSTRUCTION
|
|
74
|
+
// Use custom message if provided, otherwise generate default format
|
|
75
|
+
super(
|
|
76
|
+
props.message ||
|
|
77
|
+
`Error on ${props.method}(): invalid type${
|
|
78
|
+
props.path ? ` on ${props.path}` : ""
|
|
79
|
+
}, expect to be ${props.expected}`,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// INHERITANCE POLYFILL
|
|
83
|
+
// Set up prototype for compatibility across different JavaScript environments
|
|
84
|
+
const proto = new.target.prototype;
|
|
85
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(this, proto);
|
|
86
|
+
else (this as any).__proto__ = proto;
|
|
87
|
+
|
|
88
|
+
// ASSIGN MEMBERS
|
|
89
|
+
this.method = props.method;
|
|
90
|
+
this.path = props.path;
|
|
91
|
+
this.expected = props.expected;
|
|
92
|
+
this.value = props.value;
|
|
93
|
+
if (props.description || props.value === undefined)
|
|
94
|
+
this.description =
|
|
95
|
+
props.description ??
|
|
96
|
+
[
|
|
97
|
+
"The value at this path is `undefined`.",
|
|
98
|
+
"",
|
|
99
|
+
`Please fill the \`${props.expected}\` typed value next time.`,
|
|
100
|
+
].join("\n");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export namespace TypeGuardError {
|
|
105
|
+
/** Properties for constructing a TypeGuardError. */
|
|
106
|
+
export interface IProps {
|
|
107
|
+
/**
|
|
108
|
+
* Name of the typia method that threw the error.
|
|
109
|
+
*
|
|
110
|
+
* E.g., `"typia.assert"`, `"typia.assertEquals"`.
|
|
111
|
+
*/
|
|
112
|
+
method: string;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Property path where assertion failed (optional).
|
|
116
|
+
*
|
|
117
|
+
* E.g., `"input.age"`, `"input.profile.email"`.
|
|
118
|
+
*/
|
|
119
|
+
path?: undefined | string;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* String representation of expected type.
|
|
123
|
+
*
|
|
124
|
+
* E.g., `"string"`, `"number & ExclusiveMinimum<19>"`.
|
|
125
|
+
*/
|
|
126
|
+
expected: string;
|
|
127
|
+
|
|
128
|
+
/** Actual value that failed assertion. */
|
|
129
|
+
value: unknown;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Optional human-readable error description.
|
|
133
|
+
*
|
|
134
|
+
* For AI agent libraries or custom validation needing additional context.
|
|
135
|
+
*/
|
|
136
|
+
description?: string;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Custom error message (optional).
|
|
140
|
+
*
|
|
141
|
+
* If not provided, a default message is generated from other properties.
|
|
142
|
+
*/
|
|
143
|
+
message?: undefined | string;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { TypiaGenerator } from "@typia/transform";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
|
|
4
|
-
import { ArgumentParser } from "./setup/ArgumentParser";
|
|
5
|
-
import { PackageManager } from "./setup/PackageManager";
|
|
6
|
-
|
|
7
|
-
export namespace TypiaGenerateWizard {
|
|
8
|
-
export async function generate(): Promise<void> {
|
|
9
|
-
console.log("----------------------------------------");
|
|
10
|
-
console.log(" Typia Generate Wizard");
|
|
11
|
-
console.log("----------------------------------------");
|
|
12
|
-
|
|
13
|
-
// LOAD PACKAGE.JSON INFO
|
|
14
|
-
const pack: PackageManager = await PackageManager.mount();
|
|
15
|
-
const options: IArguments = await ArgumentParser.parse(pack, inquiry);
|
|
16
|
-
await TypiaGenerator.build(options);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const inquiry: ArgumentParser.Inquiry<IArguments> = async (
|
|
20
|
-
_pack,
|
|
21
|
-
command,
|
|
22
|
-
prompt,
|
|
23
|
-
action,
|
|
24
|
-
) => {
|
|
25
|
-
// PREPARE ASSETS
|
|
26
|
-
command.option("--input [path]", "input directory");
|
|
27
|
-
command.option("--output [directory]", "output directory");
|
|
28
|
-
command.option("--project [project]", "tsconfig.json file location");
|
|
29
|
-
|
|
30
|
-
const questioned = { value: false };
|
|
31
|
-
|
|
32
|
-
const input = (name: string) => async (message: string) => {
|
|
33
|
-
const result = await prompt()({
|
|
34
|
-
type: "input",
|
|
35
|
-
name,
|
|
36
|
-
message,
|
|
37
|
-
default: "",
|
|
38
|
-
});
|
|
39
|
-
return result[name] as string;
|
|
40
|
-
};
|
|
41
|
-
const select =
|
|
42
|
-
(name: string) =>
|
|
43
|
-
(message: string) =>
|
|
44
|
-
async <Choice extends string>(choices: Choice[]): Promise<Choice> => {
|
|
45
|
-
questioned.value = true;
|
|
46
|
-
return (
|
|
47
|
-
await prompt()({
|
|
48
|
-
type: "list",
|
|
49
|
-
name: name,
|
|
50
|
-
message: message,
|
|
51
|
-
choices: choices,
|
|
52
|
-
})
|
|
53
|
-
)[name];
|
|
54
|
-
};
|
|
55
|
-
const configure = async (): Promise<string> => {
|
|
56
|
-
const files: string[] = await (
|
|
57
|
-
await fs.promises.readdir(process.cwd())
|
|
58
|
-
).filter(
|
|
59
|
-
(str) =>
|
|
60
|
-
str.substring(0, 8) === "tsconfig" &&
|
|
61
|
-
str.substring(str.length - 5) === ".json",
|
|
62
|
-
);
|
|
63
|
-
if (files.length === 0)
|
|
64
|
-
throw new URIError(`Unable to find "tsconfig.json" file.`);
|
|
65
|
-
else if (files.length === 1) return files[0]!;
|
|
66
|
-
return select("tsconfig")("TS Config File")(files);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return action(async (options) => {
|
|
70
|
-
options.input ??= await input("input")("input directory");
|
|
71
|
-
options.output ??= await input("output")("output directory");
|
|
72
|
-
options.project ??= await configure();
|
|
73
|
-
return options as IArguments;
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export interface IArguments {
|
|
78
|
-
input: string;
|
|
79
|
-
output: string;
|
|
80
|
-
project: string;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
1
|
+
import { TypiaGenerator } from "@typia/transform";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
import { ArgumentParser } from "./setup/ArgumentParser";
|
|
5
|
+
import { PackageManager } from "./setup/PackageManager";
|
|
6
|
+
|
|
7
|
+
export namespace TypiaGenerateWizard {
|
|
8
|
+
export async function generate(): Promise<void> {
|
|
9
|
+
console.log("----------------------------------------");
|
|
10
|
+
console.log(" Typia Generate Wizard");
|
|
11
|
+
console.log("----------------------------------------");
|
|
12
|
+
|
|
13
|
+
// LOAD PACKAGE.JSON INFO
|
|
14
|
+
const pack: PackageManager = await PackageManager.mount();
|
|
15
|
+
const options: IArguments = await ArgumentParser.parse(pack, inquiry);
|
|
16
|
+
await TypiaGenerator.build(options);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const inquiry: ArgumentParser.Inquiry<IArguments> = async (
|
|
20
|
+
_pack,
|
|
21
|
+
command,
|
|
22
|
+
prompt,
|
|
23
|
+
action,
|
|
24
|
+
) => {
|
|
25
|
+
// PREPARE ASSETS
|
|
26
|
+
command.option("--input [path]", "input directory");
|
|
27
|
+
command.option("--output [directory]", "output directory");
|
|
28
|
+
command.option("--project [project]", "tsconfig.json file location");
|
|
29
|
+
|
|
30
|
+
const questioned = { value: false };
|
|
31
|
+
|
|
32
|
+
const input = (name: string) => async (message: string) => {
|
|
33
|
+
const result = await prompt()({
|
|
34
|
+
type: "input",
|
|
35
|
+
name,
|
|
36
|
+
message,
|
|
37
|
+
default: "",
|
|
38
|
+
});
|
|
39
|
+
return result[name] as string;
|
|
40
|
+
};
|
|
41
|
+
const select =
|
|
42
|
+
(name: string) =>
|
|
43
|
+
(message: string) =>
|
|
44
|
+
async <Choice extends string>(choices: Choice[]): Promise<Choice> => {
|
|
45
|
+
questioned.value = true;
|
|
46
|
+
return (
|
|
47
|
+
await prompt()({
|
|
48
|
+
type: "list",
|
|
49
|
+
name: name,
|
|
50
|
+
message: message,
|
|
51
|
+
choices: choices,
|
|
52
|
+
})
|
|
53
|
+
)[name];
|
|
54
|
+
};
|
|
55
|
+
const configure = async (): Promise<string> => {
|
|
56
|
+
const files: string[] = await (
|
|
57
|
+
await fs.promises.readdir(process.cwd())
|
|
58
|
+
).filter(
|
|
59
|
+
(str) =>
|
|
60
|
+
str.substring(0, 8) === "tsconfig" &&
|
|
61
|
+
str.substring(str.length - 5) === ".json",
|
|
62
|
+
);
|
|
63
|
+
if (files.length === 0)
|
|
64
|
+
throw new URIError(`Unable to find "tsconfig.json" file.`);
|
|
65
|
+
else if (files.length === 1) return files[0]!;
|
|
66
|
+
return select("tsconfig")("TS Config File")(files);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return action(async (options) => {
|
|
70
|
+
options.input ??= await input("input")("input directory");
|
|
71
|
+
options.output ??= await input("output")("output directory");
|
|
72
|
+
options.project ??= await configure();
|
|
73
|
+
return options as IArguments;
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export interface IArguments {
|
|
78
|
+
input: string;
|
|
79
|
+
output: string;
|
|
80
|
+
project: string;
|
|
81
|
+
}
|
|
82
|
+
}
|