diff --git a/apps/playgrounds/node/.env.example b/apps/playgrounds/node/.env.example index d9aad752d..cef375671 100644 --- a/apps/playgrounds/node/.env.example +++ b/apps/playgrounds/node/.env.example @@ -2,3 +2,4 @@ HOST=localhost PORT=3000 NODE_ENV=development DEBUG=true +ZED_ENV=development diff --git a/apps/playgrounds/node/index.ts b/apps/playgrounds/node/index.ts index b75715972..a0ee893b2 100644 --- a/apps/playgrounds/node/index.ts +++ b/apps/playgrounds/node/index.ts @@ -1,15 +1,15 @@ import arkenv, { type } from "arkenv"; +import * as z from "zod"; -const Env = type({ +const env = arkenv({ HOST: "string.host", PORT: "number.port", NODE_ENV: "'development' | 'production' | 'test' = 'development'", ALLOWED_ORIGINS: type("string[]").default(() => []), DEBUG: "boolean = true", + ZED_ENV: z.string(), }); -const env = arkenv(Env, process.env); - // Automatically validate and parse process.env // TypeScript knows the ✨exact✨ types! const host = env.HOST; @@ -17,12 +17,14 @@ const port = env.PORT; const nodeEnv = env.NODE_ENV; const allowedOrigins = env.ALLOWED_ORIGINS; const debug = env.DEBUG; +const zedEnv = env.ZED_ENV; console.log({ host, port, nodeEnv, allowedOrigins, debug, + zedEnv, }); export default env; diff --git a/apps/playgrounds/node/package.json b/apps/playgrounds/node/package.json index 2e8589022..b38ff684f 100644 --- a/apps/playgrounds/node/package.json +++ b/apps/playgrounds/node/package.json @@ -10,7 +10,8 @@ }, "dependencies": { "arkenv": "workspace:*", - "arktype": "catalog:" + "arktype": "catalog:", + "zod": "^4.1.13" }, "devDependencies": { "@types/node": "catalog:", diff --git a/packages/vite-plugin/src/index.ts b/packages/vite-plugin/src/index.ts index a629b239d..06eae7cff 100644 --- a/packages/vite-plugin/src/index.ts +++ b/packages/vite-plugin/src/index.ts @@ -61,7 +61,8 @@ export default function arkenv>( // createEnv accepts both EnvSchema and type.Any at runtime // We use overloads above to provide external type precision - const env = createEnv(options, loadEnv(mode, process.cwd(), "")); + // TODO: Improve the `EnvSchema` type rather than using `as never`. See #501. + const env = createEnv(options as never, loadEnv(mode, process.cwd(), "")); // Filter to only include environment variables matching the prefix // This prevents server-only variables from being exposed to client code diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 114bbcb06..729df8ed7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,8 +34,8 @@ catalogs: specifier: 4.0.15 version: 4.0.15 arktype: - specifier: 2.1.27 - version: 2.1.27 + specifier: 2.1.28 + version: 2.1.28 bun: specifier: 1.3.3 version: 1.3.3 @@ -120,7 +120,7 @@ importers: version: link:../../../packages/arkenv arktype: specifier: 'catalog:' - version: 2.1.27 + version: 2.1.28 devDependencies: '@types/bun': specifier: 'catalog:' @@ -139,7 +139,7 @@ importers: version: link:../../../packages/arkenv arktype: specifier: 'catalog:' - version: 2.1.27 + version: 2.1.28 react: specifier: 'catalog:' version: 19.2.1 @@ -164,7 +164,10 @@ importers: version: link:../../../packages/arkenv arktype: specifier: 'catalog:' - version: 2.1.27 + version: 2.1.28 + zod: + specifier: ^4.1.13 + version: 4.1.13 devDependencies: '@types/node': specifier: 'catalog:' @@ -186,7 +189,7 @@ importers: version: link:../../../packages/arkenv arktype: specifier: 'catalog:' - version: 2.1.27 + version: 2.1.28 solid-js: specifier: 1.9.10 version: 1.9.10 @@ -204,7 +207,7 @@ importers: version: link:../../../packages/arkenv arktype: specifier: 'catalog:' - version: 2.1.27 + version: 2.1.28 react: specifier: 'catalog:' version: 19.2.1 @@ -419,7 +422,7 @@ importers: version: 24.10.1 arktype: specifier: 'catalog:' - version: 2.1.27 + version: 2.1.28 size-limit: specifier: 'catalog:' version: 11.2.0 @@ -453,7 +456,7 @@ importers: version: 1.3.3 arktype: specifier: 'catalog:' - version: 2.1.27 + version: 2.1.28 bun: specifier: 'catalog:' version: 1.3.3 @@ -474,7 +477,7 @@ importers: devDependencies: arktype: specifier: 'catalog:' - version: 2.1.27 + version: 2.1.28 typescript: specifier: 'catalog:' version: 5.9.3 @@ -493,7 +496,7 @@ importers: version: 11.2.0(size-limit@11.2.0) arktype: specifier: 'catalog:' - version: 2.1.27 + version: 2.1.28 size-limit: specifier: 'catalog:' version: 11.2.0 @@ -550,9 +553,6 @@ packages: '@apm-js-collab/tracing-hooks@0.3.1': resolution: {integrity: sha512-Vu1CbmPURlN5fTboVuKMoJjbO5qcq9fA5YXpskx3dXe/zTBvjODFoerw+69rVBlRLrJpwPqSDqEuJDEKIrTldw==} - '@ark/schema@0.55.0': - resolution: {integrity: sha512-IlSIc0FmLKTDGr4I/FzNHauMn0MADA6bCjT1wauu4k6MyxhC1R9gz0olNpIRvK7lGGDwtc/VO0RUDNvVQW5WFg==} - '@ark/schema@0.56.0': resolution: {integrity: sha512-ECg3hox/6Z/nLajxXqNhgPtNdHWC9zNsDyskwO28WinoFEnWow4IsERNz9AnXRhTZJnYIlAJ4uGn3nlLk65vZA==} @@ -3871,15 +3871,9 @@ packages: peerDependencies: arktype: ^2.1.22 - arkregex@0.0.3: - resolution: {integrity: sha512-bU21QJOJEFJK+BPNgv+5bVXkvRxyAvgnon75D92newgHxkBJTgiFwQxusyViYyJkETsddPlHyspshDQcCzmkNg==} - arkregex@0.0.4: resolution: {integrity: sha512-biS/FkvSwQq59TZ453piUp8bxMui11pgOMV9WHAnli1F8o0ayNCZzUwQadL/bGIUic5TkS/QlPcyMuI8ZIwedQ==} - arktype@2.1.27: - resolution: {integrity: sha512-enctOHxI4SULBv/TDtCVi5M8oLd4J5SVlPUblXDzSsOYQNMzmVbUosGBnJuZDKmFlN5Ie0/QVEuTE+Z5X1UhsQ==} - arktype@2.1.28: resolution: {integrity: sha512-LVZqXl2zWRpNFnbITrtFmqeqNkPPo+KemuzbGSY6jvJwCb4v8NsDzrWOLHnQgWl26TkJeWWcUNUeBpq2Mst1/Q==} @@ -7604,6 +7598,9 @@ packages: zod@4.1.12: resolution: {integrity: sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==} + zod@4.1.13: + resolution: {integrity: sha512-AvvthqfqrAhNH9dnfmrfKzX5upOdjUVJYFqNSlkmGf64gRaTzlPwz99IHYnVs28qYAybvAlBV+H7pn0saFY4Ig==} + zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} @@ -7625,10 +7622,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@ark/schema@0.55.0': - dependencies: - '@ark/util': 0.55.0 - '@ark/schema@0.56.0': dependencies: '@ark/util': 0.56.0 @@ -11565,20 +11558,10 @@ snapshots: dependencies: arktype: 2.1.28 - arkregex@0.0.3: - dependencies: - '@ark/util': 0.55.0 - arkregex@0.0.4: dependencies: '@ark/util': 0.56.0 - arktype@2.1.27: - dependencies: - '@ark/schema': 0.55.0 - '@ark/util': 0.55.0 - arkregex: 0.0.3 - arktype@2.1.28: dependencies: '@ark/schema': 0.56.0 @@ -15824,4 +15807,6 @@ snapshots: zod@4.1.12: {} + zod@4.1.13: {} + zwitch@2.0.4: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 5b41a18cd..3c10c2136 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -18,7 +18,7 @@ catalog: "@types/react-dom": 19.2.3 "@vitejs/plugin-react": 5.1.1 "@vitest/ui": 4.0.15 - arktype: 2.1.27 + arktype: 2.1.28 bun: 1.3.3 concurrently: 9.2.1 globals: 16.5.0