@wasp.sh/wasp-cli-darwin-x64-unknown 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/Cli/starters/README.md +2 -0
- package/data/Cli/starters/basic/README.md +3 -3
- package/data/Cli/starters/basic/src/tags/components/CreateTagForm.tsx +2 -3
- package/data/Cli/starters/basic/vite.config.ts +0 -3
- package/data/Cli/starters/minimal/package.json +4 -1
- package/data/Cli/starters/minimal/vite.config.ts +0 -3
- package/data/Cli/starters/skeleton/AGENTS.md +6 -0
- package/data/Cli/starters/skeleton/CLAUDE.md +6 -0
- package/data/Cli/starters/skeleton/tsconfig.src.json +1 -11
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.26.0.tgz +0 -0
- package/data/Generator/libs/sdk-core/node_modules/@wasp.sh/lib-auth/wasp.sh-lib-auth-0.26.0.tgz +0 -0
- package/data/Generator/libs/sdk-core/wasp.sh-lib-sdk-core-0.26.0.tgz +0 -0
- package/data/Generator/libs/vite-ssr/{wasp.sh-lib-vite-ssr-0.25.0.tgz → wasp.sh-lib-vite-ssr-0.26.0.tgz} +0 -0
- package/data/Generator/templates/Dockerfile +1 -0
- package/data/Generator/templates/sdk/wasp/api/index.ts +5 -86
- package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +7 -6
- package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/Auth.tsx +12 -6
- package/data/Generator/templates/sdk/wasp/auth/forms/ForgotPassword.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/Login.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/ResetPassword.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/Signup.tsx +5 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/VerifyEmail.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.tsx +34 -33
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/DummyEmailSenderNotice.module.css +11 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/DummyEmailSenderNotice.tsx +17 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ForgotPasswordForm.tsx +9 -13
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ResetPasswordForm.tsx +8 -9
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/VerifyEmailForm.tsx +4 -8
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/useEmail.ts +5 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/usernameAndPassword/useUsernameAndPassword.ts +6 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/types.ts +0 -59
- package/data/Generator/templates/sdk/wasp/auth/helpers/_Provider.tsx +2 -2
- package/data/Generator/templates/sdk/wasp/auth/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/logout.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/providers/index.ts +4 -4
- package/data/Generator/templates/sdk/wasp/auth/providers/types.ts +20 -24
- package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +5 -5
- package/data/Generator/templates/sdk/wasp/auth/user.ts +147 -14
- package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +6 -5
- package/data/Generator/templates/sdk/wasp/auth/validation.ts +1 -83
- package/data/Generator/templates/sdk/wasp/client/app/pages/OAuthCallback.tsx +8 -5
- package/data/Generator/templates/sdk/wasp/client/app/pages/createAuthRequiredPage.jsx +6 -4
- package/data/Generator/templates/sdk/wasp/client/app/router.tsx +2 -2
- package/data/Generator/templates/sdk/wasp/client/auth/ui.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/auth/username.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/config.ts +1 -6
- package/data/Generator/templates/sdk/wasp/client/crud/_crud.ts +129 -75
- package/data/Generator/templates/sdk/wasp/client/env/schema.ts +14 -7
- package/data/Generator/templates/sdk/wasp/client/env.ts +4 -3
- package/data/Generator/templates/sdk/wasp/client/index.ts +3 -12
- package/data/Generator/templates/sdk/wasp/client/operations/actions/core.ts +14 -10
- package/data/Generator/templates/sdk/wasp/client/operations/actions/index.ts +7 -4
- package/data/Generator/templates/sdk/wasp/client/operations/index.ts +5 -5
- package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +1 -8
- package/data/Generator/templates/sdk/wasp/client/operations/queries/core.ts +13 -55
- package/data/Generator/templates/sdk/wasp/client/operations/queries/index.ts +7 -7
- package/data/Generator/templates/sdk/wasp/client/router/Link.tsx +8 -8
- package/data/Generator/templates/sdk/wasp/client/router/NavLink.tsx +8 -8
- package/data/Generator/templates/sdk/wasp/client/router/index.ts +15 -15
- package/data/Generator/templates/sdk/wasp/client/test/index.ts +2 -1
- package/data/Generator/templates/sdk/wasp/client/test/vitest/helpers.tsx +5 -36
- package/data/Generator/templates/sdk/wasp/client/vite/index.ts +2 -1
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/virtualUserModules.ts +43 -0
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/{virtualModules.ts → virtualWaspModules.ts} +4 -4
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/wasp.ts +17 -14
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/waspConfig.ts +60 -18
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/client-entry.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/routes.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/ssr-entry.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/client/webSocket/WebSocketProvider.tsx +3 -3
- package/data/Generator/templates/sdk/wasp/client/webSocket/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/core/serialization/index.ts +2 -47
- package/data/Generator/templates/sdk/wasp/core/serialization/prisma.ts +0 -1
- package/data/Generator/templates/sdk/wasp/entities/index.ts +6 -6
- package/data/Generator/templates/sdk/wasp/env/index.ts +1 -9
- package/data/Generator/templates/sdk/wasp/package.json +150 -104
- package/data/Generator/templates/sdk/wasp/server/_types/index.ts +8 -10
- package/data/Generator/templates/sdk/wasp/server/_types/taggedEntities.ts +4 -4
- package/data/Generator/templates/sdk/wasp/server/api/index.ts +5 -5
- package/data/Generator/templates/sdk/wasp/server/auth/email/index.ts +2 -12
- package/data/Generator/templates/sdk/wasp/server/auth/email/utils.ts +8 -30
- package/data/Generator/templates/sdk/wasp/server/auth/hooks.ts +5 -2
- package/data/Generator/templates/sdk/wasp/server/auth/index.ts +3 -3
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/jwt.ts +1 -1
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/lucia.ts +4 -4
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/oneTimeCode.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/discord.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/github.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/google.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/keycloak.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/microsoft.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/slack.ts +1 -1
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/session.ts +17 -6
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/utils.ts +40 -183
- package/data/Generator/templates/sdk/wasp/server/config.ts +1 -1
- package/data/Generator/templates/sdk/wasp/{core → server/core}/auth.ts +3 -3
- package/data/Generator/templates/sdk/wasp/server/crud/_operationTypes.ts +16 -63
- package/data/Generator/templates/sdk/wasp/server/dbClient.ts +15 -17
- package/data/Generator/templates/sdk/wasp/server/email/core/helpers.ts +3 -20
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/dummy.ts +2 -2
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/resend.ts +2 -1
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/smtp.ts +2 -1
- package/data/Generator/templates/sdk/wasp/server/email/core/types.ts +2 -45
- package/data/Generator/templates/sdk/wasp/server/email/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/env.ts +20 -11
- package/data/Generator/templates/sdk/wasp/server/index.ts +3 -3
- package/data/Generator/templates/sdk/wasp/server/jobs/_job.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBossJob.ts +4 -4
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/types.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/middleware/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/operations/actions/index.ts +14 -8
- package/data/Generator/templates/sdk/wasp/server/operations/actions/types.ts +5 -5
- package/data/Generator/templates/sdk/wasp/server/operations/queries/index.ts +14 -8
- package/data/Generator/templates/sdk/wasp/server/operations/queries/types.ts +5 -5
- package/data/Generator/templates/sdk/wasp/server/operations/wrappers.ts +40 -14
- package/data/Generator/templates/sdk/wasp/server/types/index.ts +1 -11
- package/data/Generator/templates/sdk/wasp/server/utils.ts +5 -20
- package/data/Generator/templates/sdk/wasp/server/webSocket/index.ts +7 -7
- package/data/Generator/templates/sdk/wasp/tsconfig.json +20 -46
- package/data/Generator/templates/sdk/wasp/types/index.ts +8 -0
- package/data/Generator/templates/sdk/wasp/types/register.ts +21 -0
- package/data/Generator/templates/sdk/wasp/vite-env.d.ts +0 -9
- package/data/Generator/templates/sdk/wasp/wasp-ssr.d.ts +8 -0
- package/data/Generator/templates/sdk/wasp/wasp-user-virtual-modules.d.ts +20 -0
- package/data/Generator/templates/server/package.json +2 -1
- package/data/Generator/templates/server/rollup.config.js +2 -43
- package/data/Generator/templates/server/rollup.dbSeed.config.js +3 -0
- package/data/Generator/templates/server/src/app.js +2 -2
- package/data/Generator/templates/server/src/auth/providers/config/email.ts +5 -5
- package/data/Generator/templates/server/src/auth/providers/email/login.ts +4 -4
- package/data/Generator/templates/server/src/auth/providers/email/requestPasswordReset.ts +4 -4
- package/data/Generator/templates/server/src/auth/providers/email/resetPassword.ts +13 -5
- package/data/Generator/templates/server/src/auth/providers/email/signup.ts +29 -18
- package/data/Generator/templates/server/src/auth/providers/email/verifyEmail.ts +7 -2
- package/data/Generator/templates/server/src/auth/providers/oauth/cookies.ts +5 -1
- package/data/Generator/templates/server/src/auth/providers/oauth/handler.ts +1 -1
- package/data/Generator/templates/server/src/auth/providers/oauth/oneTimeCode.ts +2 -2
- package/data/Generator/templates/server/src/auth/providers/oauth/state.ts +55 -13
- package/data/Generator/templates/server/src/auth/providers/oauth/user.ts +6 -3
- package/data/Generator/templates/server/src/auth/providers/username/login.ts +4 -4
- package/data/Generator/templates/server/src/auth/providers/username/signup.ts +12 -4
- package/data/Generator/templates/server/src/createRollupBundle.js +47 -0
- package/data/Generator/templates/server/src/crud/_operations.ts +16 -16
- package/data/Generator/templates/server/src/plugins/virtualUserModules.js +40 -0
- package/data/Generator/templates/server/src/routes/apis/index.ts +3 -3
- package/data/Generator/templates/server/src/routes/auth/index.js +1 -1
- package/data/Generator/templates/server/src/routes/auth/logout.ts +2 -2
- package/data/Generator/templates/server/src/routes/crud/_crud.ts +1 -1
- package/data/Generator/templates/server/src/routes/index.js +18 -18
- package/data/Generator/templates/server/src/routes/operations/index.js +1 -1
- package/data/Generator/templates/server/src/webSocket/initialization.ts +1 -1
- package/data/Generator/templates/server/tsconfig.json +7 -13
- package/data/Generator/templates/types/app/sdk/register.ts +57 -0
- package/data/packages/deploy/dist/common/cliVersion.js +17 -0
- package/data/packages/deploy/dist/common/waspProject.js +1 -1
- package/data/packages/deploy/dist/common/zx.js +24 -6
- package/data/packages/deploy/dist/providers/fly/commands/createDb/createDb.js +13 -5
- package/data/packages/deploy/dist/providers/fly/flyCli.js +29 -17
- package/data/packages/deploy/dist/providers/fly/index.js +16 -8
- package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +19 -31
- package/data/packages/deploy/dist/providers/railway/index.js +11 -2
- package/data/packages/deploy/dist/providers/railway/jsonOutputSchemas.js +19 -34
- package/data/packages/deploy/dist/providers/railway/railwayCli.js +11 -20
- package/data/packages/deploy/dist/providers/railway/railwayEnvironment/cli.js +20 -0
- package/data/packages/deploy/dist/providers/railway/railwayProject/RailwayProject.js +4 -1
- package/data/packages/deploy/dist/providers/railway/railwayProject/cli.js +6 -14
- package/data/packages/deploy/dist/providers/railway/railwayService/database.js +88 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/deployment.js +12 -25
- package/data/packages/deploy/dist/providers/railway/railwayService/nameGenerator.js +5 -4
- package/data/packages/deploy/dist/providers/railway/railwayService/serviceInstance.js +48 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/url.js +9 -30
- package/data/packages/deploy/package-lock.json +2 -2
- package/data/packages/deploy/package.json +1 -1
- package/data/packages/prisma/package-lock.json +2 -2
- package/data/packages/prisma/package.json +1 -1
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.js +19 -15
- package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.js +6 -0
- package/data/packages/spec/dist/src/appSpec.d.ts +15 -2
- package/data/packages/spec/dist/src/appSpec.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec/mapper/app.d.ts +1 -0
- package/data/packages/spec/dist/src/spec/mapper/app.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec/mapper/app.js +8 -2
- package/data/packages/spec/dist/src/spec/mapper/context.js +4 -4
- package/data/packages/spec/dist/src/spec/mapper/specElements.js +9 -9
- package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts +11 -11
- package/data/packages/spec/dist/src/spec/publicApi/constructors.js +11 -11
- package/data/packages/spec/dist/src/spec/publicApi/register.d.ts +1 -1
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts +58 -38
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts.map +1 -1
- package/data/packages/spec/package-lock.json +2 -2
- package/data/packages/spec/package.json +1 -1
- package/data/packages/studio/package-lock.json +15 -23
- package/data/packages/studio/package.json +2 -2
- package/package.json +1 -1
- package/wasp-bin +0 -0
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.25.0.tgz +0 -0
- package/data/Generator/templates/sdk/wasp/api/events.ts +0 -11
- package/data/Generator/templates/sdk/wasp/auth/email/index.ts +0 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.module.css +0 -99
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.tsx +0 -74
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.module.css +0 -22
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.tsx +0 -34
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/auth-styles.css +0 -30
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.module.css +0 -33
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.tsx +0 -14
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.module.css +0 -4
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.tsx +0 -85
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/util.ts +0 -16
- package/data/Generator/templates/sdk/wasp/auth/helpers/user.ts +0 -15
- package/data/Generator/templates/sdk/wasp/auth/responseSchemas.ts +0 -10
- package/data/Generator/templates/sdk/wasp/auth/types.ts +0 -2
- package/data/Generator/templates/sdk/wasp/auth/username/index.ts +0 -2
- package/data/Generator/templates/sdk/wasp/client/app/components/DefaultRootErrorBoundary.tsx +0 -16
- package/data/Generator/templates/sdk/wasp/client/app/components/FullPageWrapper.tsx +0 -21
- package/data/Generator/templates/sdk/wasp/client/app/components/Loader.module.css +0 -37
- package/data/Generator/templates/sdk/wasp/client/app/components/Loader.tsx +0 -12
- package/data/Generator/templates/sdk/wasp/client/app/components/Message.tsx +0 -86
- package/data/Generator/templates/sdk/wasp/client/crud/operationsHelpers.ts +0 -21
- package/data/Generator/templates/sdk/wasp/client/hooks.ts +0 -19
- package/data/Generator/templates/sdk/wasp/client/operations/hooks.ts +0 -347
- package/data/Generator/templates/sdk/wasp/client/operations/internal/resources.js +0 -85
- package/data/Generator/templates/sdk/wasp/client/operations/internal/updateHandlersMap.js +0 -37
- package/data/Generator/templates/sdk/wasp/client/operations/queryClient.ts +0 -34
- package/data/Generator/templates/sdk/wasp/client/operations/rpc.ts +0 -96
- package/data/Generator/templates/sdk/wasp/client/router/linkHelpers.ts +0 -48
- package/data/Generator/templates/sdk/wasp/client/router/types.ts +0 -98
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/detectServerImports.ts +0 -50
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/envFile.ts +0 -112
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/typescriptCheck.ts +0 -36
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/validateEnv.ts +0 -88
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/resolver.ts +0 -35
- package/data/Generator/templates/sdk/wasp/core/serialization/custom-register.ts +0 -21
- package/data/Generator/templates/sdk/wasp/core/storage.ts +0 -73
- package/data/Generator/templates/sdk/wasp/env/validation.ts +0 -44
- package/data/Generator/templates/sdk/wasp/server/HttpError.ts +0 -30
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/provider.ts +0 -20
- package/data/Generator/templates/sdk/wasp/server/auth/user.ts +0 -154
- package/data/Generator/templates/sdk/wasp/server/auth/username.ts +0 -1
- package/data/Generator/templates/sdk/wasp/server/jobs/core/job.ts +0 -28
- package/data/Generator/templates/sdk/wasp/server/middleware/globalMiddleware.ts +0 -8
- package/data/Generator/templates/sdk/wasp/universal/ansiColors.ts +0 -58
- package/data/Generator/templates/sdk/wasp/universal/predicates.ts +0 -3
- package/data/Generator/templates/sdk/wasp/universal/types.ts +0 -74
- package/data/Generator/templates/sdk/wasp/universal/url.ts +0 -9
- package/data/Generator/templates/sdk/wasp/universal/validators.ts +0 -21
- package/data/packages/ts-inspect/dist/exports.js +0 -82
- package/data/packages/ts-inspect/dist/index.js +0 -28
- package/data/packages/ts-inspect/package-lock.json +0 -4724
- package/data/packages/ts-inspect/package.json +0 -31
- /package/data/Generator/templates/sdk/wasp/{auth → server/auth}/password.ts +0 -0
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
RouteDefinitionsToRoutes,
|
|
5
|
-
OptionalRouteOptions,
|
|
6
|
-
ParamValue,
|
|
7
|
-
ExpandRouteOnOptionalStaticSegments,
|
|
8
|
-
} from '
|
|
2
|
+
import {
|
|
3
|
+
interpolatePath,
|
|
4
|
+
type RouteDefinitionsToRoutes,
|
|
5
|
+
type OptionalRouteOptions,
|
|
6
|
+
type ParamValue,
|
|
7
|
+
type ExpandRouteOnOptionalStaticSegments,
|
|
8
|
+
} from '@wasp.sh/lib-sdk-core'
|
|
9
9
|
|
|
10
10
|
// PUBLIC API
|
|
11
11
|
export const routes = {
|
|
12
12
|
{=# routes =}
|
|
13
13
|
{= name =}: {
|
|
14
|
-
to:
|
|
14
|
+
to: {=& urlPath =},
|
|
15
15
|
{=# hasUrlParams =}
|
|
16
16
|
build: (
|
|
17
17
|
options: OptionalRouteOptions
|
|
18
|
-
& { params: {{=# urlParams =}
|
|
18
|
+
& { params: {{=# urlParams =}{=& name =}{=# isOptional =}?{=/ isOptional =}: ParamValue;{=/ urlParams =}}}
|
|
19
19
|
{=# hasOptionalStaticSegments =}
|
|
20
|
-
& { path: ExpandRouteOnOptionalStaticSegments<
|
|
20
|
+
& { path: ExpandRouteOnOptionalStaticSegments<{=& urlPath =}> }
|
|
21
21
|
{=/ hasOptionalStaticSegments =}
|
|
22
22
|
) => interpolatePath(
|
|
23
23
|
{=# hasOptionalStaticSegments =}options.path,{=/ hasOptionalStaticSegments =}
|
|
24
|
-
{=^ hasOptionalStaticSegments =}
|
|
24
|
+
{=^ hasOptionalStaticSegments =}{=& urlPath =},{=/ hasOptionalStaticSegments =}
|
|
25
25
|
options.params,
|
|
26
26
|
options?.search,
|
|
27
27
|
options?.hash
|
|
@@ -32,11 +32,11 @@ export const routes = {
|
|
|
32
32
|
options?:
|
|
33
33
|
OptionalRouteOptions
|
|
34
34
|
{=# hasOptionalStaticSegments =}
|
|
35
|
-
& { path: ExpandRouteOnOptionalStaticSegments<
|
|
35
|
+
& { path: ExpandRouteOnOptionalStaticSegments<{=& urlPath =}> }
|
|
36
36
|
{=/ hasOptionalStaticSegments =}
|
|
37
37
|
) => interpolatePath(
|
|
38
38
|
{=# hasOptionalStaticSegments =}options.path,{=/ hasOptionalStaticSegments =}
|
|
39
|
-
{=^ hasOptionalStaticSegments =}
|
|
39
|
+
{=^ hasOptionalStaticSegments =}{=& urlPath =},{=/ hasOptionalStaticSegments =}
|
|
40
40
|
undefined,
|
|
41
41
|
options?.search,
|
|
42
42
|
options?.hash
|
|
@@ -50,6 +50,6 @@ export const routes = {
|
|
|
50
50
|
export type Routes = RouteDefinitionsToRoutes<typeof routes>
|
|
51
51
|
|
|
52
52
|
// PUBLIC API
|
|
53
|
-
export { Link } from './Link'
|
|
53
|
+
export { Link, type LinkProps } from './Link'
|
|
54
54
|
// PUBLIC API
|
|
55
|
-
export { NavLink } from './NavLink'
|
|
55
|
+
export { NavLink, type NavLinkProps } from './NavLink'
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { renderInContext
|
|
1
|
+
export { renderInContext } from '@wasp.sh/lib-sdk-core/browser/test'
|
|
2
|
+
export { mockServer } from './vitest/helpers'
|
|
@@ -1,44 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MockQuery, MockApi } from '@wasp.sh/lib-sdk-core/browser/test'
|
|
2
2
|
import { http, type HttpResponseResolver, type RequestHandler } from 'msw'
|
|
3
3
|
import { setupServer, type SetupServer } from 'msw/node'
|
|
4
|
-
import {
|
|
5
|
-
import { render, RenderResult, cleanup } from '@testing-library/react'
|
|
6
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
4
|
+
import { cleanup } from '@testing-library/react'
|
|
7
5
|
import { beforeAll, afterEach, afterAll } from 'vitest'
|
|
8
|
-
import {
|
|
9
|
-
import { config, HttpMethod, Route } from '../../index.js'
|
|
6
|
+
import { config, HttpMethod, type Route } from '../../index.js'
|
|
10
7
|
import { serialize } from '../../../core/serialization/index.js'
|
|
11
8
|
|
|
12
|
-
// PRIVATE API
|
|
13
|
-
export type MockQuery = <Input, Output, MockOutput extends Output>(
|
|
14
|
-
query: Query<Input, Output>,
|
|
15
|
-
resJson: MockOutput
|
|
16
|
-
) => void
|
|
17
|
-
|
|
18
|
-
// PRIVATE API
|
|
19
|
-
export type MockApi = (route: Route, resJson: unknown) => void
|
|
20
|
-
|
|
21
|
-
// PUBLIC API
|
|
22
|
-
// Inspired by the Tanstack React Query helper:
|
|
23
|
-
// https://github.com/TanStack/query/blob/4ae99561ca3383d6de3f4aad656a49ba4a17b57a/packages/react-query/src/__tests__/utils.tsx#L7-L26
|
|
24
|
-
export function renderInContext(ui: ReactElement): RenderResult {
|
|
25
|
-
const client = new QueryClient()
|
|
26
|
-
const { rerender, ...result } = render(
|
|
27
|
-
<QueryClientProvider client={client}>
|
|
28
|
-
<Router>{ui}</Router>
|
|
29
|
-
</QueryClientProvider>
|
|
30
|
-
)
|
|
31
|
-
return {
|
|
32
|
-
...result,
|
|
33
|
-
rerender: (rerenderUi: ReactNode) =>
|
|
34
|
-
rerender(
|
|
35
|
-
<QueryClientProvider client={client}>
|
|
36
|
-
<Router>{rerenderUi}</Router>
|
|
37
|
-
</QueryClientProvider>
|
|
38
|
-
),
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
9
|
// PUBLIC API
|
|
43
10
|
export function mockServer(): {
|
|
44
11
|
server: SetupServer
|
|
@@ -85,7 +52,9 @@ function mockRoute(
|
|
|
85
52
|
[HttpMethod.Get]: http.get(url, responseHandler),
|
|
86
53
|
[HttpMethod.Post]: http.post(url, responseHandler),
|
|
87
54
|
[HttpMethod.Put]: http.put(url, responseHandler),
|
|
55
|
+
[HttpMethod.Patch]: http.patch(url, responseHandler),
|
|
88
56
|
[HttpMethod.Delete]: http.delete(url, responseHandler),
|
|
57
|
+
[HttpMethod.Head]: http.head(url, responseHandler),
|
|
89
58
|
}
|
|
90
59
|
|
|
91
60
|
server.use(handlers[route.method])
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { WaspPluginOptions } from '@wasp.sh/lib-sdk-core/node/vite'
|
|
2
|
+
export { wasp } from "./plugins/wasp.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import type { Plugin } from "vite";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Maps virtual module IDs (pointing to user's client modules)
|
|
7
|
+
* to their relative import paths from the client project root.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* clientVirtualUserModuleMap["virtual:wasp/user/env"] // => "./src/env"
|
|
11
|
+
*/
|
|
12
|
+
const clientVirtualUserModuleMap: { [virtualUserModule: string]: string } = {
|
|
13
|
+
{=# virtualUserModules =}
|
|
14
|
+
{=& virtualModuleId =}: {=& importJson.importPath =},
|
|
15
|
+
{=/ virtualUserModules =}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Resolves virtual modules pointing to user's modules.
|
|
20
|
+
* Virtual user modules allow Wasp code to depend on user code at runtime,
|
|
21
|
+
* without depending on the user's project during compile time.
|
|
22
|
+
*/
|
|
23
|
+
export function virtualUserModules(): Plugin {
|
|
24
|
+
let clientRootDir!: string;
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
name: "wasp:virtual-user-modules",
|
|
28
|
+
enforce: "pre",
|
|
29
|
+
configResolved(config) {
|
|
30
|
+
clientRootDir = config.root;
|
|
31
|
+
},
|
|
32
|
+
async resolveId(id, importer, options) {
|
|
33
|
+
const userModulePath = Object.hasOwn(clientVirtualUserModuleMap, id)
|
|
34
|
+
? clientVirtualUserModuleMap[id]
|
|
35
|
+
: undefined;
|
|
36
|
+
if (userModulePath !== undefined) {
|
|
37
|
+
const absPath = path.resolve(clientRootDir, userModulePath);
|
|
38
|
+
return this.resolve(absPath, importer, { ...options, skipSelf: true });
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import {
|
|
2
|
+
import type { Plugin } from "vite";
|
|
3
3
|
import {
|
|
4
4
|
getClientEntryTsxContent,
|
|
5
5
|
getRoutesTsxContent,
|
|
6
6
|
getSsrEntryTsxContent,
|
|
7
7
|
} from "../virtual-files/index.js";
|
|
8
|
-
import { makeVirtualFilesResolver, type VirtualFiles } from "
|
|
8
|
+
import { makeVirtualFilesResolver, type VirtualFiles } from "@wasp.sh/lib-sdk-core/node/vite";
|
|
9
9
|
|
|
10
10
|
const resolveVirtualFiles = makeVirtualFilesResolver([
|
|
11
11
|
{ id: "{= clientEntryPointPath =}", load: getClientEntryTsxContent },
|
|
@@ -13,11 +13,11 @@ const resolveVirtualFiles = makeVirtualFilesResolver([
|
|
|
13
13
|
{ id: "{= ssrEntryPointPath =}", load: getSsrEntryTsxContent },
|
|
14
14
|
]);
|
|
15
15
|
|
|
16
|
-
export function
|
|
16
|
+
export function virtualWaspModules(): Plugin {
|
|
17
17
|
let virtualFiles!: VirtualFiles;
|
|
18
18
|
|
|
19
19
|
return {
|
|
20
|
-
name: "wasp:virtual-modules",
|
|
20
|
+
name: "wasp:virtual-wasp-modules",
|
|
21
21
|
enforce: "pre",
|
|
22
22
|
configResolved(config) {
|
|
23
23
|
virtualFiles = resolveVirtualFiles(config.root);
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import {
|
|
3
|
-
import react
|
|
2
|
+
import type { PluginOption } from "vite";
|
|
3
|
+
import react from "@vitejs/plugin-react";
|
|
4
|
+
import {
|
|
5
|
+
detectServerImports,
|
|
6
|
+
envFile,
|
|
7
|
+
typescriptCheck,
|
|
8
|
+
validateEnv,
|
|
9
|
+
type WaspPluginOptions,
|
|
10
|
+
} from "@wasp.sh/lib-sdk-core/node/vite";
|
|
4
11
|
import ssr from "@wasp.sh/lib-vite-ssr";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { detectServerImports } from "./detectServerImports.js";
|
|
8
|
-
import { waspVirtualModules } from "./virtualModules.js";
|
|
9
|
-
import { typescriptCheck } from "./typescriptCheck.js";
|
|
12
|
+
import { virtualWaspModules } from "./virtualWaspModules.js";
|
|
13
|
+
import { virtualUserModules } from "./virtualUserModules.js";
|
|
10
14
|
import { waspConfig } from "./waspConfig.js";
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
reactOptions?: ReactOptions;
|
|
14
|
-
}
|
|
16
|
+
|
|
15
17
|
|
|
16
18
|
export function wasp(options?: WaspPluginOptions): PluginOption {
|
|
17
19
|
return [
|
|
@@ -21,14 +23,15 @@ export function wasp(options?: WaspPluginOptions): PluginOption {
|
|
|
21
23
|
// The `wasp:config` plugin must come first because
|
|
22
24
|
// other plugins may depend on its configuration.
|
|
23
25
|
waspConfig(),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
virtualUserModules(),
|
|
27
|
+
virtualWaspModules(),
|
|
28
|
+
envFile("{= clientEnvFileName =}"),
|
|
29
|
+
detectServerImports("{= srcDirInWaspProjectDir =}"),
|
|
27
30
|
/**
|
|
28
31
|
* Plugins running after core Vite plugins.
|
|
29
32
|
*/
|
|
30
33
|
typescriptCheck({ srcTsConfigPath: "{= srcTsConfigPath =}" }),
|
|
31
|
-
validateEnv(),
|
|
34
|
+
validateEnv("{= clientEnvSchemaValidationModulePath =}"),
|
|
32
35
|
react(options?.reactOptions),
|
|
33
36
|
ssr({
|
|
34
37
|
clientEntrySrc: "{= clientEntryPointPath =}",
|
|
@@ -1,52 +1,80 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
/// <reference types="vitest/config" />
|
|
3
|
-
import {
|
|
4
|
-
import { defaultExclude } from "vitest/config"
|
|
3
|
+
import type { PluginOption } from "vite";
|
|
4
|
+
import { defaultExclude } from "vitest/config";
|
|
5
5
|
|
|
6
6
|
// Vite merges `userConfig` and our `waspConfig` returned from the plugin.
|
|
7
7
|
// In that merge, primitive values from waspConfig take precedence, and
|
|
8
8
|
// arrays are concatenated.
|
|
9
9
|
//
|
|
10
10
|
// This allows us to treat config values differently:
|
|
11
|
-
// - Forced:
|
|
12
|
-
// user set one of these in their vite.config.ts,
|
|
11
|
+
// - Forced: taken from `forcedOptions` in the return object so they
|
|
12
|
+
// always win. If the user set one of these in their vite.config.ts,
|
|
13
|
+
// we throw an error.
|
|
13
14
|
// - Overridable: we read the user's value and use it or fall back to
|
|
14
15
|
// our default.
|
|
15
16
|
// - Additive (arrays): we only return Wasp's entries; Vite's merge
|
|
16
17
|
// appends them to whatever the user already has.
|
|
17
18
|
|
|
18
19
|
const forcedOptions = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
base: {=& baseDir =},
|
|
21
|
+
envPrefix: "REACT_APP_",
|
|
22
|
+
"build.outDir": "{= clientBuildDirPath =}",
|
|
23
|
+
// Heads up! The env referred to by `clientPortEnvVarName` is empty during
|
|
24
|
+
// `build`, so it's not persisted in the final output.
|
|
25
|
+
"server.port": envVarAsNumber("{= clientPortEnvVarName =}"),
|
|
26
|
+
"server.strictPort": true,
|
|
27
|
+
// `vite preview` falls back to `server` for most options, but not for `port`
|
|
28
|
+
// (it has its own default), so we have to set it separately.
|
|
29
|
+
"preview.port": envVarAsNumber("{= clientPortEnvVarName =}"),
|
|
22
30
|
} as const;
|
|
23
31
|
|
|
32
|
+
const forcedOptionHints: Partial<Record<keyof typeof forcedOptions, string>> = {
|
|
33
|
+
base: "To serve your app from a subdirectory, set `client.baseDir` in your Wasp config.",
|
|
34
|
+
"server.port":
|
|
35
|
+
"To run the client on a different port, use `wasp start --client-port <port>`.",
|
|
36
|
+
"preview.port":
|
|
37
|
+
"To run the client on a different port, use `wasp build start --client-port <port>`.",
|
|
38
|
+
};
|
|
39
|
+
|
|
24
40
|
export function waspConfig(): PluginOption {
|
|
25
41
|
return {
|
|
26
42
|
name: "wasp:config",
|
|
27
|
-
enforce:
|
|
43
|
+
enforce: "pre",
|
|
28
44
|
config(config) {
|
|
29
45
|
throwIfOverridingForcedOptions(config);
|
|
30
46
|
|
|
31
47
|
// Returned config is merged with the user's config by Vite (mergeConfig).
|
|
32
48
|
return {
|
|
33
|
-
base: forcedOptions[
|
|
49
|
+
base: forcedOptions["base"],
|
|
34
50
|
optimizeDeps: {
|
|
35
51
|
exclude: {=& depsExcludedFromOptimization =}
|
|
36
52
|
},
|
|
37
53
|
server: {
|
|
38
|
-
port:
|
|
54
|
+
port: forcedOptions["server.port"],
|
|
55
|
+
strictPort: forcedOptions["server.strictPort"],
|
|
39
56
|
host: useUserValue(config.server?.host, "0.0.0.0"),
|
|
40
57
|
},
|
|
41
|
-
|
|
58
|
+
preview: {
|
|
59
|
+
port: forcedOptions["preview.port"],
|
|
60
|
+
},
|
|
61
|
+
envPrefix: forcedOptions["envPrefix"],
|
|
42
62
|
build: {
|
|
43
|
-
outDir: forcedOptions[
|
|
63
|
+
outDir: forcedOptions["build.outDir"],
|
|
64
|
+
},
|
|
65
|
+
ssr: {
|
|
66
|
+
noExternal: ["@wasp.sh/lib-sdk-core"],
|
|
44
67
|
},
|
|
45
68
|
resolve: {
|
|
46
69
|
// These packages rely on a single instance per page. Not deduping them
|
|
47
70
|
// causes runtime errors (e.g., hook rule violation in react, QueryClient
|
|
48
71
|
// instance error in react-query, Invariant Error in react-router).
|
|
49
|
-
dedupe: [
|
|
72
|
+
dedupe: [
|
|
73
|
+
"react",
|
|
74
|
+
"react-dom",
|
|
75
|
+
"@tanstack/react-query",
|
|
76
|
+
"react-router",
|
|
77
|
+
],
|
|
50
78
|
alias: [
|
|
51
79
|
{
|
|
52
80
|
// Vite doesn't look for `.prisma/client` imports in the `node_modules`
|
|
@@ -69,10 +97,10 @@ export function waspConfig(): PluginOption {
|
|
|
69
97
|
exclude: [
|
|
70
98
|
...defaultExclude,
|
|
71
99
|
"{= vitest.excludeWaspArtefactsPattern =}",
|
|
72
|
-
]
|
|
100
|
+
],
|
|
73
101
|
},
|
|
74
102
|
};
|
|
75
|
-
}
|
|
103
|
+
},
|
|
76
104
|
};
|
|
77
105
|
}
|
|
78
106
|
|
|
@@ -85,18 +113,32 @@ function throwIfOverridingForcedOptions(config: Record<string, any>): void {
|
|
|
85
113
|
for (const [path, forcedValue] of Object.entries(forcedOptions)) {
|
|
86
114
|
const userValue = getByPath(config, path);
|
|
87
115
|
if (userValue !== undefined && userValue !== forcedValue) {
|
|
116
|
+
const hint = forcedOptionHints[path as keyof typeof forcedOptions];
|
|
88
117
|
conflicts.push(
|
|
89
|
-
` - "${path}" is set to ${JSON.stringify(userValue)}, but Wasp requires ${JSON.stringify(forcedValue)}`
|
|
118
|
+
` - "${path}" is set to ${JSON.stringify(userValue)}, but Wasp requires ${JSON.stringify(forcedValue)}` +
|
|
119
|
+
(hint ? `\n ${hint}` : ""),
|
|
90
120
|
);
|
|
91
121
|
}
|
|
92
122
|
}
|
|
93
123
|
if (conflicts.length > 0) {
|
|
94
124
|
throw new Error(
|
|
95
|
-
`Your vite.config.ts sets options that Wasp controls:\n${conflicts.join(
|
|
125
|
+
`Your vite.config.ts sets options that Wasp controls:\n${conflicts.join("\n")}\n\nRemove these from your Vite config, Wasp sets them automatically.`,
|
|
96
126
|
);
|
|
97
127
|
}
|
|
98
128
|
}
|
|
99
129
|
|
|
100
130
|
function getByPath(obj: Record<string, any>, path: string): unknown {
|
|
101
|
-
return path.split(
|
|
131
|
+
return path.split(".").reduce<any>((node, segment) => node?.[segment], obj);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function envVarAsNumber(envName: string): number | undefined {
|
|
135
|
+
const strValue = process.env[envName];
|
|
136
|
+
if (strValue === undefined) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
const numValue = Number.parseInt(strValue);
|
|
140
|
+
if (Number.isNaN(numValue)) {
|
|
141
|
+
throw new Error(`Environment variable ${envName} is not a valid number.`);
|
|
142
|
+
}
|
|
143
|
+
return numValue;
|
|
102
144
|
}
|
|
@@ -10,7 +10,7 @@ import { WaspApp } from "wasp/client/app";
|
|
|
10
10
|
{=& routeObjects.importStatement =}
|
|
11
11
|
|
|
12
12
|
const router = createBrowserRouter({= routeObjects.importIdentifier =}, {
|
|
13
|
-
basename:
|
|
13
|
+
basename: {=& baseDir =},
|
|
14
14
|
// React Router will put hydration data on this property of the `window` object.
|
|
15
15
|
// https://reactrouter.com/8.0.1/start/data/custom#4-hydrate-in-the-browser
|
|
16
16
|
hydrationData: window.__staticRouterHydrationData,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { getRouteObjects } from "wasp/client/app/router";
|
|
3
|
-
import { initializeQueryClient } from "wasp/
|
|
3
|
+
import { initializeQueryClient } from "@wasp.sh/lib-sdk-core/browser";
|
|
4
4
|
{=^ rootComponent.isDefined =}
|
|
5
5
|
import { Outlet } from "react-router"
|
|
6
6
|
{=/ rootComponent.isDefined =}
|
|
@@ -42,7 +42,7 @@ const prerenderApp: PrerenderFn = async (route, { clientEntrySrc }) => {
|
|
|
42
42
|
export default prerenderApp;
|
|
43
43
|
|
|
44
44
|
const { query, dataRoutes } = createStaticHandler({= routeObjects.importIdentifier =}, {
|
|
45
|
-
basename:
|
|
45
|
+
basename: {=& baseDir =},
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
async function makeStaticRouterProvider(route: string) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import { createContext, useState, useEffect, Context, ReactNode } from 'react'
|
|
3
|
-
import { io, Socket } from 'socket.io-client'
|
|
2
|
+
import { createContext, useState, useEffect, type Context, type ReactNode } from 'react'
|
|
3
|
+
import { io, type Socket } from 'socket.io-client'
|
|
4
|
+
import { apiEventsEmitter } from '@wasp.sh/lib-sdk-core/browser'
|
|
4
5
|
|
|
5
6
|
import { getSessionId } from '../../api/index.js'
|
|
6
|
-
import { apiEventsEmitter } from '../../api/events.js'
|
|
7
7
|
import { config } from '../index.js'
|
|
8
8
|
|
|
9
9
|
import type { ClientToServerEvents, ServerToClientEvents } from '../../server/webSocket/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext, useEffect } from 'react'
|
|
2
|
-
import { WebSocketContext, WebSocketContextValue } from './WebSocketProvider'
|
|
2
|
+
import { WebSocketContext, type WebSocketContextValue } from './WebSocketProvider'
|
|
3
3
|
import type {
|
|
4
4
|
ClientToServerEvents,
|
|
5
5
|
ServerToClientEvents,
|
|
@@ -1,56 +1,11 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { deserialize, serialize } from "superjson"
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
{=# entitiesExist =}
|
|
6
6
|
import "./prisma"
|
|
7
7
|
{=/ entitiesExist =}
|
|
8
8
|
|
|
9
|
-
export type Payload
|
|
10
|
-
|
|
11
|
-
// The part below was copied from SuperJSON and slightly modified:
|
|
12
|
-
// https://github.com/blitz-js/superjson/blob/ae7dbcefe5d3ece5b04be0c6afe6b40f3a44a22a/src/types.ts
|
|
13
|
-
//
|
|
14
|
-
// We couldn't use SuperJSON's types directly because:
|
|
15
|
-
// 1. They have a weird quirk that turns `SuperJSONValue` into `any`.
|
|
16
|
-
// See why here:
|
|
17
|
-
// https://github.com/blitz-js/superjson/pull/36#issuecomment-669239876
|
|
18
|
-
// 2. We need to add our own custom types to the serialization process.
|
|
19
|
-
//
|
|
20
|
-
// We changed the code as little as possible to make future comparisons easier.
|
|
21
|
-
export type JSONValue = PrimitiveJSONValue | JSONArray | JSONObject;
|
|
22
|
-
|
|
23
|
-
export interface JSONObject {
|
|
24
|
-
[key: string]: JSONValue;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type PrimitiveJSONValue = string | number | boolean | undefined | null;
|
|
28
|
-
|
|
29
|
-
export interface JSONArray extends Array<JSONValue> {}
|
|
30
|
-
|
|
31
|
-
// Removed `Symbol` since we don't explicitly register any symbol to be serialized
|
|
32
|
-
// Added custom types from `CustomSerializableJSONValue`
|
|
33
|
-
export type SerializableJSONValue =
|
|
34
|
-
| Set<SuperJSONValue>
|
|
35
|
-
| Map<SuperJSONValue, SuperJSONValue>
|
|
36
|
-
| undefined
|
|
37
|
-
| bigint
|
|
38
|
-
| Date
|
|
39
|
-
| RegExp
|
|
40
|
-
| CustomSerializableJSONValue;
|
|
41
|
-
|
|
42
|
-
// Here's where we excluded `ClassInstance` (which was `any`) from the union.
|
|
43
|
-
export type SuperJSONValue =
|
|
44
|
-
| JSONValue
|
|
45
|
-
| SerializableJSONValue
|
|
46
|
-
| SuperJSONArray
|
|
47
|
-
| SuperJSONObject;
|
|
48
|
-
|
|
49
|
-
export interface SuperJSONArray extends Array<SuperJSONValue> {}
|
|
50
|
-
|
|
51
|
-
export interface SuperJSONObject {
|
|
52
|
-
[key: string]: SuperJSONValue;
|
|
53
|
-
}
|
|
9
|
+
export { type JSONArray, type JSONObject, type JSONValue, type Payload, type SerializableJSONValue, type SuperJSONArray, type SuperJSONObject, type SuperJSONValue } from '@wasp.sh/lib-sdk-core'
|
|
54
10
|
|
|
55
11
|
export { deserialize, serialize }
|
|
56
|
-
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import {
|
|
2
|
+
import type {
|
|
3
3
|
{=# entities =}
|
|
4
|
-
|
|
4
|
+
{= name =},
|
|
5
5
|
{=/ entities =}
|
|
6
6
|
} from "@prisma/client"
|
|
7
7
|
|
|
8
|
-
export {
|
|
8
|
+
export type {
|
|
9
9
|
{=# entities =}
|
|
10
|
-
|
|
10
|
+
{= name =},
|
|
11
11
|
{=/ entities =}
|
|
12
12
|
{=# isAuthEnabled =}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
{= authEntityName =},
|
|
14
|
+
{= authIdentityEntityName =},
|
|
15
15
|
{=/ isAuthEnabled =}
|
|
16
16
|
} from "@prisma/client"
|
|
17
17
|
|