@wasp.sh/wasp-cli-darwin-x64-unknown 0.20.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 +22 -0
- package/data/Cli/starters/basic/README.md +35 -0
- package/data/Cli/starters/basic/eslint.config.js +24 -0
- package/data/Cli/starters/basic/main.wasp +100 -0
- package/data/Cli/starters/basic/package.json +29 -0
- package/data/Cli/starters/basic/postcss.config.js +6 -0
- package/data/Cli/starters/basic/schema.prisma +42 -0
- package/data/Cli/starters/basic/src/App.css +13 -0
- package/data/Cli/starters/basic/src/App.tsx +12 -0
- package/data/Cli/starters/basic/src/assets/logo.svg +1 -0
- package/data/Cli/starters/basic/src/auth/AuthLayout.tsx +10 -0
- package/data/Cli/starters/basic/src/auth/email/EmailVerificationPage.tsx +19 -0
- package/data/Cli/starters/basic/src/auth/email/LoginPage.tsx +27 -0
- package/data/Cli/starters/basic/src/auth/email/PasswordResetPage.tsx +19 -0
- package/data/Cli/starters/basic/src/auth/email/RequestPasswordResetPage.tsx +10 -0
- package/data/Cli/starters/basic/src/auth/email/SignupPage.tsx +34 -0
- package/data/Cli/starters/basic/src/auth/email/userSignupFields.ts +13 -0
- package/data/Cli/starters/basic/src/shared/components/Button.tsx +90 -0
- package/data/Cli/starters/basic/src/shared/components/Dialog.tsx +85 -0
- package/data/Cli/starters/basic/src/shared/components/Header.tsx +39 -0
- package/data/Cli/starters/basic/src/shared/components/Input.tsx +36 -0
- package/data/Cli/starters/basic/src/shared/components/Portal.tsx +26 -0
- package/data/Cli/starters/basic/src/tags/actions.ts +23 -0
- package/data/Cli/starters/basic/src/tags/components/ColorRadioButton.tsx +44 -0
- package/data/Cli/starters/basic/src/tags/components/ColorRadioButtons.tsx +59 -0
- package/data/Cli/starters/basic/src/tags/components/CreateTagDialog.tsx +50 -0
- package/data/Cli/starters/basic/src/tags/components/CreateTagForm.tsx +100 -0
- package/data/Cli/starters/basic/src/tags/components/TagLabel.tsx +55 -0
- package/data/Cli/starters/basic/src/tags/components/colors.ts +8 -0
- package/data/Cli/starters/basic/src/tags/queries.ts +14 -0
- package/data/Cli/starters/basic/src/tasks/TasksPage.tsx +19 -0
- package/data/Cli/starters/basic/src/tasks/actions.ts +71 -0
- package/data/Cli/starters/basic/src/tasks/components/CreateTaskForm.tsx +103 -0
- package/data/Cli/starters/basic/src/tasks/components/TaskList.tsx +68 -0
- package/data/Cli/starters/basic/src/tasks/components/TaskListItem.tsx +56 -0
- package/data/Cli/starters/basic/src/tasks/queries.ts +21 -0
- package/data/Cli/starters/basic/tailwind.config.js +30 -0
- package/data/Cli/starters/basic/vite.config.ts +7 -0
- package/data/Cli/starters/minimal/main.wasp +14 -0
- package/data/Cli/starters/minimal/package.json +18 -0
- package/data/Cli/starters/minimal/schema.prisma +10 -0
- package/data/Cli/starters/minimal/src/Main.css +103 -0
- package/data/Cli/starters/minimal/src/MainPage.tsx +37 -0
- package/data/Cli/starters/minimal/src/assets/logo.svg +1 -0
- package/data/Cli/starters/minimal/vite.config.ts +7 -0
- package/data/Cli/starters/skeleton/public/favicon.ico +0 -0
- package/data/Cli/starters/skeleton/src/vite-env.d.ts +7 -0
- package/data/Cli/starters/skeleton/tsconfig.json +28 -0
- package/data/Generator/templates/Dockerfile +78 -0
- package/data/Generator/templates/db/schema.prisma +24 -0
- package/data/Generator/templates/dockerignore +2 -0
- package/data/Generator/templates/react-app/README.md +21 -0
- package/data/Generator/templates/react-app/gitignore +23 -0
- package/data/Generator/templates/react-app/index.html +22 -0
- package/data/Generator/templates/react-app/netlify.toml +8 -0
- package/data/Generator/templates/react-app/npmrc +1 -0
- package/data/Generator/templates/react-app/package.json +31 -0
- package/data/Generator/templates/react-app/public/manifest.json +15 -0
- package/data/Generator/templates/react-app/src/auth/pages/OAuthCallback.tsx +93 -0
- package/data/Generator/templates/react-app/src/auth/pages/createAuthRequiredPage.jsx +40 -0
- package/data/Generator/templates/react-app/src/components/DefaultRootErrorBoundary.tsx +16 -0
- package/data/Generator/templates/react-app/src/components/FullPageWrapper.tsx +21 -0
- package/data/Generator/templates/react-app/src/components/Loader.module.css +37 -0
- package/data/Generator/templates/react-app/src/components/Loader.tsx +12 -0
- package/data/Generator/templates/react-app/src/components/Message.tsx +86 -0
- package/data/Generator/templates/react-app/src/index.tsx +47 -0
- package/data/Generator/templates/react-app/src/logo.png +0 -0
- package/data/Generator/templates/react-app/src/router.tsx +59 -0
- package/data/Generator/templates/react-app/src/test/vitest/setup.ts +8 -0
- package/data/Generator/templates/react-app/src/utils.js +3 -0
- package/data/Generator/templates/react-app/src/vite-env.d.ts +1 -0
- package/data/Generator/templates/react-app/tsconfig.app.json +28 -0
- package/data/Generator/templates/react-app/tsconfig.json +11 -0
- package/data/Generator/templates/react-app/tsconfig.vite.json +16 -0
- package/data/Generator/templates/react-app/vite/detectServerImports.ts +53 -0
- package/data/Generator/templates/react-app/vite/validateEnv.ts +45 -0
- package/data/Generator/templates/react-app/vite.config.ts +74 -0
- package/data/Generator/templates/sdk/wasp/api/events.ts +11 -0
- package/data/Generator/templates/sdk/wasp/api/index.ts +136 -0
- package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +13 -0
- package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +22 -0
- package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +20 -0
- package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +14 -0
- package/data/Generator/templates/sdk/wasp/auth/email/index.ts +5 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/Auth.module.css +16 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/Auth.tsx +94 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/ForgotPassword.tsx +18 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/Login.tsx +18 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/ResetPassword.tsx +18 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/Signup.tsx +24 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/VerifyEmail.tsx +18 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.module.css +99 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.tsx +74 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.module.css +22 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.tsx +34 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/auth-styles.css +30 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.module.css +55 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.tsx +291 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ForgotPasswordForm.tsx +52 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ResetPasswordForm.tsx +82 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/VerifyEmailForm.tsx +43 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/useEmail.ts +33 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.module.css +33 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.tsx +14 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.module.css +4 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.tsx +74 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/usernameAndPassword/useUsernameAndPassword.ts +29 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/util.ts +16 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/types.ts +77 -0
- package/data/Generator/templates/sdk/wasp/auth/helpers/_Provider.tsx +17 -0
- package/data/Generator/templates/sdk/wasp/auth/helpers/user.ts +15 -0
- package/data/Generator/templates/sdk/wasp/auth/index.ts +9 -0
- package/data/Generator/templates/sdk/wasp/auth/jwt.ts +22 -0
- package/data/Generator/templates/sdk/wasp/auth/logout.ts +18 -0
- package/data/Generator/templates/sdk/wasp/auth/lucia.ts +53 -0
- package/data/Generator/templates/sdk/wasp/auth/password.ts +36 -0
- package/data/Generator/templates/sdk/wasp/auth/providers/index.ts +9 -0
- package/data/Generator/templates/sdk/wasp/auth/providers/types.ts +68 -0
- package/data/Generator/templates/sdk/wasp/auth/session.ts +78 -0
- package/data/Generator/templates/sdk/wasp/auth/types.ts +2 -0
- package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +37 -0
- package/data/Generator/templates/sdk/wasp/auth/user.ts +63 -0
- package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +13 -0
- package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +20 -0
- package/data/Generator/templates/sdk/wasp/auth/username/index.ts +2 -0
- package/data/Generator/templates/sdk/wasp/auth/utils.ts +369 -0
- package/data/Generator/templates/sdk/wasp/auth/validation.ts +83 -0
- package/data/Generator/templates/sdk/wasp/client/auth/discord.ts +2 -0
- package/data/Generator/templates/sdk/wasp/client/auth/email.ts +5 -0
- package/data/Generator/templates/sdk/wasp/client/auth/github.ts +2 -0
- package/data/Generator/templates/sdk/wasp/client/auth/google.ts +2 -0
- package/data/Generator/templates/sdk/wasp/client/auth/index.ts +29 -0
- package/data/Generator/templates/sdk/wasp/client/auth/keycloak.ts +2 -0
- package/data/Generator/templates/sdk/wasp/client/auth/slack.ts +2 -0
- package/data/Generator/templates/sdk/wasp/client/auth/ui.ts +32 -0
- package/data/Generator/templates/sdk/wasp/client/auth/username.ts +2 -0
- package/data/Generator/templates/sdk/wasp/client/config.ts +15 -0
- package/data/Generator/templates/sdk/wasp/client/crud/_crud.ts +89 -0
- package/data/Generator/templates/sdk/wasp/client/crud/index.ts +4 -0
- package/data/Generator/templates/sdk/wasp/client/crud/operationsHelpers.ts +21 -0
- package/data/Generator/templates/sdk/wasp/client/env/schema.ts +22 -0
- package/data/Generator/templates/sdk/wasp/client/env.ts +5 -0
- package/data/Generator/templates/sdk/wasp/client/hooks.ts +19 -0
- package/data/Generator/templates/sdk/wasp/client/index.ts +17 -0
- package/data/Generator/templates/sdk/wasp/client/operations/actions/core.ts +49 -0
- package/data/Generator/templates/sdk/wasp/client/operations/actions/index.ts +13 -0
- package/data/Generator/templates/sdk/wasp/client/operations/hooks.ts +347 -0
- package/data/Generator/templates/sdk/wasp/client/operations/index.ts +22 -0
- package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +22 -0
- package/data/Generator/templates/sdk/wasp/client/operations/internal/resources.js +83 -0
- package/data/Generator/templates/sdk/wasp/client/operations/internal/updateHandlersMap.js +37 -0
- package/data/Generator/templates/sdk/wasp/client/operations/queries/core.ts +91 -0
- package/data/Generator/templates/sdk/wasp/client/operations/queries/index.ts +16 -0
- package/data/Generator/templates/sdk/wasp/client/operations/queryClient.ts +34 -0
- package/data/Generator/templates/sdk/wasp/client/operations/rpc.ts +96 -0
- package/data/Generator/templates/sdk/wasp/client/router/Link.tsx +21 -0
- package/data/Generator/templates/sdk/wasp/client/router/index.ts +53 -0
- package/data/Generator/templates/sdk/wasp/client/router/linkHelpers.ts +48 -0
- package/data/Generator/templates/sdk/wasp/client/router/types.ts +98 -0
- package/data/Generator/templates/sdk/wasp/client/test/index.ts +1 -0
- package/data/Generator/templates/sdk/wasp/client/test/vitest/helpers.tsx +95 -0
- package/data/Generator/templates/sdk/wasp/client/webSocket/WebSocketProvider.tsx +77 -0
- package/data/Generator/templates/sdk/wasp/client/webSocket/index.ts +39 -0
- package/data/Generator/templates/sdk/wasp/core/auth.ts +40 -0
- package/data/Generator/templates/sdk/wasp/core/serialization/custom-register.ts +21 -0
- package/data/Generator/templates/sdk/wasp/core/serialization/index.ts +56 -0
- package/data/Generator/templates/sdk/wasp/core/serialization/prisma.ts +54 -0
- package/data/Generator/templates/sdk/wasp/core/storage.ts +50 -0
- package/data/Generator/templates/sdk/wasp/dev/index.ts +19 -0
- package/data/Generator/templates/sdk/wasp/entities/index.ts +28 -0
- package/data/Generator/templates/sdk/wasp/env/index.ts +9 -0
- package/data/Generator/templates/sdk/wasp/env/validation.ts +38 -0
- package/data/Generator/templates/sdk/wasp/package.json +152 -0
- package/data/Generator/templates/sdk/wasp/prisma-runtime-library.d.ts +17 -0
- package/data/Generator/templates/sdk/wasp/scripts/copy-assets.js +14 -0
- package/data/Generator/templates/sdk/wasp/server/HttpError.ts +30 -0
- package/data/Generator/templates/sdk/wasp/server/_types/index.ts +105 -0
- package/data/Generator/templates/sdk/wasp/server/_types/taggedEntities.ts +26 -0
- package/data/Generator/templates/sdk/wasp/server/api/index.ts +44 -0
- package/data/Generator/templates/sdk/wasp/server/auth/email/index.ts +20 -0
- package/data/Generator/templates/sdk/wasp/server/auth/email/utils.ts +104 -0
- package/data/Generator/templates/sdk/wasp/server/auth/hooks.ts +188 -0
- package/data/Generator/templates/sdk/wasp/server/auth/index.ts +49 -0
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/index.ts +38 -0
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/oneTimeCode.ts +50 -0
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/provider.ts +20 -0
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/discord.ts +22 -0
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/github.ts +20 -0
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/google.ts +22 -0
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/keycloak.ts +23 -0
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/slack.ts +22 -0
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/redirect.ts +43 -0
- package/data/Generator/templates/sdk/wasp/server/auth/user.ts +148 -0
- package/data/Generator/templates/sdk/wasp/server/auth/username.ts +1 -0
- package/data/Generator/templates/sdk/wasp/server/config.ts +47 -0
- package/data/Generator/templates/sdk/wasp/server/crud/_operationTypes.ts +134 -0
- package/data/Generator/templates/sdk/wasp/server/crud/index.ts +5 -0
- package/data/Generator/templates/sdk/wasp/server/dbClient.ts +35 -0
- package/data/Generator/templates/sdk/wasp/server/email/core/helpers.ts +40 -0
- package/data/Generator/templates/sdk/wasp/server/email/core/index.ts +17 -0
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/dummy.ts +34 -0
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/mailgun.ts +31 -0
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/sendgrid.ts +44 -0
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/smtp.ts +29 -0
- package/data/Generator/templates/sdk/wasp/server/email/core/types.ts +59 -0
- package/data/Generator/templates/sdk/wasp/server/email/index.ts +39 -0
- package/data/Generator/templates/sdk/wasp/server/env.ts +173 -0
- package/data/Generator/templates/sdk/wasp/server/index.ts +17 -0
- package/data/Generator/templates/sdk/wasp/server/jobs/_job.ts +39 -0
- package/data/Generator/templates/sdk/wasp/server/jobs/core/job.ts +28 -0
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/index.ts +3 -0
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts +76 -0
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBossJob.ts +230 -0
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/types.ts +9 -0
- package/data/Generator/templates/sdk/wasp/server/jobs/index.ts +5 -0
- package/data/Generator/templates/sdk/wasp/server/middleware/globalMiddleware.ts +8 -0
- package/data/Generator/templates/sdk/wasp/server/middleware/index.ts +1 -0
- package/data/Generator/templates/sdk/wasp/server/operations/actions/index.ts +41 -0
- package/data/Generator/templates/sdk/wasp/server/operations/actions/types.ts +35 -0
- package/data/Generator/templates/sdk/wasp/server/operations/index.ts +13 -0
- package/data/Generator/templates/sdk/wasp/server/operations/queries/index.ts +42 -0
- package/data/Generator/templates/sdk/wasp/server/operations/queries/types.ts +36 -0
- package/data/Generator/templates/sdk/wasp/server/operations/wrappers.ts +242 -0
- package/data/Generator/templates/sdk/wasp/server/types/index.ts +11 -0
- package/data/Generator/templates/sdk/wasp/server/utils.ts +38 -0
- package/data/Generator/templates/sdk/wasp/server/webSocket/index.ts +57 -0
- package/data/Generator/templates/sdk/wasp/tsconfig.json +102 -0
- package/data/Generator/templates/sdk/wasp/universal/ansiColors.ts +14 -0
- package/data/Generator/templates/sdk/wasp/universal/predicates.ts +3 -0
- package/data/Generator/templates/sdk/wasp/universal/types.ts +74 -0
- package/data/Generator/templates/sdk/wasp/universal/url.ts +9 -0
- package/data/Generator/templates/sdk/wasp/universal/validators.ts +21 -0
- package/data/Generator/templates/sdk/wasp/vite-env.d.ts +1 -0
- package/data/Generator/templates/server/README.md +1 -0
- package/data/Generator/templates/server/gitignore +6 -0
- package/data/Generator/templates/server/nodemon.json +13 -0
- package/data/Generator/templates/server/npmrc +1 -0
- package/data/Generator/templates/server/package.json +27 -0
- package/data/Generator/templates/server/rollup.config.js +44 -0
- package/data/Generator/templates/server/src/actions/_action.ts +18 -0
- package/data/Generator/templates/server/src/app.js +36 -0
- package/data/Generator/templates/server/src/auth/hooks.ts +135 -0
- package/data/Generator/templates/server/src/auth/providers/config/discord.ts +69 -0
- package/data/Generator/templates/server/src/auth/providers/config/email.ts +96 -0
- package/data/Generator/templates/server/src/auth/providers/config/github.ts +78 -0
- package/data/Generator/templates/server/src/auth/providers/config/google.ts +65 -0
- package/data/Generator/templates/server/src/auth/providers/config/keycloak.ts +67 -0
- package/data/Generator/templates/server/src/auth/providers/config/slack.ts +65 -0
- package/data/Generator/templates/server/src/auth/providers/config/username.ts +33 -0
- package/data/Generator/templates/server/src/auth/providers/email/login.ts +66 -0
- package/data/Generator/templates/server/src/auth/providers/email/requestPasswordReset.ts +74 -0
- package/data/Generator/templates/server/src/auth/providers/email/resetPassword.ts +48 -0
- package/data/Generator/templates/server/src/auth/providers/email/signup.ts +165 -0
- package/data/Generator/templates/server/src/auth/providers/email/verifyEmail.ts +42 -0
- package/data/Generator/templates/server/src/auth/providers/index.ts +32 -0
- package/data/Generator/templates/server/src/auth/providers/oauth/config.ts +19 -0
- package/data/Generator/templates/server/src/auth/providers/oauth/cookies.ts +35 -0
- package/data/Generator/templates/server/src/auth/providers/oauth/handler.ts +130 -0
- package/data/Generator/templates/server/src/auth/providers/oauth/oneTimeCode.ts +39 -0
- package/data/Generator/templates/server/src/auth/providers/oauth/state.ts +144 -0
- package/data/Generator/templates/server/src/auth/providers/oauth/types.ts +7 -0
- package/data/Generator/templates/server/src/auth/providers/oauth/user.ts +139 -0
- package/data/Generator/templates/server/src/auth/providers/username/login.ts +64 -0
- package/data/Generator/templates/server/src/auth/providers/username/signup.ts +59 -0
- package/data/Generator/templates/server/src/crud/_operations.ts +184 -0
- package/data/Generator/templates/server/src/dbSeed.ts +37 -0
- package/data/Generator/templates/server/src/jobs/_job.ts +9 -0
- package/data/Generator/templates/server/src/jobs/core/allJobs.ts +8 -0
- package/data/Generator/templates/server/src/middleware/globalMiddleware.ts +45 -0
- package/data/Generator/templates/server/src/middleware/index.ts +1 -0
- package/data/Generator/templates/server/src/middleware/operations.ts +28 -0
- package/data/Generator/templates/server/src/queries/_query.ts +18 -0
- package/data/Generator/templates/server/src/routes/apis/index.ts +67 -0
- package/data/Generator/templates/server/src/routes/auth/index.js +16 -0
- package/data/Generator/templates/server/src/routes/auth/logout.ts +12 -0
- package/data/Generator/templates/server/src/routes/auth/me.ts +10 -0
- package/data/Generator/templates/server/src/routes/crud/_crud.ts +46 -0
- package/data/Generator/templates/server/src/routes/crud/index.ts +12 -0
- package/data/Generator/templates/server/src/routes/index.js +55 -0
- package/data/Generator/templates/server/src/routes/operations/_action.js +5 -0
- package/data/Generator/templates/server/src/routes/operations/_query.js +5 -0
- package/data/Generator/templates/server/src/routes/operations/index.js +18 -0
- package/data/Generator/templates/server/src/server.ts +76 -0
- package/data/Generator/templates/server/src/views/wrong-port.ts +123 -0
- package/data/Generator/templates/server/src/webSocket/initialization.ts +59 -0
- package/data/Generator/templates/server/tsconfig.json +41 -0
- package/data/Lsp/templates/ts/action.fn.ts +12 -0
- package/data/Lsp/templates/ts/operation.fn.js +7 -0
- package/data/Lsp/templates/ts/page.component.jsx +9 -0
- package/data/Lsp/templates/ts/query.fn.ts +12 -0
- package/data/packages/deploy/dist/common/brandedTypes.js +2 -0
- package/data/packages/deploy/dist/common/clientApp.js +26 -0
- package/data/packages/deploy/dist/common/commander.js +8 -0
- package/data/packages/deploy/dist/common/random.js +5 -0
- package/data/packages/deploy/dist/common/terminal.js +24 -0
- package/data/packages/deploy/dist/common/typeUtils.js +2 -0
- package/data/packages/deploy/dist/common/validation.js +14 -0
- package/data/packages/deploy/dist/common/waspBuild.js +21 -0
- package/data/packages/deploy/dist/common/waspProject.js +43 -0
- package/data/packages/deploy/dist/common/zx.js +10 -0
- package/data/packages/deploy/dist/index.js +30 -0
- package/data/packages/deploy/dist/providers/fly/CommonCmdOptions.js +2 -0
- package/data/packages/deploy/dist/providers/fly/CommonOps.js +36 -0
- package/data/packages/deploy/dist/providers/fly/DeploymentInstructions.js +12 -0
- package/data/packages/deploy/dist/providers/fly/commands/cmd/CmdCmdOptions.js +2 -0
- package/data/packages/deploy/dist/providers/fly/commands/cmd/cmd.js +29 -0
- package/data/packages/deploy/dist/providers/fly/commands/createDb/CreateDbCmdOptions.js +2 -0
- package/data/packages/deploy/dist/providers/fly/commands/createDb/createDb.js +55 -0
- package/data/packages/deploy/dist/providers/fly/commands/deploy/DeployCmdOptions.js +2 -0
- package/data/packages/deploy/dist/providers/fly/commands/deploy/deploy.js +88 -0
- package/data/packages/deploy/dist/providers/fly/commands/launch/LaunchCmdOptions.js +2 -0
- package/data/packages/deploy/dist/providers/fly/commands/launch/launch.js +17 -0
- package/data/packages/deploy/dist/providers/fly/commands/setup/SetupCmdOptions.js +2 -0
- package/data/packages/deploy/dist/providers/fly/commands/setup/setup.js +141 -0
- package/data/packages/deploy/dist/providers/fly/flyAppUrl.js +4 -0
- package/data/packages/deploy/dist/providers/fly/flyCli.js +74 -0
- package/data/packages/deploy/dist/providers/fly/index.js +121 -0
- package/data/packages/deploy/dist/providers/fly/jsonOutputSchemas.js +37 -0
- package/data/packages/deploy/dist/providers/fly/tomlFile.js +65 -0
- package/data/packages/deploy/dist/providers/railway/DeploymentInstructions.js +11 -0
- package/data/packages/deploy/dist/providers/railway/brandedTypes.js +2 -0
- package/data/packages/deploy/dist/providers/railway/commands/deploy/DeployCmdOptions.js +2 -0
- package/data/packages/deploy/dist/providers/railway/commands/deploy/client.js +22 -0
- package/data/packages/deploy/dist/providers/railway/commands/deploy/common.js +40 -0
- package/data/packages/deploy/dist/providers/railway/commands/deploy/index.js +57 -0
- package/data/packages/deploy/dist/providers/railway/commands/deploy/server.js +17 -0
- package/data/packages/deploy/dist/providers/railway/commands/launch/LaunchCmdOptions.js +2 -0
- package/data/packages/deploy/dist/providers/railway/commands/launch/launch.js +9 -0
- package/data/packages/deploy/dist/providers/railway/commands/setup/SetupCmdOptions.js +2 -0
- package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +146 -0
- package/data/packages/deploy/dist/providers/railway/index.js +83 -0
- package/data/packages/deploy/dist/providers/railway/jsonOutputSchemas.js +19 -0
- package/data/packages/deploy/dist/providers/railway/ports.js +6 -0
- package/data/packages/deploy/dist/providers/railway/railwayCli.js +85 -0
- package/data/packages/deploy/dist/providers/railway/railwayProject/RailwayProject.js +14 -0
- package/data/packages/deploy/dist/providers/railway/railwayProject/cli.js +80 -0
- package/data/packages/deploy/dist/providers/railway/railwayProject/index.js +48 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/nameGenerator.js +24 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/url.js +32 -0
- package/data/packages/deploy/package-lock.json +3536 -0
- package/data/packages/deploy/package.json +29 -0
- package/data/packages/prisma/dist/format.js +35 -0
- package/data/packages/prisma/dist/index.js +33 -0
- package/data/packages/prisma/package-lock.json +5101 -0
- package/data/packages/prisma/package.json +30 -0
- package/data/packages/studio/dist/index.js +48 -0
- package/data/packages/studio/dist/public/assets/Flow-b5112d3d.js +26 -0
- package/data/packages/studio/dist/public/assets/index-17ce6ed4.css +1 -0
- package/data/packages/studio/dist/public/assets/index-62a9d21a.js +120 -0
- package/data/packages/studio/dist/public/index.html +14 -0
- package/data/packages/studio/package-lock.json +1866 -0
- package/data/packages/studio/package.json +33 -0
- package/data/packages/ts-inspect/dist/exports.js +82 -0
- package/data/packages/ts-inspect/dist/index.js +28 -0
- package/data/packages/ts-inspect/package-lock.json +4947 -0
- package/data/packages/ts-inspect/package.json +31 -0
- package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.d.ts +2 -0
- package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.js +59 -0
- package/data/packages/wasp-config/dist/__tests__/cli.unit.test.d.ts +2 -0
- package/data/packages/wasp-config/dist/__tests__/cli.unit.test.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/__tests__/cli.unit.test.js +65 -0
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.d.ts +2 -0
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.js +126 -0
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.d.ts +2 -0
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.js +743 -0
- package/data/packages/wasp-config/dist/__tests__/testFixtures.d.ts +224 -0
- package/data/packages/wasp-config/dist/__tests__/testFixtures.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/__tests__/testFixtures.js +656 -0
- package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.d.ts +2 -0
- package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.js +57 -0
- package/data/packages/wasp-config/dist/src/_private.d.ts +2 -0
- package/data/packages/wasp-config/dist/src/_private.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/_private.js +1 -0
- package/data/packages/wasp-config/dist/src/appAnalyzer.d.ts +16 -0
- package/data/packages/wasp-config/dist/src/appAnalyzer.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/appAnalyzer.js +34 -0
- package/data/packages/wasp-config/dist/src/appSpec.d.ts +223 -0
- package/data/packages/wasp-config/dist/src/appSpec.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/appSpec.js +6 -0
- package/data/packages/wasp-config/dist/src/branded.d.ts +7 -0
- package/data/packages/wasp-config/dist/src/branded.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/branded.js +1 -0
- package/data/packages/wasp-config/dist/src/cli.d.ts +6 -0
- package/data/packages/wasp-config/dist/src/cli.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/cli.js +24 -0
- package/data/packages/wasp-config/dist/src/index.d.ts +8 -0
- package/data/packages/wasp-config/dist/src/index.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/index.js +1 -0
- package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.d.ts +38 -0
- package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.js +294 -0
- package/data/packages/wasp-config/dist/src/publicApi/App.d.ts +24 -0
- package/data/packages/wasp-config/dist/src/publicApi/App.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/publicApi/App.js +75 -0
- package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts +171 -0
- package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.js +1 -0
- package/data/packages/wasp-config/dist/src/run.d.ts +3 -0
- package/data/packages/wasp-config/dist/src/run.d.ts.map +1 -0
- package/data/packages/wasp-config/dist/src/run.js +18 -0
- package/data/packages/wasp-config/package-lock.json +3992 -0
- package/data/packages/wasp-config/package.json +39 -0
- package/main.js +9 -0
- package/package.json +1 -0
- package/readme.md +3 -0
- package/wasp-bin +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
import { api, handleApiError } from 'wasp/client/api'
|
|
3
|
+
{=# usernameAndPasswordUserSignupFields.isDefined =}
|
|
4
|
+
import { type UserUsernameAndPasswordSignupFields } from '../../providers'
|
|
5
|
+
{=/ usernameAndPasswordUserSignupFields.isDefined =}
|
|
6
|
+
|
|
7
|
+
type UsernameSignupData = {
|
|
8
|
+
username: string
|
|
9
|
+
password: string
|
|
10
|
+
}{=# usernameAndPasswordUserSignupFields.isDefined =} & UserUsernameAndPasswordSignupFields{=/ usernameAndPasswordUserSignupFields.isDefined =}
|
|
11
|
+
|
|
12
|
+
// PUBLIC API
|
|
13
|
+
export async function signup(data: UsernameSignupData): Promise<void> {
|
|
14
|
+
try {
|
|
15
|
+
await api.post('{= signupPath =}', data)
|
|
16
|
+
} catch (error) {
|
|
17
|
+
throw handleApiError(error)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
import { hashPassword } from './password.js'
|
|
3
|
+
import { prisma, HttpError } from 'wasp/server'
|
|
4
|
+
import { sleep } from 'wasp/server/utils'
|
|
5
|
+
import {
|
|
6
|
+
type {= userEntityUpper =},
|
|
7
|
+
type {= authEntityUpper =},
|
|
8
|
+
type {= authIdentityEntityUpper =},
|
|
9
|
+
} from 'wasp/entities'
|
|
10
|
+
import { Prisma } from '@prisma/client';
|
|
11
|
+
|
|
12
|
+
import { throwValidationError } from './validation.js'
|
|
13
|
+
|
|
14
|
+
import { type UserSignupFields, type PossibleUserFields } from './providers/types.js'
|
|
15
|
+
|
|
16
|
+
// PUBLIC API
|
|
17
|
+
export type EmailProviderData = {
|
|
18
|
+
hashedPassword: string;
|
|
19
|
+
isEmailVerified: boolean;
|
|
20
|
+
emailVerificationSentAt: string | null;
|
|
21
|
+
passwordResetSentAt: string | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// PUBLIC API
|
|
25
|
+
export type UsernameProviderData = {
|
|
26
|
+
hashedPassword: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// PUBLIC API
|
|
30
|
+
export type OAuthProviderData = {}
|
|
31
|
+
|
|
32
|
+
// PRIVATE API
|
|
33
|
+
/**
|
|
34
|
+
* This type is used for type-level programming e.g. to enumerate
|
|
35
|
+
* all possible provider data types.
|
|
36
|
+
*
|
|
37
|
+
* The keys of this type are the names of the providers and the values
|
|
38
|
+
* are the types of the provider data.
|
|
39
|
+
*/
|
|
40
|
+
export type PossibleProviderData = {
|
|
41
|
+
email: EmailProviderData;
|
|
42
|
+
username: UsernameProviderData;
|
|
43
|
+
discord: OAuthProviderData;
|
|
44
|
+
slack: OAuthProviderData;
|
|
45
|
+
google: OAuthProviderData;
|
|
46
|
+
keycloak: OAuthProviderData;
|
|
47
|
+
github: OAuthProviderData;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// PUBLIC API
|
|
51
|
+
export type ProviderName = keyof PossibleProviderData
|
|
52
|
+
|
|
53
|
+
// PRIVATE API
|
|
54
|
+
export const contextWithUserEntity = {
|
|
55
|
+
entities: {
|
|
56
|
+
{= userEntityUpper =}: prisma.{= userEntityLower =}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// PRIVATE API
|
|
61
|
+
export const authConfig = {
|
|
62
|
+
failureRedirectPath: "{= failureRedirectPath =}",
|
|
63
|
+
successRedirectPath: "{= successRedirectPath =}",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// PUBLIC API
|
|
67
|
+
/**
|
|
68
|
+
* ProviderId uniquely identifies an auth identity e.g.
|
|
69
|
+
* "email" provider with user id "test@test.com" or
|
|
70
|
+
* "google" provider with user id "1234567890".
|
|
71
|
+
*
|
|
72
|
+
* We use this type to avoid passing the providerName and providerUserId
|
|
73
|
+
* separately. Also, we can normalize the providerUserId to make sure it's
|
|
74
|
+
* consistent across different DB operations.
|
|
75
|
+
*/
|
|
76
|
+
export type ProviderId = {
|
|
77
|
+
providerName: ProviderName;
|
|
78
|
+
providerUserId: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// PUBLIC API
|
|
82
|
+
export function createProviderId(providerName: ProviderName, providerUserId: string): ProviderId {
|
|
83
|
+
return {
|
|
84
|
+
providerName,
|
|
85
|
+
providerUserId: normalizeProviderUserId(providerName, providerUserId),
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// PRIVATE API
|
|
90
|
+
export function normalizeProviderUserId(providerName: ProviderName, providerUserId: string): string {
|
|
91
|
+
switch (providerName) {
|
|
92
|
+
case 'email':
|
|
93
|
+
case 'username':
|
|
94
|
+
return providerUserId.toLowerCase();
|
|
95
|
+
case 'google':
|
|
96
|
+
case 'github':
|
|
97
|
+
case 'discord':
|
|
98
|
+
case 'keycloak':
|
|
99
|
+
case 'slack':
|
|
100
|
+
return providerUserId;
|
|
101
|
+
/*
|
|
102
|
+
Why the default case?
|
|
103
|
+
In case users add a new auth provider in the user-land.
|
|
104
|
+
Users can't extend this function because it is private.
|
|
105
|
+
If there is an unknown `providerName` in runtime, we'll
|
|
106
|
+
return the `providerUserId` as is.
|
|
107
|
+
|
|
108
|
+
We want to still have explicit OAuth providers listed
|
|
109
|
+
so that we get a type error if we forget to add a new provider
|
|
110
|
+
to the switch statement.
|
|
111
|
+
*/
|
|
112
|
+
default:
|
|
113
|
+
providerName satisfies never;
|
|
114
|
+
return providerUserId;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// PUBLIC API
|
|
119
|
+
export async function findAuthIdentity(providerId: ProviderId): Promise<{= authIdentityEntityUpper =} | null> {
|
|
120
|
+
return prisma.{= authIdentityEntityLower =}.findUnique({
|
|
121
|
+
where: {
|
|
122
|
+
providerName_providerUserId: providerId,
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// PUBLIC API
|
|
128
|
+
/**
|
|
129
|
+
* Updates the provider data for the given auth identity.
|
|
130
|
+
*
|
|
131
|
+
* This function performs data sanitization and serialization.
|
|
132
|
+
* Sanitization is done by hashing the password, so this function
|
|
133
|
+
* expects the password received in the `providerDataUpdates`
|
|
134
|
+
* **not to be hashed**.
|
|
135
|
+
*/
|
|
136
|
+
export async function updateAuthIdentityProviderData<PN extends ProviderName>(
|
|
137
|
+
providerId: ProviderId,
|
|
138
|
+
existingProviderData: PossibleProviderData[PN],
|
|
139
|
+
providerDataUpdates: Partial<PossibleProviderData[PN]>,
|
|
140
|
+
): Promise<{= authIdentityEntityUpper =}> {
|
|
141
|
+
// We are doing the sanitization here only on updates to avoid
|
|
142
|
+
// hashing the password multiple times.
|
|
143
|
+
const sanitizedProviderDataUpdates = await ensurePasswordIsHashed(providerDataUpdates);
|
|
144
|
+
const newProviderData = {
|
|
145
|
+
...existingProviderData,
|
|
146
|
+
...sanitizedProviderDataUpdates,
|
|
147
|
+
}
|
|
148
|
+
const serializedProviderData = await serializeProviderData<PN>(newProviderData);
|
|
149
|
+
return prisma.{= authIdentityEntityLower =}.update({
|
|
150
|
+
where: {
|
|
151
|
+
providerName_providerUserId: providerId,
|
|
152
|
+
},
|
|
153
|
+
data: { providerData: serializedProviderData },
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// PRIVATE API
|
|
158
|
+
export type FindAuthWithUserResult = {= authEntityUpper =} & {
|
|
159
|
+
{= userFieldOnAuthEntityName =}: {= userEntityUpper =}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// PRIVATE API
|
|
163
|
+
export async function findAuthWithUserBy(
|
|
164
|
+
where: Prisma.{= authEntityUpper =}WhereInput
|
|
165
|
+
): Promise<FindAuthWithUserResult | null> {
|
|
166
|
+
const result = await prisma.{= authEntityLower =}.findFirst({ where, include: { {= userFieldOnAuthEntityName =}: true }});
|
|
167
|
+
|
|
168
|
+
if (result === null) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (result.user === null) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return { ...result, user: result.user };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// PUBLIC API
|
|
180
|
+
export type CreateUserResult = {= userEntityUpper =} & {
|
|
181
|
+
auth: {= authEntityUpper =} | null
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// PUBLIC API
|
|
185
|
+
export async function createUser(
|
|
186
|
+
providerId: ProviderId,
|
|
187
|
+
serializedProviderData?: string,
|
|
188
|
+
userFields?: PossibleUserFields,
|
|
189
|
+
): Promise<CreateUserResult> {
|
|
190
|
+
return prisma.{= userEntityLower =}.create({
|
|
191
|
+
data: {
|
|
192
|
+
// Using any here to prevent type errors when userFields are not
|
|
193
|
+
// defined. We want Prisma to throw an error in that case.
|
|
194
|
+
...(userFields ?? {} as any),
|
|
195
|
+
{= authFieldOnUserEntityName =}: {
|
|
196
|
+
create: {
|
|
197
|
+
{= identitiesFieldOnAuthEntityName =}: {
|
|
198
|
+
create: {
|
|
199
|
+
providerName: providerId.providerName,
|
|
200
|
+
providerUserId: providerId.providerUserId,
|
|
201
|
+
providerData: serializedProviderData,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
// We need to include the Auth entity here because we need `authId`
|
|
208
|
+
// to be able to create a session.
|
|
209
|
+
include: {
|
|
210
|
+
{= authFieldOnUserEntityName =}: true,
|
|
211
|
+
},
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// PRIVATE API
|
|
216
|
+
export async function deleteUserByAuthId(authId: string): Promise<{ count: number }> {
|
|
217
|
+
return prisma.{= userEntityLower =}.deleteMany({ where: { auth: {
|
|
218
|
+
id: authId,
|
|
219
|
+
} } })
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// PRIVATE API
|
|
223
|
+
// If an user exists, we don't want to leak information
|
|
224
|
+
// about it. Pretending that we're doing some work
|
|
225
|
+
// will make it harder for an attacker to determine
|
|
226
|
+
// if a user exists or not.
|
|
227
|
+
// NOTE: Attacker measuring time to response can still determine
|
|
228
|
+
// if a user exists or not. We'll be able to avoid it when
|
|
229
|
+
// we implement e-mail sending via jobs.
|
|
230
|
+
export async function doFakeWork(): Promise<unknown> {
|
|
231
|
+
const timeToWork = Math.floor(Math.random() * 1000) + 1000;
|
|
232
|
+
return sleep(timeToWork);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// PRIVATE API
|
|
236
|
+
export function rethrowPossibleAuthError(e: unknown): void {
|
|
237
|
+
// Prisma code P2002 is for unique constraint violations.
|
|
238
|
+
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2002') {
|
|
239
|
+
throw new HttpError(422, 'Save failed', {
|
|
240
|
+
message: `user with the same identity already exists`,
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (e instanceof Prisma.PrismaClientValidationError) {
|
|
245
|
+
// NOTE: Logging the error since this usually means that there are
|
|
246
|
+
// required fields missing in the request, we want the developer
|
|
247
|
+
// to know about it.
|
|
248
|
+
console.error(e)
|
|
249
|
+
throw new HttpError(422, 'Save failed', {
|
|
250
|
+
message: 'there was a database error'
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Prisma code P2021 is for missing table errors.
|
|
255
|
+
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2021') {
|
|
256
|
+
// NOTE: Logging the error since this usually means that the database
|
|
257
|
+
// migrations weren't run, we want the developer to know about it.
|
|
258
|
+
console.error(e)
|
|
259
|
+
console.info('🐝 This error can happen if you did\'t run the database migrations.')
|
|
260
|
+
throw new HttpError(500, 'Save failed', {
|
|
261
|
+
message: `there was a database error`,
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Prisma code P2003 is for foreign key constraint failure
|
|
266
|
+
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2003') {
|
|
267
|
+
console.error(e)
|
|
268
|
+
console.info(`🐝 This error can happen if you have some relation on your {= userEntityUpper =} entity
|
|
269
|
+
but you didn't specify the "onDelete" behaviour to either "Cascade" or "SetNull".
|
|
270
|
+
Read more at: https://www.prisma.io/docs/orm/prisma-schema/data-model/relations/referential-actions`)
|
|
271
|
+
throw new HttpError(500, 'Save failed', {
|
|
272
|
+
message: `there was a database error`,
|
|
273
|
+
})
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
throw e
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// PRIVATE API
|
|
280
|
+
export async function validateAndGetUserFields(
|
|
281
|
+
data: {
|
|
282
|
+
[key: string]: unknown
|
|
283
|
+
},
|
|
284
|
+
userSignupFields?: UserSignupFields,
|
|
285
|
+
): Promise<Record<string, any>> {
|
|
286
|
+
const {
|
|
287
|
+
password: _password,
|
|
288
|
+
...sanitizedData
|
|
289
|
+
} = data;
|
|
290
|
+
const result: Record<string, any> = {};
|
|
291
|
+
|
|
292
|
+
if (!userSignupFields) {
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
for (const [field, getFieldValue] of Object.entries(userSignupFields)) {
|
|
297
|
+
try {
|
|
298
|
+
const value = await getFieldValue(sanitizedData)
|
|
299
|
+
result[field] = value
|
|
300
|
+
} catch (e) {
|
|
301
|
+
throwValidationError(e.message)
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// PUBLIC API
|
|
308
|
+
export function getProviderData<PN extends ProviderName>(
|
|
309
|
+
providerData: string,
|
|
310
|
+
): Omit<PossibleProviderData[PN], 'hashedPassword'> {
|
|
311
|
+
return sanitizeProviderData(getProviderDataWithPassword(providerData));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// PUBLIC API
|
|
315
|
+
export function getProviderDataWithPassword<PN extends ProviderName>(
|
|
316
|
+
providerData: string,
|
|
317
|
+
): PossibleProviderData[PN] {
|
|
318
|
+
// NOTE: We are letting JSON.parse throw an error if the providerData is not valid JSON.
|
|
319
|
+
return JSON.parse(providerData);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function sanitizeProviderData<PN extends ProviderName>(
|
|
323
|
+
providerData: PossibleProviderData[PN],
|
|
324
|
+
): Omit<PossibleProviderData[PN], 'hashedPassword'> {
|
|
325
|
+
if (providerDataHasPasswordField(providerData)) {
|
|
326
|
+
const { hashedPassword, ...rest } = providerData;
|
|
327
|
+
return rest;
|
|
328
|
+
} else {
|
|
329
|
+
return providerData;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// PUBLIC API
|
|
334
|
+
export async function sanitizeAndSerializeProviderData<PN extends ProviderName>(
|
|
335
|
+
providerData: PossibleProviderData[PN],
|
|
336
|
+
): Promise<string> {
|
|
337
|
+
return serializeProviderData(
|
|
338
|
+
await ensurePasswordIsHashed(providerData)
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function serializeProviderData<PN extends ProviderName>(providerData: PossibleProviderData[PN]): string {
|
|
343
|
+
return JSON.stringify(providerData);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
async function ensurePasswordIsHashed<PN extends ProviderName>(
|
|
347
|
+
providerData: PossibleProviderData[PN],
|
|
348
|
+
): Promise<PossibleProviderData[PN]> {
|
|
349
|
+
const data = {
|
|
350
|
+
...providerData,
|
|
351
|
+
};
|
|
352
|
+
if (providerDataHasPasswordField(data)) {
|
|
353
|
+
data.hashedPassword = await hashPassword(data.hashedPassword);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return data;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
function providerDataHasPasswordField(
|
|
361
|
+
providerData: PossibleProviderData[keyof PossibleProviderData],
|
|
362
|
+
): providerData is { hashedPassword: string } {
|
|
363
|
+
return 'hashedPassword' in providerData;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// PRIVATE API
|
|
367
|
+
export function createInvalidCredentialsError(message?: string): HttpError {
|
|
368
|
+
return new HttpError(401, 'Invalid credentials', { message })
|
|
369
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { HttpError } from 'wasp/server';
|
|
2
|
+
|
|
3
|
+
export const PASSWORD_FIELD = 'password';
|
|
4
|
+
const USERNAME_FIELD = 'username';
|
|
5
|
+
const EMAIL_FIELD = 'email';
|
|
6
|
+
const TOKEN_FIELD = 'token';
|
|
7
|
+
|
|
8
|
+
// PUBLIC API
|
|
9
|
+
export function ensureValidEmail(args: object): void {
|
|
10
|
+
validate(args, [
|
|
11
|
+
{ validates: EMAIL_FIELD, message: 'email must be present', validator: email => !!email },
|
|
12
|
+
{ validates: EMAIL_FIELD, message: 'email must be a valid email', validator: email => isValidEmail(email) },
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// PUBLIC API
|
|
17
|
+
export function ensureValidUsername(args: object): void {
|
|
18
|
+
validate(args, [
|
|
19
|
+
{ validates: USERNAME_FIELD, message: 'username must be present', validator: username => !!username }
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// PUBLIC API
|
|
24
|
+
export function ensurePasswordIsPresent(args: object): void {
|
|
25
|
+
validate(args, [
|
|
26
|
+
{ validates: PASSWORD_FIELD, message: 'password must be present', validator: password => !!password },
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// PUBLIC API
|
|
31
|
+
export function ensureValidPassword(args: object): void {
|
|
32
|
+
validate(args, [
|
|
33
|
+
{ validates: PASSWORD_FIELD, message: 'password must be at least 8 characters', validator: password => isMinLength(password, 8) },
|
|
34
|
+
{ validates: PASSWORD_FIELD, message: 'password must contain a number', validator: password => containsNumber(password) },
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// PUBLIC API
|
|
39
|
+
export function ensureTokenIsPresent(args: object): void {
|
|
40
|
+
validate(args, [
|
|
41
|
+
{ validates: TOKEN_FIELD, message: 'token must be present', validator: token => !!token },
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// PRIVATE API
|
|
46
|
+
export function throwValidationError(message: string): void {
|
|
47
|
+
throw new HttpError(422, 'Validation failed', { message })
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function validate(args: object, validators: { validates: string, message: string, validator: (value: unknown) => boolean }[]): void {
|
|
51
|
+
for (const { validates, message, validator } of validators) {
|
|
52
|
+
if (!validator(args[validates])) {
|
|
53
|
+
throwValidationError(message);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// NOTE(miho): it would be good to replace our custom validations with e.g. Zod
|
|
59
|
+
|
|
60
|
+
const validEmailRegex = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/
|
|
61
|
+
function isValidEmail(input: unknown): boolean {
|
|
62
|
+
if (typeof input !== 'string') {
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return input.match(validEmailRegex) !== null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function isMinLength(input: unknown, minLength: number): boolean {
|
|
70
|
+
if (typeof input !== 'string') {
|
|
71
|
+
return false
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return input.length >= minLength
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function containsNumber(input: unknown): boolean {
|
|
78
|
+
if (typeof input !== 'string') {
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return /\d/.test(input)
|
|
83
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// PUBLIC API
|
|
2
|
+
export { login } from '../../auth/email/actions/login'
|
|
3
|
+
export { signup } from '../../auth/email/actions/signup'
|
|
4
|
+
export { requestPasswordReset, resetPassword } from '../../auth/email/actions/passwordReset'
|
|
5
|
+
export { verifyEmail } from '../../auth/email/actions/verifyEmail'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
export * from './ui'
|
|
3
|
+
{=# isEmailAuthEnabled =}
|
|
4
|
+
export * from './email'
|
|
5
|
+
{=/ isEmailAuthEnabled =}
|
|
6
|
+
{=# isUsernameAndPasswordAuthEnabled =}
|
|
7
|
+
export * from './username'
|
|
8
|
+
{=/ isUsernameAndPasswordAuthEnabled =}
|
|
9
|
+
{=# isSlackAuthEnabled =}
|
|
10
|
+
export * from './slack'
|
|
11
|
+
{=/ isSlackAuthEnabled =}
|
|
12
|
+
{=# isDiscordAuthEnabled =}
|
|
13
|
+
export * from './discord'
|
|
14
|
+
{=/ isDiscordAuthEnabled =}
|
|
15
|
+
{=# isGoogleAuthEnabled =}
|
|
16
|
+
export * from './google'
|
|
17
|
+
{=/ isGoogleAuthEnabled =}
|
|
18
|
+
{=# isKeycloakAuthEnabled =}
|
|
19
|
+
export * from './keycloak'
|
|
20
|
+
{=/ isKeycloakAuthEnabled =}
|
|
21
|
+
{=# isGitHubAuthEnabled =}
|
|
22
|
+
export * from './github'
|
|
23
|
+
{=/ isGitHubAuthEnabled =}
|
|
24
|
+
export {
|
|
25
|
+
default as useAuth,
|
|
26
|
+
getMe,
|
|
27
|
+
} from '../../auth/useAuth'
|
|
28
|
+
|
|
29
|
+
export { default as logout } from '../../auth/logout'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
// PUBLIC API
|
|
3
|
+
export { LoginForm } from '../../auth/forms/Login'
|
|
4
|
+
export { SignupForm } from '../../auth/forms/Signup'
|
|
5
|
+
{=# isEmailAuthEnabled =}
|
|
6
|
+
export { ForgotPasswordForm } from '../../auth/forms/ForgotPassword'
|
|
7
|
+
export { VerifyEmailForm } from '../../auth/forms/VerifyEmail'
|
|
8
|
+
export { ResetPasswordForm } from '../../auth/forms/ResetPassword'
|
|
9
|
+
{=/ isEmailAuthEnabled =}
|
|
10
|
+
export type { CustomizationOptions } from '../../auth/forms/types'
|
|
11
|
+
{=# isSlackAuthEnabled =}
|
|
12
|
+
export { SignInButton as SlackSignInButton } from '../../auth/helpers/Slack'
|
|
13
|
+
{=/ isSlackAuthEnabled =}
|
|
14
|
+
{=# isDiscordAuthEnabled =}
|
|
15
|
+
export { SignInButton as DiscordSignInButton } from '../../auth/helpers/Discord'
|
|
16
|
+
{=/ isDiscordAuthEnabled =}
|
|
17
|
+
{=# isGoogleAuthEnabled =}
|
|
18
|
+
export { SignInButton as GoogleSignInButton } from '../../auth/helpers/Google'
|
|
19
|
+
{=/ isGoogleAuthEnabled =}
|
|
20
|
+
{=# isKeycloakAuthEnabled =}
|
|
21
|
+
export { SignInButton as KeycloakSignInButton } from '../../auth/helpers/Keycloak'
|
|
22
|
+
{=/ isKeycloakAuthEnabled =}
|
|
23
|
+
{=# isGitHubAuthEnabled =}
|
|
24
|
+
export { SignInButton as GitHubSignInButton } from '../../auth/helpers/GitHub'
|
|
25
|
+
{=/ isGitHubAuthEnabled =}
|
|
26
|
+
export {
|
|
27
|
+
FormError,
|
|
28
|
+
FormInput,
|
|
29
|
+
FormTextarea,
|
|
30
|
+
FormItemGroup,
|
|
31
|
+
FormLabel,
|
|
32
|
+
} from '../../auth/forms/internal/Form'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
import { stripTrailingSlash } from '../universal/url.js'
|
|
3
|
+
import { env } from './env.js'
|
|
4
|
+
|
|
5
|
+
const apiUrl = stripTrailingSlash(env["{= serverUrlEnvVarName =}"])
|
|
6
|
+
|
|
7
|
+
// PUBLIC API
|
|
8
|
+
export type ClientConfig = {
|
|
9
|
+
apiUrl: string,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// PUBLIC API
|
|
13
|
+
export const config: ClientConfig = {
|
|
14
|
+
apiUrl,
|
|
15
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
import { createAction } from "../operations/actions/core.js";
|
|
3
|
+
import { createQuery } from "../operations/queries/core.js";
|
|
4
|
+
import { makeUseActionFor, makeUseQueryFor } from "./operationsHelpers.js";
|
|
5
|
+
import {
|
|
6
|
+
{=# operations.Get =}
|
|
7
|
+
GetQueryResolved,
|
|
8
|
+
{=/ operations.Get =}
|
|
9
|
+
{=# operations.GetAll =}
|
|
10
|
+
GetAllQueryResolved,
|
|
11
|
+
{=/ operations.GetAll =}
|
|
12
|
+
{=# operations.Create =}
|
|
13
|
+
CreateActionResolved,
|
|
14
|
+
{=/ operations.Create =}
|
|
15
|
+
{=# operations.Update =}
|
|
16
|
+
UpdateActionResolved,
|
|
17
|
+
{=/ operations.Update =}
|
|
18
|
+
{=# operations.Delete =}
|
|
19
|
+
DeleteActionResolved,
|
|
20
|
+
{=/ operations.Delete =}
|
|
21
|
+
} from 'wasp/server/crud/{= name =}'
|
|
22
|
+
|
|
23
|
+
function createCrud() {
|
|
24
|
+
{=# operations.Get =}
|
|
25
|
+
const crudGetQuery = createQuery<GetQueryResolved>(
|
|
26
|
+
'{= fullPath =}',
|
|
27
|
+
{=& entitiesArray =}
|
|
28
|
+
)
|
|
29
|
+
{=/ operations.Get =}
|
|
30
|
+
{=# operations.GetAll =}
|
|
31
|
+
const crudGetAllQuery = createQuery<GetAllQueryResolved>(
|
|
32
|
+
'{= fullPath =}',
|
|
33
|
+
{=& entitiesArray =}
|
|
34
|
+
)
|
|
35
|
+
{=/ operations.GetAll =}
|
|
36
|
+
{=# operations.Create =}
|
|
37
|
+
const crudCreateAction = createAction<CreateActionResolved>(
|
|
38
|
+
'{= fullPath =}',
|
|
39
|
+
{=& entitiesArray =}
|
|
40
|
+
)
|
|
41
|
+
{=/ operations.Create =}
|
|
42
|
+
{=# operations.Update =}
|
|
43
|
+
const crudUpdateAction = createAction<UpdateActionResolved>(
|
|
44
|
+
'{= fullPath =}',
|
|
45
|
+
{=& entitiesArray =}
|
|
46
|
+
)
|
|
47
|
+
{=/ operations.Update =}
|
|
48
|
+
{=# operations.Delete =}
|
|
49
|
+
const crudDeleteAction = createAction<DeleteActionResolved>(
|
|
50
|
+
'{= fullPath =}',
|
|
51
|
+
{=& entitiesArray =}
|
|
52
|
+
)
|
|
53
|
+
{=/ operations.Delete =}
|
|
54
|
+
return {
|
|
55
|
+
{=# operations.Get =}
|
|
56
|
+
get: {
|
|
57
|
+
query: crudGetQuery,
|
|
58
|
+
useQuery: makeUseQueryFor(crudGetQuery)
|
|
59
|
+
},
|
|
60
|
+
{=/ operations.Get =}
|
|
61
|
+
{=# operations.GetAll =}
|
|
62
|
+
getAll: {
|
|
63
|
+
query: crudGetAllQuery,
|
|
64
|
+
useQuery: makeUseQueryFor(crudGetAllQuery)
|
|
65
|
+
},
|
|
66
|
+
{=/ operations.GetAll =}
|
|
67
|
+
{=# operations.Create =}
|
|
68
|
+
create: {
|
|
69
|
+
action: crudCreateAction,
|
|
70
|
+
useAction: makeUseActionFor(crudCreateAction)
|
|
71
|
+
},
|
|
72
|
+
{=/ operations.Create =}
|
|
73
|
+
{=# operations.Update =}
|
|
74
|
+
update: {
|
|
75
|
+
action: crudUpdateAction,
|
|
76
|
+
useAction: makeUseActionFor(crudUpdateAction)
|
|
77
|
+
},
|
|
78
|
+
{=/ operations.Update =}
|
|
79
|
+
{=# operations.Delete =}
|
|
80
|
+
delete: {
|
|
81
|
+
action: crudDeleteAction,
|
|
82
|
+
useAction: makeUseActionFor(crudDeleteAction)
|
|
83
|
+
},
|
|
84
|
+
{=/ operations.Delete =}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// PUBLIC API
|
|
89
|
+
export const {= name =} = createCrud();
|