@m5kdev/backend 0.1.3 → 0.1.5

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 (309) hide show
  1. package/dist/src/lib/posthog.d.ts +0 -1
  2. package/dist/src/lib/sentry.d.ts +0 -1
  3. package/dist/src/modules/access/access.repository.d.ts +0 -1
  4. package/dist/src/modules/access/access.service.d.ts +0 -1
  5. package/dist/src/modules/access/access.test.d.ts +0 -1
  6. package/dist/src/modules/access/access.utils.d.ts +0 -1
  7. package/dist/src/modules/ai/ai.db.d.ts +0 -1
  8. package/dist/src/modules/ai/ai.prompt.d.ts +0 -1
  9. package/dist/src/modules/ai/ai.repository.d.ts +0 -1
  10. package/dist/src/modules/ai/ai.router.d.ts +0 -1
  11. package/dist/src/modules/ai/ai.service.d.ts +0 -1
  12. package/dist/src/modules/ai/ai.trpc.d.ts +4 -5
  13. package/dist/src/modules/ai/ideogram/ideogram.constants.d.ts +0 -1
  14. package/dist/src/modules/ai/ideogram/ideogram.dto.d.ts +0 -1
  15. package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts +0 -1
  16. package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts +0 -1
  17. package/dist/src/modules/ai/ideogram/ideogram.service.d.ts +0 -1
  18. package/dist/src/modules/auth/auth.db.d.ts +0 -1
  19. package/dist/src/modules/auth/auth.dto.d.ts +7 -8
  20. package/dist/src/modules/auth/auth.lib.d.ts +8 -9
  21. package/dist/src/modules/auth/auth.middleware.d.ts +0 -1
  22. package/dist/src/modules/auth/auth.repository.d.ts +0 -1
  23. package/dist/src/modules/auth/auth.service.d.ts +0 -1
  24. package/dist/src/modules/auth/auth.trpc.d.ts +17 -18
  25. package/dist/src/modules/auth/auth.utils.d.ts +0 -1
  26. package/dist/src/modules/base/base.abstract.d.ts +0 -1
  27. package/dist/src/modules/base/base.dto.d.ts +2 -3
  28. package/dist/src/modules/base/base.grants.d.ts +0 -1
  29. package/dist/src/modules/base/base.grants.test.d.ts +0 -1
  30. package/dist/src/modules/base/base.repository.d.ts +0 -1
  31. package/dist/src/modules/base/base.service.d.ts +0 -1
  32. package/dist/src/modules/base/base.types.d.ts +0 -1
  33. package/dist/src/modules/billing/billing.db.d.ts +0 -1
  34. package/dist/src/modules/billing/billing.repository.d.ts +0 -1
  35. package/dist/src/modules/billing/billing.router.d.ts +0 -1
  36. package/dist/src/modules/billing/billing.service.d.ts +0 -1
  37. package/dist/src/modules/billing/billing.trpc.d.ts +4 -5
  38. package/dist/src/modules/clay/clay.repository.d.ts +0 -1
  39. package/dist/src/modules/clay/clay.service.d.ts +0 -1
  40. package/dist/src/modules/connect/connect.db.d.ts +0 -1
  41. package/dist/src/modules/connect/connect.dto.d.ts +8 -9
  42. package/dist/src/modules/connect/connect.linkedin.d.ts +0 -1
  43. package/dist/src/modules/connect/connect.oauth.d.ts +0 -1
  44. package/dist/src/modules/connect/connect.repository.d.ts +3 -4
  45. package/dist/src/modules/connect/connect.router.d.ts +0 -1
  46. package/dist/src/modules/connect/connect.service.d.ts +6 -7
  47. package/dist/src/modules/connect/connect.trpc.d.ts +6 -7
  48. package/dist/src/modules/connect/connect.types.d.ts +0 -1
  49. package/dist/src/modules/crypto/crypto.db.d.ts +0 -1
  50. package/dist/src/modules/crypto/crypto.repository.d.ts +0 -1
  51. package/dist/src/modules/crypto/crypto.service.d.ts +0 -1
  52. package/dist/src/modules/email/email.service.d.ts +0 -1
  53. package/dist/src/modules/file/file.repository.d.ts +0 -1
  54. package/dist/src/modules/file/file.router.d.ts +0 -1
  55. package/dist/src/modules/file/file.service.d.ts +0 -1
  56. package/dist/src/modules/recurrence/recurrence.db.d.ts +0 -1
  57. package/dist/src/modules/recurrence/recurrence.repository.d.ts +0 -1
  58. package/dist/src/modules/recurrence/recurrence.service.d.ts +0 -1
  59. package/dist/src/modules/recurrence/recurrence.trpc.d.ts +5 -6
  60. package/dist/src/modules/social/social.dto.d.ts +0 -1
  61. package/dist/src/modules/social/social.linkedin.d.ts +0 -1
  62. package/dist/src/modules/social/social.linkedin.test.d.ts +0 -1
  63. package/dist/src/modules/social/social.service.d.ts +0 -1
  64. package/dist/src/modules/social/social.types.d.ts +0 -1
  65. package/dist/src/modules/tag/tag.db.d.ts +0 -1
  66. package/dist/src/modules/tag/tag.dto.d.ts +0 -1
  67. package/dist/src/modules/tag/tag.repository.d.ts +0 -1
  68. package/dist/src/modules/tag/tag.service.d.ts +0 -1
  69. package/dist/src/modules/tag/tag.trpc.d.ts +6 -7
  70. package/dist/src/modules/utils/applyPagination.d.ts +0 -1
  71. package/dist/src/modules/utils/applySorting.d.ts +0 -1
  72. package/dist/src/modules/utils/getConditionsFromFilters.d.ts +0 -1
  73. package/dist/src/modules/video/video.service.d.ts +0 -1
  74. package/dist/src/modules/webhook/webhook.constants.d.ts +0 -1
  75. package/dist/src/modules/webhook/webhook.db.d.ts +0 -1
  76. package/dist/src/modules/webhook/webhook.dto.d.ts +0 -1
  77. package/dist/src/modules/webhook/webhook.repository.d.ts +0 -1
  78. package/dist/src/modules/webhook/webhook.router.d.ts +0 -1
  79. package/dist/src/modules/webhook/webhook.service.d.ts +0 -1
  80. package/dist/src/modules/workflow/workflow.db.d.ts +0 -1
  81. package/dist/src/modules/workflow/workflow.repository.d.ts +0 -1
  82. package/dist/src/modules/workflow/workflow.service.d.ts +0 -1
  83. package/dist/src/modules/workflow/workflow.trpc.d.ts +4 -5
  84. package/dist/src/modules/workflow/workflow.types.d.ts +0 -1
  85. package/dist/src/modules/workflow/workflow.utils.d.ts +0 -1
  86. package/dist/src/test/stubs/utils.d.ts +0 -1
  87. package/dist/src/trpc/context.d.ts +4 -5
  88. package/dist/src/trpc/index.d.ts +0 -1
  89. package/dist/src/trpc/procedures.d.ts +24 -25
  90. package/dist/src/trpc/utils.d.ts +0 -1
  91. package/dist/src/types.d.ts +29 -30
  92. package/dist/src/utils/errors.d.ts +0 -1
  93. package/dist/src/utils/logger.d.ts +0 -1
  94. package/dist/src/utils/posthog.d.ts +0 -1
  95. package/dist/src/utils/types.d.ts +0 -1
  96. package/dist/tsconfig.tsbuildinfo +1 -1
  97. package/package.json +6 -3
  98. package/.cursor/rules/backend.mdc +0 -70
  99. package/.turbo/turbo-build.log +0 -5
  100. package/.turbo/turbo-check-types.log +0 -5
  101. package/.turbo/turbo-lint$colon$fix.log +0 -255
  102. package/CHANGELOG.md +0 -28
  103. package/dist/src/lib/posthog.d.ts.map +0 -1
  104. package/dist/src/lib/sentry.d.ts.map +0 -1
  105. package/dist/src/modules/access/access.repository.d.ts.map +0 -1
  106. package/dist/src/modules/access/access.service.d.ts.map +0 -1
  107. package/dist/src/modules/access/access.test.d.ts.map +0 -1
  108. package/dist/src/modules/access/access.utils.d.ts.map +0 -1
  109. package/dist/src/modules/ai/ai.db.d.ts.map +0 -1
  110. package/dist/src/modules/ai/ai.prompt.d.ts.map +0 -1
  111. package/dist/src/modules/ai/ai.repository.d.ts.map +0 -1
  112. package/dist/src/modules/ai/ai.router.d.ts.map +0 -1
  113. package/dist/src/modules/ai/ai.service.d.ts.map +0 -1
  114. package/dist/src/modules/ai/ai.trpc.d.ts.map +0 -1
  115. package/dist/src/modules/ai/ideogram/ideogram.constants.d.ts.map +0 -1
  116. package/dist/src/modules/ai/ideogram/ideogram.dto.d.ts.map +0 -1
  117. package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts.map +0 -1
  118. package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts.map +0 -1
  119. package/dist/src/modules/ai/ideogram/ideogram.service.d.ts.map +0 -1
  120. package/dist/src/modules/auth/auth.db.d.ts.map +0 -1
  121. package/dist/src/modules/auth/auth.dto.d.ts.map +0 -1
  122. package/dist/src/modules/auth/auth.lib.d.ts.map +0 -1
  123. package/dist/src/modules/auth/auth.middleware.d.ts.map +0 -1
  124. package/dist/src/modules/auth/auth.repository.d.ts.map +0 -1
  125. package/dist/src/modules/auth/auth.service.d.ts.map +0 -1
  126. package/dist/src/modules/auth/auth.trpc.d.ts.map +0 -1
  127. package/dist/src/modules/auth/auth.utils.d.ts.map +0 -1
  128. package/dist/src/modules/base/base.abstract.d.ts.map +0 -1
  129. package/dist/src/modules/base/base.dto.d.ts.map +0 -1
  130. package/dist/src/modules/base/base.grants.d.ts.map +0 -1
  131. package/dist/src/modules/base/base.grants.test.d.ts.map +0 -1
  132. package/dist/src/modules/base/base.repository.d.ts.map +0 -1
  133. package/dist/src/modules/base/base.service.d.ts.map +0 -1
  134. package/dist/src/modules/base/base.types.d.ts.map +0 -1
  135. package/dist/src/modules/billing/billing.db.d.ts.map +0 -1
  136. package/dist/src/modules/billing/billing.repository.d.ts.map +0 -1
  137. package/dist/src/modules/billing/billing.router.d.ts.map +0 -1
  138. package/dist/src/modules/billing/billing.service.d.ts.map +0 -1
  139. package/dist/src/modules/billing/billing.trpc.d.ts.map +0 -1
  140. package/dist/src/modules/clay/clay.repository.d.ts.map +0 -1
  141. package/dist/src/modules/clay/clay.service.d.ts.map +0 -1
  142. package/dist/src/modules/connect/connect.db.d.ts.map +0 -1
  143. package/dist/src/modules/connect/connect.dto.d.ts.map +0 -1
  144. package/dist/src/modules/connect/connect.linkedin.d.ts.map +0 -1
  145. package/dist/src/modules/connect/connect.oauth.d.ts.map +0 -1
  146. package/dist/src/modules/connect/connect.repository.d.ts.map +0 -1
  147. package/dist/src/modules/connect/connect.router.d.ts.map +0 -1
  148. package/dist/src/modules/connect/connect.service.d.ts.map +0 -1
  149. package/dist/src/modules/connect/connect.trpc.d.ts.map +0 -1
  150. package/dist/src/modules/connect/connect.types.d.ts.map +0 -1
  151. package/dist/src/modules/crypto/crypto.db.d.ts.map +0 -1
  152. package/dist/src/modules/crypto/crypto.repository.d.ts.map +0 -1
  153. package/dist/src/modules/crypto/crypto.service.d.ts.map +0 -1
  154. package/dist/src/modules/email/email.service.d.ts.map +0 -1
  155. package/dist/src/modules/file/file.repository.d.ts.map +0 -1
  156. package/dist/src/modules/file/file.router.d.ts.map +0 -1
  157. package/dist/src/modules/file/file.service.d.ts.map +0 -1
  158. package/dist/src/modules/recurrence/recurrence.db.d.ts.map +0 -1
  159. package/dist/src/modules/recurrence/recurrence.repository.d.ts.map +0 -1
  160. package/dist/src/modules/recurrence/recurrence.service.d.ts.map +0 -1
  161. package/dist/src/modules/recurrence/recurrence.trpc.d.ts.map +0 -1
  162. package/dist/src/modules/social/social.dto.d.ts.map +0 -1
  163. package/dist/src/modules/social/social.linkedin.d.ts.map +0 -1
  164. package/dist/src/modules/social/social.linkedin.test.d.ts.map +0 -1
  165. package/dist/src/modules/social/social.service.d.ts.map +0 -1
  166. package/dist/src/modules/social/social.types.d.ts.map +0 -1
  167. package/dist/src/modules/tag/tag.db.d.ts.map +0 -1
  168. package/dist/src/modules/tag/tag.dto.d.ts.map +0 -1
  169. package/dist/src/modules/tag/tag.repository.d.ts.map +0 -1
  170. package/dist/src/modules/tag/tag.service.d.ts.map +0 -1
  171. package/dist/src/modules/tag/tag.trpc.d.ts.map +0 -1
  172. package/dist/src/modules/utils/applyPagination.d.ts.map +0 -1
  173. package/dist/src/modules/utils/applySorting.d.ts.map +0 -1
  174. package/dist/src/modules/utils/getConditionsFromFilters.d.ts.map +0 -1
  175. package/dist/src/modules/video/video.service.d.ts.map +0 -1
  176. package/dist/src/modules/webhook/webhook.constants.d.ts.map +0 -1
  177. package/dist/src/modules/webhook/webhook.db.d.ts.map +0 -1
  178. package/dist/src/modules/webhook/webhook.dto.d.ts.map +0 -1
  179. package/dist/src/modules/webhook/webhook.repository.d.ts.map +0 -1
  180. package/dist/src/modules/webhook/webhook.router.d.ts.map +0 -1
  181. package/dist/src/modules/webhook/webhook.service.d.ts.map +0 -1
  182. package/dist/src/modules/workflow/workflow.db.d.ts.map +0 -1
  183. package/dist/src/modules/workflow/workflow.repository.d.ts.map +0 -1
  184. package/dist/src/modules/workflow/workflow.service.d.ts.map +0 -1
  185. package/dist/src/modules/workflow/workflow.trpc.d.ts.map +0 -1
  186. package/dist/src/modules/workflow/workflow.types.d.ts.map +0 -1
  187. package/dist/src/modules/workflow/workflow.utils.d.ts.map +0 -1
  188. package/dist/src/test/stubs/utils.d.ts.map +0 -1
  189. package/dist/src/trpc/context.d.ts.map +0 -1
  190. package/dist/src/trpc/index.d.ts.map +0 -1
  191. package/dist/src/trpc/procedures.d.ts.map +0 -1
  192. package/dist/src/trpc/utils.d.ts.map +0 -1
  193. package/dist/src/types.d.ts.map +0 -1
  194. package/dist/src/utils/errors.d.ts.map +0 -1
  195. package/dist/src/utils/logger.d.ts.map +0 -1
  196. package/dist/src/utils/posthog.d.ts.map +0 -1
  197. package/dist/src/utils/types.d.ts.map +0 -1
  198. package/jest.config.ts +0 -19
  199. package/src/lib/posthog.ts +0 -5
  200. package/src/lib/sentry.ts +0 -8
  201. package/src/modules/access/access.repository.ts +0 -36
  202. package/src/modules/access/access.service.ts +0 -81
  203. package/src/modules/access/access.test.ts +0 -216
  204. package/src/modules/access/access.utils.ts +0 -46
  205. package/src/modules/ai/ai.db.ts +0 -38
  206. package/src/modules/ai/ai.prompt.ts +0 -47
  207. package/src/modules/ai/ai.repository.ts +0 -53
  208. package/src/modules/ai/ai.router.ts +0 -148
  209. package/src/modules/ai/ai.service.ts +0 -310
  210. package/src/modules/ai/ai.trpc.ts +0 -22
  211. package/src/modules/ai/ideogram/ideogram.constants.ts +0 -170
  212. package/src/modules/ai/ideogram/ideogram.dto.ts +0 -64
  213. package/src/modules/ai/ideogram/ideogram.prompt.ts +0 -858
  214. package/src/modules/ai/ideogram/ideogram.repository.ts +0 -39
  215. package/src/modules/ai/ideogram/ideogram.service.ts +0 -14
  216. package/src/modules/auth/auth.db.ts +0 -224
  217. package/src/modules/auth/auth.dto.ts +0 -47
  218. package/src/modules/auth/auth.lib.ts +0 -349
  219. package/src/modules/auth/auth.middleware.ts +0 -62
  220. package/src/modules/auth/auth.repository.ts +0 -672
  221. package/src/modules/auth/auth.service.ts +0 -261
  222. package/src/modules/auth/auth.trpc.ts +0 -208
  223. package/src/modules/auth/auth.utils.ts +0 -117
  224. package/src/modules/base/base.abstract.ts +0 -62
  225. package/src/modules/base/base.dto.ts +0 -206
  226. package/src/modules/base/base.grants.test.ts +0 -861
  227. package/src/modules/base/base.grants.ts +0 -199
  228. package/src/modules/base/base.repository.ts +0 -433
  229. package/src/modules/base/base.service.ts +0 -154
  230. package/src/modules/base/base.types.ts +0 -7
  231. package/src/modules/billing/billing.db.ts +0 -27
  232. package/src/modules/billing/billing.repository.ts +0 -328
  233. package/src/modules/billing/billing.router.ts +0 -77
  234. package/src/modules/billing/billing.service.ts +0 -177
  235. package/src/modules/billing/billing.trpc.ts +0 -17
  236. package/src/modules/clay/clay.repository.ts +0 -29
  237. package/src/modules/clay/clay.service.ts +0 -61
  238. package/src/modules/connect/connect.db.ts +0 -32
  239. package/src/modules/connect/connect.dto.ts +0 -44
  240. package/src/modules/connect/connect.linkedin.ts +0 -70
  241. package/src/modules/connect/connect.oauth.ts +0 -288
  242. package/src/modules/connect/connect.repository.ts +0 -65
  243. package/src/modules/connect/connect.router.ts +0 -76
  244. package/src/modules/connect/connect.service.ts +0 -171
  245. package/src/modules/connect/connect.trpc.ts +0 -26
  246. package/src/modules/connect/connect.types.ts +0 -27
  247. package/src/modules/crypto/crypto.db.ts +0 -15
  248. package/src/modules/crypto/crypto.repository.ts +0 -13
  249. package/src/modules/crypto/crypto.service.ts +0 -57
  250. package/src/modules/email/email.service.ts +0 -222
  251. package/src/modules/file/file.repository.ts +0 -95
  252. package/src/modules/file/file.router.ts +0 -108
  253. package/src/modules/file/file.service.ts +0 -186
  254. package/src/modules/recurrence/recurrence.db.ts +0 -79
  255. package/src/modules/recurrence/recurrence.repository.ts +0 -70
  256. package/src/modules/recurrence/recurrence.service.ts +0 -105
  257. package/src/modules/recurrence/recurrence.trpc.ts +0 -82
  258. package/src/modules/social/social.dto.ts +0 -22
  259. package/src/modules/social/social.linkedin.test.ts +0 -277
  260. package/src/modules/social/social.linkedin.ts +0 -593
  261. package/src/modules/social/social.service.ts +0 -112
  262. package/src/modules/social/social.types.ts +0 -43
  263. package/src/modules/tag/tag.db.ts +0 -41
  264. package/src/modules/tag/tag.dto.ts +0 -18
  265. package/src/modules/tag/tag.repository.ts +0 -222
  266. package/src/modules/tag/tag.service.ts +0 -48
  267. package/src/modules/tag/tag.trpc.ts +0 -62
  268. package/src/modules/uploads/0581796b-8845-420d-bd95-cd7de79f6d37.webm +0 -0
  269. package/src/modules/uploads/33b1e649-6727-4bd0-94d0-a0b363646865.webm +0 -0
  270. package/src/modules/uploads/49a8c4c0-54d7-4c94-bef4-c93c029f9ed0.webm +0 -0
  271. package/src/modules/uploads/50e31e38-a2f0-47ca-8b7d-2d7fcad9267d.webm +0 -0
  272. package/src/modules/uploads/72ac8cf9-c3a7-4cd8-8a78-6d8e137a4c7e.webm +0 -0
  273. package/src/modules/uploads/75293649-d966-46cd-a675-67518958ae9c.png +0 -0
  274. package/src/modules/uploads/88b7b867-ce15-4891-bf73-81305a7de1f7.wav +0 -0
  275. package/src/modules/uploads/a5d6fee8-6a59-42c6-9d4a-ac8a3c5e7245.webm +0 -0
  276. package/src/modules/uploads/c13a9785-ca5a-4983-af30-b338ed76d370.webm +0 -0
  277. package/src/modules/uploads/caa1a5a7-71ba-4381-902d-7e2cafdf6dcb.webm +0 -0
  278. package/src/modules/uploads/cbeb0b81-374d-445b-914b-40ace7c8e031.webm +0 -0
  279. package/src/modules/uploads/d626aa82-b10f-493f-aee7-87bfb3361dfc.webm +0 -0
  280. package/src/modules/uploads/d7de4c16-de0c-495d-9612-e72260a6ecca.png +0 -0
  281. package/src/modules/uploads/e532e38a-6421-400e-8a5f-8e7bc8ce411b.wav +0 -0
  282. package/src/modules/uploads/e86ec867-6adf-4c51-84e0-00b0836625e8.webm +0 -0
  283. package/src/modules/utils/applyPagination.ts +0 -13
  284. package/src/modules/utils/applySorting.ts +0 -21
  285. package/src/modules/utils/getConditionsFromFilters.ts +0 -216
  286. package/src/modules/video/video.service.ts +0 -89
  287. package/src/modules/webhook/webhook.constants.ts +0 -9
  288. package/src/modules/webhook/webhook.db.ts +0 -15
  289. package/src/modules/webhook/webhook.dto.ts +0 -9
  290. package/src/modules/webhook/webhook.repository.ts +0 -68
  291. package/src/modules/webhook/webhook.router.ts +0 -29
  292. package/src/modules/webhook/webhook.service.ts +0 -78
  293. package/src/modules/workflow/workflow.db.ts +0 -29
  294. package/src/modules/workflow/workflow.repository.ts +0 -171
  295. package/src/modules/workflow/workflow.service.ts +0 -56
  296. package/src/modules/workflow/workflow.trpc.ts +0 -26
  297. package/src/modules/workflow/workflow.types.ts +0 -30
  298. package/src/modules/workflow/workflow.utils.ts +0 -259
  299. package/src/test/stubs/utils.ts +0 -2
  300. package/src/trpc/context.ts +0 -21
  301. package/src/trpc/index.ts +0 -3
  302. package/src/trpc/procedures.ts +0 -43
  303. package/src/trpc/utils.ts +0 -20
  304. package/src/types.ts +0 -22
  305. package/src/utils/errors.ts +0 -148
  306. package/src/utils/logger.ts +0 -8
  307. package/src/utils/posthog.ts +0 -43
  308. package/src/utils/types.ts +0 -5
  309. package/tsconfig.json +0 -21
@@ -1,39 +0,0 @@
1
- import { ok } from "neverthrow";
2
- import type {
3
- IdeogramV3GenerateInput,
4
- IdeogramV3GenerateOutput,
5
- } from "#modules/ai/ideogram/ideogram.dto";
6
- import type { ServerResultAsync } from "#modules/base/base.dto";
7
- import { BaseExternaRepository } from "#modules/base/base.repository";
8
-
9
- export class IdeogramRepository extends BaseExternaRepository {
10
- async generate(input: IdeogramV3GenerateInput): ServerResultAsync<IdeogramV3GenerateOutput> {
11
- if (!process.env.IDEOGRAM_API_KEY)
12
- return this.error("INTERNAL_SERVER_ERROR", "IDEOGRAM_API_KEY is not set");
13
- return this.throwableAsync(async () => {
14
- const formData = new FormData();
15
- formData.append("prompt", input.prompt);
16
- if (input.seed) formData.append("seed", input.seed.toString());
17
- if (input.resolution) formData.append("resolution", input.resolution);
18
- if (input.rendering_speed) formData.append("rendering_speed", input.rendering_speed);
19
- if (input.magic_prompt) formData.append("magic_prompt", input.magic_prompt);
20
- if (input.negative_prompt) formData.append("negative_prompt", input.negative_prompt);
21
- if (input.num_images) formData.append("num_images", input.num_images.toString());
22
- if (input.color_palette)
23
- formData.append("color_palette", JSON.stringify(input.color_palette));
24
- if (input.style_codes) formData.append("style_codes", JSON.stringify(input.style_codes));
25
- if (input.aspect_ratio) formData.append("aspect_ratio", input.aspect_ratio);
26
- if (input.style_type) formData.append("style_type", input.style_type);
27
- if (input.style_preset) formData.append("style_preset", input.style_preset);
28
- //TODO: Add file support
29
-
30
- const response = await fetch("https://api.ideogram.ai/v1/ideogram-v3/generate", {
31
- method: "POST",
32
- headers: { "Api-Key": process.env.IDEOGRAM_API_KEY! },
33
- body: formData,
34
- });
35
- const data = await response.json();
36
- return ok(data as IdeogramV3GenerateOutput);
37
- });
38
- }
39
- }
@@ -1,14 +0,0 @@
1
- import type {
2
- IdeogramV3GenerateInput,
3
- IdeogramV3GenerateOutput,
4
- } from "#modules/ai/ideogram/ideogram.dto";
5
- import type { IdeogramRepository } from "#modules/ai/ideogram/ideogram.repository";
6
- import type { ServerResultAsync } from "#modules/base/base.dto";
7
- import { BaseService } from "#modules/base/base.service";
8
-
9
- export class IdeogramService extends BaseService<{ ideogram: IdeogramRepository }, never> {
10
- async generate(input: IdeogramV3GenerateInput): ServerResultAsync<IdeogramV3GenerateOutput> {
11
- const result = await this.repository.ideogram.generate(input);
12
- return result;
13
- }
14
- }
@@ -1,224 +0,0 @@
1
- import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
2
- import { v4 as uuidv4 } from "uuid";
3
-
4
- export const users = sqliteTable("users", {
5
- id: text("id").primaryKey().$default(uuidv4),
6
- name: text("name").notNull(),
7
- email: text("email").notNull().unique(),
8
- emailVerified: integer("email_verified", { mode: "boolean" }).notNull(),
9
- image: text("image"),
10
- createdAt: integer("created_at", { mode: "timestamp" })
11
- .notNull()
12
- .$default(() => new Date()),
13
- updatedAt: integer("updated_at", { mode: "timestamp" })
14
- .notNull()
15
- .$default(() => new Date()),
16
- role: text("role"),
17
- banned: integer("banned", { mode: "boolean" }),
18
- banReason: text("ban_reason"),
19
- banExpires: integer("ban_expires", { mode: "timestamp" }),
20
- stripeCustomerId: text("stripe_customer_id").unique(),
21
- paymentCustomerId: text("payment_customer_id").unique(),
22
- paymentPlanTier: text("payment_plan_tier"),
23
- paymentPlanExpiresAt: integer("payment_plan_expires_at", {
24
- mode: "timestamp",
25
- }),
26
- preferences: text("preferences"),
27
- metadata: text("metadata", { mode: "json" })
28
- .notNull()
29
- .default({})
30
- .$type<Record<string, unknown>>(),
31
- onboarding: integer("onboarding"),
32
- flags: text("flags"),
33
- });
34
-
35
- export const sessions = sqliteTable("sessions", {
36
- id: text("id").primaryKey().$default(uuidv4),
37
- expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
38
- token: text("token").notNull().unique(),
39
- createdAt: integer("created_at", { mode: "timestamp" })
40
- .notNull()
41
- .$default(() => new Date()),
42
- updatedAt: integer("updated_at", { mode: "timestamp" })
43
- .notNull()
44
- .$default(() => new Date()),
45
- ipAddress: text("ip_address"),
46
- userAgent: text("user_agent"),
47
- userId: text("user_id")
48
- .notNull()
49
- .references(() => users.id, { onDelete: "cascade" }),
50
- impersonatedBy: text("impersonated_by"),
51
- activeOrganizationId: text("active_organization_id"),
52
- activeOrganizationRole: text("active_organization_role"),
53
- activeTeamId: text("active_team_id"),
54
- activeTeamRole: text("active_team_role"),
55
- });
56
-
57
- export const accounts = sqliteTable("accounts", {
58
- id: text("id").primaryKey().$default(uuidv4),
59
- accountId: text("account_id").notNull(),
60
- providerId: text("provider_id").notNull(),
61
- userId: text("user_id")
62
- .notNull()
63
- .references(() => users.id, { onDelete: "cascade" }),
64
- accessToken: text("access_token"),
65
- refreshToken: text("refresh_token"),
66
- idToken: text("id_token"),
67
- accessTokenExpiresAt: integer("access_token_expires_at", {
68
- mode: "timestamp",
69
- }),
70
- refreshTokenExpiresAt: integer("refresh_token_expires_at", {
71
- mode: "timestamp",
72
- }),
73
- scope: text("scope"),
74
- password: text("password"),
75
- createdAt: integer("created_at", { mode: "timestamp" })
76
- .notNull()
77
- .$default(() => new Date()),
78
- updatedAt: integer("updated_at", { mode: "timestamp" })
79
- .notNull()
80
- .$default(() => new Date()),
81
- });
82
-
83
- export const verifications = sqliteTable("verifications", {
84
- id: text("id").primaryKey().$default(uuidv4),
85
- identifier: text("identifier").notNull(),
86
- value: text("value").notNull(),
87
- expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
88
- createdAt: integer("created_at", { mode: "timestamp" }).$default(() => new Date()),
89
- updatedAt: integer("updated_at", { mode: "timestamp" }).$default(() => new Date()),
90
- });
91
-
92
- export const organizations = sqliteTable("organizations", {
93
- id: text("id").primaryKey().$default(uuidv4),
94
- name: text("name").notNull(),
95
- slug: text("slug").unique(),
96
- logo: text("logo"),
97
- createdAt: integer("created_at", { mode: "timestamp" })
98
- .notNull()
99
- .$default(() => new Date()),
100
- metadata: text("metadata"),
101
- });
102
-
103
- export const members = sqliteTable("members", {
104
- id: text("id").primaryKey().$default(uuidv4),
105
- organizationId: text("organization_id")
106
- .notNull()
107
- .references(() => organizations.id),
108
- userId: text("user_id")
109
- .notNull()
110
- .references(() => users.id),
111
- role: text("role").notNull(),
112
- createdAt: integer("created_at", { mode: "timestamp" })
113
- .notNull()
114
- .$default(() => new Date()),
115
- });
116
-
117
- export const teams = sqliteTable("teams", {
118
- id: text("id").primaryKey().$default(uuidv4),
119
- name: text("name").notNull(),
120
- organizationId: text("organization_id")
121
- .notNull()
122
- .references(() => organizations.id),
123
- createdAt: integer("created_at", { mode: "timestamp" })
124
- .notNull()
125
- .$default(() => new Date()),
126
- updatedAt: integer("updated_at", { mode: "timestamp" }),
127
- });
128
-
129
- export const teamMembers = sqliteTable("teammembers", {
130
- id: text("id").primaryKey().$default(uuidv4),
131
- teamId: text("team_id")
132
- .notNull()
133
- .references(() => teams.id),
134
- userId: text("user_id")
135
- .notNull()
136
- .references(() => users.id),
137
- role: text("role").notNull(),
138
- createdAt: integer("created_at", { mode: "timestamp" })
139
- .notNull()
140
- .$default(() => new Date()),
141
- });
142
-
143
- export const invitations = sqliteTable("invitations", {
144
- id: text("id").primaryKey().$default(uuidv4),
145
- organizationId: text("organization_id")
146
- .notNull()
147
- .references(() => organizations.id),
148
- teamId: text("team_id").references(() => teams.id),
149
- email: text("email").notNull(),
150
- role: text("role"),
151
- status: text("status").notNull(),
152
- createdAt: integer("created_at", { mode: "timestamp" })
153
- .notNull()
154
- .$default(() => new Date()),
155
- expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
156
- inviterId: text("inviter_id")
157
- .notNull()
158
- .references(() => users.id),
159
- });
160
-
161
- export const apikeys = sqliteTable("apikeys", {
162
- id: text("id").primaryKey().$default(uuidv4),
163
- name: text("name"),
164
- start: text("start"),
165
- prefix: text("prefix"),
166
- key: text("key").notNull(),
167
- userId: text("user_id")
168
- .notNull()
169
- .references(() => users.id),
170
- refillInterval: integer("refill_interval", { mode: "number" }),
171
- refillAmount: integer("refill_amount", { mode: "number" }),
172
- lastRefillAt: integer("last_refill_at", { mode: "timestamp" }),
173
- enabled: integer("enabled", { mode: "boolean" }).notNull(),
174
- rateLimitEnabled: integer("rate_limit_enabled", { mode: "boolean" }).notNull(),
175
- rateLimitTimeWindow: integer("rate_limit_time_window", { mode: "number" }),
176
- rateLimitMax: integer("rate_limit_max", { mode: "number" }),
177
- requestCount: integer("request_count", { mode: "number" }).notNull(),
178
- remaining: integer("remaining", { mode: "number" }),
179
- lastRequest: integer("last_request", { mode: "timestamp" }),
180
- expiresAt: integer("expires_at", { mode: "timestamp" }),
181
- createdAt: integer("created_at", { mode: "timestamp" })
182
- .notNull()
183
- .$default(() => new Date()),
184
- updatedAt: integer("updated_at", { mode: "timestamp" })
185
- .notNull()
186
- .$default(() => new Date()),
187
- permissions: text("permissions"),
188
- metadata: text("metadata"),
189
- });
190
-
191
- export const waitlist = sqliteTable("waitlist", {
192
- id: text("id").primaryKey().$default(uuidv4),
193
- name: text("name"),
194
- email: text("email"),
195
- createdAt: integer("created_at", { mode: "timestamp" })
196
- .notNull()
197
- .$default(() => new Date()),
198
- updatedAt: integer("updated_at", { mode: "timestamp" }),
199
- status: text("status").notNull().default("WAITLIST"),
200
- type: text("type").notNull().default("WAITLIST"),
201
- code: text("code"),
202
- expiresAt: integer("expires_at", { mode: "timestamp" }),
203
- userId: text("user_id").references(() => users.id),
204
- claimUserId: text("claim_user_id").references(() => users.id),
205
- claimedAt: integer("claimed_at", { mode: "timestamp" }),
206
- claimedEmail: text("claimed_email"),
207
- });
208
-
209
- export const accountClaimMagicLinks = sqliteTable("account_claim_magic_links", {
210
- id: text("id").primaryKey().$default(uuidv4),
211
- claimId: text("claim_id")
212
- .notNull()
213
- .references(() => waitlist.id, { onDelete: "cascade" }),
214
- userId: text("user_id")
215
- .notNull()
216
- .references(() => users.id, { onDelete: "cascade" }),
217
- email: text("email").notNull(),
218
- token: text("token").notNull(),
219
- url: text("url").notNull(),
220
- expiresAt: integer("expires_at", { mode: "timestamp" }),
221
- createdAt: integer("created_at", { mode: "timestamp" })
222
- .notNull()
223
- .$default(() => new Date()),
224
- });
@@ -1,47 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const waitlistSchema = z.object({
4
- id: z.string(),
5
- name: z.string().nullable(),
6
- email: z.string().nullable(),
7
- createdAt: z.date(),
8
- updatedAt: z.date().nullable(),
9
- status: z.string(),
10
- code: z.string().nullable(),
11
- expiresAt: z.date().nullable(),
12
- });
13
-
14
- export const waitlistOutputSchema = waitlistSchema.omit({ code: true, expiresAt: true });
15
- export type WaitlistOutput = z.infer<typeof waitlistOutputSchema>;
16
- export type Waitlist = z.infer<typeof waitlistSchema>;
17
-
18
- export const accountClaimSchema = z.object({
19
- id: z.string(),
20
- claimUserId: z.string().nullable(),
21
- code: z.string().nullable(),
22
- status: z.string(),
23
- expiresAt: z.date().nullable(),
24
- claimedAt: z.date().nullable(),
25
- claimedEmail: z.string().nullable(),
26
- createdAt: z.date(),
27
- updatedAt: z.date().nullable(),
28
- });
29
-
30
- export const accountClaimOutputSchema = accountClaimSchema.omit({ code: true });
31
- export type AccountClaim = z.infer<typeof accountClaimSchema>;
32
- export type AccountClaimOutput = z.infer<typeof accountClaimOutputSchema>;
33
-
34
- export const accountClaimMagicLinkSchema = z.object({
35
- id: z.string(),
36
- claimId: z.string(),
37
- userId: z.string(),
38
- email: z.string(),
39
- token: z.string(),
40
- url: z.string(),
41
- expiresAt: z.date().nullable(),
42
- createdAt: z.date(),
43
- });
44
-
45
- export const accountClaimMagicLinkOutputSchema = accountClaimMagicLinkSchema.omit({ token: true });
46
- export type AccountClaimMagicLink = z.infer<typeof accountClaimMagicLinkSchema>;
47
- export type AccountClaimMagicLinkOutput = z.infer<typeof accountClaimMagicLinkOutputSchema>;
@@ -1,349 +0,0 @@
1
- import { type BetterAuthOptions, betterAuth } from "better-auth";
2
- import { drizzleAdapter } from "better-auth/adapters/drizzle";
3
- import { getOAuthState } from "better-auth/api";
4
- import { admin, apiKey, lastLoginMethod, magicLink, organization } from "better-auth/plugins";
5
- import { and, desc, eq, gte, type InferSelectModel } from "drizzle-orm";
6
- import type { LibSQLDatabase } from "drizzle-orm/libsql";
7
- import * as auth from "#modules/auth/auth.db";
8
- import { createOrganizationAndTeam, getActiveOrganizationAndTeam } from "#modules/auth/auth.utils";
9
- import type { BillingService } from "#modules/billing/billing.service";
10
- import type { EmailService } from "#modules/email/email.service";
11
- import { logger as rootLogger } from "#utils/logger";
12
- import { posthogCapture } from "#utils/posthog";
13
-
14
- const schema = { ...auth };
15
- type Schema = typeof schema;
16
- export type Orm = LibSQLDatabase<Schema>;
17
-
18
- export type User = InferSelectModel<typeof auth.users>;
19
- export type Session = InferSelectModel<typeof auth.sessions>;
20
- export type Context = { session: Session; user: User };
21
-
22
- export type BetterAuth = ReturnType<typeof betterAuth>;
23
-
24
- type CreateBetterAuthParams<
25
- O extends Orm,
26
- S extends Schema,
27
- E extends EmailService,
28
- B extends BillingService,
29
- > = {
30
- orm: O;
31
- schema: S;
32
- services: {
33
- email?: E;
34
- billing?: B;
35
- };
36
- hooks?: {
37
- onError?: (error: unknown) => void;
38
- afterCreateUser?: (
39
- user: Pick<User, "id" | "email" | "emailVerified" | "name" | "createdAt" | "updatedAt">
40
- ) => Promise<void>;
41
- };
42
- options?: BetterAuthOptions;
43
- config?: {
44
- waitlist: boolean;
45
- provisionedAccountEmailDomain?: string;
46
- };
47
- };
48
-
49
- export function createBetterAuth<
50
- O extends Orm,
51
- S extends Schema,
52
- E extends EmailService,
53
- B extends BillingService,
54
- >({ orm, schema, services, hooks, options, config }: CreateBetterAuthParams<O, S, E, B>) {
55
- const { email: emailService, billing: billingService } = services;
56
- const { waitlist = false, provisionedAccountEmailDomain } = config ?? {};
57
- const normalizedProvisionedAccountEmailDomain = provisionedAccountEmailDomain
58
- ? provisionedAccountEmailDomain.toLowerCase().replace(/^@/, "")
59
- : null;
60
-
61
- const logger = rootLogger.child({ layer: "betterAuth" });
62
-
63
- const getWaitlistInvitationCode = async (ctx?: { headers?: Headers | null } | null) => {
64
- let code = ctx?.headers?.get("waitlist-invitation-code");
65
- if (code) return code;
66
- const oauthState = await getOAuthState();
67
- if (oauthState) {
68
- code = oauthState.waitlistInvitationCode;
69
- }
70
- return code;
71
- };
72
-
73
- const isProvisionedAccountEmail = (email: string) => {
74
- if (!normalizedProvisionedAccountEmailDomain) return false;
75
- return email.toLowerCase().endsWith(`@${normalizedProvisionedAccountEmailDomain}`);
76
- };
77
-
78
- return betterAuth({
79
- ...options,
80
- baseURL: process.env.VITE_SERVER_URL!,
81
- session: {
82
- expiresIn: 60 * 60 * 24 * 7,
83
- updateAge: 60 * 60 * 24,
84
- cookieCache: {
85
- enabled: true,
86
- maxAge: 60 * 5,
87
- },
88
- additionalFields: {
89
- activeOrganizationRole: {
90
- type: "string",
91
- required: false,
92
- defaultValue: null,
93
- },
94
- activeTeamRole: {
95
- type: "string",
96
- required: false,
97
- defaultValue: null,
98
- },
99
- },
100
- },
101
- user: {
102
- deleteUser: {
103
- enabled: true,
104
- sendDeleteAccountVerification: async ({ user, url }) => {
105
- const result = await emailService?.sendDeleteAccountVerification(user.email, url);
106
- if (result?.isErr()) {
107
- logger.error(result.error);
108
- hooks?.onError?.(result.error);
109
- throw result.error;
110
- }
111
- },
112
- },
113
- additionalFields: {
114
- onboarding: {
115
- type: "number",
116
- required: false,
117
- defaultValue: null,
118
- },
119
- preferences: {
120
- type: "string",
121
- required: false,
122
- defaultValue: null,
123
- },
124
- flags: {
125
- type: "string",
126
- required: false,
127
- defaultValue: null,
128
- },
129
- stripeCustomerId: {
130
- type: "string",
131
- required: false,
132
- defaultValue: null,
133
- input: false,
134
- },
135
- paymentCustomerId: {
136
- type: "string",
137
- required: false,
138
- defaultValue: null,
139
- input: false,
140
- },
141
- paymentPlanTier: {
142
- type: "string",
143
- required: false,
144
- defaultValue: null,
145
- input: false,
146
- },
147
- paymentPlanExpiresAt: {
148
- type: "number",
149
- required: false,
150
- defaultValue: null,
151
- input: false,
152
- },
153
- },
154
- },
155
- database: drizzleAdapter(orm, {
156
- provider: "sqlite",
157
- schema,
158
- usePlural: true,
159
- }),
160
- emailAndPassword: {
161
- enabled: true,
162
- requireEmailVerification: !waitlist,
163
- sendResetPassword: async ({ user, url }) => {
164
- const result = await emailService?.sendResetPassword(user.email, url);
165
- if (result?.isErr()) {
166
- logger.error(result.error);
167
- hooks?.onError?.(result.error);
168
- throw result.error;
169
- }
170
- },
171
- },
172
- emailVerification: {
173
- sendVerificationEmail: async ({ user, url }) => {
174
- const result = await emailService?.sendVerification(user.email, url);
175
- if (result?.isErr()) {
176
- logger.error(result.error);
177
- hooks?.onError?.(result.error);
178
- throw result.error;
179
- }
180
- },
181
- },
182
- plugins: [
183
- ...(options?.plugins ?? []),
184
- magicLink({
185
- disableSignUp: true,
186
- sendMagicLink: async ({ email, url, token }) => {
187
- const [user] = await orm
188
- .select({ id: schema.users.id })
189
- .from(schema.users)
190
- .where(eq(schema.users.email, email.toLowerCase()))
191
- .limit(1);
192
-
193
- if (!user) return;
194
-
195
- const [claim] = await orm
196
- .select({ id: schema.waitlist.id })
197
- .from(schema.waitlist)
198
- .where(
199
- and(
200
- eq(schema.waitlist.type, "ACCOUNT_CLAIM"),
201
- eq(schema.waitlist.claimUserId, user.id),
202
- eq(schema.waitlist.status, "INVITED"),
203
- gte(schema.waitlist.expiresAt, new Date())
204
- )
205
- )
206
- .orderBy(desc(schema.waitlist.createdAt))
207
- .limit(1);
208
- if (claim) {
209
- await orm.insert(schema.accountClaimMagicLinks).values({
210
- claimId: claim.id,
211
- userId: user.id,
212
- email: email.toLowerCase(),
213
- token,
214
- url,
215
- expiresAt: new Date(Date.now() + 1000 * 60 * 5),
216
- });
217
- }
218
- },
219
- }),
220
- admin(),
221
- lastLoginMethod(),
222
- organization({
223
- allowUserToCreateOrganization: false,
224
- teams: {
225
- enabled: true,
226
- allowRemovingAllTeams: false,
227
- },
228
- sendInvitationEmail: async (data) => {
229
- const invitationUrl = `${process.env.VITE_APP_URL}/organization/accept-invitation?id=${data.id}`;
230
- const inviterName = data.inviter.user.name || data.inviter.user.email;
231
- const result = await emailService?.sendOrganizationInvite(
232
- data.email,
233
- data.organization.name,
234
- inviterName,
235
- data.role,
236
- invitationUrl
237
- );
238
- if (result?.isErr()) {
239
- logger.error(result.error);
240
- hooks?.onError?.(result.error);
241
- throw result.error;
242
- }
243
- },
244
- schema: {
245
- team: {
246
- modelName: "team",
247
- },
248
- teamMember: {
249
- modelName: "teamMember",
250
- additionalFields: {
251
- role: {
252
- type: "string",
253
- required: true,
254
- },
255
- },
256
- },
257
- member: {
258
- modelName: "member",
259
- },
260
- invitation: {
261
- modelName: "invitation",
262
- },
263
- organization: {
264
- modelName: "organization",
265
- },
266
- },
267
- }),
268
- apiKey(),
269
- ],
270
- trustedOrigins: [process.env.VITE_APP_URL!, process.env.VITE_SERVER_URL!],
271
-
272
- databaseHooks: {
273
- user: {
274
- create: {
275
- before: async (_user, ctx) => {
276
- if (waitlist) {
277
- const waitlistCode = await getWaitlistInvitationCode(ctx);
278
- if (waitlistCode) {
279
- const [waitlistInvitation] = await orm
280
- .select()
281
- .from(schema.waitlist)
282
- .where(
283
- and(
284
- eq(schema.waitlist.code, waitlistCode),
285
- eq(schema.waitlist.type, "WAITLIST"),
286
- eq(schema.waitlist.status, "INVITED"),
287
- gte(schema.waitlist.expiresAt, new Date())
288
- )
289
- )
290
- .limit(1);
291
-
292
- if (!waitlistInvitation) {
293
- return false;
294
- }
295
- await orm
296
- .update(schema.waitlist)
297
- .set({
298
- status: "ACCEPTED",
299
- updatedAt: new Date(),
300
- })
301
- .where(eq(schema.waitlist.id, waitlistInvitation.id));
302
- return;
303
- }
304
- }
305
-
306
- if (waitlist) {
307
- return false;
308
- }
309
- return;
310
- },
311
- after: async (user) => {
312
- await createOrganizationAndTeam(orm, schema, user);
313
- if (!isProvisionedAccountEmail(user.email)) {
314
- await billingService?.createUserHook({ user });
315
- }
316
- posthogCapture({
317
- distinctId: user.id,
318
- event: "user_created",
319
- properties: {
320
- email: user.email,
321
- name: user.name,
322
- role: user.role,
323
- image: user.image,
324
- },
325
- });
326
- if (hooks?.afterCreateUser) await hooks.afterCreateUser(user);
327
- },
328
- },
329
- },
330
- session: {
331
- create: {
332
- before: async (session) => {
333
- const { organizationId, teamId, organizationRole, teamRole } =
334
- await getActiveOrganizationAndTeam(orm, schema, session.userId);
335
- return {
336
- data: {
337
- ...session,
338
- activeOrganizationId: organizationId,
339
- activeTeamId: teamId,
340
- activeOrganizationRole: organizationRole,
341
- activeTeamRole: teamRole,
342
- },
343
- };
344
- },
345
- },
346
- },
347
- },
348
- });
349
- }