@wasp.sh/wasp-cli-darwin-arm64-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,743 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { GET_TS_APP_SPEC } from "../src/_private.js";
|
|
3
|
+
import { makeRefParser, mapApi, mapApiNamespace, mapApp, mapAuth, mapAuthMethods, mapClient, mapCrud, mapCrudOperationOptions, mapCrudOperations, mapDb, mapEmailAuth, mapEmailFromField, mapEmailSender, mapEmailVerification, mapExternalAuth, mapExtImport, mapHttpRoute, mapJob, mapOperation, mapPage, mapPasswordReset, mapPerform, mapRoute, mapSchedule, mapServer, mapUsernameAndPassword, mapWebSocket, } from "../src/mapTsAppSpecToAppSpecDecls.js";
|
|
4
|
+
import * as Fixtures from "./testFixtures.js";
|
|
5
|
+
describe("mapApp", () => {
|
|
6
|
+
test("should map minimal config correctly", () => {
|
|
7
|
+
testMapApp(Fixtures.createApp("minimal").app);
|
|
8
|
+
});
|
|
9
|
+
test("should map full config correctly", () => {
|
|
10
|
+
testMapApp(Fixtures.createApp("full").app);
|
|
11
|
+
});
|
|
12
|
+
function testMapApp(app) {
|
|
13
|
+
const tsAppSpec = app[GET_TS_APP_SPEC]();
|
|
14
|
+
const entities = [];
|
|
15
|
+
if (tsAppSpec.auth) {
|
|
16
|
+
if (tsAppSpec.auth.userEntity) {
|
|
17
|
+
entities.push(tsAppSpec.auth.userEntity);
|
|
18
|
+
}
|
|
19
|
+
if (tsAppSpec.auth.externalAuthEntity) {
|
|
20
|
+
entities.push(tsAppSpec.auth.externalAuthEntity);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const routes = [];
|
|
24
|
+
if (tsAppSpec.auth) {
|
|
25
|
+
if (tsAppSpec.auth.methods.email?.emailVerification.clientRoute) {
|
|
26
|
+
routes.push(tsAppSpec.auth.methods.email.emailVerification.clientRoute);
|
|
27
|
+
}
|
|
28
|
+
if (tsAppSpec.auth.methods.email?.passwordReset.clientRoute) {
|
|
29
|
+
routes.push(tsAppSpec.auth.methods.email.passwordReset.clientRoute);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const entityRefParser = makeRefParser("Entity", entities);
|
|
33
|
+
const routeRefParser = makeRefParser("Route", routes);
|
|
34
|
+
const result = mapApp(tsAppSpec.app.config, entityRefParser, routeRefParser, tsAppSpec.auth, tsAppSpec.client, tsAppSpec.server, tsAppSpec.db, tsAppSpec.emailSender, tsAppSpec.websocket);
|
|
35
|
+
expect(result).toStrictEqual({
|
|
36
|
+
wasp: {
|
|
37
|
+
version: tsAppSpec.app.config.wasp.version,
|
|
38
|
+
},
|
|
39
|
+
title: tsAppSpec.app.config.title,
|
|
40
|
+
head: tsAppSpec.app.config.head,
|
|
41
|
+
auth: tsAppSpec.auth &&
|
|
42
|
+
mapAuth(tsAppSpec.auth, entityRefParser, routeRefParser),
|
|
43
|
+
server: tsAppSpec.server && mapServer(tsAppSpec.server),
|
|
44
|
+
client: tsAppSpec.client && mapClient(tsAppSpec.client),
|
|
45
|
+
db: tsAppSpec.db && mapDb(tsAppSpec.db),
|
|
46
|
+
emailSender: tsAppSpec.emailSender && mapEmailSender(tsAppSpec.emailSender),
|
|
47
|
+
webSocket: tsAppSpec.websocket && mapWebSocket(tsAppSpec.websocket),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
describe("mapAuth", () => {
|
|
52
|
+
test("should map minimal config correctly", () => {
|
|
53
|
+
testMapAuth(Fixtures.getAuthConfig("minimal"));
|
|
54
|
+
});
|
|
55
|
+
test("should map full config correctly", () => {
|
|
56
|
+
testMapAuth(Fixtures.getAuthConfig("full"));
|
|
57
|
+
});
|
|
58
|
+
test("should throw if userEntity is not provided to entity parser", () => {
|
|
59
|
+
testMapAuth(Fixtures.getAuthConfig("minimal"), {
|
|
60
|
+
overrideEntities: [],
|
|
61
|
+
shouldError: true,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
test("should throw if externalAuthEntity ref is not provided when defined", () => {
|
|
65
|
+
const auth = Fixtures.getAuthConfig("full");
|
|
66
|
+
expect(auth.externalAuthEntity).toBeDefined();
|
|
67
|
+
testMapAuth(auth, {
|
|
68
|
+
overrideEntities: [auth.userEntity],
|
|
69
|
+
shouldError: true,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
test("should throw if emailVerification clientRoute ref is not provided when defined", () => {
|
|
73
|
+
const auth = Fixtures.getAuthConfig("full");
|
|
74
|
+
expect(auth.methods.email.emailVerification.clientRoute).toBeDefined();
|
|
75
|
+
testMapAuth(auth, {
|
|
76
|
+
overrideRoutes: [auth.methods.email.passwordReset.clientRoute],
|
|
77
|
+
shouldError: true,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
test("should throw if passwordReset clientRoute ref is not provided when defined", () => {
|
|
81
|
+
const auth = Fixtures.getAuthConfig("full");
|
|
82
|
+
expect(auth.methods.email.passwordReset.clientRoute).toBeDefined();
|
|
83
|
+
testMapAuth(auth, {
|
|
84
|
+
overrideRoutes: [auth.methods.email.emailVerification.clientRoute],
|
|
85
|
+
shouldError: true,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
function testMapAuth(auth, options = {
|
|
89
|
+
shouldError: false,
|
|
90
|
+
}) {
|
|
91
|
+
const { overrideEntities, overrideRoutes, shouldError } = options;
|
|
92
|
+
const entities = overrideEntities ??
|
|
93
|
+
[auth.userEntity, auth.externalAuthEntity].filter((e) => e !== undefined);
|
|
94
|
+
const routes = overrideRoutes ??
|
|
95
|
+
[
|
|
96
|
+
auth.methods.email?.emailVerification.clientRoute,
|
|
97
|
+
auth.methods.email?.passwordReset.clientRoute,
|
|
98
|
+
].filter((e) => e !== undefined);
|
|
99
|
+
const entityRefParser = makeRefParser("Entity", entities);
|
|
100
|
+
const routeRefParser = makeRefParser("Route", routes);
|
|
101
|
+
if (shouldError) {
|
|
102
|
+
expect(() => mapAuth(auth, entityRefParser, routeRefParser)).toThrowError();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const result = mapAuth(auth, entityRefParser, routeRefParser);
|
|
106
|
+
expect(result).toStrictEqual({
|
|
107
|
+
userEntity: entityRefParser(auth.userEntity),
|
|
108
|
+
externalAuthEntity: auth.externalAuthEntity === undefined
|
|
109
|
+
? undefined
|
|
110
|
+
: entityRefParser(auth.externalAuthEntity),
|
|
111
|
+
methods: mapAuthMethods(auth.methods, routeRefParser),
|
|
112
|
+
onAuthFailedRedirectTo: auth.onAuthFailedRedirectTo,
|
|
113
|
+
onAuthSucceededRedirectTo: auth.onAuthSucceededRedirectTo,
|
|
114
|
+
onBeforeSignup: auth.onBeforeSignup && mapExtImport(auth.onBeforeSignup),
|
|
115
|
+
onAfterSignup: auth.onAfterSignup && mapExtImport(auth.onAfterSignup),
|
|
116
|
+
onAfterEmailVerified: auth.onAfterEmailVerified && mapExtImport(auth.onAfterEmailVerified),
|
|
117
|
+
onBeforeOAuthRedirect: auth.onBeforeOAuthRedirect && mapExtImport(auth.onBeforeOAuthRedirect),
|
|
118
|
+
onBeforeLogin: auth.onBeforeLogin && mapExtImport(auth.onBeforeLogin),
|
|
119
|
+
onAfterLogin: auth.onAfterLogin && mapExtImport(auth.onAfterLogin),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
describe("mapAuthMethods", () => {
|
|
124
|
+
test("should map minimal config correctly", () => {
|
|
125
|
+
testMapAuthMethods(Fixtures.getAuthMethods("minimal"));
|
|
126
|
+
});
|
|
127
|
+
test("should map full config correctly", () => {
|
|
128
|
+
testMapAuthMethods(Fixtures.getAuthMethods("full"));
|
|
129
|
+
});
|
|
130
|
+
test("should throw if emailVerification clientRoute ref is not provided when defined", () => {
|
|
131
|
+
const authMethods = Fixtures.getAuthMethods("full");
|
|
132
|
+
expect(authMethods.email.emailVerification.clientRoute).toBeDefined();
|
|
133
|
+
testMapAuthMethods(authMethods, {
|
|
134
|
+
overrideRoutes: [authMethods.email.emailVerification.clientRoute],
|
|
135
|
+
shouldError: true,
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
test("should throw if passwordReset clientRoute ref is not provided when defined", () => {
|
|
139
|
+
const authMethods = Fixtures.getAuthMethods("full");
|
|
140
|
+
expect(authMethods.email.passwordReset.clientRoute).toBeDefined();
|
|
141
|
+
testMapAuthMethods(authMethods, {
|
|
142
|
+
overrideRoutes: [authMethods.email.passwordReset.clientRoute],
|
|
143
|
+
shouldError: true,
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
function testMapAuthMethods(authMethods, options = {
|
|
147
|
+
shouldError: false,
|
|
148
|
+
}) {
|
|
149
|
+
const { overrideRoutes, shouldError } = options;
|
|
150
|
+
const routes = overrideRoutes ??
|
|
151
|
+
[
|
|
152
|
+
authMethods.email?.emailVerification.clientRoute,
|
|
153
|
+
authMethods.email?.passwordReset.clientRoute,
|
|
154
|
+
].filter((e) => e !== undefined);
|
|
155
|
+
const routeRefParser = makeRefParser("Route", routes);
|
|
156
|
+
if (shouldError) {
|
|
157
|
+
expect(() => mapAuthMethods(authMethods, routeRefParser)).toThrowError();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const result = mapAuthMethods(authMethods, routeRefParser);
|
|
161
|
+
expect(result).toStrictEqual({
|
|
162
|
+
usernameAndPassword: authMethods.usernameAndPassword &&
|
|
163
|
+
mapUsernameAndPassword(authMethods.usernameAndPassword),
|
|
164
|
+
discord: authMethods.discord && mapExternalAuth(authMethods.discord),
|
|
165
|
+
google: authMethods.google && mapExternalAuth(authMethods.google),
|
|
166
|
+
gitHub: authMethods.gitHub && mapExternalAuth(authMethods.gitHub),
|
|
167
|
+
keycloak: authMethods.keycloak && mapExternalAuth(authMethods.keycloak),
|
|
168
|
+
email: authMethods.email && mapEmailAuth(authMethods.email, routeRefParser),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
describe("mapEmailAuth", () => {
|
|
173
|
+
test("should map minimal config correctly", () => {
|
|
174
|
+
testMapEmailAuth(Fixtures.getEmailAuthConfig("minimal"));
|
|
175
|
+
});
|
|
176
|
+
test("should map full config correctly", () => {
|
|
177
|
+
testMapEmailAuth(Fixtures.getEmailAuthConfig("full"));
|
|
178
|
+
});
|
|
179
|
+
test("should throw if emailVerification clientRoute ref is not provided when defined", () => {
|
|
180
|
+
const emailAuth = Fixtures.getEmailAuthConfig("full");
|
|
181
|
+
expect(emailAuth.emailVerification.clientRoute).toBeDefined();
|
|
182
|
+
testMapEmailAuth(emailAuth, {
|
|
183
|
+
overrideRoutes: [emailAuth.passwordReset.clientRoute],
|
|
184
|
+
shouldError: true,
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
test("should throw if passwordReset clientRoute ref is not provided when defined", () => {
|
|
188
|
+
const emailAuth = Fixtures.getEmailAuthConfig("full");
|
|
189
|
+
expect(emailAuth.passwordReset.clientRoute).toBeDefined();
|
|
190
|
+
testMapEmailAuth(emailAuth, {
|
|
191
|
+
overrideRoutes: [emailAuth.emailVerification.clientRoute],
|
|
192
|
+
shouldError: true,
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
function testMapEmailAuth(emailAuth, options = {
|
|
196
|
+
shouldError: false,
|
|
197
|
+
}) {
|
|
198
|
+
const { overrideRoutes, shouldError } = options;
|
|
199
|
+
const routes = overrideRoutes ??
|
|
200
|
+
[
|
|
201
|
+
emailAuth?.emailVerification.clientRoute,
|
|
202
|
+
emailAuth?.passwordReset.clientRoute,
|
|
203
|
+
].filter((e) => e !== undefined);
|
|
204
|
+
const routeRefParser = makeRefParser("Route", routes);
|
|
205
|
+
if (shouldError) {
|
|
206
|
+
expect(() => mapEmailAuth(emailAuth, routeRefParser)).toThrowError();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const result = mapEmailAuth(emailAuth, routeRefParser);
|
|
210
|
+
expect(result).toStrictEqual({
|
|
211
|
+
userSignupFields: emailAuth.userSignupFields && mapExtImport(emailAuth.userSignupFields),
|
|
212
|
+
fromField: mapEmailFromField(emailAuth.fromField),
|
|
213
|
+
emailVerification: mapEmailVerification(emailAuth.emailVerification, routeRefParser),
|
|
214
|
+
passwordReset: mapPasswordReset(emailAuth.passwordReset, routeRefParser),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
describe("mapEmailVerification", () => {
|
|
219
|
+
test("should map minimal config correctly", () => {
|
|
220
|
+
testMapEmailVerification(Fixtures.getEmailVerificationConfig("minimal"));
|
|
221
|
+
});
|
|
222
|
+
test("should map full config correctly", () => {
|
|
223
|
+
testMapEmailVerification(Fixtures.getEmailVerificationConfig("full"));
|
|
224
|
+
});
|
|
225
|
+
test("should throw if clientRoute ref is not provided when defined", () => {
|
|
226
|
+
const emailVerification = Fixtures.getEmailVerificationConfig("full");
|
|
227
|
+
expect(emailVerification.clientRoute).toBeDefined();
|
|
228
|
+
testMapEmailVerification(emailVerification, {
|
|
229
|
+
overrideRoutes: [],
|
|
230
|
+
shouldError: true,
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
function testMapEmailVerification(emailVerification, options = {
|
|
234
|
+
shouldError: false,
|
|
235
|
+
}) {
|
|
236
|
+
const { overrideRoutes, shouldError } = options;
|
|
237
|
+
const routes = overrideRoutes ??
|
|
238
|
+
[emailVerification.clientRoute].filter((e) => e !== undefined);
|
|
239
|
+
const routeRefParser = makeRefParser("Route", routes);
|
|
240
|
+
if (shouldError) {
|
|
241
|
+
expect(() => mapEmailVerification(emailVerification, routeRefParser)).toThrowError();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const result = mapEmailVerification(emailVerification, routeRefParser);
|
|
245
|
+
expect(result).toStrictEqual({
|
|
246
|
+
clientRoute: routeRefParser(emailVerification.clientRoute),
|
|
247
|
+
getEmailContentFn: emailVerification.getEmailContentFn &&
|
|
248
|
+
mapExtImport(emailVerification.getEmailContentFn),
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
describe("mapPasswordReset", () => {
|
|
253
|
+
test("should map minimal config correctly", () => {
|
|
254
|
+
testMapPasswordReset(Fixtures.getPasswordResetConfig("minimal"));
|
|
255
|
+
});
|
|
256
|
+
test("should map full config correctly", () => {
|
|
257
|
+
testMapPasswordReset(Fixtures.getPasswordResetConfig("full"));
|
|
258
|
+
});
|
|
259
|
+
test("should throw if clientRoute ref is not provided when defined", () => {
|
|
260
|
+
const passwordReset = Fixtures.getPasswordResetConfig("full");
|
|
261
|
+
expect(passwordReset.clientRoute).toBeDefined();
|
|
262
|
+
testMapPasswordReset(passwordReset, {
|
|
263
|
+
overrideRoutes: [],
|
|
264
|
+
shouldError: true,
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
function testMapPasswordReset(passwordReset, options = {
|
|
268
|
+
shouldError: false,
|
|
269
|
+
}) {
|
|
270
|
+
const { overrideRoutes, shouldError } = options;
|
|
271
|
+
const routes = overrideRoutes ??
|
|
272
|
+
[passwordReset.clientRoute].filter((e) => e !== undefined);
|
|
273
|
+
const routeRefParser = makeRefParser("Route", routes);
|
|
274
|
+
if (shouldError) {
|
|
275
|
+
expect(() => mapPasswordReset(passwordReset, routeRefParser)).toThrowError();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const result = mapPasswordReset(passwordReset, routeRefParser);
|
|
279
|
+
expect(result).toStrictEqual({
|
|
280
|
+
clientRoute: routeRefParser(passwordReset.clientRoute),
|
|
281
|
+
getEmailContentFn: passwordReset.getEmailContentFn &&
|
|
282
|
+
mapExtImport(passwordReset.getEmailContentFn),
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
describe("mapUsernameAndPassword", () => {
|
|
287
|
+
test("should map minimal config correctly", () => {
|
|
288
|
+
testMapUsernameAndPassword(Fixtures.getUsernameAndPasswordConfig("minimal"));
|
|
289
|
+
});
|
|
290
|
+
test("should map full config correctly", () => {
|
|
291
|
+
testMapUsernameAndPassword(Fixtures.getUsernameAndPasswordConfig("full"));
|
|
292
|
+
});
|
|
293
|
+
function testMapUsernameAndPassword(usernameAndPassword) {
|
|
294
|
+
const result = mapUsernameAndPassword(usernameAndPassword);
|
|
295
|
+
expect(result).toStrictEqual({
|
|
296
|
+
userSignupFields: usernameAndPassword.userSignupFields &&
|
|
297
|
+
mapExtImport(usernameAndPassword.userSignupFields),
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
describe("mapExternalAuth", () => {
|
|
302
|
+
test("should map minimal config correctly", () => {
|
|
303
|
+
testMapExternalAuth(Fixtures.getExternalAuthConfig("minimal"));
|
|
304
|
+
});
|
|
305
|
+
test("should map full config correctly", () => {
|
|
306
|
+
testMapExternalAuth(Fixtures.getExternalAuthConfig("full"));
|
|
307
|
+
});
|
|
308
|
+
function testMapExternalAuth(externalAuth) {
|
|
309
|
+
const result = mapExternalAuth(externalAuth);
|
|
310
|
+
expect(result).toStrictEqual({
|
|
311
|
+
configFn: externalAuth.configFn && mapExtImport(externalAuth.configFn),
|
|
312
|
+
userSignupFields: externalAuth.userSignupFields &&
|
|
313
|
+
mapExtImport(externalAuth.userSignupFields),
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
describe("mapClient", () => {
|
|
318
|
+
test("should map minimal config correctly", () => {
|
|
319
|
+
testMapClient(Fixtures.getClientConfig("minimal"));
|
|
320
|
+
});
|
|
321
|
+
test("should map full config correctly", () => {
|
|
322
|
+
testMapClient(Fixtures.getClientConfig("full"));
|
|
323
|
+
});
|
|
324
|
+
function testMapClient(client) {
|
|
325
|
+
const result = mapClient(client);
|
|
326
|
+
expect(result).toStrictEqual({
|
|
327
|
+
rootComponent: client.rootComponent && mapExtImport(client.rootComponent),
|
|
328
|
+
setupFn: client.setupFn && mapExtImport(client.setupFn),
|
|
329
|
+
baseDir: client.baseDir,
|
|
330
|
+
envValidationSchema: client.envValidationSchema && mapExtImport(client.envValidationSchema),
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
describe("mapServer", () => {
|
|
335
|
+
test("should map minimal config correctly", () => {
|
|
336
|
+
testMapServer(Fixtures.getServerConfig("minimal"));
|
|
337
|
+
});
|
|
338
|
+
test("should map full config correctly", () => {
|
|
339
|
+
testMapServer(Fixtures.getServerConfig("full"));
|
|
340
|
+
});
|
|
341
|
+
function testMapServer(server) {
|
|
342
|
+
const result = mapServer(server);
|
|
343
|
+
expect(result).toStrictEqual({
|
|
344
|
+
setupFn: server.setupFn && mapExtImport(server.setupFn),
|
|
345
|
+
middlewareConfigFn: server.middlewareConfigFn && mapExtImport(server.middlewareConfigFn),
|
|
346
|
+
envValidationSchema: server.envValidationSchema && mapExtImport(server.envValidationSchema),
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
describe("mapEmailSender", () => {
|
|
351
|
+
test("should map minimal config correctly", () => {
|
|
352
|
+
testMapEmailSender(Fixtures.getEmailSenderConfig("minimal"));
|
|
353
|
+
});
|
|
354
|
+
test("should map full config correctly", () => {
|
|
355
|
+
testMapEmailSender(Fixtures.getEmailSenderConfig("full"));
|
|
356
|
+
});
|
|
357
|
+
function testMapEmailSender(emailSender) {
|
|
358
|
+
const result = mapEmailSender(emailSender);
|
|
359
|
+
expect(result).toStrictEqual({
|
|
360
|
+
provider: emailSender.provider,
|
|
361
|
+
defaultFrom: emailSender.defaultFrom && mapEmailFromField(emailSender.defaultFrom),
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
describe("mapWebSocket", () => {
|
|
366
|
+
test("should map minimal config correctly", () => {
|
|
367
|
+
testMapWebSocket(Fixtures.getWebSocketConfig("minimal"));
|
|
368
|
+
});
|
|
369
|
+
test("should map full config correctly", () => {
|
|
370
|
+
testMapWebSocket(Fixtures.getWebSocketConfig("full"));
|
|
371
|
+
});
|
|
372
|
+
function testMapWebSocket(websocket) {
|
|
373
|
+
const result = mapWebSocket(websocket);
|
|
374
|
+
expect(result).toStrictEqual({
|
|
375
|
+
fn: mapExtImport(websocket.fn),
|
|
376
|
+
autoConnect: websocket.autoConnect,
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
describe("mapDb", () => {
|
|
381
|
+
test("should map minimal config correctly", () => {
|
|
382
|
+
testDb(Fixtures.getDbConfig("minimal"));
|
|
383
|
+
});
|
|
384
|
+
test("should map full config correctly", () => {
|
|
385
|
+
testDb(Fixtures.getDbConfig("full"));
|
|
386
|
+
});
|
|
387
|
+
function testDb(db) {
|
|
388
|
+
const result = mapDb(db);
|
|
389
|
+
expect(result).toStrictEqual({
|
|
390
|
+
seeds: db.seeds?.map((seed) => mapExtImport(seed)),
|
|
391
|
+
prismaSetupFn: db.prismaSetupFn && mapExtImport(db.prismaSetupFn),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
describe("mapPage", () => {
|
|
396
|
+
test("should map minimal config correctly", () => {
|
|
397
|
+
testMapPage(Fixtures.getPageConfig("minimal").config);
|
|
398
|
+
});
|
|
399
|
+
test("should map full config correctly", () => {
|
|
400
|
+
testMapPage(Fixtures.getPageConfig("full").config);
|
|
401
|
+
});
|
|
402
|
+
function testMapPage(page) {
|
|
403
|
+
const result = mapPage(page);
|
|
404
|
+
expect(result).toStrictEqual({
|
|
405
|
+
component: mapExtImport(page.component),
|
|
406
|
+
authRequired: page.authRequired,
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
describe("mapRoute", () => {
|
|
411
|
+
// NOTE: currently minimal config is the same as full config
|
|
412
|
+
test("should map minimal config correctly", () => {
|
|
413
|
+
testMapRoute(Fixtures.getRouteConfig("minimal").config);
|
|
414
|
+
});
|
|
415
|
+
test("should map full config correctly", () => {
|
|
416
|
+
testMapRoute(Fixtures.getRouteConfig("full").config);
|
|
417
|
+
});
|
|
418
|
+
function testMapRoute(route) {
|
|
419
|
+
const pageRefParser = makeRefParser("Page", [route.to]);
|
|
420
|
+
const result = mapRoute(route, pageRefParser);
|
|
421
|
+
expect(result).toStrictEqual({
|
|
422
|
+
path: route.path,
|
|
423
|
+
to: pageRefParser(route.to),
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
describe("mapOperation", () => {
|
|
428
|
+
test("should map minimal query config correctly", () => {
|
|
429
|
+
testMapOperation(Fixtures.getQueryConfig("minimal").config);
|
|
430
|
+
});
|
|
431
|
+
test("should map full query config correctly", () => {
|
|
432
|
+
testMapOperation(Fixtures.getQueryConfig("full").config);
|
|
433
|
+
});
|
|
434
|
+
test("should throw if entity ref is not provided in query config", () => {
|
|
435
|
+
testMapOperation(Fixtures.getQueryConfig("full").config, {
|
|
436
|
+
overrideEntities: [],
|
|
437
|
+
shouldError: true,
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
test("should map minimal action config correctly", () => {
|
|
441
|
+
testMapOperation(Fixtures.getActionConfig("minimal").config);
|
|
442
|
+
});
|
|
443
|
+
test("should map action config correctly", () => {
|
|
444
|
+
testMapOperation(Fixtures.getActionConfig("full").config);
|
|
445
|
+
});
|
|
446
|
+
test("should throw if entity ref is not provided in action config", () => {
|
|
447
|
+
testMapOperation(Fixtures.getActionConfig("full").config, {
|
|
448
|
+
overrideEntities: [],
|
|
449
|
+
shouldError: true,
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
function testMapOperation(operation, options = {
|
|
453
|
+
shouldError: false,
|
|
454
|
+
}) {
|
|
455
|
+
const { overrideEntities, shouldError } = options;
|
|
456
|
+
const entities = overrideEntities ??
|
|
457
|
+
operation.entities?.filter((e) => e !== undefined) ??
|
|
458
|
+
[];
|
|
459
|
+
const entityRefParser = makeRefParser("Entity", entities);
|
|
460
|
+
if (shouldError) {
|
|
461
|
+
expect(() => mapOperation(operation, entityRefParser)).toThrowError();
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const result = mapOperation(operation, entityRefParser);
|
|
465
|
+
expect(result).toStrictEqual({
|
|
466
|
+
fn: mapExtImport(operation.fn),
|
|
467
|
+
entities: operation.entities?.map(entityRefParser),
|
|
468
|
+
auth: operation.auth,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
describe("mapCrud", () => {
|
|
473
|
+
test("should map minimal config correctly", () => {
|
|
474
|
+
testMapCrud(Fixtures.getCrudConfig("minimal").config);
|
|
475
|
+
});
|
|
476
|
+
test("should map full config correctly", () => {
|
|
477
|
+
testMapCrud(Fixtures.getCrudConfig("full").config);
|
|
478
|
+
});
|
|
479
|
+
test("should throw if entity ref is not provided", () => {
|
|
480
|
+
testMapCrud(Fixtures.getCrudConfig("full").config, {
|
|
481
|
+
overrideEntities: [],
|
|
482
|
+
shouldError: true,
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
function testMapCrud(crud, options = {
|
|
486
|
+
shouldError: false,
|
|
487
|
+
}) {
|
|
488
|
+
const { overrideEntities, shouldError } = options;
|
|
489
|
+
const entities = overrideEntities ?? [crud.entity].filter((e) => e !== undefined);
|
|
490
|
+
const entityRefParser = makeRefParser("Entity", entities);
|
|
491
|
+
if (shouldError) {
|
|
492
|
+
expect(() => mapCrud(crud, entityRefParser)).toThrowError();
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
const result = mapCrud(crud, entityRefParser);
|
|
496
|
+
expect(result).toStrictEqual({
|
|
497
|
+
entity: entityRefParser(crud.entity),
|
|
498
|
+
operations: mapCrudOperations(crud.operations),
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
describe("mapCrudOperations", () => {
|
|
503
|
+
test("should map minimal config correctly", () => {
|
|
504
|
+
testMapCrudOperations(Fixtures.getCrudOperations("minimal"));
|
|
505
|
+
});
|
|
506
|
+
test("should map full config correctly", () => {
|
|
507
|
+
testMapCrudOperations(Fixtures.getCrudOperations("full"));
|
|
508
|
+
});
|
|
509
|
+
function testMapCrudOperations(crudOperations) {
|
|
510
|
+
const result = mapCrudOperations(crudOperations);
|
|
511
|
+
expect(result).toStrictEqual({
|
|
512
|
+
get: crudOperations.get && mapCrudOperationOptions(crudOperations.get),
|
|
513
|
+
getAll: crudOperations.getAll && mapCrudOperationOptions(crudOperations.getAll),
|
|
514
|
+
create: crudOperations.create && mapCrudOperationOptions(crudOperations.create),
|
|
515
|
+
update: crudOperations.update && mapCrudOperationOptions(crudOperations.update),
|
|
516
|
+
delete: crudOperations.delete && mapCrudOperationOptions(crudOperations.delete),
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
describe("mapCrudOperationOptions", () => {
|
|
521
|
+
test("should map minimal config correctly", () => {
|
|
522
|
+
testMapCrudOperationOptions(Fixtures.getCrudOperationOptions("minimal"));
|
|
523
|
+
});
|
|
524
|
+
test("should map full config correctly", () => {
|
|
525
|
+
testMapCrudOperationOptions(Fixtures.getCrudOperationOptions("full"));
|
|
526
|
+
});
|
|
527
|
+
function testMapCrudOperationOptions(crudOperationOptions) {
|
|
528
|
+
const result = mapCrudOperationOptions(crudOperationOptions);
|
|
529
|
+
expect(result).toStrictEqual({
|
|
530
|
+
isPublic: crudOperationOptions.isPublic,
|
|
531
|
+
overrideFn: crudOperationOptions.overrideFn &&
|
|
532
|
+
mapExtImport(crudOperationOptions.overrideFn),
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
describe("mapApiNamespace", () => {
|
|
537
|
+
// NOTE: currently minimal config is the same as full config
|
|
538
|
+
test("should map minimal config correctly", () => {
|
|
539
|
+
testMapApiNamespace(Fixtures.getApiNamespaceConfig("minimal").config);
|
|
540
|
+
});
|
|
541
|
+
test("should map full config correctly", () => {
|
|
542
|
+
testMapApiNamespace(Fixtures.getApiNamespaceConfig("full").config);
|
|
543
|
+
});
|
|
544
|
+
function testMapApiNamespace(apiNamespace) {
|
|
545
|
+
const result = mapApiNamespace(apiNamespace);
|
|
546
|
+
expect(result).toStrictEqual({
|
|
547
|
+
middlewareConfigFn: mapExtImport(apiNamespace.middlewareConfigFn),
|
|
548
|
+
path: apiNamespace.path,
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
describe("mapApi", () => {
|
|
553
|
+
test("should map minimal config correctly", () => {
|
|
554
|
+
testMapApi(Fixtures.getApiConfig("minimal").config);
|
|
555
|
+
});
|
|
556
|
+
test("should map full config correctly", () => {
|
|
557
|
+
testMapApi(Fixtures.getApiConfig("full").config);
|
|
558
|
+
});
|
|
559
|
+
test("should throw if entities refs are not provided", () => {
|
|
560
|
+
testMapApi(Fixtures.getApiConfig("full").config, {
|
|
561
|
+
overrideEntities: [],
|
|
562
|
+
shouldError: true,
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
function testMapApi(api, options = {
|
|
566
|
+
shouldError: false,
|
|
567
|
+
}) {
|
|
568
|
+
const { overrideEntities, shouldError } = options;
|
|
569
|
+
const entities = overrideEntities ?? api.entities?.filter((e) => e !== undefined) ?? [];
|
|
570
|
+
const entityRefParser = makeRefParser("Entity", entities);
|
|
571
|
+
if (shouldError) {
|
|
572
|
+
expect(() => mapApi(api, entityRefParser)).toThrowError();
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
const result = mapApi(api, entityRefParser);
|
|
576
|
+
expect(result).toStrictEqual({
|
|
577
|
+
fn: mapExtImport(api.fn),
|
|
578
|
+
middlewareConfigFn: api.middlewareConfigFn && mapExtImport(api.middlewareConfigFn),
|
|
579
|
+
entities: api.entities?.map(entityRefParser),
|
|
580
|
+
httpRoute: mapHttpRoute(api.httpRoute),
|
|
581
|
+
auth: api.auth,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
describe("mapHttpRoute", () => {
|
|
586
|
+
test("should map minimal config correctly", () => {
|
|
587
|
+
testMapHttpRoute(Fixtures.getHttpRoute("minimal"));
|
|
588
|
+
});
|
|
589
|
+
test("should map full config correctly", () => {
|
|
590
|
+
testMapHttpRoute(Fixtures.getHttpRoute("full"));
|
|
591
|
+
});
|
|
592
|
+
function testMapHttpRoute(httpRoute) {
|
|
593
|
+
const result = mapHttpRoute(httpRoute);
|
|
594
|
+
expect(result).toStrictEqual([
|
|
595
|
+
httpRoute.method,
|
|
596
|
+
httpRoute.route,
|
|
597
|
+
]);
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
describe("mapJob", () => {
|
|
601
|
+
test("should map minimal config correctly", () => {
|
|
602
|
+
testMapJob(Fixtures.getJobConfig("minimal").config);
|
|
603
|
+
});
|
|
604
|
+
test("should map full config correctly", () => {
|
|
605
|
+
testMapJob(Fixtures.getJobConfig("full").config);
|
|
606
|
+
});
|
|
607
|
+
test("should throw if entity ref is not provided", () => {
|
|
608
|
+
testMapJob(Fixtures.getJobConfig("full").config, {
|
|
609
|
+
overrideEntities: [],
|
|
610
|
+
shouldError: true,
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
function testMapJob(job, options = {
|
|
614
|
+
shouldError: false,
|
|
615
|
+
}) {
|
|
616
|
+
const { overrideEntities, shouldError } = options;
|
|
617
|
+
const entities = overrideEntities ?? job.entities?.filter((e) => e !== undefined) ?? [];
|
|
618
|
+
const entityRefParser = makeRefParser("Entity", entities);
|
|
619
|
+
if (shouldError) {
|
|
620
|
+
expect(() => mapJob(job, entityRefParser)).toThrowError();
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
const result = mapJob(job, entityRefParser);
|
|
624
|
+
expect(result).toStrictEqual({
|
|
625
|
+
executor: job.executor,
|
|
626
|
+
perform: mapPerform(job.perform),
|
|
627
|
+
schedule: job.schedule && mapSchedule(job.schedule),
|
|
628
|
+
entities: job.entities?.map(entityRefParser),
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
describe("mapSchedule", () => {
|
|
633
|
+
test("should map minimal config correctly", () => {
|
|
634
|
+
testMapSchedule(Fixtures.getSchedule("minimal"));
|
|
635
|
+
});
|
|
636
|
+
test("should map full config correctly", () => {
|
|
637
|
+
testMapSchedule(Fixtures.getSchedule("full"));
|
|
638
|
+
});
|
|
639
|
+
function testMapSchedule(schedule) {
|
|
640
|
+
const result = mapSchedule(schedule);
|
|
641
|
+
expect(result).toStrictEqual({
|
|
642
|
+
cron: schedule.cron,
|
|
643
|
+
args: schedule.args,
|
|
644
|
+
executorOptions: schedule.executorOptions,
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
describe("mapPerform", () => {
|
|
649
|
+
test("should map minimal config correctly", () => {
|
|
650
|
+
testMapPerform(Fixtures.getPerform("minimal"));
|
|
651
|
+
});
|
|
652
|
+
test("should map full config correctly", () => {
|
|
653
|
+
testMapPerform(Fixtures.getPerform("full"));
|
|
654
|
+
});
|
|
655
|
+
function testMapPerform(perform) {
|
|
656
|
+
const result = mapPerform(perform);
|
|
657
|
+
expect(result).toStrictEqual({
|
|
658
|
+
fn: mapExtImport(perform.fn),
|
|
659
|
+
executorOptions: perform.executorOptions,
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
describe("mapEmailFromField", () => {
|
|
664
|
+
test("should map minimal config correctly", () => {
|
|
665
|
+
testMapEmailFromField(Fixtures.getEmailFromField("minimal"));
|
|
666
|
+
});
|
|
667
|
+
test("should map full config correctly", () => {
|
|
668
|
+
testMapEmailFromField(Fixtures.getEmailFromField("full"));
|
|
669
|
+
});
|
|
670
|
+
function testMapEmailFromField(emailFromField) {
|
|
671
|
+
const result = mapEmailFromField(emailFromField);
|
|
672
|
+
expect(result).toStrictEqual({
|
|
673
|
+
name: emailFromField.name,
|
|
674
|
+
email: emailFromField.email,
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
describe("mapExtImport", () => {
|
|
679
|
+
test("should map minimal named import correctly", () => {
|
|
680
|
+
testMapExtImport(Fixtures.getExtImport("minimal", "named"));
|
|
681
|
+
});
|
|
682
|
+
test("should map full named import correctly", () => {
|
|
683
|
+
testMapExtImport(Fixtures.getExtImport("full", "named"));
|
|
684
|
+
});
|
|
685
|
+
test("should map minimal default import correctly", () => {
|
|
686
|
+
testMapExtImport(Fixtures.getExtImport("minimal", "default"));
|
|
687
|
+
});
|
|
688
|
+
test("should map full default import correctly", () => {
|
|
689
|
+
testMapExtImport(Fixtures.getExtImport("full", "default"));
|
|
690
|
+
});
|
|
691
|
+
test("should throw for missing import kind", () => {
|
|
692
|
+
const extImport = {
|
|
693
|
+
from: "@src/myModule",
|
|
694
|
+
};
|
|
695
|
+
testMapExtImport(extImport, {
|
|
696
|
+
shouldError: true,
|
|
697
|
+
});
|
|
698
|
+
});
|
|
699
|
+
// TODO: unskip this test when we decide how to handle this
|
|
700
|
+
test.skip("should throw for having both import kind", () => {
|
|
701
|
+
const extImport = {
|
|
702
|
+
...Fixtures.getExtImport("full", "named"),
|
|
703
|
+
...Fixtures.getExtImport("full", "default"),
|
|
704
|
+
};
|
|
705
|
+
testMapExtImport(extImport, {
|
|
706
|
+
shouldError: true,
|
|
707
|
+
});
|
|
708
|
+
});
|
|
709
|
+
// TODO: unskip this test when we decide how to handle this
|
|
710
|
+
test.skip("should throw error for invalid from path", () => {
|
|
711
|
+
const extImport = {
|
|
712
|
+
import: "myNamedImport",
|
|
713
|
+
from: "./invalid/path",
|
|
714
|
+
};
|
|
715
|
+
testMapExtImport(extImport, {
|
|
716
|
+
shouldError: true,
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
function testMapExtImport(extImport, options = {
|
|
720
|
+
shouldError: false,
|
|
721
|
+
}) {
|
|
722
|
+
const { shouldError } = options;
|
|
723
|
+
if (shouldError) {
|
|
724
|
+
expect(() => mapExtImport(extImport)).toThrowError();
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
const result = mapExtImport(extImport);
|
|
728
|
+
if ("import" in extImport) {
|
|
729
|
+
expect(result).toStrictEqual({
|
|
730
|
+
kind: "named",
|
|
731
|
+
name: extImport.import,
|
|
732
|
+
path: extImport.from,
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
else if ("importDefault" in extImport) {
|
|
736
|
+
expect(result).toStrictEqual({
|
|
737
|
+
kind: "default",
|
|
738
|
+
name: extImport.importDefault,
|
|
739
|
+
path: extImport.from,
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
});
|