@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.
Files changed (410) hide show
  1. package/data/Cli/starters/README.md +22 -0
  2. package/data/Cli/starters/basic/README.md +35 -0
  3. package/data/Cli/starters/basic/eslint.config.js +24 -0
  4. package/data/Cli/starters/basic/main.wasp +100 -0
  5. package/data/Cli/starters/basic/package.json +29 -0
  6. package/data/Cli/starters/basic/postcss.config.js +6 -0
  7. package/data/Cli/starters/basic/schema.prisma +42 -0
  8. package/data/Cli/starters/basic/src/App.css +13 -0
  9. package/data/Cli/starters/basic/src/App.tsx +12 -0
  10. package/data/Cli/starters/basic/src/assets/logo.svg +1 -0
  11. package/data/Cli/starters/basic/src/auth/AuthLayout.tsx +10 -0
  12. package/data/Cli/starters/basic/src/auth/email/EmailVerificationPage.tsx +19 -0
  13. package/data/Cli/starters/basic/src/auth/email/LoginPage.tsx +27 -0
  14. package/data/Cli/starters/basic/src/auth/email/PasswordResetPage.tsx +19 -0
  15. package/data/Cli/starters/basic/src/auth/email/RequestPasswordResetPage.tsx +10 -0
  16. package/data/Cli/starters/basic/src/auth/email/SignupPage.tsx +34 -0
  17. package/data/Cli/starters/basic/src/auth/email/userSignupFields.ts +13 -0
  18. package/data/Cli/starters/basic/src/shared/components/Button.tsx +90 -0
  19. package/data/Cli/starters/basic/src/shared/components/Dialog.tsx +85 -0
  20. package/data/Cli/starters/basic/src/shared/components/Header.tsx +39 -0
  21. package/data/Cli/starters/basic/src/shared/components/Input.tsx +36 -0
  22. package/data/Cli/starters/basic/src/shared/components/Portal.tsx +26 -0
  23. package/data/Cli/starters/basic/src/tags/actions.ts +23 -0
  24. package/data/Cli/starters/basic/src/tags/components/ColorRadioButton.tsx +44 -0
  25. package/data/Cli/starters/basic/src/tags/components/ColorRadioButtons.tsx +59 -0
  26. package/data/Cli/starters/basic/src/tags/components/CreateTagDialog.tsx +50 -0
  27. package/data/Cli/starters/basic/src/tags/components/CreateTagForm.tsx +100 -0
  28. package/data/Cli/starters/basic/src/tags/components/TagLabel.tsx +55 -0
  29. package/data/Cli/starters/basic/src/tags/components/colors.ts +8 -0
  30. package/data/Cli/starters/basic/src/tags/queries.ts +14 -0
  31. package/data/Cli/starters/basic/src/tasks/TasksPage.tsx +19 -0
  32. package/data/Cli/starters/basic/src/tasks/actions.ts +71 -0
  33. package/data/Cli/starters/basic/src/tasks/components/CreateTaskForm.tsx +103 -0
  34. package/data/Cli/starters/basic/src/tasks/components/TaskList.tsx +68 -0
  35. package/data/Cli/starters/basic/src/tasks/components/TaskListItem.tsx +56 -0
  36. package/data/Cli/starters/basic/src/tasks/queries.ts +21 -0
  37. package/data/Cli/starters/basic/tailwind.config.js +30 -0
  38. package/data/Cli/starters/basic/vite.config.ts +7 -0
  39. package/data/Cli/starters/minimal/main.wasp +14 -0
  40. package/data/Cli/starters/minimal/package.json +18 -0
  41. package/data/Cli/starters/minimal/schema.prisma +10 -0
  42. package/data/Cli/starters/minimal/src/Main.css +103 -0
  43. package/data/Cli/starters/minimal/src/MainPage.tsx +37 -0
  44. package/data/Cli/starters/minimal/src/assets/logo.svg +1 -0
  45. package/data/Cli/starters/minimal/vite.config.ts +7 -0
  46. package/data/Cli/starters/skeleton/public/favicon.ico +0 -0
  47. package/data/Cli/starters/skeleton/src/vite-env.d.ts +7 -0
  48. package/data/Cli/starters/skeleton/tsconfig.json +28 -0
  49. package/data/Generator/templates/Dockerfile +78 -0
  50. package/data/Generator/templates/db/schema.prisma +24 -0
  51. package/data/Generator/templates/dockerignore +2 -0
  52. package/data/Generator/templates/react-app/README.md +21 -0
  53. package/data/Generator/templates/react-app/gitignore +23 -0
  54. package/data/Generator/templates/react-app/index.html +22 -0
  55. package/data/Generator/templates/react-app/netlify.toml +8 -0
  56. package/data/Generator/templates/react-app/npmrc +1 -0
  57. package/data/Generator/templates/react-app/package.json +31 -0
  58. package/data/Generator/templates/react-app/public/manifest.json +15 -0
  59. package/data/Generator/templates/react-app/src/auth/pages/OAuthCallback.tsx +93 -0
  60. package/data/Generator/templates/react-app/src/auth/pages/createAuthRequiredPage.jsx +40 -0
  61. package/data/Generator/templates/react-app/src/components/DefaultRootErrorBoundary.tsx +16 -0
  62. package/data/Generator/templates/react-app/src/components/FullPageWrapper.tsx +21 -0
  63. package/data/Generator/templates/react-app/src/components/Loader.module.css +37 -0
  64. package/data/Generator/templates/react-app/src/components/Loader.tsx +12 -0
  65. package/data/Generator/templates/react-app/src/components/Message.tsx +86 -0
  66. package/data/Generator/templates/react-app/src/index.tsx +47 -0
  67. package/data/Generator/templates/react-app/src/logo.png +0 -0
  68. package/data/Generator/templates/react-app/src/router.tsx +59 -0
  69. package/data/Generator/templates/react-app/src/test/vitest/setup.ts +8 -0
  70. package/data/Generator/templates/react-app/src/utils.js +3 -0
  71. package/data/Generator/templates/react-app/src/vite-env.d.ts +1 -0
  72. package/data/Generator/templates/react-app/tsconfig.app.json +28 -0
  73. package/data/Generator/templates/react-app/tsconfig.json +11 -0
  74. package/data/Generator/templates/react-app/tsconfig.vite.json +16 -0
  75. package/data/Generator/templates/react-app/vite/detectServerImports.ts +53 -0
  76. package/data/Generator/templates/react-app/vite/validateEnv.ts +45 -0
  77. package/data/Generator/templates/react-app/vite.config.ts +74 -0
  78. package/data/Generator/templates/sdk/wasp/api/events.ts +11 -0
  79. package/data/Generator/templates/sdk/wasp/api/index.ts +136 -0
  80. package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +13 -0
  81. package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +22 -0
  82. package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +20 -0
  83. package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +14 -0
  84. package/data/Generator/templates/sdk/wasp/auth/email/index.ts +5 -0
  85. package/data/Generator/templates/sdk/wasp/auth/forms/Auth.module.css +16 -0
  86. package/data/Generator/templates/sdk/wasp/auth/forms/Auth.tsx +94 -0
  87. package/data/Generator/templates/sdk/wasp/auth/forms/ForgotPassword.tsx +18 -0
  88. package/data/Generator/templates/sdk/wasp/auth/forms/Login.tsx +18 -0
  89. package/data/Generator/templates/sdk/wasp/auth/forms/ResetPassword.tsx +18 -0
  90. package/data/Generator/templates/sdk/wasp/auth/forms/Signup.tsx +24 -0
  91. package/data/Generator/templates/sdk/wasp/auth/forms/VerifyEmail.tsx +18 -0
  92. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.module.css +99 -0
  93. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.tsx +74 -0
  94. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.module.css +22 -0
  95. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.tsx +34 -0
  96. package/data/Generator/templates/sdk/wasp/auth/forms/internal/auth-styles.css +30 -0
  97. package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.module.css +55 -0
  98. package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.tsx +291 -0
  99. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ForgotPasswordForm.tsx +52 -0
  100. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ResetPasswordForm.tsx +82 -0
  101. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/VerifyEmailForm.tsx +43 -0
  102. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/useEmail.ts +33 -0
  103. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.module.css +33 -0
  104. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.tsx +14 -0
  105. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.module.css +4 -0
  106. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.tsx +74 -0
  107. package/data/Generator/templates/sdk/wasp/auth/forms/internal/usernameAndPassword/useUsernameAndPassword.ts +29 -0
  108. package/data/Generator/templates/sdk/wasp/auth/forms/internal/util.ts +16 -0
  109. package/data/Generator/templates/sdk/wasp/auth/forms/types.ts +77 -0
  110. package/data/Generator/templates/sdk/wasp/auth/helpers/_Provider.tsx +17 -0
  111. package/data/Generator/templates/sdk/wasp/auth/helpers/user.ts +15 -0
  112. package/data/Generator/templates/sdk/wasp/auth/index.ts +9 -0
  113. package/data/Generator/templates/sdk/wasp/auth/jwt.ts +22 -0
  114. package/data/Generator/templates/sdk/wasp/auth/logout.ts +18 -0
  115. package/data/Generator/templates/sdk/wasp/auth/lucia.ts +53 -0
  116. package/data/Generator/templates/sdk/wasp/auth/password.ts +36 -0
  117. package/data/Generator/templates/sdk/wasp/auth/providers/index.ts +9 -0
  118. package/data/Generator/templates/sdk/wasp/auth/providers/types.ts +68 -0
  119. package/data/Generator/templates/sdk/wasp/auth/session.ts +78 -0
  120. package/data/Generator/templates/sdk/wasp/auth/types.ts +2 -0
  121. package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +37 -0
  122. package/data/Generator/templates/sdk/wasp/auth/user.ts +63 -0
  123. package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +13 -0
  124. package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +20 -0
  125. package/data/Generator/templates/sdk/wasp/auth/username/index.ts +2 -0
  126. package/data/Generator/templates/sdk/wasp/auth/utils.ts +369 -0
  127. package/data/Generator/templates/sdk/wasp/auth/validation.ts +83 -0
  128. package/data/Generator/templates/sdk/wasp/client/auth/discord.ts +2 -0
  129. package/data/Generator/templates/sdk/wasp/client/auth/email.ts +5 -0
  130. package/data/Generator/templates/sdk/wasp/client/auth/github.ts +2 -0
  131. package/data/Generator/templates/sdk/wasp/client/auth/google.ts +2 -0
  132. package/data/Generator/templates/sdk/wasp/client/auth/index.ts +29 -0
  133. package/data/Generator/templates/sdk/wasp/client/auth/keycloak.ts +2 -0
  134. package/data/Generator/templates/sdk/wasp/client/auth/slack.ts +2 -0
  135. package/data/Generator/templates/sdk/wasp/client/auth/ui.ts +32 -0
  136. package/data/Generator/templates/sdk/wasp/client/auth/username.ts +2 -0
  137. package/data/Generator/templates/sdk/wasp/client/config.ts +15 -0
  138. package/data/Generator/templates/sdk/wasp/client/crud/_crud.ts +89 -0
  139. package/data/Generator/templates/sdk/wasp/client/crud/index.ts +4 -0
  140. package/data/Generator/templates/sdk/wasp/client/crud/operationsHelpers.ts +21 -0
  141. package/data/Generator/templates/sdk/wasp/client/env/schema.ts +22 -0
  142. package/data/Generator/templates/sdk/wasp/client/env.ts +5 -0
  143. package/data/Generator/templates/sdk/wasp/client/hooks.ts +19 -0
  144. package/data/Generator/templates/sdk/wasp/client/index.ts +17 -0
  145. package/data/Generator/templates/sdk/wasp/client/operations/actions/core.ts +49 -0
  146. package/data/Generator/templates/sdk/wasp/client/operations/actions/index.ts +13 -0
  147. package/data/Generator/templates/sdk/wasp/client/operations/hooks.ts +347 -0
  148. package/data/Generator/templates/sdk/wasp/client/operations/index.ts +22 -0
  149. package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +22 -0
  150. package/data/Generator/templates/sdk/wasp/client/operations/internal/resources.js +83 -0
  151. package/data/Generator/templates/sdk/wasp/client/operations/internal/updateHandlersMap.js +37 -0
  152. package/data/Generator/templates/sdk/wasp/client/operations/queries/core.ts +91 -0
  153. package/data/Generator/templates/sdk/wasp/client/operations/queries/index.ts +16 -0
  154. package/data/Generator/templates/sdk/wasp/client/operations/queryClient.ts +34 -0
  155. package/data/Generator/templates/sdk/wasp/client/operations/rpc.ts +96 -0
  156. package/data/Generator/templates/sdk/wasp/client/router/Link.tsx +21 -0
  157. package/data/Generator/templates/sdk/wasp/client/router/index.ts +53 -0
  158. package/data/Generator/templates/sdk/wasp/client/router/linkHelpers.ts +48 -0
  159. package/data/Generator/templates/sdk/wasp/client/router/types.ts +98 -0
  160. package/data/Generator/templates/sdk/wasp/client/test/index.ts +1 -0
  161. package/data/Generator/templates/sdk/wasp/client/test/vitest/helpers.tsx +95 -0
  162. package/data/Generator/templates/sdk/wasp/client/webSocket/WebSocketProvider.tsx +77 -0
  163. package/data/Generator/templates/sdk/wasp/client/webSocket/index.ts +39 -0
  164. package/data/Generator/templates/sdk/wasp/core/auth.ts +40 -0
  165. package/data/Generator/templates/sdk/wasp/core/serialization/custom-register.ts +21 -0
  166. package/data/Generator/templates/sdk/wasp/core/serialization/index.ts +56 -0
  167. package/data/Generator/templates/sdk/wasp/core/serialization/prisma.ts +54 -0
  168. package/data/Generator/templates/sdk/wasp/core/storage.ts +50 -0
  169. package/data/Generator/templates/sdk/wasp/dev/index.ts +19 -0
  170. package/data/Generator/templates/sdk/wasp/entities/index.ts +28 -0
  171. package/data/Generator/templates/sdk/wasp/env/index.ts +9 -0
  172. package/data/Generator/templates/sdk/wasp/env/validation.ts +38 -0
  173. package/data/Generator/templates/sdk/wasp/package.json +152 -0
  174. package/data/Generator/templates/sdk/wasp/prisma-runtime-library.d.ts +17 -0
  175. package/data/Generator/templates/sdk/wasp/scripts/copy-assets.js +14 -0
  176. package/data/Generator/templates/sdk/wasp/server/HttpError.ts +30 -0
  177. package/data/Generator/templates/sdk/wasp/server/_types/index.ts +105 -0
  178. package/data/Generator/templates/sdk/wasp/server/_types/taggedEntities.ts +26 -0
  179. package/data/Generator/templates/sdk/wasp/server/api/index.ts +44 -0
  180. package/data/Generator/templates/sdk/wasp/server/auth/email/index.ts +20 -0
  181. package/data/Generator/templates/sdk/wasp/server/auth/email/utils.ts +104 -0
  182. package/data/Generator/templates/sdk/wasp/server/auth/hooks.ts +188 -0
  183. package/data/Generator/templates/sdk/wasp/server/auth/index.ts +49 -0
  184. package/data/Generator/templates/sdk/wasp/server/auth/oauth/index.ts +38 -0
  185. package/data/Generator/templates/sdk/wasp/server/auth/oauth/oneTimeCode.ts +50 -0
  186. package/data/Generator/templates/sdk/wasp/server/auth/oauth/provider.ts +20 -0
  187. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/discord.ts +22 -0
  188. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/github.ts +20 -0
  189. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/google.ts +22 -0
  190. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/keycloak.ts +23 -0
  191. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/slack.ts +22 -0
  192. package/data/Generator/templates/sdk/wasp/server/auth/oauth/redirect.ts +43 -0
  193. package/data/Generator/templates/sdk/wasp/server/auth/user.ts +148 -0
  194. package/data/Generator/templates/sdk/wasp/server/auth/username.ts +1 -0
  195. package/data/Generator/templates/sdk/wasp/server/config.ts +47 -0
  196. package/data/Generator/templates/sdk/wasp/server/crud/_operationTypes.ts +134 -0
  197. package/data/Generator/templates/sdk/wasp/server/crud/index.ts +5 -0
  198. package/data/Generator/templates/sdk/wasp/server/dbClient.ts +35 -0
  199. package/data/Generator/templates/sdk/wasp/server/email/core/helpers.ts +40 -0
  200. package/data/Generator/templates/sdk/wasp/server/email/core/index.ts +17 -0
  201. package/data/Generator/templates/sdk/wasp/server/email/core/providers/dummy.ts +34 -0
  202. package/data/Generator/templates/sdk/wasp/server/email/core/providers/mailgun.ts +31 -0
  203. package/data/Generator/templates/sdk/wasp/server/email/core/providers/sendgrid.ts +44 -0
  204. package/data/Generator/templates/sdk/wasp/server/email/core/providers/smtp.ts +29 -0
  205. package/data/Generator/templates/sdk/wasp/server/email/core/types.ts +59 -0
  206. package/data/Generator/templates/sdk/wasp/server/email/index.ts +39 -0
  207. package/data/Generator/templates/sdk/wasp/server/env.ts +173 -0
  208. package/data/Generator/templates/sdk/wasp/server/index.ts +17 -0
  209. package/data/Generator/templates/sdk/wasp/server/jobs/_job.ts +39 -0
  210. package/data/Generator/templates/sdk/wasp/server/jobs/core/job.ts +28 -0
  211. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/index.ts +3 -0
  212. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts +76 -0
  213. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBossJob.ts +230 -0
  214. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/types.ts +9 -0
  215. package/data/Generator/templates/sdk/wasp/server/jobs/index.ts +5 -0
  216. package/data/Generator/templates/sdk/wasp/server/middleware/globalMiddleware.ts +8 -0
  217. package/data/Generator/templates/sdk/wasp/server/middleware/index.ts +1 -0
  218. package/data/Generator/templates/sdk/wasp/server/operations/actions/index.ts +41 -0
  219. package/data/Generator/templates/sdk/wasp/server/operations/actions/types.ts +35 -0
  220. package/data/Generator/templates/sdk/wasp/server/operations/index.ts +13 -0
  221. package/data/Generator/templates/sdk/wasp/server/operations/queries/index.ts +42 -0
  222. package/data/Generator/templates/sdk/wasp/server/operations/queries/types.ts +36 -0
  223. package/data/Generator/templates/sdk/wasp/server/operations/wrappers.ts +242 -0
  224. package/data/Generator/templates/sdk/wasp/server/types/index.ts +11 -0
  225. package/data/Generator/templates/sdk/wasp/server/utils.ts +38 -0
  226. package/data/Generator/templates/sdk/wasp/server/webSocket/index.ts +57 -0
  227. package/data/Generator/templates/sdk/wasp/tsconfig.json +102 -0
  228. package/data/Generator/templates/sdk/wasp/universal/ansiColors.ts +14 -0
  229. package/data/Generator/templates/sdk/wasp/universal/predicates.ts +3 -0
  230. package/data/Generator/templates/sdk/wasp/universal/types.ts +74 -0
  231. package/data/Generator/templates/sdk/wasp/universal/url.ts +9 -0
  232. package/data/Generator/templates/sdk/wasp/universal/validators.ts +21 -0
  233. package/data/Generator/templates/sdk/wasp/vite-env.d.ts +1 -0
  234. package/data/Generator/templates/server/README.md +1 -0
  235. package/data/Generator/templates/server/gitignore +6 -0
  236. package/data/Generator/templates/server/nodemon.json +13 -0
  237. package/data/Generator/templates/server/npmrc +1 -0
  238. package/data/Generator/templates/server/package.json +27 -0
  239. package/data/Generator/templates/server/rollup.config.js +44 -0
  240. package/data/Generator/templates/server/src/actions/_action.ts +18 -0
  241. package/data/Generator/templates/server/src/app.js +36 -0
  242. package/data/Generator/templates/server/src/auth/hooks.ts +135 -0
  243. package/data/Generator/templates/server/src/auth/providers/config/discord.ts +69 -0
  244. package/data/Generator/templates/server/src/auth/providers/config/email.ts +96 -0
  245. package/data/Generator/templates/server/src/auth/providers/config/github.ts +78 -0
  246. package/data/Generator/templates/server/src/auth/providers/config/google.ts +65 -0
  247. package/data/Generator/templates/server/src/auth/providers/config/keycloak.ts +67 -0
  248. package/data/Generator/templates/server/src/auth/providers/config/slack.ts +65 -0
  249. package/data/Generator/templates/server/src/auth/providers/config/username.ts +33 -0
  250. package/data/Generator/templates/server/src/auth/providers/email/login.ts +66 -0
  251. package/data/Generator/templates/server/src/auth/providers/email/requestPasswordReset.ts +74 -0
  252. package/data/Generator/templates/server/src/auth/providers/email/resetPassword.ts +48 -0
  253. package/data/Generator/templates/server/src/auth/providers/email/signup.ts +165 -0
  254. package/data/Generator/templates/server/src/auth/providers/email/verifyEmail.ts +42 -0
  255. package/data/Generator/templates/server/src/auth/providers/index.ts +32 -0
  256. package/data/Generator/templates/server/src/auth/providers/oauth/config.ts +19 -0
  257. package/data/Generator/templates/server/src/auth/providers/oauth/cookies.ts +35 -0
  258. package/data/Generator/templates/server/src/auth/providers/oauth/handler.ts +130 -0
  259. package/data/Generator/templates/server/src/auth/providers/oauth/oneTimeCode.ts +39 -0
  260. package/data/Generator/templates/server/src/auth/providers/oauth/state.ts +144 -0
  261. package/data/Generator/templates/server/src/auth/providers/oauth/types.ts +7 -0
  262. package/data/Generator/templates/server/src/auth/providers/oauth/user.ts +139 -0
  263. package/data/Generator/templates/server/src/auth/providers/username/login.ts +64 -0
  264. package/data/Generator/templates/server/src/auth/providers/username/signup.ts +59 -0
  265. package/data/Generator/templates/server/src/crud/_operations.ts +184 -0
  266. package/data/Generator/templates/server/src/dbSeed.ts +37 -0
  267. package/data/Generator/templates/server/src/jobs/_job.ts +9 -0
  268. package/data/Generator/templates/server/src/jobs/core/allJobs.ts +8 -0
  269. package/data/Generator/templates/server/src/middleware/globalMiddleware.ts +45 -0
  270. package/data/Generator/templates/server/src/middleware/index.ts +1 -0
  271. package/data/Generator/templates/server/src/middleware/operations.ts +28 -0
  272. package/data/Generator/templates/server/src/queries/_query.ts +18 -0
  273. package/data/Generator/templates/server/src/routes/apis/index.ts +67 -0
  274. package/data/Generator/templates/server/src/routes/auth/index.js +16 -0
  275. package/data/Generator/templates/server/src/routes/auth/logout.ts +12 -0
  276. package/data/Generator/templates/server/src/routes/auth/me.ts +10 -0
  277. package/data/Generator/templates/server/src/routes/crud/_crud.ts +46 -0
  278. package/data/Generator/templates/server/src/routes/crud/index.ts +12 -0
  279. package/data/Generator/templates/server/src/routes/index.js +55 -0
  280. package/data/Generator/templates/server/src/routes/operations/_action.js +5 -0
  281. package/data/Generator/templates/server/src/routes/operations/_query.js +5 -0
  282. package/data/Generator/templates/server/src/routes/operations/index.js +18 -0
  283. package/data/Generator/templates/server/src/server.ts +76 -0
  284. package/data/Generator/templates/server/src/views/wrong-port.ts +123 -0
  285. package/data/Generator/templates/server/src/webSocket/initialization.ts +59 -0
  286. package/data/Generator/templates/server/tsconfig.json +41 -0
  287. package/data/Lsp/templates/ts/action.fn.ts +12 -0
  288. package/data/Lsp/templates/ts/operation.fn.js +7 -0
  289. package/data/Lsp/templates/ts/page.component.jsx +9 -0
  290. package/data/Lsp/templates/ts/query.fn.ts +12 -0
  291. package/data/packages/deploy/dist/common/brandedTypes.js +2 -0
  292. package/data/packages/deploy/dist/common/clientApp.js +26 -0
  293. package/data/packages/deploy/dist/common/commander.js +8 -0
  294. package/data/packages/deploy/dist/common/random.js +5 -0
  295. package/data/packages/deploy/dist/common/terminal.js +24 -0
  296. package/data/packages/deploy/dist/common/typeUtils.js +2 -0
  297. package/data/packages/deploy/dist/common/validation.js +14 -0
  298. package/data/packages/deploy/dist/common/waspBuild.js +21 -0
  299. package/data/packages/deploy/dist/common/waspProject.js +43 -0
  300. package/data/packages/deploy/dist/common/zx.js +10 -0
  301. package/data/packages/deploy/dist/index.js +30 -0
  302. package/data/packages/deploy/dist/providers/fly/CommonCmdOptions.js +2 -0
  303. package/data/packages/deploy/dist/providers/fly/CommonOps.js +36 -0
  304. package/data/packages/deploy/dist/providers/fly/DeploymentInstructions.js +12 -0
  305. package/data/packages/deploy/dist/providers/fly/commands/cmd/CmdCmdOptions.js +2 -0
  306. package/data/packages/deploy/dist/providers/fly/commands/cmd/cmd.js +29 -0
  307. package/data/packages/deploy/dist/providers/fly/commands/createDb/CreateDbCmdOptions.js +2 -0
  308. package/data/packages/deploy/dist/providers/fly/commands/createDb/createDb.js +55 -0
  309. package/data/packages/deploy/dist/providers/fly/commands/deploy/DeployCmdOptions.js +2 -0
  310. package/data/packages/deploy/dist/providers/fly/commands/deploy/deploy.js +88 -0
  311. package/data/packages/deploy/dist/providers/fly/commands/launch/LaunchCmdOptions.js +2 -0
  312. package/data/packages/deploy/dist/providers/fly/commands/launch/launch.js +17 -0
  313. package/data/packages/deploy/dist/providers/fly/commands/setup/SetupCmdOptions.js +2 -0
  314. package/data/packages/deploy/dist/providers/fly/commands/setup/setup.js +141 -0
  315. package/data/packages/deploy/dist/providers/fly/flyAppUrl.js +4 -0
  316. package/data/packages/deploy/dist/providers/fly/flyCli.js +74 -0
  317. package/data/packages/deploy/dist/providers/fly/index.js +121 -0
  318. package/data/packages/deploy/dist/providers/fly/jsonOutputSchemas.js +37 -0
  319. package/data/packages/deploy/dist/providers/fly/tomlFile.js +65 -0
  320. package/data/packages/deploy/dist/providers/railway/DeploymentInstructions.js +11 -0
  321. package/data/packages/deploy/dist/providers/railway/brandedTypes.js +2 -0
  322. package/data/packages/deploy/dist/providers/railway/commands/deploy/DeployCmdOptions.js +2 -0
  323. package/data/packages/deploy/dist/providers/railway/commands/deploy/client.js +22 -0
  324. package/data/packages/deploy/dist/providers/railway/commands/deploy/common.js +40 -0
  325. package/data/packages/deploy/dist/providers/railway/commands/deploy/index.js +57 -0
  326. package/data/packages/deploy/dist/providers/railway/commands/deploy/server.js +17 -0
  327. package/data/packages/deploy/dist/providers/railway/commands/launch/LaunchCmdOptions.js +2 -0
  328. package/data/packages/deploy/dist/providers/railway/commands/launch/launch.js +9 -0
  329. package/data/packages/deploy/dist/providers/railway/commands/setup/SetupCmdOptions.js +2 -0
  330. package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +146 -0
  331. package/data/packages/deploy/dist/providers/railway/index.js +83 -0
  332. package/data/packages/deploy/dist/providers/railway/jsonOutputSchemas.js +19 -0
  333. package/data/packages/deploy/dist/providers/railway/ports.js +6 -0
  334. package/data/packages/deploy/dist/providers/railway/railwayCli.js +85 -0
  335. package/data/packages/deploy/dist/providers/railway/railwayProject/RailwayProject.js +14 -0
  336. package/data/packages/deploy/dist/providers/railway/railwayProject/cli.js +80 -0
  337. package/data/packages/deploy/dist/providers/railway/railwayProject/index.js +48 -0
  338. package/data/packages/deploy/dist/providers/railway/railwayService/nameGenerator.js +24 -0
  339. package/data/packages/deploy/dist/providers/railway/railwayService/url.js +32 -0
  340. package/data/packages/deploy/package-lock.json +3536 -0
  341. package/data/packages/deploy/package.json +29 -0
  342. package/data/packages/prisma/dist/format.js +35 -0
  343. package/data/packages/prisma/dist/index.js +33 -0
  344. package/data/packages/prisma/package-lock.json +5101 -0
  345. package/data/packages/prisma/package.json +30 -0
  346. package/data/packages/studio/dist/index.js +48 -0
  347. package/data/packages/studio/dist/public/assets/Flow-b5112d3d.js +26 -0
  348. package/data/packages/studio/dist/public/assets/index-17ce6ed4.css +1 -0
  349. package/data/packages/studio/dist/public/assets/index-62a9d21a.js +120 -0
  350. package/data/packages/studio/dist/public/index.html +14 -0
  351. package/data/packages/studio/package-lock.json +1866 -0
  352. package/data/packages/studio/package.json +33 -0
  353. package/data/packages/ts-inspect/dist/exports.js +82 -0
  354. package/data/packages/ts-inspect/dist/index.js +28 -0
  355. package/data/packages/ts-inspect/package-lock.json +4947 -0
  356. package/data/packages/ts-inspect/package.json +31 -0
  357. package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.d.ts +2 -0
  358. package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.d.ts.map +1 -0
  359. package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.js +59 -0
  360. package/data/packages/wasp-config/dist/__tests__/cli.unit.test.d.ts +2 -0
  361. package/data/packages/wasp-config/dist/__tests__/cli.unit.test.d.ts.map +1 -0
  362. package/data/packages/wasp-config/dist/__tests__/cli.unit.test.js +65 -0
  363. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.d.ts +2 -0
  364. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.d.ts.map +1 -0
  365. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.js +126 -0
  366. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.d.ts +2 -0
  367. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.d.ts.map +1 -0
  368. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.js +743 -0
  369. package/data/packages/wasp-config/dist/__tests__/testFixtures.d.ts +224 -0
  370. package/data/packages/wasp-config/dist/__tests__/testFixtures.d.ts.map +1 -0
  371. package/data/packages/wasp-config/dist/__tests__/testFixtures.js +656 -0
  372. package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.d.ts +2 -0
  373. package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.d.ts.map +1 -0
  374. package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.js +57 -0
  375. package/data/packages/wasp-config/dist/src/_private.d.ts +2 -0
  376. package/data/packages/wasp-config/dist/src/_private.d.ts.map +1 -0
  377. package/data/packages/wasp-config/dist/src/_private.js +1 -0
  378. package/data/packages/wasp-config/dist/src/appAnalyzer.d.ts +16 -0
  379. package/data/packages/wasp-config/dist/src/appAnalyzer.d.ts.map +1 -0
  380. package/data/packages/wasp-config/dist/src/appAnalyzer.js +34 -0
  381. package/data/packages/wasp-config/dist/src/appSpec.d.ts +223 -0
  382. package/data/packages/wasp-config/dist/src/appSpec.d.ts.map +1 -0
  383. package/data/packages/wasp-config/dist/src/appSpec.js +6 -0
  384. package/data/packages/wasp-config/dist/src/branded.d.ts +7 -0
  385. package/data/packages/wasp-config/dist/src/branded.d.ts.map +1 -0
  386. package/data/packages/wasp-config/dist/src/branded.js +1 -0
  387. package/data/packages/wasp-config/dist/src/cli.d.ts +6 -0
  388. package/data/packages/wasp-config/dist/src/cli.d.ts.map +1 -0
  389. package/data/packages/wasp-config/dist/src/cli.js +24 -0
  390. package/data/packages/wasp-config/dist/src/index.d.ts +8 -0
  391. package/data/packages/wasp-config/dist/src/index.d.ts.map +1 -0
  392. package/data/packages/wasp-config/dist/src/index.js +1 -0
  393. package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.d.ts +38 -0
  394. package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.d.ts.map +1 -0
  395. package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.js +294 -0
  396. package/data/packages/wasp-config/dist/src/publicApi/App.d.ts +24 -0
  397. package/data/packages/wasp-config/dist/src/publicApi/App.d.ts.map +1 -0
  398. package/data/packages/wasp-config/dist/src/publicApi/App.js +75 -0
  399. package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts +171 -0
  400. package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts.map +1 -0
  401. package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.js +1 -0
  402. package/data/packages/wasp-config/dist/src/run.d.ts +3 -0
  403. package/data/packages/wasp-config/dist/src/run.d.ts.map +1 -0
  404. package/data/packages/wasp-config/dist/src/run.js +18 -0
  405. package/data/packages/wasp-config/package-lock.json +3992 -0
  406. package/data/packages/wasp-config/package.json +39 -0
  407. package/main.js +9 -0
  408. package/package.json +1 -0
  409. package/readme.md +3 -0
  410. package/wasp-bin +0 -0
@@ -0,0 +1,35 @@
1
+ {{={= =}=}}
2
+ {=! TODO: This template is exactly the same at the moment as one for query
3
+ types, consider whether it makes sense to address this in the future. =}
4
+ import {
5
+ {=# allEntities =}
6
+ type {= internalTypeName =},
7
+ {=/ allEntities =}
8
+ {=# shouldImportNonAuthenticatedOperation =}
9
+ type UnauthenticatedActionDefinition,
10
+ {=/ shouldImportNonAuthenticatedOperation =}
11
+ {=# shouldImportAuthenticatedOperation =}
12
+ type AuthenticatedActionDefinition,
13
+ {=/ shouldImportAuthenticatedOperation =}
14
+ type Payload,
15
+ } from 'wasp/server/_types'
16
+
17
+ {=# operations =}
18
+ // PUBLIC API
19
+ export type {= typeName =}<Input extends Payload = never, Output extends Payload = Payload> =
20
+ {=# usesAuth =}
21
+ AuthenticatedActionDefinition<
22
+ {=/ usesAuth =}
23
+ {=^ usesAuth =}
24
+ UnauthenticatedActionDefinition<
25
+ {=/ usesAuth =}
26
+ [
27
+ {=# entities =}
28
+ {= internalTypeName =},
29
+ {=/ entities =}
30
+ ],
31
+ Input,
32
+ Output
33
+ >
34
+
35
+ {=/ operations =}
@@ -0,0 +1,13 @@
1
+ {{={= =}=}}
2
+ // PUBLIC API
3
+ export * from './queries/types.js'
4
+ // PUBLIC API
5
+ export * from './actions/types.js'
6
+ {=# queries =}
7
+
8
+ export { {= operationName =} } from './queries/index.js'
9
+ {=/ queries =}
10
+ {=# actions =}
11
+
12
+ export { {= operationName =} } from './actions/index.js'
13
+ {=/ actions =}
@@ -0,0 +1,42 @@
1
+ {{={= =}=}}
2
+ {=! TODO: This template is exactly the same at the moment as one for actions,
3
+ consider in the future if it is worth removing this duplication. =}
4
+
5
+ {=! TODO: This will generate multiple import statements even though they're
6
+ importing symbols from the same file. We should improve our importing machinery
7
+ to support multiple imports from the same file =}
8
+ import { prisma } from 'wasp/server'
9
+ import {
10
+ type UnauthenticatedOperationFor,
11
+ createUnauthenticatedOperation,
12
+ {=# isAuthEnabled =}
13
+ type AuthenticatedOperationFor,
14
+ createAuthenticatedOperation,
15
+ {=/ isAuthEnabled =}
16
+ } from '../wrappers.js'
17
+ {=# operations =}
18
+ {=& jsFn.importStatement =}
19
+ {=/ operations =}
20
+ {=# operations =}
21
+
22
+ // PRIVATE API
23
+ export type {= operationTypeName =} = typeof {= jsFn.importIdentifier =}
24
+
25
+ // PUBLIC API
26
+ {=# usesAuth =}
27
+ export const {= operationName =}: AuthenticatedOperationFor<{= operationTypeName =}> =
28
+ createAuthenticatedOperation(
29
+ {=/ usesAuth =}
30
+ {=^ usesAuth =}
31
+ export const {= operationName =}: UnauthenticatedOperationFor<{= operationTypeName =}> =
32
+ createUnauthenticatedOperation(
33
+ {=/ usesAuth =}
34
+ {= jsFn.importIdentifier =},
35
+ {
36
+ {=# entities =}
37
+ {= name =}: prisma.{= prismaIdentifier =},
38
+ {=/ entities =}
39
+ },
40
+ )
41
+
42
+ {=/ operations =}
@@ -0,0 +1,36 @@
1
+ {{={= =}=}}
2
+ {=! TODO: This template is exactly the same at the moment as one for action
3
+ types, consider whether it makes sense to address this in the future. =}
4
+
5
+ import {
6
+ {=# allEntities =}
7
+ type {= internalTypeName =},
8
+ {=/ allEntities =}
9
+ {=# shouldImportNonAuthenticatedOperation =}
10
+ type UnauthenticatedQueryDefinition,
11
+ {=/ shouldImportNonAuthenticatedOperation =}
12
+ {=# shouldImportAuthenticatedOperation =}
13
+ type AuthenticatedQueryDefinition,
14
+ {=/ shouldImportAuthenticatedOperation =}
15
+ type Payload,
16
+ } from 'wasp/server/_types'
17
+
18
+ {=# operations =}
19
+ // PUBLIC API
20
+ export type {= typeName =}<Input extends Payload = never, Output extends Payload = Payload> =
21
+ {=# usesAuth =}
22
+ AuthenticatedQueryDefinition<
23
+ {=/ usesAuth =}
24
+ {=^ usesAuth =}
25
+ UnauthenticatedQueryDefinition<
26
+ {=/ usesAuth =}
27
+ [
28
+ {=# entities =}
29
+ {= internalTypeName =},
30
+ {=/ entities =}
31
+ ],
32
+ Input,
33
+ Output
34
+ >
35
+
36
+ {=/ operations =}
@@ -0,0 +1,242 @@
1
+ {{={= =}=}}
2
+ import { IfAny, _Awaited, _ReturnType, _Parameters } from '../../universal/types'
3
+
4
+ {=# isAuthEnabled =}
5
+ import { type AuthUser } from 'wasp/auth'
6
+ {=/ isAuthEnabled =}
7
+ import {
8
+ _Entity,
9
+ {=# isAuthEnabled =}
10
+ AuthenticatedOperationDefinition,
11
+ {=/ isAuthEnabled =}
12
+ UnauthenticatedOperationDefinition,
13
+ Payload,
14
+ } from '../_types'
15
+
16
+ // PRIVATE API (used in SDK)
17
+ // Explanation:
18
+ // - Custom `_Awaited` and `_ReturnType` - Read the comments above their
19
+ // definitions.
20
+ // - `Parameters<OperationDefinition> extends []` - Same reason as described here:
21
+ // https://github.com/wasp-lang/wasp/pull/1992/files#r1583040080
22
+ /**
23
+ * Constructs the unauthenticated operation's server-side API type from its
24
+ * definition.
25
+ *
26
+ * @template OperationDefinition The type of the unauthenticated operation's
27
+ * definition.
28
+ */
29
+ export type UnauthenticatedOperationFor<
30
+ OperationDefinition extends GenericUnauthenticatedOperationDefinition
31
+ > = Parameters<OperationDefinition> extends []
32
+ ? UnauthenticatedOperation<void, _Awaited<_ReturnType<OperationDefinition>>>
33
+ : UnauthenticatedOperation<
34
+ Parameters<OperationDefinition>[0],
35
+ _Awaited<_ReturnType<OperationDefinition>>
36
+ >
37
+
38
+ // PRIVATE API (used in SDK)
39
+ /**
40
+ * Creates the server-side API for an unauthenticated operation.
41
+ *
42
+ * @template OperationDefinition The type of the unauthenticated operation's definition.
43
+ * @param userOperation The unauthenticated operation's definition.
44
+ * @param entities The unauthenticated operation's entity map .
45
+ * @returns The server-side API for the provided unauthenticated operation.
46
+ */
47
+ export function createUnauthenticatedOperation<
48
+ OperationDefinition extends GenericUnauthenticatedOperationDefinition
49
+ >(
50
+ userOperation: OperationDefinition,
51
+ entities: EntityMapFor<OperationDefinition>
52
+ ): UnauthenticatedOperationFor<OperationDefinition> {
53
+ async function operation(payload: Parameters<OperationDefinition>[0]) {
54
+ return userOperation(payload, {
55
+ entities,
56
+ })
57
+ }
58
+ // This assertion is necessary because, when the Input is void, we want to present
59
+ // the function as not accepting a payload (which isn't consistent with how
60
+ // it's defined).
61
+ return operation as UnauthenticatedOperationFor<OperationDefinition>
62
+ }
63
+
64
+ {=# isAuthEnabled =}
65
+ // PRIVATE API (used in SDK)
66
+ // Explanation:
67
+ // - Custom `_Awaited` and `_ReturnType` - Read the comments above their
68
+ // definitions.
69
+ // - `Parameters<OperationDefinition> extends []` - Same reason as described here:
70
+ // https://github.com/wasp-lang/wasp/pull/1992/files#r1583040080
71
+ /**
72
+ * Constructs the authenticated operation's server-side API type from its
73
+ * definition.
74
+ *
75
+ * @template OperationDefinition The type of the authenticated operation's
76
+ * definition.
77
+ */
78
+ export type AuthenticatedOperationFor<
79
+ OperationDefinition extends GenericAuthenticatedOperationDefinition
80
+ > = Parameters<OperationDefinition> extends []
81
+ ? AuthenticatedOperation<void, _Awaited<_ReturnType<OperationDefinition>>>
82
+ : AuthenticatedOperation<
83
+ Parameters<OperationDefinition>[0],
84
+ _Awaited<_ReturnType<OperationDefinition>>
85
+ >
86
+
87
+ /**
88
+ * The type of the context users must pass when calling an authenticated
89
+ * operation's server-side API.
90
+ */
91
+ export type AuthenticatedOperationContext = { user: AuthUser }
92
+
93
+ // PRIVATE API (used in SDK)
94
+ /**
95
+ * Creates the server-side API for an authenticated operation.
96
+ *
97
+ * @template OperationDefinition The type of the authenticated operation's definition.
98
+ * @param userOperation The authenticated operation's definition.
99
+ * @param entities The authenticated operation's entity map .
100
+ * @returns The server-side API for the provided authenticated operation.
101
+ */
102
+ export function createAuthenticatedOperation<
103
+ OperationDefinition extends GenericAuthenticatedOperationDefinition
104
+ >(
105
+ userOperation: OperationDefinition,
106
+ entities: EntityMapFor<OperationDefinition>
107
+ ): AuthenticatedOperationFor<OperationDefinition> {
108
+ async function operation(...args: AuthenticatedOperationArgsFor<OperationDefinition>) {
109
+ // To understand this function and its limitations, read
110
+ // https://github.com/wasp-lang/wasp/issues/2050
111
+ if (args.length < 1) {
112
+ // No arguments sent -> no user and no payload specified -> there's no way this was called correctly.
113
+ throw new Error(`
114
+ You called the operation without arguments, which is a mistake.
115
+ Check your definition and read the docs to understand what you need to send:
116
+ https://wasp.sh/docs/data-model/operations/overview
117
+ `
118
+ )
119
+ } else if (includesPayload(args)) {
120
+ // Two arguments sent -> the first argument is the payload, the second is the context.
121
+ const [payload, context] = args
122
+ return userOperation(payload as Parameters<OperationDefinition>[0], {
123
+ ...context,
124
+ entities,
125
+ })
126
+ } else {
127
+ // One argument sent -> the first and only argument is the user.
128
+ const [context] = args
129
+ return userOperation(undefined as Parameters<OperationDefinition>[0], {
130
+ ...context,
131
+ entities,
132
+ })
133
+ }
134
+ }
135
+
136
+ return operation as AuthenticatedOperationFor<OperationDefinition>
137
+ }
138
+
139
+ /**
140
+ * Returns a boolean carrying compiler type information about whether the
141
+ * provided arguments array (of an authenticated operation) includes a payload.
142
+ *
143
+ * To understand why "two arguments" means "includes payload", read
144
+ * https://github.com/wasp-lang/wasp/issues/2050
145
+ *
146
+ * @template Input The type of the payload the operation expects.
147
+ * @param args The arguments array for an authenticated operation.
148
+ * @returns true if the arguments array includes a payload, false otherwise.
149
+ */
150
+ function includesPayload<Input>(
151
+ args: [AuthenticatedOperationContext] | [Input, AuthenticatedOperationContext]
152
+ ): args is [Input, AuthenticatedOperationContext] {
153
+ return args.length === 2
154
+ }
155
+
156
+ /**
157
+ * Constructs the type of the arguments array for an authenticated operation
158
+ * based on the type of its definition.
159
+ */
160
+ type AuthenticatedOperationArgsFor<Op extends GenericAuthenticatedOperationDefinition> =
161
+ Parameters<AuthenticatedOperationFor<Op>>
162
+
163
+ // NOTE: There's some duplication in the below types.
164
+ // Read the discussion here to understand why before attempting to remove it:
165
+ // https://github.com/wasp-lang/wasp/pull/2170#discussion_r1671285049
166
+ /**
167
+ * Constructs the type for an authenticated operation's server-side API.
168
+ *
169
+ * @template Input The type of the payload the operation expects (must be
170
+ * `void` if the operation doesn't expect a payload).
171
+ * @template Output The type of the operation's return value.
172
+ */
173
+ type AuthenticatedOperation<Input, Output> =
174
+ IfAny<
175
+ Input,
176
+ (args: any, context: { user: AuthUser }) => Promise<Output>,
177
+ AuthenticatedOperationWithNonAnyInput<Input, Output>
178
+ >
179
+
180
+ // Read this to understand the type: https://github.com/wasp-lang/wasp/pull/1090#discussion_r1159732471
181
+ type AuthenticatedOperationWithNonAnyInput<Input, Output> =
182
+ [Input] extends [never]
183
+ ? (args: unknown, context: { user: AuthUser }) => Promise<Output>
184
+ : [Input] extends [void]
185
+ ? (context: { user: AuthUser }) => Promise<Output>
186
+ : (args: Input, context: { user: AuthUser }) => Promise<Output>
187
+
188
+ /**
189
+ * The principal type for an authenticated operation's definition (i.e., all
190
+ * authenticated operation definition types are a subtype of this type).
191
+ *
192
+ */
193
+ type GenericAuthenticatedOperationDefinition = AuthenticatedOperationDefinition<
194
+ // NOTE(filip): Not quite sure I understand what's going on with Variance here.
195
+ _Entity[],
196
+ never,
197
+ Payload
198
+ >
199
+
200
+ {=/ isAuthEnabled =}
201
+ // Read this to understand the type: https://github.com/wasp-lang/wasp/pull/2170#issue-2398830273
202
+ /**
203
+ * Constructs the type for an unauthenticated operation's server-side API.
204
+ *
205
+ * @template Input The type of the payload the operation expects (must be
206
+ * `void` if the operation doesn't expect a payload).
207
+ * @template Output The type of the operation's return value.
208
+ */
209
+ type UnauthenticatedOperation<Input, Output> =
210
+ IfAny<
211
+ Input,
212
+ (args?: any) => Promise<Output>,
213
+ UnauthenticatedOperationWithNonAnyInput<Input, Output>
214
+ >
215
+
216
+ // Read this to understand the type: https://github.com/wasp-lang/wasp/pull/1090#discussion_r1159732471
217
+ type UnauthenticatedOperationWithNonAnyInput<Input, Output> =
218
+ [Input] extends [never]
219
+ ? (args?: unknown) => Promise<Output>
220
+ : [Input] extends [void]
221
+ ? () => Promise<Output>
222
+ : (args: Input) => Promise<Output>
223
+
224
+ /**
225
+ * The principal type for an unauthenticated operation's definition (i.e., all
226
+ * unauthenticated operation definition types are a subtype of this type).
227
+ *
228
+ */
229
+ type GenericUnauthenticatedOperationDefinition = UnauthenticatedOperationDefinition<
230
+ // NOTE(filip): Not quite sure I understand what's going on with Variance here.
231
+ _Entity[],
232
+ never,
233
+ Payload
234
+ >
235
+
236
+ /**
237
+ * Queries the entity map from the type of the operation's definition.
238
+ *
239
+ * @template OperationDefinition The type of the operation's definition.
240
+ */
241
+ type EntityMapFor<OperationDefinition extends GenericUnauthenticatedOperationDefinition> =
242
+ _Parameters<OperationDefinition>[1]["entities"]
@@ -0,0 +1,11 @@
1
+ import { type Application } from 'express'
2
+ import { Server } from 'http'
3
+
4
+ // PUBLIC API
5
+ export type ServerSetupFn = (context: ServerSetupFnContext) => Promise<void>
6
+
7
+ // PRIVATE API (server)
8
+ export type ServerSetupFnContext = {
9
+ app: Application,
10
+ server: Server,
11
+ }
@@ -0,0 +1,38 @@
1
+ {{={= =}=}}
2
+ import { Response, RequestHandler } from 'express'
3
+
4
+ {=# isAuthEnabled =}
5
+ import { type AuthUserData } from './auth/user.js'
6
+ {=/ isAuthEnabled =}
7
+
8
+ // This is explicitly how Express expects extensions to their
9
+ // Request and Response objects to be done.
10
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/5d29b9be383902b0399f26072b4590ac61ca72c5/types/express-serve-static-core/index.d.ts#L6-L15
11
+ declare global {
12
+ namespace Express {
13
+ interface Request {
14
+ {=# isAuthEnabled =}
15
+ user?: AuthUserData | null;
16
+ sessionId?: string | null;
17
+ {=/ isAuthEnabled =}
18
+ }
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Simple helper to give the correct types for Express handlers.
24
+ * We define it in the same file as our extension to Request
25
+ * so that it is picked up by TypeScript.
26
+ */
27
+ export const defineHandler = <T extends RequestHandler>(
28
+ middleware: T
29
+ ): T => middleware
30
+
31
+ export const sleep = (ms: number): Promise<unknown> => new Promise((r) => setTimeout(r, ms))
32
+
33
+ export function redirect(res: Response, redirectUri: string) {
34
+ return res
35
+ .status(302)
36
+ .setHeader("Location", redirectUri)
37
+ .end();
38
+ }
@@ -0,0 +1,57 @@
1
+ {{={= =}=}}
2
+
3
+ import { Server } from 'socket.io'
4
+ import { EventsMap, DefaultEventsMap } from '@socket.io/component-emitter'
5
+
6
+ import { prisma } from 'wasp/server'
7
+ {=# isAuthEnabled =}
8
+ import { type AuthUser } from 'wasp/auth'
9
+ {=/ isAuthEnabled =}
10
+
11
+ {=& userWebSocketFn.importStatement =}
12
+
13
+ // Public API
14
+ export type WebSocketDefinition<
15
+ ClientToServerEvents extends EventsMap = DefaultEventsMap,
16
+ ServerToClientEvents extends EventsMap = DefaultEventsMap,
17
+ InterServerEvents extends EventsMap = DefaultEventsMap,
18
+ SocketData extends WaspSocketData = WaspSocketData
19
+ > = (
20
+ io: Server<
21
+ ClientToServerEvents,
22
+ ServerToClientEvents,
23
+ InterServerEvents,
24
+ SocketData
25
+ >,
26
+ context: {
27
+ entities: {
28
+ {=# allEntities =}
29
+ {= name =}: typeof prisma.{= prismaIdentifier =},
30
+ {=/ allEntities =}
31
+ }
32
+ }
33
+ ) => Promise<void> | void
34
+
35
+ // PUBLIC API
36
+ export interface WaspSocketData {
37
+ {=# isAuthEnabled =}
38
+ user?: AuthUser
39
+ {=/ isAuthEnabled =}
40
+ }
41
+
42
+ // PRIVATE API (framework)
43
+ export type ServerType = Parameters<WebSocketFn>[0]
44
+
45
+ // PRIVATE API (sdk)
46
+ export type ClientToServerEvents = Events[0]
47
+ // PRIVATE API (sdk)
48
+ export type ServerToClientEvents = Events[1]
49
+
50
+ type WebSocketFn = typeof {= userWebSocketFn.importIdentifier =}
51
+ type Events = ServerType extends Server<
52
+ infer ClientToServerEvents,
53
+ infer ServerToClientEvents
54
+ >
55
+ ? [ClientToServerEvents, ServerToClientEvents]
56
+ : [DefaultEventsMap, DefaultEventsMap]
57
+
@@ -0,0 +1,102 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Basic options */
4
+ "target": "esnext",
5
+ "jsx": "preserve",
6
+ "lib": [
7
+ "esnext",
8
+ "dom",
9
+ "DOM.Iterable"
10
+ ],
11
+ "skipLibCheck": true,
12
+ "allowJs": true,
13
+ "rootDir": ".",
14
+ "outDir": "dist",
15
+
16
+ /* Strictness and type checking */
17
+ /*
18
+ User code was compiled using `"strict": true`, so we know we can use it
19
+ here as well. We override some of strict's options because parts of the SDK
20
+ code don't respect them. This only makes the SDK ruleset more permissive than
21
+ the user's ruleset. Therefore, we can sefely include users code inside the
22
+ SDK without casuing errors during the SDK build step.
23
+ Reference: https://github.com/wasp-lang/wasp/issues/1938
24
+ */
25
+ "strict": true,
26
+ "useUnknownInCatchVariables": false,
27
+ "noImplicitAny": false,
28
+ "strictPropertyInitialization": false,
29
+ /*
30
+ The following two properties are disabled because we don't
31
+ yet want to force user code to use them.
32
+ Reference: https://github.com/wasp-lang/wasp/issues/2655
33
+ */
34
+ "noUncheckedIndexedAccess": false,
35
+ "noImplicitOverride": false,
36
+
37
+ /* DX */
38
+ "declaration": true, // Allows users to consume the SDK as a library, enables autocomplete
39
+ "declarationMap": true, // Makes go-to-definition go to source instead of type definitions
40
+ "sourceMap": true, // Needed for debugging
41
+
42
+ /* Modules */
43
+ "module": "esnext",
44
+ "esModuleInterop": true,
45
+ // TODO: Enable this once we enable it for users:
46
+ // https://github.com/wasp-lang/wasp/issues/2654
47
+ "resolveJsonModule": false,
48
+ /*
49
+ The `isolatedModules` flag tells typescript to throw errors on code that
50
+ doesn't work with bundlers:
51
+ - The user code must enable it because Wasp bundles user code when bundling
52
+ server code and web app code (which directly import the user code).
53
+ - The SDK code must disable it because parts of the SDK code rely on
54
+ such features. Since we build the SDK with TSC before bundling it,
55
+ these features don't cause problems.
56
+ More details in https://github.com/wasp-lang/wasp/issues/2150
57
+ */
58
+ "isolatedModules": false,
59
+ // `verbatimModuleSyntax` is disabled because we don't yet want to
60
+ // force user code into using `type` imports.
61
+ "verbatimModuleSyntax": false,
62
+ "moduleDetection": "force", // Assume all files are modules
63
+ /*
64
+ - We want to allow users to use extensionless and directory imports.
65
+ - We want users to import stuff from the SDK with `wasp/something`, and we
66
+ don't want to do extra processing on those imports (for now).
67
+
68
+ These requirements force us to bundle user code and, because we copy user
69
+ code into the SDK code, they force us to bundle the SDK too.
70
+
71
+ We currently bundle the SDK in a very hacky way (indirectly while bundling
72
+ the server and client): https://github.com/wasp-lang/wasp/issues/2150
73
+ Regardless of how we do it, the SDK code is eventually bundled, so this
74
+ `tsconfig.json` file must reflect that (which means `moduleResolution:
75
+ bundler`).
76
+ */
77
+ "moduleResolution": "bundler",
78
+ "types": [
79
+ /*
80
+ This is needed to properly support Vitest testing with jest-dom matchers.
81
+ Types for jest-dom are not recognized automatically and Typescript complains
82
+ about missing types e.g. when using `toBeInTheDocument` and other matchers.
83
+ */
84
+ "@testing-library/jest-dom"
85
+ ],
86
+ /*
87
+ The `incremental` option enables faster SDK compilation, less Vite HMR
88
+ messages and it prevent unnecessary full-page reloads when using Vite HMR.
89
+ While this is great, we still want to dig deeper at some point to understand
90
+ better why Vite HMR misbehaves when the SDK is recompiled:
91
+ https://github.com/wasp-lang/wasp/issues/1934
92
+ */
93
+ "incremental": true,
94
+ },
95
+ "include": [
96
+ "."
97
+ ],
98
+ "exclude": [
99
+ "node_modules",
100
+ "dist"
101
+ ]
102
+ }
@@ -0,0 +1,14 @@
1
+ export const colors = {
2
+ red: '\x1b[31m',
3
+ yellow: '\x1b[33m',
4
+ } as const;
5
+
6
+ export const resetColor = "\x1b[0m";
7
+
8
+ // PRIVATE API (SDK, client)
9
+ // Used with console.log() to colorize the output
10
+ // Example: console.log(getColorizedConsoleFormatString('red'), 'This is red text');
11
+ export function getColorizedConsoleFormatString(colorKey: keyof typeof colors): string {
12
+ const color = colors[colorKey];
13
+ return `${color}%s${resetColor}`;
14
+ }
@@ -0,0 +1,3 @@
1
+ export function isNotNull<T>(value: T | null): value is T {
2
+ return value !== null;
3
+ }
@@ -0,0 +1,74 @@
1
+ // This is a helper type used exclusively for DX purposes. It's a No-op for the
2
+ // compiler, but expands the type's representatoin in IDEs (i.e., inlines all
3
+ // type constructors) to make it more readable for the user.
4
+ //
5
+ // It expands this SO answer to functions: https://stackoverflow.com/a/57683652
6
+ export type Expand<T> = T extends (...args: infer A) => infer R
7
+ ? (...args: A) => R
8
+ : T extends infer O
9
+ ? { [K in keyof O]: O[K] }
10
+ : never
11
+
12
+ // TypeScript's native Awaited type exhibits strange behavior in VS Code (see
13
+ // https://github.com/wasp-lang/wasp/pull/1090#discussion_r1159687537 for
14
+ // details). Until it's fixed, we're using our own type for this.
15
+ //
16
+ // TODO: investigate further. This most likely has something to do with an
17
+ // unsatisfied 'extends' constraints. A mismatch is probably happening with
18
+ // function parameter types and/or return types (check '_ReturnType' below for
19
+ // more).
20
+ export type _Awaited<T> = T extends Promise<infer V>
21
+ ? _Awaited<V>
22
+ : T
23
+
24
+ // TypeScript's native ReturnType does not work for functions of type '(...args:
25
+ // never[]) => unknown' (and that's what operations currently use).
26
+ //
27
+ // TODO: investigate how to properly specify the 'extends' constraint for function
28
+ // type (i.e., any vs never and unknown) and stick with that. Take DX into
29
+ // consideration.
30
+ export type _ReturnType<T extends (...args: never[]) => unknown> =
31
+ T extends (...args: never[]) => infer R ? R : never
32
+
33
+
34
+ // Returns elements of an array except the first one.
35
+ export type Tail<T extends [unknown, ...unknown[]]> = T extends [unknown, ...infer R] ? R : never;
36
+
37
+
38
+ // Source: https://stackoverflow.com/a/55541672
39
+ export type IfAny<Value, Then, Else> = 0 extends (1 & Value) ? Then : Else;
40
+
41
+ // If users use JS to define their operations and destructure object arguments,
42
+ // Wasp's TS helper types can't infer correct types due to this TS bug:
43
+ // https://github.com/microsoft/TypeScript/issues/52768
44
+ // The bug breaks the built-in `Parameters` helper, so we introduce a custom version
45
+ // that works with Wasp's TS helper types like `EntityMapFor`.
46
+ export type _Parameters<T extends (...args: any) => any> = T extends (
47
+ firstParam: infer FirstParam,
48
+ ...rest: infer Rest
49
+ ) => any
50
+ ? [FirstParam, ...Rest]
51
+ : Parameters<T>;
52
+
53
+ /**
54
+ *
55
+ * Exact ensures a type has exactly the properties of another type.
56
+ * Helps with simulating excess property checking for generics in function definitions.
57
+ *
58
+ * Inspired by: https://stackoverflow.com/questions/49580725/is-it-possible-to-restrict-typescript-object-to-contain-only-properties-define
59
+ *
60
+ * @template T - The base type that defines the allowed properties
61
+ * @template U - The type to be constrained (must extend T)
62
+ *
63
+ * @example
64
+ * // User can no longer add properties outside of UserSignupFields to T
65
+ * function defineUserSignupFields<T extends UserSignupFields>(
66
+ * fields: Exact<UserSignupFields, T>
67
+ * ): T {
68
+ * return fields
69
+ * }
70
+ */
71
+ export type Exact<T, U extends T = T> = U & {
72
+ [P in Exclude<keyof U, keyof T>]: never;
73
+ }
74
+