alepha 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (461) hide show
  1. package/README.md +1 -1
  2. package/dist/api-files/index.d.ts +28 -91
  3. package/dist/api-files/index.js +10 -755
  4. package/dist/api-files/index.js.map +1 -1
  5. package/dist/api-jobs/index.d.ts +67 -67
  6. package/dist/api-jobs/index.js +13 -13
  7. package/dist/api-jobs/index.js.map +1 -1
  8. package/dist/api-notifications/index.d.ts +129 -146
  9. package/dist/api-notifications/index.js +17 -39
  10. package/dist/api-notifications/index.js.map +1 -1
  11. package/dist/api-parameters/index.d.ts +21 -22
  12. package/dist/api-parameters/index.js +22 -22
  13. package/dist/api-parameters/index.js.map +1 -1
  14. package/dist/api-users/index.d.ts +224 -2001
  15. package/dist/api-users/index.js +914 -4787
  16. package/dist/api-users/index.js.map +1 -1
  17. package/dist/api-verifications/index.d.ts +96 -96
  18. package/dist/batch/index.d.ts +13 -13
  19. package/dist/batch/index.js +8 -8
  20. package/dist/batch/index.js.map +1 -1
  21. package/dist/bucket/index.d.ts +14 -14
  22. package/dist/bucket/index.js +12 -12
  23. package/dist/bucket/index.js.map +1 -1
  24. package/dist/cache/index.d.ts +11 -11
  25. package/dist/cache/index.js +9 -9
  26. package/dist/cache/index.js.map +1 -1
  27. package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
  28. package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
  29. package/dist/cli/index.d.ts +31 -37
  30. package/dist/cli/index.js +152 -83
  31. package/dist/cli/index.js.map +1 -1
  32. package/dist/command/index.d.ts +19 -19
  33. package/dist/command/index.js +25 -25
  34. package/dist/command/index.js.map +1 -1
  35. package/dist/core/index.browser.js +218 -218
  36. package/dist/core/index.browser.js.map +1 -1
  37. package/dist/core/index.d.ts +232 -232
  38. package/dist/core/index.js +218 -218
  39. package/dist/core/index.js.map +1 -1
  40. package/dist/core/{index.cjs → index.native.js} +304 -455
  41. package/dist/core/index.native.js.map +1 -0
  42. package/dist/datetime/index.d.ts +9 -9
  43. package/dist/datetime/index.js +7 -7
  44. package/dist/datetime/index.js.map +1 -1
  45. package/dist/email/index.d.ts +16 -16
  46. package/dist/email/index.js +80 -82
  47. package/dist/email/index.js.map +1 -1
  48. package/dist/file/index.js +1 -1
  49. package/dist/file/index.js.map +1 -1
  50. package/dist/lock/index.d.ts +9 -9
  51. package/dist/lock/index.js +8 -8
  52. package/dist/lock/index.js.map +1 -1
  53. package/dist/lock-redis/index.js +3 -66
  54. package/dist/lock-redis/index.js.map +1 -1
  55. package/dist/logger/index.d.ts +5 -5
  56. package/dist/logger/index.js +8 -8
  57. package/dist/logger/index.js.map +1 -1
  58. package/dist/orm/index.browser.js +114 -114
  59. package/dist/orm/index.browser.js.map +1 -1
  60. package/dist/orm/index.d.ts +219 -219
  61. package/dist/orm/index.js +46 -46
  62. package/dist/orm/index.js.map +1 -1
  63. package/dist/queue/index.d.ts +25 -25
  64. package/dist/queue/index.js +20 -20
  65. package/dist/queue/index.js.map +1 -1
  66. package/dist/queue-redis/index.d.ts +2 -2
  67. package/dist/redis/index.d.ts +10 -10
  68. package/dist/retry/index.d.ts +20 -20
  69. package/dist/retry/index.js +9 -9
  70. package/dist/retry/index.js.map +1 -1
  71. package/dist/scheduler/index.d.ts +12 -12
  72. package/dist/scheduler/index.js +9 -9
  73. package/dist/scheduler/index.js.map +1 -1
  74. package/dist/security/index.d.ts +53 -53
  75. package/dist/security/index.js +32 -32
  76. package/dist/security/index.js.map +1 -1
  77. package/dist/server/index.browser.js +1 -1
  78. package/dist/server/index.browser.js.map +1 -1
  79. package/dist/server/index.d.ts +101 -101
  80. package/dist/server/index.js +17 -17
  81. package/dist/server/index.js.map +1 -1
  82. package/dist/server-auth/index.browser.js +4 -982
  83. package/dist/server-auth/index.browser.js.map +1 -1
  84. package/dist/server-auth/index.d.ts +204 -785
  85. package/dist/server-auth/index.js +47 -1239
  86. package/dist/server-auth/index.js.map +1 -1
  87. package/dist/server-cache/index.d.ts +10 -10
  88. package/dist/server-cache/index.js +2 -2
  89. package/dist/server-cache/index.js.map +1 -1
  90. package/dist/server-compress/index.d.ts +4 -4
  91. package/dist/server-compress/index.js +1 -1
  92. package/dist/server-compress/index.js.map +1 -1
  93. package/dist/server-cookies/index.browser.js +8 -8
  94. package/dist/server-cookies/index.browser.js.map +1 -1
  95. package/dist/server-cookies/index.d.ts +17 -17
  96. package/dist/server-cookies/index.js +10 -10
  97. package/dist/server-cookies/index.js.map +1 -1
  98. package/dist/server-cors/index.d.ts +17 -17
  99. package/dist/server-cors/index.js +9 -9
  100. package/dist/server-cors/index.js.map +1 -1
  101. package/dist/server-health/index.d.ts +2 -2
  102. package/dist/server-helmet/index.d.ts +1 -1
  103. package/dist/server-links/index.browser.js +12 -12
  104. package/dist/server-links/index.browser.js.map +1 -1
  105. package/dist/server-links/index.d.ts +59 -251
  106. package/dist/server-links/index.js +23 -502
  107. package/dist/server-links/index.js.map +1 -1
  108. package/dist/server-metrics/index.d.ts +4 -4
  109. package/dist/server-metrics/index.js +170 -174
  110. package/dist/server-metrics/index.js.map +1 -1
  111. package/dist/server-multipart/index.d.ts +2 -2
  112. package/dist/server-proxy/index.d.ts +12 -12
  113. package/dist/server-proxy/index.js +10 -10
  114. package/dist/server-proxy/index.js.map +1 -1
  115. package/dist/server-rate-limit/index.d.ts +22 -22
  116. package/dist/server-rate-limit/index.js +12 -12
  117. package/dist/server-rate-limit/index.js.map +1 -1
  118. package/dist/server-security/index.d.ts +24 -24
  119. package/dist/server-security/index.js +15 -15
  120. package/dist/server-security/index.js.map +1 -1
  121. package/dist/server-static/index.d.ts +14 -14
  122. package/dist/server-static/index.js +8 -8
  123. package/dist/server-static/index.js.map +1 -1
  124. package/dist/server-swagger/index.d.ts +25 -184
  125. package/dist/server-swagger/index.js +21 -724
  126. package/dist/server-swagger/index.js.map +1 -1
  127. package/dist/sms/index.d.ts +14 -14
  128. package/dist/sms/index.js +9 -9
  129. package/dist/sms/index.js.map +1 -1
  130. package/dist/thread/index.d.ts +11 -11
  131. package/dist/thread/index.js +17 -17
  132. package/dist/thread/index.js.map +1 -1
  133. package/dist/topic/index.d.ts +26 -26
  134. package/dist/topic/index.js +16 -16
  135. package/dist/topic/index.js.map +1 -1
  136. package/dist/topic-redis/index.d.ts +1 -1
  137. package/dist/vite/index.d.ts +3 -3
  138. package/dist/vite/index.js +12 -13
  139. package/dist/vite/index.js.map +1 -1
  140. package/dist/websocket/index.browser.js +11 -11
  141. package/dist/websocket/index.browser.js.map +1 -1
  142. package/dist/websocket/index.d.ts +51 -51
  143. package/dist/websocket/index.js +13 -13
  144. package/dist/websocket/index.js.map +1 -1
  145. package/package.json +62 -52
  146. package/src/api-files/services/FileService.ts +5 -7
  147. package/src/api-jobs/index.ts +1 -1
  148. package/src/api-jobs/{descriptors → primitives}/$job.ts +8 -8
  149. package/src/api-jobs/providers/JobProvider.ts +9 -9
  150. package/src/api-jobs/services/JobService.ts +5 -5
  151. package/src/api-notifications/index.ts +5 -15
  152. package/src/api-notifications/{descriptors → primitives}/$notification.ts +10 -10
  153. package/src/api-notifications/services/NotificationSenderService.ts +3 -3
  154. package/src/api-parameters/index.ts +1 -1
  155. package/src/api-parameters/{descriptors → primitives}/$config.ts +7 -12
  156. package/src/api-users/index.ts +1 -1
  157. package/src/api-users/{descriptors → primitives}/$userRealm.ts +8 -8
  158. package/src/api-users/providers/UserRealmProvider.ts +1 -1
  159. package/src/batch/index.ts +3 -3
  160. package/src/batch/{descriptors → primitives}/$batch.ts +13 -16
  161. package/src/bucket/index.ts +8 -8
  162. package/src/bucket/{descriptors → primitives}/$bucket.ts +8 -8
  163. package/src/bucket/providers/LocalFileStorageProvider.ts +3 -3
  164. package/src/cache/index.ts +4 -4
  165. package/src/cache/{descriptors → primitives}/$cache.ts +15 -15
  166. package/src/cli/apps/AlephaPackageBuilderCli.ts +30 -3
  167. package/src/cli/assets/appRouterTs.ts +9 -0
  168. package/src/cli/assets/indexHtml.ts +2 -1
  169. package/src/cli/assets/mainBrowserTs.ts +10 -0
  170. package/src/cli/commands/CoreCommands.ts +6 -5
  171. package/src/cli/commands/DrizzleCommands.ts +69 -61
  172. package/src/cli/commands/VerifyCommands.ts +2 -2
  173. package/src/cli/commands/ViteCommands.ts +6 -1
  174. package/src/cli/services/ProjectUtils.ts +78 -41
  175. package/src/command/index.ts +5 -5
  176. package/src/command/{descriptors → primitives}/$command.ts +9 -12
  177. package/src/command/providers/CliProvider.ts +10 -10
  178. package/src/core/Alepha.ts +30 -33
  179. package/src/core/constants/KIND.ts +1 -1
  180. package/src/core/constants/OPTIONS.ts +1 -1
  181. package/src/core/helpers/{descriptor.ts → primitive.ts} +18 -18
  182. package/src/core/helpers/ref.ts +1 -1
  183. package/src/core/index.shared.ts +8 -8
  184. package/src/core/{descriptors → primitives}/$context.ts +5 -5
  185. package/src/core/{descriptors → primitives}/$hook.ts +4 -4
  186. package/src/core/{descriptors → primitives}/$inject.ts +2 -2
  187. package/src/core/{descriptors → primitives}/$module.ts +9 -9
  188. package/src/core/{descriptors → primitives}/$use.ts +2 -2
  189. package/src/core/providers/CodecManager.ts +1 -1
  190. package/src/core/providers/JsonSchemaCodec.ts +1 -1
  191. package/src/core/providers/StateManager.ts +2 -2
  192. package/src/datetime/index.ts +3 -3
  193. package/src/datetime/{descriptors → primitives}/$interval.ts +6 -6
  194. package/src/email/index.ts +4 -4
  195. package/src/email/{descriptors → primitives}/$email.ts +8 -8
  196. package/src/file/index.ts +1 -1
  197. package/src/lock/index.ts +3 -3
  198. package/src/lock/{descriptors → primitives}/$lock.ts +10 -10
  199. package/src/logger/index.ts +8 -8
  200. package/src/logger/{descriptors → primitives}/$logger.ts +2 -2
  201. package/src/logger/services/Logger.ts +1 -1
  202. package/src/orm/constants/PG_SYMBOLS.ts +2 -2
  203. package/src/orm/index.browser.ts +2 -2
  204. package/src/orm/index.ts +8 -8
  205. package/src/orm/{descriptors → primitives}/$entity.ts +11 -11
  206. package/src/orm/{descriptors → primitives}/$repository.ts +2 -2
  207. package/src/orm/{descriptors → primitives}/$sequence.ts +8 -8
  208. package/src/orm/{descriptors → primitives}/$transaction.ts +4 -4
  209. package/src/orm/providers/DrizzleKitProvider.ts +1 -1
  210. package/src/orm/providers/PostgresTypeProvider.ts +3 -3
  211. package/src/orm/providers/RepositoryProvider.ts +4 -4
  212. package/src/orm/providers/drivers/DatabaseProvider.ts +7 -7
  213. package/src/orm/services/ModelBuilder.ts +9 -9
  214. package/src/orm/services/PgRelationManager.ts +2 -2
  215. package/src/orm/services/PostgresModelBuilder.ts +5 -5
  216. package/src/orm/services/Repository.ts +7 -7
  217. package/src/orm/services/SqliteModelBuilder.ts +5 -5
  218. package/src/queue/index.ts +7 -7
  219. package/src/queue/{descriptors → primitives}/$consumer.ts +15 -15
  220. package/src/queue/{descriptors → primitives}/$queue.ts +12 -12
  221. package/src/queue/providers/WorkerProvider.ts +7 -7
  222. package/src/retry/index.ts +3 -3
  223. package/src/retry/{descriptors → primitives}/$retry.ts +19 -17
  224. package/src/scheduler/index.ts +3 -3
  225. package/src/scheduler/{descriptors → primitives}/$scheduler.ts +9 -9
  226. package/src/scheduler/providers/CronProvider.ts +1 -1
  227. package/src/security/index.ts +9 -9
  228. package/src/security/{descriptors → primitives}/$permission.ts +7 -7
  229. package/src/security/{descriptors → primitives}/$realm.ts +6 -12
  230. package/src/security/{descriptors → primitives}/$role.ts +12 -12
  231. package/src/security/{descriptors → primitives}/$serviceAccount.ts +8 -8
  232. package/src/server/index.browser.ts +1 -1
  233. package/src/server/index.ts +14 -14
  234. package/src/server/{descriptors → primitives}/$action.ts +13 -13
  235. package/src/server/{descriptors → primitives}/$route.ts +9 -9
  236. package/src/server/providers/NodeHttpServerProvider.ts +2 -2
  237. package/src/server/services/HttpClient.ts +1 -1
  238. package/src/server-auth/index.browser.ts +1 -1
  239. package/src/server-auth/index.ts +6 -6
  240. package/src/server-auth/{descriptors → primitives}/$auth.ts +10 -10
  241. package/src/server-auth/{descriptors → primitives}/$authCredentials.ts +4 -4
  242. package/src/server-auth/{descriptors → primitives}/$authGithub.ts +4 -4
  243. package/src/server-auth/{descriptors → primitives}/$authGoogle.ts +4 -4
  244. package/src/server-auth/providers/ServerAuthProvider.ts +4 -4
  245. package/src/server-cache/providers/ServerCacheProvider.ts +7 -7
  246. package/src/server-compress/providers/ServerCompressProvider.ts +3 -3
  247. package/src/server-cookies/index.browser.ts +2 -2
  248. package/src/server-cookies/index.ts +5 -5
  249. package/src/server-cookies/{descriptors → primitives}/$cookie.browser.ts +12 -12
  250. package/src/server-cookies/{descriptors → primitives}/$cookie.ts +13 -13
  251. package/src/server-cookies/providers/ServerCookiesProvider.ts +4 -4
  252. package/src/server-cookies/services/CookieParser.ts +1 -1
  253. package/src/server-cors/index.ts +3 -3
  254. package/src/server-cors/{descriptors → primitives}/$cors.ts +11 -13
  255. package/src/server-cors/providers/ServerCorsProvider.ts +5 -5
  256. package/src/server-links/index.browser.ts +5 -5
  257. package/src/server-links/index.ts +9 -9
  258. package/src/server-links/{descriptors → primitives}/$remote.ts +11 -11
  259. package/src/server-links/providers/LinkProvider.ts +7 -7
  260. package/src/server-links/providers/{RemoteDescriptorProvider.ts → RemotePrimitiveProvider.ts} +6 -6
  261. package/src/server-links/providers/ServerLinksProvider.ts +3 -3
  262. package/src/server-proxy/index.ts +3 -3
  263. package/src/server-proxy/{descriptors → primitives}/$proxy.ts +8 -8
  264. package/src/server-proxy/providers/ServerProxyProvider.ts +4 -4
  265. package/src/server-rate-limit/index.ts +6 -6
  266. package/src/server-rate-limit/{descriptors → primitives}/$rateLimit.ts +13 -13
  267. package/src/server-rate-limit/providers/ServerRateLimitProvider.ts +5 -5
  268. package/src/server-security/index.ts +3 -3
  269. package/src/server-security/{descriptors → primitives}/$basicAuth.ts +13 -13
  270. package/src/server-security/providers/ServerBasicAuthProvider.ts +5 -5
  271. package/src/server-security/providers/ServerSecurityProvider.ts +4 -4
  272. package/src/server-static/index.ts +3 -3
  273. package/src/server-static/{descriptors → primitives}/$serve.ts +8 -10
  274. package/src/server-static/providers/ServerStaticProvider.ts +6 -6
  275. package/src/server-swagger/index.ts +5 -5
  276. package/src/server-swagger/{descriptors → primitives}/$swagger.ts +9 -9
  277. package/src/server-swagger/providers/ServerSwaggerProvider.ts +11 -10
  278. package/src/sms/index.ts +4 -4
  279. package/src/sms/{descriptors → primitives}/$sms.ts +8 -8
  280. package/src/thread/index.ts +3 -3
  281. package/src/thread/{descriptors → primitives}/$thread.ts +13 -13
  282. package/src/thread/providers/ThreadProvider.ts +7 -9
  283. package/src/topic/index.ts +5 -5
  284. package/src/topic/{descriptors → primitives}/$subscriber.ts +14 -14
  285. package/src/topic/{descriptors → primitives}/$topic.ts +10 -10
  286. package/src/topic/providers/TopicProvider.ts +4 -4
  287. package/src/vite/helpers/boot.ts +3 -3
  288. package/src/vite/tasks/copyAssets.ts +1 -1
  289. package/src/vite/tasks/generateSitemap.ts +3 -3
  290. package/src/vite/tasks/prerenderPages.ts +2 -2
  291. package/src/vite/tasks/runAlepha.ts +2 -2
  292. package/src/websocket/index.browser.ts +3 -3
  293. package/src/websocket/index.shared.ts +2 -2
  294. package/src/websocket/index.ts +4 -4
  295. package/src/websocket/interfaces/WebSocketInterfaces.ts +3 -3
  296. package/src/websocket/{descriptors → primitives}/$channel.ts +10 -10
  297. package/src/websocket/{descriptors → primitives}/$websocket.ts +8 -8
  298. package/src/websocket/providers/NodeWebSocketServerProvider.ts +7 -7
  299. package/src/websocket/providers/WebSocketServerProvider.ts +3 -3
  300. package/src/websocket/services/WebSocketClient.ts +5 -5
  301. package/dist/api-files/index.cjs +0 -1293
  302. package/dist/api-files/index.cjs.map +0 -1
  303. package/dist/api-files/index.d.cts +0 -829
  304. package/dist/api-jobs/index.cjs +0 -274
  305. package/dist/api-jobs/index.cjs.map +0 -1
  306. package/dist/api-jobs/index.d.cts +0 -654
  307. package/dist/api-notifications/index.cjs +0 -380
  308. package/dist/api-notifications/index.cjs.map +0 -1
  309. package/dist/api-notifications/index.d.cts +0 -289
  310. package/dist/api-parameters/index.cjs +0 -66
  311. package/dist/api-parameters/index.cjs.map +0 -1
  312. package/dist/api-parameters/index.d.cts +0 -84
  313. package/dist/api-users/index.cjs +0 -6009
  314. package/dist/api-users/index.cjs.map +0 -1
  315. package/dist/api-users/index.d.cts +0 -4740
  316. package/dist/api-verifications/index.cjs +0 -407
  317. package/dist/api-verifications/index.cjs.map +0 -1
  318. package/dist/api-verifications/index.d.cts +0 -207
  319. package/dist/batch/index.cjs +0 -408
  320. package/dist/batch/index.cjs.map +0 -1
  321. package/dist/batch/index.d.cts +0 -330
  322. package/dist/bin/index.cjs +0 -17
  323. package/dist/bin/index.cjs.map +0 -1
  324. package/dist/bin/index.d.cts +0 -1
  325. package/dist/bucket/index.cjs +0 -303
  326. package/dist/bucket/index.cjs.map +0 -1
  327. package/dist/bucket/index.d.cts +0 -355
  328. package/dist/cache/index.cjs +0 -241
  329. package/dist/cache/index.cjs.map +0 -1
  330. package/dist/cache/index.d.cts +0 -202
  331. package/dist/cache-redis/index.cjs +0 -84
  332. package/dist/cache-redis/index.cjs.map +0 -1
  333. package/dist/cache-redis/index.d.cts +0 -40
  334. package/dist/cli/chunk-DSlc6foC.cjs +0 -43
  335. package/dist/cli/dist-BBPjuQ56.js +0 -2778
  336. package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
  337. package/dist/cli/index.cjs +0 -1241
  338. package/dist/cli/index.cjs.map +0 -1
  339. package/dist/cli/index.d.cts +0 -422
  340. package/dist/command/index.cjs +0 -693
  341. package/dist/command/index.cjs.map +0 -1
  342. package/dist/command/index.d.cts +0 -340
  343. package/dist/core/index.cjs.map +0 -1
  344. package/dist/core/index.d.cts +0 -1927
  345. package/dist/datetime/index.cjs +0 -318
  346. package/dist/datetime/index.cjs.map +0 -1
  347. package/dist/datetime/index.d.cts +0 -145
  348. package/dist/email/index.cjs +0 -10874
  349. package/dist/email/index.cjs.map +0 -1
  350. package/dist/email/index.d.cts +0 -186
  351. package/dist/fake/index.cjs +0 -34641
  352. package/dist/fake/index.cjs.map +0 -1
  353. package/dist/fake/index.d.cts +0 -74
  354. package/dist/file/index.cjs +0 -1212
  355. package/dist/file/index.cjs.map +0 -1
  356. package/dist/file/index.d.cts +0 -698
  357. package/dist/lock/index.cjs +0 -226
  358. package/dist/lock/index.cjs.map +0 -1
  359. package/dist/lock/index.d.cts +0 -361
  360. package/dist/lock-redis/index.cjs +0 -113
  361. package/dist/lock-redis/index.cjs.map +0 -1
  362. package/dist/lock-redis/index.d.cts +0 -24
  363. package/dist/logger/index.cjs +0 -521
  364. package/dist/logger/index.cjs.map +0 -1
  365. package/dist/logger/index.d.cts +0 -281
  366. package/dist/orm/index.cjs +0 -2986
  367. package/dist/orm/index.cjs.map +0 -1
  368. package/dist/orm/index.d.cts +0 -2213
  369. package/dist/queue/index.cjs +0 -1044
  370. package/dist/queue/index.cjs.map +0 -1
  371. package/dist/queue/index.d.cts +0 -1265
  372. package/dist/queue-redis/index.cjs +0 -873
  373. package/dist/queue-redis/index.cjs.map +0 -1
  374. package/dist/queue-redis/index.d.cts +0 -82
  375. package/dist/redis/index.cjs +0 -153
  376. package/dist/redis/index.cjs.map +0 -1
  377. package/dist/redis/index.d.cts +0 -82
  378. package/dist/retry/index.cjs +0 -146
  379. package/dist/retry/index.cjs.map +0 -1
  380. package/dist/retry/index.d.cts +0 -172
  381. package/dist/router/index.cjs +0 -111
  382. package/dist/router/index.cjs.map +0 -1
  383. package/dist/router/index.d.cts +0 -46
  384. package/dist/scheduler/index.cjs +0 -576
  385. package/dist/scheduler/index.cjs.map +0 -1
  386. package/dist/scheduler/index.d.cts +0 -145
  387. package/dist/security/index.cjs +0 -2402
  388. package/dist/security/index.cjs.map +0 -1
  389. package/dist/security/index.d.cts +0 -598
  390. package/dist/server/index.cjs +0 -1680
  391. package/dist/server/index.cjs.map +0 -1
  392. package/dist/server/index.d.cts +0 -810
  393. package/dist/server-auth/index.cjs +0 -3146
  394. package/dist/server-auth/index.cjs.map +0 -1
  395. package/dist/server-auth/index.d.cts +0 -1164
  396. package/dist/server-cache/index.cjs +0 -252
  397. package/dist/server-cache/index.cjs.map +0 -1
  398. package/dist/server-cache/index.d.cts +0 -164
  399. package/dist/server-compress/index.cjs +0 -141
  400. package/dist/server-compress/index.cjs.map +0 -1
  401. package/dist/server-compress/index.d.cts +0 -38
  402. package/dist/server-cookies/index.cjs +0 -234
  403. package/dist/server-cookies/index.cjs.map +0 -1
  404. package/dist/server-cookies/index.d.cts +0 -144
  405. package/dist/server-cors/index.cjs +0 -201
  406. package/dist/server-cors/index.cjs.map +0 -1
  407. package/dist/server-cors/index.d.cts +0 -140
  408. package/dist/server-health/index.cjs +0 -62
  409. package/dist/server-health/index.cjs.map +0 -1
  410. package/dist/server-health/index.d.cts +0 -58
  411. package/dist/server-helmet/index.cjs +0 -131
  412. package/dist/server-helmet/index.cjs.map +0 -1
  413. package/dist/server-helmet/index.d.cts +0 -97
  414. package/dist/server-links/index.cjs +0 -992
  415. package/dist/server-links/index.cjs.map +0 -1
  416. package/dist/server-links/index.d.cts +0 -513
  417. package/dist/server-metrics/index.cjs +0 -4535
  418. package/dist/server-metrics/index.cjs.map +0 -1
  419. package/dist/server-metrics/index.d.cts +0 -35
  420. package/dist/server-multipart/index.cjs +0 -237
  421. package/dist/server-multipart/index.cjs.map +0 -1
  422. package/dist/server-multipart/index.d.cts +0 -50
  423. package/dist/server-proxy/index.cjs +0 -186
  424. package/dist/server-proxy/index.cjs.map +0 -1
  425. package/dist/server-proxy/index.d.cts +0 -234
  426. package/dist/server-rate-limit/index.cjs +0 -241
  427. package/dist/server-rate-limit/index.cjs.map +0 -1
  428. package/dist/server-rate-limit/index.d.cts +0 -183
  429. package/dist/server-security/index.cjs +0 -316
  430. package/dist/server-security/index.cjs.map +0 -1
  431. package/dist/server-security/index.d.cts +0 -173
  432. package/dist/server-static/index.cjs +0 -170
  433. package/dist/server-static/index.cjs.map +0 -1
  434. package/dist/server-static/index.d.cts +0 -121
  435. package/dist/server-swagger/index.cjs +0 -1021
  436. package/dist/server-swagger/index.cjs.map +0 -1
  437. package/dist/server-swagger/index.d.cts +0 -382
  438. package/dist/sms/index.cjs +0 -221
  439. package/dist/sms/index.cjs.map +0 -1
  440. package/dist/sms/index.d.cts +0 -130
  441. package/dist/thread/index.cjs +0 -350
  442. package/dist/thread/index.cjs.map +0 -1
  443. package/dist/thread/index.d.cts +0 -260
  444. package/dist/topic/index.cjs +0 -282
  445. package/dist/topic/index.cjs.map +0 -1
  446. package/dist/topic/index.d.cts +0 -523
  447. package/dist/topic-redis/index.cjs +0 -71
  448. package/dist/topic-redis/index.cjs.map +0 -1
  449. package/dist/topic-redis/index.d.cts +0 -42
  450. package/dist/vite/index.cjs +0 -1077
  451. package/dist/vite/index.cjs.map +0 -1
  452. package/dist/vite/index.d.cts +0 -542
  453. package/dist/websocket/index.cjs +0 -1117
  454. package/dist/websocket/index.cjs.map +0 -1
  455. package/dist/websocket/index.d.cts +0 -861
  456. package/src/api-notifications/providers/MemorySmsProvider.ts +0 -20
  457. package/src/api-notifications/providers/SmsProvider.ts +0 -8
  458. /package/src/core/{descriptors → primitives}/$atom.ts +0 -0
  459. /package/src/core/{descriptors → primitives}/$env.ts +0 -0
  460. /package/src/server-auth/{descriptors → primitives}/$authApple.ts +0 -0
  461. /package/src/server-links/{descriptors → primitives}/$client.ts +0 -0
@@ -1,1927 +0,0 @@
1
- import * as TypeBox from "typebox";
2
- import { Static as Static$1, StaticDecode, StaticDecode as Static, StaticEncode, StaticEncode as StaticEncode$1, TAny, TAny as TAny$1, TArray, TArray as TArray$1, TArrayOptions, TBigInt, TBoolean, TBoolean as TBoolean$1, TInteger, TInteger as TInteger$1, TInterface, TKeysToIndexer, TKeysToIndexer as TKeysToIndexer$1, TNull, TNull as TNull$1, TNumber, TNumber as TNumber$1, TNumberOptions, TNumberOptions as TNumberOptions$1, TObject, TObject as TObject$1, TObjectOptions, TObjectOptions as TObjectOptions$1, TOmit, TOptional, TOptionalAdd, TOptionalAdd as TOptionalAdd$1, TPartial, TPick, TPick as TPick$1, TProperties, TProperties as TProperties$1, TRecord, TRecord as TRecord$1, TSchema, TSchema as TSchema$1, TSchemaOptions, TString, TString as TString$1, TStringOptions, TStringOptions as TStringOptions$1, TTuple, TUnion, TUnion as TUnion$1, TUnsafe, TUnsafe as TUnsafe$1, TVoid } from "typebox";
3
- import { AsyncLocalStorage } from "node:async_hooks";
4
- import TypeBoxFormat from "typebox/format";
5
- import * as TypeBoxValue from "typebox/value";
6
- import { TLocalizedValidationError } from "typebox/error";
7
- import { Readable } from "node:stream";
8
- import { ReadableStream as ReadableStream$1 } from "node:stream/web";
9
- import { Validator } from "typebox/compile";
10
-
11
- //#region src/core/constants/KIND.d.ts
12
- /**
13
- * Used for identifying descriptors.
14
- *
15
- * @internal
16
- */
17
- declare const KIND: unique symbol;
18
- //#endregion
19
- //#region src/core/constants/MODULE.d.ts
20
- /**
21
- * Used for identifying modules.
22
- *
23
- * @internal
24
- */
25
- declare const MODULE: unique symbol;
26
- //#endregion
27
- //#region src/core/interfaces/Service.d.ts
28
- /**
29
- * In Alepha, a service is a class that can be instantiated or an abstract class. Nothing more, nothing less...
30
- */
31
- type Service<T extends object = any> = InstantiableClass<T> | AbstractClass<T> | RunFunction<T>;
32
- type RunFunction<T extends object = any> = (...args: any[]) => T | void;
33
- type InstantiableClass<T extends object = any> = new (...args: any[]) => T;
34
- /**
35
- * Abstract class is a class that cannot be instantiated directly!
36
- * It widely used for defining interfaces.
37
- */
38
- type AbstractClass<T extends object = any> = abstract new (...args: any[]) => T;
39
- /**
40
- * Service substitution allows you to register a class as a different class.
41
- * Providing class A, but using class B instead.
42
- * This is useful for testing, mocking, or providing a different implementation of a service.
43
- *
44
- * class A is mostly an AbstractClass, while class B is an InstantiableClass.
45
- */
46
- interface ServiceSubstitution<T extends object = any> {
47
- /**
48
- * Every time someone asks for this class, it will be provided with the 'use' class.
49
- */
50
- provide: Service<T>;
51
- /**
52
- * Service to use instead of the 'provide' service.
53
- *
54
- * Syntax is inspired by Angular's DI system.
55
- */
56
- use: Service<T>;
57
- /**
58
- * If true, if the service already exists -> just ignore the substitution and do not throw an error.
59
- * Mostly used for plugins to enforce a substitution without throwing an error.
60
- */
61
- optional?: boolean;
62
- }
63
- /**
64
- * Every time you register a service, you can use this type to define it.
65
- *
66
- * alepha.with( ServiceEntry )
67
- * or
68
- * alepha.with( provide: ServiceEntry, use: MyOwnServiceEntry )
69
- *
70
- * And yes, you declare the *type* of the service, not the *instance*.
71
- */
72
- type ServiceEntry<T extends object = any> = Service<T> | ServiceSubstitution<T>;
73
- declare function isClass(func: any): func is InstantiableClass;
74
- //#endregion
75
- //#region src/core/helpers/descriptor.d.ts
76
- interface DescriptorArgs<T extends object = {}> {
77
- options: T;
78
- alepha: Alepha;
79
- service: InstantiableClass<Service>;
80
- module?: Service;
81
- }
82
- interface DescriptorConfig {
83
- propertyKey: string;
84
- service: InstantiableClass<Service>;
85
- module?: Service;
86
- }
87
- declare abstract class Descriptor<T extends object = {}> {
88
- protected readonly alepha: Alepha;
89
- readonly options: T;
90
- readonly config: DescriptorConfig;
91
- constructor(args: DescriptorArgs<T>);
92
- /**
93
- * Called automatically by Alepha after the descriptor is created.
94
- */
95
- protected onInit(): void;
96
- }
97
- type DescriptorFactory<TDescriptor extends Descriptor = Descriptor> = {
98
- (options: TDescriptor["options"]): TDescriptor;
99
- [KIND]: InstantiableClass<TDescriptor>;
100
- };
101
- type DescriptorFactoryLike<T extends object = any> = {
102
- (options: T): any;
103
- [KIND]: any;
104
- };
105
- declare const createDescriptor: <TDescriptor extends Descriptor>(descriptor: InstantiableClass<TDescriptor> & {
106
- [MODULE]?: Service;
107
- }, options: TDescriptor["options"]) => TDescriptor;
108
- //#endregion
109
- //#region src/core/descriptors/$inject.d.ts
110
- /**
111
- * Get the instance of the specified type from the context.
112
- *
113
- * ```ts
114
- * class A { }
115
- * class B {
116
- * a = $inject(A);
117
- * }
118
- * ```
119
- */
120
- declare const $inject: <T extends object>(type: Service<T>, opts?: InjectOptions<T>) => T;
121
- declare class InjectDescriptor extends Descriptor {}
122
- interface InjectOptions<T extends object = any> {
123
- /**
124
- * - 'transient' → Always a new instance on every inject. Zero caching.
125
- * - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)
126
- * - 'scoped' → One instance per AsyncLocalStorage context.
127
- * - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...
128
- * - You can also start a manual scope via alepha.context.run(() => { ... }).
129
- * - When the scope ends, the scoped registry is discarded.
130
- *
131
- * @default "singleton"
132
- */
133
- lifetime?: "transient" | "singleton" | "scoped";
134
- /**
135
- * Constructor arguments to pass when creating a new instance.
136
- */
137
- args?: ConstructorParameters<InstantiableClass<T>>;
138
- /**
139
- * Parent that requested the instance.
140
- *
141
- * @internal
142
- */
143
- parent?: Service | null;
144
- }
145
- //#endregion
146
- //#region src/core/descriptors/$module.d.ts
147
- /**
148
- * Wrap Services and Descriptors into a Module.
149
- *
150
- * - A module is just a Service with some extra {@link Module}.
151
- * - You must attach a `name` to it.
152
- * - Name must follow the pattern: `project.module.submodule`. (e.g. `myapp.users.auth`).
153
- *
154
- * @example
155
- * ```ts
156
- * import { $module } from "alepha";
157
- * import { MyService } from "./MyService.ts";
158
- *
159
- * // export MyService, so it can be used everywhere (optional)
160
- * export * from "./MyService.ts";
161
- *
162
- * export default $module({
163
- * name: "my.project.module",
164
- * // MyService will have a module context "my.project.module"
165
- * services: [MyService],
166
- * });
167
- * ```
168
- *
169
- * ### Why Modules?
170
- *
171
- * #### Logging
172
- *
173
- * By default, AlephaLogger will log the module name in the logs.
174
- * This helps to identify where the logs are coming from.
175
- *
176
- * You can also set different log levels for different modules.
177
- * It means you can set 'some.very.specific.module' to 'debug' and keep the rest of the application to 'info'.
178
- *
179
- * #### Modulith
180
- *
181
- * Force to structure your application in modules, even if it's a single deployable unit.
182
- * It helps to keep a clean architecture and avoid monolithic applications.
183
- *
184
- * A strict mode flag will probably come to enforce module boundaries.
185
- * -> Throwing errors when a service from another module is injected.
186
- * But it's not implemented yet.
187
- *
188
- * ### When not to use Modules?
189
- *
190
- * Small applications does not need modules. It's better to keep it simple.
191
- * Modules are more useful when the application grows and needs to be structured.
192
- * If we speak with number of `$actions`, a module should be used when you have more than 30 actions in a single module.
193
- * Meaning that if you have 100 actions, you should have at least 3 modules.
194
- */
195
- declare const $module: <T extends object = {}>(options: ModuleDescriptorOptions) => Service<Module>;
196
- interface ModuleDescriptorOptions {
197
- /**
198
- * Name of the module.
199
- *
200
- * It should be in the format of `project.module.submodule`.
201
- */
202
- name: string;
203
- /**
204
- * List all services related to this module.
205
- *
206
- * If you don't declare 'register' function, all services will be registered automatically.
207
- * If you declare 'register' function, you must handle the registration of ALL services manually.
208
- */
209
- services?: Array<Service>;
210
- /**
211
- * List of $descriptors to register in the module.
212
- */
213
- descriptors?: Array<DescriptorFactoryLike>;
214
- /**
215
- * By default, module will register ALL services.
216
- * You can override this behavior by providing a register function.
217
- * It's useful when you want to register services conditionally or in a specific order.
218
- *
219
- * Again, if you declare 'register', you must handle the registration of ALL services manually.
220
- */
221
- register?: (alepha: Alepha) => void;
222
- }
223
- /**
224
- * Base class for all modules.
225
- */
226
- declare abstract class Module {
227
- abstract readonly options: ModuleDescriptorOptions;
228
- abstract register(alepha: Alepha): void;
229
- static NAME_REGEX: RegExp;
230
- /**
231
- * Check if a Service is a Module.
232
- */
233
- static is(ctor: Service): boolean;
234
- /**
235
- * Get the Module of a Service.
236
- *
237
- * Returns undefined if the Service is not part of a Module.
238
- */
239
- static of(ctor: Service): Service<Module> | undefined;
240
- }
241
- /**
242
- * Helper type to add Module metadata to a Service.
243
- */
244
- type WithModule<T extends object = any> = T & {
245
- [MODULE]?: Service;
246
- };
247
- //#endregion
248
- //#region src/core/interfaces/Async.d.ts
249
- /**
250
- * Represents a value that can be either a value or a promise of value.
251
- */
252
- type Async<T> = T | Promise<T>;
253
- /**
254
- * Represents a function that returns an async value.
255
- */
256
- type AsyncFn = (...args: any[]) => Async<any>;
257
- /**
258
- * Transforms a type T into a promise if it is not already a promise.
259
- */
260
- type MaybePromise<T> = T extends Promise<any> ? T : Promise<T>;
261
- //#endregion
262
- //#region src/core/interfaces/LoggerInterface.d.ts
263
- type LogLevel = "ERROR" | "WARN" | "INFO" | "DEBUG" | "TRACE" | "SILENT";
264
- interface LoggerInterface {
265
- trace(message: string, data?: unknown): void;
266
- debug(message: string, data?: unknown): void;
267
- info(message: string, data?: unknown): void;
268
- warn(message: string, data?: unknown): void;
269
- error(message: string, data?: unknown): void;
270
- }
271
- //#endregion
272
- //#region src/core/providers/AlsProvider.d.ts
273
- type AsyncLocalStorageData = any;
274
- declare class AlsProvider {
275
- static create: () => AsyncLocalStorage<AsyncLocalStorageData> | undefined;
276
- als?: AsyncLocalStorage<AsyncLocalStorageData>;
277
- constructor();
278
- createContextId(): string;
279
- run<R>(callback: () => R, data?: Record<string, any>): R;
280
- exists(): boolean;
281
- get<T>(key: string): T | undefined;
282
- set<T>(key: string, value: T): void;
283
- }
284
- //#endregion
285
- //#region src/core/providers/Json.d.ts
286
- /**
287
- * Mimics the JSON global object with stringify and parse methods.
288
- *
289
- * Used across the codebase via dependency injection.
290
- */
291
- declare class Json {
292
- stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
293
- parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
294
- }
295
- //#endregion
296
- //#region src/core/errors/AlephaError.d.ts
297
- /**
298
- * Default error class for Alepha.
299
- */
300
- declare class AlephaError extends Error {
301
- name: string;
302
- }
303
- //#endregion
304
- //#region src/core/errors/TypeBoxError.d.ts
305
- declare class TypeBoxError extends AlephaError {
306
- name: string;
307
- readonly cause: TLocalizedValidationError;
308
- readonly value: {
309
- path: string;
310
- message: string;
311
- };
312
- constructor(error: TLocalizedValidationError);
313
- }
314
- interface TypeBoxErrorParams {
315
- requiredProperties?: string[];
316
- }
317
- //#endregion
318
- //#region src/core/helpers/FileLike.d.ts
319
- interface FileLike {
320
- /**
321
- * Filename.
322
- * @default "file"
323
- */
324
- name: string;
325
- /**
326
- * Mandatory MIME type of the file.
327
- * @default "application/octet-stream"
328
- */
329
- type: string;
330
- /**
331
- * Size of the file in bytes.
332
- *
333
- * Always 0 for streams, as the size is not known until the stream is fully read.
334
- *
335
- * @default 0
336
- */
337
- size: number;
338
- /**
339
- * Last modified timestamp in milliseconds since epoch.
340
- *
341
- * Always the current timestamp for streams, as the last modified time is not known.
342
- * We use this field to ensure compatibility with File API.
343
- *
344
- * @default Date.now()
345
- */
346
- lastModified: number;
347
- /**
348
- * Returns a ReadableStream or Node.js Readable stream of the file content.
349
- *
350
- * For streams, this is the original stream.
351
- */
352
- stream(): StreamLike;
353
- /**
354
- * Returns the file content as an ArrayBuffer.
355
- *
356
- * For streams, this reads the entire stream into memory.
357
- */
358
- arrayBuffer(): Promise<ArrayBuffer>;
359
- /**
360
- * Returns the file content as a string.
361
- *
362
- * For streams, this reads the entire stream into memory and converts it to a string.
363
- */
364
- text(): Promise<string>;
365
- /**
366
- * Optional file path, if the file is stored on disk.
367
- *
368
- * This is not from the File API, but rather a custom field to indicate where the file is stored.
369
- */
370
- filepath?: string;
371
- }
372
- /**
373
- * TypeBox view of FileLike.
374
- */
375
- type TFile = TUnsafe$1<FileLike>;
376
- declare const isTypeFile: (value: TSchema$1) => value is TFile;
377
- declare const isFileLike: (value: any) => value is FileLike;
378
- type StreamLike = ReadableStream | ReadableStream$1 | Readable | NodeJS.ReadableStream;
379
- type TStream = TUnsafe$1<StreamLike>;
380
- //#endregion
381
- //#region src/core/providers/TypeProvider.d.ts
382
- declare const isUUID: typeof TypeBoxFormat.IsUuid;
383
- declare const isEmail: typeof TypeBoxFormat.IsEmail;
384
- declare const isURL: typeof TypeBoxFormat.IsUrl;
385
- declare const isDateTime: typeof TypeBoxFormat.IsDateTime;
386
- declare const isDate: typeof TypeBoxFormat.IsDate;
387
- declare const isTime: typeof TypeBoxFormat.IsTime;
388
- declare const isDuration: typeof TypeBoxFormat.IsDuration;
389
- declare class TypeGuard {
390
- isBigInt: (value: TSchema$1) => value is TString$1;
391
- isUUID: (value: TSchema$1) => value is TString$1;
392
- isObject: typeof TypeBox.IsObject;
393
- isNumber: typeof TypeBox.IsNumber;
394
- isString: typeof TypeBox.IsString;
395
- isBoolean: typeof TypeBox.IsBoolean;
396
- isAny: typeof TypeBox.IsAny;
397
- isArray: typeof TypeBox.IsArray;
398
- isOptional: typeof TypeBox.IsOptional;
399
- isUnion: typeof TypeBox.IsUnion;
400
- isInteger: typeof TypeBox.IsInteger;
401
- isNull: typeof TypeBox.IsNull;
402
- isUndefined: typeof TypeBox.IsUndefined;
403
- isUnsafe: typeof TypeBox.IsUnsafe;
404
- isRecord: typeof TypeBox.IsRecord;
405
- isTuple: typeof TypeBox.IsTuple;
406
- isVoid: typeof TypeBox.IsVoid;
407
- isLiteral: typeof TypeBox.IsLiteral;
408
- isSchema: typeof TypeBox.IsSchema;
409
- isFile: (value: TSchema$1) => value is TFile;
410
- isDateTime: (schema: unknown) => boolean;
411
- isDate: (schema: unknown) => boolean;
412
- isTime: (schema: unknown) => boolean;
413
- isDuration: (schema: unknown) => boolean;
414
- }
415
- declare module "typebox" {
416
- interface TString {
417
- format?: string;
418
- minLength?: number;
419
- maxLength?: number;
420
- }
421
- interface TNumber {
422
- format?: "int64";
423
- }
424
- }
425
- declare class TypeProvider {
426
- static format: typeof TypeBoxFormat;
427
- static translateError(error: TypeBoxError, locale?: string): string;
428
- static setLocale(locale: string): void;
429
- static isValidBigInt(value: string | number): boolean;
430
- /**
431
- * Default maximum length for strings.
432
- *
433
- * It can be set to a larger value:
434
- * ```ts
435
- * TypeProvider.DEFAULT_STRING_MAX_LENGTH = 1000000;
436
- * TypeProvider.DEFAULT_STRING_MAX_LENGTH = undefined; // no limit (not recommended)
437
- * ```
438
- */
439
- static DEFAULT_STRING_MAX_LENGTH: number | undefined;
440
- /**
441
- * Maximum length for short strings, such as names or titles.
442
- */
443
- static DEFAULT_SHORT_STRING_MAX_LENGTH: number | undefined;
444
- /**
445
- * Maximum length for long strings, such as descriptions or comments.
446
- * It can be overridden in the string options.
447
- *
448
- * It can be set to a larger value:
449
- * ```ts
450
- * TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH = 2048;
451
- * ```
452
- */
453
- static DEFAULT_LONG_STRING_MAX_LENGTH: number | undefined;
454
- /**
455
- * Maximum length for rich strings, such as HTML or Markdown.
456
- * This is a large value to accommodate rich text content.
457
- * > It's also the maximum length of PG's TEXT type.
458
- *
459
- * It can be overridden in the string options.
460
- *
461
- * It can be set to a larger value:
462
- * ```ts
463
- * TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH = 1000000;
464
- * ```
465
- */
466
- static DEFAULT_RICH_STRING_MAX_LENGTH: number | undefined;
467
- /**
468
- * Maximum number of items in an array.
469
- * This is a default value to prevent excessive memory usage.
470
- * It can be overridden in the array options.
471
- */
472
- static DEFAULT_ARRAY_MAX_ITEMS: number;
473
- raw: typeof TypeBox.Type;
474
- any: typeof TypeBox.Any;
475
- void: typeof TypeBox.Void;
476
- undefined: typeof TypeBox.Undefined;
477
- record: typeof TypeBox.Record;
478
- union: typeof TypeBox.Union;
479
- tuple: typeof TypeBox.Tuple;
480
- null: typeof TypeBox.Null;
481
- const: typeof TypeBox.Literal;
482
- options: typeof TypeBox.Options;
483
- /**
484
- * Type guards to check the type of schema.
485
- * This is not a runtime type check, but a compile-time type guard.
486
- *
487
- * @example
488
- * ```ts
489
- * if (t.schema.isString(schema)) {
490
- * // schema is TString
491
- * }
492
- * ```
493
- */
494
- readonly schema: TypeGuard;
495
- extend<T extends TSchema$1[], U$1 extends TProperties$1>(schema: [...T], properties: U$1, options?: TSchemaOptions): TInterface<T, U$1>;
496
- extend<T extends TObject$1, U$1 extends TProperties$1>(schema: T, properties: U$1, options?: TSchemaOptions): TInterface<[T], U$1>;
497
- pick<T extends TObject$1, Indexer extends PropertyKey[]>(schema: T, keys: [...Indexer], options?: TObjectOptions$1): TPick$1<T, TKeysToIndexer$1<Indexer>>;
498
- omit<T extends TObject$1, Indexer extends PropertyKey[]>(schema: T, keys: [...Indexer], options?: TObjectOptions$1): TOmit<T, TKeysToIndexer$1<Indexer>>;
499
- partial<T extends TSchema$1>(schema: T, options?: TSchemaOptions): TPartial<T>;
500
- /**
501
- * Create a schema for an object.
502
- * By default, additional properties are not allowed.
503
- *
504
- * @example
505
- * ```ts
506
- * const userSchema = t.object({
507
- * id: t.integer(),
508
- * name: t.string(),
509
- * });
510
- * ```
511
- */
512
- object<T extends TProperties$1>(properties: T, options?: TObjectOptions$1): TObject$1<T>;
513
- /**
514
- * Create a schema for an array.
515
- * By default, the maximum number of items is limited to prevent excessive memory usage.
516
- *
517
- * @see TypeProvider.DEFAULT_ARRAY_MAX_ITEMS
518
- */
519
- array<T extends TSchema$1>(schema: T, options?: TArrayOptions): TArray$1<T>;
520
- /**
521
- * Create a schema for a string.
522
- * For db or input fields, consider using `t.text()` instead, which has length limits.
523
- *
524
- * If you need a string with specific format (e.g. email, uuid), consider using the corresponding method (e.g. `t.email()`, `t.uuid()`).
525
- */
526
- string(options?: TStringOptions$1): TString$1;
527
- /**
528
- * Create a schema for a string with length limits.
529
- * For internal strings without length limits, consider using `t.string()` instead.
530
- *
531
- * Default size is "regular", which has a max length of 255 characters.
532
- */
533
- text(options?: TTextOptions): TString$1;
534
- /**
535
- * Create a schema for a JSON object.
536
- * This is a record with string keys and any values.
537
- */
538
- json(options?: TSchemaOptions): TRecord$1<string, TAny$1>;
539
- /**
540
- * Create a schema for a boolean.
541
- */
542
- boolean(options?: TSchemaOptions): TBoolean$1;
543
- /**
544
- * Create a schema for a number.
545
- */
546
- number(options?: TNumberOptions$1): TNumber$1;
547
- /**
548
- * Create a schema for an integer.
549
- */
550
- integer(options?: TNumberOptions$1): TInteger$1;
551
- int32(options?: TNumberOptions$1): TInteger$1;
552
- /**
553
- * Mimic a signed 64-bit integer.
554
- *
555
- * This is NOT a true int64, as JavaScript cannot represent all int64 values.
556
- * It is a number that is an integer and between -9007199254740991 and 9007199254740991.
557
- * Use `t.bigint()` for true int64 values represented as strings.
558
- */
559
- int64(options?: TNumberOptions$1): TNumber$1;
560
- /**
561
- * Make a schema optional.
562
- */
563
- optional<T extends TSchema$1>(schema: T): TOptionalAdd$1<T>;
564
- /**
565
- * Make a schema nullable.
566
- */
567
- nullable<T extends TSchema$1>(schema: T, options?: TObjectOptions$1): TUnion$1<[TNull$1, T]>;
568
- /**
569
- * Create a schema that maps all properties of an object schema to nullable.
570
- */
571
- nullify: <T extends TSchema$1>(schema: T, options?: TObjectOptions$1) => TypeBox.TMappedInstantiate<{}, {
572
- callstack: [];
573
- }, TypeBox.TIdentifier<"K">, TypeBox.TKeyOfInstantiate<{}, {
574
- callstack: [];
575
- }, T>, TypeBox.TRef<"K">, TUnion$1<[TypeBox.TIndexInstantiate<{}, {
576
- callstack: [];
577
- }, T, TypeBox.TRef<"K">>, TNull$1]>>;
578
- /**
579
- * Create a schema for a string enum.
580
- */
581
- enum<T extends string[]>(values: [...T], options?: TTextOptions): TUnsafe$1<T[number]>;
582
- /**
583
- * Create a schema for a bigint represented as a string.
584
- * This is a string that validates bigint format (e.g. "123456789").
585
- */
586
- bigint(options?: TStringOptions$1): TString$1;
587
- /**
588
- * Create a schema for a URL represented as a string.
589
- */
590
- url(options?: TStringOptions$1): TString$1;
591
- /**
592
- * Create a schema for binary data represented as a base64 string.
593
- */
594
- binary(options: TStringOptions$1): TString$1;
595
- /**
596
- * Create a schema for uuid.
597
- */
598
- uuid(options?: TStringOptions$1): TString$1;
599
- /**
600
- * Create a schema for a file-like object.
601
- *
602
- * File like mimics the File API in browsers, but is adapted to work in Node.js as well.
603
- *
604
- * Implementation of file-like objects is handled by "alepha/file" package.
605
- */
606
- file(options?: {
607
- maxSize?: number;
608
- }): TFile;
609
- /**
610
- * @experimental
611
- */
612
- stream(): TStream;
613
- email(options?: TStringOptions$1): TString$1;
614
- e164(options?: TStringOptions$1): TString$1;
615
- bcp47(options?: TStringOptions$1): TString$1;
616
- /**
617
- * Create a schema for short text, such as names or titles.
618
- * Default max length is 64 characters.
619
- */
620
- shortText(options?: TStringOptions$1): TString$1;
621
- /**
622
- * Create a schema for long text, such as descriptions or comments.
623
- * Default max length is 1024 characters.
624
- */
625
- longText(options?: TStringOptions$1): TString$1;
626
- /**
627
- * Create a schema for rich text, such as HTML or Markdown.
628
- * Default max length is 65535 characters.
629
- */
630
- richText(options?: TStringOptions$1): TString$1;
631
- /**
632
- * Create a schema for a string enum e.g. LIKE_THIS.
633
- */
634
- snakeCase: (options?: TStringOptions$1) => TString$1;
635
- /**
636
- * Create a schema for an object with a value and label.
637
- */
638
- valueLabel: (options?: TObjectOptions$1) => TObject$1<{
639
- value: TString$1;
640
- label: TString$1;
641
- description: TypeBox.TOptional<TString$1>;
642
- }>;
643
- datetime: (options?: TStringOptions$1) => TString$1;
644
- date: (options?: TStringOptions$1) => TString$1;
645
- time: (options?: TStringOptions$1) => TString$1;
646
- duration: (options?: TStringOptions$1) => TString$1;
647
- }
648
- type TextLength = "short" | "regular" | "long" | "rich";
649
- interface TTextOptions extends TStringOptions$1 {
650
- /**
651
- * Predefined size of the text.
652
- *
653
- * - `short` - short text, such as names or titles. Default max length is 64 characters.
654
- * - `regular` - regular text, such as single-line input. Default max length is 255 characters.
655
- * - `long` - long text, such as descriptions or comments. Default max length is 1024 characters.
656
- * - `rich` - rich text, such as HTML or Markdown. Default max length is 65535 characters.
657
- *
658
- * You can override the default max length by specifying `maxLength` in the options.
659
- *
660
- * @default "regular"
661
- */
662
- size?: TextLength;
663
- /**
664
- * Trim whitespace from both ends of the string.
665
- *
666
- * @default true
667
- */
668
- trim?: boolean;
669
- /**
670
- * Convert the string to lowercase.
671
- *
672
- * @default false
673
- */
674
- lowercase?: boolean;
675
- }
676
- declare const t: TypeProvider;
677
- //#endregion
678
- //#region src/core/providers/SchemaCodec.d.ts
679
- declare abstract class SchemaCodec {
680
- /**
681
- * Encode the value to a string format.
682
- */
683
- abstract encodeToString<T extends TSchema>(schema: T, value: Static<T>): string;
684
- /**
685
- * Encode the value to a binary format.
686
- */
687
- abstract encodeToBinary<T extends TSchema>(schema: T, value: Static<T>): Uint8Array;
688
- /**
689
- * Decode string, binary, or other formats to the schema type.
690
- */
691
- abstract decode<T>(schema: TSchema, value: unknown): T;
692
- }
693
- //#endregion
694
- //#region src/core/providers/JsonSchemaCodec.d.ts
695
- declare class JsonSchemaCodec extends SchemaCodec {
696
- protected readonly json: Json;
697
- protected readonly encoder: TextEncoder;
698
- protected readonly decoder: TextDecoder;
699
- encodeToString<T extends TSchema$1>(schema: T, value: Static<T>): string;
700
- encodeToBinary<T extends TSchema$1>(schema: T, value: Static<T>): Uint8Array;
701
- decode<T>(schema: TSchema$1, value: unknown): T;
702
- }
703
- //#endregion
704
- //#region src/core/providers/SchemaValidator.d.ts
705
- declare class SchemaValidator {
706
- protected cache: Map<TSchema$1, Validator<TypeBox.TProperties, TSchema$1, unknown, unknown>>;
707
- /**
708
- * Validate the value against the provided schema.
709
- *
710
- * Validation create a new value by applying some preprocessing. (e.g., trimming text)
711
- */
712
- validate<T extends TSchema$1>(schema: T, value: unknown, options?: ValidateOptions): Static<T>;
713
- protected getValidator<T extends TSchema$1>(schema: T): Validator<{}, T>;
714
- /**
715
- * Preprocess the value based on the schema before validation.
716
- *
717
- * - If the value is `null` and the schema does not allow `null`, it converts it to `undefined`.
718
- * - If the value is a string and the schema has a `~options.trim` flag, it trims whitespace from the string.
719
- */
720
- beforeParse(schema: any, value: any, options: ValidateOptions): any;
721
- /**
722
- * Used by `beforeParse` to determine if a schema allows null values.
723
- */
724
- protected isSchemaNullable: (schema: any) => boolean;
725
- }
726
- interface ValidateOptions {
727
- trim?: boolean;
728
- nullToUndefined?: boolean;
729
- deleteUndefined?: boolean;
730
- }
731
- //#endregion
732
- //#region src/core/providers/CodecManager.d.ts
733
- type Encoding = "object" | "string" | "binary";
734
- interface EncodeOptions<T extends Encoding = Encoding> {
735
- /**
736
- * The output encoding format:
737
- * - 'string': Returns JSON string
738
- * - 'binary': Returns Uint8Array (for protobuf, msgpack, etc.)
739
- *
740
- * @default "string"
741
- */
742
- as?: T;
743
- /**
744
- * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
745
- *
746
- * @default "json"
747
- */
748
- encoder?: string;
749
- /**
750
- * Validation options to apply before encoding.
751
- */
752
- validation?: ValidateOptions | false;
753
- }
754
- type EncodeResult<T extends TSchema$1, E extends Encoding> = E extends "string" ? string : E extends "binary" ? Uint8Array : StaticEncode$1<T>;
755
- interface DecodeOptions {
756
- /**
757
- * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
758
- *
759
- * @default "json"
760
- */
761
- encoder?: string;
762
- /**
763
- * Validation options to apply before encoding.
764
- */
765
- validation?: ValidateOptions | false;
766
- }
767
- /**
768
- * CodecManager manages multiple codec formats and provides a unified interface
769
- * for encoding and decoding data with different formats.
770
- */
771
- declare class CodecManager {
772
- protected readonly codecs: Map<string, SchemaCodec>;
773
- protected readonly jsonCodec: JsonSchemaCodec;
774
- protected readonly schemaValidator: SchemaValidator;
775
- default: string;
776
- constructor();
777
- /**
778
- * Register a new codec format.
779
- *
780
- * @param name - The name of the codec (e.g., 'json', 'protobuf')
781
- * @param codec - The codec implementation
782
- */
783
- register(name: string, codec: SchemaCodec): void;
784
- /**
785
- * Get a specific codec by name.
786
- *
787
- * @param name - The name of the codec
788
- * @returns The codec instance
789
- * @throws {AlephaError} If the codec is not found
790
- */
791
- getCodec(name: string): SchemaCodec;
792
- /**
793
- * Encode data using the specified codec and output format.
794
- */
795
- encode<T extends TSchema$1, E extends Encoding = "object">(schema: T, value: unknown, options?: EncodeOptions<E>): EncodeResult<T, E>;
796
- /**
797
- * Decode data using the specified codec.
798
- */
799
- decode<T extends TSchema$1>(schema: T, data: any, options?: DecodeOptions): Static<T>;
800
- /**
801
- * Validate decoded data against the schema.
802
- *
803
- * This is automatically called before encoding or after decoding.
804
- */
805
- validate<T extends TSchema$1>(schema: T, value: unknown, options?: ValidateOptions): Static<T>;
806
- }
807
- //#endregion
808
- //#region src/core/providers/EventManager.d.ts
809
- declare class EventManager {
810
- protected logFn?: () => LoggerInterface | undefined;
811
- /**
812
- * List of events that can be triggered. Powered by $hook().
813
- */
814
- protected events: Record<string, Array<Hook>>;
815
- constructor(logFn?: () => LoggerInterface | undefined);
816
- protected get log(): LoggerInterface | undefined;
817
- /**
818
- * Registers a hook for the specified event.
819
- */
820
- on<T extends keyof Hooks>(event: T, hookOrFunc: Hook<T> | ((payload: Hooks[T]) => Async<void>)): () => void;
821
- /**
822
- * Emits the specified event with the given payload.
823
- */
824
- emit<T extends keyof Hooks>(func: T, payload: Hooks[T], options?: {
825
- /**
826
- * If true, the hooks will be executed in reverse order.
827
- * This is useful for "stop" hooks that should be executed in reverse order.
828
- *
829
- * @default false
830
- */
831
- reverse?: boolean;
832
- /**
833
- * If true, the hooks will be logged with their execution time.
834
- *
835
- * @default false
836
- */
837
- log?: boolean;
838
- /**
839
- * If true, errors will be caught and logged instead of throwing.
840
- *
841
- * @default false
842
- */
843
- catch?: boolean;
844
- }): Promise<void>;
845
- }
846
- //#endregion
847
- //#region src/core/descriptors/$atom.d.ts
848
- /**
849
- * Define an atom for state management.
850
- *
851
- * Atom lets you define a piece of state with a name, schema, and default value.
852
- *
853
- * By default, Alepha state is just a simple key-value store.
854
- * Using atoms allows you to have type safety, validation, and default values for your state.
855
- *
856
- * You control how state is structured and validated.
857
- *
858
- * Features:
859
- * - Set a schema for validation
860
- * - Set a default value for initial state
861
- * - Rules, like read-only, custom validation, etc.
862
- * - Automatic getter access in services with {@link $use}
863
- * - SSR support (server state automatically serialized and hydrated on client)
864
- * - React integration (useAtom hook for automatic component re-renders)
865
- * - Middleware
866
- * - Persistence adapters (localStorage, Redis, database, file system, cookie, etc.)
867
- * - State migrations (version upgrades when schema changes)
868
- * - Documentation generation & devtools integration
869
- *
870
- * Common use cases:
871
- * - user preferences
872
- * - feature flags
873
- * - configuration options
874
- * - session data
875
- *
876
- * Atom must contain only serializable data.
877
- * Avoid storing complex objects like class instances, functions, or DOM elements.
878
- * If you need to store complex data, consider using identifiers or references instead.
879
- */
880
- declare const $atom: {
881
- <T extends TObject<TProperties$2> | TArray$1, N extends string>(options: AtomOptions<T, N>): Atom<T, N>;
882
- [KIND]: string;
883
- };
884
- type AtomOptions<T extends TAtomObject, N extends string> = {
885
- name: N;
886
- schema: T;
887
- description?: string;
888
- } & (T extends TOptionalAdd<T> ? {
889
- default?: Static<T>;
890
- } : {
891
- default: Static<T>;
892
- });
893
- declare class Atom<T extends TAtomObject = TObject, N extends string = string> {
894
- readonly options: AtomOptions<T, N>;
895
- get schema(): T;
896
- get key(): N;
897
- constructor(options: AtomOptions<T, N>);
898
- }
899
- type TProperties$2 = any;
900
- type TAtomObject = TObject<any> | TArray$1;
901
- type AtomStatic<T extends TAtomObject> = T extends TOptionalAdd<T> ? Static<T> | undefined : Static<T>;
902
- //#endregion
903
- //#region src/core/providers/StateManager.d.ts
904
- interface AtomWithValue {
905
- atom: Atom;
906
- value: unknown;
907
- }
908
- declare class StateManager<State$1 extends object = State> {
909
- protected readonly als: AlsProvider;
910
- protected readonly events: EventManager;
911
- protected readonly codec: JsonSchemaCodec;
912
- protected readonly atoms: Map<keyof State$1, Atom<TObject$1<TypeBox.TProperties>, string>>;
913
- protected store: Partial<State$1>;
914
- constructor(store?: Partial<State$1>);
915
- getAtoms(context?: boolean): Array<AtomWithValue>;
916
- register(atom: Atom<any>): this;
917
- /**
918
- * Get a value from the state with proper typing
919
- */
920
- get<T extends TAtomObject>(target: Atom<T>): Static<T>;
921
- get<Key extends keyof State$1>(target: Key): State$1[Key] | undefined;
922
- /**
923
- * Set a value in the state
924
- */
925
- set<T extends TAtomObject>(target: Atom<T>, value: AtomStatic<T>): this;
926
- set<Key extends keyof State$1>(target: Key, value: State$1[Key] | undefined): this;
927
- /**
928
- * Mutate a value in the state.
929
- */
930
- mut<T extends TObject$1>(target: Atom<T>, mutator: (current: Static<T>) => Static<T>): this;
931
- mut<Key extends keyof State$1>(target: Key, mutator: (current: State$1[Key] | undefined) => State$1[Key] | undefined): this;
932
- /**
933
- * Check if a key exists in the state
934
- */
935
- has<Key extends keyof State$1>(key: Key): boolean;
936
- /**
937
- * Delete a key from the state (set to undefined)
938
- */
939
- del<Key extends keyof State$1>(key: Key): this;
940
- /**
941
- * Push a value to an array in the state
942
- */
943
- push<Key extends keyof OnlyArray<State$1>>(key: Key, value: NonNullable<State$1[Key]> extends Array<infer U> ? U : never): this;
944
- /**
945
- * Clear all state
946
- */
947
- clear(): this;
948
- /**
949
- * Get all keys that exist in the state
950
- */
951
- keys(): (keyof State$1)[];
952
- }
953
- type OnlyArray<T extends object> = { [K in keyof T]: NonNullable<T[K]> extends Array<any> ? K : never };
954
- //#endregion
955
- //#region src/core/Alepha.d.ts
956
- /**
957
- * Core container of the Alepha framework.
958
- *
959
- * It is responsible for managing the lifecycle of services,
960
- * handling dependency injection,
961
- * and providing a unified interface for the application.
962
- *
963
- * @example
964
- * ```ts
965
- * import { Alepha, run } from "alepha";
966
- *
967
- * class MyService {
968
- * // business logic here
969
- * }
970
- *
971
- * const alepha = Alepha.create({
972
- * // state, env, and other properties
973
- * })
974
- *
975
- * alepha.with(MyService);
976
- *
977
- * run(alepha); // trigger .start (and .stop) automatically
978
- * ```
979
- *
980
- * ### Alepha Factory
981
- *
982
- * Alepha.create() is an enhanced version of new Alepha().
983
- * - It merges `process.env` with the provided state.env when available.
984
- * - It populates the test hooks for Vitest or Jest environments when available.
985
- *
986
- * new Alepha() is fine if you don't need these helpers.
987
- *
988
- * ### Platforms & Environments
989
- *
990
- * Alepha is designed to work in various environments:
991
- * - **Browser**: Runs in the browser, using the global `window` object.
992
- * - **Serverless**: Runs in serverless environments like Vercel or Vite.
993
- * - **Test**: Runs in test environments like Jest or Vitest.
994
- * - **Production**: Runs in production environments, typically with NODE_ENV set to "production".
995
- * * You can check the current environment using the following methods:
996
- *
997
- * - `isBrowser()`: Returns true if the App is running in a browser environment.
998
- * - `isServerless()`: Returns true if the App is running in a serverless environment.
999
- * - `isTest()`: Returns true if the App is running in a test environment.
1000
- * - `isProduction()`: Returns true if the App is running in a production environment.
1001
- *
1002
- * ### State & Environment
1003
- *
1004
- * The state of the Alepha container is stored in the `store` property.
1005
- * Most important property is `store.env`, which contains the environment variables.
1006
- *
1007
- * ```ts
1008
- * const alepha = Alepha.create({ env: { MY_VAR: "value" } });
1009
- *
1010
- * // You can access the environment variables using alepha.env
1011
- * console.log(alepha.env.MY_VAR); // "value"
1012
- *
1013
- * // But you should use $env() descriptor to get typed values from the environment.
1014
- * class App {
1015
- * env = $env(
1016
- * t.object({
1017
- * MY_VAR: t.text(),
1018
- * })
1019
- * );
1020
- * }
1021
- * ```
1022
- *
1023
- * ### Modules
1024
- *
1025
- * Modules are a way to group services together.
1026
- * You can register a module using the `$module` descriptor.
1027
- *
1028
- * ```ts
1029
- * import { $module } from "alepha";
1030
- *
1031
- * class MyLib {}
1032
- *
1033
- * const myModule = $module({
1034
- * name: "my.project.module",
1035
- * services: [MyLib],
1036
- * });
1037
- * ```
1038
- *
1039
- * Do not use modules for small applications.
1040
- *
1041
- * ### Hooks
1042
- *
1043
- * Hooks are a way to run async functions from all registered providers/services.
1044
- * You can register a hook using the `$hook` descriptor.
1045
- *
1046
- * ```ts
1047
- * import { $hook } from "alepha";
1048
- *
1049
- * class App {
1050
- * log = $logger();
1051
- * onCustomerHook = $hook({
1052
- * on: "my:custom:hook",
1053
- * handler: () => {
1054
- * this.log?.info("App is being configured");
1055
- * },
1056
- * });
1057
- * }
1058
- *
1059
- * Alepha.create()
1060
- * .with(App)
1061
- * .start()
1062
- * .then(alepha => alepha.events.emit("my:custom:hook"));
1063
- * ```
1064
- *
1065
- * Hooks are fully typed. You can create your own hooks by using module augmentation:
1066
- *
1067
- * ```ts
1068
- * declare module "alepha" {
1069
- * interface Hooks {
1070
- * "my:custom:hook": {
1071
- * arg1: string;
1072
- * }
1073
- * }
1074
- * }
1075
- * ```
1076
- *
1077
- * @module alepha
1078
- */
1079
- declare class Alepha {
1080
- /**
1081
- * Creates a new instance of the Alepha container with some helpers:
1082
- *
1083
- * - merges `process.env` with the provided state.env when available.
1084
- * - populates the test hooks for Vitest or Jest environments when available.
1085
- *
1086
- * If you are not interested about these helpers, you can use the constructor directly.
1087
- */
1088
- static create(state?: Partial<State>): Alepha;
1089
- /**
1090
- * Flag indicating whether the App won't accept any further changes.
1091
- * Pass to true when #start() is called.
1092
- */
1093
- protected locked: boolean;
1094
- /**
1095
- * True if the App has been configured.
1096
- */
1097
- protected configured: boolean;
1098
- /**
1099
- * True if the App has started.
1100
- */
1101
- protected started: boolean;
1102
- /**
1103
- * True if the App is ready.
1104
- */
1105
- protected ready: boolean;
1106
- /**
1107
- * A promise that resolves when the App has started.
1108
- */
1109
- protected starting?: PromiseWithResolvers<this>;
1110
- /**
1111
- * Initial state of the container.
1112
- *
1113
- * > Used to initialize the StateManager.
1114
- */
1115
- protected init: Partial<State>;
1116
- /**
1117
- * During the instantiation process, we keep a list of pending instantiations.
1118
- * > It allows us to detect circular dependencies.
1119
- */
1120
- protected pendingInstantiations: Service[];
1121
- /**
1122
- * Cache for environment variables.
1123
- * > It allows us to avoid parsing the same schema multiple times.
1124
- */
1125
- protected cacheEnv: Map<TSchema, any>;
1126
- /**
1127
- * List of modules that are registered in the container.
1128
- *
1129
- * Modules are used to group services and provide a way to register them in the container.
1130
- */
1131
- protected modules: Array<Module>;
1132
- /**
1133
- * List of service substitutions.
1134
- *
1135
- * Services registered here will be replaced by the specified service when injected.
1136
- */
1137
- protected substitutions: Map<Service, {
1138
- use: Service;
1139
- }>;
1140
- /**
1141
- * Registry of descriptors.
1142
- */
1143
- protected descriptorRegistry: Map<Service<Descriptor<{}>>, Descriptor<{}>[]>;
1144
- /**
1145
- * List of all services + how they are provided.
1146
- */
1147
- protected registry: Map<Service, ServiceDefinition>;
1148
- /**
1149
- * Node.js feature that allows to store context across asynchronous calls.
1150
- *
1151
- * This is used for logging, tracing, and other context-related features.
1152
- *
1153
- * Mocked for browser environments.
1154
- */
1155
- get context(): AlsProvider;
1156
- /**
1157
- * Event manager to handle lifecycle events and custom events.
1158
- */
1159
- get events(): EventManager;
1160
- /**
1161
- * State manager to store arbitrary values.
1162
- */
1163
- get state(): StateManager<State>;
1164
- /**
1165
- * Codec manager for encoding and decoding data with different formats.
1166
- *
1167
- * Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.
1168
- */
1169
- get codec(): CodecManager;
1170
- /**
1171
- * Get logger instance.
1172
- */
1173
- get log(): LoggerInterface | undefined;
1174
- /**
1175
- * The environment variables for the App.
1176
- */
1177
- get env(): Readonly<Env>;
1178
- constructor(init?: Partial<State>);
1179
- /**
1180
- * True when start() is called.
1181
- *
1182
- * -> No more services can be added, it's over, bye!
1183
- */
1184
- isLocked(): boolean;
1185
- /**
1186
- * Returns whether the App is configured.
1187
- *
1188
- * It means that Alepha#configure() has been called.
1189
- *
1190
- * > By default, configure() is called automatically when start() is called, but you can also call it manually.
1191
- */
1192
- isConfigured(): boolean;
1193
- /**
1194
- * Returns whether the App has started.
1195
- *
1196
- * It means that #start() has been called but maybe not all services are ready.
1197
- */
1198
- isStarted(): boolean;
1199
- /**
1200
- * True if the App is ready. It means that Alepha is started AND ready() hook has beed called.
1201
- */
1202
- isReady(): boolean;
1203
- /**
1204
- * True if the App is running in a Continuous Integration environment.
1205
- */
1206
- isCI(): boolean;
1207
- /**
1208
- * True if the App is running in a browser environment.
1209
- */
1210
- isBrowser(): boolean;
1211
- /**
1212
- * Returns whether the App is running in Vite dev mode.
1213
- */
1214
- isViteDev(): boolean;
1215
- isBun(): boolean;
1216
- /**
1217
- * Returns whether the App is running in a serverless environment.
1218
- */
1219
- isServerless(): boolean;
1220
- /**
1221
- * Returns whether the App is in test mode. (Running in a test environment)
1222
- *
1223
- * > This is automatically set when running tests with Jest or Vitest.
1224
- */
1225
- isTest(): boolean;
1226
- /**
1227
- * Returns whether the App is in production mode. (Running in a production environment)
1228
- *
1229
- * > This is automatically set by Vite or Vercel. However, you have to set it manually when running Docker apps.
1230
- */
1231
- isProduction(): boolean;
1232
- /**
1233
- * Starts the App.
1234
- *
1235
- * - Lock any further changes to the container.
1236
- * - Run "configure" hook for all services. Descriptors will be processed.
1237
- * - Run "start" hook for all services. Providers will connect/listen/...
1238
- * - Run "ready" hook for all services. This is the point where the App is ready to serve requests.
1239
- *
1240
- * @return A promise that resolves when the App has started.
1241
- */
1242
- start(): Promise<this>;
1243
- /**
1244
- * Stops the App.
1245
- *
1246
- * - Run "stop" hook for all services.
1247
- *
1248
- * Stop will NOT reset the container.
1249
- * Stop will NOT unlock the container.
1250
- *
1251
- * > Stop is used to gracefully shut down the application, nothing more. There is no "restart".
1252
- *
1253
- * @return A promise that resolves when the App has stopped.
1254
- */
1255
- stop(): Promise<void>;
1256
- /**
1257
- * Check if entry is registered in the container.
1258
- */
1259
- has(entry: ServiceEntry, opts?: {
1260
- /**
1261
- * Check if the entry is registered in the pending instantiation stack.
1262
- *
1263
- * @default true
1264
- */
1265
- inStack?: boolean;
1266
- /**
1267
- * Check if the entry is registered in the container registry.
1268
- *
1269
- * @default true
1270
- */
1271
- inRegistry?: boolean;
1272
- /**
1273
- * Check if the entry is registered in the substitutions.
1274
- *
1275
- * @default true
1276
- */
1277
- inSubstitutions?: boolean;
1278
- /**
1279
- * Where to look for registered services.
1280
- *
1281
- * @default this.registry
1282
- */
1283
- registry?: Map<Service, ServiceDefinition>;
1284
- }): boolean;
1285
- /**
1286
- * Registers the specified service in the container.
1287
- *
1288
- * - If the service is ALREADY registered, the method does nothing.
1289
- * - If the service is NOT registered, a new instance is created and registered.
1290
- *
1291
- * Method is chainable, so you can register multiple services in a single call.
1292
- *
1293
- * > ServiceEntry allows to provide a service **substitution** feature.
1294
- *
1295
- * @example
1296
- * ```ts
1297
- * class A { value = "a"; }
1298
- * class B { value = "b"; }
1299
- * class M { a = $inject(A); }
1300
- *
1301
- * Alepha.create().with({ provide: A, use: B }).get(M).a.value; // "b"
1302
- * ```
1303
- *
1304
- * > **Substitution** is an advanced feature that allows you to replace a service with another service.
1305
- * > It's useful for testing or for providing different implementations of a service.
1306
- * > If you are interested in configuring a service, use Alepha#configure() instead.
1307
- *
1308
- * @param serviceEntry - The service to register in the container.
1309
- * @return Current instance of Alepha.
1310
- */
1311
- with<T extends object>(serviceEntry: ServiceEntry<T> | {
1312
- default: ServiceEntry<T>;
1313
- }): this;
1314
- /**
1315
- * Get an instance of the specified service from the container.
1316
- *
1317
- * @see {@link InjectOptions} for the available options.
1318
- */
1319
- inject<T extends object>(service: Service<T> | string, opts?: InjectOptions<T>): T;
1320
- /**
1321
- * Applies environment variables to the provided schema and state object.
1322
- *
1323
- * It replaces also all templated $ENV inside string values.
1324
- *
1325
- * @param schema - The schema object to apply environment variables to.
1326
- * @return The schema object with environment variables applied.
1327
- */
1328
- parseEnv<T extends TObject$1>(schema: T): Static$1<T>;
1329
- /**
1330
- * Dump the current dependency graph of the App.
1331
- *
1332
- * This method returns a record where the keys are the names of the services.
1333
- */
1334
- graph(): Record<string, {
1335
- from: string[];
1336
- as?: string[];
1337
- module?: string;
1338
- }>;
1339
- services<T extends object>(base: Service<T>): Array<T>;
1340
- /**
1341
- * Get all descriptors of the specified type.
1342
- */
1343
- descriptors<TDescriptor extends Descriptor>(factory: {
1344
- [KIND]: InstantiableClass<TDescriptor>;
1345
- } | string): Array<TDescriptor>;
1346
- protected new<T extends object>(service: Service<T>, args?: any[]): T;
1347
- protected processDescriptor(value: Descriptor, propertyKey?: string): void;
1348
- }
1349
- interface Hook<T extends keyof Hooks = any> {
1350
- caller?: Service;
1351
- priority?: "first" | "last";
1352
- callback: (payload: Hooks[T]) => Async<void>;
1353
- }
1354
- /**
1355
- * This is how we store services in the Alepha container.
1356
- */
1357
- interface ServiceDefinition<T extends object = any> {
1358
- /**
1359
- * The instance of the class or type definition.
1360
- * Mostly used for caching / singleton but can be used for other purposes like forcing the instance.
1361
- */
1362
- instance: T;
1363
- /**
1364
- * List of classes which use this class.
1365
- */
1366
- parents: Array<Service | null>;
1367
- }
1368
- interface Env {
1369
- [key: string]: string | boolean | number | undefined;
1370
- /**
1371
- * Optional environment variable that indicates the current environment.
1372
- */
1373
- NODE_ENV?: "dev" | "test" | "production";
1374
- /**
1375
- * Optional name of the application.
1376
- */
1377
- APP_NAME?: string;
1378
- /**
1379
- * Optional root module name.
1380
- */
1381
- MODULE_NAME?: string;
1382
- }
1383
- interface State {
1384
- /**
1385
- * Environment variables for the application.
1386
- */
1387
- env?: Readonly<Env>;
1388
- /**
1389
- * Logger instance to be used by the Alepha container.
1390
- *
1391
- * @internal
1392
- */
1393
- "alepha.logger"?: LoggerInterface;
1394
- /**
1395
- * If defined, the Alepha container will only register this service and its dependencies.
1396
- */
1397
- "alepha.target"?: Service;
1398
- /**
1399
- * Bind to Vitest 'beforeAll' hook.
1400
- * Used for testing purposes.
1401
- * This is automatically attached if Alepha#create() detects a test environment and global 'beforeAll' is available.
1402
- */
1403
- "alepha.test.beforeAll"?: (run: any) => any;
1404
- /**
1405
- * Bind to Vitest 'afterAll' hook.
1406
- * Used for testing purposes.
1407
- * This is automatically attached if Alepha#create() detects a test environment and global 'afterAll' is available.
1408
- */
1409
- "alepha.test.afterAll"?: (run: any) => any;
1410
- /**
1411
- * Bind to Vitest 'afterEach' hook.
1412
- * Used for testing purposes.
1413
- * This is automatically attached if Alepha#create() detects a test environment and global 'afterEach' is available.
1414
- */
1415
- "alepha.test.afterEach"?: (run: any) => any;
1416
- /**
1417
- * Bind to Vitest 'onTestFinished' hook.
1418
- * Used for testing purposes.
1419
- * This is automatically attached if Alepha#create() detects a test environment and global 'onTestFinished' is available.
1420
- */
1421
- "alepha.test.onTestFinished"?: (run: any) => any;
1422
- /**
1423
- * List of static assets to be copied to the output directory during the build process.
1424
- *
1425
- * Used for Alepha-based applications that require static assets.
1426
- *
1427
- * See alepha/vite for more details.
1428
- */
1429
- "alepha.build.assets"?: Array<string>;
1430
- }
1431
- interface Hooks {
1432
- /**
1433
- * Used for testing purposes.
1434
- */
1435
- echo: unknown;
1436
- /**
1437
- * Triggered during the configuration phase. Before the start phase.
1438
- */
1439
- configure: Alepha;
1440
- /**
1441
- * Triggered during the start phase. When `Alepha#start()` is called.
1442
- */
1443
- start: Alepha;
1444
- /**
1445
- * Triggered during the ready phase. After the start phase.
1446
- */
1447
- ready: Alepha;
1448
- /**
1449
- * Triggered during the stop phase.
1450
- *
1451
- * - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)
1452
- *
1453
- */
1454
- stop: Alepha;
1455
- /**
1456
- * Triggered when a state value is mutated.
1457
- */
1458
- "state:mutate": {
1459
- /**
1460
- * The key of the state that was mutated.
1461
- */
1462
- key: keyof State;
1463
- /**
1464
- * The new value of the state.
1465
- */
1466
- value: any;
1467
- /**
1468
- * The previous value of the state.
1469
- */
1470
- prevValue: any;
1471
- };
1472
- }
1473
- //#endregion
1474
- //#region src/core/interfaces/Run.d.ts
1475
- interface RunOptions {
1476
- /**
1477
- * Environment variables to be used by the application.
1478
- * It will be merged with the current process environment.
1479
- */
1480
- env?: Env;
1481
- /**
1482
- * A callback that will be executed before the application starts.
1483
- */
1484
- configure?: (alepha: Alepha) => Async<void>;
1485
- /**
1486
- * A callback that will be executed once the application is ready.
1487
- * This is useful for initializing resources or starting background tasks.
1488
- */
1489
- ready?: (alepha: Alepha) => Async<void>;
1490
- /**
1491
- * If true, the application will .stop() after the ready callback is executed.
1492
- * Useful for one-time tasks!
1493
- */
1494
- once?: boolean;
1495
- /**
1496
- * If true, the application will run in cluster mode.
1497
- */
1498
- cluster?: boolean;
1499
- }
1500
- //#endregion
1501
- //#region src/core/constants/OPTIONS.d.ts
1502
- /**
1503
- * Used for descriptors options.
1504
- *
1505
- * @internal
1506
- */
1507
- declare const OPTIONS: unique symbol;
1508
- //#endregion
1509
- //#region src/core/descriptors/$context.d.ts
1510
- /**
1511
- * Get Alepha instance and current service from the current context.
1512
- *
1513
- * It can only be used inside $descriptor functions.
1514
- *
1515
- * ```ts
1516
- * import { $context } from "alepha";
1517
- *
1518
- * const $hello = () => {
1519
- * const { alepha, service, module } = $context();
1520
- *
1521
- * // alepha - alepha instance
1522
- * // service - class which is creating this descriptor, this is NOT the instance but the service definition
1523
- * // module - module definition, if any
1524
- *
1525
- * return {};
1526
- * }
1527
- *
1528
- * class MyService {
1529
- * hello = $hello();
1530
- * }
1531
- *
1532
- * const alepha = new Alepha().with(MyService);
1533
- * ```
1534
- *
1535
- * @internal
1536
- */
1537
- declare const $context: () => ContextDescriptor;
1538
- interface ContextDescriptor {
1539
- /**
1540
- * Alepha instance.
1541
- */
1542
- alepha: Alepha;
1543
- /**
1544
- * Service definition which is creating this descriptor.
1545
- * This is NOT the instance but the service definition.
1546
- */
1547
- service?: Service;
1548
- /**
1549
- * Module definition, if any.
1550
- */
1551
- module?: Service;
1552
- }
1553
- //#endregion
1554
- //#region src/core/descriptors/$env.d.ts
1555
- /**
1556
- * Get typed values from environment variables.
1557
- *
1558
- * @example
1559
- * ```ts
1560
- * const alepha = Alepha.create({
1561
- * env: {
1562
- * // Alepha.create() will also use process.env when running on Node.js
1563
- * HELLO: "world",
1564
- * }
1565
- * });
1566
- *
1567
- * class App {
1568
- * log = $logger();
1569
- *
1570
- * // program expect a var env "HELLO" as string to works
1571
- * env = $env(t.object({
1572
- * HELLO: t.text()
1573
- * }));
1574
- *
1575
- * sayHello = () => this.log.info("Hello ${this.env.HELLO}")
1576
- * }
1577
- *
1578
- * run(alepha.with(App));
1579
- * ```
1580
- */
1581
- declare const $env: <T extends TObject$1>(type: T) => Static$1<T>;
1582
- //#endregion
1583
- //#region src/core/descriptors/$hook.d.ts
1584
- /**
1585
- * Registers a new hook.
1586
- *
1587
- * ```ts
1588
- * import { $hook } from "alepha";
1589
- *
1590
- * class MyProvider {
1591
- * onStart = $hook({
1592
- * name: "start", // or "configure", "ready", "stop", ...
1593
- * handler: async (app) => {
1594
- * // await db.connect(); ...
1595
- * }
1596
- * });
1597
- * }
1598
- * ```
1599
- *
1600
- * Hooks are used to run async functions from all registered providers/services.
1601
- *
1602
- * You can't register a hook after the App has started.
1603
- *
1604
- * It's used under the hood by the `configure`, `start`, and `stop` methods.
1605
- * Some modules also use hooks to run their own logic. (e.g. `alepha/server`).
1606
- *
1607
- * You can create your own hooks by using module augmentation:
1608
- *
1609
- * ```ts
1610
- * declare module "alepha" {
1611
- *
1612
- * interface Hooks {
1613
- * "my:custom:hook": {
1614
- * arg1: string;
1615
- * }
1616
- * }
1617
- * }
1618
- *
1619
- * await alepha.events.emit("my:custom:hook", { arg1: "value" });
1620
- * ```
1621
- *
1622
- */
1623
- declare const $hook: {
1624
- <T extends keyof Hooks>(options: HookOptions<T>): HookDescriptor<T>;
1625
- [KIND]: typeof HookDescriptor;
1626
- };
1627
- interface HookOptions<T extends keyof Hooks> {
1628
- /**
1629
- * The name of the hook. "configure", "start", "ready", "stop", ...
1630
- */
1631
- on: T;
1632
- /**
1633
- * The handler to run when the hook is triggered.
1634
- */
1635
- handler: (args: Hooks[T]) => Async<any>;
1636
- /**
1637
- * Force the hook to run first or last on the list of hooks.
1638
- */
1639
- priority?: "first" | "last";
1640
- /**
1641
- * Empty placeholder, not implemented yet. :-)
1642
- */
1643
- before?: object | Array<object>;
1644
- /**
1645
- * Empty placeholder, not implemented yet. :-)
1646
- */
1647
- after?: object | Array<object>;
1648
- }
1649
- declare class HookDescriptor<T extends keyof Hooks> extends Descriptor<HookOptions<T>> {
1650
- called: number;
1651
- protected onInit(): void;
1652
- }
1653
- //#endregion
1654
- //#region src/core/descriptors/$use.d.ts
1655
- /**
1656
- * Subscribes to an atom's state and returns its current value for use in components.
1657
- *
1658
- * Creates a reactive connection between an atom and a component, automatically registering
1659
- * the atom in the application state if not already registered. The returned value is reactive
1660
- * and will update when the atom's state changes.
1661
- *
1662
- * **Use Cases**: Accessing global state, sharing data between components, reactive UI updates
1663
- *
1664
- * @example
1665
- * ```ts
1666
- * const userState = $atom({ schema: t.object({ name: t.text(), role: t.text() }) });
1667
- *
1668
- * class UserComponent {
1669
- * user = $use(userState); // Reactive reference to atom state
1670
- *
1671
- * render() {
1672
- * return <div>Hello {this.user.name}!</div>;
1673
- * }
1674
- * }
1675
- * ```
1676
- */
1677
- declare const $use: <T extends TObject, N extends string>(atom: Atom<T, N>) => Readonly<Static<T>>;
1678
- //#endregion
1679
- //#region src/core/errors/AppNotStartedError.d.ts
1680
- declare class AppNotStartedError extends AlephaError {
1681
- readonly name = "AppNotStartedError";
1682
- constructor();
1683
- }
1684
- //#endregion
1685
- //#region src/core/errors/CircularDependencyError.d.ts
1686
- declare class CircularDependencyError extends AlephaError {
1687
- readonly name = "CircularDependencyError";
1688
- constructor(provider: string, parents?: string[]);
1689
- }
1690
- //#endregion
1691
- //#region src/core/errors/ContainerLockedError.d.ts
1692
- declare class ContainerLockedError extends AlephaError {
1693
- readonly name = "ContainerLockedError";
1694
- constructor(message?: string);
1695
- }
1696
- //#endregion
1697
- //#region src/core/errors/TooLateSubstitutionError.d.ts
1698
- declare class TooLateSubstitutionError extends AlephaError {
1699
- readonly name = "TooLateSubstitutionError";
1700
- constructor(original: string, substitution: string);
1701
- }
1702
- //#endregion
1703
- //#region src/core/schemas/pageSchema.d.ts
1704
- declare const pageMetadataSchema: TObject<{
1705
- number: TInteger;
1706
- size: TInteger;
1707
- offset: TInteger;
1708
- numberOfElements: TInteger;
1709
- totalElements: TOptional<TInteger>;
1710
- totalPages: TOptional<TInteger>;
1711
- isEmpty: TBoolean;
1712
- isFirst: TBoolean;
1713
- isLast: TBoolean;
1714
- sort: TOptional<TObject<{
1715
- sorted: TBoolean;
1716
- fields: TArray<TObject<{
1717
- field: TString;
1718
- direction: TUnsafe<"asc" | "desc">;
1719
- }>>;
1720
- }>>;
1721
- }>;
1722
- /**
1723
- * Create a pagination schema for the given object schema.
1724
- *
1725
- * Provides a standardized pagination response format compatible with Spring Data's Page interface.
1726
- * This schema can be used across any data source (databases, APIs, caches, etc.).
1727
- *
1728
- * @example
1729
- * ```ts
1730
- * const userSchema = t.object({ id: t.integer(), name: t.text() });
1731
- * const userPageSchema = pageSchema(userSchema);
1732
- * ```
1733
- *
1734
- * @example In an API endpoint
1735
- * ```ts
1736
- * $action({
1737
- * output: pageSchema(UserSchema),
1738
- * handler: async () => {
1739
- * return await userRepo.paginate();
1740
- * }
1741
- * })
1742
- * ```
1743
- */
1744
- declare const pageSchema: <T extends TObject | TRecord>(objectSchema: T, options?: TObjectOptions) => TPage<T>;
1745
- type TPage<T extends TObject | TRecord> = TObject<{
1746
- content: TArray<T>;
1747
- page: typeof pageMetadataSchema;
1748
- }>;
1749
- /**
1750
- * Opinionated type definition for a paginated response.
1751
- *
1752
- * Inspired by Spring Data's Page interface with all essential pagination metadata.
1753
- * This generic type can be used with any data source.
1754
- *
1755
- * @example
1756
- * ```ts
1757
- * const page: Page<User> = {
1758
- * content: [user1, user2, ...],
1759
- * page: {
1760
- * number: 0,
1761
- * size: 10,
1762
- * offset: 0,
1763
- * numberOfElements: 10,
1764
- * totalElements: 1200,
1765
- * totalPages: 120,
1766
- * isEmpty: false,
1767
- * isFirst: true,
1768
- * isLast: false,
1769
- * sort: {
1770
- * sorted: true,
1771
- * fields: [
1772
- * { field: "name", direction: "asc" }
1773
- * ]
1774
- * }
1775
- * }
1776
- * }
1777
- * ```
1778
- */
1779
- type Page<T> = {
1780
- /**
1781
- * Array of items on the current page.
1782
- */
1783
- content: T[];
1784
- page: Static<typeof pageMetadataSchema>;
1785
- };
1786
- type PageMetadata = Static<typeof pageMetadataSchema>;
1787
- declare module "alepha" {
1788
- interface TypeProvider {
1789
- /**
1790
- * Create a schema for a paginated response.
1791
- */
1792
- page<T extends TObject | TRecord>(itemSchema: T): TPage<T>;
1793
- }
1794
- }
1795
- //#endregion
1796
- //#region src/core/helpers/createPagination.d.ts
1797
- /**
1798
- * Create a pagination object from an array of entities.
1799
- *
1800
- * This is a pure function that works with any data source (databases, APIs, caches, arrays, etc.).
1801
- * It handles the core pagination logic including:
1802
- * - Slicing the content to the requested page size
1803
- * - Calculating pagination metadata (offset, page number, etc.)
1804
- * - Determining navigation state (isFirst, isLast)
1805
- * - Including sort metadata when provided
1806
- *
1807
- * @param entities - The entities to paginate (should include one extra item to detect if there's a next page)
1808
- * @param limit - The limit of the pagination (page size)
1809
- * @param offset - The offset of the pagination (starting position)
1810
- * @param sort - Optional sort metadata to include in response
1811
- * @returns A complete Page object with content and metadata
1812
- *
1813
- * @example Basic pagination
1814
- * ```ts
1815
- * const users = await fetchUsers({ limit: 11, offset: 0 }); // Fetch limit + 1
1816
- * const page = createPagination(users, 10, 0);
1817
- * // page.content has max 10 items
1818
- * // page.page.isLast tells us if there are more pages
1819
- * ```
1820
- *
1821
- * @example With sorting
1822
- * ```ts
1823
- * const page = createPagination(
1824
- * entities,
1825
- * 10,
1826
- * 0,
1827
- * [{ column: "name", direction: "asc" }]
1828
- * );
1829
- * ```
1830
- *
1831
- * @example In a custom service
1832
- * ```ts
1833
- * class MyService {
1834
- * async listItems(page: number, size: number) {
1835
- * const items = await this.fetchItems({ limit: size + 1, offset: page * size });
1836
- * return createPagination(items, size, page * size);
1837
- * }
1838
- * }
1839
- * ```
1840
- */
1841
- declare function createPagination<T>(entities: T[], limit?: number, offset?: number, sort?: Array<{
1842
- column: string;
1843
- direction: "asc" | "desc";
1844
- }>): Page<T>;
1845
- //#endregion
1846
- //#region src/core/interfaces/Pagination.d.ts
1847
- /**
1848
- * Generic pagination request parameters.
1849
- *
1850
- * This interface defines the common structure for pagination queries
1851
- * across all data sources. Individual packages can extend or adapt this
1852
- * interface for their specific needs.
1853
- *
1854
- * @example Basic usage
1855
- * ```ts
1856
- * const query: PageRequest = {
1857
- * page: 0,
1858
- * size: 20
1859
- * };
1860
- * ```
1861
- *
1862
- * @example With all parameters
1863
- * ```ts
1864
- * const query: PageRequest = {
1865
- * page: 2,
1866
- * size: 50
1867
- * };
1868
- * ```
1869
- */
1870
- interface PageRequest {
1871
- /**
1872
- * The page number to retrieve (0-indexed).
1873
- * @default 0
1874
- */
1875
- page?: number;
1876
- /**
1877
- * The number of items per page.
1878
- * @default 10
1879
- */
1880
- size?: number;
1881
- }
1882
- /**
1883
- * Sort direction for ordering results.
1884
- */
1885
- type SortDirection = "asc" | "desc";
1886
- /**
1887
- * Sort field specification.
1888
- */
1889
- interface SortField {
1890
- /**
1891
- * The field/column name to sort by.
1892
- */
1893
- field: string;
1894
- /**
1895
- * The sort direction.
1896
- * @default "asc"
1897
- */
1898
- direction: SortDirection;
1899
- }
1900
- //#endregion
1901
- //#region src/core/schemas/pageQuerySchema.d.ts
1902
- declare const pageQuerySchema: TObject<{
1903
- page: TOptional<TInteger>;
1904
- size: TOptional<TInteger>;
1905
- sort: TOptional<TString>;
1906
- }>;
1907
- type PageQuery = Static<typeof pageQuerySchema>;
1908
- //#endregion
1909
- //#region src/core/index.d.ts
1910
- /**
1911
- * Run Alepha application, trigger start lifecycle.
1912
- *
1913
- * ```ts
1914
- * import { Alepha, run } from "alepha";
1915
- * import { MyService } from "./services/MyService.ts";
1916
- *
1917
- * const alepha = new Alepha({ env: { APP_NAME: "MyAlephaApp" } });
1918
- *
1919
- * alepha.with(MyService);
1920
- *
1921
- * export default run(alepha);
1922
- * ```
1923
- */
1924
- declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => Alepha;
1925
- //#endregion
1926
- export { $atom, $context, $env, $hook, $inject, $module, $use, AbstractClass, Alepha, AlephaError, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, Atom, AtomOptions, AtomStatic, AtomWithValue, CircularDependencyError, CodecManager, ContainerLockedError, ContextDescriptor, DecodeOptions, Descriptor, DescriptorArgs, DescriptorConfig, DescriptorFactory, DescriptorFactoryLike, EncodeOptions, EncodeResult, Encoding, Env, EventManager, FileLike, Hook, HookDescriptor, HookOptions, Hooks, InjectDescriptor, InjectOptions, InstantiableClass, JsonSchemaCodec, KIND, LogLevel, LoggerInterface, MaybePromise, Module, ModuleDescriptorOptions, OPTIONS, Page, PageMetadata, PageQuery, PageRequest, RunFunction, SchemaCodec, Service, ServiceEntry, ServiceSubstitution, SortDirection, SortField, State, StateManager, type Static, type StaticDecode, type StaticEncode, StreamLike, type TAny, type TArray, TAtomObject, type TBigInt, type TBoolean, TFile, type TInteger, type TKeysToIndexer, type TNull, type TNumber, type TNumberOptions, type TObject, type TObjectOptions, type TOptional, type TOptionalAdd, TPage, type TPick, type TProperties, type TRecord, type TSchema, TStream, type TString, type TStringOptions, TTextOptions, type TTuple, type TUnion, type TUnsafe, type TVoid, TextLength, TooLateSubstitutionError, TypeBox, TypeBoxError, TypeBoxErrorParams, TypeBoxFormat, TypeBoxValue, TypeGuard, TypeProvider, WithModule, createDescriptor, createPagination, isClass, isDate, isDateTime, isDuration, isEmail, isFileLike, isTime, isTypeFile, isURL, isUUID, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
1927
- //# sourceMappingURL=index.d.cts.map