@m5kdev/backend 0.1.0 → 0.1.2

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 (294) hide show
  1. package/.cursor/rules/backend.mdc +70 -0
  2. package/.turbo/turbo-build.log +5 -0
  3. package/.turbo/turbo-check-types.log +5 -0
  4. package/.turbo/turbo-lint$colon$fix.log +255 -0
  5. package/CHANGELOG.md +19 -0
  6. package/dist/src/lib/posthog.d.ts +3 -0
  7. package/dist/src/lib/posthog.d.ts.map +1 -0
  8. package/dist/src/lib/posthog.js +7 -0
  9. package/dist/src/lib/sentry.d.ts +2 -0
  10. package/dist/src/lib/sentry.d.ts.map +1 -0
  11. package/dist/src/lib/sentry.js +9 -0
  12. package/dist/src/modules/access/access.repository.d.ts +2348 -0
  13. package/dist/src/modules/access/access.repository.d.ts.map +1 -0
  14. package/dist/src/modules/access/access.repository.js +32 -0
  15. package/dist/src/modules/access/access.service.d.ts +22 -0
  16. package/dist/src/modules/access/access.service.d.ts.map +1 -0
  17. package/dist/src/modules/access/access.service.js +51 -0
  18. package/dist/src/modules/access/access.test.d.ts +2 -0
  19. package/dist/src/modules/access/access.test.d.ts.map +1 -0
  20. package/dist/src/modules/access/access.test.js +182 -0
  21. package/dist/src/modules/access/access.utils.d.ts +17 -0
  22. package/dist/src/modules/access/access.utils.d.ts.map +1 -0
  23. package/dist/src/modules/access/access.utils.js +20 -0
  24. package/dist/src/modules/ai/ai.db.d.ts +396 -0
  25. package/dist/src/modules/ai/ai.db.d.ts.map +1 -0
  26. package/dist/src/modules/ai/ai.db.js +39 -0
  27. package/dist/src/modules/ai/ai.prompt.d.ts +28 -0
  28. package/dist/src/modules/ai/ai.prompt.d.ts.map +1 -0
  29. package/dist/src/modules/ai/ai.prompt.js +30 -0
  30. package/dist/src/modules/ai/ai.repository.d.ts +424 -0
  31. package/dist/src/modules/ai/ai.repository.d.ts.map +1 -0
  32. package/dist/src/modules/ai/ai.repository.js +26 -0
  33. package/dist/src/modules/ai/ai.router.d.ts +2 -0
  34. package/dist/src/modules/ai/ai.router.d.ts.map +1 -0
  35. package/dist/src/modules/ai/ai.router.js +132 -0
  36. package/dist/src/modules/ai/ai.service.d.ts +115 -0
  37. package/dist/src/modules/ai/ai.service.d.ts.map +1 -0
  38. package/dist/src/modules/ai/ai.service.js +207 -0
  39. package/dist/src/modules/ai/ai.trpc.d.ts +59 -0
  40. package/dist/src/modules/ai/ai.trpc.d.ts.map +1 -0
  41. package/dist/src/modules/ai/ai.trpc.js +20 -0
  42. package/dist/src/modules/ai/ideogram/ideogram.constants.d.ts +8 -0
  43. package/dist/src/modules/ai/ideogram/ideogram.constants.d.ts.map +1 -0
  44. package/dist/src/modules/ai/ideogram/ideogram.constants.js +167 -0
  45. package/dist/src/modules/ai/ideogram/ideogram.dto.d.ts +230 -0
  46. package/dist/src/modules/ai/ideogram/ideogram.dto.d.ts.map +1 -0
  47. package/dist/src/modules/ai/ideogram/ideogram.dto.js +49 -0
  48. package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts +3 -0
  49. package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts.map +1 -0
  50. package/dist/src/modules/ai/ideogram/ideogram.prompt.js +860 -0
  51. package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts +7 -0
  52. package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts.map +1 -0
  53. package/dist/src/modules/ai/ideogram/ideogram.repository.js +46 -0
  54. package/dist/src/modules/ai/ideogram/ideogram.service.d.ts +10 -0
  55. package/dist/src/modules/ai/ideogram/ideogram.service.d.ts.map +1 -0
  56. package/dist/src/modules/ai/ideogram/ideogram.service.js +11 -0
  57. package/dist/src/modules/auth/auth.db.d.ts +2336 -0
  58. package/dist/src/modules/auth/auth.db.d.ts.map +1 -0
  59. package/dist/src/modules/auth/auth.db.js +215 -0
  60. package/dist/src/modules/auth/auth.dto.d.ts +66 -0
  61. package/dist/src/modules/auth/auth.dto.d.ts.map +1 -0
  62. package/dist/src/modules/auth/auth.dto.js +38 -0
  63. package/dist/src/modules/auth/auth.lib.d.ts +4874 -0
  64. package/dist/src/modules/auth/auth.lib.d.ts.map +1 -0
  65. package/dist/src/modules/auth/auth.lib.js +284 -0
  66. package/dist/src/modules/auth/auth.middleware.d.ts +615 -0
  67. package/dist/src/modules/auth/auth.middleware.d.ts.map +1 -0
  68. package/dist/src/modules/auth/auth.middleware.js +52 -0
  69. package/dist/src/modules/auth/auth.repository.d.ts +2417 -0
  70. package/dist/src/modules/auth/auth.repository.d.ts.map +1 -0
  71. package/dist/src/modules/auth/auth.repository.js +541 -0
  72. package/dist/src/modules/auth/auth.service.d.ts +104 -0
  73. package/dist/src/modules/auth/auth.service.d.ts.map +1 -0
  74. package/dist/src/modules/auth/auth.service.js +201 -0
  75. package/dist/src/modules/auth/auth.trpc.d.ts +309 -0
  76. package/dist/src/modules/auth/auth.trpc.d.ts.map +1 -0
  77. package/dist/src/modules/auth/auth.trpc.js +157 -0
  78. package/dist/src/modules/auth/auth.utils.d.ts +2352 -0
  79. package/dist/src/modules/auth/auth.utils.d.ts.map +1 -0
  80. package/dist/src/modules/auth/auth.utils.js +97 -0
  81. package/dist/src/modules/base/base.abstract.d.ts +19 -0
  82. package/dist/src/modules/base/base.abstract.d.ts.map +1 -0
  83. package/dist/src/modules/base/base.abstract.js +53 -0
  84. package/dist/src/modules/base/base.dto.d.ts +70 -0
  85. package/dist/src/modules/base/base.dto.d.ts.map +1 -0
  86. package/dist/src/modules/base/base.dto.js +112 -0
  87. package/dist/src/modules/base/base.grants.d.ts +29 -0
  88. package/dist/src/modules/base/base.grants.d.ts.map +1 -0
  89. package/dist/src/modules/base/base.grants.js +123 -0
  90. package/dist/src/modules/base/base.grants.test.d.ts +2 -0
  91. package/dist/src/modules/base/base.grants.test.d.ts.map +1 -0
  92. package/dist/src/modules/base/base.grants.test.js +668 -0
  93. package/dist/src/modules/base/base.repository.d.ts +97 -0
  94. package/dist/src/modules/base/base.repository.d.ts.map +1 -0
  95. package/dist/src/modules/base/base.repository.js +307 -0
  96. package/dist/src/modules/base/base.service.d.ts +42 -0
  97. package/dist/src/modules/base/base.service.d.ts.map +1 -0
  98. package/dist/src/modules/base/base.service.js +109 -0
  99. package/dist/src/modules/base/base.types.d.ts +2 -0
  100. package/dist/src/modules/base/base.types.d.ts.map +1 -0
  101. package/dist/src/modules/base/base.types.js +2 -0
  102. package/dist/src/modules/billing/billing.db.d.ts +366 -0
  103. package/dist/src/modules/billing/billing.db.d.ts.map +1 -0
  104. package/dist/src/modules/billing/billing.db.js +29 -0
  105. package/dist/src/modules/billing/billing.repository.d.ts +2764 -0
  106. package/dist/src/modules/billing/billing.repository.d.ts.map +1 -0
  107. package/dist/src/modules/billing/billing.repository.js +235 -0
  108. package/dist/src/modules/billing/billing.router.d.ts +5 -0
  109. package/dist/src/modules/billing/billing.router.d.ts.map +1 -0
  110. package/dist/src/modules/billing/billing.router.js +56 -0
  111. package/dist/src/modules/billing/billing.service.d.ts +60 -0
  112. package/dist/src/modules/billing/billing.service.d.ts.map +1 -0
  113. package/dist/src/modules/billing/billing.service.js +147 -0
  114. package/dist/src/modules/billing/billing.trpc.d.ts +75 -0
  115. package/dist/src/modules/billing/billing.trpc.d.ts.map +1 -0
  116. package/dist/src/modules/billing/billing.trpc.js +17 -0
  117. package/dist/src/modules/clay/clay.repository.d.ts +6 -0
  118. package/dist/src/modules/clay/clay.repository.d.ts.map +1 -0
  119. package/dist/src/modules/clay/clay.repository.js +26 -0
  120. package/dist/src/modules/clay/clay.service.d.ts +29 -0
  121. package/dist/src/modules/clay/clay.service.d.ts.map +1 -0
  122. package/dist/src/modules/clay/clay.service.js +24 -0
  123. package/dist/src/modules/connect/connect.db.d.ts +357 -0
  124. package/dist/src/modules/connect/connect.db.d.ts.map +1 -0
  125. package/dist/src/modules/connect/connect.db.js +30 -0
  126. package/dist/src/modules/connect/connect.dto.d.ts +75 -0
  127. package/dist/src/modules/connect/connect.dto.d.ts.map +1 -0
  128. package/dist/src/modules/connect/connect.dto.js +36 -0
  129. package/dist/src/modules/connect/connect.linkedin.d.ts +3 -0
  130. package/dist/src/modules/connect/connect.linkedin.d.ts.map +1 -0
  131. package/dist/src/modules/connect/connect.linkedin.js +53 -0
  132. package/dist/src/modules/connect/connect.oauth.d.ts +28 -0
  133. package/dist/src/modules/connect/connect.oauth.d.ts.map +1 -0
  134. package/dist/src/modules/connect/connect.oauth.js +198 -0
  135. package/dist/src/modules/connect/connect.repository.d.ts +414 -0
  136. package/dist/src/modules/connect/connect.repository.d.ts.map +1 -0
  137. package/dist/src/modules/connect/connect.repository.js +54 -0
  138. package/dist/src/modules/connect/connect.router.d.ts +5 -0
  139. package/dist/src/modules/connect/connect.router.d.ts.map +1 -0
  140. package/dist/src/modules/connect/connect.router.js +54 -0
  141. package/dist/src/modules/connect/connect.service.d.ts +89 -0
  142. package/dist/src/modules/connect/connect.service.d.ts.map +1 -0
  143. package/dist/src/modules/connect/connect.service.js +114 -0
  144. package/dist/src/modules/connect/connect.trpc.d.ts +81 -0
  145. package/dist/src/modules/connect/connect.trpc.d.ts.map +1 -0
  146. package/dist/src/modules/connect/connect.trpc.js +21 -0
  147. package/dist/src/modules/connect/connect.types.d.ts +26 -0
  148. package/dist/src/modules/connect/connect.types.d.ts.map +1 -0
  149. package/dist/src/modules/connect/connect.types.js +2 -0
  150. package/dist/src/modules/crypto/crypto.db.d.ts +152 -0
  151. package/dist/src/modules/crypto/crypto.db.d.ts.map +1 -0
  152. package/dist/src/modules/crypto/crypto.db.js +17 -0
  153. package/dist/src/modules/crypto/crypto.repository.d.ts +160 -0
  154. package/dist/src/modules/crypto/crypto.repository.d.ts.map +1 -0
  155. package/dist/src/modules/crypto/crypto.repository.js +10 -0
  156. package/dist/src/modules/crypto/crypto.service.d.ts +11 -0
  157. package/dist/src/modules/crypto/crypto.service.d.ts.map +1 -0
  158. package/dist/src/modules/crypto/crypto.service.js +52 -0
  159. package/dist/src/modules/email/email.service.d.ts +57 -0
  160. package/dist/src/modules/email/email.service.d.ts.map +1 -0
  161. package/dist/src/modules/email/email.service.js +107 -0
  162. package/dist/src/modules/file/file.repository.d.ts +13 -0
  163. package/dist/src/modules/file/file.repository.d.ts.map +1 -0
  164. package/dist/src/modules/file/file.repository.js +79 -0
  165. package/dist/src/modules/file/file.router.d.ts +4 -0
  166. package/dist/src/modules/file/file.router.d.ts.map +1 -0
  167. package/dist/src/modules/file/file.router.js +99 -0
  168. package/dist/src/modules/file/file.service.d.ts +25 -0
  169. package/dist/src/modules/file/file.service.d.ts.map +1 -0
  170. package/dist/src/modules/file/file.service.js +150 -0
  171. package/dist/src/modules/recurrence/recurrence.db.d.ts +563 -0
  172. package/dist/src/modules/recurrence/recurrence.db.d.ts.map +1 -0
  173. package/dist/src/modules/recurrence/recurrence.db.js +66 -0
  174. package/dist/src/modules/recurrence/recurrence.repository.d.ts +585 -0
  175. package/dist/src/modules/recurrence/recurrence.repository.d.ts.map +1 -0
  176. package/dist/src/modules/recurrence/recurrence.repository.js +39 -0
  177. package/dist/src/modules/recurrence/recurrence.service.d.ts +30 -0
  178. package/dist/src/modules/recurrence/recurrence.service.d.ts.map +1 -0
  179. package/dist/src/modules/recurrence/recurrence.service.js +70 -0
  180. package/dist/src/modules/recurrence/recurrence.trpc.d.ts +243 -0
  181. package/dist/src/modules/recurrence/recurrence.trpc.d.ts.map +1 -0
  182. package/dist/src/modules/recurrence/recurrence.trpc.js +65 -0
  183. package/dist/src/modules/social/social.dto.d.ts +35 -0
  184. package/dist/src/modules/social/social.dto.d.ts.map +1 -0
  185. package/dist/src/modules/social/social.dto.js +18 -0
  186. package/dist/src/modules/social/social.linkedin.d.ts +11 -0
  187. package/dist/src/modules/social/social.linkedin.d.ts.map +1 -0
  188. package/dist/src/modules/social/social.linkedin.js +427 -0
  189. package/dist/src/modules/social/social.linkedin.test.d.ts +2 -0
  190. package/dist/src/modules/social/social.linkedin.test.d.ts.map +1 -0
  191. package/dist/src/modules/social/social.linkedin.test.js +235 -0
  192. package/dist/src/modules/social/social.service.d.ts +29 -0
  193. package/dist/src/modules/social/social.service.d.ts.map +1 -0
  194. package/dist/src/modules/social/social.service.js +76 -0
  195. package/dist/src/modules/social/social.types.d.ts +36 -0
  196. package/dist/src/modules/social/social.types.d.ts.map +1 -0
  197. package/dist/src/modules/social/social.types.js +2 -0
  198. package/dist/src/modules/tag/tag.db.d.ts +347 -0
  199. package/dist/src/modules/tag/tag.db.d.ts.map +1 -0
  200. package/dist/src/modules/tag/tag.db.js +42 -0
  201. package/dist/src/modules/tag/tag.dto.d.ts +1019 -0
  202. package/dist/src/modules/tag/tag.dto.d.ts.map +1 -0
  203. package/dist/src/modules/tag/tag.dto.js +9 -0
  204. package/dist/src/modules/tag/tag.repository.d.ts +384 -0
  205. package/dist/src/modules/tag/tag.repository.d.ts.map +1 -0
  206. package/dist/src/modules/tag/tag.repository.js +154 -0
  207. package/dist/src/modules/tag/tag.service.d.ts +36 -0
  208. package/dist/src/modules/tag/tag.service.d.ts.map +1 -0
  209. package/dist/src/modules/tag/tag.service.js +31 -0
  210. package/dist/src/modules/tag/tag.trpc.d.ts +191 -0
  211. package/dist/src/modules/tag/tag.trpc.d.ts.map +1 -0
  212. package/dist/src/modules/tag/tag.trpc.js +47 -0
  213. package/dist/src/modules/utils/applyPagination.d.ts +7 -0
  214. package/dist/src/modules/utils/applyPagination.d.ts.map +1 -0
  215. package/dist/src/modules/utils/applyPagination.js +16 -0
  216. package/dist/src/modules/utils/applySorting.d.ts +9 -0
  217. package/dist/src/modules/utils/applySorting.d.ts.map +1 -0
  218. package/dist/src/modules/utils/applySorting.js +18 -0
  219. package/dist/src/modules/utils/getConditionsFromFilters.d.ts +5 -0
  220. package/dist/src/modules/utils/getConditionsFromFilters.d.ts.map +1 -0
  221. package/dist/src/modules/utils/getConditionsFromFilters.js +200 -0
  222. package/dist/src/modules/video/video.service.d.ts +8 -0
  223. package/dist/src/modules/video/video.service.d.ts.map +1 -0
  224. package/dist/src/modules/video/video.service.js +84 -0
  225. package/dist/src/modules/webhook/webhook.constants.d.ts +9 -0
  226. package/dist/src/modules/webhook/webhook.constants.d.ts.map +1 -0
  227. package/dist/src/modules/webhook/webhook.constants.js +10 -0
  228. package/dist/src/modules/webhook/webhook.db.d.ts +137 -0
  229. package/dist/src/modules/webhook/webhook.db.d.ts.map +1 -0
  230. package/dist/src/modules/webhook/webhook.db.js +17 -0
  231. package/dist/src/modules/webhook/webhook.dto.d.ts +395 -0
  232. package/dist/src/modules/webhook/webhook.dto.d.ts.map +1 -0
  233. package/dist/src/modules/webhook/webhook.dto.js +7 -0
  234. package/dist/src/modules/webhook/webhook.repository.d.ts +149 -0
  235. package/dist/src/modules/webhook/webhook.repository.d.ts.map +1 -0
  236. package/dist/src/modules/webhook/webhook.repository.js +56 -0
  237. package/dist/src/modules/webhook/webhook.router.d.ts +4 -0
  238. package/dist/src/modules/webhook/webhook.router.d.ts.map +1 -0
  239. package/dist/src/modules/webhook/webhook.router.js +30 -0
  240. package/dist/src/modules/webhook/webhook.service.d.ts +10 -0
  241. package/dist/src/modules/webhook/webhook.service.d.ts.map +1 -0
  242. package/dist/src/modules/webhook/webhook.service.js +68 -0
  243. package/dist/src/modules/workflow/workflow.db.d.ts +297 -0
  244. package/dist/src/modules/workflow/workflow.db.d.ts.map +1 -0
  245. package/dist/src/modules/workflow/workflow.db.js +30 -0
  246. package/dist/src/modules/workflow/workflow.repository.d.ts +344 -0
  247. package/dist/src/modules/workflow/workflow.repository.d.ts.map +1 -0
  248. package/dist/src/modules/workflow/workflow.repository.js +105 -0
  249. package/dist/src/modules/workflow/workflow.service.d.ts +22 -0
  250. package/dist/src/modules/workflow/workflow.service.d.ts.map +1 -0
  251. package/dist/src/modules/workflow/workflow.service.js +37 -0
  252. package/dist/src/modules/workflow/workflow.trpc.d.ts +93 -0
  253. package/dist/src/modules/workflow/workflow.trpc.d.ts.map +1 -0
  254. package/dist/src/modules/workflow/workflow.trpc.js +21 -0
  255. package/dist/src/modules/workflow/workflow.types.d.ts +21 -0
  256. package/dist/src/modules/workflow/workflow.types.d.ts.map +1 -0
  257. package/dist/src/modules/workflow/workflow.types.js +2 -0
  258. package/dist/src/modules/workflow/workflow.utils.d.ts +22 -0
  259. package/dist/src/modules/workflow/workflow.utils.d.ts.map +1 -0
  260. package/dist/src/modules/workflow/workflow.utils.js +173 -0
  261. package/dist/src/test/stubs/utils.d.ts +3 -0
  262. package/dist/src/test/stubs/utils.d.ts.map +1 -0
  263. package/dist/src/test/stubs/utils.js +5 -0
  264. package/dist/src/trpc/context.d.ts +42 -0
  265. package/dist/src/trpc/context.d.ts.map +1 -0
  266. package/dist/src/trpc/context.js +17 -0
  267. package/dist/src/trpc/index.d.ts +4 -0
  268. package/dist/src/trpc/index.d.ts.map +1 -0
  269. package/dist/src/trpc/index.js +6 -0
  270. package/dist/src/trpc/procedures.d.ts +234 -0
  271. package/dist/src/trpc/procedures.d.ts.map +1 -0
  272. package/dist/src/trpc/procedures.js +32 -0
  273. package/dist/src/trpc/utils.d.ts +5 -0
  274. package/dist/src/trpc/utils.d.ts.map +1 -0
  275. package/dist/src/trpc/utils.js +20 -0
  276. package/dist/src/types.d.ts +486 -0
  277. package/dist/src/types.d.ts.map +1 -0
  278. package/dist/src/types.js +13 -0
  279. package/dist/src/utils/errors.d.ts +50 -0
  280. package/dist/src/utils/errors.d.ts.map +1 -0
  281. package/dist/src/utils/errors.js +104 -0
  282. package/dist/src/utils/logger.d.ts +2 -0
  283. package/dist/src/utils/logger.d.ts.map +1 -0
  284. package/dist/src/utils/logger.js +11 -0
  285. package/dist/src/utils/posthog.d.ts +14 -0
  286. package/dist/src/utils/posthog.d.ts.map +1 -0
  287. package/dist/src/utils/posthog.js +31 -0
  288. package/dist/src/utils/types.d.ts +5 -0
  289. package/dist/src/utils/types.d.ts.map +1 -0
  290. package/dist/src/utils/types.js +2 -0
  291. package/dist/tsconfig.tsbuildinfo +1 -0
  292. package/jest.config.ts +19 -0
  293. package/package.json +3 -6
  294. package/tsconfig.json +21 -0
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthService = void 0;
4
+ const neverthrow_1 = require("neverthrow");
5
+ const base_service_1 = require("#modules/base/base.service");
6
+ const posthog_1 = require("#utils/posthog");
7
+ class AuthService extends base_service_1.BaseService {
8
+ getBillingService() {
9
+ if (!("billing" in this.service))
10
+ return null;
11
+ return this.service.billing;
12
+ }
13
+ async getUserWaitlistCount({ user }) {
14
+ if (user.role === "admin")
15
+ return (0, neverthrow_1.ok)(0);
16
+ return this.repository.auth.getUserWaitlistCount(user.id);
17
+ }
18
+ async getOnboarding({ user }) {
19
+ return this.repository.auth.getOnboarding(user.id);
20
+ }
21
+ async setOnboarding(onboarding, { user }) {
22
+ (0, posthog_1.posthogCapture)({
23
+ distinctId: user.id,
24
+ event: "onboarding_set",
25
+ properties: {
26
+ onboarding,
27
+ },
28
+ });
29
+ return this.repository.auth.setOnboarding(user.id, onboarding);
30
+ }
31
+ async getPreferences({ user }) {
32
+ return this.repository.auth.getPreferences(user.id);
33
+ }
34
+ async setPreferences(preferences, { user }) {
35
+ (0, posthog_1.posthogCapture)({
36
+ distinctId: user.id,
37
+ event: "preferences_set",
38
+ });
39
+ return this.repository.auth.setPreferences(user.id, preferences);
40
+ }
41
+ async getMetadata({ user }) {
42
+ return this.repository.auth.getMetadata(user.id);
43
+ }
44
+ async setMetadata(metadata, { user }) {
45
+ (0, posthog_1.posthogCapture)({
46
+ distinctId: user.id,
47
+ event: "metadata_set",
48
+ });
49
+ return this.repository.auth.setMetadata(user.id, metadata);
50
+ }
51
+ async getFlags({ user }) {
52
+ return this.repository.auth.getFlags(user.id);
53
+ }
54
+ async setFlags(flags, { user }) {
55
+ (0, posthog_1.posthogCapture)({
56
+ distinctId: user.id,
57
+ event: "flags_set",
58
+ });
59
+ return this.repository.auth.setFlags(user.id, flags);
60
+ }
61
+ async listAdminWaitlist() {
62
+ return this.repository.auth.listAdminWaitlist();
63
+ }
64
+ async listWaitlist({ user }) {
65
+ return this.repository.auth.listWaitlist(user.id);
66
+ }
67
+ async addToWaitlist({ email }) {
68
+ return this.repository.auth.addToWaitlist(email);
69
+ }
70
+ async inviteFromWaitlist({ id }) {
71
+ const waitlist = await this.repository.auth.inviteFromWaitlist(id);
72
+ if (waitlist.isErr())
73
+ return (0, neverthrow_1.err)(waitlist.error);
74
+ if (!waitlist.value.code)
75
+ return this.repository.auth.error("BAD_REQUEST");
76
+ if (!waitlist.value.email)
77
+ return this.repository.auth.error("BAD_REQUEST");
78
+ await this.service.email.sendWaitlistInvite(waitlist.value.email, waitlist.value.code);
79
+ return (0, neverthrow_1.ok)(waitlist.value);
80
+ }
81
+ async inviteToWaitlist({ email, name }, { user }) {
82
+ const count = await this.repository.auth.getUserWaitlistCount(user.id);
83
+ if (count.isErr())
84
+ return (0, neverthrow_1.err)(count.error);
85
+ if (count.value >= 3)
86
+ return this.repository.auth.error("BAD_REQUEST", "Run out of invites");
87
+ const waitlist = await this.repository.auth.inviteToWaitlist({ email, userId: user.id, name });
88
+ if (waitlist.isErr())
89
+ return (0, neverthrow_1.err)(waitlist.error);
90
+ if (!waitlist.value.code)
91
+ return this.repository.auth.error("BAD_REQUEST");
92
+ await this.service.email.sendWaitlistUserInvite(email, waitlist.value.code, user.name, name);
93
+ (0, posthog_1.posthogCapture)({
94
+ distinctId: user.id,
95
+ event: "waitlist_invite_sent",
96
+ properties: {
97
+ email,
98
+ name,
99
+ },
100
+ });
101
+ return (0, neverthrow_1.ok)(waitlist.value);
102
+ }
103
+ async createInvitationCode({ name }, { user }) {
104
+ (0, posthog_1.posthogCapture)({
105
+ distinctId: user.id,
106
+ event: "waitlist_invitation_code_created",
107
+ properties: {
108
+ name,
109
+ },
110
+ });
111
+ return this.repository.auth.createInvitationCode({ userId: user.id, name });
112
+ }
113
+ async joinWaitlist({ email }) {
114
+ const waitlist = await this.repository.auth.joinWaitlist(email);
115
+ if (waitlist.isErr())
116
+ return (0, neverthrow_1.err)(waitlist.error);
117
+ await this.service.email.sendWaitlistConfirmation(email);
118
+ return (0, neverthrow_1.ok)(waitlist.value);
119
+ }
120
+ async removeFromWaitlist({ id }) {
121
+ return this.repository.auth.removeFromWaitlist(id);
122
+ }
123
+ async validateWaitlistCode(code) {
124
+ return this.repository.auth.validateWaitlistCode(code);
125
+ }
126
+ async createAccountClaimCode({ userId, expiresInHours, }) {
127
+ return this.repository.auth.createAccountClaimCode({ userId, expiresInHours });
128
+ }
129
+ async listAccountClaims() {
130
+ return this.repository.auth.listAccountClaims();
131
+ }
132
+ async getMyAccountClaimStatus({ user }) {
133
+ return this.repository.auth.findPendingAccountClaimForUser(user.id);
134
+ }
135
+ async setMyAccountClaimEmail({ email }, { user }) {
136
+ return this.repository.auth.setAccountClaimEmail({ userId: user.id, email });
137
+ }
138
+ async acceptMyAccountClaim({ user }) {
139
+ const pendingClaim = await this.repository.auth.findPendingAccountClaimForUser(user.id);
140
+ if (pendingClaim.isErr())
141
+ return (0, neverthrow_1.err)(pendingClaim.error);
142
+ const accepted = await this.repository.auth.acceptAccountClaim(user.id);
143
+ if (accepted.isErr())
144
+ return (0, neverthrow_1.err)(accepted.error);
145
+ if (pendingClaim.value) {
146
+ const billingService = this.getBillingService();
147
+ if (billingService) {
148
+ await billingService.createUserHook({ user });
149
+ }
150
+ }
151
+ return (0, neverthrow_1.ok)(accepted.value);
152
+ }
153
+ async generateAccountClaimMagicLink({ claimId, email, }) {
154
+ const claim = await this.repository.auth.findAccountClaimById(claimId);
155
+ if (claim.isErr())
156
+ return (0, neverthrow_1.err)(claim.error);
157
+ if (!claim.value)
158
+ return this.repository.auth.error("NOT_FOUND", "Claim not found");
159
+ if (!claim.value.claimUserId)
160
+ return this.repository.auth.error("BAD_REQUEST", "Claim has no user");
161
+ if (claim.value.status !== "INVITED") {
162
+ return this.repository.auth.error("BAD_REQUEST", "Claim is not pending");
163
+ }
164
+ if (claim.value.expiresAt && claim.value.expiresAt < new Date()) {
165
+ return this.repository.auth.error("BAD_REQUEST", "Claim is expired");
166
+ }
167
+ const targetEmail = email ?? claim.value.claimedEmail ?? undefined;
168
+ if (!targetEmail) {
169
+ return this.repository.auth.error("BAD_REQUEST", "Email required to generate magic link");
170
+ }
171
+ const setEmail = await this.repository.auth.setAccountClaimEmail({
172
+ userId: claim.value.claimUserId,
173
+ email: targetEmail,
174
+ });
175
+ if (setEmail.isErr())
176
+ return (0, neverthrow_1.err)(setEmail.error);
177
+ const response = await fetch(`${process.env.VITE_SERVER_URL}/api/auth/sign-in/magic-link`, {
178
+ method: "POST",
179
+ headers: {
180
+ "content-type": "application/json",
181
+ },
182
+ body: JSON.stringify({
183
+ email: targetEmail.toLowerCase(),
184
+ callbackURL: `${process.env.VITE_APP_URL}/claim-account?claim=${claimId}`,
185
+ }),
186
+ });
187
+ if (!response.ok) {
188
+ return this.repository.auth.error("INTERNAL_SERVER_ERROR", "Failed to generate magic link");
189
+ }
190
+ const latest = await this.repository.auth.latestAccountClaimMagicLink(claimId);
191
+ if (latest.isErr())
192
+ return (0, neverthrow_1.err)(latest.error);
193
+ if (!latest.value)
194
+ return this.repository.auth.error("INTERNAL_SERVER_ERROR");
195
+ return (0, neverthrow_1.ok)(latest.value);
196
+ }
197
+ async listAccountClaimMagicLinks({ claimId, }) {
198
+ return this.repository.auth.listAccountClaimMagicLinks(claimId);
199
+ }
200
+ }
201
+ exports.AuthService = AuthService;
@@ -0,0 +1,309 @@
1
+ import type { AuthService } from "#modules/auth/auth.service";
2
+ export declare function createAuthTRPC(authService: AuthService): import("@trpc/server").TRPCBuiltRouter<{
3
+ ctx: {
4
+ session: {
5
+ id: string;
6
+ userId: string;
7
+ updatedAt: Date;
8
+ createdAt: Date;
9
+ expiresAt: Date;
10
+ token: string;
11
+ ipAddress: string | null;
12
+ userAgent: string | null;
13
+ impersonatedBy: string | null;
14
+ activeOrganizationId: string | null;
15
+ activeOrganizationRole: string | null;
16
+ activeTeamId: string | null;
17
+ activeTeamRole: string | null;
18
+ };
19
+ user: {
20
+ name: string;
21
+ id: string;
22
+ updatedAt: Date;
23
+ email: string;
24
+ emailVerified: boolean;
25
+ image: string | null;
26
+ createdAt: Date;
27
+ role: string | null;
28
+ banned: boolean | null;
29
+ banReason: string | null;
30
+ banExpires: Date | null;
31
+ stripeCustomerId: string | null;
32
+ paymentCustomerId: string | null;
33
+ paymentPlanTier: string | null;
34
+ paymentPlanExpiresAt: Date | null;
35
+ preferences: string | null;
36
+ metadata: Record<string, unknown>;
37
+ onboarding: number | null;
38
+ flags: string | null;
39
+ };
40
+ };
41
+ meta: import("trpc-to-openapi").OpenApiMeta;
42
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape;
43
+ transformer: true;
44
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
45
+ getUserWaitlistCount: import("@trpc/server").TRPCQueryProcedure<{
46
+ input: void;
47
+ output: number;
48
+ meta: import("trpc-to-openapi").OpenApiMeta;
49
+ }>;
50
+ createInvitationCode: import("@trpc/server").TRPCMutationProcedure<{
51
+ input: {
52
+ name?: string | undefined;
53
+ };
54
+ output: {
55
+ id: string;
56
+ name: string | null;
57
+ email: string | null;
58
+ createdAt: Date;
59
+ updatedAt: Date | null;
60
+ status: string;
61
+ code: string | null;
62
+ expiresAt: Date | null;
63
+ };
64
+ meta: import("trpc-to-openapi").OpenApiMeta;
65
+ }>;
66
+ createAccountClaimCode: import("@trpc/server").TRPCMutationProcedure<{
67
+ input: {
68
+ userId: string;
69
+ expiresInHours?: number | undefined;
70
+ };
71
+ output: {
72
+ id: string;
73
+ claimUserId: string | null;
74
+ code: string | null;
75
+ status: string;
76
+ expiresAt: Date | null;
77
+ claimedAt: Date | null;
78
+ claimedEmail: string | null;
79
+ createdAt: Date;
80
+ updatedAt: Date | null;
81
+ };
82
+ meta: import("trpc-to-openapi").OpenApiMeta;
83
+ }>;
84
+ listAccountClaims: import("@trpc/server").TRPCQueryProcedure<{
85
+ input: void;
86
+ output: {
87
+ id: string;
88
+ updatedAt: Date | null;
89
+ createdAt: Date;
90
+ expiresAt: Date | null;
91
+ status: string;
92
+ claimUserId: string | null;
93
+ claimedAt: Date | null;
94
+ claimedEmail: string | null;
95
+ }[];
96
+ meta: import("trpc-to-openapi").OpenApiMeta;
97
+ }>;
98
+ generateAccountClaimMagicLink: import("@trpc/server").TRPCMutationProcedure<{
99
+ input: {
100
+ claimId: string;
101
+ email?: string | undefined;
102
+ };
103
+ output: {
104
+ id: string;
105
+ userId: string;
106
+ email: string;
107
+ createdAt: Date;
108
+ expiresAt: Date | null;
109
+ claimId: string;
110
+ url: string;
111
+ };
112
+ meta: import("trpc-to-openapi").OpenApiMeta;
113
+ }>;
114
+ listAccountClaimMagicLinks: import("@trpc/server").TRPCQueryProcedure<{
115
+ input: {
116
+ claimId: string;
117
+ };
118
+ output: {
119
+ id: string;
120
+ userId: string;
121
+ email: string;
122
+ createdAt: Date;
123
+ expiresAt: Date | null;
124
+ claimId: string;
125
+ url: string;
126
+ }[];
127
+ meta: import("trpc-to-openapi").OpenApiMeta;
128
+ }>;
129
+ getMyAccountClaimStatus: import("@trpc/server").TRPCQueryProcedure<{
130
+ input: void;
131
+ output: {
132
+ id: string;
133
+ claimUserId: string | null;
134
+ code: string | null;
135
+ status: string;
136
+ expiresAt: Date | null;
137
+ claimedAt: Date | null;
138
+ claimedEmail: string | null;
139
+ createdAt: Date;
140
+ updatedAt: Date | null;
141
+ } | null;
142
+ meta: import("trpc-to-openapi").OpenApiMeta;
143
+ }>;
144
+ setMyAccountClaimEmail: import("@trpc/server").TRPCMutationProcedure<{
145
+ input: {
146
+ email: string;
147
+ };
148
+ output: {
149
+ status: boolean;
150
+ };
151
+ meta: import("trpc-to-openapi").OpenApiMeta;
152
+ }>;
153
+ acceptMyAccountClaim: import("@trpc/server").TRPCMutationProcedure<{
154
+ input: void;
155
+ output: {
156
+ status: boolean;
157
+ };
158
+ meta: import("trpc-to-openapi").OpenApiMeta;
159
+ }>;
160
+ listWaitlist: import("@trpc/server").TRPCQueryProcedure<{
161
+ input: void;
162
+ output: {
163
+ id: string;
164
+ name: string | null;
165
+ email: string | null;
166
+ createdAt: Date;
167
+ updatedAt: Date | null;
168
+ status: string;
169
+ code: string | null;
170
+ expiresAt: Date | null;
171
+ }[];
172
+ meta: import("trpc-to-openapi").OpenApiMeta;
173
+ }>;
174
+ listAdminWaitlist: import("@trpc/server").TRPCQueryProcedure<{
175
+ input: void;
176
+ output: {
177
+ name: string | null;
178
+ id: string;
179
+ updatedAt: Date | null;
180
+ email: string | null;
181
+ createdAt: Date;
182
+ status: string;
183
+ }[];
184
+ meta: import("trpc-to-openapi").OpenApiMeta;
185
+ }>;
186
+ addToWaitlist: import("@trpc/server").TRPCMutationProcedure<{
187
+ input: {
188
+ email: string;
189
+ };
190
+ output: {
191
+ name: string | null;
192
+ id: string;
193
+ updatedAt: Date | null;
194
+ email: string | null;
195
+ createdAt: Date;
196
+ status: string;
197
+ };
198
+ meta: import("trpc-to-openapi").OpenApiMeta;
199
+ }>;
200
+ inviteToWaitlist: import("@trpc/server").TRPCMutationProcedure<{
201
+ input: {
202
+ email: string;
203
+ name?: string | undefined;
204
+ };
205
+ output: {
206
+ id: string;
207
+ name: string | null;
208
+ email: string | null;
209
+ createdAt: Date;
210
+ updatedAt: Date | null;
211
+ status: string;
212
+ code: string | null;
213
+ expiresAt: Date | null;
214
+ };
215
+ meta: import("trpc-to-openapi").OpenApiMeta;
216
+ }>;
217
+ inviteFromWaitlist: import("@trpc/server").TRPCMutationProcedure<{
218
+ input: {
219
+ id: string;
220
+ };
221
+ output: {
222
+ name: string | null;
223
+ id: string;
224
+ updatedAt: Date | null;
225
+ email: string | null;
226
+ createdAt: Date;
227
+ status: string;
228
+ };
229
+ meta: import("trpc-to-openapi").OpenApiMeta;
230
+ }>;
231
+ removeFromWaitlist: import("@trpc/server").TRPCMutationProcedure<{
232
+ input: {
233
+ id: string;
234
+ };
235
+ output: {
236
+ name: string | null;
237
+ id: string;
238
+ updatedAt: Date | null;
239
+ email: string | null;
240
+ createdAt: Date;
241
+ status: string;
242
+ };
243
+ meta: import("trpc-to-openapi").OpenApiMeta;
244
+ }>;
245
+ joinWaitlist: import("@trpc/server").TRPCMutationProcedure<{
246
+ input: {
247
+ email: string;
248
+ };
249
+ output: {
250
+ name: string | null;
251
+ id: string;
252
+ updatedAt: Date | null;
253
+ email: string | null;
254
+ createdAt: Date;
255
+ status: string;
256
+ };
257
+ meta: import("trpc-to-openapi").OpenApiMeta;
258
+ }>;
259
+ getOnboarding: import("@trpc/server").TRPCQueryProcedure<{
260
+ input: void;
261
+ output: number;
262
+ meta: import("trpc-to-openapi").OpenApiMeta;
263
+ }>;
264
+ setOnboarding: import("@trpc/server").TRPCMutationProcedure<{
265
+ input: number;
266
+ output: number;
267
+ meta: import("trpc-to-openapi").OpenApiMeta;
268
+ }>;
269
+ getPreferences: import("@trpc/server").TRPCQueryProcedure<{
270
+ input: void;
271
+ output: Record<string, unknown>;
272
+ meta: import("trpc-to-openapi").OpenApiMeta;
273
+ }>;
274
+ setPreferences: import("@trpc/server").TRPCMutationProcedure<{
275
+ input: Record<string, unknown>;
276
+ output: Record<string, unknown>;
277
+ meta: import("trpc-to-openapi").OpenApiMeta;
278
+ }>;
279
+ getMetadata: import("@trpc/server").TRPCQueryProcedure<{
280
+ input: void;
281
+ output: Record<string, unknown>;
282
+ meta: import("trpc-to-openapi").OpenApiMeta;
283
+ }>;
284
+ setMetadata: import("@trpc/server").TRPCMutationProcedure<{
285
+ input: Record<string, unknown>;
286
+ output: Record<string, unknown>;
287
+ meta: import("trpc-to-openapi").OpenApiMeta;
288
+ }>;
289
+ getFlags: import("@trpc/server").TRPCQueryProcedure<{
290
+ input: void;
291
+ output: string[];
292
+ meta: import("trpc-to-openapi").OpenApiMeta;
293
+ }>;
294
+ setFlags: import("@trpc/server").TRPCMutationProcedure<{
295
+ input: string[];
296
+ output: string[];
297
+ meta: import("trpc-to-openapi").OpenApiMeta;
298
+ }>;
299
+ validateWaitlistCode: import("@trpc/server").TRPCQueryProcedure<{
300
+ input: {
301
+ code: string;
302
+ };
303
+ output: {
304
+ status: string;
305
+ };
306
+ meta: import("trpc-to-openapi").OpenApiMeta;
307
+ }>;
308
+ }>>;
309
+ //# sourceMappingURL=auth.trpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.trpc.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/auth.trpc.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoMtD"}
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAuthTRPC = createAuthTRPC;
4
+ const zod_1 = require("zod");
5
+ const auth_dto_1 = require("#modules/auth/auth.dto");
6
+ const _trpc_1 = require("#trpc");
7
+ function createAuthTRPC(authService) {
8
+ return (0, _trpc_1.router)({
9
+ getUserWaitlistCount: _trpc_1.procedure.output(zod_1.z.number()).query(async ({ ctx }) => {
10
+ return (0, _trpc_1.handleTRPCResult)(await authService.getUserWaitlistCount(ctx));
11
+ }),
12
+ createInvitationCode: _trpc_1.procedure
13
+ .input(zod_1.z.object({ name: zod_1.z.string().optional() }))
14
+ .output(auth_dto_1.waitlistSchema)
15
+ .mutation(async ({ input, ctx }) => {
16
+ return (0, _trpc_1.handleTRPCResult)(await authService.createInvitationCode(input, ctx));
17
+ }),
18
+ createAccountClaimCode: _trpc_1.adminProcedure
19
+ .input(zod_1.z.object({
20
+ userId: zod_1.z.string(),
21
+ expiresInHours: zod_1.z.number().optional(),
22
+ }))
23
+ .output(auth_dto_1.accountClaimSchema)
24
+ .mutation(async ({ input }) => {
25
+ return (0, _trpc_1.handleTRPCResult)(await authService.createAccountClaimCode(input));
26
+ }),
27
+ listAccountClaims: _trpc_1.adminProcedure.output(zod_1.z.array(auth_dto_1.accountClaimOutputSchema)).query(async () => {
28
+ return (0, _trpc_1.handleTRPCResult)(await authService.listAccountClaims());
29
+ }),
30
+ generateAccountClaimMagicLink: _trpc_1.adminProcedure
31
+ .input(zod_1.z.object({
32
+ claimId: zod_1.z.string(),
33
+ email: zod_1.z.string().email().optional(),
34
+ }))
35
+ .output(auth_dto_1.accountClaimMagicLinkOutputSchema)
36
+ .mutation(async ({ input }) => {
37
+ return (0, _trpc_1.handleTRPCResult)(await authService.generateAccountClaimMagicLink(input));
38
+ }),
39
+ listAccountClaimMagicLinks: _trpc_1.adminProcedure
40
+ .input(zod_1.z.object({
41
+ claimId: zod_1.z.string(),
42
+ }))
43
+ .output(zod_1.z.array(auth_dto_1.accountClaimMagicLinkOutputSchema))
44
+ .query(async ({ input }) => {
45
+ return (0, _trpc_1.handleTRPCResult)(await authService.listAccountClaimMagicLinks(input));
46
+ }),
47
+ getMyAccountClaimStatus: _trpc_1.procedure.output(auth_dto_1.accountClaimSchema.nullable()).query(async ({ ctx }) => {
48
+ return (0, _trpc_1.handleTRPCResult)(await authService.getMyAccountClaimStatus(ctx));
49
+ }),
50
+ setMyAccountClaimEmail: _trpc_1.procedure
51
+ .input(zod_1.z.object({
52
+ email: zod_1.z.string().email(),
53
+ }))
54
+ .output(zod_1.z.object({ status: zod_1.z.boolean() }))
55
+ .mutation(async ({ input, ctx }) => {
56
+ return (0, _trpc_1.handleTRPCResult)(await authService.setMyAccountClaimEmail(input, ctx));
57
+ }),
58
+ acceptMyAccountClaim: _trpc_1.procedure
59
+ .output(zod_1.z.object({ status: zod_1.z.boolean() }))
60
+ .mutation(async ({ ctx }) => {
61
+ return (0, _trpc_1.handleTRPCResult)(await authService.acceptMyAccountClaim(ctx));
62
+ }),
63
+ listWaitlist: _trpc_1.procedure.output(zod_1.z.array(auth_dto_1.waitlistSchema)).query(async ({ ctx }) => {
64
+ return (0, _trpc_1.handleTRPCResult)(await authService.listWaitlist(ctx));
65
+ }),
66
+ listAdminWaitlist: _trpc_1.adminProcedure.output(zod_1.z.array(auth_dto_1.waitlistOutputSchema)).query(async () => {
67
+ return (0, _trpc_1.handleTRPCResult)(await authService.listAdminWaitlist());
68
+ }),
69
+ addToWaitlist: _trpc_1.adminProcedure
70
+ .input(zod_1.z.object({
71
+ email: zod_1.z.string(),
72
+ }))
73
+ .output(auth_dto_1.waitlistOutputSchema)
74
+ .mutation(async ({ input }) => {
75
+ return (0, _trpc_1.handleTRPCResult)(await authService.addToWaitlist(input));
76
+ }),
77
+ inviteToWaitlist: _trpc_1.procedure
78
+ .input(zod_1.z.object({
79
+ email: zod_1.z.string(),
80
+ name: zod_1.z.string().optional(),
81
+ }))
82
+ .output(auth_dto_1.waitlistSchema)
83
+ .mutation(async ({ input, ctx }) => {
84
+ return (0, _trpc_1.handleTRPCResult)(await authService.inviteToWaitlist(input, ctx));
85
+ }),
86
+ inviteFromWaitlist: _trpc_1.adminProcedure
87
+ .input(zod_1.z.object({
88
+ id: zod_1.z.string(),
89
+ }))
90
+ .output(auth_dto_1.waitlistOutputSchema)
91
+ .mutation(async ({ input }) => {
92
+ return (0, _trpc_1.handleTRPCResult)(await authService.inviteFromWaitlist(input));
93
+ }),
94
+ removeFromWaitlist: _trpc_1.adminProcedure
95
+ .input(zod_1.z.object({
96
+ id: zod_1.z.string(),
97
+ }))
98
+ .output(auth_dto_1.waitlistOutputSchema)
99
+ .mutation(async ({ input }) => {
100
+ return (0, _trpc_1.handleTRPCResult)(await authService.removeFromWaitlist(input));
101
+ }),
102
+ joinWaitlist: _trpc_1.publicProcedure
103
+ .input(zod_1.z.object({
104
+ email: zod_1.z.string(),
105
+ }))
106
+ .output(auth_dto_1.waitlistOutputSchema)
107
+ .mutation(async ({ input }) => {
108
+ return (0, _trpc_1.handleTRPCResult)(await authService.joinWaitlist(input));
109
+ }),
110
+ getOnboarding: _trpc_1.procedure.output(zod_1.z.number()).query(async ({ ctx }) => {
111
+ return (0, _trpc_1.handleTRPCResult)(await authService.getOnboarding(ctx));
112
+ }),
113
+ setOnboarding: _trpc_1.procedure
114
+ .input(zod_1.z.number())
115
+ .output(zod_1.z.number())
116
+ .mutation(async ({ ctx, input }) => {
117
+ return (0, _trpc_1.handleTRPCResult)(await authService.setOnboarding(input, ctx));
118
+ }),
119
+ getPreferences: _trpc_1.procedure.output(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).query(async ({ ctx }) => {
120
+ return (0, _trpc_1.handleTRPCResult)(await authService.getPreferences(ctx));
121
+ }),
122
+ setPreferences: _trpc_1.procedure
123
+ .input(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()))
124
+ .output(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()))
125
+ .mutation(async ({ ctx, input }) => {
126
+ return (0, _trpc_1.handleTRPCResult)(await authService.setPreferences(input, ctx));
127
+ }),
128
+ getMetadata: _trpc_1.procedure.output(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).query(async ({ ctx }) => {
129
+ return (0, _trpc_1.handleTRPCResult)(await authService.getMetadata(ctx));
130
+ }),
131
+ setMetadata: _trpc_1.procedure
132
+ .input(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()))
133
+ .output(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()))
134
+ .mutation(async ({ ctx, input }) => {
135
+ return (0, _trpc_1.handleTRPCResult)(await authService.setMetadata(input, ctx));
136
+ }),
137
+ getFlags: _trpc_1.procedure.output(zod_1.z.array(zod_1.z.string())).query(async ({ ctx }) => {
138
+ return (0, _trpc_1.handleTRPCResult)(await authService.getFlags(ctx));
139
+ }),
140
+ setFlags: _trpc_1.procedure
141
+ .input(zod_1.z.array(zod_1.z.string()))
142
+ .output(zod_1.z.array(zod_1.z.string()))
143
+ .mutation(async ({ ctx, input }) => {
144
+ return (0, _trpc_1.handleTRPCResult)(await authService.setFlags(input, ctx));
145
+ }),
146
+ validateWaitlistCode: _trpc_1.publicProcedure
147
+ .input(zod_1.z.object({
148
+ code: zod_1.z.string(),
149
+ }))
150
+ .output(zod_1.z.object({
151
+ status: zod_1.z.string(),
152
+ }))
153
+ .query(async ({ input }) => {
154
+ return (0, _trpc_1.handleTRPCResult)(await authService.validateWaitlistCode(input.code));
155
+ }),
156
+ });
157
+ }