diff --git a/bun.lockb b/bun.lockb index 6ec775e9..9ce4a2f8 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/examples/bun-build/package.json b/examples/bun-build/package.json index 61b9f5dd..e1c969f0 100644 --- a/examples/bun-build/package.json +++ b/examples/bun-build/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@types/bun": "latest", "std-env": "^3.7.0", - "typia": "^6.7.0" + "typia": "^6.8.0" }, "peerDependencies": { "ts-patch": "^3.2.1", diff --git a/examples/nextjs/package.json b/examples/nextjs/package.json index 603c8526..76f06a65 100644 --- a/examples/nextjs/package.json +++ b/examples/nextjs/package.json @@ -15,13 +15,13 @@ }, "devDependencies": { "@ryoppippi/unplugin-typia": "workspace:*", - "@types/node": "^20.14.14", + "@types/node": "^20.14.15", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "ts-patch": "^3.2.1", "tslib": "^2.6.3", - "type-fest": "^4.23.0", + "type-fest": "^4.24.0", "typescript": "~5.5.4", - "typia": "^6.7.0" + "typia": "^6.8.0" } } diff --git a/examples/sveltekit/package.json b/examples/sveltekit/package.json index 281a2e38..f05b8517 100644 --- a/examples/sveltekit/package.json +++ b/examples/sveltekit/package.json @@ -12,17 +12,17 @@ "prepare": "ts-patch install && typia patch" }, "devDependencies": { - "@sveltejs/adapter-auto": "^3.2.2", - "@sveltejs/adapter-cloudflare": "^4.7.0", - "@sveltejs/kit": "^2.5.20", + "@sveltejs/adapter-auto": "^3.2.4", + "@sveltejs/adapter-cloudflare": "^4.7.2", + "@sveltejs/kit": "^2.5.22", "@sveltejs/vite-plugin-svelte": "^3.1.1", - "svelte": "^5.0.0-next.208", + "svelte": "^5.0.0-next.222", "svelte-check": "^3.8.5", "ts-patch": "^3.2.1", "tslib": "^2.6.3", "typescript": "~5.5.4", - "typia": "^6.7.0", - "vite": "^5.3.5" + "typia": "^6.8.0", + "vite": "^5.4.1" }, "type": "module", "dependencies": { diff --git a/examples/vite-hono/package.json b/examples/vite-hono/package.json index ff86f6ff..a7a9483a 100644 --- a/examples/vite-hono/package.json +++ b/examples/vite-hono/package.json @@ -10,7 +10,7 @@ "prepare": "ts-patch install && typia patch" }, "dependencies": { - "hono": "^4.5.3", + "hono": "^4.5.5", "uuid": "^9.0.1" }, "devDependencies": { @@ -20,7 +20,7 @@ "@ryoppippi/unplugin-typia": "workspace:*", "ts-patch": "^3.2.1", "typescript": "~5.5.4", - "typia": "^6.7.0", - "vite": "^5.3.5" + "typia": "^6.8.0", + "vite": "^5.4.1" } } diff --git a/examples/vite-react/package.json b/examples/vite-react/package.json index f518e89d..abc088ad 100644 --- a/examples/vite-react/package.json +++ b/examples/vite-react/package.json @@ -23,7 +23,7 @@ "@vitejs/plugin-react": "^4.3.1", "ts-patch": "^3.2.1", "typescript": "~5.5.4", - "typia": "^6.7.0", - "vite": "^5.3.5" + "typia": "^6.8.0", + "vite": "^5.4.1" } } diff --git a/examples/webpack-minimal/package.json b/examples/webpack-minimal/package.json index 2aefb691..e5018bf1 100644 --- a/examples/webpack-minimal/package.json +++ b/examples/webpack-minimal/package.json @@ -2,14 +2,14 @@ "name": "webpack-minimal", "private": true, "devDependencies": { - "@types/node": "^20.14.14", + "@types/node": "^20.14.15", "@webpack-cli/generators": "^3.0.7", "html-webpack-plugin": "^5.6.0", "prettier": "^3.3.3", "ts-loader": "^9.5.1", "ts-node": "^10.9.2", "ts-patch": "^3.2.1", - "tsx": "^4.16.5", + "tsx": "^4.17.0", "typescript": "~5.5.4", "webpack": "^5.93.0", "webpack-cli": "^5.1.4", @@ -28,6 +28,6 @@ "dependencies": { "@ryoppippi/unplugin-typia": "workspace:*", "cross-env": "^7.0.3", - "typia": "^6.7.0" + "typia": "^6.8.0" } } diff --git a/package.json b/package.json index 168a6cc7..2053d681 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "format": "bun run --filter '*' format", "test": "bun run --filter '*' test", "deploy": "bun run --filter '*' deploy", - "prepare": "npx bunpare" + "prepare": "bun x bunpare", + "taze": "bun x taze -r" }, "workspaces": [ "examples/*", @@ -27,6 +28,6 @@ "vite-vanilla", "workerd" ], - "packageManager": "bun@1.1.21", + "packageManager": "bun@1.1.24", "private": true } diff --git a/packages/unplugin-typia/package.json b/packages/unplugin-typia/package.json index 6e198e93..f1b47edb 100644 --- a/packages/unplugin-typia/package.json +++ b/packages/unplugin-typia/package.json @@ -37,7 +37,7 @@ "scripts": { "lint": "nr check && eslint --cache .", "format": "eslint --cache --fix .", - "test": "vitest --typecheck", + "test": "vitest --typecheck --testTimeout 150000", "check": "nr tsc --noEmit", "release": "nr test && bumpp", "publish": "nr publish:prepare && nr test && nlx jsr publish --allow-dirty", @@ -51,25 +51,25 @@ "magic-string": "^0.30.11", "pathe": "^1.1.2", "pkg-types": "^1.1.3", - "type-fest": "^4.23.0", + "type-fest": "^4.24.0", "typescript": "~5.5.4", - "typia": "^6.7.0", - "unplugin": "^1.12.0" + "typia": "^6.8.0", + "unplugin": "^1.12.2" }, "devDependencies": { - "@antfu/ni": "^0.22.0", + "@antfu/ni": "^0.22.4", "@ryoppippi/eslint-config": "npm:@jsr/ryoppippi__eslint-config", "@types/bun": "^1.1.6", - "@types/node": "^20.14.14", + "@types/node": "^20.14.15", "@vue-macros/test-utils": "^1.6.0", - "bumpp": "^9.4.2", + "bumpp": "^9.5.1", "dax-sh": "^0.41.0", "esbuild": "^0.23.0", - "eslint": "^9.8.0", + "eslint": "^9.9.0", "eslint-plugin-format": "^0.1.2", "rollup": "^4.20.0", "ts-patch": "^3.2.1", - "vite": "^5.4.0", + "vite": "^5.4.1", "vitest": "^2.0.5" } } diff --git a/packages/unplugin-typia/tests/fixtures/__snapshots__/alias.ts b/packages/unplugin-typia/tests/fixtures/__snapshots__/alias.ts index d43794ce..76610b0f 100644 --- a/packages/unplugin-typia/tests/fixtures/__snapshots__/alias.ts +++ b/packages/unplugin-typia/tests/fixtures/__snapshots__/alias.ts @@ -1,43 +1,42 @@ import type { IMember } from '@/type.js'; import typia from 'typia'; const is = (() => { const $io0 = (input: any): boolean => "string" === typeof input.email && /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(input.email) && ("string" === typeof input.id && /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(input.id)) && ("number" === typeof input.age && (Math.floor(input.age) === input.age && 0 <= input.age && input.age <= 4294967295 && 19 < input.age && input.age <= 100)); return (input: any): input is IMember => "object" === typeof input && null !== input && $io0(input); })(); -const random = (generator?: Partial): import("typia").Resolved => { - const $generator = (typia.createRandom as any).generator; - const $ro0 = (_recursive: boolean = false, _depth: number = 0): any => ({ - email: (generator?.customs ?? $generator.customs)?.string?.([ - { - name: "Format<\"email\">", - kind: "format", - value: "email" - } - ]) ?? (generator?.email ?? $generator.email)(), - id: (generator?.customs ?? $generator.customs)?.string?.([ - { - name: "Format<\"uuid\">", - kind: "format", - value: "uuid" - } - ]) ?? (generator?.uuid ?? $generator.uuid)(), - age: (generator?.customs ?? $generator.customs)?.number?.([ - { - name: "Type<\"uint32\">", - kind: "type", - value: "uint32" - }, - { - name: "ExclusiveMinimum<19>", - kind: "exclusiveMinimum", - value: 19 - }, - { - name: "Maximum<100>", - kind: "maximum", - value: 100 - } - ]) ?? (generator?.integer ?? $generator.integer)(19, 100) - }); +const random = (() => { const $generator = (typia.createRandom as any).generator; const $ro0 = (_recursive: boolean = false, _depth: number = 0): any => ({ + email: (_generator?.customs ?? $generator.customs)?.string?.([ + { + name: "Format<\"email\">", + kind: "format", + value: "email" + } + ]) ?? (_generator?.email ?? $generator.email)(), + id: (_generator?.customs ?? $generator.customs)?.string?.([ + { + name: "Format<\"uuid\">", + kind: "format", + value: "uuid" + } + ]) ?? (_generator?.uuid ?? $generator.uuid)(), + age: (_generator?.customs ?? $generator.customs)?.number?.([ + { + name: "Type<\"uint32\">", + kind: "type", + value: "uint32" + }, + { + name: "ExclusiveMinimum<19>", + kind: "exclusiveMinimum", + value: 19 + }, + { + name: "Maximum<100>", + kind: "maximum", + value: 100 + } + ]) ?? (_generator?.integer ?? $generator.integer)(19, 100) +}); let _generator: any; return (generator?: Partial): import("typia").Resolved => { + _generator = generator; return $ro0(); -}; +}; })(); const validate = (() => { const $io0 = (input: any): boolean => "string" === typeof input.email && /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(input.email) && ("string" === typeof input.id && /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(input.id)) && ("number" === typeof input.age && (Math.floor(input.age) === input.age && 0 <= input.age && input.age <= 4294967295 && 19 < input.age && input.age <= 100)); const $vo0 = (input: any, _path: string, _exceptionable: boolean = true): boolean => ["string" === typeof input.email && (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(input.email) || $report(_exceptionable, { path: _path + ".email", expected: "string & Format<\"email\">", @@ -70,7 +69,7 @@ const validate = (() => { const $io0 = (input: any): boolean => "string" === typ path: _path + ".age", expected: "(number & Type<\"uint32\"> & ExclusiveMinimum<19> & Maximum<100>)", value: input.age - })].every((flag: boolean) => flag); const __is = (input: any): input is IMember => "object" === typeof input && null !== input && $io0(input); let errors; let $report; return (input: any): typia.IValidation => { + })].every((flag: boolean) => flag); const __is = (input: any): input is IMember => "object" === typeof input && null !== input && $io0(input); let errors: any; let $report: any; return (input: any): typia.IValidation => { if (false === __is(input)) { errors = []; $report = (typia.createValidate as any).report(errors); diff --git a/packages/unplugin-typia/tests/fixtures/__snapshots__/esbuild/alias.js b/packages/unplugin-typia/tests/fixtures/__snapshots__/esbuild/alias.js index cebfad2e..b896ecf9 100644 --- a/packages/unplugin-typia/tests/fixtures/__snapshots__/esbuild/alias.js +++ b/packages/unplugin-typia/tests/fixtures/__snapshots__/esbuild/alias.js @@ -2,9 +2,13 @@ import typia from "typia"; const is = /* @__PURE__ */ (() => { return (input) => true; })(); -const random = (generator) => { - return "any type used..."; -}; +const random = /* @__PURE__ */ (() => { + let _generator; + return (generator) => { + _generator = generator; + return "any type used..."; + }; +})(); const validate = /* @__PURE__ */ (() => { const __is = (input) => true; let errors; diff --git a/packages/unplugin-typia/tests/fixtures/__snapshots__/esbuild/random.js b/packages/unplugin-typia/tests/fixtures/__snapshots__/esbuild/random.js index 8b3a0742..9bd75ab3 100644 --- a/packages/unplugin-typia/tests/fixtures/__snapshots__/esbuild/random.js +++ b/packages/unplugin-typia/tests/fixtures/__snapshots__/esbuild/random.js @@ -1,22 +1,22 @@ import typia from "typia"; -const random = (generator) => { +const random = (() => { const $generator = typia.createRandom.generator; const $ro0 = (_recursive = false, _depth = 0) => ({ - email: (generator?.customs ?? $generator.customs)?.string?.([ + email: (_generator?.customs ?? $generator.customs)?.string?.([ { name: 'Format<"email">', kind: "format", value: "email" } - ]) ?? (generator?.email ?? $generator.email)(), - id: (generator?.customs ?? $generator.customs)?.string?.([ + ]) ?? (_generator?.email ?? $generator.email)(), + id: (_generator?.customs ?? $generator.customs)?.string?.([ { name: 'Format<"uuid">', kind: "format", value: "uuid" } - ]) ?? (generator?.uuid ?? $generator.uuid)(), - age: (generator?.customs ?? $generator.customs)?.number?.([ + ]) ?? (_generator?.uuid ?? $generator.uuid)(), + age: (_generator?.customs ?? $generator.customs)?.number?.([ { name: 'Type<"uint32">', kind: "type", @@ -32,8 +32,12 @@ const random = (generator) => { kind: "maximum", value: 100 } - ]) ?? (generator?.integer ?? $generator.integer)(19, 100) + ]) ?? (_generator?.integer ?? $generator.integer)(19, 100) }); - return $ro0(); -}; + let _generator; + return (generator) => { + _generator = generator; + return $ro0(); + }; +})(); random(); diff --git a/packages/unplugin-typia/tests/fixtures/__snapshots__/random.ts b/packages/unplugin-typia/tests/fixtures/__snapshots__/random.ts index de7f8148..c9c2c614 100644 --- a/packages/unplugin-typia/tests/fixtures/__snapshots__/random.ts +++ b/packages/unplugin-typia/tests/fixtures/__snapshots__/random.ts @@ -1,40 +1,39 @@ import typia from 'typia'; import type { IMember } from './type.js'; -const random = (generator?: Partial): import("typia").Resolved => { - const $generator = (typia.createRandom as any).generator; - const $ro0 = (_recursive: boolean = false, _depth: number = 0): any => ({ - email: (generator?.customs ?? $generator.customs)?.string?.([ - { - name: "Format<\"email\">", - kind: "format", - value: "email" - } - ]) ?? (generator?.email ?? $generator.email)(), - id: (generator?.customs ?? $generator.customs)?.string?.([ - { - name: "Format<\"uuid\">", - kind: "format", - value: "uuid" - } - ]) ?? (generator?.uuid ?? $generator.uuid)(), - age: (generator?.customs ?? $generator.customs)?.number?.([ - { - name: "Type<\"uint32\">", - kind: "type", - value: "uint32" - }, - { - name: "ExclusiveMinimum<19>", - kind: "exclusiveMinimum", - value: 19 - }, - { - name: "Maximum<100>", - kind: "maximum", - value: 100 - } - ]) ?? (generator?.integer ?? $generator.integer)(19, 100) - }); +const random = (() => { const $generator = (typia.createRandom as any).generator; const $ro0 = (_recursive: boolean = false, _depth: number = 0): any => ({ + email: (_generator?.customs ?? $generator.customs)?.string?.([ + { + name: "Format<\"email\">", + kind: "format", + value: "email" + } + ]) ?? (_generator?.email ?? $generator.email)(), + id: (_generator?.customs ?? $generator.customs)?.string?.([ + { + name: "Format<\"uuid\">", + kind: "format", + value: "uuid" + } + ]) ?? (_generator?.uuid ?? $generator.uuid)(), + age: (_generator?.customs ?? $generator.customs)?.number?.([ + { + name: "Type<\"uint32\">", + kind: "type", + value: "uint32" + }, + { + name: "ExclusiveMinimum<19>", + kind: "exclusiveMinimum", + value: 19 + }, + { + name: "Maximum<100>", + kind: "maximum", + value: 100 + } + ]) ?? (_generator?.integer ?? $generator.integer)(19, 100) +}); let _generator: any; return (generator?: Partial): import("typia").Resolved => { + _generator = generator; return $ro0(); -}; +}; })(); random(); diff --git a/packages/unplugin-typia/tests/fixtures/__snapshots__/rollup/alias.js b/packages/unplugin-typia/tests/fixtures/__snapshots__/rollup/alias.js index 94924bd2..13483461 100644 --- a/packages/unplugin-typia/tests/fixtures/__snapshots__/rollup/alias.js +++ b/packages/unplugin-typia/tests/fixtures/__snapshots__/rollup/alias.js @@ -1,6 +1,13 @@ // alias.js import typia from 'typia'; +const random = /* @__PURE__ */ (() => { + let _generator; + return (generator) => { + _generator = generator; + return "any type used..."; + }; +})(); const validate = /* @__PURE__ */ (() => { const __is = (input) => true; let errors; @@ -23,3 +30,4 @@ const validate = /* @__PURE__ */ (() => { }; })(); validate({}); +random(); diff --git a/packages/unplugin-typia/tests/fixtures/__snapshots__/rollup/random.js b/packages/unplugin-typia/tests/fixtures/__snapshots__/rollup/random.js index 501e1ae8..42c202b7 100644 --- a/packages/unplugin-typia/tests/fixtures/__snapshots__/rollup/random.js +++ b/packages/unplugin-typia/tests/fixtures/__snapshots__/rollup/random.js @@ -1,24 +1,24 @@ // random.js import typia from 'typia'; -const random = (generator) => { +const random = (() => { const $generator = typia.createRandom.generator; const $ro0 = (_recursive = false, _depth = 0) => ({ - email: ($generator.customs)?.string?.([ + email: (_generator?.customs ?? $generator.customs)?.string?.([ { name: 'Format<"email">', kind: "format", value: "email" } - ]) ?? (0, $generator.email)(), - id: ($generator.customs)?.string?.([ + ]) ?? (_generator?.email ?? $generator.email)(), + id: (_generator?.customs ?? $generator.customs)?.string?.([ { name: 'Format<"uuid">', kind: "format", value: "uuid" } - ]) ?? (0, $generator.uuid)(), - age: ($generator.customs)?.number?.([ + ]) ?? (_generator?.uuid ?? $generator.uuid)(), + age: (_generator?.customs ?? $generator.customs)?.number?.([ { name: 'Type<"uint32">', kind: "type", @@ -34,8 +34,12 @@ const random = (generator) => { kind: "maximum", value: 100 } - ]) ?? (0, $generator.integer)(19, 100) + ]) ?? (_generator?.integer ?? $generator.integer)(19, 100) }); - return $ro0(); -}; + let _generator; + return (generator) => { + _generator = generator; + return $ro0(); + }; +})(); random(); diff --git a/packages/unplugin-typia/tests/fixtures/__snapshots__/validate.ts b/packages/unplugin-typia/tests/fixtures/__snapshots__/validate.ts index 122f366a..39d9db81 100644 --- a/packages/unplugin-typia/tests/fixtures/__snapshots__/validate.ts +++ b/packages/unplugin-typia/tests/fixtures/__snapshots__/validate.ts @@ -32,7 +32,7 @@ const validate = (() => { const $io0 = (input: any): boolean => "string" === typ path: _path + ".age", expected: "(number & Type<\"uint32\"> & ExclusiveMinimum<19> & Maximum<100>)", value: input.age - })].every((flag: boolean) => flag); const __is = (input: any): input is IMember => "object" === typeof input && null !== input && $io0(input); let errors; let $report; return (input: any): typia.IValidation => { + })].every((flag: boolean) => flag); const __is = (input: any): input is IMember => "object" === typeof input && null !== input && $io0(input); let errors: any; let $report: any; return (input: any): typia.IValidation => { if (false === __is(input)) { errors = []; $report = (typia.createValidate as any).report(errors); diff --git a/packages/unplugin-typia/tests/fixtures/__snapshots__/vite/alias.js b/packages/unplugin-typia/tests/fixtures/__snapshots__/vite/alias.js index 49d912f3..af34a556 100644 --- a/packages/unplugin-typia/tests/fixtures/__snapshots__/vite/alias.js +++ b/packages/unplugin-typia/tests/fixtures/__snapshots__/vite/alias.js @@ -3,26 +3,26 @@ const is = /* @__PURE__ */ (() => { const $io0 = (input) => "string" === typeof input.email && /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(input.email) && ("string" === typeof input.id && /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(input.id)) && ("number" === typeof input.age && (Math.floor(input.age) === input.age && 0 <= input.age && input.age <= 4294967295 && 19 < input.age && input.age <= 100)); return (input) => "object" === typeof input && null !== input && $io0(input); })(); -const random = (generator) => { +const random = (() => { const $generator = typia.createRandom.generator; const $ro0 = (_recursive = false, _depth = 0) => { var _a, _b, _c, _d, _e, _f; return { - email: ((_b = (_a = $generator.customs) == null ? void 0 : _a.string) == null ? void 0 : _b.call(_a, [ + email: ((_b = (_a = (_generator == null ? void 0 : _generator.customs) ?? $generator.customs) == null ? void 0 : _a.string) == null ? void 0 : _b.call(_a, [ { name: 'Format<"email">', kind: "format", value: "email" } - ])) ?? (0, $generator.email)(), - id: ((_d = (_c = $generator.customs) == null ? void 0 : _c.string) == null ? void 0 : _d.call(_c, [ + ])) ?? ((_generator == null ? void 0 : _generator.email) ?? $generator.email)(), + id: ((_d = (_c = (_generator == null ? void 0 : _generator.customs) ?? $generator.customs) == null ? void 0 : _c.string) == null ? void 0 : _d.call(_c, [ { name: 'Format<"uuid">', kind: "format", value: "uuid" } - ])) ?? (0, $generator.uuid)(), - age: ((_f = (_e = $generator.customs) == null ? void 0 : _e.number) == null ? void 0 : _f.call(_e, [ + ])) ?? ((_generator == null ? void 0 : _generator.uuid) ?? $generator.uuid)(), + age: ((_f = (_e = (_generator == null ? void 0 : _generator.customs) ?? $generator.customs) == null ? void 0 : _e.number) == null ? void 0 : _f.call(_e, [ { name: 'Type<"uint32">', kind: "type", @@ -38,11 +38,15 @@ const random = (generator) => { kind: "maximum", value: 100 } - ])) ?? (0, $generator.integer)(19, 100) + ])) ?? ((_generator == null ? void 0 : _generator.integer) ?? $generator.integer)(19, 100) }; }; - return $ro0(); -}; + let _generator; + return (generator) => { + _generator = generator; + return $ro0(); + }; +})(); const validate = /* @__PURE__ */ (() => { const $io0 = (input) => "string" === typeof input.email && /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(input.email) && ("string" === typeof input.id && /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(input.id)) && ("number" === typeof input.age && (Math.floor(input.age) === input.age && 0 <= input.age && input.age <= 4294967295 && 19 < input.age && input.age <= 100)); const $vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.email && (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(input.email) || $report(_exceptionable, { diff --git a/packages/unplugin-typia/tests/fixtures/__snapshots__/vite/random.js b/packages/unplugin-typia/tests/fixtures/__snapshots__/vite/random.js index 80bd641e..a1cc78fb 100644 --- a/packages/unplugin-typia/tests/fixtures/__snapshots__/vite/random.js +++ b/packages/unplugin-typia/tests/fixtures/__snapshots__/vite/random.js @@ -1,24 +1,24 @@ import typia from "typia"; -const random = (generator) => { +const random = (() => { const $generator = typia.createRandom.generator; const $ro0 = (_recursive = false, _depth = 0) => { var _a, _b, _c, _d, _e, _f; return { - email: ((_b = (_a = $generator.customs) == null ? void 0 : _a.string) == null ? void 0 : _b.call(_a, [ + email: ((_b = (_a = (_generator == null ? void 0 : _generator.customs) ?? $generator.customs) == null ? void 0 : _a.string) == null ? void 0 : _b.call(_a, [ { name: 'Format<"email">', kind: "format", value: "email" } - ])) ?? (0, $generator.email)(), - id: ((_d = (_c = $generator.customs) == null ? void 0 : _c.string) == null ? void 0 : _d.call(_c, [ + ])) ?? ((_generator == null ? void 0 : _generator.email) ?? $generator.email)(), + id: ((_d = (_c = (_generator == null ? void 0 : _generator.customs) ?? $generator.customs) == null ? void 0 : _c.string) == null ? void 0 : _d.call(_c, [ { name: 'Format<"uuid">', kind: "format", value: "uuid" } - ])) ?? (0, $generator.uuid)(), - age: ((_f = (_e = $generator.customs) == null ? void 0 : _e.number) == null ? void 0 : _f.call(_e, [ + ])) ?? ((_generator == null ? void 0 : _generator.uuid) ?? $generator.uuid)(), + age: ((_f = (_e = (_generator == null ? void 0 : _generator.customs) ?? $generator.customs) == null ? void 0 : _e.number) == null ? void 0 : _f.call(_e, [ { name: 'Type<"uint32">', kind: "type", @@ -34,9 +34,13 @@ const random = (generator) => { kind: "maximum", value: 100 } - ])) ?? (0, $generator.integer)(19, 100) + ])) ?? ((_generator == null ? void 0 : _generator.integer) ?? $generator.integer)(19, 100) }; }; - return $ro0(); -}; + let _generator; + return (generator) => { + _generator = generator; + return $ro0(); + }; +})(); random(); diff --git a/packages/unplugin-typia/tests/vite.spec.ts b/packages/unplugin-typia/tests/vite.spec.ts index 4a7b18ad..9c719b46 100644 --- a/packages/unplugin-typia/tests/vite.spec.ts +++ b/packages/unplugin-typia/tests/vite.spec.ts @@ -46,6 +46,5 @@ for (const id of await getFixtureIDs()) { await expect(code).toMatchFileSnapshot(snapshot); await $`node ${snapshot}`; }, - { timeout: 15_000 }, ); }