typia 7.0.0-dev.20241009-2 → 7.0.0-dev.20241010
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/factories/JsonMetadataFactory.d.ts +5 -1
- package/lib/factories/JsonMetadataFactory.js +4 -1
- package/lib/factories/JsonMetadataFactory.js.map +1 -1
- package/lib/internal/{$httpFormDataReadArray.js → $httpFormdataReadArray.js} +1 -1
- package/lib/internal/$httpFormdataReadArray.js.map +1 -0
- package/lib/programmers/CheckerProgrammer.js +4 -1
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +4 -1
- package/lib/programmers/FeatureProgrammer.js +2 -2
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +12 -9
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/TypiaProgrammer.js +4 -1
- package/lib/programmers/TypiaProgrammer.js.map +1 -1
- package/lib/programmers/internal/prune_object_properties.js +3 -2
- package/lib/programmers/internal/prune_object_properties.js.map +1 -1
- package/lib/programmers/json/JsonAssertParseProgrammer.js +2 -2
- package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +4 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js +4 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js +4 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
- package/lib/transformers/FileTransformer.js +0 -6
- package/lib/transformers/FileTransformer.js.map +1 -1
- package/lib/transformers/ImportTransformer.d.ts +4 -1
- package/lib/transformers/ImportTransformer.js +34 -30
- package/lib/transformers/ImportTransformer.js.map +1 -1
- package/package.json +1 -1
- package/src/IRandomGenerator.ts +49 -49
- package/src/factories/ExpressionFactory.ts +164 -164
- package/src/factories/JsonMetadataFactory.ts +25 -15
- package/src/factories/LiteralFactory.ts +50 -50
- package/src/factories/MetadataCommentTagFactory.ts +650 -650
- package/src/functional.ts +750 -750
- package/src/http.ts +1042 -1042
- package/src/internal/$IProtobufWriter.ts +18 -18
- package/src/internal/$ProtobufReader.ts +194 -194
- package/src/internal/$ProtobufSizer.ts +151 -151
- package/src/internal/$ProtobufWriter.ts +145 -145
- package/src/internal/$accessExpressionAsString.ts +46 -46
- package/src/internal/$assertGuard.ts +13 -13
- package/src/internal/$functionalTypeGuardErrorFactory.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/{$httpFormDataReadArray.ts → $httpFormdataReadArray.ts} +4 -4
- package/src/internal/$httpHeaderReadBigint.ts +10 -10
- package/src/internal/$httpHeaderReadBoolean.ts +8 -8
- package/src/internal/$httpHeaderReadNumber.ts +7 -7
- package/src/internal/$httpParameterBigint.ts +10 -10
- package/src/internal/$httpParameterBoolean.ts +8 -8
- package/src/internal/$httpParameterNumber.ts +7 -7
- package/src/internal/$httpParameterString.ts +2 -2
- package/src/internal/$httpQueryParseURLSearchParams.ts +10 -10
- 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/$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 +18 -18
- package/src/internal/$miscCloneAny.ts +48 -48
- 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/$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 +47 -47
- package/src/internal/$randomNumber.ts +74 -74
- 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 +13 -13
- package/src/internal/private/$__notationCapitalize.ts +2 -2
- package/src/internal/private/$__notationUnsnake.ts +24 -24
- package/src/json.ts +651 -651
- package/src/llm.ts +178 -178
- package/src/misc.ts +658 -658
- package/src/module.ts +933 -933
- package/src/notations.ts +827 -827
- package/src/programmers/CheckerProgrammer.ts +4 -1
- package/src/programmers/FeatureProgrammer.ts +619 -616
- package/src/programmers/RandomProgrammer.ts +24 -16
- package/src/programmers/TypiaProgrammer.ts +4 -1
- package/src/programmers/functional/FunctionalAssertFunctionProgrammer.ts +153 -153
- package/src/programmers/functional/FunctionalAssertParametersProgrammer.ts +125 -125
- package/src/programmers/functional/FunctionalAssertReturnProgrammer.ts +115 -115
- package/src/programmers/functional/FunctionalValidateFunctionProgrammer.ts +119 -119
- package/src/programmers/functional/FunctionalValidateParametersProgrammer.ts +274 -274
- package/src/programmers/functional/FunctionalValidateReturnProgrammer.ts +135 -135
- package/src/programmers/helpers/FunctionProgrammer.ts +67 -67
- package/src/programmers/helpers/RandomJoiner.ts +168 -168
- package/src/programmers/helpers/StringifyJoinder.ts +115 -115
- package/src/programmers/helpers/disable_function_programmer_declare.ts +32 -32
- package/src/programmers/internal/check_dynamic_key.ts +201 -201
- package/src/programmers/internal/check_dynamic_properties.ts +208 -208
- package/src/programmers/internal/check_object.ts +75 -75
- package/src/programmers/internal/feature_object_entries.ts +61 -61
- package/src/programmers/internal/prune_object_properties.ts +71 -63
- package/src/programmers/json/JsonAssertParseProgrammer.ts +14 -11
- package/src/programmers/llm/LlmApplicationProgrammer.ts +235 -235
- package/src/programmers/llm/LlmSchemaProgrammer.ts +51 -51
- package/src/programmers/misc/MiscCloneProgrammer.ts +4 -1
- package/src/programmers/misc/MiscPruneProgrammer.ts +4 -1
- package/src/programmers/notations/NotationGeneralProgrammer.ts +4 -1
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +1 -1
- package/src/protobuf.ts +868 -868
- package/src/reflect.ts +57 -57
- package/src/transformers/FileTransformer.ts +0 -6
- package/src/transformers/ImportTransformer.ts +59 -44
- package/src/utils/NamingConvention.ts +94 -94
- package/src/utils/StringUtil.ts +16 -16
- package/lib/internal/$httpFormDataReadArray.js.map +0 -1
- /package/lib/internal/{$httpFormDataReadArray.d.ts → $httpFormdataReadArray.d.ts} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
-
|
|
3
|
-
export const $assertGuard = (
|
|
4
|
-
exceptionable: boolean,
|
|
5
|
-
props: TypeGuardError.IProps,
|
|
6
|
-
factory?: (props: TypeGuardError.IProps) => Error,
|
|
7
|
-
): false => {
|
|
8
|
-
if (exceptionable === true) {
|
|
9
|
-
if (factory) throw factory(props);
|
|
10
|
-
else throw new TypeGuardError(props);
|
|
11
|
-
}
|
|
12
|
-
return false;
|
|
13
|
-
};
|
|
1
|
+
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
+
|
|
3
|
+
export const $assertGuard = (
|
|
4
|
+
exceptionable: boolean,
|
|
5
|
+
props: TypeGuardError.IProps,
|
|
6
|
+
factory?: (props: TypeGuardError.IProps) => Error,
|
|
7
|
+
): false => {
|
|
8
|
+
if (exceptionable === true) {
|
|
9
|
+
if (factory) throw factory(props);
|
|
10
|
+
else throw new TypeGuardError(props);
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
};
|
|
@@ -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,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,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,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 $httpParameterBigint = (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 $httpParameterBigint = (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 $httpParameterBoolean = (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 $httpParameterBoolean = (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 $httpParameterNumber = (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 $httpParameterNumber = (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 $httpParameterString = (value: string) =>
|
|
2
|
-
value !== "null" ? value : null;
|
|
1
|
+
export const $httpParameterString = (value: string) =>
|
|
2
|
+
value !== "null" ? value : null;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const $httpQueryParseURLSearchParams = (
|
|
2
|
-
input: string | URLSearchParams,
|
|
3
|
-
) => {
|
|
4
|
-
if (typeof input === "string") {
|
|
5
|
-
const index: number = input.indexOf("?");
|
|
6
|
-
input = index === -1 ? "" : input.substring(index + 1);
|
|
7
|
-
return new URLSearchParams(input);
|
|
8
|
-
}
|
|
9
|
-
return input;
|
|
10
|
-
};
|
|
1
|
+
export const $httpQueryParseURLSearchParams = (
|
|
2
|
+
input: string | URLSearchParams,
|
|
3
|
+
) => {
|
|
4
|
+
if (typeof input === "string") {
|
|
5
|
+
const index: number = input.indexOf("?");
|
|
6
|
+
input = index === -1 ? "" : input.substring(index + 1);
|
|
7
|
+
return new URLSearchParams(input);
|
|
8
|
+
}
|
|
9
|
+
return input;
|
|
10
|
+
};
|
|
@@ -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
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export const $httpQueryReadNumber = (
|
|
2
|
-
str: string | null,
|
|
3
|
-
): number | null | undefined =>
|
|
4
|
-
!!str?.length ? (str === "null" ? null : (toNumber(str) as any)) : undefined;
|
|
5
|
-
|
|
6
|
-
const toNumber = (str: string): number | string => {
|
|
7
|
-
const value: number = Number(str);
|
|
8
|
-
return isNaN(value) ? str : value;
|
|
9
|
-
};
|
|
1
|
+
export const $httpQueryReadNumber = (
|
|
2
|
+
str: string | null,
|
|
3
|
+
): number | null | undefined =>
|
|
4
|
+
!!str?.length ? (str === "null" ? null : (toNumber(str) as any)) : undefined;
|
|
5
|
+
|
|
6
|
+
const toNumber = (str: string): number | string => {
|
|
7
|
+
const value: number = Number(str);
|
|
8
|
+
return isNaN(value) ? str : value;
|
|
9
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const $httpQueryReadString = (
|
|
2
|
-
str: string | null,
|
|
3
|
-
): string | null | undefined =>
|
|
4
|
-
str === null ? undefined : str === "null" ? null : str;
|
|
1
|
+
export const $httpQueryReadString = (
|
|
2
|
+
str: string | null,
|
|
3
|
+
): string | null | undefined =>
|
|
4
|
+
str === null ? undefined : str === "null" ? null : str;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const $isBetween = (value: number, minimum: number, maximum: number) =>
|
|
2
|
-
minimum <= value && value <= maximum;
|
|
1
|
+
export const $isBetween = (value: number, minimum: number, maximum: number) =>
|
|
2
|
+
minimum <= value && value <= maximum;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export const $isBigintString = (str: string): boolean => {
|
|
2
|
-
try {
|
|
3
|
-
BigInt(str);
|
|
4
|
-
return true;
|
|
5
|
-
} catch {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
1
|
+
export const $isBigintString = (str: string): boolean => {
|
|
2
|
+
try {
|
|
3
|
+
BigInt(str);
|
|
4
|
+
return true;
|
|
5
|
+
} catch {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
-
|
|
3
|
-
export const $jsonStringifyNumber = (value: number): number => {
|
|
4
|
-
if (isFinite(value) === false)
|
|
5
|
-
throw new TypeGuardError({
|
|
6
|
-
method: "typia.json.stringify",
|
|
7
|
-
expected: "number",
|
|
8
|
-
value,
|
|
9
|
-
message: "Error on typia.json.stringify(): infinite or not a number.",
|
|
10
|
-
});
|
|
11
|
-
return value;
|
|
12
|
-
};
|
|
1
|
+
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
+
|
|
3
|
+
export const $jsonStringifyNumber = (value: number): number => {
|
|
4
|
+
if (isFinite(value) === false)
|
|
5
|
+
throw new TypeGuardError({
|
|
6
|
+
method: "typia.json.stringify",
|
|
7
|
+
expected: "number",
|
|
8
|
+
value,
|
|
9
|
+
message: "Error on typia.json.stringify(): infinite or not a number.",
|
|
10
|
+
});
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const $jsonStringifyRest = (str: string): string => {
|
|
2
|
-
return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
|
|
3
|
-
};
|
|
1
|
+
export const $jsonStringifyRest = (str: string): string => {
|
|
2
|
+
return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
|
|
3
|
+
};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In the past, name of `typia` was `typescript-json`, and supported
|
|
3
|
-
* JSON serialization by wrapping `fast-json-stringify. `typescript-json` was
|
|
4
|
-
* a helper library of `fast-json-stringify`, which can skip manual JSON schema
|
|
5
|
-
* definition just by putting pure TypeScript type.
|
|
6
|
-
*
|
|
7
|
-
* This `$string` function is a part of `fast-json-stringify` at that time, and
|
|
8
|
-
* still being used in `typia` for the string serialization.
|
|
9
|
-
*
|
|
10
|
-
* @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
|
|
11
|
-
* @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
|
|
12
|
-
*/
|
|
13
|
-
export const $jsonStringifyString = (str: string): string => {
|
|
14
|
-
const len = str.length;
|
|
15
|
-
let result = "";
|
|
16
|
-
let last = -1;
|
|
17
|
-
let point = 255;
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line
|
|
20
|
-
for (var i = 0; i < len; i++) {
|
|
21
|
-
point = str.charCodeAt(i);
|
|
22
|
-
if (point < 32) {
|
|
23
|
-
return JSON.stringify(str);
|
|
24
|
-
}
|
|
25
|
-
if (point >= 0xd800 && point <= 0xdfff) {
|
|
26
|
-
// The current character is a surrogate.
|
|
27
|
-
return JSON.stringify(str);
|
|
28
|
-
}
|
|
29
|
-
if (
|
|
30
|
-
point === 0x22 || // '"'
|
|
31
|
-
point === 0x5c // '\'
|
|
32
|
-
) {
|
|
33
|
-
last === -1 && (last = 0);
|
|
34
|
-
result += str.slice(last, i) + "\\";
|
|
35
|
-
last = i;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
(last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
|
|
41
|
-
);
|
|
42
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* In the past, name of `typia` was `typescript-json`, and supported
|
|
3
|
+
* JSON serialization by wrapping `fast-json-stringify. `typescript-json` was
|
|
4
|
+
* a helper library of `fast-json-stringify`, which can skip manual JSON schema
|
|
5
|
+
* definition just by putting pure TypeScript type.
|
|
6
|
+
*
|
|
7
|
+
* This `$string` function is a part of `fast-json-stringify` at that time, and
|
|
8
|
+
* still being used in `typia` for the string serialization.
|
|
9
|
+
*
|
|
10
|
+
* @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
|
|
11
|
+
* @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
|
|
12
|
+
*/
|
|
13
|
+
export const $jsonStringifyString = (str: string): string => {
|
|
14
|
+
const len = str.length;
|
|
15
|
+
let result = "";
|
|
16
|
+
let last = -1;
|
|
17
|
+
let point = 255;
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line
|
|
20
|
+
for (var i = 0; i < len; i++) {
|
|
21
|
+
point = str.charCodeAt(i);
|
|
22
|
+
if (point < 32) {
|
|
23
|
+
return JSON.stringify(str);
|
|
24
|
+
}
|
|
25
|
+
if (point >= 0xd800 && point <= 0xdfff) {
|
|
26
|
+
// The current character is a surrogate.
|
|
27
|
+
return JSON.stringify(str);
|
|
28
|
+
}
|
|
29
|
+
if (
|
|
30
|
+
point === 0x22 || // '"'
|
|
31
|
+
point === 0x5c // '\'
|
|
32
|
+
) {
|
|
33
|
+
last === -1 && (last = 0);
|
|
34
|
+
result += str.slice(last, i) + "\\";
|
|
35
|
+
last = i;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
(last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const $jsonStringifyTail = (str: string): string =>
|
|
2
|
-
str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
|
|
1
|
+
export const $jsonStringifyTail = (str: string): string =>
|
|
2
|
+
str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ILlmApplication } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
import { LlmSchemaSeparator } from "@samchon/openapi/lib/utils/LlmSchemaSeparator";
|
|
4
|
-
|
|
5
|
-
export const $llmApplicationFinalize = (
|
|
6
|
-
app: ILlmApplication,
|
|
7
|
-
options?: ILlmApplication.IOptions,
|
|
8
|
-
): void => {
|
|
9
|
-
app.options = {
|
|
10
|
-
separate: options?.separate ?? null,
|
|
11
|
-
};
|
|
12
|
-
if (app.options.separate === null) return;
|
|
13
|
-
for (const func of app.functions)
|
|
14
|
-
func.separated = LlmSchemaSeparator.parameters({
|
|
15
|
-
parameters: func.parameters,
|
|
16
|
-
predicator: app.options.separate,
|
|
17
|
-
});
|
|
18
|
-
};
|
|
1
|
+
import { ILlmApplication } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { LlmSchemaSeparator } from "@samchon/openapi/lib/utils/LlmSchemaSeparator";
|
|
4
|
+
|
|
5
|
+
export const $llmApplicationFinalize = (
|
|
6
|
+
app: ILlmApplication,
|
|
7
|
+
options?: ILlmApplication.IOptions,
|
|
8
|
+
): void => {
|
|
9
|
+
app.options = {
|
|
10
|
+
separate: options?.separate ?? null,
|
|
11
|
+
};
|
|
12
|
+
if (app.options.separate === null) return;
|
|
13
|
+
for (const func of app.functions)
|
|
14
|
+
func.separated = LlmSchemaSeparator.parameters({
|
|
15
|
+
parameters: func.parameters,
|
|
16
|
+
predicator: app.options.separate,
|
|
17
|
+
});
|
|
18
|
+
};
|