alepha 0.15.0 → 0.15.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 (551) hide show
  1. package/README.md +43 -98
  2. package/dist/api/audits/index.d.ts +630 -653
  3. package/dist/api/audits/index.d.ts.map +1 -1
  4. package/dist/api/audits/index.js +12 -35
  5. package/dist/api/audits/index.js.map +1 -1
  6. package/dist/api/files/index.d.ts +365 -358
  7. package/dist/api/files/index.d.ts.map +1 -1
  8. package/dist/api/files/index.js +12 -5
  9. package/dist/api/files/index.js.map +1 -1
  10. package/dist/api/jobs/index.d.ts +255 -248
  11. package/dist/api/jobs/index.d.ts.map +1 -1
  12. package/dist/api/jobs/index.js +10 -3
  13. package/dist/api/jobs/index.js.map +1 -1
  14. package/dist/api/keys/index.d.ts +413 -0
  15. package/dist/api/keys/index.d.ts.map +1 -0
  16. package/dist/api/keys/index.js +476 -0
  17. package/dist/api/keys/index.js.map +1 -0
  18. package/dist/api/notifications/index.browser.js +4 -4
  19. package/dist/api/notifications/index.browser.js.map +1 -1
  20. package/dist/api/notifications/index.d.ts +84 -78
  21. package/dist/api/notifications/index.d.ts.map +1 -1
  22. package/dist/api/notifications/index.js +14 -8
  23. package/dist/api/notifications/index.js.map +1 -1
  24. package/dist/api/parameters/index.d.ts +528 -535
  25. package/dist/api/parameters/index.d.ts.map +1 -1
  26. package/dist/api/parameters/index.js +30 -37
  27. package/dist/api/parameters/index.js.map +1 -1
  28. package/dist/api/users/index.d.ts +1221 -910
  29. package/dist/api/users/index.d.ts.map +1 -1
  30. package/dist/api/users/index.js +2556 -248
  31. package/dist/api/users/index.js.map +1 -1
  32. package/dist/api/verifications/index.d.ts +142 -136
  33. package/dist/api/verifications/index.d.ts.map +1 -1
  34. package/dist/api/verifications/index.js +12 -4
  35. package/dist/api/verifications/index.js.map +1 -1
  36. package/dist/batch/index.d.ts +142 -162
  37. package/dist/batch/index.d.ts.map +1 -1
  38. package/dist/batch/index.js +31 -44
  39. package/dist/batch/index.js.map +1 -1
  40. package/dist/bucket/index.d.ts +595 -171
  41. package/dist/bucket/index.d.ts.map +1 -1
  42. package/dist/bucket/index.js +1856 -12
  43. package/dist/bucket/index.js.map +1 -1
  44. package/dist/cache/core/index.d.ts +225 -53
  45. package/dist/cache/core/index.d.ts.map +1 -1
  46. package/dist/cache/core/index.js +213 -7
  47. package/dist/cache/core/index.js.map +1 -1
  48. package/dist/cache/redis/index.d.ts +1 -0
  49. package/dist/cache/redis/index.d.ts.map +1 -1
  50. package/dist/cache/redis/index.js +6 -2
  51. package/dist/cache/redis/index.js.map +1 -1
  52. package/dist/cli/index.d.ts +834 -226
  53. package/dist/cli/index.d.ts.map +1 -1
  54. package/dist/cli/index.js +2872 -417
  55. package/dist/cli/index.js.map +1 -1
  56. package/dist/command/index.d.ts +458 -310
  57. package/dist/command/index.d.ts.map +1 -1
  58. package/dist/command/index.js +2011 -76
  59. package/dist/command/index.js.map +1 -1
  60. package/dist/core/index.browser.js +309 -97
  61. package/dist/core/index.browser.js.map +1 -1
  62. package/dist/core/index.d.ts +796 -701
  63. package/dist/core/index.d.ts.map +1 -1
  64. package/dist/core/index.js +329 -97
  65. package/dist/core/index.js.map +1 -1
  66. package/dist/core/index.native.js +309 -97
  67. package/dist/core/index.native.js.map +1 -1
  68. package/dist/datetime/index.d.ts +59 -44
  69. package/dist/datetime/index.d.ts.map +1 -1
  70. package/dist/datetime/index.js +15 -0
  71. package/dist/datetime/index.js.map +1 -1
  72. package/dist/email/index.d.ts +314 -19
  73. package/dist/email/index.d.ts.map +1 -1
  74. package/dist/email/index.js +1852 -7
  75. package/dist/email/index.js.map +1 -1
  76. package/dist/fake/index.d.ts +5500 -5418
  77. package/dist/fake/index.d.ts.map +1 -1
  78. package/dist/fake/index.js +113 -42
  79. package/dist/fake/index.js.map +1 -1
  80. package/dist/lock/core/index.d.ts +219 -212
  81. package/dist/lock/core/index.d.ts.map +1 -1
  82. package/dist/lock/core/index.js +11 -4
  83. package/dist/lock/core/index.js.map +1 -1
  84. package/dist/lock/redis/index.d.ts.map +1 -1
  85. package/dist/logger/index.d.ts +41 -90
  86. package/dist/logger/index.d.ts.map +1 -1
  87. package/dist/logger/index.js +15 -68
  88. package/dist/logger/index.js.map +1 -1
  89. package/dist/mcp/index.d.ts +228 -230
  90. package/dist/mcp/index.d.ts.map +1 -1
  91. package/dist/mcp/index.js +32 -31
  92. package/dist/mcp/index.js.map +1 -1
  93. package/dist/orm/index.browser.js +12 -12
  94. package/dist/orm/index.browser.js.map +1 -1
  95. package/dist/orm/index.bun.js +90 -80
  96. package/dist/orm/index.bun.js.map +1 -1
  97. package/dist/orm/index.d.ts +1434 -1459
  98. package/dist/orm/index.d.ts.map +1 -1
  99. package/dist/orm/index.js +112 -130
  100. package/dist/orm/index.js.map +1 -1
  101. package/dist/queue/core/index.d.ts +262 -254
  102. package/dist/queue/core/index.d.ts.map +1 -1
  103. package/dist/queue/core/index.js +14 -6
  104. package/dist/queue/core/index.js.map +1 -1
  105. package/dist/queue/redis/index.d.ts.map +1 -1
  106. package/dist/react/auth/index.browser.js +108 -0
  107. package/dist/react/auth/index.browser.js.map +1 -0
  108. package/dist/react/auth/index.d.ts +100 -0
  109. package/dist/react/auth/index.d.ts.map +1 -0
  110. package/dist/react/auth/index.js +145 -0
  111. package/dist/react/auth/index.js.map +1 -0
  112. package/dist/react/core/index.d.ts +469 -0
  113. package/dist/react/core/index.d.ts.map +1 -0
  114. package/dist/react/core/index.js +464 -0
  115. package/dist/react/core/index.js.map +1 -0
  116. package/dist/react/form/index.d.ts +232 -0
  117. package/dist/react/form/index.d.ts.map +1 -0
  118. package/dist/react/form/index.js +432 -0
  119. package/dist/react/form/index.js.map +1 -0
  120. package/dist/react/head/index.browser.js +423 -0
  121. package/dist/react/head/index.browser.js.map +1 -0
  122. package/dist/react/head/index.d.ts +288 -0
  123. package/dist/react/head/index.d.ts.map +1 -0
  124. package/dist/react/head/index.js +465 -0
  125. package/dist/react/head/index.js.map +1 -0
  126. package/dist/react/i18n/index.d.ts +175 -0
  127. package/dist/react/i18n/index.d.ts.map +1 -0
  128. package/dist/react/i18n/index.js +224 -0
  129. package/dist/react/i18n/index.js.map +1 -0
  130. package/dist/react/router/index.browser.js +1980 -0
  131. package/dist/react/router/index.browser.js.map +1 -0
  132. package/dist/react/router/index.d.ts +2068 -0
  133. package/dist/react/router/index.d.ts.map +1 -0
  134. package/dist/react/router/index.js +4932 -0
  135. package/dist/react/router/index.js.map +1 -0
  136. package/dist/react/websocket/index.d.ts +117 -0
  137. package/dist/react/websocket/index.d.ts.map +1 -0
  138. package/dist/react/websocket/index.js +107 -0
  139. package/dist/react/websocket/index.js.map +1 -0
  140. package/dist/redis/index.bun.js +4 -0
  141. package/dist/redis/index.bun.js.map +1 -1
  142. package/dist/redis/index.d.ts +127 -130
  143. package/dist/redis/index.d.ts.map +1 -1
  144. package/dist/redis/index.js +16 -25
  145. package/dist/redis/index.js.map +1 -1
  146. package/dist/retry/index.d.ts +80 -71
  147. package/dist/retry/index.d.ts.map +1 -1
  148. package/dist/retry/index.js +11 -2
  149. package/dist/retry/index.js.map +1 -1
  150. package/dist/router/index.d.ts +6 -6
  151. package/dist/router/index.d.ts.map +1 -1
  152. package/dist/scheduler/index.d.ts +119 -28
  153. package/dist/scheduler/index.d.ts.map +1 -1
  154. package/dist/scheduler/index.js +404 -3
  155. package/dist/scheduler/index.js.map +1 -1
  156. package/dist/security/index.d.ts +642 -228
  157. package/dist/security/index.d.ts.map +1 -1
  158. package/dist/security/index.js +1579 -37
  159. package/dist/security/index.js.map +1 -1
  160. package/dist/server/auth/index.d.ts +1141 -111
  161. package/dist/server/auth/index.d.ts.map +1 -1
  162. package/dist/server/auth/index.js +1261 -25
  163. package/dist/server/auth/index.js.map +1 -1
  164. package/dist/server/cache/index.d.ts +63 -78
  165. package/dist/server/cache/index.d.ts.map +1 -1
  166. package/dist/server/cache/index.js +7 -22
  167. package/dist/server/cache/index.js.map +1 -1
  168. package/dist/server/compress/index.d.ts +13 -5
  169. package/dist/server/compress/index.d.ts.map +1 -1
  170. package/dist/server/compress/index.js +10 -2
  171. package/dist/server/compress/index.js.map +1 -1
  172. package/dist/server/cookies/index.d.ts +46 -22
  173. package/dist/server/cookies/index.d.ts.map +1 -1
  174. package/dist/server/cookies/index.js +7 -5
  175. package/dist/server/cookies/index.js.map +1 -1
  176. package/dist/server/core/index.d.ts +307 -196
  177. package/dist/server/core/index.d.ts.map +1 -1
  178. package/dist/server/core/index.js +271 -38
  179. package/dist/server/core/index.js.map +1 -1
  180. package/dist/server/cors/index.d.ts +24 -34
  181. package/dist/server/cors/index.d.ts.map +1 -1
  182. package/dist/server/cors/index.js +7 -21
  183. package/dist/server/cors/index.js.map +1 -1
  184. package/dist/server/health/index.d.ts +25 -19
  185. package/dist/server/health/index.d.ts.map +1 -1
  186. package/dist/server/health/index.js +8 -2
  187. package/dist/server/health/index.js.map +1 -1
  188. package/dist/server/helmet/index.d.ts +13 -5
  189. package/dist/server/helmet/index.d.ts.map +1 -1
  190. package/dist/server/helmet/index.js +11 -3
  191. package/dist/server/helmet/index.js.map +1 -1
  192. package/dist/server/links/index.browser.js +9 -1
  193. package/dist/server/links/index.browser.js.map +1 -1
  194. package/dist/server/links/index.d.ts +133 -128
  195. package/dist/server/links/index.d.ts.map +1 -1
  196. package/dist/server/links/index.js +24 -11
  197. package/dist/server/links/index.js.map +1 -1
  198. package/dist/server/metrics/index.d.ts +524 -4
  199. package/dist/server/metrics/index.d.ts.map +1 -1
  200. package/dist/server/metrics/index.js +4472 -7
  201. package/dist/server/metrics/index.js.map +1 -1
  202. package/dist/server/multipart/index.d.ts +15 -9
  203. package/dist/server/multipart/index.d.ts.map +1 -1
  204. package/dist/server/multipart/index.js +9 -3
  205. package/dist/server/multipart/index.js.map +1 -1
  206. package/dist/server/proxy/index.d.ts +110 -104
  207. package/dist/server/proxy/index.d.ts.map +1 -1
  208. package/dist/server/proxy/index.js +8 -2
  209. package/dist/server/proxy/index.js.map +1 -1
  210. package/dist/server/rate-limit/index.d.ts +46 -51
  211. package/dist/server/rate-limit/index.d.ts.map +1 -1
  212. package/dist/server/rate-limit/index.js +18 -55
  213. package/dist/server/rate-limit/index.js.map +1 -1
  214. package/dist/server/static/index.d.ts +181 -48
  215. package/dist/server/static/index.d.ts.map +1 -1
  216. package/dist/server/static/index.js +1848 -5
  217. package/dist/server/static/index.js.map +1 -1
  218. package/dist/server/swagger/index.d.ts +348 -53
  219. package/dist/server/swagger/index.d.ts.map +1 -1
  220. package/dist/server/swagger/index.js +1849 -6
  221. package/dist/server/swagger/index.js.map +1 -1
  222. package/dist/sms/index.d.ts +312 -18
  223. package/dist/sms/index.d.ts.map +1 -1
  224. package/dist/sms/index.js +1854 -10
  225. package/dist/sms/index.js.map +1 -1
  226. package/dist/system/index.browser.js +496 -0
  227. package/dist/system/index.browser.js.map +1 -0
  228. package/dist/system/index.d.ts +1158 -0
  229. package/dist/system/index.d.ts.map +1 -0
  230. package/dist/{file → system}/index.js +412 -20
  231. package/dist/system/index.js.map +1 -0
  232. package/dist/thread/index.d.ts +82 -73
  233. package/dist/thread/index.d.ts.map +1 -1
  234. package/dist/thread/index.js +13 -4
  235. package/dist/thread/index.js.map +1 -1
  236. package/dist/topic/core/index.d.ts +330 -323
  237. package/dist/topic/core/index.d.ts.map +1 -1
  238. package/dist/topic/core/index.js +12 -5
  239. package/dist/topic/core/index.js.map +1 -1
  240. package/dist/topic/redis/index.d.ts +6 -6
  241. package/dist/topic/redis/index.d.ts.map +1 -1
  242. package/dist/vite/index.d.ts +163 -5825
  243. package/dist/vite/index.d.ts.map +1 -1
  244. package/dist/vite/index.js +130 -477
  245. package/dist/vite/index.js.map +1 -1
  246. package/dist/websocket/index.browser.js +3 -3
  247. package/dist/websocket/index.browser.js.map +1 -1
  248. package/dist/websocket/index.d.ts +287 -283
  249. package/dist/websocket/index.d.ts.map +1 -1
  250. package/dist/websocket/index.js +15 -11
  251. package/dist/websocket/index.js.map +1 -1
  252. package/package.json +86 -17
  253. package/src/api/audits/index.ts +10 -33
  254. package/src/api/files/__tests__/$bucket.spec.ts +1 -1
  255. package/src/api/files/controllers/AdminFileStatsController.spec.ts +1 -1
  256. package/src/api/files/controllers/FileController.spec.ts +1 -1
  257. package/src/api/files/index.ts +10 -3
  258. package/src/api/files/jobs/FileJobs.spec.ts +1 -1
  259. package/src/api/files/services/FileService.spec.ts +1 -1
  260. package/src/api/jobs/index.ts +10 -3
  261. package/src/api/keys/controllers/AdminApiKeyController.ts +75 -0
  262. package/src/api/keys/controllers/ApiKeyController.ts +103 -0
  263. package/src/api/keys/entities/apiKeyEntity.ts +41 -0
  264. package/src/api/keys/index.ts +49 -0
  265. package/src/api/keys/schemas/adminApiKeyQuerySchema.ts +7 -0
  266. package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +17 -0
  267. package/src/api/keys/schemas/createApiKeyBodySchema.ts +7 -0
  268. package/src/api/keys/schemas/createApiKeyResponseSchema.ts +11 -0
  269. package/src/api/keys/schemas/listApiKeyResponseSchema.ts +15 -0
  270. package/src/api/keys/schemas/revokeApiKeyParamsSchema.ts +5 -0
  271. package/src/api/keys/schemas/revokeApiKeyResponseSchema.ts +5 -0
  272. package/src/api/keys/services/ApiKeyService.spec.ts +553 -0
  273. package/src/api/keys/services/ApiKeyService.ts +306 -0
  274. package/src/api/logs/TODO.md +52 -0
  275. package/src/api/notifications/index.ts +10 -4
  276. package/src/api/parameters/index.ts +9 -30
  277. package/src/api/parameters/primitives/$config.ts +12 -4
  278. package/src/api/parameters/services/ConfigStore.ts +9 -3
  279. package/src/api/users/__tests__/ApiKeys-integration.spec.ts +1035 -0
  280. package/src/api/users/__tests__/ApiKeys.spec.ts +401 -0
  281. package/src/api/users/index.ts +14 -3
  282. package/src/api/users/primitives/$realm.ts +33 -5
  283. package/src/api/users/providers/RealmProvider.ts +1 -12
  284. package/src/api/users/services/SessionService.ts +1 -11
  285. package/src/api/verifications/controllers/VerificationController.ts +2 -0
  286. package/src/api/verifications/index.ts +10 -4
  287. package/src/batch/index.ts +9 -36
  288. package/src/batch/primitives/$batch.ts +0 -8
  289. package/src/batch/providers/BatchProvider.ts +29 -2
  290. package/src/bucket/__tests__/shared.ts +1 -1
  291. package/src/bucket/index.ts +13 -6
  292. package/src/bucket/primitives/$bucket.ts +1 -1
  293. package/src/bucket/providers/LocalFileStorageProvider.ts +1 -1
  294. package/src/bucket/providers/MemoryFileStorageProvider.ts +1 -1
  295. package/src/cache/core/__tests__/shared.ts +30 -0
  296. package/src/cache/core/index.ts +11 -6
  297. package/src/cache/core/primitives/$cache.spec.ts +5 -0
  298. package/src/cache/core/providers/CacheProvider.ts +17 -0
  299. package/src/cache/core/providers/MemoryCacheProvider.ts +300 -1
  300. package/src/cache/redis/__tests__/cache-redis.spec.ts +5 -0
  301. package/src/cache/redis/providers/RedisCacheProvider.ts +9 -0
  302. package/src/cli/apps/AlephaCli.ts +3 -16
  303. package/src/cli/apps/AlephaPackageBuilderCli.ts +10 -2
  304. package/src/cli/atoms/appEntryOptions.ts +13 -0
  305. package/src/cli/atoms/buildOptions.ts +1 -1
  306. package/src/cli/atoms/changelogOptions.ts +1 -1
  307. package/src/cli/commands/build.ts +64 -52
  308. package/src/cli/commands/db.ts +17 -11
  309. package/src/cli/commands/deploy.ts +1 -1
  310. package/src/cli/commands/dev.ts +13 -49
  311. package/src/cli/commands/gen/env.ts +6 -3
  312. package/src/cli/commands/gen/openapi.ts +5 -2
  313. package/src/cli/commands/init.spec.ts +544 -0
  314. package/src/cli/commands/init.ts +101 -58
  315. package/src/cli/commands/lint.ts +8 -2
  316. package/src/cli/commands/typecheck.ts +11 -0
  317. package/src/cli/defineConfig.ts +9 -0
  318. package/src/cli/index.ts +2 -1
  319. package/src/cli/providers/AppEntryProvider.ts +131 -0
  320. package/src/cli/providers/ViteBuildProvider.ts +40 -0
  321. package/src/cli/providers/ViteDevServerProvider.ts +378 -0
  322. package/src/cli/services/AlephaCliUtils.ts +39 -93
  323. package/src/cli/services/PackageManagerUtils.ts +140 -17
  324. package/src/cli/services/ProjectScaffolder.ts +169 -101
  325. package/src/cli/services/ViteUtils.ts +82 -0
  326. package/src/cli/{assets/claudeMd.ts → templates/agentMd.ts} +41 -28
  327. package/src/cli/{assets → templates}/apiHelloControllerTs.ts +2 -1
  328. package/src/cli/{assets → templates}/biomeJson.ts +2 -1
  329. package/src/cli/{assets → templates}/dummySpecTs.ts +2 -1
  330. package/src/cli/{assets → templates}/editorconfig.ts +2 -1
  331. package/src/cli/templates/gitignore.ts +39 -0
  332. package/src/cli/{assets → templates}/mainBrowserTs.ts +2 -1
  333. package/src/cli/templates/mainCss.ts +33 -0
  334. package/src/cli/templates/mainServerTs.ts +33 -0
  335. package/src/cli/{assets → templates}/tsconfigJson.ts +2 -1
  336. package/src/cli/templates/webAppRouterTs.ts +50 -0
  337. package/src/cli/templates/webHelloComponentTsx.ts +20 -0
  338. package/src/command/helpers/Runner.spec.ts +4 -0
  339. package/src/command/helpers/Runner.ts +3 -21
  340. package/src/command/index.ts +12 -4
  341. package/src/command/providers/CliProvider.spec.ts +1067 -0
  342. package/src/command/providers/CliProvider.ts +203 -40
  343. package/src/core/Alepha.ts +3 -9
  344. package/src/core/__tests__/Alepha-start.spec.ts +4 -4
  345. package/src/core/helpers/jsonSchemaToTypeBox.spec.ts +771 -0
  346. package/src/core/helpers/jsonSchemaToTypeBox.ts +62 -10
  347. package/src/core/index.shared.ts +1 -0
  348. package/src/core/index.ts +20 -0
  349. package/src/core/primitives/$module.ts +12 -0
  350. package/src/core/providers/EventManager.spec.ts +0 -71
  351. package/src/core/providers/EventManager.ts +3 -15
  352. package/src/core/providers/Json.ts +2 -14
  353. package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +257 -0
  354. package/src/core/providers/KeylessJsonSchemaCodec.ts +396 -14
  355. package/src/core/providers/SchemaValidator.spec.ts +236 -0
  356. package/src/datetime/index.ts +15 -0
  357. package/src/email/index.ts +10 -5
  358. package/src/email/providers/LocalEmailProvider.spec.ts +1 -1
  359. package/src/email/providers/LocalEmailProvider.ts +1 -1
  360. package/src/fake/__tests__/keyName.example.ts +1 -1
  361. package/src/fake/__tests__/keyName.spec.ts +5 -5
  362. package/src/fake/index.ts +9 -6
  363. package/src/fake/providers/FakeProvider.spec.ts +258 -40
  364. package/src/fake/providers/FakeProvider.ts +133 -19
  365. package/src/lock/core/index.ts +11 -4
  366. package/src/logger/index.ts +17 -66
  367. package/src/logger/providers/PrettyFormatterProvider.ts +0 -9
  368. package/src/mcp/errors/McpError.ts +30 -0
  369. package/src/mcp/index.ts +13 -27
  370. package/src/mcp/transports/SseMcpTransport.ts +6 -7
  371. package/src/orm/__tests__/PostgresProvider.spec.ts +2 -2
  372. package/src/orm/index.browser.ts +2 -2
  373. package/src/orm/index.bun.ts +4 -2
  374. package/src/orm/index.ts +21 -47
  375. package/src/orm/providers/DrizzleKitProvider.ts +3 -5
  376. package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -0
  377. package/src/orm/services/Repository.ts +18 -3
  378. package/src/queue/core/index.ts +14 -6
  379. package/src/react/auth/__tests__/$auth.spec.ts +202 -0
  380. package/src/react/auth/hooks/useAuth.ts +32 -0
  381. package/src/react/auth/index.browser.ts +13 -0
  382. package/src/react/auth/index.shared.ts +2 -0
  383. package/src/react/auth/index.ts +48 -0
  384. package/src/react/auth/providers/ReactAuthProvider.ts +16 -0
  385. package/src/react/auth/services/ReactAuth.ts +135 -0
  386. package/src/react/core/__tests__/Router.spec.tsx +169 -0
  387. package/src/react/core/components/ClientOnly.tsx +49 -0
  388. package/src/react/core/components/ErrorBoundary.tsx +73 -0
  389. package/src/react/core/contexts/AlephaContext.ts +7 -0
  390. package/src/react/core/contexts/AlephaProvider.tsx +42 -0
  391. package/src/react/core/hooks/useAction.browser.spec.tsx +569 -0
  392. package/src/react/core/hooks/useAction.ts +480 -0
  393. package/src/react/core/hooks/useAlepha.ts +26 -0
  394. package/src/react/core/hooks/useClient.ts +17 -0
  395. package/src/react/core/hooks/useEvents.ts +51 -0
  396. package/src/react/core/hooks/useInject.ts +12 -0
  397. package/src/react/core/hooks/useStore.ts +52 -0
  398. package/src/react/core/index.ts +90 -0
  399. package/src/react/form/components/FormState.tsx +17 -0
  400. package/src/react/form/errors/FormValidationError.ts +18 -0
  401. package/src/react/form/hooks/useForm.browser.spec.tsx +366 -0
  402. package/src/react/form/hooks/useForm.ts +47 -0
  403. package/src/react/form/hooks/useFormState.ts +130 -0
  404. package/src/react/form/index.ts +44 -0
  405. package/src/react/form/services/FormModel.ts +614 -0
  406. package/src/react/head/helpers/SeoExpander.spec.ts +203 -0
  407. package/src/react/head/helpers/SeoExpander.ts +142 -0
  408. package/src/react/head/hooks/useHead.spec.tsx +288 -0
  409. package/src/react/head/hooks/useHead.ts +62 -0
  410. package/src/react/head/index.browser.ts +26 -0
  411. package/src/react/head/index.ts +44 -0
  412. package/src/react/head/interfaces/Head.ts +105 -0
  413. package/src/react/head/primitives/$head.ts +25 -0
  414. package/src/react/head/providers/BrowserHeadProvider.browser.spec.ts +196 -0
  415. package/src/react/head/providers/BrowserHeadProvider.ts +212 -0
  416. package/src/react/head/providers/HeadProvider.ts +168 -0
  417. package/src/react/head/providers/ServerHeadProvider.ts +31 -0
  418. package/src/react/i18n/__tests__/integration.spec.tsx +239 -0
  419. package/src/react/i18n/components/Localize.spec.tsx +357 -0
  420. package/src/react/i18n/components/Localize.tsx +35 -0
  421. package/src/react/i18n/hooks/useI18n.browser.spec.tsx +438 -0
  422. package/src/react/i18n/hooks/useI18n.ts +18 -0
  423. package/src/react/i18n/index.ts +41 -0
  424. package/src/react/i18n/primitives/$dictionary.ts +69 -0
  425. package/src/react/i18n/providers/I18nProvider.spec.ts +389 -0
  426. package/src/react/i18n/providers/I18nProvider.ts +278 -0
  427. package/src/react/router/__tests__/page-head-browser.browser.spec.ts +95 -0
  428. package/src/react/router/__tests__/page-head.spec.ts +48 -0
  429. package/src/react/router/__tests__/seo-head.spec.ts +125 -0
  430. package/src/react/router/atoms/ssrManifestAtom.ts +58 -0
  431. package/src/react/router/components/ErrorViewer.tsx +872 -0
  432. package/src/react/router/components/Link.tsx +23 -0
  433. package/src/react/router/components/NestedView.tsx +223 -0
  434. package/src/react/router/components/NotFound.tsx +30 -0
  435. package/src/react/router/constants/PAGE_PRELOAD_KEY.ts +6 -0
  436. package/src/react/router/contexts/RouterLayerContext.ts +12 -0
  437. package/src/react/router/errors/Redirection.ts +28 -0
  438. package/src/react/router/hooks/useActive.ts +52 -0
  439. package/src/react/router/hooks/useQueryParams.ts +63 -0
  440. package/src/react/router/hooks/useRouter.ts +20 -0
  441. package/src/react/router/hooks/useRouterState.ts +11 -0
  442. package/src/react/router/index.browser.ts +45 -0
  443. package/src/react/router/index.shared.ts +19 -0
  444. package/src/react/router/index.ts +142 -0
  445. package/src/react/router/primitives/$page.browser.spec.tsx +851 -0
  446. package/src/react/router/primitives/$page.spec.tsx +708 -0
  447. package/src/react/router/primitives/$page.ts +497 -0
  448. package/src/react/router/providers/ReactBrowserProvider.ts +309 -0
  449. package/src/react/router/providers/ReactBrowserRendererProvider.ts +25 -0
  450. package/src/react/router/providers/ReactBrowserRouterProvider.ts +168 -0
  451. package/src/react/router/providers/ReactPageProvider.ts +726 -0
  452. package/src/react/router/providers/ReactServerProvider.spec.tsx +316 -0
  453. package/src/react/router/providers/ReactServerProvider.ts +558 -0
  454. package/src/react/router/providers/ReactServerTemplateProvider.ts +979 -0
  455. package/src/react/router/providers/SSRManifestProvider.ts +334 -0
  456. package/src/react/router/services/ReactPageServerService.ts +48 -0
  457. package/src/react/router/services/ReactPageService.ts +27 -0
  458. package/src/react/router/services/ReactRouter.ts +262 -0
  459. package/src/react/websocket/hooks/useRoom.tsx +242 -0
  460. package/src/react/websocket/index.ts +7 -0
  461. package/src/redis/__tests__/redis.spec.ts +13 -0
  462. package/src/redis/index.ts +9 -25
  463. package/src/redis/providers/BunRedisProvider.ts +9 -0
  464. package/src/redis/providers/NodeRedisProvider.ts +8 -0
  465. package/src/redis/providers/RedisProvider.ts +16 -0
  466. package/src/retry/index.ts +11 -2
  467. package/src/router/index.ts +15 -0
  468. package/src/scheduler/index.ts +11 -2
  469. package/src/security/__tests__/BasicAuth.spec.ts +2 -0
  470. package/src/security/__tests__/ServerSecurityProvider.spec.ts +13 -5
  471. package/src/security/index.ts +15 -10
  472. package/src/security/interfaces/IssuerResolver.ts +27 -0
  473. package/src/security/primitives/$issuer.ts +55 -0
  474. package/src/security/providers/SecurityProvider.ts +179 -0
  475. package/src/security/providers/ServerBasicAuthProvider.ts +6 -2
  476. package/src/security/providers/ServerSecurityProvider.ts +36 -22
  477. package/src/server/auth/index.ts +12 -7
  478. package/src/server/cache/index.ts +7 -22
  479. package/src/server/compress/index.ts +10 -2
  480. package/src/server/cookies/index.ts +7 -5
  481. package/src/server/cookies/primitives/$cookie.ts +33 -11
  482. package/src/server/core/index.ts +17 -7
  483. package/src/server/core/interfaces/ServerRequest.ts +83 -1
  484. package/src/server/core/primitives/$action.spec.ts +1 -1
  485. package/src/server/core/primitives/$action.ts +8 -3
  486. package/src/server/core/providers/BunHttpServerProvider.ts +1 -1
  487. package/src/server/core/providers/NodeHttpServerProvider.spec.ts +125 -0
  488. package/src/server/core/providers/NodeHttpServerProvider.ts +77 -22
  489. package/src/server/core/providers/ServerLoggerProvider.ts +2 -2
  490. package/src/server/core/providers/ServerProvider.ts +9 -12
  491. package/src/server/core/services/ServerRequestParser.spec.ts +520 -0
  492. package/src/server/core/services/ServerRequestParser.ts +306 -13
  493. package/src/server/cors/index.ts +7 -21
  494. package/src/server/cors/primitives/$cors.ts +6 -2
  495. package/src/server/health/index.ts +8 -2
  496. package/src/server/helmet/index.ts +11 -3
  497. package/src/server/links/atoms/apiLinksAtom.ts +7 -0
  498. package/src/server/links/index.browser.ts +2 -0
  499. package/src/server/links/index.ts +13 -6
  500. package/src/server/metrics/index.ts +10 -3
  501. package/src/server/multipart/index.ts +9 -3
  502. package/src/server/proxy/index.ts +8 -2
  503. package/src/server/rate-limit/index.ts +21 -25
  504. package/src/server/rate-limit/primitives/$rateLimit.ts +6 -2
  505. package/src/server/rate-limit/providers/ServerRateLimitProvider.spec.ts +38 -14
  506. package/src/server/rate-limit/providers/ServerRateLimitProvider.ts +22 -56
  507. package/src/server/static/index.ts +8 -2
  508. package/src/server/static/providers/ServerStaticProvider.ts +1 -1
  509. package/src/server/swagger/index.ts +9 -4
  510. package/src/server/swagger/providers/ServerSwaggerProvider.ts +1 -1
  511. package/src/sms/index.ts +9 -5
  512. package/src/sms/providers/LocalSmsProvider.spec.ts +1 -1
  513. package/src/sms/providers/LocalSmsProvider.ts +1 -1
  514. package/src/system/index.browser.ts +11 -0
  515. package/src/system/index.ts +62 -0
  516. package/src/{file → system}/providers/FileSystemProvider.ts +16 -0
  517. package/src/{file → system}/providers/MemoryFileSystemProvider.ts +116 -3
  518. package/src/system/providers/MemoryShellProvider.ts +164 -0
  519. package/src/{file → system}/providers/NodeFileSystemProvider.spec.ts +2 -2
  520. package/src/{file → system}/providers/NodeFileSystemProvider.ts +36 -0
  521. package/src/system/providers/NodeShellProvider.ts +184 -0
  522. package/src/system/providers/ShellProvider.ts +74 -0
  523. package/src/{file → system}/services/FileDetector.spec.ts +2 -2
  524. package/src/thread/index.ts +11 -2
  525. package/src/topic/core/index.ts +12 -5
  526. package/src/vite/index.ts +3 -2
  527. package/src/vite/tasks/buildClient.ts +2 -8
  528. package/src/vite/tasks/buildServer.ts +84 -21
  529. package/src/vite/tasks/copyAssets.ts +5 -4
  530. package/src/vite/tasks/generateSitemap.ts +64 -23
  531. package/src/vite/tasks/index.ts +0 -2
  532. package/src/vite/tasks/prerenderPages.ts +49 -24
  533. package/src/websocket/index.ts +12 -8
  534. package/dist/file/index.d.ts +0 -839
  535. package/dist/file/index.d.ts.map +0 -1
  536. package/dist/file/index.js.map +0 -1
  537. package/src/cli/assets/indexHtml.ts +0 -15
  538. package/src/cli/assets/mainServerTs.ts +0 -24
  539. package/src/cli/assets/webAppRouterTs.ts +0 -15
  540. package/src/cli/assets/webHelloComponentTsx.ts +0 -16
  541. package/src/cli/commands/format.ts +0 -23
  542. package/src/file/index.ts +0 -43
  543. package/src/vite/helpers/boot.ts +0 -117
  544. package/src/vite/plugins/viteAlephaDev.ts +0 -177
  545. package/src/vite/tasks/devServer.ts +0 -71
  546. package/src/vite/tasks/runAlepha.ts +0 -270
  547. /package/dist/orm/{chunk-DtkW-qnP.js → chunk-DH6iiROE.js} +0 -0
  548. /package/src/cli/{assets → templates}/apiIndexTs.ts +0 -0
  549. /package/src/cli/{assets → templates}/webIndexTs.ts +0 -0
  550. /package/src/{file → system}/errors/FileError.ts +0 -0
  551. /package/src/{file → system}/services/FileDetector.ts +0 -0
@@ -262,6 +262,7 @@ const $module = (options) => {
262
262
  const $ = class extends Module {
263
263
  options = options;
264
264
  register(alepha) {
265
+ if (options.atoms) for (const atom of options.atoms) alepha.store.register(atom);
265
266
  if (typeof options.register === "function") {
266
267
  options.register(alepha);
267
268
  return;
@@ -360,12 +361,8 @@ var InjectPrimitive = class extends Primitive {};
360
361
  * Used across the codebase via dependency injection.
361
362
  */
362
363
  var Json = class {
363
- stringify(value, replacer, space) {
364
- return JSON.stringify(value, replacer, space);
365
- }
366
- parse(text, reviver) {
367
- return JSON.parse(text, reviver);
368
- }
364
+ stringify = JSON.stringify;
365
+ parse = JSON.parse;
369
366
  };
370
367
 
371
368
  //#endregion
@@ -398,6 +395,64 @@ var JsonSchemaCodec = class extends SchemaCodec {
398
395
  }
399
396
  };
400
397
 
398
+ //#endregion
399
+ //#region ../../src/core/primitives/$hook.ts
400
+ /**
401
+ * Registers a new hook.
402
+ *
403
+ * ```ts
404
+ * import { $hook } from "alepha";
405
+ *
406
+ * class MyProvider {
407
+ * onStart = $hook({
408
+ * name: "start", // or "configure", "ready", "stop", ...
409
+ * handler: async (app) => {
410
+ * // await db.connect(); ...
411
+ * }
412
+ * });
413
+ * }
414
+ * ```
415
+ *
416
+ * Hooks are used to run async functions from all registered providers/services.
417
+ *
418
+ * You can't register a hook after the App has started.
419
+ *
420
+ * It's used under the hood by the `configure`, `start`, and `stop` methods.
421
+ * Some modules also use hooks to run their own logic. (e.g. `alepha/server`).
422
+ *
423
+ * You can create your own hooks by using module augmentation:
424
+ *
425
+ * ```ts
426
+ * declare module "alepha" {
427
+ *
428
+ * interface Hooks {
429
+ * "my:custom:hook": {
430
+ * arg1: string;
431
+ * }
432
+ * }
433
+ * }
434
+ *
435
+ * await alepha.events.emit("my:custom:hook", { arg1: "value" });
436
+ * ```
437
+ *
438
+ */
439
+ const $hook = (options) => createPrimitive(HookPrimitive, options);
440
+ var HookPrimitive = class extends Primitive {
441
+ called = 0;
442
+ onInit() {
443
+ const handler = this.options.handler;
444
+ this.alepha.events.on(this.options.on, {
445
+ caller: this.config.service,
446
+ priority: this.options.priority,
447
+ callback: (args) => {
448
+ this.called += 1;
449
+ return handler(args);
450
+ }
451
+ });
452
+ }
453
+ };
454
+ $hook[KIND] = HookPrimitive;
455
+
401
456
  //#endregion
402
457
  //#region ../../src/core/helpers/FileLike.ts
403
458
  const isTypeFile = (value) => {
@@ -834,22 +889,49 @@ const t = new TypeProvider();
834
889
 
835
890
  //#endregion
836
891
  //#region ../../src/core/providers/KeylessJsonSchemaCodec.ts
892
+ const UNSAFE_KEYS = new Set([
893
+ "__proto__",
894
+ "constructor",
895
+ "prototype"
896
+ ]);
837
897
  /**
838
898
  * KeylessJsonSchemaCodec provides schema-driven JSON encoding without keys.
839
899
  *
840
900
  * It uses the schema to determine field order, allowing the encoded output
841
901
  * to be a simple JSON array instead of an object with keys.
842
- *
843
- * Performance characteristics:
844
- * - Encode: 0.94-1.53x vs JSON.stringify (faster for complex objects)
845
- * - Decode: 1.76-2.00x vs JSON.parse
846
- * - Size: 50-56% smaller than JSON
847
902
  */
848
903
  var KeylessJsonSchemaCodec = class extends SchemaCodec {
849
904
  cache = /* @__PURE__ */ new Map();
850
- encoder = new TextEncoder();
851
- decoder = new TextDecoder();
905
+ textEncoder = new TextEncoder();
906
+ textDecoder = new TextDecoder();
852
907
  varCounter = 0;
908
+ useFunctionCompilation = true;
909
+ maxArrayLength = 1e4;
910
+ maxStringLength = 1e6;
911
+ maxDepth = 50;
912
+ /**
913
+ * Configure codec options.
914
+ */
915
+ configure(options) {
916
+ if (options.useFunctionCompilation !== void 0) {
917
+ this.useFunctionCompilation = options.useFunctionCompilation;
918
+ this.cache.clear();
919
+ }
920
+ if (options.maxArrayLength !== void 0) this.maxArrayLength = options.maxArrayLength;
921
+ if (options.maxStringLength !== void 0) this.maxStringLength = options.maxStringLength;
922
+ if (options.maxDepth !== void 0) this.maxDepth = options.maxDepth;
923
+ return this;
924
+ }
925
+ /**
926
+ * Hook to auto-detect safe mode on configure.
927
+ * Disables function compilation in browser by default.
928
+ */
929
+ onConfigure = $hook({
930
+ on: "configure",
931
+ handler: () => {
932
+ this.useFunctionCompilation = this.canUseFunction();
933
+ }
934
+ });
853
935
  /**
854
936
  * Encode value to a keyless JSON string.
855
937
  */
@@ -860,14 +942,14 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
860
942
  * Encode value to binary (UTF-8 encoded keyless JSON).
861
943
  */
862
944
  encodeToBinary(schema, value) {
863
- return this.encoder.encode(this.encodeToString(schema, value));
945
+ return this.textEncoder.encode(this.encodeToString(schema, value));
864
946
  }
865
947
  /**
866
948
  * Decode keyless JSON string or binary to value.
867
949
  */
868
950
  decode(schema, value) {
869
951
  if (value instanceof Uint8Array) {
870
- const text = this.decoder.decode(value);
952
+ const text = this.textDecoder.decode(value);
871
953
  return this.getCodec(schema).decode(text);
872
954
  }
873
955
  if (typeof value === "string") return this.getCodec(schema).decode(value);
@@ -875,13 +957,54 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
875
957
  return value;
876
958
  }
877
959
  /**
960
+ * Test if `new Function()` is available (not blocked by CSP).
961
+ */
962
+ canUseFunction() {
963
+ try {
964
+ return new Function("return true")() === true;
965
+ } catch {
966
+ return false;
967
+ }
968
+ }
969
+ /**
970
+ * Validate schema keys for prototype pollution.
971
+ * Uses a visited set to avoid infinite recursion on recursive schemas.
972
+ */
973
+ validateSchemaKeys(schema, depth = 0, visited = /* @__PURE__ */ new Set()) {
974
+ if (visited.has(schema)) return;
975
+ visited.add(schema);
976
+ if (depth > this.maxDepth) throw new AlephaError(`Schema depth exceeds maximum allowed (${this.maxDepth})`);
977
+ if (t.schema.isObject(schema)) {
978
+ const props = schema.properties;
979
+ for (const key of Object.keys(props)) {
980
+ if (UNSAFE_KEYS.has(key)) throw new AlephaError(`Unsafe schema key "${key}" detected. This key is blocked to prevent prototype pollution.`);
981
+ this.validateSchemaKeys(props[key], depth + 1, visited);
982
+ }
983
+ } else if (t.schema.isArray(schema)) {
984
+ const arrSchema = schema;
985
+ this.validateSchemaKeys(arrSchema.items, depth + 1, visited);
986
+ } else if (t.schema.isUnion(schema) || t.schema.isOptional(schema)) this.validateSchemaKeys(this.unwrap(schema), depth, visited);
987
+ }
988
+ /**
989
+ * Validate array length.
990
+ */
991
+ validateArrayLength(arr) {
992
+ if (arr.length > this.maxArrayLength) throw new AlephaError(`Array length (${arr.length}) exceeds maximum allowed (${this.maxArrayLength})`);
993
+ }
994
+ /**
995
+ * Validate string length.
996
+ */
997
+ validateStringLength(str) {
998
+ if (str.length > this.maxStringLength) throw new AlephaError(`String length (${str.length}) exceeds maximum allowed (${this.maxStringLength})`);
999
+ }
1000
+ /**
878
1001
  * Get a compiled codec for the given schema.
879
1002
  * Codecs are cached for reuse.
880
1003
  */
881
1004
  getCodec(schema) {
882
1005
  let c = this.cache.get(schema);
883
1006
  if (!c) {
884
- c = this.compile(schema);
1007
+ c = this.useFunctionCompilation ? this.compileWithFunction(schema) : this.compileInterpreted(schema);
885
1008
  this.cache.set(schema, c);
886
1009
  }
887
1010
  return c;
@@ -889,7 +1012,11 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
889
1012
  nextVar() {
890
1013
  return `_${this.varCounter++}`;
891
1014
  }
892
- compile(schema) {
1015
+ /**
1016
+ * Compile codec using `new Function()` for maximum performance.
1017
+ * Only used when CSP allows and useFunctionCompilation is true.
1018
+ */
1019
+ compileWithFunction(schema) {
893
1020
  this.varCounter = 0;
894
1021
  const encBody = this.genEnc(schema, "v");
895
1022
  this.varCounter = 0;
@@ -899,6 +1026,122 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
899
1026
  decode: new Function("s", `const a=JSON.parse(s);let i=0;${decBody.code}return ${decBody.result};`)
900
1027
  };
901
1028
  }
1029
+ /**
1030
+ * Compile codec using interpreter-based approach.
1031
+ * Safer (no eval/Function) but slower. Used in browser by default.
1032
+ */
1033
+ compileInterpreted(schema) {
1034
+ const self = this;
1035
+ return {
1036
+ encode(value) {
1037
+ return JSON.stringify(self.interpretEncode(schema, value));
1038
+ },
1039
+ decode(str) {
1040
+ const ctx = {
1041
+ arr: JSON.parse(str),
1042
+ i: 0
1043
+ };
1044
+ return self.interpretDecode(schema, ctx);
1045
+ }
1046
+ };
1047
+ }
1048
+ interpretEncode(schema, value) {
1049
+ if (t.schema.isString(schema) || t.schema.isNumber(schema) || t.schema.isInteger(schema) || t.schema.isBoolean(schema) || this.isEnum(schema)) return value;
1050
+ if (t.schema.isBigInt(schema)) return `${value}n`;
1051
+ if (t.schema.isArray(schema)) {
1052
+ const arrSchema = schema;
1053
+ if (!Array.isArray(value)) return value;
1054
+ if (t.schema.isString(arrSchema.items) || t.schema.isNumber(arrSchema.items) || t.schema.isInteger(arrSchema.items) || t.schema.isBoolean(arrSchema.items)) return value;
1055
+ return value.map((e) => this.interpretEncode(arrSchema.items, e));
1056
+ }
1057
+ if (t.schema.isObject(schema)) {
1058
+ const objSchema = schema;
1059
+ const props = objSchema.properties;
1060
+ const keys = Object.keys(props);
1061
+ const req = new Set(objSchema.required || []);
1062
+ const result = [];
1063
+ for (const k of keys) {
1064
+ const ps = props[k];
1065
+ const isOpt = !req.has(k) || t.schema.isOptional(ps);
1066
+ const isNullable = this.isNullable(ps);
1067
+ const inner = this.unwrap(ps);
1068
+ const v = value[k];
1069
+ if (isOpt) result.push(v !== void 0 ? this.interpretEncode(inner, v) : null);
1070
+ else if (isNullable) result.push(v !== null ? this.interpretEncode(inner, v) : null);
1071
+ else result.push(this.interpretEncode(inner, v));
1072
+ }
1073
+ return result;
1074
+ }
1075
+ if (t.schema.isOptional(schema) || t.schema.isUnion(schema)) {
1076
+ const inner = this.unwrap(schema);
1077
+ if (this.isNullable(schema)) return value !== null ? this.interpretEncode(inner, value) : null;
1078
+ return value !== void 0 ? this.interpretEncode(inner, value) : null;
1079
+ }
1080
+ return value;
1081
+ }
1082
+ interpretDecode(schema, ctx) {
1083
+ if (t.schema.isString(schema) || t.schema.isNumber(schema) || t.schema.isInteger(schema) || t.schema.isBoolean(schema) || this.isEnum(schema)) return ctx.arr[ctx.i++];
1084
+ if (t.schema.isBigInt(schema)) return BigInt(ctx.arr[ctx.i++].slice(0, -1));
1085
+ if (t.schema.isArray(schema)) {
1086
+ const arrSchema = schema;
1087
+ const arr = ctx.arr[ctx.i++];
1088
+ if (!Array.isArray(arr)) return arr;
1089
+ if (t.schema.isObject(arrSchema.items)) return arr.map((e) => this.interpretDecodeFromValue(arrSchema.items, e));
1090
+ return arr;
1091
+ }
1092
+ if (t.schema.isObject(schema)) {
1093
+ const objSchema = schema;
1094
+ const props = objSchema.properties;
1095
+ const keys = Object.keys(props);
1096
+ const req = new Set(objSchema.required || []);
1097
+ const result = {};
1098
+ for (const k of keys) {
1099
+ const ps = props[k];
1100
+ const isOpt = !req.has(k) || t.schema.isOptional(ps);
1101
+ const isNullable = this.isNullable(ps);
1102
+ const inner = this.unwrap(ps);
1103
+ const val = ctx.arr[ctx.i++];
1104
+ if (isOpt) {
1105
+ if (val !== null) result[k] = this.interpretDecodeFromValue(inner, val);
1106
+ } else if (isNullable) result[k] = val === null ? null : this.interpretDecodeFromValue(inner, val);
1107
+ else result[k] = this.interpretDecodeFromValue(inner, val);
1108
+ }
1109
+ return result;
1110
+ }
1111
+ if (t.schema.isOptional(schema) || t.schema.isUnion(schema)) {
1112
+ const inner = this.unwrap(schema);
1113
+ const val = ctx.arr[ctx.i++];
1114
+ if (val === null) return this.isNullable(schema) ? null : void 0;
1115
+ if (t.schema.isObject(inner) || t.schema.isArray(inner)) return this.interpretDecodeFromValue(inner, val);
1116
+ return val;
1117
+ }
1118
+ return ctx.arr[ctx.i++];
1119
+ }
1120
+ interpretDecodeFromValue(schema, value) {
1121
+ if (t.schema.isString(schema) || t.schema.isNumber(schema) || t.schema.isInteger(schema) || t.schema.isBoolean(schema) || this.isEnum(schema)) return value;
1122
+ if (t.schema.isBigInt(schema)) return BigInt(value.slice(0, -1));
1123
+ if (t.schema.isArray(schema)) {
1124
+ if (!Array.isArray(value)) return value;
1125
+ const arrSchema = schema;
1126
+ if (t.schema.isObject(arrSchema.items)) return value.map((e) => this.interpretDecodeFromValue(arrSchema.items, e));
1127
+ return value;
1128
+ }
1129
+ if (t.schema.isObject(schema)) {
1130
+ const props = schema.properties;
1131
+ const keys = Object.keys(props);
1132
+ const result = {};
1133
+ for (let idx = 0; idx < keys.length; idx++) {
1134
+ const k = keys[idx];
1135
+ const inner = this.unwrap(props[k]);
1136
+ const v = value[idx];
1137
+ if (t.schema.isObject(inner)) result[k] = this.interpretDecodeFromValue(inner, v);
1138
+ else if (t.schema.isBigInt(inner)) result[k] = BigInt(v.slice(0, -1));
1139
+ else result[k] = v;
1140
+ }
1141
+ return result;
1142
+ }
1143
+ return value;
1144
+ }
902
1145
  genEnc(schema, ve) {
903
1146
  if (t.schema.isString(schema) || t.schema.isNumber(schema) || t.schema.isInteger(schema) || t.schema.isBoolean(schema) || this.isEnum(schema)) return ve;
904
1147
  if (t.schema.isBigInt(schema)) return `${ve}+'n'`;
@@ -1090,64 +1333,6 @@ var TypeBoxError = class extends AlephaError {
1090
1333
  }
1091
1334
  };
1092
1335
 
1093
- //#endregion
1094
- //#region ../../src/core/primitives/$hook.ts
1095
- /**
1096
- * Registers a new hook.
1097
- *
1098
- * ```ts
1099
- * import { $hook } from "alepha";
1100
- *
1101
- * class MyProvider {
1102
- * onStart = $hook({
1103
- * name: "start", // or "configure", "ready", "stop", ...
1104
- * handler: async (app) => {
1105
- * // await db.connect(); ...
1106
- * }
1107
- * });
1108
- * }
1109
- * ```
1110
- *
1111
- * Hooks are used to run async functions from all registered providers/services.
1112
- *
1113
- * You can't register a hook after the App has started.
1114
- *
1115
- * It's used under the hood by the `configure`, `start`, and `stop` methods.
1116
- * Some modules also use hooks to run their own logic. (e.g. `alepha/server`).
1117
- *
1118
- * You can create your own hooks by using module augmentation:
1119
- *
1120
- * ```ts
1121
- * declare module "alepha" {
1122
- *
1123
- * interface Hooks {
1124
- * "my:custom:hook": {
1125
- * arg1: string;
1126
- * }
1127
- * }
1128
- * }
1129
- *
1130
- * await alepha.events.emit("my:custom:hook", { arg1: "value" });
1131
- * ```
1132
- *
1133
- */
1134
- const $hook = (options) => createPrimitive(HookPrimitive, options);
1135
- var HookPrimitive = class extends Primitive {
1136
- called = 0;
1137
- onInit() {
1138
- const handler = this.options.handler;
1139
- this.alepha.events.on(this.options.on, {
1140
- caller: this.config.service,
1141
- priority: this.options.priority,
1142
- callback: (args) => {
1143
- this.called += 1;
1144
- return handler(args);
1145
- }
1146
- });
1147
- }
1148
- };
1149
- $hook[KIND] = HookPrimitive;
1150
-
1151
1336
  //#endregion
1152
1337
  //#region ../../src/core/providers/SchemaValidator.ts
1153
1338
  var SchemaValidator = class {
@@ -1403,7 +1588,7 @@ var EventManager = class {
1403
1588
  async emit(func, payload, options = {}) {
1404
1589
  const events = this.events[func];
1405
1590
  if (!events || events.length === 0) return;
1406
- if (events.length === 1 && !options.log && !options.reverse) {
1591
+ if (events.length === 1 && !options.log) {
1407
1592
  const hook = events[0];
1408
1593
  try {
1409
1594
  const result = hook.callback(payload);
@@ -1422,9 +1607,7 @@ var EventManager = class {
1422
1607
  ctx.now = performance.now();
1423
1608
  this.log?.trace(`${String(func)} ...`);
1424
1609
  }
1425
- let eventList = events;
1426
- if (options.reverse) eventList = events.toReversed();
1427
- for (const hook of eventList) {
1610
+ for (const hook of events) {
1428
1611
  const name = hook.caller?.name ?? "unknown";
1429
1612
  if (options.log) {
1430
1613
  ctx.now2 = performance.now();
@@ -1727,13 +1910,10 @@ var Alepha = class Alepha {
1727
1910
  * If you are not interested about these helpers, you can use the constructor directly.
1728
1911
  */
1729
1912
  static create(state = {}) {
1730
- if (typeof process === "object" && typeof process.env === "object") {
1731
- state.env = {
1732
- ...state.env,
1733
- ...process.env
1734
- };
1735
- for (const key in state.env) if (state.env[key] === "") delete state.env[key];
1736
- }
1913
+ if (typeof process === "object" && typeof process.env === "object") state.env = {
1914
+ ...state.env,
1915
+ ...process.env
1916
+ };
1737
1917
  if (process.env.NODE_ENV === "production") {
1738
1918
  state.env ??= {};
1739
1919
  Object.assign(state.env, { NODE_ENV: "production" });
@@ -1992,10 +2172,7 @@ var Alepha = class Alepha {
1992
2172
  async stop() {
1993
2173
  if (!this.started) return;
1994
2174
  this.log?.info("Stopping App...");
1995
- await this.events.emit("stop", this, {
1996
- reverse: true,
1997
- log: true
1998
- });
2175
+ await this.events.emit("stop", this, { log: true });
1999
2176
  this.log?.info("App is now off");
2000
2177
  this.started = false;
2001
2178
  this.ready = false;
@@ -2095,7 +2272,10 @@ var Alepha = class Alepha {
2095
2272
  if (!match.parents.includes(parent) && parent !== service) match.parents.push(parent);
2096
2273
  return match.instance;
2097
2274
  }
2098
- if (this.started) throw new ContainerLockedError(`Container is locked. No more services can be added. ${parent?.name} -> ${service.name}`);
2275
+ if (this.started) {
2276
+ const mod = service[MODULE]?.name;
2277
+ throw new ContainerLockedError(`Container is locked. No more services can be added. Attempted to inject '${service.name}' from '${parent?.name}'. ${mod ? `Module '${mod}' is not registered ?` : ""}`);
2278
+ }
2099
2279
  }
2100
2280
  const module = service[MODULE];
2101
2281
  if (module && typeof module === "function") this.with(module);
@@ -2111,10 +2291,10 @@ var Alepha = class Alepha {
2111
2291
  if (!transient) registry.set(service, definition);
2112
2292
  if (instance instanceof Module) {
2113
2293
  this.modules.push(instance);
2114
- const parent$1 = __alephaRef.parent;
2294
+ const parent = __alephaRef.parent;
2115
2295
  __alephaRef.parent = instance.constructor;
2116
2296
  instance.register(this);
2117
- __alephaRef.parent = parent$1;
2297
+ __alephaRef.parent = parent;
2118
2298
  }
2119
2299
  return instance;
2120
2300
  }
@@ -2326,11 +2506,13 @@ function createPagination(entities, limit = 10, offset = 0, sort) {
2326
2506
  * - Nested objects with required/optional properties
2327
2507
  * - Arrays with item schemas
2328
2508
  * - Common validation options: minLength, maxLength, minimum, maximum, pattern
2509
+ * - anyOf/oneOf/allOf with nullable patterns (e.g., `anyOf: [type, null]` → `t.nullable(type)`)
2510
+ * - Alepha ~options (trim, lowercase) pass-through
2329
2511
  *
2330
2512
  * **Not supported:**
2331
- * - oneOf, anyOf, allOf, not (composition schemas)
2332
2513
  * - $ref (references)
2333
2514
  * - additionalProperties, patternProperties
2515
+ * - Complex composition schemas (multiple non-null types in anyOf/oneOf/allOf)
2334
2516
  *
2335
2517
  * @param schema - JSON Schema object to convert
2336
2518
  * @returns TypeBox TSchema
@@ -2357,7 +2539,6 @@ function createPagination(entities, limit = 10, offset = 0, sort) {
2357
2539
  * ```
2358
2540
  */
2359
2541
  function jsonSchemaToTypeBox(schema) {
2360
- if (schema["~kind"]) return schema;
2361
2542
  if (schema.const !== void 0) return t.const(schema.const);
2362
2543
  if (schema.enum && Array.isArray(schema.enum)) {
2363
2544
  if (schema.enum.every((v) => typeof v === "string")) return t.enum(schema.enum, filterUndefined({
@@ -2367,6 +2548,33 @@ function jsonSchemaToTypeBox(schema) {
2367
2548
  }));
2368
2549
  return t.union(schema.enum.map((v) => t.const(v)));
2369
2550
  }
2551
+ if (schema.anyOf && Array.isArray(schema.anyOf)) {
2552
+ const nullSchema = schema.anyOf.find((s) => s.type === "null");
2553
+ const nonNullSchemas = schema.anyOf.filter((s) => s.type !== "null");
2554
+ if (nullSchema && nonNullSchemas.length === 1) {
2555
+ const converted = jsonSchemaToTypeBox(nonNullSchemas[0]);
2556
+ return t.nullable(converted);
2557
+ }
2558
+ return t.union(schema.anyOf.map((s) => jsonSchemaToTypeBox(s)));
2559
+ }
2560
+ if (schema.allOf && Array.isArray(schema.allOf)) {
2561
+ const nullSchema = schema.allOf.find((s) => s.type === "null");
2562
+ const nonNullSchemas = schema.allOf.filter((s) => s.type !== "null");
2563
+ if (nullSchema && nonNullSchemas.length === 1) {
2564
+ const converted = jsonSchemaToTypeBox(nonNullSchemas[0]);
2565
+ return t.nullable(converted);
2566
+ }
2567
+ if (nonNullSchemas.length > 0) return jsonSchemaToTypeBox(nonNullSchemas[0]);
2568
+ }
2569
+ if (schema.oneOf && Array.isArray(schema.oneOf)) {
2570
+ const nullSchema = schema.oneOf.find((s) => s.type === "null");
2571
+ const nonNullSchemas = schema.oneOf.filter((s) => s.type !== "null");
2572
+ if (nullSchema && nonNullSchemas.length === 1) {
2573
+ const converted = jsonSchemaToTypeBox(nonNullSchemas[0]);
2574
+ return t.nullable(converted);
2575
+ }
2576
+ return t.union(schema.oneOf.map((s) => jsonSchemaToTypeBox(s)));
2577
+ }
2370
2578
  switch (Array.isArray(schema.type) ? schema.type[0] : schema.type) {
2371
2579
  case "string": return convertString(schema);
2372
2580
  case "number": return convertNumber(schema);
@@ -2390,7 +2598,7 @@ function filterUndefined(obj) {
2390
2598
  * Convert JSON Schema string type to TypeBox.
2391
2599
  */
2392
2600
  function convertString(schema) {
2393
- const options = filterUndefined({
2601
+ const baseOptions = filterUndefined({
2394
2602
  title: schema.title,
2395
2603
  description: schema.description,
2396
2604
  default: schema.default,
@@ -2398,6 +2606,10 @@ function convertString(schema) {
2398
2606
  maxLength: schema.maxLength,
2399
2607
  pattern: schema.pattern
2400
2608
  });
2609
+ const options = schema["~options"] ? {
2610
+ ...baseOptions,
2611
+ "~options": schema["~options"]
2612
+ } : baseOptions;
2401
2613
  switch (schema.format) {
2402
2614
  case "email": return t.email(options);
2403
2615
  case "uuid": return t.uuid(options);
@@ -2632,6 +2844,26 @@ TypeProvider.prototype.page = (itemSchema) => pageSchema(itemSchema);
2632
2844
 
2633
2845
  //#endregion
2634
2846
  //#region ../../src/core/index.ts
2847
+ /**
2848
+ * | type | quality | stability |
2849
+ * |------|---------|-----------|
2850
+ * | tooling | epic | stable |
2851
+ *
2852
+ * Foundation of the entire framework with dependency injection and lifecycle management.
2853
+ *
2854
+ * **Features:**
2855
+ * - Dependency injection for services
2856
+ * - Service substitution/mocking
2857
+ * - Type-safe environment variable loading with TypeBox schemas
2858
+ * - Lifecycle hooks (start, stop, log, etc.)
2859
+ * - Module definitions and composition
2860
+ * - Request-scoped context access via Async Local Storage (ALS)
2861
+ * - Reactive state management with atoms
2862
+ * - Cluster mode with automatic worker forking
2863
+ * - Full TypeScript generics and type inference
2864
+ *
2865
+ * @module alepha.core
2866
+ */
2635
2867
  const AlephaCore = $module({
2636
2868
  name: "alepha.core",
2637
2869
  services: [
@@ -2729,5 +2961,5 @@ const withCluster = (entry, opts) => {
2729
2961
  };
2730
2962
 
2731
2963
  //#endregion
2732
- export { $atom, $context, $env, $hook, $inject, $module, $use, Alepha, AlephaCore, AlephaError, AlsProvider, AppNotStartedError, Atom, CircularDependencyError, CodecManager, ContainerLockedError, EventManager, Format, HookPrimitive, InjectPrimitive, JsonSchemaCodec, KIND, KeylessJsonSchemaCodec, Module, OPTIONS, Primitive, SchemaCodec, StateManager, TooLateSubstitutionError, Type, TypeBoxError, TypeGuard, TypeProvider, Value, createPagination, createPrimitive, isClass, isFileLike, isTypeFile, isUUID, jsonSchemaToTypeBox, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
2964
+ export { $atom, $context, $env, $hook, $inject, $module, $use, Alepha, AlephaCore, AlephaError, AlsProvider, AppNotStartedError, Atom, CircularDependencyError, CodecManager, ContainerLockedError, EventManager, Format, HookPrimitive, InjectPrimitive, Json, JsonSchemaCodec, KIND, KeylessJsonSchemaCodec, Module, OPTIONS, Primitive, SchemaCodec, StateManager, TooLateSubstitutionError, Type, TypeBoxError, TypeGuard, TypeProvider, Value, createPagination, createPrimitive, isClass, isFileLike, isTypeFile, isUUID, jsonSchemaToTypeBox, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
2733
2965
  //# sourceMappingURL=index.js.map