@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,91 @@
|
|
|
1
|
+
import { Route } from 'wasp/client'
|
|
2
|
+
import type { _Awaited, _ReturnType } from 'wasp/universal/types'
|
|
3
|
+
import type {
|
|
4
|
+
GenericBackendOperation,
|
|
5
|
+
GenericOperationRpc,
|
|
6
|
+
OperationRpcFor,
|
|
7
|
+
Query,
|
|
8
|
+
QueryMetadata,
|
|
9
|
+
} from '../rpc.js'
|
|
10
|
+
import { callOperation, makeOperationRoute } from '../internal/index.js'
|
|
11
|
+
import {
|
|
12
|
+
addResourcesUsedByQuery,
|
|
13
|
+
getActiveOptimisticUpdates,
|
|
14
|
+
} from '../internal/resources'
|
|
15
|
+
|
|
16
|
+
// PRIVATE API (used in the SDK)
|
|
17
|
+
// todo: find ways to remove this duplication and make the type more precise.
|
|
18
|
+
// Details here: https://github.com/wasp-lang/wasp/issues/2017
|
|
19
|
+
export function makeQueryCacheKey<Input, Output>(
|
|
20
|
+
query: Query<Input, Output>,
|
|
21
|
+
payload: Input
|
|
22
|
+
): (string | Input)[] {
|
|
23
|
+
return payload !== undefined ?
|
|
24
|
+
[...query.queryCacheKey, payload]
|
|
25
|
+
: query.queryCacheKey
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// PRIVATE API (unsed in SDK)
|
|
29
|
+
export function createQuery<BackendQuery extends GenericBackendOperation>(
|
|
30
|
+
relativeQueryPath: string,
|
|
31
|
+
entitiesUsed: string[]
|
|
32
|
+
): QueryFor<BackendQuery> {
|
|
33
|
+
const queryRoute = makeOperationRoute(relativeQueryPath)
|
|
34
|
+
const queryCacheKey = [relativeQueryPath]
|
|
35
|
+
|
|
36
|
+
const queryFn = (async (queryArgs) => {
|
|
37
|
+
const serverResult = await callOperation(queryRoute, queryArgs)
|
|
38
|
+
// todo: The full queryCacheKey is constructed in two places, both here and
|
|
39
|
+
// inside the useQuery hook. See
|
|
40
|
+
// https://github.com/wasp-lang/wasp/issues/2017
|
|
41
|
+
const queryCacheKey = makeQueryCacheKey(queryFn as QueryFor<BackendQuery>, queryArgs)
|
|
42
|
+
return getActiveOptimisticUpdates(queryCacheKey).reduce(
|
|
43
|
+
(result, update) => update(result),
|
|
44
|
+
serverResult,
|
|
45
|
+
)
|
|
46
|
+
// This assertion is necessary because, when the Input is void, we want to
|
|
47
|
+
// present the function as not accepting a payload (which isn't consistent
|
|
48
|
+
// with how it's defined).
|
|
49
|
+
}) as QueryFunctionFor<BackendQuery>
|
|
50
|
+
|
|
51
|
+
return buildAndRegisterQuery(
|
|
52
|
+
queryFn,
|
|
53
|
+
{ queryCacheKey, queryRoute, entitiesUsed },
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// PRIVATE API (used in SDK)
|
|
58
|
+
export function buildAndRegisterQuery<QF extends GenericOperationRpc>(
|
|
59
|
+
queryFn: QF,
|
|
60
|
+
{ queryCacheKey, queryRoute, entitiesUsed }:
|
|
61
|
+
{ queryCacheKey: string[], queryRoute: Route, entitiesUsed: string[] }
|
|
62
|
+
): QueryForFunction<QF> {
|
|
63
|
+
const query = queryFn as QueryForFunction<QF>
|
|
64
|
+
|
|
65
|
+
query.queryCacheKey = queryCacheKey
|
|
66
|
+
query.route = queryRoute
|
|
67
|
+
addResourcesUsedByQuery(query.queryCacheKey, entitiesUsed)
|
|
68
|
+
|
|
69
|
+
return query
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// PRIVATE API (but should maybe be public, users define values of this type)
|
|
73
|
+
/**
|
|
74
|
+
* Constructs the client Query object type from the type of the Query's definition
|
|
75
|
+
* on the backend.
|
|
76
|
+
*/
|
|
77
|
+
export type QueryFor<BackendQuery extends GenericBackendOperation> =
|
|
78
|
+
QueryForFunction<QueryFunctionFor<BackendQuery>>
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Constructs the client Query function type from the type of the Query's
|
|
82
|
+
* definition on the backend.
|
|
83
|
+
*/
|
|
84
|
+
type QueryFunctionFor<BackendQuery extends GenericBackendOperation> =
|
|
85
|
+
OperationRpcFor<BackendQuery>
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Returns the appropriate client Query object type for the provided client
|
|
89
|
+
* Query function type.
|
|
90
|
+
*/
|
|
91
|
+
type QueryForFunction<QF extends GenericOperationRpc> = QF & QueryMetadata
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
import { type QueryFor, createQuery } from './core'
|
|
3
|
+
{=# queries =}
|
|
4
|
+
{=& operationTypeImportStmt =}
|
|
5
|
+
{=/ queries =}
|
|
6
|
+
{=# queries =}
|
|
7
|
+
|
|
8
|
+
// PUBLIC API
|
|
9
|
+
export const {= operationName =}: QueryFor<{= operationTypeName =}> = createQuery<{= operationTypeName =}>(
|
|
10
|
+
'{= queryRoute =}',
|
|
11
|
+
{=& entitiesArray =},
|
|
12
|
+
)
|
|
13
|
+
{=/ queries =}
|
|
14
|
+
|
|
15
|
+
// PRIVATE API (used in SDK)
|
|
16
|
+
export { buildAndRegisterQuery } from './core'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { QueryClient, QueryClientConfig } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
const defaultQueryClientConfig = {};
|
|
4
|
+
|
|
5
|
+
let queryClientConfig: QueryClientConfig,
|
|
6
|
+
resolveQueryClientInitialized: (...args: any[]) => any,
|
|
7
|
+
isQueryClientInitialized: boolean;
|
|
8
|
+
|
|
9
|
+
// PRIVATE API (framework code)
|
|
10
|
+
export const queryClientInitialized: Promise<QueryClient> = new Promise(
|
|
11
|
+
(resolve) => {
|
|
12
|
+
resolveQueryClientInitialized = resolve;
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// PUBLIC API
|
|
17
|
+
export function configureQueryClient(config: QueryClientConfig): void {
|
|
18
|
+
if (isQueryClientInitialized) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"Attempted to configure the QueryClient after initialization"
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
queryClientConfig = config;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// PRIVATE API (framework code)
|
|
28
|
+
export function initializeQueryClient(): void {
|
|
29
|
+
const queryClient = new QueryClient(
|
|
30
|
+
queryClientConfig ?? defaultQueryClientConfig
|
|
31
|
+
);
|
|
32
|
+
isQueryClientInitialized = true;
|
|
33
|
+
resolveQueryClientInitialized(queryClient);
|
|
34
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type Route } from "wasp/client";
|
|
2
|
+
import type {
|
|
3
|
+
IfAny,
|
|
4
|
+
_Awaited,
|
|
5
|
+
_ReturnType,
|
|
6
|
+
} from "wasp/universal/types"
|
|
7
|
+
|
|
8
|
+
// PRIVATE API (for SDK, should maybe be public, users define values of this
|
|
9
|
+
// type).
|
|
10
|
+
//
|
|
11
|
+
// Frontend queries are functions with some extra properties (metadata).
|
|
12
|
+
//
|
|
13
|
+
// To simplify working with the type (i.e., referencing the type's two different
|
|
14
|
+
// components), we've defined it as an intersection of two distinct types:
|
|
15
|
+
// one representing the function (QueryFunction), and the other representing the
|
|
16
|
+
// metadata (QueryMetadata) .
|
|
17
|
+
/**
|
|
18
|
+
* The client Query object type. It's a callable Query function with some extra
|
|
19
|
+
* properties (metadata).
|
|
20
|
+
*/
|
|
21
|
+
export type Query<Input, Output> = QueryFunction<Input, Output> & QueryMetadata
|
|
22
|
+
|
|
23
|
+
// PRIVATE API (for SDK, should maybe be public, users define values of this
|
|
24
|
+
// type)
|
|
25
|
+
/**
|
|
26
|
+
* The client Action object type (unlike a Query, it's just a normal function).
|
|
27
|
+
*/
|
|
28
|
+
export type Action<Input, Output> = ClientOperation<Input, Output>
|
|
29
|
+
|
|
30
|
+
// PRIVATE API (for SDK)
|
|
31
|
+
/**
|
|
32
|
+
* The client Query function type.
|
|
33
|
+
*/
|
|
34
|
+
export type QueryFunction<Input, Output> = ClientOperation<Input, Output>
|
|
35
|
+
|
|
36
|
+
// PRIVATE API (for SDK)
|
|
37
|
+
// todo: revisit what we expose. Also, queryCacheKey is confusing and
|
|
38
|
+
// incorrect.Details here: https://github.com/wasp-lang/wasp/issues/2017
|
|
39
|
+
/**
|
|
40
|
+
* All extra properties (metadata) found on a Query object type.
|
|
41
|
+
*/
|
|
42
|
+
export type QueryMetadata = {
|
|
43
|
+
queryCacheKey: string[]
|
|
44
|
+
route: Route
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// PRIVATE API (needed in SDK)
|
|
48
|
+
// Explanation:
|
|
49
|
+
// - Custom `_Awaited` and `_ReturnType` - Read the comments above their
|
|
50
|
+
// definitions.
|
|
51
|
+
// - `Parameters<BackendOperation> extends []` - See here:
|
|
52
|
+
// https://github.com/wasp-lang/wasp/pull/1992/files#r1583040080
|
|
53
|
+
/**
|
|
54
|
+
* Constructs the client RPC function type from the type of the operation's
|
|
55
|
+
* definition on the backend.
|
|
56
|
+
*/
|
|
57
|
+
export type OperationRpcFor<BackendOperation extends GenericBackendOperation> =
|
|
58
|
+
Parameters<BackendOperation> extends []
|
|
59
|
+
? ClientOperation<void, _Awaited<_ReturnType<BackendOperation>>>
|
|
60
|
+
: ClientOperation<
|
|
61
|
+
Parameters<BackendOperation>[0],
|
|
62
|
+
_Awaited<_ReturnType<BackendOperation>>
|
|
63
|
+
>
|
|
64
|
+
|
|
65
|
+
// PRIVATE API (needed in SDK)
|
|
66
|
+
/**
|
|
67
|
+
* A supertype of all possible backend operation definitions (i.e., Queries and
|
|
68
|
+
* Actions)
|
|
69
|
+
*/
|
|
70
|
+
export type GenericBackendOperation = (args: never, context: any) => unknown
|
|
71
|
+
|
|
72
|
+
// PRIVATE API (needed in SDK)
|
|
73
|
+
/**
|
|
74
|
+
* A supertype of all possible frontend RPC function types.
|
|
75
|
+
*/
|
|
76
|
+
export type GenericOperationRpc = (args: never) => Promise<unknown>
|
|
77
|
+
|
|
78
|
+
// NOTE: There's some duplication in the below types.
|
|
79
|
+
// Read the discussion here to understand why before trying to remove it:
|
|
80
|
+
// https://github.com/wasp-lang/wasp/pull/2170#discussion_r1671285049
|
|
81
|
+
//
|
|
82
|
+
// Read this to understand the type: https://github.com/wasp-lang/wasp/pull/2170#issue-2398830273
|
|
83
|
+
type ClientOperation<Input, Output> =
|
|
84
|
+
IfAny<
|
|
85
|
+
Input,
|
|
86
|
+
(args?: any) => Promise<Output>,
|
|
87
|
+
ClientOperationWithNonAnyInput<Input, Output>
|
|
88
|
+
>
|
|
89
|
+
|
|
90
|
+
// Read this to understand the type: https://github.com/wasp-lang/wasp/pull/1090#discussion_r1159732471
|
|
91
|
+
type ClientOperationWithNonAnyInput<Input, Output> =
|
|
92
|
+
[Input] extends [never]
|
|
93
|
+
? (args?: unknown) => Promise<Output>
|
|
94
|
+
: [Input] extends [void]
|
|
95
|
+
? () => Promise<Output>
|
|
96
|
+
: (args: Input) => Promise<Output>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { Link as RouterLink } from 'react-router-dom'
|
|
3
|
+
import { interpolatePath } from './linkHelpers'
|
|
4
|
+
import { type Routes } from './index'
|
|
5
|
+
|
|
6
|
+
type RouterLinkProps = Parameters<typeof RouterLink>[0]
|
|
7
|
+
|
|
8
|
+
// PUBLIC API
|
|
9
|
+
export function Link(
|
|
10
|
+
{ to, params, search, hash, ...restOfProps }: Omit<RouterLinkProps, "to">
|
|
11
|
+
& {
|
|
12
|
+
search?: Record<string, string>;
|
|
13
|
+
hash?: string;
|
|
14
|
+
}
|
|
15
|
+
& Routes
|
|
16
|
+
): React.JSX.Element {
|
|
17
|
+
const toPropWithParams = useMemo(() => {
|
|
18
|
+
return interpolatePath(to, params, search, hash)
|
|
19
|
+
}, [to, params])
|
|
20
|
+
return <RouterLink to={toPropWithParams} {...restOfProps} />
|
|
21
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
import { interpolatePath } from './linkHelpers'
|
|
3
|
+
import type {
|
|
4
|
+
RouteDefinitionsToRoutes,
|
|
5
|
+
OptionalRouteOptions,
|
|
6
|
+
ParamValue,
|
|
7
|
+
ExpandRouteOnOptionalStaticSegments,
|
|
8
|
+
} from './types'
|
|
9
|
+
|
|
10
|
+
// PUBLIC API
|
|
11
|
+
export const routes = {
|
|
12
|
+
{=# routes =}
|
|
13
|
+
{= name =}: {
|
|
14
|
+
to: "{= urlPath =}",
|
|
15
|
+
{=# hasUrlParams =}
|
|
16
|
+
build: (
|
|
17
|
+
options: OptionalRouteOptions
|
|
18
|
+
& { params: {{=# urlParams =}"{= name =}"{=# isOptional =}?{=/ isOptional =}: ParamValue;{=/ urlParams =}}}
|
|
19
|
+
{=# hasOptionalStaticSegments =}
|
|
20
|
+
& { path: ExpandRouteOnOptionalStaticSegments<"{= urlPath =}"> }
|
|
21
|
+
{=/ hasOptionalStaticSegments =}
|
|
22
|
+
) => interpolatePath(
|
|
23
|
+
{=# hasOptionalStaticSegments =}options.path,{=/ hasOptionalStaticSegments =}
|
|
24
|
+
{=^ hasOptionalStaticSegments =}"{= urlPath =}",{=/ hasOptionalStaticSegments =}
|
|
25
|
+
options.params,
|
|
26
|
+
options?.search,
|
|
27
|
+
options?.hash
|
|
28
|
+
),
|
|
29
|
+
{=/ hasUrlParams =}
|
|
30
|
+
{=^ hasUrlParams =}
|
|
31
|
+
build: (
|
|
32
|
+
options?:
|
|
33
|
+
OptionalRouteOptions
|
|
34
|
+
{=# hasOptionalStaticSegments =}
|
|
35
|
+
& { path: ExpandRouteOnOptionalStaticSegments<"{= urlPath =}"> }
|
|
36
|
+
{=/ hasOptionalStaticSegments =}
|
|
37
|
+
) => interpolatePath(
|
|
38
|
+
{=# hasOptionalStaticSegments =}options.path,{=/ hasOptionalStaticSegments =}
|
|
39
|
+
{=^ hasOptionalStaticSegments =}"{= urlPath =}",{=/ hasOptionalStaticSegments =}
|
|
40
|
+
undefined,
|
|
41
|
+
options?.search,
|
|
42
|
+
options?.hash
|
|
43
|
+
),
|
|
44
|
+
{=/ hasUrlParams =}
|
|
45
|
+
},
|
|
46
|
+
{=/ routes =}
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
// PRIVATE API
|
|
50
|
+
export type Routes = RouteDefinitionsToRoutes<typeof routes>
|
|
51
|
+
|
|
52
|
+
// PUBLIC API
|
|
53
|
+
export { Link } from './Link'
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Params, Search } from "./types";
|
|
2
|
+
|
|
3
|
+
// PRIVATE API
|
|
4
|
+
export function interpolatePath(
|
|
5
|
+
path: string,
|
|
6
|
+
params?: Params,
|
|
7
|
+
search?: Search,
|
|
8
|
+
hash?: string
|
|
9
|
+
) {
|
|
10
|
+
const interpolatedPath = params ? interpolatePathParams(path, params) : path
|
|
11
|
+
const interpolatedSearch = search
|
|
12
|
+
? `?${new URLSearchParams(search).toString()}`
|
|
13
|
+
: ''
|
|
14
|
+
const interpolatedHash = hash ? `#${hash}` : ''
|
|
15
|
+
return interpolatedPath + interpolatedSearch + interpolatedHash
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function interpolatePathParams(path: string, params: Params) {
|
|
19
|
+
function mapPathPart(part: string) {
|
|
20
|
+
if (part === '*') {
|
|
21
|
+
return params['*'];
|
|
22
|
+
}
|
|
23
|
+
if (part.startsWith(":")) {
|
|
24
|
+
const paramName = extractParamNameFromPathPart(part);
|
|
25
|
+
return params[paramName];
|
|
26
|
+
}
|
|
27
|
+
return part;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const interpolatedPath = path
|
|
31
|
+
.split("/")
|
|
32
|
+
.map(mapPathPart)
|
|
33
|
+
.filter(isValidPathPart)
|
|
34
|
+
.join("/");
|
|
35
|
+
|
|
36
|
+
return path.startsWith("/") ? `/${interpolatedPath}` : interpolatedPath;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isValidPathPart(part: any): boolean {
|
|
40
|
+
return !!part;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function extractParamNameFromPathPart(paramString: string) {
|
|
44
|
+
if (paramString.endsWith("?")) {
|
|
45
|
+
return paramString.slice(1, -1);
|
|
46
|
+
}
|
|
47
|
+
return paramString.slice(1);
|
|
48
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// PRIVATE API
|
|
2
|
+
export type RouteDefinitionsToRoutes<Routes extends RoutesDefinition> =
|
|
3
|
+
RouteDefinitionsToRoutesObj<Routes>[keyof RouteDefinitionsToRoutesObj<Routes>]
|
|
4
|
+
|
|
5
|
+
// PRIVATE API
|
|
6
|
+
export type OptionalRouteOptions = {
|
|
7
|
+
search?: Search
|
|
8
|
+
hash?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// PRIVATE API
|
|
12
|
+
export type ParamValue = string | number
|
|
13
|
+
// PRIVATE API
|
|
14
|
+
export type Params = { [name: string]: ParamValue }
|
|
15
|
+
// PRIVATE API
|
|
16
|
+
export type Search =
|
|
17
|
+
| string[][]
|
|
18
|
+
| Record<string, string>
|
|
19
|
+
| string
|
|
20
|
+
| URLSearchParams
|
|
21
|
+
|
|
22
|
+
type RouteDefinitionsToRoutesObj<Routes extends RoutesDefinition> = {
|
|
23
|
+
[K in keyof Routes]: {
|
|
24
|
+
to: ExpandRouteOnOptionalStaticSegments<Routes[K]['to']>
|
|
25
|
+
} & ParamsFromBuildFn<Routes[K]['build']>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type RoutesDefinition = {
|
|
29
|
+
[name: string]: {
|
|
30
|
+
to: string
|
|
31
|
+
build: BuildFn
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type BuildFn = (params: never) => string
|
|
36
|
+
|
|
37
|
+
type ParamsFromBuildFn<BF extends BuildFn> = Parameters<BF>[0] extends {
|
|
38
|
+
params: infer Params
|
|
39
|
+
}
|
|
40
|
+
? { params: Params }
|
|
41
|
+
: { params?: never }
|
|
42
|
+
|
|
43
|
+
// PRIVATE API (sdk)
|
|
44
|
+
/**
|
|
45
|
+
* Optional static segments handling: expands routes with optional segments
|
|
46
|
+
* into multiple routes, one for each possible combination of optional segments.
|
|
47
|
+
*
|
|
48
|
+
* For example: /users/tasks?/:id? will be expanded into two routes:
|
|
49
|
+
* - /users/:id?
|
|
50
|
+
* - /users/tasks/:id?
|
|
51
|
+
*/
|
|
52
|
+
export type ExpandRouteOnOptionalStaticSegments<Route extends string> = JoinPath<
|
|
53
|
+
ExpandOptionalSegments<ParseSegments<SplitPath<NonEmptyString<Route>>>>
|
|
54
|
+
>;
|
|
55
|
+
|
|
56
|
+
type ParseSegments<T> = T extends [infer Head, ...infer Tail]
|
|
57
|
+
? [_ParseSegment<Head>, ...ParseSegments<Tail>]
|
|
58
|
+
: T;
|
|
59
|
+
|
|
60
|
+
type _ParseSegment<T> = T extends `:${infer P}`
|
|
61
|
+
? // Param segment
|
|
62
|
+
{ segment: T }
|
|
63
|
+
: T extends `${infer S}?`
|
|
64
|
+
? // Optional segment
|
|
65
|
+
{ optionalSegment: S }
|
|
66
|
+
: // Regular segment
|
|
67
|
+
{ segment: T };
|
|
68
|
+
|
|
69
|
+
type Segment = { segment: string };
|
|
70
|
+
type OptionalSegment = { optionalSegment: string };
|
|
71
|
+
|
|
72
|
+
type Elem = Segment | OptionalSegment;
|
|
73
|
+
|
|
74
|
+
type ExpandOptionalSegments<T extends Elem[]> = T extends []
|
|
75
|
+
? []
|
|
76
|
+
: T extends [infer First extends Elem, ...infer Rest extends Elem[]]
|
|
77
|
+
? First extends Segment
|
|
78
|
+
? [First["segment"], ...ExpandOptionalSegments<Rest>]
|
|
79
|
+
: First extends OptionalSegment
|
|
80
|
+
? [First["optionalSegment"], ...ExpandOptionalSegments<Rest>] | ExpandOptionalSegments<Rest>
|
|
81
|
+
: []
|
|
82
|
+
: [];
|
|
83
|
+
|
|
84
|
+
type SplitPath<S extends string> = S extends "/"
|
|
85
|
+
? [""]
|
|
86
|
+
: S extends `${infer T}/${infer U}`
|
|
87
|
+
? [T, ...SplitPath<U>]
|
|
88
|
+
: [S];
|
|
89
|
+
|
|
90
|
+
type JoinPath<T extends string[]> = T extends [infer Only extends string]
|
|
91
|
+
? Only extends ""
|
|
92
|
+
? "/"
|
|
93
|
+
: Only
|
|
94
|
+
: T extends [infer First extends string, ...infer Rest extends string[]]
|
|
95
|
+
? `${First}/${JoinPath<Rest>}`
|
|
96
|
+
: never;
|
|
97
|
+
|
|
98
|
+
type NonEmptyString<S extends string> = S extends "" ? never : S;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { renderInContext, mockServer } from './vitest/helpers'
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react'
|
|
2
|
+
import { rest, type ResponseResolver, type RestContext } from 'msw'
|
|
3
|
+
import { setupServer, type SetupServer } from 'msw/node'
|
|
4
|
+
import { BrowserRouter as Router } from 'react-router-dom'
|
|
5
|
+
import { render, RenderResult, cleanup } from '@testing-library/react'
|
|
6
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
7
|
+
import { beforeAll, afterEach, afterAll } from 'vitest'
|
|
8
|
+
import { Query } from 'wasp/client/operations/rpc'
|
|
9
|
+
import { config } from 'wasp/client'
|
|
10
|
+
import { HttpMethod, Route } from 'wasp/client'
|
|
11
|
+
import { serialize } from 'wasp/core/serialization'
|
|
12
|
+
|
|
13
|
+
// PRIVATE API
|
|
14
|
+
export type MockQuery = <Input, Output, MockOutput extends Output>(
|
|
15
|
+
query: Query<Input, Output>,
|
|
16
|
+
resJson: MockOutput
|
|
17
|
+
) => void
|
|
18
|
+
|
|
19
|
+
// PRIVATE API
|
|
20
|
+
export type MockApi = (route: Route, resJson: unknown) => void
|
|
21
|
+
|
|
22
|
+
// PUBLIC API
|
|
23
|
+
// Inspired by the Tanstack React Query helper:
|
|
24
|
+
// https://github.com/TanStack/query/blob/4ae99561ca3383d6de3f4aad656a49ba4a17b57a/packages/react-query/src/__tests__/utils.tsx#L7-L26
|
|
25
|
+
export function renderInContext(ui: ReactElement): RenderResult {
|
|
26
|
+
const client = new QueryClient()
|
|
27
|
+
const { rerender, ...result } = render(
|
|
28
|
+
<QueryClientProvider client={client}>
|
|
29
|
+
<Router>{ui}</Router>
|
|
30
|
+
</QueryClientProvider>
|
|
31
|
+
)
|
|
32
|
+
return {
|
|
33
|
+
...result,
|
|
34
|
+
rerender: (rerenderUi: ReactNode) =>
|
|
35
|
+
rerender(
|
|
36
|
+
<QueryClientProvider client={client}>
|
|
37
|
+
<Router>{rerenderUi}</Router>
|
|
38
|
+
</QueryClientProvider>
|
|
39
|
+
),
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// PUBLIC API
|
|
44
|
+
export function mockServer(): {
|
|
45
|
+
server: SetupServer
|
|
46
|
+
mockQuery: MockQuery
|
|
47
|
+
mockApi: MockApi
|
|
48
|
+
} {
|
|
49
|
+
const server: SetupServer = setupServer()
|
|
50
|
+
|
|
51
|
+
beforeAll(() => server.listen())
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
server.resetHandlers()
|
|
54
|
+
cleanup()
|
|
55
|
+
})
|
|
56
|
+
afterAll(() => server.close())
|
|
57
|
+
|
|
58
|
+
const mockQuery: MockQuery = (query, mockData) => {
|
|
59
|
+
const route = (query as unknown as { route: Route }).route
|
|
60
|
+
mockRoute(server, route, (_req, res, ctx) =>
|
|
61
|
+
res(ctx.json(serialize(mockData)))
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const mockApi: MockApi = (route, mockData) => {
|
|
66
|
+
mockRoute(server, route, (_req, res, ctx) => res(ctx.json(mockData)))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return { server, mockQuery, mockApi }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function mockRoute(
|
|
73
|
+
server: SetupServer,
|
|
74
|
+
route: Route,
|
|
75
|
+
responseHandler: ResponseResolver<any, RestContext, any>
|
|
76
|
+
) {
|
|
77
|
+
if (!Object.values(HttpMethod).includes(route.method)) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`Unsupported query method for mocking: ${
|
|
80
|
+
route.method
|
|
81
|
+
}. Supported method strings are: ${Object.values(HttpMethod).join(', ')}.`
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const url = `${config.apiUrl}${route.path}`
|
|
86
|
+
|
|
87
|
+
const handlers: Record<HttpMethod, Parameters<typeof server.use>[0]> = {
|
|
88
|
+
[HttpMethod.Get]: rest.get(url, responseHandler),
|
|
89
|
+
[HttpMethod.Post]: rest.post(url, responseHandler),
|
|
90
|
+
[HttpMethod.Put]: rest.put(url, responseHandler),
|
|
91
|
+
[HttpMethod.Delete]: rest.delete(url, responseHandler),
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
server.use(handlers[route.method])
|
|
95
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{{={= =}=}}
|
|
2
|
+
import { createContext, useState, useEffect, Context, ReactNode } from 'react'
|
|
3
|
+
import { io, Socket } from 'socket.io-client'
|
|
4
|
+
|
|
5
|
+
import { getSessionId } from 'wasp/client/api'
|
|
6
|
+
import { apiEventsEmitter } from 'wasp/api/events'
|
|
7
|
+
import { config } from 'wasp/client'
|
|
8
|
+
|
|
9
|
+
import type { ClientToServerEvents, ServerToClientEvents } from 'wasp/server/webSocket';
|
|
10
|
+
|
|
11
|
+
export type WebSocketContextValue = {
|
|
12
|
+
socket: typeof socket
|
|
13
|
+
isConnected: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// PRIVATE API
|
|
17
|
+
// TODO: In the future, it would be nice if users could pass more
|
|
18
|
+
// options to `io`, likely via some `configFn`.
|
|
19
|
+
export const socket: Socket<ServerToClientEvents, ClientToServerEvents> = io(
|
|
20
|
+
config.apiUrl,
|
|
21
|
+
{
|
|
22
|
+
transports: ['websocket'],
|
|
23
|
+
autoConnect: {= autoConnect =},
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
function refreshAuthToken() {
|
|
28
|
+
// NOTE: When we figure out how `auth: true` works for Operations, we should
|
|
29
|
+
// mirror that behavior here for WebSockets. Ref: https://github.com/wasp-lang/wasp/issues/1133
|
|
30
|
+
socket.auth = {
|
|
31
|
+
sessionId: getSessionId()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (socket.connected) {
|
|
35
|
+
socket.disconnect()
|
|
36
|
+
socket.connect()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
refreshAuthToken()
|
|
41
|
+
apiEventsEmitter.on('sessionId.set', refreshAuthToken)
|
|
42
|
+
apiEventsEmitter.on('sessionId.clear', refreshAuthToken)
|
|
43
|
+
|
|
44
|
+
// PRIVATE API
|
|
45
|
+
export const WebSocketContext: Context<WebSocketContextValue> = createContext<WebSocketContextValue>({
|
|
46
|
+
socket,
|
|
47
|
+
isConnected: false,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// PRIVATE API
|
|
51
|
+
export function WebSocketProvider({ children }: { children: ReactNode }) {
|
|
52
|
+
const [isConnected, setIsConnected] = useState(socket.connected)
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
function onConnect() {
|
|
56
|
+
setIsConnected(true)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function onDisconnect() {
|
|
60
|
+
setIsConnected(false)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
socket.on('connect', onConnect)
|
|
64
|
+
socket.on('disconnect', onDisconnect)
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
socket.off('connect', onConnect)
|
|
68
|
+
socket.off('disconnect', onDisconnect)
|
|
69
|
+
}
|
|
70
|
+
}, [])
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<WebSocketContext.Provider value={{ socket, isConnected }}>
|
|
74
|
+
{children}
|
|
75
|
+
</WebSocketContext.Provider>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useContext, useEffect } from 'react'
|
|
2
|
+
import { WebSocketContext, WebSocketContextValue } from './WebSocketProvider'
|
|
3
|
+
import type {
|
|
4
|
+
ClientToServerEvents,
|
|
5
|
+
ServerToClientEvents,
|
|
6
|
+
} from 'wasp/server/webSocket'
|
|
7
|
+
|
|
8
|
+
// PUBLIC API
|
|
9
|
+
export type ServerToClientPayload<Event extends keyof ServerToClientEvents> =
|
|
10
|
+
Parameters<ServerToClientEvents[Event]>[0]
|
|
11
|
+
// PUBLIC API
|
|
12
|
+
export type ClientToServerPayload<Event extends keyof ClientToServerEvents> =
|
|
13
|
+
Parameters<ClientToServerEvents[Event]>[0]
|
|
14
|
+
|
|
15
|
+
// PUBLIC API
|
|
16
|
+
export function useSocket(): WebSocketContextValue {
|
|
17
|
+
return useContext(WebSocketContext)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// PUBLIC API
|
|
21
|
+
export function useSocketListener<Event extends keyof ServerToClientEvents>(
|
|
22
|
+
event: Event,
|
|
23
|
+
handler: ServerToClientEvents[Event]
|
|
24
|
+
): void {
|
|
25
|
+
const { socket } = useContext(WebSocketContext)
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
// Casting to `keyof ServerToClientEvents` is necessary because TypeScript
|
|
28
|
+
// reports the handler function as incompatible with the event type.
|
|
29
|
+
// See https://github.com/wasp-lang/wasp/pull/1203#discussion_r1232068898
|
|
30
|
+
|
|
31
|
+
// We are wrapping it in `Extract<...>` due to Typescript infering string | number
|
|
32
|
+
// in the case of default events being used.
|
|
33
|
+
type AllowedEvents = Extract<keyof ServerToClientEvents, string>;
|
|
34
|
+
socket.on(event as AllowedEvents, handler)
|
|
35
|
+
return () => {
|
|
36
|
+
socket.off(event as AllowedEvents, handler)
|
|
37
|
+
}
|
|
38
|
+
}, [event, handler])
|
|
39
|
+
}
|