From c606b6b2d5ac300575c3c80998def16b0f5a8f07 Mon Sep 17 00:00:00 2001 From: Mihovil Ilakovac Date: Wed, 30 Oct 2024 19:42:54 +0100 Subject: [PATCH] Update env validation fn type usage --- .../waspBuild-golden/files.manifest | 8 +++++ .../waspBuild/.wasp/build/.waspchecksums | 15 +++++++--- .../.wasp/build/sdk/wasp/client/env.ts | 2 +- .../.wasp/build/sdk/wasp/dist/client/env.js | 2 +- .../build/sdk/wasp/dist/client/env.js.map | 2 +- .../.wasp/build/sdk/wasp/dist/env/index.d.ts | 4 +-- .../.wasp/build/sdk/wasp/dist/env/index.js | 27 +---------------- .../build/sdk/wasp/dist/env/index.js.map | 2 +- .../build/sdk/wasp/dist/env/validation.d.ts | 2 ++ .../build/sdk/wasp/dist/env/validation.js | 26 ++++++++++++++++ .../build/sdk/wasp/dist/env/validation.js.map | 1 + .../.wasp/build/sdk/wasp/dist/server/env.js | 2 +- .../build/sdk/wasp/dist/server/env.js.map | 2 +- .../.wasp/build/sdk/wasp/env/index.ts | 30 ++----------------- .../.wasp/build/sdk/wasp/env/validation.ts | 28 +++++++++++++++++ .../.wasp/build/sdk/wasp/package.json | 1 + .../.wasp/build/sdk/wasp/server/env.ts | 2 +- .../.wasp/out/sdk/wasp/client/env.ts | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../.wasp/out/sdk/wasp/dist/env/index.d.ts | 4 +-- .../.wasp/out/sdk/wasp/dist/env/index.js | 27 +---------------- .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../out/sdk/wasp/dist/env/validation.d.ts | 2 ++ .../.wasp/out/sdk/wasp/dist/env/validation.js | 26 ++++++++++++++++ .../out/sdk/wasp/dist/env/validation.js.map | 1 + .../.wasp/out/sdk/wasp/dist/server/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../waspBuild/.wasp/out/sdk/wasp/env/index.ts | 30 ++----------------- .../.wasp/out/sdk/wasp/env/validation.ts | 28 +++++++++++++++++ .../waspBuild/.wasp/out/sdk/wasp/package.json | 1 + .../.wasp/out/sdk/wasp/server/env.ts | 2 +- .../waspCompile-golden/files.manifest | 4 +++ .../waspCompile/.wasp/out/.waspchecksums | 15 +++++++--- .../.wasp/out/sdk/wasp/client/env.ts | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../.wasp/out/sdk/wasp/dist/env/index.d.ts | 4 +-- .../.wasp/out/sdk/wasp/dist/env/index.js | 27 +---------------- .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../out/sdk/wasp/dist/env/validation.d.ts | 2 ++ .../.wasp/out/sdk/wasp/dist/env/validation.js | 26 ++++++++++++++++ .../out/sdk/wasp/dist/env/validation.js.map | 1 + .../.wasp/out/sdk/wasp/dist/server/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../.wasp/out/sdk/wasp/env/index.ts | 30 ++----------------- .../.wasp/out/sdk/wasp/env/validation.ts | 28 +++++++++++++++++ .../.wasp/out/sdk/wasp/package.json | 1 + .../.wasp/out/sdk/wasp/server/env.ts | 2 +- .../waspComplexTest-golden/files.manifest | 4 +++ .../waspComplexTest/.wasp/out/.waspchecksums | 15 +++++++--- .../.wasp/out/sdk/wasp/client/env.ts | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../.wasp/out/sdk/wasp/dist/env/index.d.ts | 4 +-- .../.wasp/out/sdk/wasp/dist/env/index.js | 27 +---------------- .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../out/sdk/wasp/dist/env/validation.d.ts | 2 ++ .../.wasp/out/sdk/wasp/dist/env/validation.js | 26 ++++++++++++++++ .../out/sdk/wasp/dist/env/validation.js.map | 1 + .../.wasp/out/sdk/wasp/dist/server/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../.wasp/out/sdk/wasp/env/index.ts | 30 ++----------------- .../.wasp/out/sdk/wasp/env/validation.ts | 28 +++++++++++++++++ .../.wasp/out/sdk/wasp/package.json | 1 + .../.wasp/out/sdk/wasp/server/env.ts | 2 +- .../waspJob-golden/files.manifest | 4 +++ .../waspJob/.wasp/out/.waspchecksums | 15 +++++++--- .../waspJob/.wasp/out/sdk/wasp/client/env.ts | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../.wasp/out/sdk/wasp/dist/env/index.d.ts | 4 +-- .../.wasp/out/sdk/wasp/dist/env/index.js | 27 +---------------- .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../out/sdk/wasp/dist/env/validation.d.ts | 2 ++ .../.wasp/out/sdk/wasp/dist/env/validation.js | 26 ++++++++++++++++ .../out/sdk/wasp/dist/env/validation.js.map | 1 + .../.wasp/out/sdk/wasp/dist/server/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../waspJob/.wasp/out/sdk/wasp/env/index.ts | 30 ++----------------- .../.wasp/out/sdk/wasp/env/validation.ts | 28 +++++++++++++++++ .../waspJob/.wasp/out/sdk/wasp/package.json | 1 + .../waspJob/.wasp/out/sdk/wasp/server/env.ts | 2 +- .../waspMigrate-golden/files.manifest | 4 +++ .../waspMigrate/.wasp/out/.waspchecksums | 15 +++++++--- .../.wasp/out/sdk/wasp/client/env.ts | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../.wasp/out/sdk/wasp/dist/env/index.d.ts | 4 +-- .../.wasp/out/sdk/wasp/dist/env/index.js | 27 +---------------- .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../out/sdk/wasp/dist/env/validation.d.ts | 2 ++ .../.wasp/out/sdk/wasp/dist/env/validation.js | 26 ++++++++++++++++ .../out/sdk/wasp/dist/env/validation.js.map | 1 + .../.wasp/out/sdk/wasp/dist/server/env.js | 2 +- .../.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../.wasp/out/sdk/wasp/env/index.ts | 30 ++----------------- .../.wasp/out/sdk/wasp/env/validation.ts | 28 +++++++++++++++++ .../.wasp/out/sdk/wasp/package.json | 1 + .../.wasp/out/sdk/wasp/server/env.ts | 2 +- waspc/examples/todoApp/src/env.ts | 8 ++--- 101 files changed, 503 insertions(+), 402 deletions(-) create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js.map create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/validation.ts create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js.map create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/validation.ts create mode 100644 waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js create mode 100644 waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js.map create mode 100644 waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/validation.ts create mode 100644 waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js create mode 100644 waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js.map create mode 100644 waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/validation.ts create mode 100644 waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.js create mode 100644 waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.js.map create mode 100644 waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/validation.ts create mode 100644 waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js create mode 100644 waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js.map create mode 100644 waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/validation.ts diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest b/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest index fdefab5e0d..4c99052cf1 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest @@ -106,6 +106,9 @@ waspBuild/.wasp/build/sdk/wasp/dist/entities/index.js.map waspBuild/.wasp/build/sdk/wasp/dist/env/index.d.ts waspBuild/.wasp/build/sdk/wasp/dist/env/index.js waspBuild/.wasp/build/sdk/wasp/dist/env/index.js.map +waspBuild/.wasp/build/sdk/wasp/dist/env/validation.d.ts +waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js +waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js.map waspBuild/.wasp/build/sdk/wasp/dist/ext-src/MainPage.d.ts waspBuild/.wasp/build/sdk/wasp/dist/ext-src/MainPage.jsx waspBuild/.wasp/build/sdk/wasp/dist/ext-src/MainPage.jsx.map @@ -174,6 +177,7 @@ waspBuild/.wasp/build/sdk/wasp/dist/universal/validators.js waspBuild/.wasp/build/sdk/wasp/dist/universal/validators.js.map waspBuild/.wasp/build/sdk/wasp/entities/index.ts waspBuild/.wasp/build/sdk/wasp/env/index.ts +waspBuild/.wasp/build/sdk/wasp/env/validation.ts waspBuild/.wasp/build/sdk/wasp/ext-src/Main.css waspBuild/.wasp/build/sdk/wasp/ext-src/MainPage.jsx waspBuild/.wasp/build/sdk/wasp/ext-src/vite-env.d.ts @@ -346,6 +350,9 @@ waspBuild/.wasp/out/sdk/wasp/dist/entities/index.js.map waspBuild/.wasp/out/sdk/wasp/dist/env/index.d.ts waspBuild/.wasp/out/sdk/wasp/dist/env/index.js waspBuild/.wasp/out/sdk/wasp/dist/env/index.js.map +waspBuild/.wasp/out/sdk/wasp/dist/env/validation.d.ts +waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js +waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js.map waspBuild/.wasp/out/sdk/wasp/dist/ext-src/MainPage.d.ts waspBuild/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx waspBuild/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx.map @@ -414,6 +421,7 @@ waspBuild/.wasp/out/sdk/wasp/dist/universal/validators.js waspBuild/.wasp/out/sdk/wasp/dist/universal/validators.js.map waspBuild/.wasp/out/sdk/wasp/entities/index.ts waspBuild/.wasp/out/sdk/wasp/env/index.ts +waspBuild/.wasp/out/sdk/wasp/env/validation.ts waspBuild/.wasp/out/sdk/wasp/ext-src/Main.css waspBuild/.wasp/out/sdk/wasp/ext-src/MainPage.jsx waspBuild/.wasp/out/sdk/wasp/ext-src/vite-env.d.ts diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums index 01b06d0d33..8a88f748dc 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums @@ -25,7 +25,7 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" + "20166d488967dca6605440e3e5f9c2fa69366ae7da2c4604303056dab395c5e3" ], [ [ @@ -179,7 +179,14 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "84a5ba04975efaade7e14b8a58d962bfa234b502d3993d3edf73cf7db85e3e42" + "6e150a0fa5a288d13b8700ad0d33122e073bbdc63a3a97f838aa26aa8e3cafa9" + ], + [ + [ + "file", + "../out/sdk/wasp/env/validation.ts" + ], + "6b8052c668824c4198aec6185e2c795807b0c4b39edee66e6494417e8f9e7769" ], [ [ @@ -214,7 +221,7 @@ "file", "../out/sdk/wasp/package.json" ], - "9f8844eca690b66c914179693b7f7beedef8b7c8fe2016d9d7353d474cea3d56" + "b991fb5ade61a662dea3f21bf09aa30379f30ea76204a369c0800b1413256a64" ], [ [ @@ -270,7 +277,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "e38f20080e1b3f5c9a32f7c5d1cf3d058f360c7e759af73c9455502841cdd33c" + "3de8487f53dda511c07f1a9509389a60d715743e5f7342b56e134e93069f3ac0" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env.ts index e533790d8e..7ffeaea457 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userClientEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js index e6929526bc..8e12baec33 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userClientEnvSchema = z.object({}); const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map index ceaad625f3..36f75af25b 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.d.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.d.ts index 6bc9d059a3..091ab90c67 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.d.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.d.ts @@ -1,2 +1,2 @@ -import * as z from 'zod'; -export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; +import type { ZodObject } from 'zod'; +export type EnvValidationFn = () => ZodObject; diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js index 36c04180f7..f8a711af8c 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js @@ -1,27 +1,2 @@ -import * as z from 'zod'; -const redColor = '\x1b[31m'; -export function ensureEnvSchema(data, schema) { - try { - return schema.parse(data); - } - catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error(); - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error(); - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`); - } - console.error(); - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables'); - } - else { - throw e; - } - } -} +export {}; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js.map index 71eefab95e..79d6b8864f 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,mEAAmE;QACnE,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.d.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.d.ts new file mode 100644 index 0000000000..6bc9d059a3 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.d.ts @@ -0,0 +1,2 @@ +import * as z from 'zod'; +export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js new file mode 100644 index 0000000000..af3bd973f0 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js @@ -0,0 +1,26 @@ +import * as z from 'zod'; +const redColor = '\x1b[31m'; +export function ensureEnvSchema(data, schema) { + try { + return schema.parse(data); + } + catch (e) { + if (e instanceof z.ZodError) { + console.error(); + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error(); + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`); + } + console.error(); + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables'); + } + else { + throw e; + } + } +} +//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js.map new file mode 100644 index 0000000000..558f17d813 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/validation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../env/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/server/env.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/server/env.js index 821b94d705..1180a269d4 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/server/env.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/server/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userServerEnvSchema = z.object({}); const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/server/env.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/server/env.js.map index 6d31329712..074edda300 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/server/env.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/server/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../server/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACrC,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACrB,cAAc,EAAE,0BAA0B;KAC3C,CAAC;IACF,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1C,8BAA8B,EAAE,CAAC;SAC9B,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;QACvB,OAAO,EAAE,iEAAiE;KAC3E,CAAC;SACD,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC;SACtC,OAAO,CAAC,OAAO,CAAC;CACpB,CAAC,CAAA;AAEF,MAAM,e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B,OAAO,CAAC,uBAAuB,CAAC;IACnC,mBAAmB,EAAE,eAAe;SACjC,OAAO,CAAC,wBAAwB,CAAC;CACrC,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACjC,eAAe,EAAE,eAAe;IAChC,mBAAmB,EAAE,eAAe;CACrC,CAAC,CAAA;AAEF,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAC5E,MAAM,eAAe,GAAG,CAAC,CAAC,kBAAkB,CAAC,UAAU,EAAE;IACvD,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACzC,gBAAgB,CAAC,KAAK,CAAC,kBAAkB,CAAC;CAC3C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/index.ts index 713aa49386..2a99979b11 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/index.ts @@ -1,29 +1,3 @@ -import * as z from 'zod' +import type { ZodObject } from 'zod' -const redColor = '\x1b[31m' - -export function ensureEnvSchema( - data: unknown, - schema: Schema -): z.infer { - try { - return schema.parse(data) - } catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error() - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error() - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`) - } - console.error() - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables') - } else { - throw e - } - } -} +export type EnvValidationFn = () => ZodObject diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/validation.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/validation.ts new file mode 100644 index 0000000000..04eeb88b03 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/validation.ts @@ -0,0 +1,28 @@ +import * as z from 'zod' + +const redColor = '\x1b[31m' + +export function ensureEnvSchema( + data: unknown, + schema: Schema +): z.infer { + try { + return schema.parse(data) + } catch (e) { + if (e instanceof z.ZodError) { + console.error() + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error() + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`) + } + console.error() + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables') + } else { + throw e + } + } +} diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/package.json index 10a54b5d6e..55c07a5084 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/package.json @@ -51,6 +51,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/server/env.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/server/env.ts index e7c5e3fb70..5f6a4805c3 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/server/env.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/server/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userServerEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env.ts index e533790d8e..7ffeaea457 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userClientEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js index e6929526bc..8e12baec33 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userClientEnvSchema = z.object({}); const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map index ceaad625f3..36f75af25b 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.d.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.d.ts index 6bc9d059a3..091ab90c67 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.d.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.d.ts @@ -1,2 +1,2 @@ -import * as z from 'zod'; -export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; +import type { ZodObject } from 'zod'; +export type EnvValidationFn = () => ZodObject; diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js index 36c04180f7..f8a711af8c 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,27 +1,2 @@ -import * as z from 'zod'; -const redColor = '\x1b[31m'; -export function ensureEnvSchema(data, schema) { - try { - return schema.parse(data); - } - catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error(); - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error(); - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`); - } - console.error(); - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables'); - } - else { - throw e; - } - } -} +export {}; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js.map index 71eefab95e..79d6b8864f 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,mEAAmE;QACnE,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.d.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.d.ts new file mode 100644 index 0000000000..6bc9d059a3 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.d.ts @@ -0,0 +1,2 @@ +import * as z from 'zod'; +export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js new file mode 100644 index 0000000000..af3bd973f0 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js @@ -0,0 +1,26 @@ +import * as z from 'zod'; +const redColor = '\x1b[31m'; +export function ensureEnvSchema(data, schema) { + try { + return schema.parse(data); + } + catch (e) { + if (e instanceof z.ZodError) { + console.error(); + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error(); + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`); + } + console.error(); + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables'); + } + else { + throw e; + } + } +} +//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js.map new file mode 100644 index 0000000000..558f17d813 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/validation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../env/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/server/env.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/server/env.js index 821b94d705..1180a269d4 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/server/env.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/server/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userServerEnvSchema = z.object({}); const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/server/env.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/server/env.js.map index 6d31329712..074edda300 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/server/env.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/server/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../server/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC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J,MAAM,eAAe,GAAG,CAAC;KACtB,MAAM,CAAC;IACN,cAAc,EAAE,iCAAiC;CAClD,CAAC;KACD,GAAG,CAAC;IACH,OAAO,EAAE,yCAAyC;CACnD,CAAC,CAAA;AAEJ,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,CAAC;IACN,cAAc,EAAE,wBAAwB;CACzC,CAAC,CAAA;AAEJ,2EAA2E;AAC3E,yCAAyC;AACzC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IAClC,eAAe,EAAE,eAAe;SAC7B,OAAO,CAAC,uBAAuB,CAAC;IACnC,mBAAmB,EAAE,eAAe;SACjC,OAAO,CAAC,wBAAwB,CAAC;CACrC,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACjC,eAAe,EAAE,eAAe;IAChC,mBAAmB,EAAE,eAAe;CACrC,CAAC,CAAA;AAEF,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAC5E,MAAM,eAAe,GAAG,CAAC,CAAC,kBAAkB,CAAC,UAAU,EAAE;IACvD,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACzC,gBAAgB,CAAC,KAAK,CAAC,kBAAkB,CAAC;CAC3C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/index.ts index 713aa49386..2a99979b11 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/index.ts @@ -1,29 +1,3 @@ -import * as z from 'zod' +import type { ZodObject } from 'zod' -const redColor = '\x1b[31m' - -export function ensureEnvSchema( - data: unknown, - schema: Schema -): z.infer { - try { - return schema.parse(data) - } catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error() - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error() - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`) - } - console.error() - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables') - } else { - throw e - } - } -} +export type EnvValidationFn = () => ZodObject diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/validation.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/validation.ts new file mode 100644 index 0000000000..04eeb88b03 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/validation.ts @@ -0,0 +1,28 @@ +import * as z from 'zod' + +const redColor = '\x1b[31m' + +export function ensureEnvSchema( + data: unknown, + schema: Schema +): z.infer { + try { + return schema.parse(data) + } catch (e) { + if (e instanceof z.ZodError) { + console.error() + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error() + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`) + } + console.error() + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables') + } else { + throw e + } + } +} diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/package.json index 10a54b5d6e..55c07a5084 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/package.json @@ -51,6 +51,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/server/env.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/server/env.ts index e7c5e3fb70..5f6a4805c3 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/server/env.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/server/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userServerEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest b/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest index c142de0718..094633692c 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest @@ -105,6 +105,9 @@ waspCompile/.wasp/out/sdk/wasp/dist/entities/index.js.map waspCompile/.wasp/out/sdk/wasp/dist/env/index.d.ts waspCompile/.wasp/out/sdk/wasp/dist/env/index.js waspCompile/.wasp/out/sdk/wasp/dist/env/index.js.map +waspCompile/.wasp/out/sdk/wasp/dist/env/validation.d.ts +waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js +waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js.map waspCompile/.wasp/out/sdk/wasp/dist/ext-src/MainPage.d.ts waspCompile/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx waspCompile/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx.map @@ -173,6 +176,7 @@ waspCompile/.wasp/out/sdk/wasp/dist/universal/validators.js waspCompile/.wasp/out/sdk/wasp/dist/universal/validators.js.map waspCompile/.wasp/out/sdk/wasp/entities/index.ts waspCompile/.wasp/out/sdk/wasp/env/index.ts +waspCompile/.wasp/out/sdk/wasp/env/validation.ts waspCompile/.wasp/out/sdk/wasp/ext-src/Main.css waspCompile/.wasp/out/sdk/wasp/ext-src/MainPage.jsx waspCompile/.wasp/out/sdk/wasp/ext-src/vite-env.d.ts diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums index 8649ec2baa..44e0dda41f 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums @@ -25,7 +25,7 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" + "20166d488967dca6605440e3e5f9c2fa69366ae7da2c4604303056dab395c5e3" ], [ [ @@ -179,7 +179,14 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "84a5ba04975efaade7e14b8a58d962bfa234b502d3993d3edf73cf7db85e3e42" + "6e150a0fa5a288d13b8700ad0d33122e073bbdc63a3a97f838aa26aa8e3cafa9" + ], + [ + [ + "file", + "../out/sdk/wasp/env/validation.ts" + ], + "6b8052c668824c4198aec6185e2c795807b0c4b39edee66e6494417e8f9e7769" ], [ [ @@ -214,7 +221,7 @@ "file", "../out/sdk/wasp/package.json" ], - "9f8844eca690b66c914179693b7f7beedef8b7c8fe2016d9d7353d474cea3d56" + "b991fb5ade61a662dea3f21bf09aa30379f30ea76204a369c0800b1413256a64" ], [ [ @@ -270,7 +277,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "e38f20080e1b3f5c9a32f7c5d1cf3d058f360c7e759af73c9455502841cdd33c" + "3de8487f53dda511c07f1a9509389a60d715743e5f7342b56e134e93069f3ac0" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env.ts index e533790d8e..7ffeaea457 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userClientEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js index e6929526bc..8e12baec33 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userClientEnvSchema = z.object({}); const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map index ceaad625f3..36f75af25b 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.d.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.d.ts index 6bc9d059a3..091ab90c67 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.d.ts +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.d.ts @@ -1,2 +1,2 @@ -import * as z from 'zod'; -export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; +import type { ZodObject } from 'zod'; +export type EnvValidationFn = () => ZodObject; diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js index 36c04180f7..f8a711af8c 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,27 +1,2 @@ -import * as z from 'zod'; -const redColor = '\x1b[31m'; -export function ensureEnvSchema(data, schema) { - try { - return schema.parse(data); - } - catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error(); - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error(); - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`); - } - console.error(); - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables'); - } - else { - throw e; - } - } -} +export {}; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js.map index 71eefab95e..79d6b8864f 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,mEAAmE;QACnE,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.d.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.d.ts new file mode 100644 index 0000000000..6bc9d059a3 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.d.ts @@ -0,0 +1,2 @@ +import * as z from 'zod'; +export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js new file mode 100644 index 0000000000..af3bd973f0 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js @@ -0,0 +1,26 @@ +import * as z from 'zod'; +const redColor = '\x1b[31m'; +export function ensureEnvSchema(data, schema) { + try { + return schema.parse(data); + } + catch (e) { + if (e instanceof z.ZodError) { + console.error(); + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error(); + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`); + } + console.error(); + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables'); + } + else { + throw e; + } + } +} +//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js.map b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js.map new file mode 100644 index 0000000000..558f17d813 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/validation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../env/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/server/env.js b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/server/env.js index 821b94d705..1180a269d4 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/server/env.js +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/server/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userServerEnvSchema = z.object({}); const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/server/env.js.map b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/server/env.js.map index 6d31329712..074edda300 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/server/env.js.map +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/server/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../server/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACrC,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACrB,cAAc,EAAE,0BAA0B;KAC3C,CAAC;IACF,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAA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,CAAA;AAEJ,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,CAAC;IACN,cAAc,EAAE,wBAAwB;CACzC,CAAC,CAAA;AAEJ,2EAA2E;AAC3E,yCAAyC;AACzC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IAClC,eAAe,EAAE,eAAe;SAC7B,OAAO,CAAC,uBAAuB,CAAC;IACnC,mBAAmB,EAAE,eAAe;SACjC,OAAO,CAAC,wBAAwB,CAAC;CACrC,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACjC,eAAe,EAAE,eAAe;IAChC,mBAAmB,EAAE,eAAe;CACrC,CAAC,CAAA;AAEF,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAC5E,MAAM,eAAe,GAAG,CAAC,CAAC,kBAAkB,CAAC,UAAU,EAAE;IACvD,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACzC,gBAAgB,CAAC,KAAK,CAAC,kBAAkB,CAAC;CAC3C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/index.ts index 713aa49386..2a99979b11 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/index.ts @@ -1,29 +1,3 @@ -import * as z from 'zod' +import type { ZodObject } from 'zod' -const redColor = '\x1b[31m' - -export function ensureEnvSchema( - data: unknown, - schema: Schema -): z.infer { - try { - return schema.parse(data) - } catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error() - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error() - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`) - } - console.error() - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables') - } else { - throw e - } - } -} +export type EnvValidationFn = () => ZodObject diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/validation.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/validation.ts new file mode 100644 index 0000000000..04eeb88b03 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/validation.ts @@ -0,0 +1,28 @@ +import * as z from 'zod' + +const redColor = '\x1b[31m' + +export function ensureEnvSchema( + data: unknown, + schema: Schema +): z.infer { + try { + return schema.parse(data) + } catch (e) { + if (e instanceof z.ZodError) { + console.error() + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error() + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`) + } + console.error() + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables') + } else { + throw e + } + } +} diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/package.json index 10a54b5d6e..55c07a5084 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/package.json @@ -51,6 +51,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/server/env.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/server/env.ts index e7c5e3fb70..5f6a4805c3 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/server/env.ts +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/server/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userServerEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest b/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest index 5368cb869a..c941bee978 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest @@ -231,6 +231,9 @@ waspComplexTest/.wasp/out/sdk/wasp/dist/entities/index.js.map waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.d.ts waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js.map +waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.d.ts +waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js +waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js.map waspComplexTest/.wasp/out/sdk/wasp/dist/ext-src/MainPage.d.ts waspComplexTest/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx waspComplexTest/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx.map @@ -401,6 +404,7 @@ waspComplexTest/.wasp/out/sdk/wasp/dist/universal/validators.js waspComplexTest/.wasp/out/sdk/wasp/dist/universal/validators.js.map waspComplexTest/.wasp/out/sdk/wasp/entities/index.ts waspComplexTest/.wasp/out/sdk/wasp/env/index.ts +waspComplexTest/.wasp/out/sdk/wasp/env/validation.ts waspComplexTest/.wasp/out/sdk/wasp/ext-src/Main.css waspComplexTest/.wasp/out/sdk/wasp/ext-src/MainPage.jsx waspComplexTest/.wasp/out/sdk/wasp/ext-src/auth/hooks.ts diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums index a32d08228a..55ea7c3de6 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums @@ -228,7 +228,7 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" + "20166d488967dca6605440e3e5f9c2fa69366ae7da2c4604303056dab395c5e3" ], [ [ @@ -396,7 +396,14 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "84a5ba04975efaade7e14b8a58d962bfa234b502d3993d3edf73cf7db85e3e42" + "6e150a0fa5a288d13b8700ad0d33122e073bbdc63a3a97f838aa26aa8e3cafa9" + ], + [ + [ + "file", + "../out/sdk/wasp/env/validation.ts" + ], + "6b8052c668824c4198aec6185e2c795807b0c4b39edee66e6494417e8f9e7769" ], [ [ @@ -501,7 +508,7 @@ "file", "../out/sdk/wasp/package.json" ], - "e9daaa0fd911e4211651d99935e3191bbc17f33d1c5f8e5e9960fef5a2b0497f" + "f481b1b2cb68f26b7496bfcc92dfd80958fb01b013853f9fd1a36672a117acd8" ], [ [ @@ -669,7 +676,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "75019681fe3c0273d4e02bf1042549e4f5345bc3e64ccf465590710e01649f4a" + "d2e735469946788ad621cfe8a78876aeed6b4b8a3c782658e01ba9ce056a8d08" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env.ts index e533790d8e..7ffeaea457 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userClientEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js index e6929526bc..8e12baec33 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userClientEnvSchema = z.object({}); const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js.map index ceaad625f3..36f75af25b 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.d.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.d.ts index 6bc9d059a3..091ab90c67 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.d.ts +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.d.ts @@ -1,2 +1,2 @@ -import * as z from 'zod'; -export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; +import type { ZodObject } from 'zod'; +export type EnvValidationFn = () => ZodObject; diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js index 36c04180f7..f8a711af8c 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,27 +1,2 @@ -import * as z from 'zod'; -const redColor = '\x1b[31m'; -export function ensureEnvSchema(data, schema) { - try { - return schema.parse(data); - } - catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error(); - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error(); - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`); - } - console.error(); - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables'); - } - else { - throw e; - } - } -} +export {}; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js.map index 71eefab95e..79d6b8864f 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,mEAAmE;QACnE,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.d.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.d.ts new file mode 100644 index 0000000000..6bc9d059a3 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.d.ts @@ -0,0 +1,2 @@ +import * as z from 'zod'; +export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js new file mode 100644 index 0000000000..af3bd973f0 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js @@ -0,0 +1,26 @@ +import * as z from 'zod'; +const redColor = '\x1b[31m'; +export function ensureEnvSchema(data, schema) { + try { + return schema.parse(data); + } + catch (e) { + if (e instanceof z.ZodError) { + console.error(); + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error(); + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`); + } + console.error(); + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables'); + } + else { + throw e; + } + } +} +//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js.map b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js.map new file mode 100644 index 0000000000..558f17d813 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/validation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../env/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/env.js b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/env.js index 535d8a27f8..44e4924ba0 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/env.js +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userServerEnvSchema = z.object({}); const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/env.js.map b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/env.js.map index f00b7a2da3..f4d9d25ab7 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/env.js.map +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../server/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,OA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AAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACjC,eAAe,EAAE,eAAe;IAChC,mBAAmB,EAAE,eAAe;IACpC,UAAU,EAAE,cAAc;CAC3B,CAAC,CAAA;AAEF,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAC5E,MAAM,eAAe,GAAG,CAAC,CAAC,kBAAkB,CAAC,UAAU,EAAE;IACvD,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACzC,gBAAgB,CAAC,KAAK,CAAC,kBAAkB,CAAC;CAC3C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/index.ts index 713aa49386..2a99979b11 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/index.ts @@ -1,29 +1,3 @@ -import * as z from 'zod' +import type { ZodObject } from 'zod' -const redColor = '\x1b[31m' - -export function ensureEnvSchema( - data: unknown, - schema: Schema -): z.infer { - try { - return schema.parse(data) - } catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error() - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error() - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`) - } - console.error() - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables') - } else { - throw e - } - } -} +export type EnvValidationFn = () => ZodObject diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/validation.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/validation.ts new file mode 100644 index 0000000000..04eeb88b03 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/validation.ts @@ -0,0 +1,28 @@ +import * as z from 'zod' + +const redColor = '\x1b[31m' + +export function ensureEnvSchema( + data: unknown, + schema: Schema +): z.infer { + try { + return schema.parse(data) + } catch (e) { + if (e instanceof z.ZodError) { + console.error() + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error() + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`) + } + console.error() + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables') + } else { + throw e + } + } +} diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/package.json index 22e2c2d0e6..7fcae55c1d 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/package.json @@ -59,6 +59,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/server/env.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/server/env.ts index 32dd97a952..8fd05ca324 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/server/env.ts +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/server/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userServerEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest b/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest index 5a841ca13a..53038b06de 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest @@ -106,6 +106,9 @@ waspJob/.wasp/out/sdk/wasp/dist/entities/index.js.map waspJob/.wasp/out/sdk/wasp/dist/env/index.d.ts waspJob/.wasp/out/sdk/wasp/dist/env/index.js waspJob/.wasp/out/sdk/wasp/dist/env/index.js.map +waspJob/.wasp/out/sdk/wasp/dist/env/validation.d.ts +waspJob/.wasp/out/sdk/wasp/dist/env/validation.js +waspJob/.wasp/out/sdk/wasp/dist/env/validation.js.map waspJob/.wasp/out/sdk/wasp/dist/ext-src/MainPage.d.ts waspJob/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx waspJob/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx.map @@ -198,6 +201,7 @@ waspJob/.wasp/out/sdk/wasp/dist/universal/validators.js waspJob/.wasp/out/sdk/wasp/dist/universal/validators.js.map waspJob/.wasp/out/sdk/wasp/entities/index.ts waspJob/.wasp/out/sdk/wasp/env/index.ts +waspJob/.wasp/out/sdk/wasp/env/validation.ts waspJob/.wasp/out/sdk/wasp/ext-src/Main.css waspJob/.wasp/out/sdk/wasp/ext-src/MainPage.jsx waspJob/.wasp/out/sdk/wasp/ext-src/server/jobs/bar.js diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums index 9b69b98b7c..157696b21d 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums @@ -25,7 +25,7 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" + "20166d488967dca6605440e3e5f9c2fa69366ae7da2c4604303056dab395c5e3" ], [ [ @@ -179,7 +179,14 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "84a5ba04975efaade7e14b8a58d962bfa234b502d3993d3edf73cf7db85e3e42" + "6e150a0fa5a288d13b8700ad0d33122e073bbdc63a3a97f838aa26aa8e3cafa9" + ], + [ + [ + "file", + "../out/sdk/wasp/env/validation.ts" + ], + "6b8052c668824c4198aec6185e2c795807b0c4b39edee66e6494417e8f9e7769" ], [ [ @@ -221,7 +228,7 @@ "file", "../out/sdk/wasp/package.json" ], - "f045068da4d6b321ff13c7fe91eb01a10f98e7bf477edee21ab1621e95166bf7" + "489fe48bafdb9893ee52621efcdefee11132f532ff07c22c9cca41fcb09ae6f3" ], [ [ @@ -277,7 +284,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "e38f20080e1b3f5c9a32f7c5d1cf3d058f360c7e759af73c9455502841cdd33c" + "3de8487f53dda511c07f1a9509389a60d715743e5f7342b56e134e93069f3ac0" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env.ts index e533790d8e..7ffeaea457 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userClientEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js index e6929526bc..8e12baec33 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userClientEnvSchema = z.object({}); const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map index ceaad625f3..36f75af25b 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.d.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.d.ts index 6bc9d059a3..091ab90c67 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.d.ts +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.d.ts @@ -1,2 +1,2 @@ -import * as z from 'zod'; -export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; +import type { ZodObject } from 'zod'; +export type EnvValidationFn = () => ZodObject; diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js index 36c04180f7..f8a711af8c 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,27 +1,2 @@ -import * as z from 'zod'; -const redColor = '\x1b[31m'; -export function ensureEnvSchema(data, schema) { - try { - return schema.parse(data); - } - catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error(); - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error(); - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`); - } - console.error(); - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables'); - } - else { - throw e; - } - } -} +export {}; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js.map index 71eefab95e..79d6b8864f 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,mEAAmE;QACnE,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.d.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.d.ts new file mode 100644 index 0000000000..6bc9d059a3 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.d.ts @@ -0,0 +1,2 @@ +import * as z from 'zod'; +export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.js b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.js new file mode 100644 index 0000000000..af3bd973f0 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.js @@ -0,0 +1,26 @@ +import * as z from 'zod'; +const redColor = '\x1b[31m'; +export function ensureEnvSchema(data, schema) { + try { + return schema.parse(data); + } + catch (e) { + if (e instanceof z.ZodError) { + console.error(); + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error(); + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`); + } + console.error(); + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables'); + } + else { + throw e; + } + } +} +//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.js.map b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.js.map new file mode 100644 index 0000000000..558f17d813 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/validation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../env/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/env.js b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/env.js index 821b94d705..1180a269d4 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/env.js +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userServerEnvSchema = z.object({}); const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/env.js.map b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/env.js.map index 6d31329712..074edda300 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/env.js.map +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../server/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACrC,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACrB,cAAc,EAAE,0BAA0B;KAC3C,CAAC;IACF,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1C,8BAA8B,EAAE,CAAC;SAC9B,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;QACvB,OAAO,EAAE,iEAAiE;KAC3E,CAAC;SACD,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC;SACtC,OAAO,CAAC,OAAO,CAAC;CACpB,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,CAAC;KACtB,MAAM,CAAC;IACN,cAAc,EAAE,6BAA6B;CAC9C,CAAC;KACD,GAAG,CAAC;IACH,OAAO,EAAE,qCAAqC;CAC/C,CAAC,CAAA;AAEJ,MAAM,eAAe,GAAG,CAAC;KACtB,MAAM,CAAC;IACN,cAAc,EAAE,iCAAiC;CAClD,CAAC;KACD,GAAG,CAAC;IACH,OAAO,EAAE,yCAAyC;CACnD,CAAC,CAAA;AAEJ,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,CAAC;IACN,cAAc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,CAAC,CAAA;AAC5E,MAAM,eAAe,GAAG,CAAC,CAAC,kBAAkB,CAAC,UAAU,EAAE;IACvD,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACzC,gBAAgB,CAAC,KAAK,CAAC,kBAAkB,CAAC;CAC3C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/index.ts index 713aa49386..2a99979b11 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/index.ts @@ -1,29 +1,3 @@ -import * as z from 'zod' +import type { ZodObject } from 'zod' -const redColor = '\x1b[31m' - -export function ensureEnvSchema( - data: unknown, - schema: Schema -): z.infer { - try { - return schema.parse(data) - } catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error() - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error() - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`) - } - console.error() - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables') - } else { - throw e - } - } -} +export type EnvValidationFn = () => ZodObject diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/validation.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/validation.ts new file mode 100644 index 0000000000..04eeb88b03 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/validation.ts @@ -0,0 +1,28 @@ +import * as z from 'zod' + +const redColor = '\x1b[31m' + +export function ensureEnvSchema( + data: unknown, + schema: Schema +): z.infer { + try { + return schema.parse(data) + } catch (e) { + if (e instanceof z.ZodError) { + console.error() + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error() + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`) + } + console.error() + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables') + } else { + throw e + } + } +} diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/package.json index 096de35ddb..a78accf43a 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/package.json @@ -52,6 +52,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/server/env.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/server/env.ts index e7c5e3fb70..5f6a4805c3 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/server/env.ts +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/server/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userServerEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest b/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest index bd29970f97..8289971019 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest @@ -109,6 +109,9 @@ waspMigrate/.wasp/out/sdk/wasp/dist/entities/index.js.map waspMigrate/.wasp/out/sdk/wasp/dist/env/index.d.ts waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js.map +waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.d.ts +waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js +waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js.map waspMigrate/.wasp/out/sdk/wasp/dist/ext-src/MainPage.d.ts waspMigrate/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx waspMigrate/.wasp/out/sdk/wasp/dist/ext-src/MainPage.jsx.map @@ -177,6 +180,7 @@ waspMigrate/.wasp/out/sdk/wasp/dist/universal/validators.js waspMigrate/.wasp/out/sdk/wasp/dist/universal/validators.js.map waspMigrate/.wasp/out/sdk/wasp/entities/index.ts waspMigrate/.wasp/out/sdk/wasp/env/index.ts +waspMigrate/.wasp/out/sdk/wasp/env/validation.ts waspMigrate/.wasp/out/sdk/wasp/ext-src/Main.css waspMigrate/.wasp/out/sdk/wasp/ext-src/MainPage.jsx waspMigrate/.wasp/out/sdk/wasp/ext-src/vite-env.d.ts diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums index 7da9ae9d09..ab1aef7b35 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums @@ -25,7 +25,7 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" + "20166d488967dca6605440e3e5f9c2fa69366ae7da2c4604303056dab395c5e3" ], [ [ @@ -179,7 +179,14 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "84a5ba04975efaade7e14b8a58d962bfa234b502d3993d3edf73cf7db85e3e42" + "6e150a0fa5a288d13b8700ad0d33122e073bbdc63a3a97f838aa26aa8e3cafa9" + ], + [ + [ + "file", + "../out/sdk/wasp/env/validation.ts" + ], + "6b8052c668824c4198aec6185e2c795807b0c4b39edee66e6494417e8f9e7769" ], [ [ @@ -214,7 +221,7 @@ "file", "../out/sdk/wasp/package.json" ], - "9f8844eca690b66c914179693b7f7beedef8b7c8fe2016d9d7353d474cea3d56" + "b991fb5ade61a662dea3f21bf09aa30379f30ea76204a369c0800b1413256a64" ], [ [ @@ -270,7 +277,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "e38f20080e1b3f5c9a32f7c5d1cf3d058f360c7e759af73c9455502841cdd33c" + "3de8487f53dda511c07f1a9509389a60d715743e5f7342b56e134e93069f3ac0" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env.ts index e533790d8e..7ffeaea457 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userClientEnvSchema = z.object({}) diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js index e6929526bc..8e12baec33 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userClientEnvSchema = z.object({}); const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map index ceaad625f3..36f75af25b 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.d.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.d.ts index 6bc9d059a3..091ab90c67 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.d.ts +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.d.ts @@ -1,2 +1,2 @@ -import * as z from 'zod'; -export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; +import type { ZodObject } from 'zod'; +export type EnvValidationFn = () => ZodObject; diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js index 36c04180f7..f8a711af8c 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,27 +1,2 @@ -import * as z from 'zod'; -const redColor = '\x1b[31m'; -export function ensureEnvSchema(data, schema) { - try { - return schema.parse(data); - } - catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error(); - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error(); - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`); - } - console.error(); - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables'); - } - else { - throw e; - } - } -} +export {}; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js.map index 71eefab95e..79d6b8864f 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,mEAAmE;QACnE,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.d.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.d.ts new file mode 100644 index 0000000000..6bc9d059a3 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.d.ts @@ -0,0 +1,2 @@ +import * as z from 'zod'; +export declare function ensureEnvSchema(data: unknown, schema: Schema): z.infer; diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js new file mode 100644 index 0000000000..af3bd973f0 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js @@ -0,0 +1,26 @@ +import * as z from 'zod'; +const redColor = '\x1b[31m'; +export function ensureEnvSchema(data, schema) { + try { + return schema.parse(data); + } + catch (e) { + if (e instanceof z.ZodError) { + console.error(); + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error(); + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`); + } + console.error(); + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables'); + } + else { + throw e; + } + } +} +//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js.map b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js.map new file mode 100644 index 0000000000..558f17d813 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/validation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../env/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js index 821b94d705..1180a269d4 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js @@ -1,5 +1,5 @@ import * as z from 'zod'; -import { ensureEnvSchema } from '../env/index.js'; +import { ensureEnvSchema } from '../env/validation.js'; const userServerEnvSchema = z.object({}); const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js.map b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js.map index 6d31329712..074edda300 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js.map +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../server/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAExC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACrC,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACrB,cAAc,EAAE,0BAA0B;KAC3C,CAAC;IACF,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1C,8BAA8B,EAAE,CAAC;SAC9B,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;QACvB,OAAO,EAAE,iEAAiE;KAC3E,CAAC;SACD,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC;SACtC,OAAO,CAAC,OAAO,CAAC;CACpB,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,CAAC;KACtB,MAAM,CAAC;IACN,cAAc,EAAE,6BAA6B;CAC9C,CAAC;KACD,GAAG,CAAC;IACH,OAAO,EAAE,qCAAqC;CAC/C,CAAC,CAAA;AAEJ,MAAM,eAAe,GAAG,CAAC;KACtB,MAAM,CAAC;IACN,cAAc,EAAE,iCAAiC;CAClD,CAAC;KACD,GAAG,CAAC;IACH,OAAO,EAAE,yCAAyC;CACnD,CAAC,CAAA;AAEJ,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,CAAC;IACN,cAAc,EAAE,wBAAwB;CACzC,CAAC,CAAA;AA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G,CAAC,CAAC,kBAAkB,CAAC,UAAU,EAAE;IACvD,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACzC,gBAAgB,CAAC,KAAK,CAAC,kBAAkB,CAAC;CAC3C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/index.ts index 713aa49386..2a99979b11 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/index.ts @@ -1,29 +1,3 @@ -import * as z from 'zod' +import type { ZodObject } from 'zod' -const redColor = '\x1b[31m' - -export function ensureEnvSchema( - data: unknown, - schema: Schema -): z.infer { - try { - return schema.parse(data) - } catch (e) { - // TODO: figure out how to output the error message in a better way - if (e instanceof z.ZodError) { - console.error() - console.error(redColor, '╔═════════════════════════════╗'); - console.error(redColor, '║ Env vars validation failed ║'); - console.error(redColor, '╚═════════════════════════════╝'); - console.error() - for (const error of e.errors) { - console.error(redColor, `- ${error.message}`) - } - console.error() - console.error(redColor, '═══════════════════════════════'); - throw new Error('Error parsing environment variables') - } else { - throw e - } - } -} +export type EnvValidationFn = () => ZodObject diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/validation.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/validation.ts new file mode 100644 index 0000000000..04eeb88b03 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/validation.ts @@ -0,0 +1,28 @@ +import * as z from 'zod' + +const redColor = '\x1b[31m' + +export function ensureEnvSchema( + data: unknown, + schema: Schema +): z.infer { + try { + return schema.parse(data) + } catch (e) { + if (e instanceof z.ZodError) { + console.error() + console.error(redColor, '╔═════════════════════════════╗'); + console.error(redColor, '║ Env vars validation failed ║'); + console.error(redColor, '╚═════════════════════════════╝'); + console.error() + for (const error of e.errors) { + console.error(redColor, `- ${error.message}`) + } + console.error() + console.error(redColor, '═══════════════════════════════'); + throw new Error('Error parsing environment variables') + } else { + throw e + } + } +} diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/package.json index 10a54b5d6e..55c07a5084 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/package.json @@ -51,6 +51,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/server/env.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/server/env.ts index e7c5e3fb70..5f6a4805c3 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/server/env.ts +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/server/env.ts @@ -1,6 +1,6 @@ import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' const userServerEnvSchema = z.object({}) diff --git a/waspc/examples/todoApp/src/env.ts b/waspc/examples/todoApp/src/env.ts index bd74293604..1a7c4cb6e3 100644 --- a/waspc/examples/todoApp/src/env.ts +++ b/waspc/examples/todoApp/src/env.ts @@ -1,14 +1,14 @@ import * as z from 'zod' import type { EnvValidationFn } from 'wasp/env' -export const serverEnvValidationFn: EnvValidationFn = () => +export const serverEnvValidationFn = (() => z.object({ MY_ENV_VAR: z.string({ required_error: 'MY_ENV_VAR is required.', }), - }) + })) satisfies EnvValidationFn -export const clientEnvValidationFn: EnvValidationFn = () => +export const clientEnvValidationFn = (() => z.object({ REACT_APP_NAME: z.string().default('TODO App'), - }) + })) satisfies EnvValidationFn