From 1d823aea51b16a42c47cb24601e7e5a38a8e7938 Mon Sep 17 00:00:00 2001 From: Mihovil Ilakovac Date: Wed, 30 Oct 2024 14:53:27 +0100 Subject: [PATCH 1/5] Enable users to define their env vars --- .../templates/sdk/wasp/client/env.ts | 12 +++++++++- .../templates/sdk/wasp/server/env.ts | 11 +++++++++- .../wasp/server/jobs/core/pgBoss/pgBoss.ts | 3 +-- waspc/examples/todoApp/.env.server.example | 2 ++ waspc/examples/todoApp/main.wasp | 6 +++-- waspc/examples/todoApp/prettier.config.cjs | 6 +++++ waspc/examples/todoApp/prettier.config.js | 6 ----- waspc/examples/todoApp/src/App.tsx | 5 +---- waspc/examples/todoApp/src/clientSetup.js | 2 +- waspc/examples/todoApp/src/env.ts | 13 +++++++++++ waspc/examples/todoApp/src/serverSetup.ts | 6 ++--- waspc/src/Wasp/AppSpec/App/Client.hs | 3 ++- waspc/src/Wasp/AppSpec/App/Server.hs | 3 ++- .../Generator/SdkGenerator/EnvValidation.hs | 22 ++++++++++++++----- 14 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 waspc/examples/todoApp/prettier.config.cjs delete mode 100644 waspc/examples/todoApp/prettier.config.js create mode 100644 waspc/examples/todoApp/src/env.ts diff --git a/waspc/data/Generator/templates/sdk/wasp/client/env.ts b/waspc/data/Generator/templates/sdk/wasp/client/env.ts index 0de23660f4..6031b21875 100644 --- a/waspc/data/Generator/templates/sdk/wasp/client/env.ts +++ b/waspc/data/Generator/templates/sdk/wasp/client/env.ts @@ -3,7 +3,15 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const clientEnvSchema = z.object({ +{=# envValidationFn.isDefined =} +{=& envValidationFn.importStatement =} +const userClientEnvSchema = {= envValidationFn.importIdentifier =}() +{=/ envValidationFn.isDefined =} +{=^ envValidationFn.isDefined =} +const userClientEnvSchema = z.object({}) +{=/ envValidationFn.isDefined =} + +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', @@ -11,4 +19,6 @@ const clientEnvSchema = z.object({ .default('{= defaultServerUrl =}') }) +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema) + export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) diff --git a/waspc/data/Generator/templates/sdk/wasp/server/env.ts b/waspc/data/Generator/templates/sdk/wasp/server/env.ts index c80f1c37e3..92bd1feb50 100644 --- a/waspc/data/Generator/templates/sdk/wasp/server/env.ts +++ b/waspc/data/Generator/templates/sdk/wasp/server/env.ts @@ -3,7 +3,15 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const serverCommonSchema = z.object({ +{=# envValidationFn.isDefined =} +{=& envValidationFn.importStatement =} +const userServerEnvSchema = {= envValidationFn.importIdentifier =}() +{=/ envValidationFn.isDefined =} +{=^ envValidationFn.isDefined =} +const userServerEnvSchema = z.object({}) +{=/ envValidationFn.isDefined =} + +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default({= defaultServerPort =}), {= databaseUrlEnvVarName =}: z.string({ required_error: '{= databaseUrlEnvVarName =} is required', @@ -133,6 +141,7 @@ const serverProdSchema = z.object({ {=/ isAuthEnabled =} }) +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema) const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) diff --git a/waspc/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts b/waspc/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts index 0292f11176..eed0cf23cc 100644 --- a/waspc/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts +++ b/waspc/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts @@ -1,6 +1,5 @@ import PgBoss from 'pg-boss' -import { env } from '../../../env.js' -import { config } from '../../../index.js' +import { config, env } from '../../../index.js' const boss = createPgBoss() diff --git a/waspc/examples/todoApp/.env.server.example b/waspc/examples/todoApp/.env.server.example index 76df894076..08a8f0dd11 100644 --- a/waspc/examples/todoApp/.env.server.example +++ b/waspc/examples/todoApp/.env.server.example @@ -22,3 +22,5 @@ GITHUB_CLIENT_SECRET='dummy-gh-client-secret' # Dummy values here will allow app to run, but you will need real values to get Discord Auth to work. DISCORD_CLIENT_SECRET='dummy-discord-client-secret' DISCORD_CLIENT_ID='dummy-discord-client-id' + +MY_ENV_VAR=123 diff --git a/waspc/examples/todoApp/main.wasp b/waspc/examples/todoApp/main.wasp index 9cd2f4b1c6..7e32f29ad6 100644 --- a/waspc/examples/todoApp/main.wasp +++ b/waspc/examples/todoApp/main.wasp @@ -52,12 +52,14 @@ app todoApp { onAfterLogin: import { onAfterLogin } from "@src/auth/hooks.js", }, server: { - setupFn: import setup from "@src/serverSetup", + setupFn: import { setup } from "@src/serverSetup", middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup", + envValidationFn: import { serverEnvValidationFn } from "@src/env", }, client: { rootComponent: import { App } from "@src/App", - setupFn: import setup from "@src/clientSetup" + setupFn: import { setup } from "@src/clientSetup", + envValidationFn: import { clientEnvValidationFn } from "@src/env", }, db: { seeds: [ diff --git a/waspc/examples/todoApp/prettier.config.cjs b/waspc/examples/todoApp/prettier.config.cjs new file mode 100644 index 0000000000..0614ee70c6 --- /dev/null +++ b/waspc/examples/todoApp/prettier.config.cjs @@ -0,0 +1,6 @@ +module.exports = { + trailingComma: 'es5', + tabWidth: 2, + semi: false, + singleQuote: true, +} diff --git a/waspc/examples/todoApp/prettier.config.js b/waspc/examples/todoApp/prettier.config.js deleted file mode 100644 index abcda7180c..0000000000 --- a/waspc/examples/todoApp/prettier.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - trailingComma: 'es5', - tabWidth: 2, - semi: false, - singleQuote: true, -} diff --git a/waspc/examples/todoApp/src/App.tsx b/waspc/examples/todoApp/src/App.tsx index 0b8b3f2323..25b9867eb5 100644 --- a/waspc/examples/todoApp/src/App.tsx +++ b/waspc/examples/todoApp/src/App.tsx @@ -17,10 +17,7 @@ export function App() { const connectionIcon = isConnected ? '🟢' : '🔴' - // TODO: enable users to define their own client env vars - const appName = import.meta.env.REACT_APP_NAME - ? import.meta.env.REACT_APP_NAME - : 'TODO App' + const appName = env.REACT_APP_NAME return (
diff --git a/waspc/examples/todoApp/src/clientSetup.js b/waspc/examples/todoApp/src/clientSetup.js index 35a39dd00d..fc35f6ec82 100644 --- a/waspc/examples/todoApp/src/clientSetup.js +++ b/waspc/examples/todoApp/src/clientSetup.js @@ -1,7 +1,7 @@ import { testingAction } from 'wasp/client/operations' import { sayHi } from './util' -export default function setup() { +export function setup() { console.log('This was called from the client setup function') testingAction() sayHi() diff --git a/waspc/examples/todoApp/src/env.ts b/waspc/examples/todoApp/src/env.ts new file mode 100644 index 0000000000..10396f0d55 --- /dev/null +++ b/waspc/examples/todoApp/src/env.ts @@ -0,0 +1,13 @@ +import * as z from 'zod' + +export const serverEnvValidationFn = () => + z.object({ + MY_ENV_VAR: z.string({ + required_error: 'MY_ENV_VAR is required.', + }), + }) + +export const clientEnvValidationFn = () => + z.object({ + REACT_APP_NAME: z.string().default('TODO App'), + }) diff --git a/waspc/examples/todoApp/src/serverSetup.ts b/waspc/examples/todoApp/src/serverSetup.ts index 4d499763ab..1194f26cf0 100644 --- a/waspc/examples/todoApp/src/serverSetup.ts +++ b/waspc/examples/todoApp/src/serverSetup.ts @@ -14,7 +14,7 @@ let someResource: string | undefined = undefined export const getSomeResource = () => someResource -const setup: ServerSetupFn = async ({ app }) => { +export const setup: ServerSetupFn = async ({ app }) => { addCustomRoute(app) sayHi() @@ -34,6 +34,8 @@ const setup: ServerSetupFn = async ({ app }) => { 'submittedJob.pgBoss.details()', await submittedJob.pgBoss.details() ) + + console.log('Env var MY_ENV_VAR:', env.MY_ENV_VAR) } function addCustomRoute(app: Application) { @@ -52,5 +54,3 @@ export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => { ) return middlewareConfig } - -export default setup diff --git a/waspc/src/Wasp/AppSpec/App/Client.hs b/waspc/src/Wasp/AppSpec/App/Client.hs index 2764c9205d..46a244edc3 100644 --- a/waspc/src/Wasp/AppSpec/App/Client.hs +++ b/waspc/src/Wasp/AppSpec/App/Client.hs @@ -16,6 +16,7 @@ data Client = Client { setupFn :: Maybe ExtImport, rootComponent :: Maybe ExtImport, -- We expect the base dir to start with a slash e.g. /client - baseDir :: Maybe String + baseDir :: Maybe String, + envValidationFn :: Maybe ExtImport } deriving (Show, Eq, Data, Generic, FromJSON) diff --git a/waspc/src/Wasp/AppSpec/App/Server.hs b/waspc/src/Wasp/AppSpec/App/Server.hs index 89b9cee5e6..3bc7c68947 100644 --- a/waspc/src/Wasp/AppSpec/App/Server.hs +++ b/waspc/src/Wasp/AppSpec/App/Server.hs @@ -14,6 +14,7 @@ import Wasp.AppSpec.ExtImport (ExtImport) data Server = Server { setupFn :: Maybe ExtImport, - middlewareConfigFn :: Maybe ExtImport + middlewareConfigFn :: Maybe ExtImport, + envValidationFn :: Maybe ExtImport } deriving (Show, Eq, Data, Generic, FromJSON) diff --git a/waspc/src/Wasp/Generator/SdkGenerator/EnvValidation.hs b/waspc/src/Wasp/Generator/SdkGenerator/EnvValidation.hs index e7787d4ae2..d4ab5a373f 100644 --- a/waspc/src/Wasp/Generator/SdkGenerator/EnvValidation.hs +++ b/waspc/src/Wasp/Generator/SdkGenerator/EnvValidation.hs @@ -9,13 +9,17 @@ import Data.Maybe (isJust) import StrongPath (relfile) import Wasp.AppSpec (AppSpec) import qualified Wasp.AppSpec.App as AS.App +import qualified Wasp.AppSpec.App.Client as AS.App.Client import qualified Wasp.AppSpec.App.Dependency as AS.Dependency +import qualified Wasp.AppSpec.App.Server as AS.App.Server import Wasp.AppSpec.Valid (getApp) import qualified Wasp.Generator.AuthProviders as AuthProviders import qualified Wasp.Generator.EmailSenders as EmailSenders import Wasp.Generator.FileDraft (FileDraft) +import qualified Wasp.Generator.JsImport as GJI import Wasp.Generator.Monad (Generator) import qualified Wasp.Generator.SdkGenerator.Common as C +import Wasp.Generator.SdkGenerator.Server.OperationsGenerator (extImportToJsImport) import qualified Wasp.Generator.ServerGenerator.Common as Server import qualified Wasp.Generator.WebAppGenerator.Common as WebApp import qualified Wasp.Project.Db as Db @@ -24,7 +28,7 @@ genEnvValidation :: AppSpec -> Generator [FileDraft] genEnvValidation spec = sequence [ genServerEnv spec, - genClientEnv, + genClientEnv spec, genFileCopy [relfile|env/index.ts|] ] where @@ -43,17 +47,25 @@ genServerEnv spec = return $ C.mkTmplFdWithData tmplPath tmplData "defaultServerPort" .= Server.defaultServerPort, "enabledAuthProviders" .= (AuthProviders.getEnabledAuthProvidersJson <$> maybeAuth), "isEmailSenderUsed" .= isJust maybeEmailSender, - "enabledEmailSenders" .= (EmailSenders.getEnabledEmailProvidersJson <$> maybeEmailSender) + "enabledEmailSenders" .= (EmailSenders.getEnabledEmailProvidersJson <$> maybeEmailSender), + "envValidationFn" .= GJI.jsImportToImportJson (extImportToJsImport <$> maybeEnvValidationFn) ] maybeAuth = AS.App.auth app maybeEmailSender = AS.App.emailSender app + maybeEnvValidationFn = AS.App.server app >>= AS.App.Server.envValidationFn app = snd $ getApp spec -genClientEnv :: Generator FileDraft -genClientEnv = return $ C.mkTmplFdWithData tmplPath tmplData +genClientEnv :: AppSpec -> Generator FileDraft +genClientEnv spec = return $ C.mkTmplFdWithData tmplPath tmplData where tmplPath = [relfile|client/env.ts|] - tmplData = object ["defaultServerUrl" .= Server.defaultDevServerUrl] + tmplData = + object + [ "defaultServerUrl" .= Server.defaultDevServerUrl, + "envValidationFn" .= GJI.jsImportToImportJson (extImportToJsImport <$> maybeEnvValidationFn) + ] + maybeEnvValidationFn = AS.App.client app >>= AS.App.Client.envValidationFn + app = snd $ getApp spec depsRequiredByEnvValidation :: [AS.Dependency.Dependency] depsRequiredByEnvValidation = From 32f475ecebe18826c1fbb26ebb060be23a58a9a4 Mon Sep 17 00:00:00 2001 From: Mihovil Ilakovac Date: Wed, 30 Oct 2024 14:55:45 +0100 Subject: [PATCH 2/5] e2e tests --- .../waspBuild-golden/waspBuild/.wasp/build/.waspchecksums | 4 ++-- .../waspBuild/.wasp/build/sdk/wasp/client/env.ts | 6 +++++- .../waspBuild/.wasp/build/sdk/wasp/dist/client/env.js | 4 +++- .../waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map | 2 +- .../waspBuild/.wasp/build/sdk/wasp/dist/server/env.js | 4 +++- .../waspBuild/.wasp/build/sdk/wasp/dist/server/env.js.map | 2 +- .../waspBuild/.wasp/build/sdk/wasp/server/env.ts | 5 ++++- .../waspBuild/.wasp/out/sdk/wasp/client/env.ts | 6 +++++- .../waspBuild/.wasp/out/sdk/wasp/dist/client/env.js | 4 +++- .../waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../waspBuild/.wasp/out/sdk/wasp/dist/server/env.js | 4 +++- .../waspBuild/.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../waspBuild/.wasp/out/sdk/wasp/server/env.ts | 5 ++++- .../waspCompile-golden/waspCompile/.wasp/out/.waspchecksums | 4 ++-- .../waspCompile/.wasp/out/sdk/wasp/client/env.ts | 6 +++++- .../waspCompile/.wasp/out/sdk/wasp/dist/client/env.js | 4 +++- .../waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../waspCompile/.wasp/out/sdk/wasp/dist/server/env.js | 4 +++- .../waspCompile/.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../waspCompile/.wasp/out/sdk/wasp/server/env.ts | 5 ++++- .../waspComplexTest/.wasp/out/.waspchecksums | 6 +++--- .../waspComplexTest/.wasp/out/sdk/wasp/client/env.ts | 6 +++++- .../waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js | 4 +++- .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../waspComplexTest/.wasp/out/sdk/wasp/dist/server/env.js | 4 +++- .../.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js | 3 +-- .../out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map | 2 +- .../waspComplexTest/.wasp/out/sdk/wasp/server/env.ts | 5 ++++- .../.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts | 3 +-- .../waspJob-golden/waspJob/.wasp/out/.waspchecksums | 6 +++--- .../waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env.ts | 6 +++++- .../waspJob/.wasp/out/sdk/wasp/dist/client/env.js | 4 +++- .../waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../waspJob/.wasp/out/sdk/wasp/dist/server/env.js | 4 +++- .../waspJob/.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js | 3 +-- .../out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map | 2 +- .../waspJob-golden/waspJob/.wasp/out/sdk/wasp/server/env.ts | 5 ++++- .../.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts | 3 +-- .../waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums | 4 ++-- .../waspMigrate/.wasp/out/sdk/wasp/client/env.ts | 6 +++++- .../waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js | 4 +++- .../waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js | 4 +++- .../waspMigrate/.wasp/out/sdk/wasp/dist/server/env.js.map | 2 +- .../waspMigrate/.wasp/out/sdk/wasp/server/env.ts | 5 ++++- 47 files changed, 120 insertions(+), 58 deletions(-) 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 b80125b9b6..01b06d0d33 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" ], - "f630ded0392d5b60be93e1852f80ea8c75bc10262aee6fb106b6eb2561339362" + "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" ], [ [ @@ -270,7 +270,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "105527a58a272d1c51fc9e5368644aeb4d0df3aa65339b2212af49d9c1992d41" + "e38f20080e1b3f5c9a32f7c5d1cf3d058f360c7e759af73c9455502841cdd33c" ], [ [ 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 dfa9e70ee3..e533790d8e 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}) + +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', @@ -10,4 +12,6 @@ const clientEnvSchema = z.object({ .default('http://localhost:3001') }) +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema) + export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) 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 692179bc05..e6929526bc 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,11 +1,13 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}); +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', }) .default('http://localhost:3001') }); +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema); export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file 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 bde7e9e367..ceaad625f3 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,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,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,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 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 99c82bd75b..821b94d705 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,6 +1,7 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}); +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -45,6 +46,7 @@ const serverProdSchema = z.object({ WASP_SERVER_URL: serverUrlSchema, WASP_WEB_CLIENT_URL: clientUrlSchema, }); +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema); const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) 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 b118614980..6d31329712 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,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,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;IAC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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/server/env.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/server/env.ts index c48499a728..e7c5e3fb70 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}) + +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -53,6 +55,7 @@ const serverProdSchema = z.object({ WASP_WEB_CLIENT_URL: clientUrlSchema, }) +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema) const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) 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 dfa9e70ee3..e533790d8e 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}) + +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', @@ -10,4 +12,6 @@ const clientEnvSchema = z.object({ .default('http://localhost:3001') }) +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema) + export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) 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 692179bc05..e6929526bc 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,11 +1,13 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}); +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', }) .default('http://localhost:3001') }); +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema); export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file 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 bde7e9e367..ceaad625f3 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,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,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,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 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 99c82bd75b..821b94d705 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,6 +1,7 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}); +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -45,6 +46,7 @@ const serverProdSchema = z.object({ WASP_SERVER_URL: serverUrlSchema, WASP_WEB_CLIENT_URL: clientUrlSchema, }); +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema); const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) 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 b118614980..6d31329712 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,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACrC,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACrB,cAAc,EAAE,0BAA0B;KAC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,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/server/env.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/server/env.ts index c48499a728..e7c5e3fb70 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}) + +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -53,6 +55,7 @@ const serverProdSchema = z.object({ WASP_WEB_CLIENT_URL: clientUrlSchema, }) +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema) const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) 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 76f8bcf0c0..8649ec2baa 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" ], - "f630ded0392d5b60be93e1852f80ea8c75bc10262aee6fb106b6eb2561339362" + "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" ], [ [ @@ -270,7 +270,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "105527a58a272d1c51fc9e5368644aeb4d0df3aa65339b2212af49d9c1992d41" + "e38f20080e1b3f5c9a32f7c5d1cf3d058f360c7e759af73c9455502841cdd33c" ], [ [ 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 dfa9e70ee3..e533790d8e 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}) + +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', @@ -10,4 +12,6 @@ const clientEnvSchema = z.object({ .default('http://localhost:3001') }) +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema) + export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) 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 692179bc05..e6929526bc 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,11 +1,13 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}); +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', }) .default('http://localhost:3001') }); +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema); export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file 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 bde7e9e367..ceaad625f3 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,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,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,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 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 99c82bd75b..821b94d705 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,6 +1,7 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}); +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -45,6 +46,7 @@ const serverProdSchema = z.object({ WASP_SERVER_URL: serverUrlSchema, WASP_WEB_CLIENT_URL: clientUrlSchema, }); +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema); const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) 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 b118614980..6d31329712 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,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,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;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zC,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/server/env.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/server/env.ts index c48499a728..e7c5e3fb70 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}) + +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -53,6 +55,7 @@ const serverProdSchema = z.object({ WASP_WEB_CLIENT_URL: clientUrlSchema, }) +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema) const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) 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 f6a0c52eb3..a32d08228a 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" ], - "f630ded0392d5b60be93e1852f80ea8c75bc10262aee6fb106b6eb2561339362" + "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" ], [ [ @@ -669,7 +669,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "7fbf42a69723970df679ed0d89fc2c80e9d2bd3e433af73a838e3c1033ba459a" + "75019681fe3c0273d4e02bf1042549e4f5345bc3e64ccf465590710e01649f4a" ], [ [ @@ -697,7 +697,7 @@ "file", "../out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts" ], - "6ffb60e3dd86ebf2f83248d18e3d647018b3d583233c64259559221fe9d2c882" + "44ea6eb19cb4e283e24b4d3da1105539ef81cd36dfeb71d9fa5695f0b0c15b34" ], [ [ 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 dfa9e70ee3..e533790d8e 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}) + +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', @@ -10,4 +12,6 @@ const clientEnvSchema = z.object({ .default('http://localhost:3001') }) +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema) + export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) 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 692179bc05..e6929526bc 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,11 +1,13 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}); +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', }) .default('http://localhost:3001') }); +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema); export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file 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 bde7e9e367..ceaad625f3 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,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,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,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 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 691331476c..535d8a27f8 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,6 +1,7 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}); +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -57,6 +58,7 @@ const serverProdSchema = z.object({ WASP_WEB_CLIENT_URL: clientUrlSchema, JWT_SECRET: jwtTokenSchema, }); +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema); const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) 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 9ef87fe808..f00b7a2da3 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,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAA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,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/dist/server/jobs/core/pgBoss/pgBoss.js b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js index de0a202c7f..8fe6f220bc 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js @@ -1,6 +1,5 @@ import PgBoss from 'pg-boss'; -import { env } from '../../../env.js'; -import { config } from '../../../index.js'; +import { config, env } from '../../../index.js'; const boss = createPgBoss(); function createPgBoss() { let pgBossNewOptions = { diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map index 7080f1ddba..c87ccbfc48 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map @@ -1 +1 @@ -{"version":3,"file":"pgBoss.js","sourceRoot":"","sources":["../../../../../server/jobs/core/pgBoss/pgBoss.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,MAAM,IAAI,GAAG,YAAY,EAAE,CAAA;AAE3B,SAAS,YAAY;IACnB,IAAI,gBAAgB,GAAG;QACrB,gBAAgB,EAAE,MAAM,CAAC,WAAW;KACrC,CAAA;IAED,uFAAuF;IACvF,IAAI,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;QACxD,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,CAAC,KAAK,CACX,4EAA4E,CAC7E,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;AACrC,CAAC;AAED,IAAI,oBAA4C,CAAA;AAChD,IAAI,mBAA2C,CAAA;AAC/C,cAAc;AACd,yEAAyE;AACzE,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IACnE,oBAAoB,GAAG,OAAO,CAAA;IAC9B,mBAAmB,GAAG,MAAM,CAAA;AAC9B,CAAC,CAAC,CAAA;AAEF,IAAK,YAKJ;AALD,WAAK,YAAY;IACf,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;IACrB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;AACjB,CAAC,EALI,YAAY,KAAZ,YAAY,QAKhB;AAED,IAAI,YAAY,GAAiB,YAAY,CAAC,SAAS,CAAA;AAEvD,cAAc;AACd;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,sEAAsE;IACtE,IAAI,YAAY,KAAK,YAAY,CAAC,SAAS,EAAE,CAAC;QAC5C,OAAM;IACR,CAAC;IACD,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAA;IACpC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;IAElC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IACjD,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;QACzC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,YAAY,GAAG,YAAY,CAAC,KAAK,CAAA;QACjC,mBAAmB,CAAC,IAAI,CAAC,CAAA;QACzB,OAAM;IACR,CAAC;IAED,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAE1B,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/B,YAAY,GAAG,YAAY,CAAC,OAAO,CAAA;AACrC,CAAC"} \ No newline at end of file +{"version":3,"file":"pgBoss.js","sourceRoot":"","sources":["../../../../../server/jobs/core/pgBoss/pgBoss.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,MAAM,IAAI,GAAG,YAAY,EAAE,CAAA;AAE3B,SAAS,YAAY;IACnB,IAAI,gBAAgB,GAAG;QACrB,gB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,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;QACzC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,YAAY,GAAG,YAAY,CAAC,KAAK,CAAA;QACjC,mBAAmB,CAAC,IAAI,CAAC,CAAA;QACzB,OAAM;IACR,CAAC;IAED,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAE1B,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/B,YAAY,GAAG,YAAY,CAAC,OAAO,CAAA;AACrC,CAAC"} \ No newline at end of file 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 7b6ef4cafd..32dd97a952 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}) + +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -65,6 +67,7 @@ const serverProdSchema = z.object({ JWT_SECRET: jwtTokenSchema, }) +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema) const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts index 0292f11176..eed0cf23cc 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts @@ -1,6 +1,5 @@ import PgBoss from 'pg-boss' -import { env } from '../../../env.js' -import { config } from '../../../index.js' +import { config, env } from '../../../index.js' const boss = createPgBoss() 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 7bf5e3abbe..9b69b98b7c 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" ], - "f630ded0392d5b60be93e1852f80ea8c75bc10262aee6fb106b6eb2561339362" + "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" ], [ [ @@ -277,7 +277,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "105527a58a272d1c51fc9e5368644aeb4d0df3aa65339b2212af49d9c1992d41" + "e38f20080e1b3f5c9a32f7c5d1cf3d058f360c7e759af73c9455502841cdd33c" ], [ [ @@ -305,7 +305,7 @@ "file", "../out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts" ], - "6ffb60e3dd86ebf2f83248d18e3d647018b3d583233c64259559221fe9d2c882" + "44ea6eb19cb4e283e24b4d3da1105539ef81cd36dfeb71d9fa5695f0b0c15b34" ], [ [ 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 dfa9e70ee3..e533790d8e 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}) + +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', @@ -10,4 +12,6 @@ const clientEnvSchema = z.object({ .default('http://localhost:3001') }) +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema) + export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) 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 692179bc05..e6929526bc 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,11 +1,13 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}); +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', }) .default('http://localhost:3001') }); +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema); export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file 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 bde7e9e367..ceaad625f3 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,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,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,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 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 99c82bd75b..821b94d705 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,6 +1,7 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}); +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -45,6 +46,7 @@ const serverProdSchema = z.object({ WASP_SERVER_URL: serverUrlSchema, WASP_WEB_CLIENT_URL: clientUrlSchema, }); +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema); const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) 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 b118614980..6d31329712 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,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,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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/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js index de0a202c7f..8fe6f220bc 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js @@ -1,6 +1,5 @@ import PgBoss from 'pg-boss'; -import { env } from '../../../env.js'; -import { config } from '../../../index.js'; +import { config, env } from '../../../index.js'; const boss = createPgBoss(); function createPgBoss() { let pgBossNewOptions = { diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map index 7080f1ddba..c87ccbfc48 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/core/pgBoss/pgBoss.js.map @@ -1 +1 @@ -{"version":3,"file":"pgBoss.js","sourceRoot":"","sources":["../../../../../server/jobs/core/pgBoss/pgBoss.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,MAAM,IAAI,GAAG,YAAY,EAAE,CAAA;AAE3B,SAAS,YAAY;IACnB,IAAI,gBAAgB,GAAG;QACrB,gBAAgB,EAAE,MAAM,CAAC,WAAW;KACrC,CAAA;IAED,uFAAuF;IACvF,IAAI,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;QACxD,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,CAAC,KA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;QACzB,OAAM;IACR,CAAC;IAED,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAE1B,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/B,YAAY,GAAG,YAAY,CAAC,OAAO,CAAA;AACrC,CAAC"} \ No newline at end of file +{"version":3,"file":"pgBoss.js","sourceRoot":"","sources":["../../../../../server/jobs/core/pgBoss/pgBoss.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,MAAM,IAAI,GAAG,YAAY,EAAE,CAAA;AAE3B,SAAS,YAAY;IACnB,IAAI,gBAAgB,GAAG;QACrB,gBAAgB,EAAE,MAAM,CAAC,WAAW;KACrC,CAAA;IAED,uFAAuF;IACvF,IAAI,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;QACxD,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,CAAC,KAAK,CACX,4EAA4E,CAC7E,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;AACrC,CAAC;AAED,IAAI,oBAA4C,CAAA;AAChD,IAAI,mBAA2C,CAAA;AAC/C,cAAc;AACd,yEAAyE;AACzE,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IACnE,oBAAoB,GAAG,OAAO,CAAA;IAC9B,mBAAmB,GAAG,MAAM,CAAA;AAC9B,CAAC,CAAC,CAAA;AAEF,IAAK,YAKJ;AALD,WAAK,YAAY;IACf,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;IACrB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;AACjB,CAAC,EALI,YAAY,KAAZ,YAAY,QAKhB;AAED,IAAI,YAAY,GAAiB,YAAY,CAAC,SAAS,CAAA;AAEvD,cAAc;AACd;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,sEAAsE;IACtE,IAAI,YAAY,KAAK,YAAY,CAAC,SAAS,EAAE,CAAC;QAC5C,OAAM;IACR,CAAC;IACD,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAA;IACpC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;IAElC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IACjD,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;QACzC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,YAAY,GAAG,YAAY,CAAC,KAAK,CAAA;QACjC,mBAAmB,CAAC,IAAI,CAAC,CAAA;QACzB,OAAM;IACR,CAAC;IAED,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAE1B,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/B,YAAY,GAAG,YAAY,CAAC,OAAO,CAAA;AACrC,CAAC"} \ No newline at end of file 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 c48499a728..e7c5e3fb70 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}) + +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -53,6 +55,7 @@ const serverProdSchema = z.object({ WASP_WEB_CLIENT_URL: clientUrlSchema, }) +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema) const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts index 0292f11176..eed0cf23cc 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts @@ -1,6 +1,5 @@ import PgBoss from 'pg-boss' -import { env } from '../../../env.js' -import { config } from '../../../index.js' +import { config, env } from '../../../index.js' const boss = createPgBoss() 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 20f263b827..7da9ae9d09 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" ], - "f630ded0392d5b60be93e1852f80ea8c75bc10262aee6fb106b6eb2561339362" + "8bfc7818c7f133b91ec4bed709575172e226f7f09dcc2ab9bf45754f0af3b229" ], [ [ @@ -270,7 +270,7 @@ "file", "../out/sdk/wasp/server/env.ts" ], - "105527a58a272d1c51fc9e5368644aeb4d0df3aa65339b2212af49d9c1992d41" + "e38f20080e1b3f5c9a32f7c5d1cf3d058f360c7e759af73c9455502841cdd33c" ], [ [ 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 dfa9e70ee3..e533790d8e 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}) + +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', @@ -10,4 +12,6 @@ const clientEnvSchema = z.object({ .default('http://localhost:3001') }) +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema) + export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) 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 692179bc05..e6929526bc 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,11 +1,13 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ +const userClientEnvSchema = z.object({}); +const waspClientEnvSchema = z.object({ REACT_APP_API_URL: z .string({ required_error: 'REACT_APP_API_URL is required', }) .default('http://localhost:3001') }); +const clientEnvSchema = waspClientEnvSchema.merge(userClientEnvSchema); export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file 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 bde7e9e367..ceaad625f3 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,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,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,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 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 99c82bd75b..821b94d705 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,6 +1,7 @@ import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}); +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -45,6 +46,7 @@ const serverProdSchema = z.object({ WASP_SERVER_URL: serverUrlSchema, WASP_WEB_CLIENT_URL: clientUrlSchema, }); +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema); const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) 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 b118614980..6d31329712 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,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,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;AAEJ,2EAA2E;AAC3E,yCAAyC;AACzC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,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AAM,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/server/env.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/server/env.ts index c48499a728..e7c5e3fb70 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 @@ -2,7 +2,9 @@ import * as z from 'zod' import { ensureEnvSchema } from '../env/index.js' -const serverCommonSchema = z.object({ +const userServerEnvSchema = z.object({}) + +const waspServerCommonSchema = z.object({ PORT: z.coerce.number().default(3001), DATABASE_URL: z.string({ required_error: 'DATABASE_URL is required', @@ -53,6 +55,7 @@ const serverProdSchema = z.object({ WASP_WEB_CLIENT_URL: clientUrlSchema, }) +const serverCommonSchema = waspServerCommonSchema.merge(userServerEnvSchema) const serverEnvSchema = z.discriminatedUnion('NODE_ENV', [ serverDevSchema.merge(serverCommonSchema), serverProdSchema.merge(serverCommonSchema) From f0ffeec0418a0aab3dcb7fdb692b6d0cfadd7d4a Mon Sep 17 00:00:00 2001 From: Mihovil Ilakovac Date: Wed, 30 Oct 2024 15:08:44 +0100 Subject: [PATCH 3/5] Fixes unit tests --- waspc/test/AnalyzerTest.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/waspc/test/AnalyzerTest.hs b/waspc/test/AnalyzerTest.hs index 6b145d7478..babdb3f9f4 100644 --- a/waspc/test/AnalyzerTest.hs +++ b/waspc/test/AnalyzerTest.hs @@ -164,7 +164,8 @@ spec_Analyzer = do ExtImport (ExtImportField "setupServer") (fromJust $ SP.parseRelFileP "bar.js"), - Server.middlewareConfigFn = Nothing + Server.middlewareConfigFn = Nothing, + Server.envValidationFn = Nothing }, App.client = Just @@ -175,7 +176,8 @@ spec_Analyzer = do Client.rootComponent = Just $ ExtImport (ExtImportField "App") (fromJust $ SP.parseRelFileP "App.jsx"), - Client.baseDir = Just "/" + Client.baseDir = Just "/", + Client.envValidationFn = Nothing }, App.db = Just From c46f96145b976781779af26ab42c0f668e75d437 Mon Sep 17 00:00:00 2001 From: Mihovil Ilakovac Date: Wed, 30 Oct 2024 19:35:28 +0100 Subject: [PATCH 4/5] Add EnvValidationFn user facing type --- .../templates/sdk/wasp/client/env.ts | 2 +- .../Generator/templates/sdk/wasp/env/index.ts | 30 ++----------------- .../templates/sdk/wasp/env/validation.ts | 28 +++++++++++++++++ .../Generator/templates/sdk/wasp/package.json | 1 + .../templates/sdk/wasp/server/env.ts | 2 +- waspc/examples/todoApp/src/env.ts | 5 ++-- .../Generator/SdkGenerator/EnvValidation.hs | 3 +- 7 files changed, 38 insertions(+), 33 deletions(-) create mode 100644 waspc/data/Generator/templates/sdk/wasp/env/validation.ts diff --git a/waspc/data/Generator/templates/sdk/wasp/client/env.ts b/waspc/data/Generator/templates/sdk/wasp/client/env.ts index 6031b21875..610acde509 100644 --- a/waspc/data/Generator/templates/sdk/wasp/client/env.ts +++ b/waspc/data/Generator/templates/sdk/wasp/client/env.ts @@ -1,7 +1,7 @@ {{={= =}=}} import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' {=# envValidationFn.isDefined =} {=& envValidationFn.importStatement =} diff --git a/waspc/data/Generator/templates/sdk/wasp/env/index.ts b/waspc/data/Generator/templates/sdk/wasp/env/index.ts index 713aa49386..2a99979b11 100644 --- a/waspc/data/Generator/templates/sdk/wasp/env/index.ts +++ b/waspc/data/Generator/templates/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/data/Generator/templates/sdk/wasp/env/validation.ts b/waspc/data/Generator/templates/sdk/wasp/env/validation.ts new file mode 100644 index 0000000000..04eeb88b03 --- /dev/null +++ b/waspc/data/Generator/templates/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/data/Generator/templates/sdk/wasp/package.json b/waspc/data/Generator/templates/sdk/wasp/package.json index 5995a7e777..440c10e913 100644 --- a/waspc/data/Generator/templates/sdk/wasp/package.json +++ b/waspc/data/Generator/templates/sdk/wasp/package.json @@ -109,6 +109,7 @@ "./client/test": "./dist/client/test/index.js", "./client": "./dist/client/index.js", "./dev": "./dist/dev/index.js", + "./env": "./dist/env/index.js", {=! todo(filip): Fixes below are for type errors in 0.13.1, remove ASAP =} {=! Used by our code (SDK for full-stack type safety), uncodumented (but accessible) for users. =} diff --git a/waspc/data/Generator/templates/sdk/wasp/server/env.ts b/waspc/data/Generator/templates/sdk/wasp/server/env.ts index 92bd1feb50..f4ece2a27c 100644 --- a/waspc/data/Generator/templates/sdk/wasp/server/env.ts +++ b/waspc/data/Generator/templates/sdk/wasp/server/env.ts @@ -1,7 +1,7 @@ {{={= =}=}} import * as z from 'zod' -import { ensureEnvSchema } from '../env/index.js' +import { ensureEnvSchema } from '../env/validation.js' {=# envValidationFn.isDefined =} {=& envValidationFn.importStatement =} diff --git a/waspc/examples/todoApp/src/env.ts b/waspc/examples/todoApp/src/env.ts index 10396f0d55..bd74293604 100644 --- a/waspc/examples/todoApp/src/env.ts +++ b/waspc/examples/todoApp/src/env.ts @@ -1,13 +1,14 @@ import * as z from 'zod' +import type { EnvValidationFn } from 'wasp/env' -export const serverEnvValidationFn = () => +export const serverEnvValidationFn: EnvValidationFn = () => z.object({ MY_ENV_VAR: z.string({ required_error: 'MY_ENV_VAR is required.', }), }) -export const clientEnvValidationFn = () => +export const clientEnvValidationFn: EnvValidationFn = () => z.object({ REACT_APP_NAME: z.string().default('TODO App'), }) diff --git a/waspc/src/Wasp/Generator/SdkGenerator/EnvValidation.hs b/waspc/src/Wasp/Generator/SdkGenerator/EnvValidation.hs index d4ab5a373f..37f43e17f7 100644 --- a/waspc/src/Wasp/Generator/SdkGenerator/EnvValidation.hs +++ b/waspc/src/Wasp/Generator/SdkGenerator/EnvValidation.hs @@ -29,7 +29,8 @@ genEnvValidation spec = sequence [ genServerEnv spec, genClientEnv spec, - genFileCopy [relfile|env/index.ts|] + genFileCopy [relfile|env/index.ts|], + genFileCopy [relfile|env/validation.ts|] ] where genFileCopy = return . C.mkTmplFd From c606b6b2d5ac300575c3c80998def16b0f5a8f07 Mon Sep 17 00:00:00 2001 From: Mihovil Ilakovac Date: Wed, 30 Oct 2024 19:42:54 +0100 Subject: [PATCH 5/5] 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,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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BAAkB,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;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,KA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AC,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,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,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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,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,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC;QACzB,cAAc,EAAE,8BAA8B;KAC/C,CAAC;IACF,8BAA8B,EAAE,CAAC;SAC9B,IAAI,CAA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C,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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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,MA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spMigrate/.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