typia 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/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/lib/internal/_coerceLlmArguments.d.ts +2 -0
- package/lib/internal/_coerceLlmArguments.js +7 -0
- package/lib/internal/_coerceLlmArguments.js.map +1 -0
- package/lib/internal/_coerceLlmArguments.mjs +6 -0
- package/lib/internal/_coerceLlmArguments.mjs.map +1 -0
- package/lib/internal/_llmApplicationFinalize.js +1 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -0
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_parseLlmArguments.d.ts +2 -0
- package/lib/internal/_parseLlmArguments.js +7 -0
- package/lib/internal/_parseLlmArguments.js.map +1 -0
- package/lib/internal/_parseLlmArguments.mjs +6 -0
- package/lib/internal/_parseLlmArguments.mjs.map +1 -0
- package/lib/llm.d.ts +154 -1
- package/lib/llm.js +20 -0
- package/lib/llm.js.map +1 -1
- package/lib/llm.mjs +17 -1
- package/lib/llm.mjs.map +1 -1
- package/lib/re-exports.d.ts +1 -1
- package/lib/re-exports.js.map +1 -1
- 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 -0
- 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 -23
- 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 -0
- 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 -211
- 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 -32
- package/src/reflect.ts +75 -75
- package/src/transform.ts +5 -5
- package/src/transformers/NoTransformConfigurationError.ts +16 -16
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
-
import { IValidation } from "@typia/interface";
|
|
3
|
-
|
|
4
|
-
export const _createStandardSchema = <T>(
|
|
5
|
-
fn: (input: unknown) => IValidation<T>,
|
|
6
|
-
): ((input: unknown) => IValidation<T>) & StandardSchemaV1<T, T> =>
|
|
7
|
-
Object.assign(fn, {
|
|
8
|
-
"~standard": {
|
|
9
|
-
version: 1,
|
|
10
|
-
vendor: "typia",
|
|
11
|
-
validate: (input: unknown): StandardSchemaV1.Result<T> => {
|
|
12
|
-
const result = fn(input);
|
|
13
|
-
if (result.success) {
|
|
14
|
-
return {
|
|
15
|
-
value: result.data,
|
|
16
|
-
} satisfies StandardSchemaV1.SuccessResult<T>;
|
|
17
|
-
} else {
|
|
18
|
-
return {
|
|
19
|
-
issues: result.errors.map((error) => ({
|
|
20
|
-
message: `expected ${error.expected}, got ${error.value}`,
|
|
21
|
-
path: typiaPathToStandardSchemaPath(error.path),
|
|
22
|
-
})),
|
|
23
|
-
} satisfies StandardSchemaV1.FailureResult;
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
} satisfies StandardSchemaV1<T, T>);
|
|
28
|
-
|
|
29
|
-
enum PathParserState {
|
|
30
|
-
// Start of a new segment
|
|
31
|
-
// When the parser is in this state,
|
|
32
|
-
// the pointer must point `.` or `[` or equal to length of the path
|
|
33
|
-
Start,
|
|
34
|
-
// Parsing a property key (`.hoge`)
|
|
35
|
-
Property,
|
|
36
|
-
// Parsing a string key (`["fuga"]`)
|
|
37
|
-
StringKey,
|
|
38
|
-
// Parsing a number key (`[42]`)
|
|
39
|
-
NumberKey,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const typiaPathToStandardSchemaPath = (
|
|
43
|
-
path: string,
|
|
44
|
-
): ReadonlyArray<StandardSchemaV1.PathSegment> => {
|
|
45
|
-
if (!path.startsWith("$input")) {
|
|
46
|
-
throw new Error(`Invalid path: ${JSON.stringify(path)}`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const segments: StandardSchemaV1.PathSegment[] = [];
|
|
50
|
-
let currentSegment = "";
|
|
51
|
-
let state: PathParserState = PathParserState.Start;
|
|
52
|
-
let index = "$input".length - 1;
|
|
53
|
-
while (index < path.length - 1) {
|
|
54
|
-
index++;
|
|
55
|
-
const char = path[index];
|
|
56
|
-
|
|
57
|
-
if (state === PathParserState.Property) {
|
|
58
|
-
if (char === "." || char === "[") {
|
|
59
|
-
// End of property
|
|
60
|
-
segments.push({
|
|
61
|
-
key: currentSegment,
|
|
62
|
-
});
|
|
63
|
-
state = PathParserState.Start;
|
|
64
|
-
} else if (index === path.length - 1) {
|
|
65
|
-
// End of path
|
|
66
|
-
currentSegment += char;
|
|
67
|
-
segments.push({
|
|
68
|
-
key: currentSegment,
|
|
69
|
-
});
|
|
70
|
-
index++;
|
|
71
|
-
state = PathParserState.Start;
|
|
72
|
-
} else {
|
|
73
|
-
currentSegment += char;
|
|
74
|
-
}
|
|
75
|
-
} else if (state === PathParserState.StringKey) {
|
|
76
|
-
if (char === '"') {
|
|
77
|
-
// End of string key
|
|
78
|
-
segments.push({
|
|
79
|
-
key: JSON.parse(currentSegment + char),
|
|
80
|
-
});
|
|
81
|
-
// Skip `"` and `]`
|
|
82
|
-
index += 2;
|
|
83
|
-
state = PathParserState.Start;
|
|
84
|
-
} else if (char === "\\") {
|
|
85
|
-
// Skip the next character from parsing
|
|
86
|
-
currentSegment += path[index];
|
|
87
|
-
index++;
|
|
88
|
-
currentSegment += path[index];
|
|
89
|
-
} else {
|
|
90
|
-
currentSegment += char;
|
|
91
|
-
}
|
|
92
|
-
} else if (state === PathParserState.NumberKey) {
|
|
93
|
-
if (char === "]") {
|
|
94
|
-
// End of number key
|
|
95
|
-
segments.push({
|
|
96
|
-
key: Number.parseInt(currentSegment),
|
|
97
|
-
});
|
|
98
|
-
index++;
|
|
99
|
-
state = PathParserState.Start;
|
|
100
|
-
} else {
|
|
101
|
-
currentSegment += char;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (state === PathParserState.Start && index < path.length - 1) {
|
|
106
|
-
const newChar = path[index];
|
|
107
|
-
currentSegment = "";
|
|
108
|
-
if (newChar === "[") {
|
|
109
|
-
if (path[index + 1] === '"') {
|
|
110
|
-
// Start of string key
|
|
111
|
-
// NOTE: Typia uses JSON.stringify for this kind of keys, so `'` will not used as a string delimiter
|
|
112
|
-
state = PathParserState.StringKey;
|
|
113
|
-
index++;
|
|
114
|
-
currentSegment = '"';
|
|
115
|
-
} else {
|
|
116
|
-
// Start of number key
|
|
117
|
-
state = PathParserState.NumberKey;
|
|
118
|
-
}
|
|
119
|
-
} else if (newChar === ".") {
|
|
120
|
-
// Start of property
|
|
121
|
-
state = PathParserState.Property;
|
|
122
|
-
} else {
|
|
123
|
-
throw new Error("Unreachable: pointer points invalid character");
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (state !== PathParserState.Start) {
|
|
129
|
-
throw new Error(`Failed to parse path: ${JSON.stringify(path)}`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return segments;
|
|
133
|
-
};
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
import { IValidation } from "@typia/interface";
|
|
3
|
+
|
|
4
|
+
export const _createStandardSchema = <T>(
|
|
5
|
+
fn: (input: unknown) => IValidation<T>,
|
|
6
|
+
): ((input: unknown) => IValidation<T>) & StandardSchemaV1<T, T> =>
|
|
7
|
+
Object.assign(fn, {
|
|
8
|
+
"~standard": {
|
|
9
|
+
version: 1,
|
|
10
|
+
vendor: "typia",
|
|
11
|
+
validate: (input: unknown): StandardSchemaV1.Result<T> => {
|
|
12
|
+
const result = fn(input);
|
|
13
|
+
if (result.success) {
|
|
14
|
+
return {
|
|
15
|
+
value: result.data,
|
|
16
|
+
} satisfies StandardSchemaV1.SuccessResult<T>;
|
|
17
|
+
} else {
|
|
18
|
+
return {
|
|
19
|
+
issues: result.errors.map((error) => ({
|
|
20
|
+
message: `expected ${error.expected}, got ${error.value}`,
|
|
21
|
+
path: typiaPathToStandardSchemaPath(error.path),
|
|
22
|
+
})),
|
|
23
|
+
} satisfies StandardSchemaV1.FailureResult;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
} satisfies StandardSchemaV1<T, T>);
|
|
28
|
+
|
|
29
|
+
enum PathParserState {
|
|
30
|
+
// Start of a new segment
|
|
31
|
+
// When the parser is in this state,
|
|
32
|
+
// the pointer must point `.` or `[` or equal to length of the path
|
|
33
|
+
Start,
|
|
34
|
+
// Parsing a property key (`.hoge`)
|
|
35
|
+
Property,
|
|
36
|
+
// Parsing a string key (`["fuga"]`)
|
|
37
|
+
StringKey,
|
|
38
|
+
// Parsing a number key (`[42]`)
|
|
39
|
+
NumberKey,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const typiaPathToStandardSchemaPath = (
|
|
43
|
+
path: string,
|
|
44
|
+
): ReadonlyArray<StandardSchemaV1.PathSegment> => {
|
|
45
|
+
if (!path.startsWith("$input")) {
|
|
46
|
+
throw new Error(`Invalid path: ${JSON.stringify(path)}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const segments: StandardSchemaV1.PathSegment[] = [];
|
|
50
|
+
let currentSegment = "";
|
|
51
|
+
let state: PathParserState = PathParserState.Start;
|
|
52
|
+
let index = "$input".length - 1;
|
|
53
|
+
while (index < path.length - 1) {
|
|
54
|
+
index++;
|
|
55
|
+
const char = path[index];
|
|
56
|
+
|
|
57
|
+
if (state === PathParserState.Property) {
|
|
58
|
+
if (char === "." || char === "[") {
|
|
59
|
+
// End of property
|
|
60
|
+
segments.push({
|
|
61
|
+
key: currentSegment,
|
|
62
|
+
});
|
|
63
|
+
state = PathParserState.Start;
|
|
64
|
+
} else if (index === path.length - 1) {
|
|
65
|
+
// End of path
|
|
66
|
+
currentSegment += char;
|
|
67
|
+
segments.push({
|
|
68
|
+
key: currentSegment,
|
|
69
|
+
});
|
|
70
|
+
index++;
|
|
71
|
+
state = PathParserState.Start;
|
|
72
|
+
} else {
|
|
73
|
+
currentSegment += char;
|
|
74
|
+
}
|
|
75
|
+
} else if (state === PathParserState.StringKey) {
|
|
76
|
+
if (char === '"') {
|
|
77
|
+
// End of string key
|
|
78
|
+
segments.push({
|
|
79
|
+
key: JSON.parse(currentSegment + char),
|
|
80
|
+
});
|
|
81
|
+
// Skip `"` and `]`
|
|
82
|
+
index += 2;
|
|
83
|
+
state = PathParserState.Start;
|
|
84
|
+
} else if (char === "\\") {
|
|
85
|
+
// Skip the next character from parsing
|
|
86
|
+
currentSegment += path[index];
|
|
87
|
+
index++;
|
|
88
|
+
currentSegment += path[index];
|
|
89
|
+
} else {
|
|
90
|
+
currentSegment += char;
|
|
91
|
+
}
|
|
92
|
+
} else if (state === PathParserState.NumberKey) {
|
|
93
|
+
if (char === "]") {
|
|
94
|
+
// End of number key
|
|
95
|
+
segments.push({
|
|
96
|
+
key: Number.parseInt(currentSegment),
|
|
97
|
+
});
|
|
98
|
+
index++;
|
|
99
|
+
state = PathParserState.Start;
|
|
100
|
+
} else {
|
|
101
|
+
currentSegment += char;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (state === PathParserState.Start && index < path.length - 1) {
|
|
106
|
+
const newChar = path[index];
|
|
107
|
+
currentSegment = "";
|
|
108
|
+
if (newChar === "[") {
|
|
109
|
+
if (path[index + 1] === '"') {
|
|
110
|
+
// Start of string key
|
|
111
|
+
// NOTE: Typia uses JSON.stringify for this kind of keys, so `'` will not used as a string delimiter
|
|
112
|
+
state = PathParserState.StringKey;
|
|
113
|
+
index++;
|
|
114
|
+
currentSegment = '"';
|
|
115
|
+
} else {
|
|
116
|
+
// Start of number key
|
|
117
|
+
state = PathParserState.NumberKey;
|
|
118
|
+
}
|
|
119
|
+
} else if (newChar === ".") {
|
|
120
|
+
// Start of property
|
|
121
|
+
state = PathParserState.Property;
|
|
122
|
+
} else {
|
|
123
|
+
throw new Error("Unreachable: pointer points invalid character");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (state !== PathParserState.Start) {
|
|
129
|
+
throw new Error(`Failed to parse path: ${JSON.stringify(path)}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return segments;
|
|
133
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
-
|
|
3
|
-
export const _functionalTypeGuardErrorFactory = (p: TypeGuardError.IProps) =>
|
|
4
|
-
new TypeGuardError(p);
|
|
1
|
+
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
+
|
|
3
|
+
export const _functionalTypeGuardErrorFactory = (p: TypeGuardError.IProps) =>
|
|
4
|
+
new TypeGuardError(p);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const _httpFormDataReadArray = (
|
|
2
|
-
input: any[],
|
|
3
|
-
alternative: null | undefined,
|
|
4
|
-
) => (input.length ? input : alternative);
|
|
1
|
+
export const _httpFormDataReadArray = (
|
|
2
|
+
input: any[],
|
|
3
|
+
alternative: null | undefined,
|
|
4
|
+
) => (input.length ? input : alternative);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export const _httpFormDataReadBigint = (
|
|
2
|
-
input: string | File | null,
|
|
3
|
-
): bigint | null | undefined =>
|
|
4
|
-
input instanceof File
|
|
5
|
-
? (input as any)
|
|
6
|
-
: !!input?.length
|
|
7
|
-
? input === "null"
|
|
8
|
-
? null
|
|
9
|
-
: (toBigint(input) as any)
|
|
10
|
-
: undefined;
|
|
11
|
-
|
|
12
|
-
const toBigint = (str: string): bigint | string => {
|
|
13
|
-
try {
|
|
14
|
-
return BigInt(str);
|
|
15
|
-
} catch {
|
|
16
|
-
return str;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
1
|
+
export const _httpFormDataReadBigint = (
|
|
2
|
+
input: string | File | null,
|
|
3
|
+
): bigint | null | undefined =>
|
|
4
|
+
input instanceof File
|
|
5
|
+
? (input as any)
|
|
6
|
+
: !!input?.length
|
|
7
|
+
? input === "null"
|
|
8
|
+
? null
|
|
9
|
+
: (toBigint(input) as any)
|
|
10
|
+
: undefined;
|
|
11
|
+
|
|
12
|
+
const toBigint = (str: string): bigint | string => {
|
|
13
|
+
try {
|
|
14
|
+
return BigInt(str);
|
|
15
|
+
} catch {
|
|
16
|
+
return str;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const _httpFormDataReadBlob = (
|
|
2
|
-
input: string | Blob | null,
|
|
3
|
-
): Blob | null | undefined =>
|
|
4
|
-
input instanceof Blob
|
|
5
|
-
? input
|
|
6
|
-
: input === null
|
|
7
|
-
? undefined
|
|
8
|
-
: input === "null"
|
|
9
|
-
? null
|
|
10
|
-
: (input as any);
|
|
1
|
+
export const _httpFormDataReadBlob = (
|
|
2
|
+
input: string | Blob | null,
|
|
3
|
+
): Blob | null | undefined =>
|
|
4
|
+
input instanceof Blob
|
|
5
|
+
? input
|
|
6
|
+
: input === null
|
|
7
|
+
? undefined
|
|
8
|
+
: input === "null"
|
|
9
|
+
? null
|
|
10
|
+
: (input as any);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export const _httpFormDataReadBoolean = (
|
|
2
|
-
input: string | File | null,
|
|
3
|
-
): boolean | null | undefined =>
|
|
4
|
-
input instanceof File
|
|
5
|
-
? (input as any)
|
|
6
|
-
: input === null
|
|
7
|
-
? undefined
|
|
8
|
-
: input === "null"
|
|
9
|
-
? null
|
|
10
|
-
: input.length === 0
|
|
11
|
-
? true
|
|
12
|
-
: input === "true" || input === "1"
|
|
13
|
-
? true
|
|
14
|
-
: input === "false" || input === "0"
|
|
15
|
-
? false
|
|
16
|
-
: (input as any); // wrong type
|
|
1
|
+
export const _httpFormDataReadBoolean = (
|
|
2
|
+
input: string | File | null,
|
|
3
|
+
): boolean | null | undefined =>
|
|
4
|
+
input instanceof File
|
|
5
|
+
? (input as any)
|
|
6
|
+
: input === null
|
|
7
|
+
? undefined
|
|
8
|
+
: input === "null"
|
|
9
|
+
? null
|
|
10
|
+
: input.length === 0
|
|
11
|
+
? true
|
|
12
|
+
: input === "true" || input === "1"
|
|
13
|
+
? true
|
|
14
|
+
: input === "false" || input === "0"
|
|
15
|
+
? false
|
|
16
|
+
: (input as any); // wrong type
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const _httpFormDataReadFile = (
|
|
2
|
-
input: string | File | null,
|
|
3
|
-
): File | null | undefined =>
|
|
4
|
-
input instanceof File
|
|
5
|
-
? input
|
|
6
|
-
: input === null
|
|
7
|
-
? undefined
|
|
8
|
-
: input === "null"
|
|
9
|
-
? null
|
|
10
|
-
: (input as any);
|
|
1
|
+
export const _httpFormDataReadFile = (
|
|
2
|
+
input: string | File | null,
|
|
3
|
+
): File | null | undefined =>
|
|
4
|
+
input instanceof File
|
|
5
|
+
? input
|
|
6
|
+
: input === null
|
|
7
|
+
? undefined
|
|
8
|
+
: input === "null"
|
|
9
|
+
? null
|
|
10
|
+
: (input as any);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export const _httpFormDataReadNumber = (
|
|
2
|
-
input: string | File | null,
|
|
3
|
-
): number | null | undefined =>
|
|
4
|
-
input instanceof File
|
|
5
|
-
? (input as any)
|
|
6
|
-
: !!input?.length
|
|
7
|
-
? input === "null"
|
|
8
|
-
? null
|
|
9
|
-
: (toNumber(input) as any)
|
|
10
|
-
: undefined;
|
|
11
|
-
|
|
12
|
-
const toNumber = (str: string): number | string => {
|
|
13
|
-
const value: number = Number(str);
|
|
14
|
-
return isNaN(value) ? str : value;
|
|
15
|
-
};
|
|
1
|
+
export const _httpFormDataReadNumber = (
|
|
2
|
+
input: string | File | null,
|
|
3
|
+
): number | null | undefined =>
|
|
4
|
+
input instanceof File
|
|
5
|
+
? (input as any)
|
|
6
|
+
: !!input?.length
|
|
7
|
+
? input === "null"
|
|
8
|
+
? null
|
|
9
|
+
: (toNumber(input) as any)
|
|
10
|
+
: undefined;
|
|
11
|
+
|
|
12
|
+
const toNumber = (str: string): number | string => {
|
|
13
|
+
const value: number = Number(str);
|
|
14
|
+
return isNaN(value) ? str : value;
|
|
15
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const _httpFormDataReadString = (
|
|
2
|
-
input: string | File | null,
|
|
3
|
-
): string | null | undefined =>
|
|
4
|
-
input instanceof File
|
|
5
|
-
? (input as any)
|
|
6
|
-
: input === null
|
|
7
|
-
? undefined
|
|
8
|
-
: input === "null"
|
|
9
|
-
? null
|
|
10
|
-
: input;
|
|
1
|
+
export const _httpFormDataReadString = (
|
|
2
|
+
input: string | File | null,
|
|
3
|
+
): string | null | undefined =>
|
|
4
|
+
input instanceof File
|
|
5
|
+
? (input as any)
|
|
6
|
+
: input === null
|
|
7
|
+
? undefined
|
|
8
|
+
: input === "null"
|
|
9
|
+
? null
|
|
10
|
+
: input;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const _httpHeaderReadBigint = (value: string | undefined) =>
|
|
2
|
-
value !== undefined ? toBigint(value) : undefined;
|
|
3
|
-
|
|
4
|
-
const toBigint = (str: string): bigint | string => {
|
|
5
|
-
try {
|
|
6
|
-
return BigInt(str);
|
|
7
|
-
} catch {
|
|
8
|
-
return str;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
1
|
+
export const _httpHeaderReadBigint = (value: string | undefined) =>
|
|
2
|
+
value !== undefined ? toBigint(value) : undefined;
|
|
3
|
+
|
|
4
|
+
const toBigint = (str: string): bigint | string => {
|
|
5
|
+
try {
|
|
6
|
+
return BigInt(str);
|
|
7
|
+
} catch {
|
|
8
|
+
return str;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export const _httpHeaderReadBoolean = (value: string | undefined) =>
|
|
2
|
-
value !== undefined
|
|
3
|
-
? value === "true"
|
|
4
|
-
? true
|
|
5
|
-
: value === "false"
|
|
6
|
-
? false
|
|
7
|
-
: value
|
|
8
|
-
: undefined;
|
|
1
|
+
export const _httpHeaderReadBoolean = (value: string | undefined) =>
|
|
2
|
+
value !== undefined
|
|
3
|
+
? value === "true"
|
|
4
|
+
? true
|
|
5
|
+
: value === "false"
|
|
6
|
+
? false
|
|
7
|
+
: value
|
|
8
|
+
: undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const _httpHeaderReadNumber = (value: string | undefined) =>
|
|
2
|
-
value !== undefined ? toNumber(value) : undefined;
|
|
3
|
-
|
|
4
|
-
const toNumber = (str: string): number | string => {
|
|
5
|
-
const value: number = Number(str);
|
|
6
|
-
return isNaN(value) ? str : value;
|
|
7
|
-
};
|
|
1
|
+
export const _httpHeaderReadNumber = (value: string | undefined) =>
|
|
2
|
+
value !== undefined ? toNumber(value) : undefined;
|
|
3
|
+
|
|
4
|
+
const toNumber = (str: string): number | string => {
|
|
5
|
+
const value: number = Number(str);
|
|
6
|
+
return isNaN(value) ? str : value;
|
|
7
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const _httpParameterReadBigint = (value: string) =>
|
|
2
|
-
value !== "null" ? toBigint(value) : null;
|
|
3
|
-
|
|
4
|
-
const toBigint = (str: string): bigint | string => {
|
|
5
|
-
try {
|
|
6
|
-
return BigInt(str);
|
|
7
|
-
} catch {
|
|
8
|
-
return str;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
1
|
+
export const _httpParameterReadBigint = (value: string) =>
|
|
2
|
+
value !== "null" ? toBigint(value) : null;
|
|
3
|
+
|
|
4
|
+
const toBigint = (str: string): bigint | string => {
|
|
5
|
+
try {
|
|
6
|
+
return BigInt(str);
|
|
7
|
+
} catch {
|
|
8
|
+
return str;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export const _httpParameterReadBoolean = (value: string) =>
|
|
2
|
-
value !== "null"
|
|
3
|
-
? value === "true" || value === "1"
|
|
4
|
-
? true
|
|
5
|
-
: value === "false" || value === "0"
|
|
6
|
-
? false
|
|
7
|
-
: value
|
|
8
|
-
: null;
|
|
1
|
+
export const _httpParameterReadBoolean = (value: string) =>
|
|
2
|
+
value !== "null"
|
|
3
|
+
? value === "true" || value === "1"
|
|
4
|
+
? true
|
|
5
|
+
: value === "false" || value === "0"
|
|
6
|
+
? false
|
|
7
|
+
: value
|
|
8
|
+
: null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const _httpParameterReadNumber = (value: string) =>
|
|
2
|
-
value !== "null" ? toNumber(value) : null;
|
|
3
|
-
|
|
4
|
-
const toNumber = (str: string): number | string => {
|
|
5
|
-
const value: number = Number(str);
|
|
6
|
-
return isNaN(value) ? str : value;
|
|
7
|
-
};
|
|
1
|
+
export const _httpParameterReadNumber = (value: string) =>
|
|
2
|
+
value !== "null" ? toNumber(value) : null;
|
|
3
|
+
|
|
4
|
+
const toNumber = (str: string): number | string => {
|
|
5
|
+
const value: number = Number(str);
|
|
6
|
+
return isNaN(value) ? str : value;
|
|
7
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const _httpParameterReadString = (value: string) =>
|
|
2
|
-
value !== "null" ? value : null;
|
|
1
|
+
export const _httpParameterReadString = (value: string) =>
|
|
2
|
+
value !== "null" ? value : null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { IReadableURLSearchParams } from "@typia/interface";
|
|
2
|
-
|
|
3
|
-
export const _httpQueryParseURLSearchParams = (
|
|
4
|
-
input: string | IReadableURLSearchParams,
|
|
5
|
-
): IReadableURLSearchParams => {
|
|
6
|
-
if (typeof input === "string") {
|
|
7
|
-
const index: number = input.indexOf("?");
|
|
8
|
-
input = index === -1 ? "" : input.substring(index + 1);
|
|
9
|
-
return new URLSearchParams(input);
|
|
10
|
-
}
|
|
11
|
-
return input;
|
|
12
|
-
};
|
|
1
|
+
import { IReadableURLSearchParams } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
export const _httpQueryParseURLSearchParams = (
|
|
4
|
+
input: string | IReadableURLSearchParams,
|
|
5
|
+
): IReadableURLSearchParams => {
|
|
6
|
+
if (typeof input === "string") {
|
|
7
|
+
const index: number = input.indexOf("?");
|
|
8
|
+
input = index === -1 ? "" : input.substring(index + 1);
|
|
9
|
+
return new URLSearchParams(input);
|
|
10
|
+
}
|
|
11
|
+
return input;
|
|
12
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const _httpQueryReadArray = (
|
|
2
|
-
input: any[],
|
|
3
|
-
alternative: null | undefined,
|
|
4
|
-
) => (input.length ? input : alternative);
|
|
1
|
+
export const _httpQueryReadArray = (
|
|
2
|
+
input: any[],
|
|
3
|
+
alternative: null | undefined,
|
|
4
|
+
) => (input.length ? input : alternative);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export const _httpQueryReadBigint = (
|
|
2
|
-
str: string | null,
|
|
3
|
-
): bigint | null | undefined =>
|
|
4
|
-
!!str?.length ? (str === "null" ? null : (toBigint(str) as any)) : undefined;
|
|
5
|
-
|
|
6
|
-
const toBigint = (str: string): bigint | string => {
|
|
7
|
-
try {
|
|
8
|
-
return BigInt(str);
|
|
9
|
-
} catch {
|
|
10
|
-
return str;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
1
|
+
export const _httpQueryReadBigint = (
|
|
2
|
+
str: string | null,
|
|
3
|
+
): bigint | null | undefined =>
|
|
4
|
+
!!str?.length ? (str === "null" ? null : (toBigint(str) as any)) : undefined;
|
|
5
|
+
|
|
6
|
+
const toBigint = (str: string): bigint | string => {
|
|
7
|
+
try {
|
|
8
|
+
return BigInt(str);
|
|
9
|
+
} catch {
|
|
10
|
+
return str;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export const _httpQueryReadBoolean = (
|
|
2
|
-
str: string | null,
|
|
3
|
-
): boolean | null | undefined =>
|
|
4
|
-
str === null
|
|
5
|
-
? undefined
|
|
6
|
-
: str === "null"
|
|
7
|
-
? null
|
|
8
|
-
: str.length === 0
|
|
9
|
-
? true
|
|
10
|
-
: str === "true" || str === "1"
|
|
11
|
-
? true
|
|
12
|
-
: str === "false" || str === "0"
|
|
13
|
-
? false
|
|
14
|
-
: (str as any); // wrong type
|
|
1
|
+
export const _httpQueryReadBoolean = (
|
|
2
|
+
str: string | null,
|
|
3
|
+
): boolean | null | undefined =>
|
|
4
|
+
str === null
|
|
5
|
+
? undefined
|
|
6
|
+
: str === "null"
|
|
7
|
+
? null
|
|
8
|
+
: str.length === 0
|
|
9
|
+
? true
|
|
10
|
+
: str === "true" || str === "1"
|
|
11
|
+
? true
|
|
12
|
+
: str === "false" || str === "0"
|
|
13
|
+
? false
|
|
14
|
+
: (str as any); // wrong type
|