alepha 0.13.6 → 0.13.8

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 (487) hide show
  1. package/README.md +5 -2
  2. package/assets/swagger-ui/swagger-ui-bundle.js +1 -1
  3. package/assets/swagger-ui/swagger-ui-standalone-preset.js +1 -1
  4. package/assets/swagger-ui/swagger-ui.css +1 -1
  5. package/dist/api/audits/index.browser.js +116 -0
  6. package/dist/api/audits/index.browser.js.map +1 -0
  7. package/dist/api/audits/index.d.ts +1194 -0
  8. package/dist/api/audits/index.js +674 -0
  9. package/dist/api/audits/index.js.map +1 -0
  10. package/dist/{api-files → api/files}/index.browser.js +5 -5
  11. package/dist/api/files/index.browser.js.map +1 -0
  12. package/dist/{api-files → api/files}/index.d.ts +16 -9
  13. package/dist/{api-files → api/files}/index.js +10 -10
  14. package/dist/api/files/index.js.map +1 -0
  15. package/dist/{api-jobs → api/jobs}/index.browser.js +5 -5
  16. package/dist/api/jobs/index.browser.js.map +1 -0
  17. package/dist/{api-jobs → api/jobs}/index.d.ts +35 -35
  18. package/dist/{api-jobs → api/jobs}/index.js +9 -9
  19. package/dist/api/jobs/index.js.map +1 -0
  20. package/dist/{api-notifications → api/notifications}/index.browser.js +11 -11
  21. package/dist/api/notifications/index.browser.js.map +1 -0
  22. package/dist/api/notifications/index.d.ts +327 -0
  23. package/dist/{api-notifications → api/notifications}/index.js +11 -11
  24. package/dist/api/notifications/index.js.map +1 -0
  25. package/dist/api/parameters/index.browser.js +60 -0
  26. package/dist/api/parameters/index.browser.js.map +1 -0
  27. package/dist/api/parameters/index.d.ts +761 -0
  28. package/dist/api/parameters/index.js +877 -0
  29. package/dist/api/parameters/index.js.map +1 -0
  30. package/dist/{api-users → api/users}/index.browser.js +6 -6
  31. package/dist/api/users/index.browser.js.map +1 -0
  32. package/dist/{api-users → api/users}/index.d.ts +259 -247
  33. package/dist/{api-users → api/users}/index.js +125 -112
  34. package/dist/api/users/index.js.map +1 -0
  35. package/dist/{api-verifications → api/verifications}/index.browser.js +5 -5
  36. package/dist/api/verifications/index.browser.js.map +1 -0
  37. package/dist/api/verifications/index.d.ts +248 -0
  38. package/dist/{api-verifications → api/verifications}/index.js +13 -12
  39. package/dist/api/verifications/index.js.map +1 -0
  40. package/dist/bin/index.js +1 -0
  41. package/dist/bin/index.js.map +1 -1
  42. package/dist/cache/{index.d.ts → core/index.d.ts} +4 -4
  43. package/dist/cache/{index.js → core/index.js} +5 -5
  44. package/dist/cache/core/index.js.map +1 -0
  45. package/dist/{cache-redis → cache/redis}/index.d.ts +2 -2
  46. package/dist/{cache-redis → cache/redis}/index.js +2 -2
  47. package/dist/cache/redis/index.js.map +1 -0
  48. package/dist/cli/index.d.ts +71 -9
  49. package/dist/cli/index.js +280 -79
  50. package/dist/cli/index.js.map +1 -1
  51. package/dist/command/index.d.ts +63 -2
  52. package/dist/command/index.js +30 -3
  53. package/dist/command/index.js.map +1 -1
  54. package/dist/core/index.browser.js +241 -61
  55. package/dist/core/index.browser.js.map +1 -1
  56. package/dist/core/index.d.ts +170 -90
  57. package/dist/core/index.js +264 -67
  58. package/dist/core/index.js.map +1 -1
  59. package/dist/core/index.native.js +248 -65
  60. package/dist/core/index.native.js.map +1 -1
  61. package/dist/email/index.js +15 -10554
  62. package/dist/email/index.js.map +1 -1
  63. package/dist/lock/{index.d.ts → core/index.d.ts} +5 -5
  64. package/dist/lock/{index.js → core/index.js} +5 -5
  65. package/dist/lock/core/index.js.map +1 -0
  66. package/dist/{lock-redis → lock/redis}/index.d.ts +2 -2
  67. package/dist/{lock-redis → lock/redis}/index.js +2 -2
  68. package/dist/lock/redis/index.js.map +1 -0
  69. package/dist/logger/index.d.ts +4 -4
  70. package/dist/logger/index.js +77 -72
  71. package/dist/logger/index.js.map +1 -1
  72. package/dist/orm/index.d.ts +5 -1
  73. package/dist/orm/index.js +24 -7
  74. package/dist/orm/index.js.map +1 -1
  75. package/dist/queue/core/index.d.ts +548 -0
  76. package/dist/queue/core/index.js +391 -0
  77. package/dist/queue/core/index.js.map +1 -0
  78. package/dist/queue/redis/index.d.ts +28 -0
  79. package/dist/queue/redis/index.js +43 -0
  80. package/dist/queue/redis/index.js.map +1 -0
  81. package/dist/scheduler/index.d.ts +7 -7
  82. package/dist/scheduler/index.js +1 -393
  83. package/dist/scheduler/index.js.map +1 -1
  84. package/dist/security/index.d.ts +1 -1
  85. package/dist/security/index.js +2 -1413
  86. package/dist/security/index.js.map +1 -1
  87. package/dist/{server-auth → server/auth}/index.browser.js +6 -6
  88. package/dist/server/auth/index.browser.js.map +1 -0
  89. package/dist/{server-auth → server/auth}/index.d.ts +175 -164
  90. package/dist/server/auth/index.js +742 -0
  91. package/dist/server/auth/index.js.map +1 -0
  92. package/dist/{server-cache → server/cache}/index.d.ts +2 -2
  93. package/dist/{server-cache → server/cache}/index.js +2 -2
  94. package/dist/server/cache/index.js.map +1 -0
  95. package/dist/{server-compress → server/compress}/index.d.ts +2 -2
  96. package/dist/{server-compress → server/compress}/index.js +2 -2
  97. package/dist/server/compress/index.js.map +1 -0
  98. package/dist/{server-cookies → server/cookies}/index.browser.js +3 -3
  99. package/dist/server/cookies/index.browser.js.map +1 -0
  100. package/dist/{server-cookies → server/cookies}/index.d.ts +4 -4
  101. package/dist/{server-cookies → server/cookies}/index.js +9 -5
  102. package/dist/server/cookies/index.js.map +1 -0
  103. package/dist/server/{index.browser.js → core/index.browser.js} +14 -14
  104. package/dist/server/core/index.browser.js.map +1 -0
  105. package/dist/server/{index.d.ts → core/index.d.ts} +46 -37
  106. package/dist/server/{index.js → core/index.js} +47 -33
  107. package/dist/server/core/index.js.map +1 -0
  108. package/dist/{server-cors → server/cors}/index.d.ts +3 -3
  109. package/dist/{server-cors → server/cors}/index.js +3 -3
  110. package/dist/server/cors/index.js.map +1 -0
  111. package/dist/{server-health → server/health}/index.d.ts +3 -3
  112. package/dist/{server-health → server/health}/index.js +3 -3
  113. package/dist/server/health/index.js.map +1 -0
  114. package/dist/{server-helmet → server/helmet}/index.d.ts +2 -2
  115. package/dist/{server-helmet → server/helmet}/index.js +2 -2
  116. package/dist/server/helmet/index.js.map +1 -0
  117. package/dist/{server-links → server/links}/index.browser.js +5 -5
  118. package/dist/server/links/index.browser.js.map +1 -0
  119. package/dist/{server-links → server/links}/index.d.ts +40 -40
  120. package/dist/{server-links → server/links}/index.js +7 -7
  121. package/dist/server/links/index.js.map +1 -0
  122. package/dist/{server-metrics → server/metrics}/index.d.ts +2 -2
  123. package/dist/server/metrics/index.js +74 -0
  124. package/dist/server/metrics/index.js.map +1 -0
  125. package/dist/{server-multipart → server/multipart}/index.d.ts +2 -2
  126. package/dist/{server-multipart → server/multipart}/index.js +2 -2
  127. package/dist/server/multipart/index.js.map +1 -0
  128. package/dist/{server-proxy → server/proxy}/index.d.ts +3 -3
  129. package/dist/{server-proxy → server/proxy}/index.js +3 -3
  130. package/dist/server/proxy/index.js.map +1 -0
  131. package/dist/{server-rate-limit → server/rate-limit}/index.d.ts +4 -4
  132. package/dist/{server-rate-limit → server/rate-limit}/index.js +4 -4
  133. package/dist/server/rate-limit/index.js.map +1 -0
  134. package/dist/{server-security → server/security}/index.browser.js +1 -1
  135. package/dist/server/security/index.browser.js.map +1 -0
  136. package/dist/{server-security → server/security}/index.d.ts +4 -4
  137. package/dist/{server-security → server/security}/index.js +4 -4
  138. package/dist/server/security/index.js.map +1 -0
  139. package/dist/{server-static → server/static}/index.d.ts +3 -3
  140. package/dist/{server-static → server/static}/index.js +3 -3
  141. package/dist/server/static/index.js.map +1 -0
  142. package/dist/{server-swagger → server/swagger}/index.d.ts +3 -3
  143. package/dist/{server-swagger → server/swagger}/index.js +4 -4
  144. package/dist/server/swagger/index.js.map +1 -0
  145. package/dist/thread/index.js +2 -2
  146. package/dist/thread/index.js.map +1 -1
  147. package/dist/topic/{index.d.ts → core/index.d.ts} +6 -6
  148. package/dist/topic/{index.js → core/index.js} +6 -6
  149. package/dist/topic/core/index.js.map +1 -0
  150. package/dist/{topic-redis → topic/redis}/index.d.ts +2 -2
  151. package/dist/{topic-redis → topic/redis}/index.js +2 -2
  152. package/dist/topic/redis/index.js.map +1 -0
  153. package/dist/vite/index.d.ts +13 -2
  154. package/dist/vite/index.js +114 -50
  155. package/dist/vite/index.js.map +1 -1
  156. package/dist/websocket/index.browser.js +3 -3
  157. package/dist/websocket/index.browser.js.map +1 -1
  158. package/dist/websocket/index.js +4 -4
  159. package/dist/websocket/index.js.map +1 -1
  160. package/package.json +160 -156
  161. package/src/api/audits/controllers/AuditController.ts +186 -0
  162. package/src/api/audits/entities/audits.ts +132 -0
  163. package/src/api/audits/index.browser.ts +18 -0
  164. package/src/api/audits/index.ts +58 -0
  165. package/src/api/audits/primitives/$audit.ts +159 -0
  166. package/src/api/audits/schemas/auditQuerySchema.ts +23 -0
  167. package/src/api/audits/schemas/auditResourceSchema.ts +9 -0
  168. package/src/api/audits/schemas/createAuditSchema.ts +27 -0
  169. package/src/api/audits/services/AuditService.ts +412 -0
  170. package/src/{api-files → api/files}/index.ts +1 -0
  171. package/src/api/parameters/controllers/ConfigController.ts +324 -0
  172. package/src/api/parameters/entities/parameters.ts +113 -0
  173. package/src/api/parameters/index.ts +60 -0
  174. package/src/api/parameters/primitives/$config.ts +351 -0
  175. package/src/api/parameters/schedulers/ConfigActivationScheduler.ts +30 -0
  176. package/src/api/parameters/services/ConfigStore.ts +491 -0
  177. package/src/{api-users → api/users}/atoms/realmAuthSettingsAtom.ts +19 -0
  178. package/src/{api-users → api/users}/controllers/UserRealmController.ts +0 -2
  179. package/src/{api-users → api/users}/index.ts +2 -0
  180. package/src/{api-users → api/users}/primitives/$userRealm.ts +18 -3
  181. package/src/{api-users → api/users}/providers/UserRealmProvider.ts +12 -10
  182. package/src/{api-users → api/users}/services/RegistrationService.ts +2 -1
  183. package/src/{api-users → api/users}/services/SessionService.ts +4 -0
  184. package/src/{api-users → api/users}/services/UserService.ts +3 -0
  185. package/src/{api-verifications → api/verifications}/index.ts +9 -1
  186. package/src/bin/index.ts +1 -0
  187. package/src/cli/apps/AlephaPackageBuilderCli.ts +73 -48
  188. package/src/cli/assets/appRouterTs.ts +1 -1
  189. package/src/cli/assets/biomeJson.ts +2 -2
  190. package/src/cli/assets/dummySpecTs.ts +7 -0
  191. package/src/cli/assets/editorconfig.ts +13 -0
  192. package/src/cli/assets/indexHtml.ts +1 -1
  193. package/src/cli/assets/mainBrowserTs.ts +1 -1
  194. package/src/cli/assets/mainTs.ts +14 -0
  195. package/src/cli/assets/viteConfigTs.ts +1 -1
  196. package/src/cli/commands/BiomeCommands.ts +2 -0
  197. package/src/cli/commands/CoreCommands.ts +38 -15
  198. package/src/cli/commands/VerifyCommands.ts +6 -2
  199. package/src/cli/commands/ViteCommands.ts +28 -18
  200. package/src/cli/services/AlephaCliUtils.ts +243 -37
  201. package/src/command/helpers/Asker.ts +0 -1
  202. package/src/command/primitives/$command.ts +67 -0
  203. package/src/command/providers/CliProvider.ts +39 -8
  204. package/src/core/Alepha.ts +40 -30
  205. package/src/core/helpers/jsonSchemaToTypeBox.ts +307 -0
  206. package/src/core/index.shared.ts +1 -0
  207. package/src/core/index.ts +30 -3
  208. package/src/core/providers/EventManager.ts +1 -1
  209. package/src/core/providers/SchemaValidator.ts +1 -1
  210. package/src/core/providers/StateManager.ts +23 -12
  211. package/src/core/providers/TypeProvider.ts +26 -34
  212. package/src/logger/index.ts +8 -6
  213. package/src/logger/primitives/$logger.ts +1 -1
  214. package/src/logger/providers/{SimpleFormatterProvider.ts → PrettyFormatterProvider.ts} +10 -1
  215. package/src/orm/index.ts +6 -0
  216. package/src/orm/services/PgRelationManager.ts +2 -2
  217. package/src/orm/services/PostgresModelBuilder.ts +11 -7
  218. package/src/orm/services/Repository.ts +16 -7
  219. package/src/orm/services/SqliteModelBuilder.ts +10 -0
  220. package/src/queue/{index.ts → core/index.ts} +2 -3
  221. package/src/queue/{primitives → core/primitives}/$queue.ts +17 -162
  222. package/src/queue/core/providers/MemoryQueueProvider.ts +19 -0
  223. package/src/queue/core/providers/QueueProvider.ts +23 -0
  224. package/src/queue/core/providers/WorkerProvider.ts +244 -0
  225. package/src/queue/redis/providers/RedisQueueProvider.ts +31 -0
  226. package/src/{server-auth → server/auth}/primitives/$auth.ts +7 -0
  227. package/src/{server-auth → server/auth}/providers/ServerAuthProvider.ts +51 -8
  228. package/src/{server-cookies → server/cookies}/index.ts +2 -1
  229. package/src/server/{index.ts → core/index.ts} +7 -0
  230. package/src/server/{primitives → core/primitives}/$action.ts +10 -1
  231. package/src/server/{providers → core/providers}/ServerBodyParserProvider.ts +11 -5
  232. package/src/server/{providers → core/providers}/ServerRouterProvider.ts +13 -7
  233. package/src/{server-rate-limit → server/rate-limit}/index.ts +1 -1
  234. package/src/{server-swagger → server/swagger}/providers/ServerSwaggerProvider.ts +1 -0
  235. package/src/thread/primitives/$thread.ts +2 -2
  236. package/src/vite/index.ts +0 -2
  237. package/src/vite/tasks/buildServer.ts +3 -4
  238. package/src/vite/tasks/copyAssets.ts +32 -8
  239. package/src/vite/tasks/generateCloudflare.ts +35 -19
  240. package/src/vite/tasks/generateDocker.ts +18 -4
  241. package/src/vite/tasks/generateSitemap.ts +5 -7
  242. package/src/vite/tasks/generateVercel.ts +76 -41
  243. package/src/vite/tasks/runAlepha.ts +16 -1
  244. package/src/websocket/providers/NodeWebSocketServerProvider.ts +3 -11
  245. package/src/websocket/services/WebSocketClient.ts +3 -3
  246. package/dist/api-files/index.browser.js.map +0 -1
  247. package/dist/api-files/index.js.map +0 -1
  248. package/dist/api-jobs/index.browser.js.map +0 -1
  249. package/dist/api-jobs/index.js.map +0 -1
  250. package/dist/api-notifications/index.browser.js.map +0 -1
  251. package/dist/api-notifications/index.d.ts +0 -327
  252. package/dist/api-notifications/index.js.map +0 -1
  253. package/dist/api-parameters/index.browser.js +0 -29
  254. package/dist/api-parameters/index.browser.js.map +0 -1
  255. package/dist/api-parameters/index.d.ts +0 -83
  256. package/dist/api-parameters/index.js +0 -63
  257. package/dist/api-parameters/index.js.map +0 -1
  258. package/dist/api-users/index.browser.js.map +0 -1
  259. package/dist/api-users/index.js.map +0 -1
  260. package/dist/api-verifications/index.browser.js.map +0 -1
  261. package/dist/api-verifications/index.d.ts +0 -229
  262. package/dist/api-verifications/index.js.map +0 -1
  263. package/dist/cache/index.js.map +0 -1
  264. package/dist/cache-redis/index.js.map +0 -1
  265. package/dist/cli/dist-BlfFtOk2.js +0 -2770
  266. package/dist/cli/dist-BlfFtOk2.js.map +0 -1
  267. package/dist/lock/index.js.map +0 -1
  268. package/dist/lock-redis/index.js.map +0 -1
  269. package/dist/queue/index.d.ts +0 -1265
  270. package/dist/queue/index.js +0 -1037
  271. package/dist/queue/index.js.map +0 -1
  272. package/dist/queue-redis/index.d.ts +0 -82
  273. package/dist/queue-redis/index.js +0 -872
  274. package/dist/queue-redis/index.js.map +0 -1
  275. package/dist/server/index.browser.js.map +0 -1
  276. package/dist/server/index.js.map +0 -1
  277. package/dist/server-auth/index.browser.js.map +0 -1
  278. package/dist/server-auth/index.js +0 -1943
  279. package/dist/server-auth/index.js.map +0 -1
  280. package/dist/server-cache/index.js.map +0 -1
  281. package/dist/server-compress/index.js.map +0 -1
  282. package/dist/server-cookies/index.browser.js.map +0 -1
  283. package/dist/server-cookies/index.js.map +0 -1
  284. package/dist/server-cors/index.js.map +0 -1
  285. package/dist/server-health/index.js.map +0 -1
  286. package/dist/server-helmet/index.js.map +0 -1
  287. package/dist/server-links/index.browser.js.map +0 -1
  288. package/dist/server-links/index.js.map +0 -1
  289. package/dist/server-metrics/index.js +0 -4532
  290. package/dist/server-metrics/index.js.map +0 -1
  291. package/dist/server-multipart/index.js.map +0 -1
  292. package/dist/server-proxy/index.js.map +0 -1
  293. package/dist/server-rate-limit/index.js.map +0 -1
  294. package/dist/server-security/index.browser.js.map +0 -1
  295. package/dist/server-security/index.js.map +0 -1
  296. package/dist/server-static/index.js.map +0 -1
  297. package/dist/server-swagger/index.js.map +0 -1
  298. package/dist/topic/index.js.map +0 -1
  299. package/dist/topic-redis/index.js.map +0 -1
  300. package/src/api-parameters/controllers/ParameterController.ts +0 -45
  301. package/src/api-parameters/entities/parameters.ts +0 -30
  302. package/src/api-parameters/index.ts +0 -21
  303. package/src/api-parameters/primitives/$config.ts +0 -79
  304. package/src/api-parameters/services/ParameterStore.ts +0 -23
  305. package/src/queue/interfaces/QueueJob.ts +0 -459
  306. package/src/queue/providers/MemoryQueueProvider.ts +0 -850
  307. package/src/queue/providers/QueueProvider.ts +0 -319
  308. package/src/queue/providers/WorkerProvider.ts +0 -344
  309. package/src/queue-redis/providers/RedisQueueProvider.ts +0 -1209
  310. /package/src/{api-files → api/files}/controllers/FileController.ts +0 -0
  311. /package/src/{api-files → api/files}/controllers/StorageStatsController.ts +0 -0
  312. /package/src/{api-files → api/files}/entities/files.ts +0 -0
  313. /package/src/{api-files → api/files}/index.browser.ts +0 -0
  314. /package/src/{api-files → api/files}/jobs/FileJobs.ts +0 -0
  315. /package/src/{api-files → api/files}/schemas/fileQuerySchema.ts +0 -0
  316. /package/src/{api-files → api/files}/schemas/fileResourceSchema.ts +0 -0
  317. /package/src/{api-files → api/files}/schemas/storageStatsSchema.ts +0 -0
  318. /package/src/{api-files → api/files}/services/FileService.ts +0 -0
  319. /package/src/{api-jobs → api/jobs}/controllers/JobController.ts +0 -0
  320. /package/src/{api-jobs → api/jobs}/entities/jobExecutions.ts +0 -0
  321. /package/src/{api-jobs → api/jobs}/index.browser.ts +0 -0
  322. /package/src/{api-jobs → api/jobs}/index.ts +0 -0
  323. /package/src/{api-jobs → api/jobs}/primitives/$job.ts +0 -0
  324. /package/src/{api-jobs → api/jobs}/providers/JobProvider.ts +0 -0
  325. /package/src/{api-jobs → api/jobs}/schemas/jobExecutionQuerySchema.ts +0 -0
  326. /package/src/{api-jobs → api/jobs}/schemas/jobExecutionResourceSchema.ts +0 -0
  327. /package/src/{api-jobs → api/jobs}/schemas/triggerJobSchema.ts +0 -0
  328. /package/src/{api-jobs → api/jobs}/services/JobService.ts +0 -0
  329. /package/src/{api-notifications → api/notifications}/controllers/NotificationController.ts +0 -0
  330. /package/src/{api-notifications → api/notifications}/entities/notifications.ts +0 -0
  331. /package/src/{api-notifications → api/notifications}/index.browser.ts +0 -0
  332. /package/src/{api-notifications → api/notifications}/index.ts +0 -0
  333. /package/src/{api-notifications → api/notifications}/jobs/NotificationJobs.ts +0 -0
  334. /package/src/{api-notifications → api/notifications}/primitives/$notification.ts +0 -0
  335. /package/src/{api-notifications → api/notifications}/queues/NotificationQueues.ts +0 -0
  336. /package/src/{api-notifications → api/notifications}/schemas/notificationContactPreferencesSchema.ts +0 -0
  337. /package/src/{api-notifications → api/notifications}/schemas/notificationContactSchema.ts +0 -0
  338. /package/src/{api-notifications → api/notifications}/schemas/notificationCreateSchema.ts +0 -0
  339. /package/src/{api-notifications → api/notifications}/schemas/notificationQuerySchema.ts +0 -0
  340. /package/src/{api-notifications → api/notifications}/services/NotificationSenderService.ts +0 -0
  341. /package/src/{api-notifications → api/notifications}/services/NotificationService.ts +0 -0
  342. /package/src/{api-parameters → api/parameters}/index.browser.ts +0 -0
  343. /package/src/{api-users → api/users}/controllers/IdentityController.ts +0 -0
  344. /package/src/{api-users → api/users}/controllers/SessionController.ts +0 -0
  345. /package/src/{api-users → api/users}/controllers/UserController.ts +0 -0
  346. /package/src/{api-users → api/users}/entities/identities.ts +0 -0
  347. /package/src/{api-users → api/users}/entities/sessions.ts +0 -0
  348. /package/src/{api-users → api/users}/entities/users.ts +0 -0
  349. /package/src/{api-users → api/users}/index.browser.ts +0 -0
  350. /package/src/{api-users → api/users}/notifications/UserNotifications.ts +0 -0
  351. /package/src/{api-users → api/users}/schemas/completePasswordResetRequestSchema.ts +0 -0
  352. /package/src/{api-users → api/users}/schemas/completeRegistrationRequestSchema.ts +0 -0
  353. /package/src/{api-users → api/users}/schemas/createUserSchema.ts +0 -0
  354. /package/src/{api-users → api/users}/schemas/identityQuerySchema.ts +0 -0
  355. /package/src/{api-users → api/users}/schemas/identityResourceSchema.ts +0 -0
  356. /package/src/{api-users → api/users}/schemas/loginSchema.ts +0 -0
  357. /package/src/{api-users → api/users}/schemas/passwordResetIntentResponseSchema.ts +0 -0
  358. /package/src/{api-users → api/users}/schemas/registerQuerySchema.ts +0 -0
  359. /package/src/{api-users → api/users}/schemas/registerRequestSchema.ts +0 -0
  360. /package/src/{api-users → api/users}/schemas/registerResponseSchema.ts +0 -0
  361. /package/src/{api-users → api/users}/schemas/registerSchema.ts +0 -0
  362. /package/src/{api-users → api/users}/schemas/registrationIntentResponseSchema.ts +0 -0
  363. /package/src/{api-users → api/users}/schemas/resetPasswordSchema.ts +0 -0
  364. /package/src/{api-users → api/users}/schemas/sessionQuerySchema.ts +0 -0
  365. /package/src/{api-users → api/users}/schemas/sessionResourceSchema.ts +0 -0
  366. /package/src/{api-users → api/users}/schemas/updateUserSchema.ts +0 -0
  367. /package/src/{api-users → api/users}/schemas/userQuerySchema.ts +0 -0
  368. /package/src/{api-users → api/users}/schemas/userRealmConfigSchema.ts +0 -0
  369. /package/src/{api-users → api/users}/schemas/userResourceSchema.ts +0 -0
  370. /package/src/{api-users → api/users}/services/CredentialService.ts +0 -0
  371. /package/src/{api-users → api/users}/services/IdentityService.ts +0 -0
  372. /package/src/{api-users → api/users}/services/SessionCrudService.ts +0 -0
  373. /package/src/{api-verifications → api/verifications}/controllers/VerificationController.ts +0 -0
  374. /package/src/{api-verifications → api/verifications}/entities/verifications.ts +0 -0
  375. /package/src/{api-verifications → api/verifications}/index.browser.ts +0 -0
  376. /package/src/{api-verifications → api/verifications}/jobs/VerificationJobs.ts +0 -0
  377. /package/src/{api-verifications → api/verifications}/parameters/VerificationParameters.ts +0 -0
  378. /package/src/{api-verifications → api/verifications}/schemas/requestVerificationCodeResponseSchema.ts +0 -0
  379. /package/src/{api-verifications → api/verifications}/schemas/validateVerificationCodeResponseSchema.ts +0 -0
  380. /package/src/{api-verifications → api/verifications}/schemas/verificationSettingsSchema.ts +0 -0
  381. /package/src/{api-verifications → api/verifications}/schemas/verificationTypeEnumSchema.ts +0 -0
  382. /package/src/{api-verifications → api/verifications}/services/VerificationService.ts +0 -0
  383. /package/src/cache/{errors → core/errors}/CacheError.ts +0 -0
  384. /package/src/cache/{index.ts → core/index.ts} +0 -0
  385. /package/src/cache/{primitives → core/primitives}/$cache.ts +0 -0
  386. /package/src/cache/{providers → core/providers}/CacheProvider.ts +0 -0
  387. /package/src/cache/{providers → core/providers}/MemoryCacheProvider.ts +0 -0
  388. /package/src/{cache-redis → cache/redis}/index.ts +0 -0
  389. /package/src/{cache-redis → cache/redis}/providers/RedisCacheProvider.ts +0 -0
  390. /package/src/lock/{index.ts → core/index.ts} +0 -0
  391. /package/src/lock/{primitives → core/primitives}/$lock.ts +0 -0
  392. /package/src/lock/{providers → core/providers}/LockProvider.ts +0 -0
  393. /package/src/lock/{providers → core/providers}/LockTopicProvider.ts +0 -0
  394. /package/src/lock/{providers → core/providers}/MemoryLockProvider.ts +0 -0
  395. /package/src/{lock-redis → lock/redis}/index.ts +0 -0
  396. /package/src/{lock-redis → lock/redis}/providers/RedisLockProvider.ts +0 -0
  397. /package/src/queue/{primitives → core/primitives}/$consumer.ts +0 -0
  398. /package/src/{queue-redis → queue/redis}/index.ts +0 -0
  399. /package/src/{server-auth → server/auth}/constants/routes.ts +0 -0
  400. /package/src/{server-auth → server/auth}/index.browser.ts +0 -0
  401. /package/src/{server-auth → server/auth}/index.shared.ts +0 -0
  402. /package/src/{server-auth → server/auth}/index.ts +0 -0
  403. /package/src/{server-auth → server/auth}/primitives/$authApple.ts +0 -0
  404. /package/src/{server-auth → server/auth}/primitives/$authCredentials.ts +0 -0
  405. /package/src/{server-auth → server/auth}/primitives/$authGithub.ts +0 -0
  406. /package/src/{server-auth → server/auth}/primitives/$authGoogle.ts +0 -0
  407. /package/src/{server-auth → server/auth}/schemas/authenticationProviderSchema.ts +0 -0
  408. /package/src/{server-auth → server/auth}/schemas/tokenResponseSchema.ts +0 -0
  409. /package/src/{server-auth → server/auth}/schemas/tokensSchema.ts +0 -0
  410. /package/src/{server-auth → server/auth}/schemas/userinfoResponseSchema.ts +0 -0
  411. /package/src/{server-cache → server/cache}/index.ts +0 -0
  412. /package/src/{server-cache → server/cache}/providers/ServerCacheProvider.ts +0 -0
  413. /package/src/{server-compress → server/compress}/index.ts +0 -0
  414. /package/src/{server-compress → server/compress}/providers/ServerCompressProvider.ts +0 -0
  415. /package/src/{server-cookies → server/cookies}/index.browser.ts +0 -0
  416. /package/src/{server-cookies → server/cookies}/primitives/$cookie.browser.ts +0 -0
  417. /package/src/{server-cookies → server/cookies}/primitives/$cookie.ts +0 -0
  418. /package/src/{server-cookies → server/cookies}/providers/ServerCookiesProvider.ts +0 -0
  419. /package/src/{server-cookies → server/cookies}/services/CookieParser.ts +0 -0
  420. /package/src/server/{constants → core/constants}/routeMethods.ts +0 -0
  421. /package/src/server/{errors → core/errors}/BadRequestError.ts +0 -0
  422. /package/src/server/{errors → core/errors}/ConflictError.ts +0 -0
  423. /package/src/server/{errors → core/errors}/ForbiddenError.ts +0 -0
  424. /package/src/server/{errors → core/errors}/HttpError.ts +0 -0
  425. /package/src/server/{errors → core/errors}/NotFoundError.ts +0 -0
  426. /package/src/server/{errors → core/errors}/UnauthorizedError.ts +0 -0
  427. /package/src/server/{errors → core/errors}/ValidationError.ts +0 -0
  428. /package/src/server/{helpers → core/helpers}/ServerReply.ts +0 -0
  429. /package/src/server/{helpers → core/helpers}/isMultipart.ts +0 -0
  430. /package/src/server/{index.browser.ts → core/index.browser.ts} +0 -0
  431. /package/src/server/{index.shared.ts → core/index.shared.ts} +0 -0
  432. /package/src/server/{interfaces → core/interfaces}/ServerRequest.ts +0 -0
  433. /package/src/server/{primitives → core/primitives}/$route.ts +0 -0
  434. /package/src/server/{providers → core/providers}/BunHttpServerProvider.ts +0 -0
  435. /package/src/server/{providers → core/providers}/NodeHttpServerProvider.ts +0 -0
  436. /package/src/server/{providers → core/providers}/ServerLoggerProvider.ts +0 -0
  437. /package/src/server/{providers → core/providers}/ServerNotReadyProvider.ts +0 -0
  438. /package/src/server/{providers → core/providers}/ServerProvider.ts +0 -0
  439. /package/src/server/{providers → core/providers}/ServerTimingProvider.ts +0 -0
  440. /package/src/server/{schemas → core/schemas}/errorSchema.ts +0 -0
  441. /package/src/server/{schemas → core/schemas}/okSchema.ts +0 -0
  442. /package/src/server/{services → core/services}/HttpClient.ts +0 -0
  443. /package/src/server/{services → core/services}/ServerRequestParser.ts +0 -0
  444. /package/src/server/{services → core/services}/UserAgentParser.ts +0 -0
  445. /package/src/{server-cors → server/cors}/index.ts +0 -0
  446. /package/src/{server-cors → server/cors}/primitives/$cors.ts +0 -0
  447. /package/src/{server-cors → server/cors}/providers/ServerCorsProvider.ts +0 -0
  448. /package/src/{server-health → server/health}/index.ts +0 -0
  449. /package/src/{server-health → server/health}/providers/ServerHealthProvider.ts +0 -0
  450. /package/src/{server-health → server/health}/schemas/healthSchema.ts +0 -0
  451. /package/src/{server-helmet → server/helmet}/index.ts +0 -0
  452. /package/src/{server-helmet → server/helmet}/providers/ServerHelmetProvider.ts +0 -0
  453. /package/src/{server-links → server/links}/index.browser.ts +0 -0
  454. /package/src/{server-links → server/links}/index.ts +0 -0
  455. /package/src/{server-links → server/links}/primitives/$client.ts +0 -0
  456. /package/src/{server-links → server/links}/primitives/$remote.ts +0 -0
  457. /package/src/{server-links → server/links}/providers/LinkProvider.ts +0 -0
  458. /package/src/{server-links → server/links}/providers/RemotePrimitiveProvider.ts +0 -0
  459. /package/src/{server-links → server/links}/providers/ServerLinksProvider.ts +0 -0
  460. /package/src/{server-links → server/links}/schemas/apiLinksResponseSchema.ts +0 -0
  461. /package/src/{server-metrics → server/metrics}/index.ts +0 -0
  462. /package/src/{server-metrics → server/metrics}/providers/ServerMetricsProvider.ts +0 -0
  463. /package/src/{server-multipart → server/multipart}/index.ts +0 -0
  464. /package/src/{server-multipart → server/multipart}/providers/ServerMultipartProvider.ts +0 -0
  465. /package/src/{server-proxy → server/proxy}/index.ts +0 -0
  466. /package/src/{server-proxy → server/proxy}/primitives/$proxy.ts +0 -0
  467. /package/src/{server-proxy → server/proxy}/providers/ServerProxyProvider.ts +0 -0
  468. /package/src/{server-rate-limit → server/rate-limit}/primitives/$rateLimit.ts +0 -0
  469. /package/src/{server-rate-limit → server/rate-limit}/providers/ServerRateLimitProvider.ts +0 -0
  470. /package/src/{server-security → server/security}/index.browser.ts +0 -0
  471. /package/src/{server-security → server/security}/index.ts +0 -0
  472. /package/src/{server-security → server/security}/primitives/$basicAuth.ts +0 -0
  473. /package/src/{server-security → server/security}/providers/ServerBasicAuthProvider.ts +0 -0
  474. /package/src/{server-security → server/security}/providers/ServerSecurityProvider.ts +0 -0
  475. /package/src/{server-static → server/static}/index.ts +0 -0
  476. /package/src/{server-static → server/static}/primitives/$serve.ts +0 -0
  477. /package/src/{server-static → server/static}/providers/ServerStaticProvider.ts +0 -0
  478. /package/src/{server-swagger → server/swagger}/index.ts +0 -0
  479. /package/src/{server-swagger → server/swagger}/primitives/$swagger.ts +0 -0
  480. /package/src/topic/{errors → core/errors}/TopicTimeoutError.ts +0 -0
  481. /package/src/topic/{index.ts → core/index.ts} +0 -0
  482. /package/src/topic/{primitives → core/primitives}/$subscriber.ts +0 -0
  483. /package/src/topic/{primitives → core/primitives}/$topic.ts +0 -0
  484. /package/src/topic/{providers → core/providers}/MemoryTopicProvider.ts +0 -0
  485. /package/src/topic/{providers → core/providers}/TopicProvider.ts +0 -0
  486. /package/src/{topic-redis → topic/redis}/index.ts +0 -0
  487. /package/src/{topic-redis → topic/redis}/providers/RedisTopicProvider.ts +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.browser.js","names":["notifications"],"sources":["../../src/api-notifications/entities/notifications.ts","../../src/api-notifications/schemas/notificationQuerySchema.ts","../../src/api-notifications/primitives/$notification.ts","../../src/api-notifications/services/NotificationSenderService.ts","../../src/api-notifications/queues/NotificationQueues.ts","../../src/api-notifications/schemas/notificationCreateSchema.ts","../../src/api-notifications/services/NotificationService.ts","../../src/api-notifications/controllers/NotificationController.ts","../../src/api-notifications/schemas/notificationContactPreferencesSchema.ts","../../src/api-notifications/schemas/notificationContactSchema.ts","../../src/api-notifications/index.browser.ts"],"sourcesContent":["import { type Static, t } from \"alepha\";\nimport { $entity, pg } from \"alepha/orm\";\n\nexport const notifications = $entity({\n name: \"notifications\",\n schema: t.object({\n id: pg.primaryKey(t.uuid()),\n\n version: pg.version(),\n\n createdAt: pg.createdAt(),\n\n updatedAt: pg.updatedAt(),\n\n // -----------------------------------------------------------------------------------------------------------------\n\n type: t.enum([\"email\", \"sms\"]),\n\n template: t.text(), // e.g. 'resetPassword'\n\n category: t.optional(\n t.text({\n description:\n \"For grouping related notifications (e.g., 'authentication', 'marketing'). Contact can filter notifications by category.\",\n }),\n ),\n\n critical: t.optional(\n t.boolean({\n description:\n \"Prioritize delivery of this notification. Set to true for important system alerts.\",\n }),\n ),\n\n sensitive: t.optional(\n t.boolean({\n description:\n \"Message won't be logged or stored in plain text. Set to true when notification contains passwords or codes.\",\n }),\n ),\n\n // -----------------------------------------------------------------------------------------------------------------\n\n contact: t.text(), // e.g. email address or phone number or user ID or whatever\n\n variables: t.optional(t.record(t.text(), t.any())),\n\n scheduledAt: t.optional(\n t.datetime({\n description:\n \"When set, the notification will be sent at or after this date/time.\",\n }),\n ),\n\n // -----------------------------------------------------------------------------------------------------------------\n\n sentAt: t.optional(t.datetime()),\n\n error: t.optional(\n t.object({\n at: t.datetime(),\n name: t.text(),\n message: t.text({ size: \"rich\" }),\n }),\n ),\n\n // TODO: retryCount, lastRetryAt, etc.\n }),\n});\n\nexport type NotificationEntity = Static<typeof notifications.schema>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\nimport { pageQuerySchema } from \"alepha/orm\";\n\nexport const notificationQuerySchema = t.extend(pageQuerySchema, {\n type: t.optional(t.enum([\"email\", \"sms\"])),\n template: t.optional(t.string()),\n contact: t.optional(t.string()),\n category: t.optional(t.string()),\n status: t.optional(t.enum([\"pending\", \"sent\", \"failed\"])),\n});\n\nexport type NotificationQuery = Static<typeof notificationQuerySchema>;\n","import {\n $inject,\n createPrimitive,\n KIND,\n Primitive,\n type Static,\n type StaticEncode,\n type TObject,\n} from \"alepha\";\nimport { NotificationService } from \"../services/NotificationService.ts\";\n\n/**\n * Creates a notification primitive for managing email/SMS notification templates.\n *\n * Provides type-safe, reusable notification templates with multi-language support,\n * variable substitution, and categorization for different notification channels.\n *\n * @example\n * ```ts\n * class NotificationTemplates {\n * welcomeEmail = $notification({\n * name: \"welcome-email\",\n * category: \"onboarding\",\n * schema: t.object({ username: t.text(), activationLink: t.text() }),\n * email: {\n * subject: \"Welcome to our platform!\",\n * body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}`\n * }\n * });\n *\n * async sendWelcome(user: User) {\n * await this.welcomeEmail.push({\n * variables: { username: user.name, activationLink: generateLink() },\n * contact: user.email\n * });\n * }\n * }\n * ```\n */\nexport const $notification = <T extends TObject>(\n options: NotificationPrimitiveOptions<T>,\n) => createPrimitive(NotificationPrimitive<T>, options);\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPrimitiveOptions<T extends TObject>\n extends NotificationMessage<T> {\n name?: string;\n description?: string;\n category?: string;\n critical?: boolean;\n sensitive?: boolean;\n translations?: {\n // e.g., \"en\", \"fr\", even \"en-US\"\n [lang: string]: NotificationMessage<T>;\n };\n schema: T;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class NotificationPrimitive<T extends TObject> extends Primitive<\n NotificationPrimitiveOptions<T>\n> {\n protected readonly notificationService = $inject(NotificationService);\n\n public get name() {\n return this.options.name ?? `${this.config.propertyKey}`;\n }\n\n public async push(options: NotificationPushOptions<T>) {\n if (this.options.email) {\n await this.notificationService.createNotification({\n ...options,\n type: \"email\",\n template: this.name,\n });\n }\n }\n\n public configure(options: Partial<NotificationPrimitiveOptions<T>>) {\n Object.assign(this.options, options);\n }\n}\n\n$notification[KIND] = NotificationPrimitive;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPushOptions<T extends TObject> {\n variables: StaticEncode<T>;\n contact: string;\n}\n\nexport interface NotificationMessage<T extends TObject> {\n email?: {\n subject: string;\n body: string | ((variables: Static<T>) => string);\n };\n sms?: {\n message: string | ((variables: Static<T>) => string);\n };\n}\n","import { $inject, Alepha, AlephaError } from \"alepha\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { EmailProvider } from \"alepha/email\";\nimport { $logger } from \"alepha/logger\";\nimport { $repository } from \"alepha/orm\";\nimport { SmsProvider } from \"alepha/sms\";\nimport {\n type NotificationEntity,\n notifications,\n} from \"../entities/notifications.ts\";\nimport { $notification } from \"../primitives/$notification.ts\";\n\nexport class NotificationSenderService {\n protected readonly alepha = $inject(Alepha);\n protected readonly log = $logger();\n protected readonly notificationRepository = $repository(notifications);\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly emailProvider = $inject(EmailProvider);\n protected readonly smsProvider = $inject(SmsProvider);\n\n public async send(notificationId: string | NotificationEntity) {\n this.log.trace(\"Sending notification\", {\n notificationId:\n typeof notificationId === \"string\" ? notificationId : notificationId.id,\n });\n\n const notification =\n typeof notificationId === \"string\"\n ? await this.notificationRepository.findById(notificationId)\n : notificationId;\n\n if (notification.sentAt) {\n this.log.debug(\"Notification already sent\", {\n notificationId: notification.id,\n sentAt: notification.sentAt,\n });\n return;\n }\n\n this.log.debug(\"Processing notification\", {\n id: notification.id,\n type: notification.type,\n template: notification.template,\n contact: notification.contact,\n });\n\n try {\n if (notification.type === \"email\") {\n await this.emailProvider.send(this.renderEmail(notification));\n notification.sentAt = this.dateTimeProvider.nowISOString();\n this.log.info(\"Email notification sent\", {\n id: notification.id,\n template: notification.template,\n contact: notification.contact,\n });\n }\n if (notification.type === \"sms\") {\n await this.smsProvider.send(this.renderSms(notification));\n notification.sentAt = this.dateTimeProvider.nowISOString();\n this.log.info(\"SMS notification sent\", {\n id: notification.id,\n template: notification.template,\n contact: notification.contact,\n });\n }\n } catch (e) {\n this.log.error(\"Failed to send notification\", {\n id: notification.id,\n type: notification.type,\n template: notification.template,\n contact: notification.contact,\n error: e,\n });\n if (e instanceof Error) {\n notification.error = {\n at: this.dateTimeProvider.nowISOString(),\n name: e.name,\n message: e.message,\n };\n }\n } finally {\n await this.notificationRepository.save(notification);\n }\n }\n\n public renderSms(notification: NotificationEntity) {\n this.log.trace(\"Rendering SMS notification\", {\n id: notification.id,\n template: notification.template,\n });\n\n const { variables, contact, template } = this.load(notification);\n\n const sms = template.options.sms;\n if (!sms) {\n this.log.error(\"Notification template has no SMS defined\", {\n id: notification.id,\n template: notification.template,\n });\n throw new AlephaError(\n `Notification template ${notification.template} has no sms defined`,\n );\n }\n\n this.log.debug(\"Rendering SMS\", {\n template: notification.template,\n contact,\n });\n\n const message =\n typeof sms.message === \"function\"\n ? sms.message(variables as any)\n : sms.message;\n\n return {\n to: contact,\n message,\n };\n }\n\n public renderEmail(notification: NotificationEntity) {\n this.log.trace(\"Rendering email notification\", {\n id: notification.id,\n template: notification.template,\n });\n\n const { variables, contact, template } = this.load(notification);\n\n const email = template.options.email;\n if (!email) {\n this.log.error(\"Notification template has no email defined\", {\n id: notification.id,\n template: notification.template,\n });\n throw new AlephaError(\n `Notification template ${notification.template} has no email defined`,\n );\n }\n\n this.log.debug(\"Rendering email\", {\n template: notification.template,\n contact,\n subject: email.subject,\n });\n\n const subject = email.subject;\n\n const body =\n typeof email.body === \"function\"\n ? email.body(variables as any)\n : email.body;\n\n return {\n to: contact,\n subject,\n body,\n };\n }\n\n protected load(notification: NotificationEntity) {\n const variables = notification.variables || {};\n const contact = notification.contact;\n const template = this.alepha\n .primitives($notification)\n .find((it) => it.name === notification.template);\n\n if (!template) {\n this.log.error(\"Notification template not found\", {\n id: notification.id,\n template: notification.template,\n });\n throw new AlephaError(\n `No notification template found for ${notification.template}`,\n );\n }\n\n return {\n template,\n variables,\n contact,\n };\n }\n}\n","import { $inject, t } from \"alepha\";\nimport { $queue } from \"alepha/queue\";\nimport { NotificationSenderService } from \"../services/NotificationSenderService.ts\";\n\nexport class NotificationQueues {\n protected readonly notificationSenderService = $inject(\n NotificationSenderService,\n );\n\n public readonly processNotification = $queue({\n description: \"Queue for processing notifications\",\n schema: t.object({\n notificationId: t.string({ format: \"uuid\" }),\n }),\n handler: async (message) => {\n await this.notificationSenderService.send(message.payload.notificationId);\n },\n });\n}\n","import { type Static, t } from \"alepha\";\nimport { notifications } from \"../entities/notifications.ts\";\n\nexport const notificationCreateSchema = t.pick(notifications.schema, [\n \"type\",\n \"contact\",\n \"template\",\n \"variables\",\n]);\n\nexport type NotificationCreate = Static<typeof notificationCreateSchema>;\n","import { $env, $inject, Alepha, type Static, t } from \"alepha\";\nimport { $batch } from \"alepha/batch\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport { $repository, type Page } from \"alepha/orm\";\nimport {\n type NotificationEntity,\n notifications,\n} from \"../entities/notifications.ts\";\nimport { NotificationQueues } from \"../queues/NotificationQueues.ts\";\nimport {\n type NotificationCreate,\n notificationCreateSchema,\n} from \"../schemas/notificationCreateSchema.ts\";\nimport type { NotificationQuery } from \"../schemas/notificationQuerySchema.ts\";\nimport { NotificationSenderService } from \"./NotificationSenderService.ts\";\n\nexport const notificationServiceEnvSchema = t.object({\n NOTIFICATION_QUEUE: t.optional(\n t.boolean({\n description:\n \"If true, notifications will be queued instead of sent immediately\",\n }),\n ),\n});\n\ndeclare module \"alepha\" {\n interface Env extends Partial<Static<typeof notificationServiceEnvSchema>> {}\n}\n\nexport class NotificationService {\n protected readonly alepha = $inject(Alepha);\n protected readonly log = $logger();\n protected readonly env = $env(notificationServiceEnvSchema);\n protected readonly notificationRepository = $repository(notifications);\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly notificationSenderService = $inject(\n NotificationSenderService,\n );\n\n public readonly notificationBatch = $batch({\n maxSize: 100,\n maxDuration: [15, \"seconds\"],\n schema: notificationCreateSchema,\n handler: async (notifications: NotificationCreate[]) => {\n this.log.debug(\"Processing notification batch\", {\n size: notifications.length,\n templates: [...new Set(notifications.map((n) => n.template))],\n });\n\n const entities =\n await this.notificationRepository.createMany(notifications);\n\n await this.alepha\n .inject(NotificationQueues)\n .processNotification.push(\n ...entities.map((it) => ({ notificationId: it.id })),\n );\n\n this.log.info(\"Notification batch queued\", {\n count: entities.length,\n ids: entities.map((it) => it.id),\n });\n },\n });\n\n public async findNotificationById(id: string) {\n this.log.trace(\"Finding notification by ID\", { id });\n return this.notificationRepository.findOne({ where: { id } });\n }\n\n public async findNotifications(\n q: NotificationQuery = {},\n ): Promise<Page<NotificationEntity>> {\n this.log.trace(\"Finding notifications\", { query: q });\n q.sort ??= \"-createdAt\";\n\n const where = this.notificationRepository.createQueryWhere();\n\n if (q.type) {\n where.type = { eq: q.type };\n }\n\n if (q.template) {\n where.template = { like: `%${q.template}%` };\n }\n\n if (q.contact) {\n where.contact = { like: `%${q.contact}%` };\n }\n\n if (q.category) {\n where.category = { eq: q.category };\n }\n\n if (q.status) {\n if (q.status === \"sent\") {\n where.sentAt = { isNotNull: true };\n where.error = { isNull: true };\n } else if (q.status === \"failed\") {\n where.error = { isNotNull: true };\n } else if (q.status === \"pending\") {\n where.sentAt = { isNull: true };\n where.error = { isNull: true };\n }\n }\n\n return this.notificationRepository.paginate(q, { where }, { count: true });\n }\n\n /**\n * Create a new notification.\n */\n public async createNotification(entry: NotificationCreate): Promise<void> {\n this.log.trace(\"Creating notification\", {\n template: entry.template,\n type: entry.type,\n contact: entry.contact,\n });\n\n if (\n this.env.NOTIFICATION_QUEUE !== true ||\n this.alepha.isServerless() ||\n this.alepha.isTest()\n ) {\n this.log.debug(\"Sending notification immediately\", {\n template: entry.template,\n type: entry.type,\n contact: entry.contact,\n });\n const notification = await this.notificationRepository.create(entry);\n await this.notificationSenderService.send(notification);\n return;\n }\n\n this.log.debug(\"Queuing notification to batch\", {\n template: entry.template,\n type: entry.type,\n contact: entry.contact,\n });\n\n this.notificationBatch.push(entry).catch((e) => {\n this.log.error(\"Failed to push notification to batch\", {\n template: entry.template,\n type: entry.type,\n contact: entry.contact,\n error: e,\n });\n });\n }\n}\n","import { $inject } from \"alepha\";\nimport { pg } from \"alepha/orm\";\nimport { $action } from \"alepha/server\";\nimport { notifications } from \"../entities/notifications.ts\";\nimport { notificationQuerySchema } from \"../schemas/notificationQuerySchema.ts\";\nimport { NotificationService } from \"../services/NotificationService.ts\";\n\nexport class NotificationController {\n protected readonly url = \"/notifications\";\n protected readonly group = \"notifications\";\n protected readonly notificationService = $inject(NotificationService);\n\n /**\n * Find notifications with pagination and filtering.\n */\n public readonly findNotifications = $action({\n path: this.url,\n group: this.group,\n description: \"Find notifications with pagination and filtering\",\n schema: {\n query: notificationQuerySchema,\n response: pg.page(notifications.schema),\n },\n handler: ({ query }) => this.notificationService.findNotifications(query),\n });\n}\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactPreferencesSchema = t.object({\n language: t.optional(t.text()),\n exclude: t.array(t.text()),\n});\n\nexport type NotificationContactPreferences = Static<\n typeof notificationContactPreferencesSchema\n>;\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactSchema = t.object({\n email: t.optional(t.email()),\n phoneNumber: t.optional(t.e164()),\n firstName: t.optional(t.shortText()),\n lastName: t.optional(t.text({ size: \"short\" })),\n language: t.optional(t.bcp47()),\n});\n\nexport type NotificationContact = Static<typeof notificationContactSchema>;\n","import { $module } from \"alepha\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./controllers/NotificationController.ts\";\nexport * from \"./entities/notifications.ts\";\nexport * from \"./schemas/notificationContactPreferencesSchema.ts\";\nexport * from \"./schemas/notificationContactSchema.ts\";\nexport * from \"./schemas/notificationCreateSchema.ts\";\nexport * from \"./schemas/notificationQuerySchema.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport const AlephaApiNotifications = $module({\n name: \"alepha.api.notifications\",\n services: [],\n});\n"],"m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zB,AAAmB,QAAQ;CAC3B,AAAmB,sBAAsB,QAAQ,oBAAoB;;;;CAKrE,AAAgB,oBAAoB,QAAQ;EAC1C,MAAM,KAAK;EACX,OAAO,KAAK;EACZ,aAAa;EACb,QAAQ;GACN,OAAO;GACP,UAAU,GAAG,KAAK,cAAc,OAAO;GACxC;EACD,UAAU,EAAE,YAAY,KAAK,oBAAoB,kBAAkB,MAAM;EAC1E,CAAC;;;;;ACtBJ,MAAa,uCAAuC,EAAE,OAAO;CAC3D,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC;CAC9B,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;CAC3B,CAAC;;;;ACHF,MAAa,4BAA4B,EAAE,OAAO;CAChD,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;CAC5B,aAAa,EAAE,SAAS,EAAE,MAAM,CAAC;CACjC,WAAW,EAAE,SAAS,EAAE,WAAW,CAAC;CACpC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC,CAAC;CAC/C,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,CAAC;;;;ACKF,MAAa,yBAAyB,QAAQ;CAC5C,MAAM;CACN,UAAU,EAAE;CACb,CAAC"}
@@ -1,327 +0,0 @@
1
- import * as alepha45 from "alepha";
2
- import { Alepha, KIND, Primitive, Static, StaticEncode, TObject } from "alepha";
3
- import * as alepha_orm15 from "alepha/orm";
4
- import { Page } from "alepha/orm";
5
- import * as alepha_server0 from "alepha/server";
6
- import * as alepha_batch0 from "alepha/batch";
7
- import { DateTimeProvider } from "alepha/datetime";
8
- import * as alepha_logger0 from "alepha/logger";
9
- import * as alepha_queue0 from "alepha/queue";
10
- import { EmailProvider } from "alepha/email";
11
- import { SmsProvider } from "alepha/sms";
12
-
13
- //#region ../../src/api-notifications/entities/notifications.d.ts
14
- declare const notifications: alepha_orm15.EntityPrimitive<alepha45.TObject<{
15
- id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
16
- version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
17
- createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
18
- updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
19
- type: alepha45.TUnsafe<"email" | "sms">;
20
- template: alepha45.TString;
21
- category: alepha45.TOptional<alepha45.TString>;
22
- critical: alepha45.TOptional<alepha45.TBoolean>;
23
- sensitive: alepha45.TOptional<alepha45.TBoolean>;
24
- contact: alepha45.TString;
25
- variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
26
- scheduledAt: alepha45.TOptional<alepha45.TString>;
27
- sentAt: alepha45.TOptional<alepha45.TString>;
28
- error: alepha45.TOptional<alepha45.TObject<{
29
- at: alepha45.TString;
30
- name: alepha45.TString;
31
- message: alepha45.TString;
32
- }>>;
33
- }>>;
34
- type NotificationEntity = Static<typeof notifications.schema>;
35
- //#endregion
36
- //#region ../../src/api-notifications/schemas/notificationCreateSchema.d.ts
37
- declare const notificationCreateSchema: alepha45.TObject<{
38
- type: alepha45.TUnsafe<"email" | "sms">;
39
- template: alepha45.TString;
40
- contact: alepha45.TString;
41
- variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
42
- }>;
43
- type NotificationCreate = Static<typeof notificationCreateSchema>;
44
- //#endregion
45
- //#region ../../src/api-notifications/schemas/notificationQuerySchema.d.ts
46
- declare const notificationQuerySchema: alepha45.TObject<{
47
- page: alepha45.TOptional<alepha45.TInteger>;
48
- size: alepha45.TOptional<alepha45.TInteger>;
49
- sort: alepha45.TOptional<alepha45.TString>;
50
- type: alepha45.TOptional<alepha45.TUnsafe<"email" | "sms">>;
51
- template: alepha45.TOptional<alepha45.TString>;
52
- contact: alepha45.TOptional<alepha45.TString>;
53
- category: alepha45.TOptional<alepha45.TString>;
54
- status: alepha45.TOptional<alepha45.TUnsafe<"pending" | "sent" | "failed">>;
55
- }>;
56
- type NotificationQuery = Static<typeof notificationQuerySchema>;
57
- //#endregion
58
- //#region ../../src/api-notifications/primitives/$notification.d.ts
59
- /**
60
- * Creates a notification primitive for managing email/SMS notification templates.
61
- *
62
- * Provides type-safe, reusable notification templates with multi-language support,
63
- * variable substitution, and categorization for different notification channels.
64
- *
65
- * @example
66
- * ```ts
67
- * class NotificationTemplates {
68
- * welcomeEmail = $notification({
69
- * name: "welcome-email",
70
- * category: "onboarding",
71
- * schema: t.object({ username: t.text(), activationLink: t.text() }),
72
- * email: {
73
- * subject: "Welcome to our platform!",
74
- * body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}`
75
- * }
76
- * });
77
- *
78
- * async sendWelcome(user: User) {
79
- * await this.welcomeEmail.push({
80
- * variables: { username: user.name, activationLink: generateLink() },
81
- * contact: user.email
82
- * });
83
- * }
84
- * }
85
- * ```
86
- */
87
- declare const $notification: {
88
- <T extends TObject>(options: NotificationPrimitiveOptions<T>): NotificationPrimitive<T>;
89
- [KIND]: typeof NotificationPrimitive;
90
- };
91
- interface NotificationPrimitiveOptions<T extends TObject> extends NotificationMessage<T> {
92
- name?: string;
93
- description?: string;
94
- category?: string;
95
- critical?: boolean;
96
- sensitive?: boolean;
97
- translations?: {
98
- [lang: string]: NotificationMessage<T>;
99
- };
100
- schema: T;
101
- }
102
- declare class NotificationPrimitive<T extends TObject> extends Primitive<NotificationPrimitiveOptions<T>> {
103
- protected readonly notificationService: NotificationService;
104
- get name(): string;
105
- push(options: NotificationPushOptions<T>): Promise<void>;
106
- configure(options: Partial<NotificationPrimitiveOptions<T>>): void;
107
- }
108
- interface NotificationPushOptions<T extends TObject> {
109
- variables: StaticEncode<T>;
110
- contact: string;
111
- }
112
- interface NotificationMessage<T extends TObject> {
113
- email?: {
114
- subject: string;
115
- body: string | ((variables: Static<T>) => string);
116
- };
117
- sms?: {
118
- message: string | ((variables: Static<T>) => string);
119
- };
120
- }
121
- //#endregion
122
- //#region ../../src/api-notifications/services/NotificationSenderService.d.ts
123
- declare class NotificationSenderService {
124
- protected readonly alepha: Alepha;
125
- protected readonly log: alepha_logger0.Logger;
126
- protected readonly notificationRepository: alepha_orm15.Repository<alepha45.TObject<{
127
- id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
128
- version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
129
- createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
130
- updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
131
- type: alepha45.TUnsafe<"email" | "sms">;
132
- template: alepha45.TString;
133
- category: alepha45.TOptional<alepha45.TString>;
134
- critical: alepha45.TOptional<alepha45.TBoolean>;
135
- sensitive: alepha45.TOptional<alepha45.TBoolean>;
136
- contact: alepha45.TString;
137
- variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
138
- scheduledAt: alepha45.TOptional<alepha45.TString>;
139
- sentAt: alepha45.TOptional<alepha45.TString>;
140
- error: alepha45.TOptional<alepha45.TObject<{
141
- at: alepha45.TString;
142
- name: alepha45.TString;
143
- message: alepha45.TString;
144
- }>>;
145
- }>>;
146
- protected readonly dateTimeProvider: DateTimeProvider;
147
- protected readonly emailProvider: EmailProvider;
148
- protected readonly smsProvider: SmsProvider;
149
- send(notificationId: string | NotificationEntity): Promise<void>;
150
- renderSms(notification: NotificationEntity): {
151
- to: string;
152
- message: string;
153
- };
154
- renderEmail(notification: NotificationEntity): {
155
- to: string;
156
- subject: string;
157
- body: string;
158
- };
159
- protected load(notification: NotificationEntity): {
160
- template: NotificationPrimitive<alepha45.TObject<alepha45.TProperties>>;
161
- variables: Record<string, any>;
162
- contact: string;
163
- };
164
- }
165
- //#endregion
166
- //#region ../../src/api-notifications/services/NotificationService.d.ts
167
- declare const notificationServiceEnvSchema: alepha45.TObject<{
168
- NOTIFICATION_QUEUE: alepha45.TOptional<alepha45.TBoolean>;
169
- }>;
170
- declare module "alepha" {
171
- interface Env extends Partial<Static<typeof notificationServiceEnvSchema>> {}
172
- }
173
- declare class NotificationService {
174
- protected readonly alepha: Alepha;
175
- protected readonly log: alepha_logger0.Logger;
176
- protected readonly env: {
177
- NOTIFICATION_QUEUE?: boolean | undefined;
178
- };
179
- protected readonly notificationRepository: alepha_orm15.Repository<alepha45.TObject<{
180
- id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
181
- version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
182
- createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
183
- updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
184
- type: alepha45.TUnsafe<"email" | "sms">;
185
- template: alepha45.TString;
186
- category: alepha45.TOptional<alepha45.TString>;
187
- critical: alepha45.TOptional<alepha45.TBoolean>;
188
- sensitive: alepha45.TOptional<alepha45.TBoolean>;
189
- contact: alepha45.TString;
190
- variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
191
- scheduledAt: alepha45.TOptional<alepha45.TString>;
192
- sentAt: alepha45.TOptional<alepha45.TString>;
193
- error: alepha45.TOptional<alepha45.TObject<{
194
- at: alepha45.TString;
195
- name: alepha45.TString;
196
- message: alepha45.TString;
197
- }>>;
198
- }>>;
199
- protected readonly dateTimeProvider: DateTimeProvider;
200
- protected readonly notificationSenderService: NotificationSenderService;
201
- readonly notificationBatch: alepha_batch0.BatchPrimitive<alepha45.TObject<{
202
- type: alepha45.TUnsafe<"email" | "sms">;
203
- template: alepha45.TString;
204
- contact: alepha45.TString;
205
- variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
206
- }>, Promise<void>>;
207
- findNotificationById(id: string): Promise<alepha_orm15.PgStatic<alepha45.TObject<{
208
- id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
209
- version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
210
- createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
211
- updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
212
- type: alepha45.TUnsafe<"email" | "sms">;
213
- template: alepha45.TString;
214
- category: alepha45.TOptional<alepha45.TString>;
215
- critical: alepha45.TOptional<alepha45.TBoolean>;
216
- sensitive: alepha45.TOptional<alepha45.TBoolean>;
217
- contact: alepha45.TString;
218
- variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
219
- scheduledAt: alepha45.TOptional<alepha45.TString>;
220
- sentAt: alepha45.TOptional<alepha45.TString>;
221
- error: alepha45.TOptional<alepha45.TObject<{
222
- at: alepha45.TString;
223
- name: alepha45.TString;
224
- message: alepha45.TString;
225
- }>>;
226
- }>, alepha_orm15.PgRelationMap<alepha45.TObject<{
227
- id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
228
- version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
229
- createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
230
- updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
231
- type: alepha45.TUnsafe<"email" | "sms">;
232
- template: alepha45.TString;
233
- category: alepha45.TOptional<alepha45.TString>;
234
- critical: alepha45.TOptional<alepha45.TBoolean>;
235
- sensitive: alepha45.TOptional<alepha45.TBoolean>;
236
- contact: alepha45.TString;
237
- variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
238
- scheduledAt: alepha45.TOptional<alepha45.TString>;
239
- sentAt: alepha45.TOptional<alepha45.TString>;
240
- error: alepha45.TOptional<alepha45.TObject<{
241
- at: alepha45.TString;
242
- name: alepha45.TString;
243
- message: alepha45.TString;
244
- }>>;
245
- }>>>>;
246
- findNotifications(q?: NotificationQuery): Promise<Page<NotificationEntity>>;
247
- /**
248
- * Create a new notification.
249
- */
250
- createNotification(entry: NotificationCreate): Promise<void>;
251
- }
252
- //#endregion
253
- //#region ../../src/api-notifications/controllers/NotificationController.d.ts
254
- declare class NotificationController {
255
- protected readonly url = "/notifications";
256
- protected readonly group = "notifications";
257
- protected readonly notificationService: NotificationService;
258
- /**
259
- * Find notifications with pagination and filtering.
260
- */
261
- readonly findNotifications: alepha_server0.ActionPrimitiveFn<{
262
- query: alepha45.TObject<{
263
- page: alepha45.TOptional<alepha45.TInteger>;
264
- size: alepha45.TOptional<alepha45.TInteger>;
265
- sort: alepha45.TOptional<alepha45.TString>;
266
- type: alepha45.TOptional<alepha45.TUnsafe<"email" | "sms">>;
267
- template: alepha45.TOptional<alepha45.TString>;
268
- contact: alepha45.TOptional<alepha45.TString>;
269
- category: alepha45.TOptional<alepha45.TString>;
270
- status: alepha45.TOptional<alepha45.TUnsafe<"pending" | "sent" | "failed">>;
271
- }>;
272
- response: alepha45.TPage<alepha45.TObject<{
273
- id: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_PRIMARY_KEY>, typeof alepha_orm15.PG_DEFAULT>;
274
- version: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TInteger, typeof alepha_orm15.PG_VERSION>, typeof alepha_orm15.PG_DEFAULT>;
275
- createdAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_CREATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
276
- updatedAt: alepha_orm15.PgAttr<alepha_orm15.PgAttr<alepha45.TString, typeof alepha_orm15.PG_UPDATED_AT>, typeof alepha_orm15.PG_DEFAULT>;
277
- type: alepha45.TUnsafe<"email" | "sms">;
278
- template: alepha45.TString;
279
- category: alepha45.TOptional<alepha45.TString>;
280
- critical: alepha45.TOptional<alepha45.TBoolean>;
281
- sensitive: alepha45.TOptional<alepha45.TBoolean>;
282
- contact: alepha45.TString;
283
- variables: alepha45.TOptional<alepha45.TRecord<"^.*$", alepha45.TAny>>;
284
- scheduledAt: alepha45.TOptional<alepha45.TString>;
285
- sentAt: alepha45.TOptional<alepha45.TString>;
286
- error: alepha45.TOptional<alepha45.TObject<{
287
- at: alepha45.TString;
288
- name: alepha45.TString;
289
- message: alepha45.TString;
290
- }>>;
291
- }>>;
292
- }>;
293
- }
294
- //#endregion
295
- //#region ../../src/api-notifications/jobs/NotificationJobs.d.ts
296
- declare class NotificationJobs {}
297
- //#endregion
298
- //#region ../../src/api-notifications/queues/NotificationQueues.d.ts
299
- declare class NotificationQueues {
300
- protected readonly notificationSenderService: NotificationSenderService;
301
- readonly processNotification: alepha_queue0.QueuePrimitive<alepha45.TObject<{
302
- notificationId: alepha45.TString;
303
- }>>;
304
- }
305
- //#endregion
306
- //#region ../../src/api-notifications/schemas/notificationContactPreferencesSchema.d.ts
307
- declare const notificationContactPreferencesSchema: alepha45.TObject<{
308
- language: alepha45.TOptional<alepha45.TString>;
309
- exclude: alepha45.TArray<alepha45.TString>;
310
- }>;
311
- type NotificationContactPreferences = Static<typeof notificationContactPreferencesSchema>;
312
- //#endregion
313
- //#region ../../src/api-notifications/index.d.ts
314
- /**
315
- * Provides notification management API endpoints for Alepha applications.
316
- *
317
- * This module includes notification sending, retrieval, status tracking,
318
- * and user notification preferences management.
319
- *
320
- * Requires `AlephaSms` module to be loaded for SMS notifications.
321
- *
322
- * @module alepha.api.notifications
323
- */
324
- declare const AlephaApiNotifications: alepha45.Service<alepha45.Module>;
325
- //#endregion
326
- export { $notification, AlephaApiNotifications, NotificationContactPreferences, NotificationController, NotificationCreate, NotificationEntity, NotificationJobs, NotificationMessage, NotificationPrimitive, NotificationPrimitiveOptions, NotificationPushOptions, NotificationQuery, NotificationQueues, NotificationSenderService, NotificationService, notificationContactPreferencesSchema, notificationCreateSchema, notificationQuerySchema, notificationServiceEnvSchema, notifications };
327
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["notifications"],"sources":["../../src/api-notifications/entities/notifications.ts","../../src/api-notifications/schemas/notificationQuerySchema.ts","../../src/api-notifications/primitives/$notification.ts","../../src/api-notifications/services/NotificationSenderService.ts","../../src/api-notifications/queues/NotificationQueues.ts","../../src/api-notifications/schemas/notificationCreateSchema.ts","../../src/api-notifications/services/NotificationService.ts","../../src/api-notifications/controllers/NotificationController.ts","../../src/api-notifications/jobs/NotificationJobs.ts","../../src/api-notifications/schemas/notificationContactPreferencesSchema.ts","../../src/api-notifications/index.ts"],"sourcesContent":["import { type Static, t } from \"alepha\";\nimport { $entity, pg } from \"alepha/orm\";\n\nexport const notifications = $entity({\n name: \"notifications\",\n schema: t.object({\n id: pg.primaryKey(t.uuid()),\n\n version: pg.version(),\n\n createdAt: pg.createdAt(),\n\n updatedAt: pg.updatedAt(),\n\n // -----------------------------------------------------------------------------------------------------------------\n\n type: t.enum([\"email\", \"sms\"]),\n\n template: t.text(), // e.g. 'resetPassword'\n\n category: t.optional(\n t.text({\n description:\n \"For grouping related notifications (e.g., 'authentication', 'marketing'). Contact can filter notifications by category.\",\n }),\n ),\n\n critical: t.optional(\n t.boolean({\n description:\n \"Prioritize delivery of this notification. Set to true for important system alerts.\",\n }),\n ),\n\n sensitive: t.optional(\n t.boolean({\n description:\n \"Message won't be logged or stored in plain text. Set to true when notification contains passwords or codes.\",\n }),\n ),\n\n // -----------------------------------------------------------------------------------------------------------------\n\n contact: t.text(), // e.g. email address or phone number or user ID or whatever\n\n variables: t.optional(t.record(t.text(), t.any())),\n\n scheduledAt: t.optional(\n t.datetime({\n description:\n \"When set, the notification will be sent at or after this date/time.\",\n }),\n ),\n\n // -----------------------------------------------------------------------------------------------------------------\n\n sentAt: t.optional(t.datetime()),\n\n error: t.optional(\n t.object({\n at: t.datetime(),\n name: t.text(),\n message: t.text({ size: \"rich\" }),\n }),\n ),\n\n // TODO: retryCount, lastRetryAt, etc.\n }),\n});\n\nexport type NotificationEntity = Static<typeof notifications.schema>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\nimport { pageQuerySchema } from \"alepha/orm\";\n\nexport const notificationQuerySchema = t.extend(pageQuerySchema, {\n type: t.optional(t.enum([\"email\", \"sms\"])),\n template: t.optional(t.string()),\n contact: t.optional(t.string()),\n category: t.optional(t.string()),\n status: t.optional(t.enum([\"pending\", \"sent\", \"failed\"])),\n});\n\nexport type NotificationQuery = Static<typeof notificationQuerySchema>;\n","import {\n $inject,\n createPrimitive,\n KIND,\n Primitive,\n type Static,\n type StaticEncode,\n type TObject,\n} from \"alepha\";\nimport { NotificationService } from \"../services/NotificationService.ts\";\n\n/**\n * Creates a notification primitive for managing email/SMS notification templates.\n *\n * Provides type-safe, reusable notification templates with multi-language support,\n * variable substitution, and categorization for different notification channels.\n *\n * @example\n * ```ts\n * class NotificationTemplates {\n * welcomeEmail = $notification({\n * name: \"welcome-email\",\n * category: \"onboarding\",\n * schema: t.object({ username: t.text(), activationLink: t.text() }),\n * email: {\n * subject: \"Welcome to our platform!\",\n * body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}`\n * }\n * });\n *\n * async sendWelcome(user: User) {\n * await this.welcomeEmail.push({\n * variables: { username: user.name, activationLink: generateLink() },\n * contact: user.email\n * });\n * }\n * }\n * ```\n */\nexport const $notification = <T extends TObject>(\n options: NotificationPrimitiveOptions<T>,\n) => createPrimitive(NotificationPrimitive<T>, options);\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPrimitiveOptions<T extends TObject>\n extends NotificationMessage<T> {\n name?: string;\n description?: string;\n category?: string;\n critical?: boolean;\n sensitive?: boolean;\n translations?: {\n // e.g., \"en\", \"fr\", even \"en-US\"\n [lang: string]: NotificationMessage<T>;\n };\n schema: T;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class NotificationPrimitive<T extends TObject> extends Primitive<\n NotificationPrimitiveOptions<T>\n> {\n protected readonly notificationService = $inject(NotificationService);\n\n public get name() {\n return this.options.name ?? `${this.config.propertyKey}`;\n }\n\n public async push(options: NotificationPushOptions<T>) {\n if (this.options.email) {\n await this.notificationService.createNotification({\n ...options,\n type: \"email\",\n template: this.name,\n });\n }\n }\n\n public configure(options: Partial<NotificationPrimitiveOptions<T>>) {\n Object.assign(this.options, options);\n }\n}\n\n$notification[KIND] = NotificationPrimitive;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPushOptions<T extends TObject> {\n variables: StaticEncode<T>;\n contact: string;\n}\n\nexport interface NotificationMessage<T extends TObject> {\n email?: {\n subject: string;\n body: string | ((variables: Static<T>) => string);\n };\n sms?: {\n message: string | ((variables: Static<T>) => string);\n };\n}\n","import { $inject, Alepha, AlephaError } from \"alepha\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { EmailProvider } from \"alepha/email\";\nimport { $logger } from \"alepha/logger\";\nimport { $repository } from \"alepha/orm\";\nimport { SmsProvider } from \"alepha/sms\";\nimport {\n type NotificationEntity,\n notifications,\n} from \"../entities/notifications.ts\";\nimport { $notification } from \"../primitives/$notification.ts\";\n\nexport class NotificationSenderService {\n protected readonly alepha = $inject(Alepha);\n protected readonly log = $logger();\n protected readonly notificationRepository = $repository(notifications);\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly emailProvider = $inject(EmailProvider);\n protected readonly smsProvider = $inject(SmsProvider);\n\n public async send(notificationId: string | NotificationEntity) {\n this.log.trace(\"Sending notification\", {\n notificationId:\n typeof notificationId === \"string\" ? notificationId : notificationId.id,\n });\n\n const notification =\n typeof notificationId === \"string\"\n ? await this.notificationRepository.findById(notificationId)\n : notificationId;\n\n if (notification.sentAt) {\n this.log.debug(\"Notification already sent\", {\n notificationId: notification.id,\n sentAt: notification.sentAt,\n });\n return;\n }\n\n this.log.debug(\"Processing notification\", {\n id: notification.id,\n type: notification.type,\n template: notification.template,\n contact: notification.contact,\n });\n\n try {\n if (notification.type === \"email\") {\n await this.emailProvider.send(this.renderEmail(notification));\n notification.sentAt = this.dateTimeProvider.nowISOString();\n this.log.info(\"Email notification sent\", {\n id: notification.id,\n template: notification.template,\n contact: notification.contact,\n });\n }\n if (notification.type === \"sms\") {\n await this.smsProvider.send(this.renderSms(notification));\n notification.sentAt = this.dateTimeProvider.nowISOString();\n this.log.info(\"SMS notification sent\", {\n id: notification.id,\n template: notification.template,\n contact: notification.contact,\n });\n }\n } catch (e) {\n this.log.error(\"Failed to send notification\", {\n id: notification.id,\n type: notification.type,\n template: notification.template,\n contact: notification.contact,\n error: e,\n });\n if (e instanceof Error) {\n notification.error = {\n at: this.dateTimeProvider.nowISOString(),\n name: e.name,\n message: e.message,\n };\n }\n } finally {\n await this.notificationRepository.save(notification);\n }\n }\n\n public renderSms(notification: NotificationEntity) {\n this.log.trace(\"Rendering SMS notification\", {\n id: notification.id,\n template: notification.template,\n });\n\n const { variables, contact, template } = this.load(notification);\n\n const sms = template.options.sms;\n if (!sms) {\n this.log.error(\"Notification template has no SMS defined\", {\n id: notification.id,\n template: notification.template,\n });\n throw new AlephaError(\n `Notification template ${notification.template} has no sms defined`,\n );\n }\n\n this.log.debug(\"Rendering SMS\", {\n template: notification.template,\n contact,\n });\n\n const message =\n typeof sms.message === \"function\"\n ? sms.message(variables as any)\n : sms.message;\n\n return {\n to: contact,\n message,\n };\n }\n\n public renderEmail(notification: NotificationEntity) {\n this.log.trace(\"Rendering email notification\", {\n id: notification.id,\n template: notification.template,\n });\n\n const { variables, contact, template } = this.load(notification);\n\n const email = template.options.email;\n if (!email) {\n this.log.error(\"Notification template has no email defined\", {\n id: notification.id,\n template: notification.template,\n });\n throw new AlephaError(\n `Notification template ${notification.template} has no email defined`,\n );\n }\n\n this.log.debug(\"Rendering email\", {\n template: notification.template,\n contact,\n subject: email.subject,\n });\n\n const subject = email.subject;\n\n const body =\n typeof email.body === \"function\"\n ? email.body(variables as any)\n : email.body;\n\n return {\n to: contact,\n subject,\n body,\n };\n }\n\n protected load(notification: NotificationEntity) {\n const variables = notification.variables || {};\n const contact = notification.contact;\n const template = this.alepha\n .primitives($notification)\n .find((it) => it.name === notification.template);\n\n if (!template) {\n this.log.error(\"Notification template not found\", {\n id: notification.id,\n template: notification.template,\n });\n throw new AlephaError(\n `No notification template found for ${notification.template}`,\n );\n }\n\n return {\n template,\n variables,\n contact,\n };\n }\n}\n","import { $inject, t } from \"alepha\";\nimport { $queue } from \"alepha/queue\";\nimport { NotificationSenderService } from \"../services/NotificationSenderService.ts\";\n\nexport class NotificationQueues {\n protected readonly notificationSenderService = $inject(\n NotificationSenderService,\n );\n\n public readonly processNotification = $queue({\n description: \"Queue for processing notifications\",\n schema: t.object({\n notificationId: t.string({ format: \"uuid\" }),\n }),\n handler: async (message) => {\n await this.notificationSenderService.send(message.payload.notificationId);\n },\n });\n}\n","import { type Static, t } from \"alepha\";\nimport { notifications } from \"../entities/notifications.ts\";\n\nexport const notificationCreateSchema = t.pick(notifications.schema, [\n \"type\",\n \"contact\",\n \"template\",\n \"variables\",\n]);\n\nexport type NotificationCreate = Static<typeof notificationCreateSchema>;\n","import { $env, $inject, Alepha, type Static, t } from \"alepha\";\nimport { $batch } from \"alepha/batch\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport { $repository, type Page } from \"alepha/orm\";\nimport {\n type NotificationEntity,\n notifications,\n} from \"../entities/notifications.ts\";\nimport { NotificationQueues } from \"../queues/NotificationQueues.ts\";\nimport {\n type NotificationCreate,\n notificationCreateSchema,\n} from \"../schemas/notificationCreateSchema.ts\";\nimport type { NotificationQuery } from \"../schemas/notificationQuerySchema.ts\";\nimport { NotificationSenderService } from \"./NotificationSenderService.ts\";\n\nexport const notificationServiceEnvSchema = t.object({\n NOTIFICATION_QUEUE: t.optional(\n t.boolean({\n description:\n \"If true, notifications will be queued instead of sent immediately\",\n }),\n ),\n});\n\ndeclare module \"alepha\" {\n interface Env extends Partial<Static<typeof notificationServiceEnvSchema>> {}\n}\n\nexport class NotificationService {\n protected readonly alepha = $inject(Alepha);\n protected readonly log = $logger();\n protected readonly env = $env(notificationServiceEnvSchema);\n protected readonly notificationRepository = $repository(notifications);\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly notificationSenderService = $inject(\n NotificationSenderService,\n );\n\n public readonly notificationBatch = $batch({\n maxSize: 100,\n maxDuration: [15, \"seconds\"],\n schema: notificationCreateSchema,\n handler: async (notifications: NotificationCreate[]) => {\n this.log.debug(\"Processing notification batch\", {\n size: notifications.length,\n templates: [...new Set(notifications.map((n) => n.template))],\n });\n\n const entities =\n await this.notificationRepository.createMany(notifications);\n\n await this.alepha\n .inject(NotificationQueues)\n .processNotification.push(\n ...entities.map((it) => ({ notificationId: it.id })),\n );\n\n this.log.info(\"Notification batch queued\", {\n count: entities.length,\n ids: entities.map((it) => it.id),\n });\n },\n });\n\n public async findNotificationById(id: string) {\n this.log.trace(\"Finding notification by ID\", { id });\n return this.notificationRepository.findOne({ where: { id } });\n }\n\n public async findNotifications(\n q: NotificationQuery = {},\n ): Promise<Page<NotificationEntity>> {\n this.log.trace(\"Finding notifications\", { query: q });\n q.sort ??= \"-createdAt\";\n\n const where = this.notificationRepository.createQueryWhere();\n\n if (q.type) {\n where.type = { eq: q.type };\n }\n\n if (q.template) {\n where.template = { like: `%${q.template}%` };\n }\n\n if (q.contact) {\n where.contact = { like: `%${q.contact}%` };\n }\n\n if (q.category) {\n where.category = { eq: q.category };\n }\n\n if (q.status) {\n if (q.status === \"sent\") {\n where.sentAt = { isNotNull: true };\n where.error = { isNull: true };\n } else if (q.status === \"failed\") {\n where.error = { isNotNull: true };\n } else if (q.status === \"pending\") {\n where.sentAt = { isNull: true };\n where.error = { isNull: true };\n }\n }\n\n return this.notificationRepository.paginate(q, { where }, { count: true });\n }\n\n /**\n * Create a new notification.\n */\n public async createNotification(entry: NotificationCreate): Promise<void> {\n this.log.trace(\"Creating notification\", {\n template: entry.template,\n type: entry.type,\n contact: entry.contact,\n });\n\n if (\n this.env.NOTIFICATION_QUEUE !== true ||\n this.alepha.isServerless() ||\n this.alepha.isTest()\n ) {\n this.log.debug(\"Sending notification immediately\", {\n template: entry.template,\n type: entry.type,\n contact: entry.contact,\n });\n const notification = await this.notificationRepository.create(entry);\n await this.notificationSenderService.send(notification);\n return;\n }\n\n this.log.debug(\"Queuing notification to batch\", {\n template: entry.template,\n type: entry.type,\n contact: entry.contact,\n });\n\n this.notificationBatch.push(entry).catch((e) => {\n this.log.error(\"Failed to push notification to batch\", {\n template: entry.template,\n type: entry.type,\n contact: entry.contact,\n error: e,\n });\n });\n }\n}\n","import { $inject } from \"alepha\";\nimport { pg } from \"alepha/orm\";\nimport { $action } from \"alepha/server\";\nimport { notifications } from \"../entities/notifications.ts\";\nimport { notificationQuerySchema } from \"../schemas/notificationQuerySchema.ts\";\nimport { NotificationService } from \"../services/NotificationService.ts\";\n\nexport class NotificationController {\n protected readonly url = \"/notifications\";\n protected readonly group = \"notifications\";\n protected readonly notificationService = $inject(NotificationService);\n\n /**\n * Find notifications with pagination and filtering.\n */\n public readonly findNotifications = $action({\n path: this.url,\n group: this.group,\n description: \"Find notifications with pagination and filtering\",\n schema: {\n query: notificationQuerySchema,\n response: pg.page(notifications.schema),\n },\n handler: ({ query }) => this.notificationService.findNotifications(query),\n });\n}\n","export class NotificationJobs {\n // - retry (lost, failed) notifications\n // - purge old notifications\n}\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactPreferencesSchema = t.object({\n language: t.optional(t.text()),\n exclude: t.array(t.text()),\n});\n\nexport type NotificationContactPreferences = Static<\n typeof notificationContactPreferencesSchema\n>;\n","import { $module } from \"alepha\";\nimport { NotificationController } from \"./controllers/NotificationController.ts\";\nimport { NotificationJobs } from \"./jobs/NotificationJobs.ts\";\nimport { $notification } from \"./primitives/$notification.ts\";\nimport { NotificationQueues } from \"./queues/NotificationQueues.ts\";\nimport { NotificationSenderService } from \"./services/NotificationSenderService.ts\";\nimport {\n NotificationService,\n notificationServiceEnvSchema,\n} from \"./services/NotificationService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./controllers/NotificationController.ts\";\nexport * from \"./entities/notifications.ts\";\nexport * from \"./jobs/NotificationJobs.ts\";\nexport * from \"./primitives/$notification.ts\";\nexport * from \"./queues/NotificationQueues.ts\";\nexport * from \"./schemas/notificationContactPreferencesSchema.ts\";\nexport * from \"./schemas/notificationCreateSchema.ts\";\nexport * from \"./schemas/notificationQuerySchema.ts\";\nexport * from \"./services/NotificationSenderService.ts\";\nexport * from \"./services/NotificationService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Provides notification management API endpoints for Alepha applications.\n *\n * This module includes notification sending, retrieval, status tracking,\n * and user notification preferences management.\n *\n * Requires `AlephaSms` module to be loaded for SMS notifications.\n *\n * @module alepha.api.notifications\n */\nexport const AlephaApiNotifications = $module({\n name: \"alepha.api.notifications\",\n primitives: [$notification],\n services: [\n NotificationController,\n NotificationService,\n NotificationSenderService,\n NotificationQueues,\n NotificationJobs,\n ],\n register: (alepha) => {\n const env = alepha.parseEnv(notificationServiceEnvSchema);\n if (env.NOTIFICATION_QUEUE) {\n alepha.with(NotificationQueues);\n }\n\n alepha\n .with(NotificationController)\n .with(NotificationService)\n .with(NotificationSenderService)\n .with(NotificationJobs);\n },\n});\n"],"mappings":";;;;;;;;;;;AAGA,MAAa,gBAAgB,QAAQ;CACnC,MAAM;CACN,QAAQ,EAAE,OAAO;EACf,IAAI,GAAG,WAAW,EAAE,MAAM,CAAC;EAE3B,SAAS,GAAG,SAAS;EAErB,WAAW,GAAG,WAAW;EAEzB,WAAW,GAAG,WAAW;EAIzB,MAAM,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC;EAE9B,UAAU,EAAE,MAAM;EAElB,UAAU,EAAE,SACV,EAAE,KAAK,EACL,aACE,2HACH,CAAC,CACH;EAED,UAAU,EAAE,SACV,EAAE,QAAQ,EACR,aACE,sFACH,CAAC,CACH;EAED,WAAW,EAAE,SACX,EAAE,QAAQ,EACR,aACE,+GACH,CAAC,CACH;EAID,SAAS,EAAE,MAAM;EAEjB,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;EAElD,aAAa,EAAE,SACb,EAAE,SAAS,EACT,aACE,uEACH,CAAC,CACH;EAID,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC;EAEhC,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,CAC5B,KAAK,oBAAoB,CACzB,KAAK,0BAA0B,CAC/B,KAAK,iBAAiB;;CAE5B,CAAC"}
@@ -1,29 +0,0 @@
1
- import { $module, t } from "alepha";
2
- import { $entity, pg } from "alepha/orm";
3
-
4
- //#region ../../src/api-parameters/entities/parameters.ts
5
- const parameters = $entity({
6
- name: "parameters",
7
- schema: t.object({
8
- id: pg.primaryKey(t.uuid()),
9
- createdAt: pg.createdAt(),
10
- updatedAt: pg.updatedAt(),
11
- name: t.string(),
12
- content: t.json(),
13
- tags: t.optional(t.array(t.string())),
14
- creatorId: t.optional(t.uuid()),
15
- creatorName: t.optional(t.string()),
16
- activationDate: t.datetime({ description: "Optional activation date. Default to now. Must be now or later." })
17
- })
18
- });
19
-
20
- //#endregion
21
- //#region ../../src/api-parameters/index.browser.ts
22
- const AlephaApiParameters = $module({
23
- name: "alepha.api.parameters",
24
- services: []
25
- });
26
-
27
- //#endregion
28
- export { AlephaApiParameters, parameters };
29
- //# sourceMappingURL=index.browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.browser.js","names":[],"sources":["../../src/api-parameters/entities/parameters.ts","../../src/api-parameters/index.browser.ts"],"sourcesContent":["import { type Static, t } from \"alepha\";\nimport { $entity, pg } from \"alepha/orm\";\n\nexport const parameters = $entity({\n name: \"parameters\",\n schema: t.object({\n id: pg.primaryKey(t.uuid()),\n\n createdAt: pg.createdAt(),\n\n updatedAt: pg.updatedAt(),\n\n name: t.string(),\n\n content: t.json(),\n\n tags: t.optional(t.array(t.string())),\n\n creatorId: t.optional(t.uuid()),\n\n creatorName: t.optional(t.string()),\n\n activationDate: t.datetime({\n description:\n \"Optional activation date. Default to now. Must be now or later.\",\n }),\n }),\n});\n\nexport type ParameterEntity = Static<typeof parameters.schema>;\n","import { $module } from \"alepha\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./entities/parameters.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport const AlephaApiParameters = $module({\n name: \"alepha.api.parameters\",\n services: [],\n});\n"],"mappings":";;;;AAGA,MAAa,aAAa,QAAQ;CAChC,MAAM;CACN,QAAQ,EAAE,OAAO;EACf,IAAI,GAAG,WAAW,EAAE,MAAM,CAAC;EAE3B,WAAW,GAAG,WAAW;EAEzB,WAAW,GAAG,WAAW;EAEzB,MAAM,EAAE,QAAQ;EAEhB,SAAS,EAAE,MAAM;EAEjB,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;EAErC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC;EAE/B,aAAa,EAAE,SAAS,EAAE,QAAQ,CAAC;EAEnC,gBAAgB,EAAE,SAAS,EACzB,aACE,mEACH,CAAC;EACH,CAAC;CACH,CAAC;;;;ACnBF,MAAa,sBAAsB,QAAQ;CACzC,MAAM;CACN,UAAU,EAAE;CACb,CAAC"}
@@ -1,83 +0,0 @@
1
- import * as alepha1 from "alepha";
2
- import { Primitive, Static, TObject } from "alepha";
3
- import * as alepha_orm0 from "alepha/orm";
4
- import { UserAccount } from "alepha/security";
5
-
6
- //#region ../../src/api-parameters/entities/parameters.d.ts
7
- declare const parameters: alepha_orm0.EntityPrimitive<alepha1.TObject<{
8
- id: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_PRIMARY_KEY>, typeof alepha_orm0.PG_DEFAULT>;
9
- createdAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_CREATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
10
- updatedAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha1.TString, typeof alepha_orm0.PG_UPDATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
11
- name: alepha1.TString;
12
- content: alepha1.TRecord<string, alepha1.TAny>;
13
- tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
14
- creatorId: alepha1.TOptional<alepha1.TString>;
15
- creatorName: alepha1.TOptional<alepha1.TString>;
16
- activationDate: alepha1.TString;
17
- }>>;
18
- type ParameterEntity = Static<typeof parameters.schema>;
19
- //#endregion
20
- //#region ../../src/api-parameters/primitives/$config.d.ts
21
- /**
22
- * Creates a configuration parameter primitive for managing application settings.
23
- *
24
- * Provides type-safe, versioned configuration with schema validation, default values,
25
- * and scheduled activation. Useful for feature flags, system parameters, and runtime settings.
26
- *
27
- * @example
28
- * ```ts
29
- * class AppConfig {
30
- * features = $config({
31
- * name: "feature-flags",
32
- * schema: t.object({
33
- * enableBeta: t.boolean(),
34
- * maxUploadSize: t.number()
35
- * }),
36
- * default: { enableBeta: false, maxUploadSize: 10485760 }
37
- * });
38
- *
39
- * async updateFeatures() {
40
- * await this.features.set(
41
- * { enableBeta: true, maxUploadSize: 20971520 },
42
- * { user: currentUser, activationDate: tomorrow }
43
- * );
44
- * }
45
- * }
46
- * ```
47
- */
48
- interface ConfigPrimitiveOptions<T extends TObject> {
49
- name?: string;
50
- description?: string;
51
- schema: T;
52
- default: Static<T>;
53
- }
54
- declare class ConfigPrimitive<T extends TObject> extends Primitive<ConfigPrimitiveOptions<T>> {
55
- get name(): string;
56
- get schema(): T;
57
- get current(): Static<T>;
58
- get next(): Static<T> | undefined;
59
- get<Key extends keyof Static<T>>(key: Key): Static<T>[Key];
60
- /**
61
- * Apply a new configuration object.
62
- */
63
- set(value: Static<T>, options: {
64
- user?: UserAccount;
65
- activationDate?: Date;
66
- }): Promise<void>;
67
- sub(fn: (curr: Static<T>) => void): void;
68
- }
69
- declare const $config: <T extends TObject>(options: ConfigPrimitiveOptions<T>) => ConfigPrimitive<T>;
70
- //#endregion
71
- //#region ../../src/api-parameters/index.d.ts
72
- /**
73
- * Provides parameter management API endpoints for Alepha applications.
74
- *
75
- * This module includes configuration parameter storage, retrieval,
76
- * and dynamic application settings management.
77
- *
78
- * @module alepha.api.parameters
79
- */
80
- declare const AlephaApiParameters: alepha1.Service<alepha1.Module>;
81
- //#endregion
82
- export { $config, AlephaApiParameters, ConfigPrimitive, ConfigPrimitiveOptions, ParameterEntity, parameters };
83
- //# sourceMappingURL=index.d.ts.map
@@ -1,63 +0,0 @@
1
- import { $module, Primitive, createPrimitive, t } from "alepha";
2
- import { $entity, pg } from "alepha/orm";
3
-
4
- //#region ../../src/api-parameters/entities/parameters.ts
5
- const parameters = $entity({
6
- name: "parameters",
7
- schema: t.object({
8
- id: pg.primaryKey(t.uuid()),
9
- createdAt: pg.createdAt(),
10
- updatedAt: pg.updatedAt(),
11
- name: t.string(),
12
- content: t.json(),
13
- tags: t.optional(t.array(t.string())),
14
- creatorId: t.optional(t.uuid()),
15
- creatorName: t.optional(t.string()),
16
- activationDate: t.datetime({ description: "Optional activation date. Default to now. Must be now or later." })
17
- })
18
- });
19
-
20
- //#endregion
21
- //#region ../../src/api-parameters/primitives/$config.ts
22
- var ConfigPrimitive = class extends Primitive {
23
- get name() {
24
- return this.options.name || this.config.propertyKey;
25
- }
26
- get schema() {
27
- return this.options.schema;
28
- }
29
- get current() {
30
- return this.options.default;
31
- }
32
- get next() {}
33
- get(key) {
34
- return this.current[key];
35
- }
36
- /**
37
- * Apply a new configuration object.
38
- */
39
- async set(value, options) {}
40
- sub(fn) {}
41
- };
42
- const $config = (options) => {
43
- return createPrimitive(ConfigPrimitive, options);
44
- };
45
-
46
- //#endregion
47
- //#region ../../src/api-parameters/index.ts
48
- /**
49
- * Provides parameter management API endpoints for Alepha applications.
50
- *
51
- * This module includes configuration parameter storage, retrieval,
52
- * and dynamic application settings management.
53
- *
54
- * @module alepha.api.parameters
55
- */
56
- const AlephaApiParameters = $module({
57
- name: "alepha.api.parameters",
58
- services: []
59
- });
60
-
61
- //#endregion
62
- export { $config, AlephaApiParameters, ConfigPrimitive, parameters };
63
- //# sourceMappingURL=index.js.map