diff --git a/benchmark/package.json b/benchmark/package.json index 3c5e8af63c..2bb1327c2c 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -72,6 +72,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^3.0.0", "uuid": "^9.0.1", - "typia": "../typia-6.8.0-dev.20240811.tgz" + "typia": "../typia-6.8.0-dev.20240811-2.tgz" } } \ No newline at end of file diff --git a/debug/src/bigint.ts b/debug/src/bigint.ts new file mode 100644 index 0000000000..bed493f0a1 --- /dev/null +++ b/debug/src/bigint.ts @@ -0,0 +1,19 @@ +import typia, { IJsonApplication, tags } from "typia"; + +import { IMetadataApplication } from "typia/lib/schemas/metadata/IMetadataApplication"; +import { MetadataApplication } from "typia/lib/schemas/metadata/MetadataApplication"; + +import { JsonApplicationProgrammer } from "typia/lib/programmers/json/JsonApplicationProgrammer"; + +const raw: IMetadataApplication = + typia.reflect.metadata< + [ + bigint & tags.Minimum<0n> & tags.Maximum<100n> & tags.MultipleOf<5n>, + bigint & tags.ExclusiveMinimum<0n> & tags.ExclusiveMaximum<100n>, + ] + >(); +const app: MetadataApplication = MetadataApplication.from(raw); +const json: IJsonApplication = JsonApplicationProgrammer.write("3.1")( + app.metadatas, +) as IJsonApplication; +console.log(json.schemas); diff --git a/debug/src/prune.ts b/debug/src/prune.ts deleted file mode 100644 index 5531d65840..0000000000 --- a/debug/src/prune.ts +++ /dev/null @@ -1,7 +0,0 @@ -import typia, { tags } from "typia"; - -interface DynamicTag { - [key: number & tags.Minimum<0> & tags.ExclusiveMaximum<10>]: number; - [key: string & tags.Format<"uuid">]: string; -} -typia.misc.createPrune(); diff --git a/errors/package.json b/errors/package.json index 9f518954cb..b7fab1ea52 100644 --- a/errors/package.json +++ b/errors/package.json @@ -32,6 +32,6 @@ "typescript": "^5.3.2" }, "dependencies": { - "typia": "../typia-6.8.0-dev.20240811.tgz" + "typia": "../typia-6.8.0-dev.20240811-2.tgz" } } \ No newline at end of file diff --git a/package.json b/package.json index f4a676b5ad..21a575a775 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typia", - "version": "6.8.0-dev.20240811", + "version": "6.8.0-dev.20240811-2", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", diff --git a/packages/typescript-json/package.json b/packages/typescript-json/package.json index f6b64048a3..7ef3eddf43 100644 --- a/packages/typescript-json/package.json +++ b/packages/typescript-json/package.json @@ -1,6 +1,6 @@ { "name": "typescript-json", - "version": "6.8.0-dev.20240811", + "version": "6.8.0-dev.20240811-2", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -63,7 +63,7 @@ }, "homepage": "https://typia.io", "dependencies": { - "typia": "6.8.0-dev.20240811" + "typia": "6.8.0-dev.20240811-2" }, "peerDependencies": { "typescript": ">=4.8.0 <5.6.0" diff --git a/src/programmers/internal/application_v30_schema.ts b/src/programmers/internal/application_v30_schema.ts index eb508ac16e..1fea2c302e 100644 --- a/src/programmers/internal/application_v30_schema.ts +++ b/src/programmers/internal/application_v30_schema.ts @@ -67,8 +67,7 @@ export const application_v30_schema = else insert(application_v30_constant(constant)); for (const a of meta.atomics) if (a.type === "boolean") application_boolean(a).forEach(insert); - else if (a.type === "bigint") - application_bigint(a).forEach(insert as any); + else if (a.type === "bigint") application_bigint(a).forEach(insert); else if (a.type === "number") application_number(a).forEach(insert); else if (a.type === "string") application_string(a).forEach(insert); diff --git a/src/schemas/metadata/MetadataAtomic.ts b/src/schemas/metadata/MetadataAtomic.ts index d11d2e5bd7..88daf44117 100644 --- a/src/schemas/metadata/MetadataAtomic.ts +++ b/src/schemas/metadata/MetadataAtomic.ts @@ -64,7 +64,7 @@ export class MetadataAtomic { : tag.value, validate: tag.validate, exclusive: tag.exclusive, - schema: this.type !== "bigint" ? tag.schema : undefined, + schema: tag.schema, })), ), }; diff --git a/test-esm/package.json b/test-esm/package.json index 20f8b783ee..998a098cb1 100644 --- a/test-esm/package.json +++ b/test-esm/package.json @@ -36,6 +36,6 @@ "typescript": "^5.4.5" }, "dependencies": { - "typia": "../typia-6.8.0-dev.20240811.tgz" + "typia": "../typia-6.8.0-dev.20240811-2.tgz" } } \ No newline at end of file diff --git a/test/package.json b/test/package.json index dea7414ffe..b5ca5310cb 100644 --- a/test/package.json +++ b/test/package.json @@ -52,6 +52,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^3.0.0", "uuid": "^9.0.1", - "typia": "../typia-6.8.0-dev.20240811.tgz" + "typia": "../typia-6.8.0-dev.20240811-2.tgz" } } \ No newline at end of file diff --git a/test/schemas/reflect/metadata/ArraySimpleProtobuf.json b/test/schemas/reflect/metadata/ArraySimpleProtobuf.json index 9439ebacf0..c7833aecac 100644 --- a/test/schemas/reflect/metadata/ArraySimpleProtobuf.json +++ b/test/schemas/reflect/metadata/ArraySimpleProtobuf.json @@ -741,7 +741,10 @@ "kind": "type", "value": "int64", "validate": "true", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] @@ -784,7 +787,10 @@ "kind": "type", "value": "uint64", "validate": "BigInt(0) <= $input", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] diff --git a/test/schemas/reflect/metadata/ArraySimpleProtobufNullable.json b/test/schemas/reflect/metadata/ArraySimpleProtobufNullable.json index 76973a01f0..20bc7b0b39 100644 --- a/test/schemas/reflect/metadata/ArraySimpleProtobufNullable.json +++ b/test/schemas/reflect/metadata/ArraySimpleProtobufNullable.json @@ -741,7 +741,10 @@ "kind": "type", "value": "int64", "validate": "true", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] @@ -784,7 +787,10 @@ "kind": "type", "value": "uint64", "validate": "BigInt(0) <= $input", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] diff --git a/test/schemas/reflect/metadata/ArraySimpleProtobufOptional.json b/test/schemas/reflect/metadata/ArraySimpleProtobufOptional.json index 589e66f651..768b5d8239 100644 --- a/test/schemas/reflect/metadata/ArraySimpleProtobufOptional.json +++ b/test/schemas/reflect/metadata/ArraySimpleProtobufOptional.json @@ -741,7 +741,10 @@ "kind": "type", "value": "int64", "validate": "true", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] @@ -784,7 +787,10 @@ "kind": "type", "value": "uint64", "validate": "BigInt(0) <= $input", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] diff --git a/test/schemas/reflect/metadata/DynamicTag.json b/test/schemas/reflect/metadata/DynamicTag.json index 71e6f75237..aa6e8fbd39 100644 --- a/test/schemas/reflect/metadata/DynamicTag.json +++ b/test/schemas/reflect/metadata/DynamicTag.json @@ -101,7 +101,10 @@ "kind": "type", "value": "uint64", "validate": "BigInt(0) <= $input", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] diff --git a/test/schemas/reflect/metadata/ObjectHttpTypeTag.json b/test/schemas/reflect/metadata/ObjectHttpTypeTag.json index b1cdb3e7a0..887aa00e23 100644 --- a/test/schemas/reflect/metadata/ObjectHttpTypeTag.json +++ b/test/schemas/reflect/metadata/ObjectHttpTypeTag.json @@ -143,7 +143,10 @@ "kind": "type", "value": "uint64", "validate": "BigInt(0) <= $input", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] diff --git a/test/schemas/reflect/metadata/ObjectSimpleProtobuf.json b/test/schemas/reflect/metadata/ObjectSimpleProtobuf.json index ad15ce2818..8eda20bac3 100644 --- a/test/schemas/reflect/metadata/ObjectSimpleProtobuf.json +++ b/test/schemas/reflect/metadata/ObjectSimpleProtobuf.json @@ -325,7 +325,10 @@ "kind": "type", "value": "uint64", "validate": "BigInt(0) <= $input", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] diff --git a/test/schemas/reflect/metadata/ObjectSimpleProtobufNullable.json b/test/schemas/reflect/metadata/ObjectSimpleProtobufNullable.json index e5c03120f2..7fe0724d1b 100644 --- a/test/schemas/reflect/metadata/ObjectSimpleProtobufNullable.json +++ b/test/schemas/reflect/metadata/ObjectSimpleProtobufNullable.json @@ -325,7 +325,10 @@ "kind": "type", "value": "uint64", "validate": "BigInt(0) <= $input", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] diff --git a/test/schemas/reflect/metadata/ObjectSimpleProtobufOptional.json b/test/schemas/reflect/metadata/ObjectSimpleProtobufOptional.json index bcdcf59efe..994fb0f302 100644 --- a/test/schemas/reflect/metadata/ObjectSimpleProtobufOptional.json +++ b/test/schemas/reflect/metadata/ObjectSimpleProtobufOptional.json @@ -325,7 +325,10 @@ "kind": "type", "value": "uint64", "validate": "BigInt(0) <= $input", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] diff --git a/test/schemas/reflect/metadata/TypeTagBigInt.json b/test/schemas/reflect/metadata/TypeTagBigInt.json index 39bcbe7de1..2478f6d907 100644 --- a/test/schemas/reflect/metadata/TypeTagBigInt.json +++ b/test/schemas/reflect/metadata/TypeTagBigInt.json @@ -135,7 +135,10 @@ "exclusive": [ "minimum", "exclusiveMinimum" - ] + ], + "schema": { + "minimum": 0 + } }, { "target": "bigint", @@ -149,7 +152,10 @@ "exclusive": [ "maximum", "exclusiveMaximum" - ] + ], + "schema": { + "maximum": 100 + } } ] ] @@ -222,7 +228,10 @@ "exclusive": [ "minimum", "exclusiveMinimum" - ] + ], + "schema": { + "minimum": 0 + } } ] ] @@ -295,7 +304,10 @@ "exclusive": [ "maximum", "exclusiveMaximum" - ] + ], + "schema": { + "maximum": 100 + } } ] ] @@ -365,7 +377,10 @@ "value": "3" }, "validate": "$input % BigInt(3) === BigInt(0)", - "exclusive": true + "exclusive": true, + "schema": { + "multipleOf": 3 + } } ] ] diff --git a/test/schemas/reflect/metadata/TypeTagRangeBigInt.json b/test/schemas/reflect/metadata/TypeTagRangeBigInt.json index 85409f0080..500eaeef38 100644 --- a/test/schemas/reflect/metadata/TypeTagRangeBigInt.json +++ b/test/schemas/reflect/metadata/TypeTagRangeBigInt.json @@ -146,7 +146,11 @@ "exclusive": [ "exclusiveMinimum", "minimum" - ] + ], + "schema": { + "exclusiveMinimum": true, + "minimum": 3 + } } ] ] @@ -219,7 +223,10 @@ "exclusive": [ "minimum", "exclusiveMinimum" - ] + ], + "schema": { + "minimum": 3 + } } ] ] @@ -292,7 +299,11 @@ "exclusive": [ "exclusiveMaximum", "maximum" - ] + ], + "schema": { + "exclusiveMaximum": true, + "maximum": 7 + } } ] ] @@ -365,7 +376,10 @@ "exclusive": [ "maximum", "exclusiveMaximum" - ] + ], + "schema": { + "maximum": 7 + } } ] ] @@ -438,7 +452,11 @@ "exclusive": [ "exclusiveMinimum", "minimum" - ] + ], + "schema": { + "exclusiveMinimum": true, + "minimum": 3 + } }, { "target": "bigint", @@ -452,7 +470,11 @@ "exclusive": [ "exclusiveMaximum", "maximum" - ] + ], + "schema": { + "exclusiveMaximum": true, + "maximum": 7 + } } ] ] @@ -525,7 +547,10 @@ "exclusive": [ "minimum", "exclusiveMinimum" - ] + ], + "schema": { + "minimum": 3 + } }, { "target": "bigint", @@ -539,7 +564,11 @@ "exclusive": [ "exclusiveMaximum", "maximum" - ] + ], + "schema": { + "exclusiveMaximum": true, + "maximum": 7 + } } ] ] @@ -612,7 +641,11 @@ "exclusive": [ "exclusiveMinimum", "minimum" - ] + ], + "schema": { + "exclusiveMinimum": true, + "minimum": 3 + } }, { "target": "bigint", @@ -626,7 +659,10 @@ "exclusive": [ "maximum", "exclusiveMaximum" - ] + ], + "schema": { + "maximum": 7 + } } ] ] @@ -699,7 +735,10 @@ "exclusive": [ "minimum", "exclusiveMinimum" - ] + ], + "schema": { + "minimum": 3 + } }, { "target": "bigint", @@ -713,7 +752,10 @@ "exclusive": [ "maximum", "exclusiveMaximum" - ] + ], + "schema": { + "maximum": 7 + } } ] ] @@ -786,7 +828,10 @@ "exclusive": [ "minimum", "exclusiveMinimum" - ] + ], + "schema": { + "minimum": 10 + } }, { "target": "bigint", @@ -800,7 +845,10 @@ "exclusive": [ "maximum", "exclusiveMaximum" - ] + ], + "schema": { + "maximum": 10 + } } ] ] diff --git a/test/schemas/reflect/metadata/TypeTagTypeBigInt.json b/test/schemas/reflect/metadata/TypeTagTypeBigInt.json index c8e588083d..85527c6e50 100644 --- a/test/schemas/reflect/metadata/TypeTagTypeBigInt.json +++ b/test/schemas/reflect/metadata/TypeTagTypeBigInt.json @@ -129,7 +129,10 @@ "kind": "type", "value": "uint64", "validate": "BigInt(0) <= $input", - "exclusive": true + "exclusive": true, + "schema": { + "type": "integer" + } } ] ] diff --git a/test/src/features/issues/test_pr_1217_bigint_json_schema.ts b/test/src/features/issues/test_pr_1217_bigint_json_schema.ts new file mode 100644 index 0000000000..cfc5d9b966 --- /dev/null +++ b/test/src/features/issues/test_pr_1217_bigint_json_schema.ts @@ -0,0 +1,35 @@ +import typia, { IJsonApplication, tags } from "typia"; +import { JsonApplicationProgrammer } from "typia/lib/programmers/json/JsonApplicationProgrammer"; +import { IMetadataApplication } from "typia/lib/schemas/metadata/IMetadataApplication"; +import { MetadataApplication } from "typia/lib/schemas/metadata/MetadataApplication"; + +import { TestValidator } from "../../helpers/TestValidator"; + +export const test_pr_1217_bigint_json_schema = (): void => { + const raw: IMetadataApplication = + typia.reflect.metadata< + [ + bigint & tags.Minimum<0n> & tags.Maximum<100n> & tags.MultipleOf<5n>, + bigint & tags.ExclusiveMinimum<0n> & tags.ExclusiveMaximum<100n>, + ] + >(); + const app: MetadataApplication = MetadataApplication.from(raw); + const json: IJsonApplication = JsonApplicationProgrammer.write("3.1")( + app.metadatas, + ) as IJsonApplication; + TestValidator.equals("bigint")(json.schemas)([ + { + type: "integer", + minimum: 0, + maximum: 100, + multipleOf: 5, + }, + { + type: "integer", + minimum: 0, + maximum: 100, + exclusiveMinimum: true, + exclusiveMaximum: true, + }, + ]); +};