alepha 0.22.0 → 0.24.0

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 (869) hide show
  1. package/assets/swagger-ui/swagger-ui-bundle.js +1 -1
  2. package/assets/swagger-ui/swagger-ui-standalone-preset.js +1 -1
  3. package/dist/api/audits/index.browser.js +49 -52
  4. package/dist/api/audits/index.browser.js.map +1 -1
  5. package/dist/api/audits/index.d.ts +629 -565
  6. package/dist/api/audits/index.d.ts.map +1 -1
  7. package/dist/api/audits/index.js +206 -98
  8. package/dist/api/audits/index.js.map +1 -1
  9. package/dist/api/files/index.browser.js +44 -44
  10. package/dist/api/files/index.browser.js.map +1 -1
  11. package/dist/api/files/index.d.ts +292 -293
  12. package/dist/api/files/index.d.ts.map +1 -1
  13. package/dist/api/files/index.js +61 -64
  14. package/dist/api/files/index.js.map +1 -1
  15. package/dist/api/jobs/index.browser.js +61 -59
  16. package/dist/api/jobs/index.browser.js.map +1 -1
  17. package/dist/api/jobs/index.d.ts +546 -347
  18. package/dist/api/jobs/index.d.ts.map +1 -1
  19. package/dist/api/jobs/index.js +165 -86
  20. package/dist/api/jobs/index.js.map +1 -1
  21. package/dist/api/keys/index.d.ts +242 -230
  22. package/dist/api/keys/index.d.ts.map +1 -1
  23. package/dist/api/keys/index.js +63 -66
  24. package/dist/api/keys/index.js.map +1 -1
  25. package/dist/api/notifications/index.browser.js +40 -38
  26. package/dist/api/notifications/index.browser.js.map +1 -1
  27. package/dist/api/notifications/index.d.ts +339 -209
  28. package/dist/api/notifications/index.d.ts.map +1 -1
  29. package/dist/api/notifications/index.js +108 -60
  30. package/dist/api/notifications/index.js.map +1 -1
  31. package/dist/api/oauth/index.d.ts +190 -78
  32. package/dist/api/oauth/index.d.ts.map +1 -1
  33. package/dist/api/oauth/index.js +290 -68
  34. package/dist/api/oauth/index.js.map +1 -1
  35. package/dist/api/organizations/index.browser.js +14 -14
  36. package/dist/api/organizations/index.browser.js.map +1 -1
  37. package/dist/api/organizations/index.d.ts +158 -134
  38. package/dist/api/organizations/index.d.ts.map +1 -1
  39. package/dist/api/organizations/index.js +18 -18
  40. package/dist/api/organizations/index.js.map +1 -1
  41. package/dist/api/parameters/index.browser.js +74 -53
  42. package/dist/api/parameters/index.browser.js.map +1 -1
  43. package/dist/api/parameters/index.d.ts +607 -513
  44. package/dist/api/parameters/index.d.ts.map +1 -1
  45. package/dist/api/parameters/index.js +205 -127
  46. package/dist/api/parameters/index.js.map +1 -1
  47. package/dist/api/payments/index.d.ts +652 -449
  48. package/dist/api/payments/index.d.ts.map +1 -1
  49. package/dist/api/payments/index.js +159 -93
  50. package/dist/api/payments/index.js.map +1 -1
  51. package/dist/api/subscriptions/index.d.ts +1032 -762
  52. package/dist/api/subscriptions/index.d.ts.map +1 -1
  53. package/dist/api/subscriptions/index.js +166 -185
  54. package/dist/api/subscriptions/index.js.map +1 -1
  55. package/dist/api/users/index.browser.js +48 -71
  56. package/dist/api/users/index.browser.js.map +1 -1
  57. package/dist/api/users/index.d.ts +1297 -1109
  58. package/dist/api/users/index.d.ts.map +1 -1
  59. package/dist/api/users/index.js +454 -369
  60. package/dist/api/users/index.js.map +1 -1
  61. package/dist/api/verifications/index.browser.js +17 -17
  62. package/dist/api/verifications/index.browser.js.map +1 -1
  63. package/dist/api/verifications/index.d.ts +169 -157
  64. package/dist/api/verifications/index.d.ts.map +1 -1
  65. package/dist/api/verifications/index.js +47 -95
  66. package/dist/api/verifications/index.js.map +1 -1
  67. package/dist/background/index.d.ts +0 -1
  68. package/dist/background/index.d.ts.map +1 -1
  69. package/dist/background/index.js.map +1 -1
  70. package/dist/background/index.workerd.js.map +1 -1
  71. package/dist/batch/index.d.ts +0 -1
  72. package/dist/batch/index.d.ts.map +1 -1
  73. package/dist/batch/index.js.map +1 -1
  74. package/dist/bin/index.js +1 -1
  75. package/dist/bin/index.js.map +1 -1
  76. package/dist/bucket/index.d.ts +27 -32
  77. package/dist/bucket/index.d.ts.map +1 -1
  78. package/dist/bucket/index.js +56 -26
  79. package/dist/bucket/index.js.map +1 -1
  80. package/dist/bucket/index.workerd.js +52 -24
  81. package/dist/bucket/index.workerd.js.map +1 -1
  82. package/dist/cache/core/index.d.ts +4 -6
  83. package/dist/cache/core/index.d.ts.map +1 -1
  84. package/dist/cache/core/index.js +4 -10
  85. package/dist/cache/core/index.js.map +1 -1
  86. package/dist/cache/core/index.workerd.js +4 -10
  87. package/dist/cache/core/index.workerd.js.map +1 -1
  88. package/dist/cache/database/index.d.ts +22 -23
  89. package/dist/cache/database/index.d.ts.map +1 -1
  90. package/dist/cache/database/index.js +11 -20
  91. package/dist/cache/database/index.js.map +1 -1
  92. package/dist/cache/redis/index.d.ts +3 -4
  93. package/dist/cache/redis/index.d.ts.map +1 -1
  94. package/dist/cache/redis/index.js +2 -2
  95. package/dist/cache/redis/index.js.map +1 -1
  96. package/dist/captcha/index.d.ts.map +1 -1
  97. package/dist/captcha/index.js +4 -4
  98. package/dist/captcha/index.js.map +1 -1
  99. package/dist/cli/config/index.d.ts +0 -1
  100. package/dist/cli/config/index.d.ts.map +1 -1
  101. package/dist/cli/core/index.d.ts +244 -475
  102. package/dist/cli/core/index.d.ts.map +1 -1
  103. package/dist/cli/core/index.js +308 -383
  104. package/dist/cli/core/index.js.map +1 -1
  105. package/dist/cli/devtools/index.d.ts +3 -9
  106. package/dist/cli/devtools/index.d.ts.map +1 -1
  107. package/dist/cli/devtools/index.js +3 -3
  108. package/dist/cli/devtools/index.js.map +1 -1
  109. package/dist/cli/i18n/index.d.ts +20 -39
  110. package/dist/cli/i18n/index.d.ts.map +1 -1
  111. package/dist/cli/i18n/index.js +51 -17
  112. package/dist/cli/i18n/index.js.map +1 -1
  113. package/dist/cli/platform/index.d.ts +89 -82
  114. package/dist/cli/platform/index.d.ts.map +1 -1
  115. package/dist/cli/platform/index.js +27 -33
  116. package/dist/cli/platform/index.js.map +1 -1
  117. package/dist/cli/platform-lib/index.d.ts +383 -410
  118. package/dist/cli/platform-lib/index.d.ts.map +1 -1
  119. package/dist/cli/platform-lib/index.js +300 -258
  120. package/dist/cli/platform-lib/index.js.map +1 -1
  121. package/dist/cli/vendor/index.d.ts +17 -41
  122. package/dist/cli/vendor/index.d.ts.map +1 -1
  123. package/dist/cli/vendor/index.js +10 -13
  124. package/dist/cli/vendor/index.js.map +1 -1
  125. package/dist/command/index.d.ts +82 -194
  126. package/dist/command/index.d.ts.map +1 -1
  127. package/dist/command/index.js +160 -563
  128. package/dist/command/index.js.map +1 -1
  129. package/dist/core/index.browser.js +845 -859
  130. package/dist/core/index.browser.js.map +1 -1
  131. package/dist/core/index.d.ts +787 -527
  132. package/dist/core/index.d.ts.map +1 -1
  133. package/dist/core/index.js +845 -859
  134. package/dist/core/index.js.map +1 -1
  135. package/dist/core/index.native.js +845 -859
  136. package/dist/core/index.native.js.map +1 -1
  137. package/dist/core/index.workerd.js +845 -859
  138. package/dist/core/index.workerd.js.map +1 -1
  139. package/dist/crypto/index.browser.js +1 -1
  140. package/dist/crypto/index.browser.js.map +1 -1
  141. package/dist/crypto/index.d.ts +3 -4
  142. package/dist/crypto/index.d.ts.map +1 -1
  143. package/dist/crypto/index.js +6 -3
  144. package/dist/crypto/index.js.map +1 -1
  145. package/dist/datetime/index.d.ts +12 -2
  146. package/dist/datetime/index.d.ts.map +1 -1
  147. package/dist/datetime/index.js +6 -1
  148. package/dist/datetime/index.js.map +1 -1
  149. package/dist/email/brevo/index.d.ts +0 -1
  150. package/dist/email/brevo/index.d.ts.map +1 -1
  151. package/dist/email/brevo/index.js +4 -4
  152. package/dist/email/brevo/index.js.map +1 -1
  153. package/dist/email/cloudflare/index.d.ts +0 -1
  154. package/dist/email/cloudflare/index.d.ts.map +1 -1
  155. package/dist/email/cloudflare/index.js +2 -2
  156. package/dist/email/cloudflare/index.js.map +1 -1
  157. package/dist/email/core/index.d.ts +15 -7
  158. package/dist/email/core/index.d.ts.map +1 -1
  159. package/dist/email/core/index.js +14 -5
  160. package/dist/email/core/index.js.map +1 -1
  161. package/dist/email/core/index.workerd.js +5 -1
  162. package/dist/email/core/index.workerd.js.map +1 -1
  163. package/dist/email/smtp/index.d.ts +8 -9
  164. package/dist/email/smtp/index.d.ts.map +1 -1
  165. package/dist/email/smtp/index.js +702 -479
  166. package/dist/email/smtp/index.js.map +1 -1
  167. package/dist/fake/index.d.ts +1580 -1238
  168. package/dist/fake/index.d.ts.map +1 -1
  169. package/dist/fake/index.js +11728 -32131
  170. package/dist/fake/index.js.map +1 -1
  171. package/dist/lock/core/index.d.ts +13 -9
  172. package/dist/lock/core/index.d.ts.map +1 -1
  173. package/dist/lock/core/index.js +5 -5
  174. package/dist/lock/core/index.js.map +1 -1
  175. package/dist/lock/redis/index.d.ts +0 -1
  176. package/dist/lock/redis/index.d.ts.map +1 -1
  177. package/dist/lock/redis/index.js.map +1 -1
  178. package/dist/logger/index.d.ts +81 -69
  179. package/dist/logger/index.d.ts.map +1 -1
  180. package/dist/logger/index.js +123 -56
  181. package/dist/logger/index.js.map +1 -1
  182. package/dist/mcp/index.d.ts +36 -90
  183. package/dist/mcp/index.d.ts.map +1 -1
  184. package/dist/mcp/index.js +65 -70
  185. package/dist/mcp/index.js.map +1 -1
  186. package/dist/orm/core/index.browser.js +54 -40
  187. package/dist/orm/core/index.browser.js.map +1 -1
  188. package/dist/orm/core/index.bun.js +140 -106
  189. package/dist/orm/core/index.bun.js.map +1 -1
  190. package/dist/orm/core/index.d.ts +145 -150
  191. package/dist/orm/core/index.d.ts.map +1 -1
  192. package/dist/orm/core/index.js +144 -109
  193. package/dist/orm/core/index.js.map +1 -1
  194. package/dist/orm/postgres/index.bun.js +64 -54
  195. package/dist/orm/postgres/index.bun.js.map +1 -1
  196. package/dist/orm/postgres/index.d.ts +36 -76
  197. package/dist/orm/postgres/index.d.ts.map +1 -1
  198. package/dist/orm/postgres/index.js +67 -57
  199. package/dist/orm/postgres/index.js.map +1 -1
  200. package/dist/queue/core/index.d.ts +62 -75
  201. package/dist/queue/core/index.d.ts.map +1 -1
  202. package/dist/queue/core/index.js +48 -71
  203. package/dist/queue/core/index.js.map +1 -1
  204. package/dist/queue/core/index.workerd.js +48 -71
  205. package/dist/queue/core/index.workerd.js.map +1 -1
  206. package/dist/queue/redis/index.d.ts +3 -4
  207. package/dist/queue/redis/index.d.ts.map +1 -1
  208. package/dist/queue/redis/index.js +2 -2
  209. package/dist/queue/redis/index.js.map +1 -1
  210. package/dist/react/auth/index.browser.js.map +1 -1
  211. package/dist/react/auth/index.d.ts +7 -4
  212. package/dist/react/auth/index.d.ts.map +1 -1
  213. package/dist/react/auth/index.js.map +1 -1
  214. package/dist/react/core/index.d.ts +87 -5
  215. package/dist/react/core/index.d.ts.map +1 -1
  216. package/dist/react/core/index.js +170 -23
  217. package/dist/react/core/index.js.map +1 -1
  218. package/dist/react/form/index.d.ts +4 -6
  219. package/dist/react/form/index.d.ts.map +1 -1
  220. package/dist/react/form/index.js +107 -71
  221. package/dist/react/form/index.js.map +1 -1
  222. package/dist/react/head/index.browser.js.map +1 -1
  223. package/dist/react/head/index.d.ts +0 -1
  224. package/dist/react/head/index.d.ts.map +1 -1
  225. package/dist/react/head/index.js.map +1 -1
  226. package/dist/react/i18n/index.d.ts +47 -5
  227. package/dist/react/i18n/index.d.ts.map +1 -1
  228. package/dist/react/i18n/index.js +116 -12
  229. package/dist/react/i18n/index.js.map +1 -1
  230. package/dist/react/intro/index.d.ts +1 -4
  231. package/dist/react/intro/index.d.ts.map +1 -1
  232. package/dist/react/intro/index.js.map +1 -1
  233. package/dist/react/router/index.browser.js +188 -29
  234. package/dist/react/router/index.browser.js.map +1 -1
  235. package/dist/react/router/index.d.ts +480 -372
  236. package/dist/react/router/index.d.ts.map +1 -1
  237. package/dist/react/router/index.js +261 -47
  238. package/dist/react/router/index.js.map +1 -1
  239. package/dist/react/sitemap/index.browser.js +35 -0
  240. package/dist/react/sitemap/index.browser.js.map +1 -0
  241. package/dist/react/sitemap/index.d.ts +91 -0
  242. package/dist/react/sitemap/index.d.ts.map +1 -0
  243. package/dist/react/sitemap/index.js +131 -0
  244. package/dist/react/sitemap/index.js.map +1 -0
  245. package/dist/react/testing/index.d.ts +4 -5
  246. package/dist/react/testing/index.d.ts.map +1 -1
  247. package/dist/react/testing/index.js +41 -15
  248. package/dist/react/testing/index.js.map +1 -1
  249. package/dist/react/testing/{chunk-BpyX8vjI.js → rolldown-runtime-Bl3dcgcQ.js} +1 -1
  250. package/dist/react/ui/index.d.ts +35 -34
  251. package/dist/react/ui/index.d.ts.map +1 -1
  252. package/dist/react/ui/index.js +12 -17
  253. package/dist/react/ui/index.js.map +1 -1
  254. package/dist/redis/index.bun.js +5 -5
  255. package/dist/redis/index.bun.js.map +1 -1
  256. package/dist/redis/index.d.ts +6 -7
  257. package/dist/redis/index.d.ts.map +1 -1
  258. package/dist/redis/index.js +6 -6
  259. package/dist/redis/index.js.map +1 -1
  260. package/dist/retry/index.d.ts +0 -1
  261. package/dist/retry/index.d.ts.map +1 -1
  262. package/dist/retry/index.js.map +1 -1
  263. package/dist/router/index.d.ts.map +1 -1
  264. package/dist/router/index.js.map +1 -1
  265. package/dist/scheduler/index.d.ts +4 -12
  266. package/dist/scheduler/index.d.ts.map +1 -1
  267. package/dist/scheduler/index.js +9 -4
  268. package/dist/scheduler/index.js.map +1 -1
  269. package/dist/scheduler/index.workerd.js +9 -4
  270. package/dist/scheduler/index.workerd.js.map +1 -1
  271. package/dist/security/index.browser.js +30 -28
  272. package/dist/security/index.browser.js.map +1 -1
  273. package/dist/security/index.d.ts +113 -44
  274. package/dist/security/index.d.ts.map +1 -1
  275. package/dist/security/index.js +452 -37
  276. package/dist/security/index.js.map +1 -1
  277. package/dist/server/auth/index.browser.js +19 -19
  278. package/dist/server/auth/index.browser.js.map +1 -1
  279. package/dist/server/auth/index.d.ts +215 -187
  280. package/dist/server/auth/index.d.ts.map +1 -1
  281. package/dist/server/auth/index.js +1145 -86
  282. package/dist/server/auth/index.js.map +1 -1
  283. package/dist/server/cookies/index.browser.js +103 -5
  284. package/dist/server/cookies/index.browser.js.map +1 -1
  285. package/dist/server/cookies/index.d.ts +86 -4
  286. package/dist/server/cookies/index.d.ts.map +1 -1
  287. package/dist/server/cookies/index.js +121 -8
  288. package/dist/server/cookies/index.js.map +1 -1
  289. package/dist/server/core/index.browser.js +22 -27
  290. package/dist/server/core/index.browser.js.map +1 -1
  291. package/dist/server/core/index.d.ts +134 -85
  292. package/dist/server/core/index.d.ts.map +1 -1
  293. package/dist/server/core/index.js +130 -118
  294. package/dist/server/core/index.js.map +1 -1
  295. package/dist/server/cors/index.d.ts +9 -10
  296. package/dist/server/cors/index.d.ts.map +1 -1
  297. package/dist/server/cors/index.js +14 -26
  298. package/dist/server/cors/index.js.map +1 -1
  299. package/dist/server/etag/index.d.ts +2 -3
  300. package/dist/server/etag/index.d.ts.map +1 -1
  301. package/dist/server/etag/index.js.map +1 -1
  302. package/dist/server/health/index.d.ts +18 -19
  303. package/dist/server/health/index.d.ts.map +1 -1
  304. package/dist/server/health/index.js +6 -6
  305. package/dist/server/health/index.js.map +1 -1
  306. package/dist/server/links/index.browser.js +15 -18
  307. package/dist/server/links/index.browser.js.map +1 -1
  308. package/dist/server/links/index.d.ts +66 -67
  309. package/dist/server/links/index.d.ts.map +1 -1
  310. package/dist/server/links/index.js +29 -32
  311. package/dist/server/links/index.js.map +1 -1
  312. package/dist/server/metrics/index.d.ts +0 -1
  313. package/dist/server/metrics/index.d.ts.map +1 -1
  314. package/dist/server/metrics/index.js +10 -3
  315. package/dist/server/metrics/index.js.map +1 -1
  316. package/dist/server/proxy/index.d.ts +0 -1
  317. package/dist/server/proxy/index.d.ts.map +1 -1
  318. package/dist/server/proxy/index.js.map +1 -1
  319. package/dist/server/rate-limit/index.d.ts +8 -9
  320. package/dist/server/rate-limit/index.d.ts.map +1 -1
  321. package/dist/server/rate-limit/index.js +6 -12
  322. package/dist/server/rate-limit/index.js.map +1 -1
  323. package/dist/server/static/index.d.ts +0 -1
  324. package/dist/server/static/index.d.ts.map +1 -1
  325. package/dist/server/static/index.js.map +1 -1
  326. package/dist/server/swagger/index.d.ts +4 -4
  327. package/dist/server/swagger/index.d.ts.map +1 -1
  328. package/dist/server/swagger/index.js +37 -25
  329. package/dist/server/swagger/index.js.map +1 -1
  330. package/dist/sms/index.d.ts +0 -1
  331. package/dist/sms/index.d.ts.map +1 -1
  332. package/dist/sms/index.js.map +1 -1
  333. package/dist/system/index.browser.js.map +1 -1
  334. package/dist/system/index.d.ts +0 -1
  335. package/dist/system/index.d.ts.map +1 -1
  336. package/dist/system/index.js +2 -1
  337. package/dist/system/index.js.map +1 -1
  338. package/dist/system/index.workerd.js.map +1 -1
  339. package/dist/topic/core/index.d.ts +19 -20
  340. package/dist/topic/core/index.d.ts.map +1 -1
  341. package/dist/topic/core/index.js +8 -8
  342. package/dist/topic/core/index.js.map +1 -1
  343. package/dist/topic/redis/index.d.ts +3 -4
  344. package/dist/topic/redis/index.d.ts.map +1 -1
  345. package/dist/topic/redis/index.js +2 -2
  346. package/dist/topic/redis/index.js.map +1 -1
  347. package/package.json +36 -36
  348. package/src/api/audits/__tests__/AuditJobs.spec.ts +83 -0
  349. package/src/api/audits/__tests__/AuditService.spec.ts +139 -1
  350. package/src/api/audits/controllers/AdminAuditController.ts +41 -41
  351. package/src/api/audits/entities/audits.ts +22 -22
  352. package/src/api/audits/index.ts +6 -1
  353. package/src/api/audits/jobs/AuditJobs.ts +29 -0
  354. package/src/api/audits/parameters/AuditParameters.ts +51 -0
  355. package/src/api/audits/primitives/$audit.ts +24 -0
  356. package/src/api/audits/schemas/auditQuerySchema.ts +13 -13
  357. package/src/api/audits/schemas/createAuditSchema.ts +18 -18
  358. package/src/api/audits/services/AuditService.ts +79 -7
  359. package/src/api/files/__tests__/FileController.spec.ts +5 -5
  360. package/src/api/files/__tests__/FileJobs.spec.ts +6 -0
  361. package/src/api/files/controllers/FileController.ts +25 -25
  362. package/src/api/files/entities/files.ts +15 -15
  363. package/src/api/files/schemas/fileCreatorSummarySchema.ts +7 -7
  364. package/src/api/files/schemas/fileQuerySchema.ts +9 -9
  365. package/src/api/files/schemas/fileResourceSchema.ts +7 -9
  366. package/src/api/files/schemas/storageStatsSchema.ts +13 -13
  367. package/src/api/jobs/__tests__/$job-hardening.spec.ts +289 -0
  368. package/src/api/jobs/__tests__/$job.spec.ts +18 -18
  369. package/src/api/jobs/controllers/AdminJobController.ts +8 -8
  370. package/src/api/jobs/entities/jobExecutionEntity.ts +29 -19
  371. package/src/api/jobs/providers/JobProvider.ts +128 -12
  372. package/src/api/jobs/providers/JobQueueProvider.ts +2 -2
  373. package/src/api/jobs/schemas/jobConfigAtom.ts +22 -22
  374. package/src/api/jobs/schemas/jobExecutionQuerySchema.ts +6 -6
  375. package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +11 -15
  376. package/src/api/jobs/schemas/jobRegistrationSchema.ts +20 -19
  377. package/src/api/jobs/schemas/triggerJobSchema.ts +3 -3
  378. package/src/api/jobs/services/JobService.ts +6 -6
  379. package/src/api/keys/__tests__/ApiKeyService.spec.ts +2 -2
  380. package/src/api/keys/controllers/AdminApiKeyController.ts +10 -10
  381. package/src/api/keys/entities/apiKeyEntity.ts +15 -15
  382. package/src/api/keys/schemas/adminApiKeyQuerySchema.ts +4 -4
  383. package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +15 -15
  384. package/src/api/keys/schemas/createApiKeyBodySchema.ts +5 -5
  385. package/src/api/keys/schemas/createApiKeyResponseSchema.ts +9 -9
  386. package/src/api/keys/schemas/listApiKeyResponseSchema.ts +13 -13
  387. package/src/api/keys/schemas/revokeApiKeyParamsSchema.ts +3 -3
  388. package/src/api/keys/schemas/revokeApiKeyResponseSchema.ts +3 -3
  389. package/src/api/notifications/__tests__/AlephaApiNotifications.spec.ts +2 -2
  390. package/src/api/notifications/controllers/AdminNotificationController.ts +38 -14
  391. package/src/api/notifications/jobs/NotificationJobs.ts +7 -6
  392. package/src/api/notifications/primitives/$notification.ts +43 -4
  393. package/src/api/notifications/schemas/notificationContactPreferencesSchema.ts +4 -4
  394. package/src/api/notifications/schemas/notificationContactSchema.ts +7 -7
  395. package/src/api/notifications/schemas/notificationDetailResourceSchema.ts +9 -11
  396. package/src/api/notifications/schemas/notificationPayloadSchema.ts +11 -9
  397. package/src/api/notifications/schemas/notificationQuerySchema.ts +6 -6
  398. package/src/api/notifications/schemas/notificationResourceSchema.ts +14 -14
  399. package/src/api/notifications/services/NotificationSenderService.ts +38 -2
  400. package/src/api/oauth/__tests__/OAuthClientService.spec.ts +42 -0
  401. package/src/api/oauth/__tests__/OAuthController.spec.ts +128 -0
  402. package/src/api/oauth/controllers/OAuthController.ts +132 -12
  403. package/src/api/oauth/entities/oauthClientEntity.ts +29 -12
  404. package/src/api/oauth/helpers/oauthMetadata.ts +1 -0
  405. package/src/api/oauth/helpers/oidcMetadata.ts +19 -0
  406. package/src/api/oauth/index.ts +1 -0
  407. package/src/api/oauth/schemas/authorizeDecisionBodySchema.ts +12 -11
  408. package/src/api/oauth/schemas/authorizeQuerySchema.ts +12 -10
  409. package/src/api/oauth/schemas/registerClientBodySchema.ts +10 -11
  410. package/src/api/oauth/schemas/tokenRequestBodySchema.ts +9 -8
  411. package/src/api/oauth/services/OAuthClientService.ts +228 -15
  412. package/src/api/organizations/controllers/AdminOrganizationController.ts +8 -8
  413. package/src/api/organizations/entities/organizations.ts +6 -6
  414. package/src/api/organizations/schemas/createOrganizationSchema.ts +5 -5
  415. package/src/api/organizations/schemas/organizationQuerySchema.ts +4 -4
  416. package/src/api/organizations/schemas/updateOrganizationSchema.ts +1 -2
  417. package/src/api/parameters/__tests__/$parameter.spec.ts +229 -50
  418. package/src/api/parameters/controllers/AdminParameterController.ts +9 -12
  419. package/src/api/parameters/entities/parameters.ts +29 -16
  420. package/src/api/parameters/primitives/$parameter.ts +3 -3
  421. package/src/api/parameters/schemas/activateParameterBodySchema.ts +4 -4
  422. package/src/api/parameters/schemas/createParameterVersionBodySchema.ts +15 -15
  423. package/src/api/parameters/schemas/parameterCreatorSummarySchema.ts +7 -7
  424. package/src/api/parameters/schemas/parameterCurrentResponseSchema.ts +7 -7
  425. package/src/api/parameters/schemas/parameterHistoryResponseSchema.ts +3 -3
  426. package/src/api/parameters/schemas/parameterNameParamSchema.ts +2 -3
  427. package/src/api/parameters/schemas/parameterNamesResponseSchema.ts +3 -3
  428. package/src/api/parameters/schemas/parameterResponseSchema.ts +3 -3
  429. package/src/api/parameters/schemas/parameterStatusSchema.ts +2 -2
  430. package/src/api/parameters/schemas/parameterTreeNodeSchema.ts +6 -6
  431. package/src/api/parameters/schemas/parameterVersionParamSchema.ts +5 -6
  432. package/src/api/parameters/schemas/parameterVersionResponseSchema.ts +3 -3
  433. package/src/api/parameters/schemas/rollbackParameterBodySchema.ts +6 -9
  434. package/src/api/parameters/services/ParameterProvider.ts +152 -65
  435. package/src/api/payments/controllers/AdminPaymentController.ts +7 -7
  436. package/src/api/payments/controllers/MockCheckoutController.ts +79 -28
  437. package/src/api/payments/controllers/PaymentController.ts +4 -4
  438. package/src/api/payments/entities/paymentIntents.ts +11 -11
  439. package/src/api/payments/entities/paymentMethods.ts +11 -11
  440. package/src/api/payments/entities/refunds.ts +9 -9
  441. package/src/api/payments/providers/PaymentProvider.ts +18 -0
  442. package/src/api/payments/schemas/intentSchemas.ts +25 -25
  443. package/src/api/payments/schemas/paymentMethodSchemas.ts +3 -3
  444. package/src/api/payments/services/PaymentService.ts +60 -3
  445. package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +14 -0
  446. package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +11 -11
  447. package/src/api/subscriptions/controllers/SubscriptionController.ts +5 -4
  448. package/src/api/subscriptions/entities/subscriptionEvents.ts +15 -15
  449. package/src/api/subscriptions/entities/subscriptions.ts +22 -22
  450. package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +22 -22
  451. package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +4 -4
  452. package/src/api/subscriptions/schemas/changePlanSchema.ts +5 -5
  453. package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +14 -7
  454. package/src/api/subscriptions/schemas/entitlementsSchema.ts +10 -10
  455. package/src/api/subscriptions/schemas/mrrSchema.ts +9 -9
  456. package/src/api/subscriptions/schemas/planDefinitionSchema.ts +21 -21
  457. package/src/api/subscriptions/schemas/planResourceSchema.ts +19 -19
  458. package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +8 -8
  459. package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +7 -7
  460. package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +17 -17
  461. package/src/api/subscriptions/services/SubscriptionConfig.ts +2 -2
  462. package/src/api/users/__tests__/ApiKeys-integration.spec.ts +11 -11
  463. package/src/api/users/atoms/realmAuthSettingsAtom.ts +111 -119
  464. package/src/api/users/controllers/AdminIdentityController.ts +29 -19
  465. package/src/api/users/controllers/AdminSessionController.ts +37 -27
  466. package/src/api/users/controllers/AdminUserController.ts +75 -53
  467. package/src/api/users/controllers/MySessionController.ts +125 -0
  468. package/src/api/users/controllers/RealmController.ts +9 -9
  469. package/src/api/users/controllers/UserController.ts +55 -55
  470. package/src/api/users/entities/identities.ts +8 -8
  471. package/src/api/users/entities/sessions.ts +17 -17
  472. package/src/api/users/entities/users.ts +17 -17
  473. package/src/api/users/index.ts +3 -0
  474. package/src/api/users/notifications/UserNotifications.ts +76 -24
  475. package/src/api/users/primitives/$realm.ts +12 -0
  476. package/src/api/users/schemas/completePasswordResetRequestSchema.ts +8 -12
  477. package/src/api/users/schemas/completeRegistrationRequestSchema.ts +17 -20
  478. package/src/api/users/schemas/createUserSchema.ts +2 -2
  479. package/src/api/users/schemas/identityQuerySchema.ts +4 -4
  480. package/src/api/users/schemas/identityResourceSchema.ts +3 -2
  481. package/src/api/users/schemas/loginSchema.ts +4 -4
  482. package/src/api/users/schemas/passwordResetIntentResponseSchema.ts +6 -8
  483. package/src/api/users/schemas/realmConfigSchema.ts +10 -10
  484. package/src/api/users/schemas/registerQuerySchema.ts +6 -6
  485. package/src/api/users/schemas/registerRequestSchema.ts +21 -43
  486. package/src/api/users/schemas/registerResponseSchema.ts +2 -2
  487. package/src/api/users/schemas/registerSchema.ts +13 -31
  488. package/src/api/users/schemas/registrationIntentResponseSchema.ts +19 -23
  489. package/src/api/users/schemas/resetPasswordSchema.ts +10 -17
  490. package/src/api/users/schemas/sessionQuerySchema.ts +3 -3
  491. package/src/api/users/schemas/sessionResourceSchema.ts +25 -25
  492. package/src/api/users/schemas/updateUserSchema.ts +3 -4
  493. package/src/api/users/schemas/userQuerySchema.ts +7 -7
  494. package/src/api/users/services/RegistrationService.ts +25 -11
  495. package/src/api/users/services/UserService.ts +12 -6
  496. package/src/api/verifications/__tests__/CodeVerification.spec.ts +63 -101
  497. package/src/api/verifications/__tests__/LinkVerification.spec.ts +23 -92
  498. package/src/api/verifications/controllers/VerificationController.ts +13 -27
  499. package/src/api/verifications/entities/verifications.ts +13 -14
  500. package/src/api/verifications/schemas/requestVerificationCodeResponseSchema.ts +17 -14
  501. package/src/api/verifications/schemas/validateVerificationCodeResponseSchema.ts +9 -10
  502. package/src/api/verifications/schemas/verificationSettingsSchema.ts +65 -66
  503. package/src/api/verifications/schemas/verificationTypeEnumSchema.ts +2 -2
  504. package/src/api/verifications/services/VerificationService.ts +12 -0
  505. package/src/background/__tests__/BackgroundTaskProvider.spec.ts +36 -0
  506. package/src/batch/__tests__/$batch.spec.ts +22 -22
  507. package/src/batch/__tests__/startup-buffering.spec.ts +9 -9
  508. package/src/bin/index.ts +1 -1
  509. package/src/bucket/__tests__/TenantScopedBucket.spec.ts +60 -0
  510. package/src/bucket/providers/LocalFileStorageProvider.ts +14 -6
  511. package/src/bucket/providers/MemoryFileStorageProvider.ts +18 -7
  512. package/src/bucket/providers/R2FileStorageProvider.ts +14 -6
  513. package/src/bucket/providers/S3FileStorageProvider.ts +31 -15
  514. package/src/cache/core/primitives/$cache.ts +7 -10
  515. package/src/cache/database/entities/cacheEntries.ts +16 -27
  516. package/src/cache/database/providers/DatabaseCacheProvider.ts +15 -13
  517. package/src/cache/redis/providers/RedisCacheProvider.ts +6 -6
  518. package/src/captcha/providers/TurnstileCaptchaProvider.ts +4 -4
  519. package/src/cli/core/__tests__/BuildCloudflareTask.spec.ts +178 -0
  520. package/src/cli/core/__tests__/BuildDockerTask.spec.ts +0 -2
  521. package/src/cli/core/__tests__/DbCommand.spec.ts +108 -0
  522. package/src/cli/core/atoms/appEntryOptions.ts +5 -5
  523. package/src/cli/core/atoms/buildOptions.ts +76 -88
  524. package/src/cli/core/atoms/changelogOptions.ts +3 -3
  525. package/src/cli/core/atoms/devOptions.ts +3 -3
  526. package/src/cli/core/commands/build.ts +36 -49
  527. package/src/cli/core/commands/db.ts +171 -83
  528. package/src/cli/core/commands/dev.ts +8 -8
  529. package/src/cli/core/commands/gen/changelog.ts +12 -14
  530. package/src/cli/core/commands/gen/env.ts +6 -6
  531. package/src/cli/core/commands/gen/openapi.ts +6 -6
  532. package/src/cli/core/commands/init.ts +28 -33
  533. package/src/cli/core/commands/pack.ts +10 -10
  534. package/src/cli/core/commands/root.ts +7 -8
  535. package/src/cli/core/commands/test.ts +17 -20
  536. package/src/cli/core/index.ts +0 -3
  537. package/src/cli/core/tasks/BuildCloudflareTask.ts +138 -245
  538. package/src/cli/core/tasks/BuildPrerenderTask.ts +44 -7
  539. package/src/cli/core/templates/apiHelloResponseSchemaTs.ts +4 -4
  540. package/src/cli/devtools/atoms/devtoolsOptions.ts +6 -6
  541. package/src/cli/i18n/__tests__/I18nCheckService.spec.ts +48 -0
  542. package/src/cli/i18n/atoms/i18nOptions.ts +8 -8
  543. package/src/cli/i18n/services/I18nCheckService.ts +65 -11
  544. package/src/cli/platform/commands/SecretsCommand.ts +24 -25
  545. package/src/cli/platform/commands/platform.ts +40 -46
  546. package/src/cli/platform/index.ts +1 -1
  547. package/src/cli/platform-lib/__tests__/CloudflareAdapter.spec.ts +0 -4
  548. package/src/cli/platform-lib/__tests__/PlatformInspector.spec.ts +10 -3
  549. package/src/cli/platform-lib/__tests__/VercelAdapter.spec.ts +0 -2
  550. package/src/cli/platform-lib/adapters/CloudflareAdapter.ts +141 -50
  551. package/src/cli/platform-lib/adapters/VercelAdapter.ts +6 -11
  552. package/src/cli/platform-lib/atoms/platformOptions.ts +46 -25
  553. package/src/cli/platform-lib/schemas/cloudflare.ts +87 -87
  554. package/src/cli/platform-lib/schemas/platform.ts +51 -51
  555. package/src/cli/platform-lib/schemas/vercel.ts +28 -28
  556. package/src/cli/platform-lib/services/CloudflareApi.ts +5 -5
  557. package/src/cli/platform-lib/services/VercelApi.ts +4 -4
  558. package/src/cli/platform-lib/services/VercelCli.ts +6 -15
  559. package/src/cli/platform-lib/services/WranglerApi.ts +6 -15
  560. package/src/cli/vendor/atoms/vendorOptions.ts +9 -9
  561. package/src/cli/vendor/commands/VendorCommand.ts +11 -12
  562. package/src/command/__tests__/$command.spec.ts +82 -83
  563. package/src/command/__tests__/Asker.spec.ts +6 -13
  564. package/src/command/__tests__/CliProvider.spec.ts +136 -149
  565. package/src/command/__tests__/Runner.spec.ts +86 -110
  566. package/src/command/helpers/Asker.ts +23 -58
  567. package/src/command/helpers/Runner.ts +34 -110
  568. package/src/command/index.ts +4 -9
  569. package/src/command/primitives/$command.ts +10 -10
  570. package/src/command/providers/CliProvider.ts +183 -161
  571. package/src/core/Alepha.ts +62 -13
  572. package/src/core/__tests__/$atom.spec.ts +52 -3
  573. package/src/core/__tests__/$computed.spec.ts +129 -0
  574. package/src/core/__tests__/$env.spec.ts +13 -13
  575. package/src/core/__tests__/$inject.spec.ts +4 -4
  576. package/src/core/__tests__/$module.spec.ts +1 -1
  577. package/src/core/__tests__/Alepha-graph.spec.ts +1 -1
  578. package/src/core/__tests__/Alepha-parseEnv.spec.ts +32 -32
  579. package/src/core/__tests__/Alepha-start.spec.ts +3 -3
  580. package/src/core/__tests__/CodecManager.spec.ts +113 -94
  581. package/src/core/__tests__/KeylessJsonSchemaCodec.spec.ts +138 -138
  582. package/src/core/__tests__/SchemaValidator.spec.ts +43 -44
  583. package/src/core/__tests__/StateManager.persist.browser.spec.ts +87 -0
  584. package/src/core/__tests__/StateManager.spec.ts +423 -0
  585. package/src/core/__tests__/TypeBox-usecases.spec.ts +8 -8
  586. package/src/core/__tests__/TypeProvider.spec.ts +314 -309
  587. package/src/core/__tests__/dump.spec.ts +6 -6
  588. package/src/core/__tests__/pagination.spec.ts +4 -4
  589. package/src/core/__tests__/scoped-after-start.spec.ts +43 -0
  590. package/src/core/errors/TypeBoxError.ts +10 -4
  591. package/src/core/helpers/FileLike.ts +5 -5
  592. package/src/core/helpers/coerceStrings.ts +70 -0
  593. package/src/core/helpers/jsonSchemaToZod.ts +112 -0
  594. package/src/core/index.shared.ts +4 -1
  595. package/src/core/primitives/$atom.ts +95 -27
  596. package/src/core/primitives/$computed.ts +148 -0
  597. package/src/core/primitives/$env.ts +5 -5
  598. package/src/core/primitives/$state.ts +1 -1
  599. package/src/core/providers/AlsProvider.ts +26 -0
  600. package/src/core/providers/CodecManager.ts +1 -2
  601. package/src/core/providers/JsonSchemaCodec.ts +1 -2
  602. package/src/core/providers/KeylessJsonSchemaCodec.ts +82 -57
  603. package/src/core/providers/SchemaValidator.ts +48 -158
  604. package/src/core/providers/StateManager.ts +383 -9
  605. package/src/core/providers/TypeProvider.ts +80 -734
  606. package/src/core/providers/ZodProvider.ts +380 -0
  607. package/src/core/providers/zodAugment.ts +69 -0
  608. package/src/core/schemas/pageQuerySchema.ts +19 -21
  609. package/src/core/schemas/pageSchema.ts +47 -57
  610. package/src/crypto/__tests__/SecretProvider.spec.ts +31 -0
  611. package/src/crypto/providers/SecretProvider.ts +16 -10
  612. package/src/datetime/primitives/$throttle.ts +6 -1
  613. package/src/email/brevo/providers/BrevoEmailProvider.ts +4 -4
  614. package/src/email/cloudflare/providers/CloudflareEmailProvider.ts +6 -6
  615. package/src/email/core/index.ts +7 -2
  616. package/src/email/core/primitives/$email.ts +5 -1
  617. package/src/email/core/providers/LocalEmailProvider.ts +5 -5
  618. package/src/email/smtp/providers/NodemailerEmailProvider.ts +41 -52
  619. package/src/fake/__tests__/FakeProvider.spec.ts +110 -110
  620. package/src/fake/__tests__/keyName.example.ts +21 -21
  621. package/src/fake/__tests__/keyName.spec.ts +41 -41
  622. package/src/fake/__tests__/module.example.ts +8 -8
  623. package/src/fake/providers/FakeProvider.ts +122 -121
  624. package/src/lock/core/__tests__/lock-mutual-exclusion.spec.ts +44 -0
  625. package/src/lock/core/index.ts +1 -0
  626. package/src/lock/core/primitives/$lock.ts +13 -6
  627. package/src/logger/__tests__/CliFormatterProvider.spec.ts +76 -0
  628. package/src/logger/__tests__/Logger.spec.ts +49 -0
  629. package/src/logger/index.ts +25 -18
  630. package/src/logger/providers/CliFormatterProvider.ts +75 -0
  631. package/src/logger/schemas/logEntrySchema.ts +10 -10
  632. package/src/logger/services/Logger.ts +18 -0
  633. package/src/mcp/__tests__/$prompt.spec.ts +21 -23
  634. package/src/mcp/__tests__/$tool.spec.ts +22 -22
  635. package/src/mcp/__tests__/McpServerProvider.spec.ts +82 -11
  636. package/src/mcp/__tests__/StreamableHttpMcpTransport.spec.ts +2 -2
  637. package/src/mcp/__tests__/integration.spec.ts +33 -33
  638. package/src/mcp/primitives/$prompt.ts +11 -9
  639. package/src/mcp/primitives/$tool.ts +27 -86
  640. package/src/mcp/providers/McpServerProvider.ts +55 -0
  641. package/src/mcp/transports/StreamableHttpMcpTransport.ts +7 -7
  642. package/src/orm/__tests__/$repository-tests.ts +133 -27
  643. package/src/orm/__tests__/$repository.spec.ts +23 -0
  644. package/src/orm/__tests__/$transactional-tests.ts +4 -4
  645. package/src/orm/__tests__/ModelBuilder-tests.ts +28 -28
  646. package/src/orm/__tests__/ModelBuilder.spec.ts +124 -106
  647. package/src/orm/__tests__/QueryManager.spec.ts +5 -5
  648. package/src/orm/__tests__/delete-returning-tests.ts +11 -11
  649. package/src/orm/__tests__/deletedAt-tests.ts +3 -3
  650. package/src/orm/__tests__/enums.spec.ts +29 -25
  651. package/src/orm/__tests__/execute-tests.ts +8 -8
  652. package/src/orm/__tests__/fixtures/bigEntitySchema.ts +48 -48
  653. package/src/orm/__tests__/fixtures/userEntitySchema.ts +6 -6
  654. package/src/orm/__tests__/joins-tests.ts +30 -30
  655. package/src/orm/__tests__/organization-tests.ts +105 -3
  656. package/src/orm/__tests__/organization.spec.ts +46 -0
  657. package/src/orm/__tests__/orm-errors.spec.ts +10 -10
  658. package/src/orm/__tests__/orm-next-tests.ts +29 -29
  659. package/src/orm/__tests__/orm-showcase-tests.ts +9 -9
  660. package/src/orm/__tests__/primaryKey.spec.ts +4 -4
  661. package/src/orm/__tests__/query-date-encoding-tests.ts +17 -17
  662. package/src/orm/__tests__/ref-auto-onDelete.spec.ts +14 -14
  663. package/src/orm/__tests__/references.spec.ts +7 -7
  664. package/src/orm/__tests__/security.spec.ts +17 -17
  665. package/src/orm/__tests__/string-operators-tests.ts +5 -5
  666. package/src/orm/__tests__/timestamps-tests.ts +14 -14
  667. package/src/orm/__tests__/validation-tests.ts +5 -5
  668. package/src/orm/core/__tests__/BunSqliteProvider.bun.spec.ts +8 -8
  669. package/src/orm/core/constants/PG_SYMBOLS.ts +13 -1
  670. package/src/orm/core/entities/alephaSequences.ts +8 -8
  671. package/src/orm/core/helpers/pgAttr.ts +4 -4
  672. package/src/orm/core/primitives/$entity.ts +10 -6
  673. package/src/orm/core/providers/DatabaseTypeProvider.ts +46 -53
  674. package/src/orm/core/providers/drivers/BunSqliteProvider.ts +8 -8
  675. package/src/orm/core/providers/drivers/CloudflareD1Provider.ts +3 -5
  676. package/src/orm/core/providers/drivers/NodeSqliteProvider.ts +8 -8
  677. package/src/orm/core/schemas/databaseEnvSchema.ts +4 -4
  678. package/src/orm/core/schemas/insertSchema.ts +14 -18
  679. package/src/orm/core/schemas/legacyIdSchema.ts +2 -2
  680. package/src/orm/core/schemas/updateSchema.ts +10 -16
  681. package/src/orm/core/services/PgRelationManager.ts +2 -2
  682. package/src/orm/core/services/QueryManager.ts +13 -2
  683. package/src/orm/core/services/Repository.ts +88 -33
  684. package/src/orm/core/services/SqliteModelBuilder.ts +38 -45
  685. package/src/orm/postgres/__tests__/BunPostgresProvider.bun.spec.ts +4 -4
  686. package/src/orm/postgres/providers/CloudflareHyperdriveProvider.ts +4 -6
  687. package/src/orm/postgres/schemas/postgresEnvSchema.ts +6 -6
  688. package/src/orm/postgres/services/PostgresModelBuilder.ts +127 -114
  689. package/src/queue/core/__tests__/$consumer.spec.ts +4 -4
  690. package/src/queue/core/__tests__/WorkerProvider.spec.ts +4 -4
  691. package/src/queue/core/__tests__/shared.ts +6 -6
  692. package/src/queue/core/primitives/$consumer.ts +5 -5
  693. package/src/queue/core/primitives/$queue.ts +44 -61
  694. package/src/queue/core/providers/CloudflareQueueProvider.ts +6 -0
  695. package/src/queue/core/providers/WorkerProvider.ts +17 -14
  696. package/src/queue/redis/providers/RedisQueueProvider.ts +3 -3
  697. package/src/react/core/__tests__/ErrorBoundary.browser.spec.tsx +92 -0
  698. package/src/react/core/__tests__/Router.spec.tsx +4 -4
  699. package/src/react/core/__tests__/useComputed.browser.spec.tsx +192 -0
  700. package/src/react/core/__tests__/useQuery.browser.spec.tsx +48 -0
  701. package/src/react/core/__tests__/useSelector.browser.spec.tsx +105 -0
  702. package/src/react/core/__tests__/useStore.browser.spec.tsx +113 -0
  703. package/src/react/core/components/ErrorBoundary.tsx +42 -0
  704. package/src/react/core/hooks/useAction.ts +56 -19
  705. package/src/react/core/hooks/useComputed.ts +91 -0
  706. package/src/react/core/hooks/useSelector.ts +67 -0
  707. package/src/react/core/hooks/useStore.ts +36 -17
  708. package/src/react/core/index.ts +3 -0
  709. package/src/react/core/utils/shallowEqual.ts +36 -0
  710. package/src/react/form/__tests__/FormModel-submit-loading.spec.ts +71 -0
  711. package/src/react/form/__tests__/form-submitting-reactive.browser.spec.tsx +96 -0
  712. package/src/react/form/__tests__/useForm.browser.spec.tsx +54 -54
  713. package/src/react/form/errors/FormValidationError.ts +0 -2
  714. package/src/react/form/hooks/useForm.ts +19 -4
  715. package/src/react/form/hooks/useFormQuerySync.ts +0 -0
  716. package/src/react/form/services/FormModel.ts +124 -86
  717. package/src/react/form/services/parseField.ts +66 -27
  718. package/src/react/i18n/__tests__/I18nProvider.spec.ts +89 -0
  719. package/src/react/i18n/__tests__/Localize.spec.tsx +1 -1
  720. package/src/react/i18n/__tests__/locale-routing.spec.ts +107 -0
  721. package/src/react/i18n/providers/I18nProvider.ts +173 -14
  722. package/src/react/router/__tests__/$page.browser.spec.tsx +19 -19
  723. package/src/react/router/__tests__/$page.spec.tsx +21 -21
  724. package/src/react/router/__tests__/ReactBrowserProvider.browser.spec.ts +87 -1
  725. package/src/react/router/__tests__/RouterLocaleProvider.spec.ts +127 -0
  726. package/src/react/router/atoms/ssrManifestAtom.ts +16 -16
  727. package/src/react/router/components/NestedView.tsx +11 -3
  728. package/src/react/router/hooks/useQueryParams.ts +1 -1
  729. package/src/react/router/index.browser.ts +4 -0
  730. package/src/react/router/index.shared.ts +1 -0
  731. package/src/react/router/index.ts +9 -0
  732. package/src/react/router/primitives/$page.ts +2 -2
  733. package/src/react/router/providers/ReactBrowserProvider.ts +64 -13
  734. package/src/react/router/providers/ReactBrowserRouterProvider.ts +15 -1
  735. package/src/react/router/providers/ReactPageProvider.ts +38 -13
  736. package/src/react/router/providers/ReactServerProvider.ts +105 -16
  737. package/src/react/router/providers/RootComponentsProvider.ts +13 -0
  738. package/src/react/router/providers/RouterLocaleProvider.ts +125 -0
  739. package/src/react/router/providers/__tests__/RootComponentsProvider.spec.ts +15 -0
  740. package/src/react/router/providers/__tests__/rootComponents.ssr.browser.spec.tsx +67 -0
  741. package/src/react/sitemap/__tests__/$sitemap.spec.ts +131 -0
  742. package/src/react/sitemap/index.browser.ts +21 -0
  743. package/src/react/sitemap/index.ts +25 -0
  744. package/src/react/sitemap/primitives/$sitemap.browser.ts +26 -0
  745. package/src/react/sitemap/primitives/$sitemap.ts +196 -0
  746. package/src/react/ui/atoms/uiAtom.ts +6 -6
  747. package/src/react/ui/atoms/uiThemeListAtom.ts +7 -7
  748. package/src/react/ui/hooks/useColorMode.ts +11 -4
  749. package/src/react/ui/services/SchemaControl.ts +4 -4
  750. package/src/redis/providers/BunRedisProvider.ts +19 -11
  751. package/src/redis/providers/NodeRedisProvider.ts +3 -3
  752. package/src/scheduler/primitives/$scheduler.ts +21 -8
  753. package/src/security/__tests__/assertRealmScope.spec.ts +29 -0
  754. package/src/security/atoms/currentTenantAtom.ts +6 -6
  755. package/src/security/atoms/currentUserAtom.ts +2 -2
  756. package/src/security/primitives/$issuer.ts +24 -2
  757. package/src/security/providers/JwtProvider.ts +100 -0
  758. package/src/security/providers/SecurityProvider.ts +43 -2
  759. package/src/security/schemas/permissionSchema.ts +19 -19
  760. package/src/security/schemas/roleSchema.ts +22 -28
  761. package/src/security/schemas/userAccountInfoSchema.ts +47 -37
  762. package/src/server/auth/__tests__/appleClientSecret.spec.ts +34 -0
  763. package/src/server/auth/__tests__/federationRedirectReplay.spec.ts +44 -0
  764. package/src/server/auth/helpers/appleClientSecret.ts +24 -0
  765. package/src/server/auth/helpers/jtiReplayGuard.ts +41 -0
  766. package/src/server/auth/helpers/safeRedirectPath.ts +19 -0
  767. package/src/server/auth/index.ts +1 -0
  768. package/src/server/auth/primitives/$auth.ts +6 -6
  769. package/src/server/auth/primitives/$authApple.ts +10 -10
  770. package/src/server/auth/primitives/$authFacebook.ts +10 -10
  771. package/src/server/auth/primitives/$authFranceConnect.ts +10 -10
  772. package/src/server/auth/primitives/$authGithub.ts +10 -10
  773. package/src/server/auth/primitives/$authGoogle.ts +10 -10
  774. package/src/server/auth/primitives/$authMicrosoft.ts +14 -14
  775. package/src/server/auth/providers/ServerAuthProvider.ts +67 -52
  776. package/src/server/auth/schemas/authenticationProviderSchema.ts +9 -12
  777. package/src/server/auth/schemas/tokenResponseSchema.ts +2 -2
  778. package/src/server/auth/schemas/tokensSchema.ts +16 -16
  779. package/src/server/auth/schemas/userinfoResponseSchema.ts +3 -3
  780. package/src/server/cookies/__tests__/AtomCookieBinding.spec.ts +80 -0
  781. package/src/server/cookies/__tests__/AtomCookiePersistence.browser.spec.ts +169 -0
  782. package/src/server/cookies/__tests__/AtomCookiePersistence.spec.ts +294 -0
  783. package/src/server/cookies/__tests__/ServerCookiesProvider.spec.ts +82 -12
  784. package/src/server/cookies/index.browser.ts +4 -1
  785. package/src/server/cookies/index.ts +8 -1
  786. package/src/server/cookies/primitives/$cookie.browser.ts +1 -1
  787. package/src/server/cookies/primitives/$cookie.ts +16 -0
  788. package/src/server/cookies/providers/AtomCookiePersistence.browser.ts +133 -0
  789. package/src/server/cookies/providers/AtomCookiePersistence.ts +148 -0
  790. package/src/server/cookies/providers/ServerCookiesProvider.ts +32 -4
  791. package/src/server/cookies/services/CookieParser.ts +6 -1
  792. package/src/server/core/__tests__/$action.spec.ts +13 -13
  793. package/src/server/core/__tests__/$middleware.spec.ts +10 -10
  794. package/src/server/core/__tests__/$route.spec.ts +9 -9
  795. package/src/server/core/__tests__/$sse.spec.ts +26 -26
  796. package/src/server/core/__tests__/BunHttpServerProvider.bun.spec.ts +6 -6
  797. package/src/server/core/__tests__/HttpClient.spec.ts +2 -2
  798. package/src/server/core/__tests__/NodeHttpServerProvider.spec.ts +15 -3
  799. package/src/server/core/__tests__/ServerBodyParserProvider.spec.ts +14 -14
  800. package/src/server/core/__tests__/ServerMultipartProvider.spec.ts +33 -33
  801. package/src/server/core/__tests__/ServerRouterProvider-errorHandler.spec.ts +5 -1
  802. package/src/server/core/__tests__/ServerRouterProvider-getRoutes.spec.ts +25 -25
  803. package/src/server/core/__tests__/ServerRouterProvider-serializationError.spec.ts +9 -5
  804. package/src/server/core/__tests__/ServerRouterProvider-validationError.spec.ts +56 -24
  805. package/src/server/core/errors/ValidationError.ts +6 -3
  806. package/src/server/core/helpers/isMultipart.ts +2 -1
  807. package/src/server/core/index.ts +5 -2
  808. package/src/server/core/interfaces/ServerRequest.ts +14 -14
  809. package/src/server/core/primitives/$action.ts +26 -36
  810. package/src/server/core/primitives/$route.ts +27 -0
  811. package/src/server/core/primitives/$sse.ts +3 -3
  812. package/src/server/core/providers/BunHttpServerProvider.ts +8 -9
  813. package/src/server/core/providers/NodeHttpServerProvider.ts +8 -9
  814. package/src/server/core/providers/ServerBodyParserProvider.ts +20 -12
  815. package/src/server/core/providers/ServerCompressProvider.ts +9 -10
  816. package/src/server/core/providers/ServerHelmetProvider.ts +26 -27
  817. package/src/server/core/providers/ServerMultipartProvider.ts +19 -19
  818. package/src/server/core/providers/ServerRouterProvider.ts +44 -15
  819. package/src/server/core/schemas/errorSchema.ts +20 -25
  820. package/src/server/core/schemas/okSchema.ts +9 -14
  821. package/src/server/core/services/HttpClient.ts +13 -1
  822. package/src/server/core/services/ServerRequestParser.ts +6 -6
  823. package/src/server/cors/providers/ServerCorsProvider.ts +26 -28
  824. package/src/server/health/schemas/healthSchema.ts +6 -6
  825. package/src/server/links/__tests__/$remote.spec.ts +3 -3
  826. package/src/server/links/__tests__/BatchEndpoint.spec.ts +9 -9
  827. package/src/server/links/__tests__/LinkProvider.spec.ts +9 -9
  828. package/src/server/links/__tests__/ServerLinksProvider.spec.ts +23 -23
  829. package/src/server/links/__tests__/fixtures/CrudApp.ts +21 -21
  830. package/src/server/links/atoms/apiLinksAtom.ts +2 -2
  831. package/src/server/links/atoms/linkOptionsAtom.ts +6 -6
  832. package/src/server/links/primitives/$remote.ts +3 -3
  833. package/src/server/links/providers/LinkProvider.ts +3 -3
  834. package/src/server/links/providers/ServerLinksProvider.ts +20 -20
  835. package/src/server/links/schemas/apiLinksResponseSchema.ts +23 -23
  836. package/src/server/proxy/__tests__/$proxy.spec.ts +9 -9
  837. package/src/server/proxy/providers/ServerProxyProvider.ts +5 -0
  838. package/src/server/rate-limit/providers/ServerRateLimitProvider.ts +18 -20
  839. package/src/server/swagger/__tests__/$swagger.spec.ts +91 -94
  840. package/src/server/swagger/__tests__/ui.spec.ts +3 -3
  841. package/src/server/swagger/providers/ServerSwaggerProvider.ts +66 -43
  842. package/src/system/__tests__/NodeShellProvider.spec.ts +46 -0
  843. package/src/system/providers/NodeShellProvider.ts +4 -1
  844. package/src/topic/core/__tests__/$subscriber.spec.ts +4 -4
  845. package/src/topic/core/__tests__/shared.ts +8 -8
  846. package/src/topic/core/primitives/$subscriber.ts +5 -5
  847. package/src/topic/core/primitives/$topic.ts +14 -14
  848. package/src/topic/redis/providers/RedisTopicProvider.ts +3 -3
  849. package/dist/container/core/index.d.ts +0 -236
  850. package/dist/container/core/index.d.ts.map +0 -1
  851. package/dist/container/core/index.js +0 -231
  852. package/dist/container/core/index.js.map +0 -1
  853. package/dist/container/core/index.workerd.js +0 -192
  854. package/dist/container/core/index.workerd.js.map +0 -1
  855. package/src/cli/core/tasks/BuildSitemapTask.ts +0 -130
  856. package/src/command/helpers/PrettyAsker.ts +0 -256
  857. package/src/command/helpers/PrettyPrint.ts +0 -332
  858. package/src/container/core/__tests__/$container.spec.ts +0 -83
  859. package/src/container/core/index.ts +0 -50
  860. package/src/container/core/index.workerd.ts +0 -53
  861. package/src/container/core/interfaces/ContainerOptions.ts +0 -69
  862. package/src/container/core/primitives/$container.ts +0 -100
  863. package/src/container/core/providers/CloudflareContainerProvider.ts +0 -70
  864. package/src/container/core/providers/ContainerProvider.ts +0 -92
  865. package/src/container/core/providers/MockContainerProvider.ts +0 -62
  866. package/src/container/core/providers/NodeContainerProvider.ts +0 -53
  867. package/src/core/__tests__/jsonSchemaToTypeBox.spec.ts +0 -771
  868. package/src/core/helpers/jsonSchemaToTypeBox.ts +0 -359
  869. /package/dist/orm/core/{chunk-B4FMCO8f.js → rolldown-runtime-B4FMCO8f.js} +0 -0
@@ -1,9 +1,6 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- import { Type } from "typebox";
3
- import Format from "typebox/format";
4
- import { Settings } from "typebox/system";
5
- import { Compile } from "typebox/compile";
6
- import * as Value from "typebox/value";
2
+ import { z as z$1 } from "zod";
3
+ import enLocale from "zod/v4/locales/en.js";
7
4
  import { createMiddleware as createMiddleware$1 } from "alepha";
8
5
  //#region ../../src/core/constants/KIND.ts
9
6
  /**
@@ -61,6 +58,316 @@ var TooLateSubstitutionError = class extends AlephaError {
61
58
  }
62
59
  };
63
60
  //#endregion
61
+ //#region ../../src/core/providers/zodAugment.ts
62
+ const alias = (ctor, name, target) => {
63
+ const proto = ctor?.prototype;
64
+ if (!proto || Object.getOwnPropertyDescriptor(proto, name)) return;
65
+ Object.defineProperty(proto, name, {
66
+ configurable: true,
67
+ get() {
68
+ return this[target];
69
+ }
70
+ });
71
+ };
72
+ alias(z$1.ZodObject, "properties", "shape");
73
+ alias(z$1.ZodArray, "items", "element");
74
+ alias(z$1.ZodUnion, "anyOf", "options");
75
+ {
76
+ const proto = z$1.ZodTuple?.prototype;
77
+ if (proto && !Object.getOwnPropertyDescriptor(proto, "items")) Object.defineProperty(proto, "items", {
78
+ configurable: true,
79
+ get() {
80
+ return this?._zod?.def?.items ?? [];
81
+ }
82
+ });
83
+ }
84
+ //#endregion
85
+ //#region ../../src/core/providers/ZodProvider.ts
86
+ z$1.config(enLocale());
87
+ /** Defaults mirroring TypeProvider's static length caps. */
88
+ const Z_LIMITS = {
89
+ short: 64,
90
+ regular: 255,
91
+ long: 1024,
92
+ rich: 65535,
93
+ arrayMaxItems: 1e3
94
+ };
95
+ /** Attach metadata + default without changing the schema's inferred type. */
96
+ const meta = (schema, options) => {
97
+ if (!options) return schema;
98
+ const { default: def, ...rest } = options;
99
+ let s = schema;
100
+ if (def !== void 0) s = s.default(def);
101
+ if (Object.keys(rest).length > 0) s = s.meta(rest);
102
+ return s;
103
+ };
104
+ const applyString = (base, o) => {
105
+ let s = base;
106
+ if (o?.minLength != null) s = s.min(o.minLength);
107
+ if (o?.maxLength != null) s = s.max(o.maxLength);
108
+ if (o?.pattern) s = s.regex(typeof o.pattern === "string" ? new RegExp(o.pattern) : o.pattern);
109
+ return s;
110
+ };
111
+ /** zod's native `.format` getter (uuid/email/safeint/…), guarded. */
112
+ const nativeFmt = (s) => {
113
+ try {
114
+ return s?.format ?? void 0;
115
+ } catch {
116
+ return;
117
+ }
118
+ };
119
+ /**
120
+ * Read the JSON-Schema-style format tag off a schema (drives ORM columns).
121
+ * Prefers our normalized `.meta({ format })` (typebox vocab: `date-time`,
122
+ * `int64`, `binary`, …) and falls back to zod's native `.format`.
123
+ */
124
+ const fmt = (s) => {
125
+ try {
126
+ return s?.meta?.()?.format ?? nativeFmt(s);
127
+ } catch {
128
+ return;
129
+ }
130
+ };
131
+ /** zod's internal type discriminator (`string` | `number` | …), wrapping-safe. */
132
+ const defType = (s) => s?._zod?.def?.type;
133
+ /** Tag a string-format schema with its JSON-Schema `format` (stays a real `ZodString`). */
134
+ const strFmt = (base, format) => meta(base, { format });
135
+ const z = {
136
+ /**
137
+ * Native zod coercion namespace (`z.coerce.number()`, `z.coerce.boolean()`…).
138
+ * Used at the HTTP/string boundary (query, headers, env) where everything
139
+ * arrives as a string; request bodies and the ORM stay strict (no coercion).
140
+ */
141
+ coerce: z$1.coerce,
142
+ object: z$1.object,
143
+ array: z$1.array,
144
+ record: z$1.record,
145
+ tuple: z$1.tuple,
146
+ union: z$1.union,
147
+ string: z$1.string,
148
+ number: z$1.number,
149
+ boolean: z$1.boolean,
150
+ null: z$1.null,
151
+ any: z$1.any,
152
+ void: z$1.void,
153
+ undefined: z$1.undefined,
154
+ literal: z$1.literal,
155
+ /** Alias for `zod.literal` (legacy `t.const`). */
156
+ const: z$1.literal,
157
+ enum: z$1.enum,
158
+ /** Integer — native `z.int()` (format `safeint`, drives PG INT column). */
159
+ integer: z$1.int,
160
+ /** Free-form JSON object (`Record<string, any>`). */
161
+ json: () => z$1.record(z$1.string(), z$1.any()),
162
+ text: (options = {}) => {
163
+ const { size = "regular", trim = true, lowercase = false, maxLength, ...rest } = options;
164
+ const max = maxLength ?? Z_LIMITS[size] ?? Z_LIMITS.regular;
165
+ let s = z$1.string().max(max);
166
+ if (trim) s = s.trim();
167
+ if (lowercase) s = s.toLowerCase();
168
+ return meta(applyString(s, rest), {
169
+ ...rest,
170
+ maxLength: max,
171
+ "~options": {
172
+ trim,
173
+ lowercase
174
+ }
175
+ });
176
+ },
177
+ shortText: (options = {}) => z.text({
178
+ ...options,
179
+ size: "short"
180
+ }),
181
+ longText: (options = {}) => z.text({
182
+ ...options,
183
+ size: "long"
184
+ }),
185
+ richText: (options = {}) => z.text({
186
+ ...options,
187
+ size: "rich"
188
+ }),
189
+ email: () => strFmt(z$1.email(), "email"),
190
+ uuid: () => strFmt(z$1.guid(), "uuid"),
191
+ url: () => strFmt(z$1.url(), "url"),
192
+ datetime: () => strFmt(z$1.iso.datetime(), "date-time"),
193
+ date: () => strFmt(z$1.iso.date(), "date"),
194
+ time: () => strFmt(z$1.iso.time(), "time"),
195
+ /** bigint as a validated string (no codec). */
196
+ bigint: () => strFmt(z$1.string().regex(/^-?\d+$/), "bigint"),
197
+ binary: () => strFmt(z$1.string(), "binary"),
198
+ duration: () => strFmt(z$1.string(), "duration"),
199
+ e164: () => z.text({ pattern: "^\\+[1-9]\\d{1,14}$" }),
200
+ bcp47: () => z.text({ pattern: "^[a-z]{2,3}(?:-[A-Z]{2})?$" }),
201
+ constantCase: () => z.text({ pattern: "^[A-Z_-]+$" }),
202
+ int32: () => z$1.int().min(-2147483648).max(2147483647),
203
+ int64: () => z$1.int().min(-9007199254740991).max(9007199254740991).meta({ format: "int64" }),
204
+ file: (options) => z$1.any().meta({
205
+ format: "binary",
206
+ ...options
207
+ }),
208
+ stream: () => z$1.any().meta({ format: "stream" }),
209
+ valueLabel: () => z$1.object({
210
+ value: z.constantCase(),
211
+ label: z.text(),
212
+ description: z.longText().optional()
213
+ }),
214
+ /** Pagination wrapper, mirrors `pageSchema(item)`. */
215
+ page: (item) => z$1.object({
216
+ content: z$1.array(item),
217
+ page: z$1.object({
218
+ number: z$1.int(),
219
+ size: z$1.int(),
220
+ offset: z$1.int(),
221
+ numberOfElements: z$1.int(),
222
+ totalElements: z$1.int().optional(),
223
+ totalPages: z$1.int().optional(),
224
+ isEmpty: z$1.boolean(),
225
+ isFirst: z$1.boolean(),
226
+ isLast: z$1.boolean()
227
+ })
228
+ }),
229
+ /** Export a schema to JSON Schema (OpenAPI / form generation). */
230
+ toJSONSchema: z$1.toJSONSchema,
231
+ /** Runtime type guards (`z.schema.*`) — schema introspection for ORM + forms. */
232
+ schema: {
233
+ isOptional: (s) => s instanceof z$1.ZodOptional,
234
+ isDefault: (s) => s instanceof z$1.ZodDefault,
235
+ isObject: (s) => s instanceof z$1.ZodObject,
236
+ isString: (s) => defType(s) === "string",
237
+ isNumber: (s) => defType(s) === "number",
238
+ isBoolean: (s) => s instanceof z$1.ZodBoolean,
239
+ isArray: (s) => s instanceof z$1.ZodArray,
240
+ isUnion: (s) => s instanceof z$1.ZodUnion,
241
+ isNull: (s) => s instanceof z$1.ZodNull,
242
+ isRecord: (s) => s instanceof z$1.ZodRecord,
243
+ isEnum: (s) => s instanceof z$1.ZodEnum,
244
+ isLiteral: (s) => s instanceof z$1.ZodLiteral,
245
+ isAny: (s) => s instanceof z$1.ZodAny,
246
+ isNullable: (s) => s instanceof z$1.ZodNullable,
247
+ isInteger: (s) => defType(s) === "number" && nativeFmt(s) === "safeint",
248
+ isText: (s) => defType(s) === "string" && !fmt(s),
249
+ isDateTime: (s) => fmt(s) === "date-time",
250
+ isDate: (s) => fmt(s) === "date",
251
+ isTime: (s) => fmt(s) === "time",
252
+ isBigInt: (s) => fmt(s) === "bigint",
253
+ isUuid: (s) => fmt(s) === "uuid",
254
+ isEmail: (s) => fmt(s) === "email",
255
+ isUrl: (s) => fmt(s) === "url",
256
+ isBinary: (s) => fmt(s) === "binary",
257
+ isUUID: (s) => fmt(s) === "uuid",
258
+ isScalar: (s) => s instanceof z$1.ZodString || s instanceof z$1.ZodNumber || s instanceof z$1.ZodBoolean || s instanceof z$1.ZodNull || s instanceof z$1.ZodLiteral || s instanceof z$1.ZodEnum || s instanceof z$1.ZodDate,
259
+ isSchema: (s) => s instanceof z$1.ZodType,
260
+ isTuple: (s) => s instanceof z$1.ZodTuple,
261
+ isUndefined: (s) => s instanceof z$1.ZodUndefined,
262
+ isUnsafe: (s) => s instanceof z$1.ZodAny || s instanceof z$1.ZodUnknown,
263
+ isVoid: (s) => s instanceof z$1.ZodVoid,
264
+ format: (s) => fmt(s),
265
+ /** The string values of a `ZodEnum` (typebox-compat for `value.enum`). */
266
+ enumValues: (s) => {
267
+ const opts = s?.options;
268
+ if (Array.isArray(opts)) return opts;
269
+ const entries = s?._zod?.def?.entries;
270
+ return entries ? Object.values(entries) : [];
271
+ },
272
+ /** Peel optional / nullable / default wrappers to the inner schema. */
273
+ unwrap: (s) => {
274
+ let cur = s;
275
+ while (cur instanceof z$1.ZodOptional || cur instanceof z$1.ZodNullable || cur instanceof z$1.ZodDefault) cur = typeof cur.unwrap === "function" ? cur.unwrap() : cur?._zod?.def?.innerType;
276
+ return cur;
277
+ },
278
+ /**
279
+ * Read a schema's default value (peeling optional/nullable wrappers), or
280
+ * `undefined` if there is none. In zod, defaults are a `ZodDefault` wrapper
281
+ * (not a `default` data property as in typebox), so `"default" in schema`
282
+ * is NOT a valid test — every schema has a `.default()` method.
283
+ */
284
+ getDefault: (s) => {
285
+ if (s && Object.hasOwn(s, "default")) return s.default;
286
+ let cur = s;
287
+ while (cur) {
288
+ if (cur instanceof z$1.ZodDefault) {
289
+ const dv = cur?._zod?.def?.defaultValue;
290
+ return typeof dv === "function" ? dv() : dv;
291
+ }
292
+ if (cur instanceof z$1.ZodOptional || cur instanceof z$1.ZodNullable) {
293
+ cur = cur.unwrap();
294
+ continue;
295
+ }
296
+ return;
297
+ }
298
+ },
299
+ /** typebox-compat: the object's required (non-optional) field names. */
300
+ requiredKeys: (s) => {
301
+ const shape = s?.shape;
302
+ return shape ? Object.keys(shape).filter((k) => !(shape[k] instanceof z$1.ZodOptional)) : [];
303
+ }
304
+ }
305
+ };
306
+ //#endregion
307
+ //#region ../../src/core/providers/TypeProvider.ts
308
+ /**
309
+ * TypeProvider — now a thin compatibility shim over `z` (zod 4).
310
+ *
311
+ * typebox is gone. `t` is just `z`, and the legacy `T*` type names are
312
+ * re-aliased to their zod equivalents so existing call-sites keep compiling
313
+ * while they are migrated to `z` / `Infer`.
314
+ */
315
+ /** Raw zod namespace (legacy `Type` escape hatch). */
316
+ const Type = z$1;
317
+ /** Legacy `TypeProvider` — kept for its static config knobs. */
318
+ var TypeProvider = class {
319
+ static DEFAULT_STRING_MAX_LENGTH = 255;
320
+ static DEFAULT_SHORT_STRING_MAX_LENGTH = 64;
321
+ static DEFAULT_LONG_STRING_MAX_LENGTH = 1024;
322
+ static DEFAULT_RICH_STRING_MAX_LENGTH = 65535;
323
+ static DEFAULT_ARRAY_MAX_ITEMS = 1e3;
324
+ static translateError = (error, _locale) => error.message ?? "";
325
+ static setLocale = (_locale) => {};
326
+ static isValidBigInt = (value) => typeof value === "number" ? Number.isInteger(value) : /^-?\d+$/.test(value.trim());
327
+ };
328
+ //#endregion
329
+ //#region ../../src/core/helpers/coerceStrings.ts
330
+ /**
331
+ * Coerce a single string value coming from a string-only boundary (HTTP query,
332
+ * HTTP headers, environment variables) to the JS type its schema declares.
333
+ *
334
+ * This is the zod-standard `z.coerce` behavior applied only at the edges where
335
+ * inputs are inherently strings — request bodies and the ORM stay strict. A
336
+ * value that cannot be coerced is returned unchanged so the subsequent
337
+ * validation produces a proper rejection. Arrays coerce element-wise.
338
+ */
339
+ const coerceScalar = (schema, value) => {
340
+ const base = z.schema.unwrap(schema);
341
+ if (z.schema.isArray(base) && Array.isArray(value)) {
342
+ const element = base.element;
343
+ return value.map((v) => coerceScalar(element, v));
344
+ }
345
+ if (z.schema.isString(base) && (typeof value === "number" || typeof value === "boolean")) return String(value);
346
+ if (typeof value !== "string") return value;
347
+ if (z.schema.isInteger(base) || z.schema.isNumber(base)) {
348
+ const n = Number(value);
349
+ return value.trim() !== "" && !Number.isNaN(n) ? n : value;
350
+ }
351
+ if (z.schema.isBoolean(base)) {
352
+ if (value === "true") return true;
353
+ if (value === "false") return false;
354
+ return value;
355
+ }
356
+ return value;
357
+ };
358
+ /**
359
+ * Coerce each declared field of an object against its object schema. Used to
360
+ * normalize string-only boundary maps (env vars, query objects) before strict
361
+ * validation. Undeclared keys are passed through untouched.
362
+ */
363
+ const coerceObject = (schema, value) => {
364
+ const shape = schema?.shape;
365
+ if (!shape) return value;
366
+ const out = { ...value };
367
+ for (const key of Object.keys(shape)) if (out[key] != null) out[key] = coerceScalar(shape[key], out[key]);
368
+ return out;
369
+ };
370
+ //#endregion
64
371
  //#region ../../src/core/errors/MissingContextError.ts
65
372
  var MissingContextError = class extends AlephaError {
66
373
  name = "MissingContextError";
@@ -375,6 +682,24 @@ var AlsProvider = class AlsProvider {
375
682
  current = current[ALS_PARENT];
376
683
  }
377
684
  }
685
+ /**
686
+ * Return the raw ALS layer object that owns `key`, walking from the
687
+ * current layer up through parent forks — the same resolution order as
688
+ * the default-scope branch of {@link get}. Returns `undefined` when no
689
+ * active ALS layer (current or any ancestor) has the key.
690
+ *
691
+ * Used by `StateManager.register()` to decode a value in place, in
692
+ * whichever fork layer it physically lives, instead of flattening
693
+ * fork-scoped state into the app-level store.
694
+ */
695
+ getLayer(key) {
696
+ if (!this.als) return;
697
+ let current = this.als.getStore();
698
+ while (current) {
699
+ if (key in current) return current;
700
+ current = current[ALS_PARENT];
701
+ }
702
+ }
378
703
  has(key) {
379
704
  if (!this.als) return false;
380
705
  const store = this.als.getStore();
@@ -517,458 +842,6 @@ var HookPrimitive = class extends Primitive {
517
842
  };
518
843
  $hook[KIND] = HookPrimitive;
519
844
  //#endregion
520
- //#region ../../src/core/helpers/FileLike.ts
521
- const isTypeFile = (value) => {
522
- return value && typeof value === "object" && "format" in value && value.format === "binary";
523
- };
524
- const isFileLike = (value) => {
525
- return !!value && typeof value === "object" && !Array.isArray(value) && typeof value.name === "string" && typeof value.type === "string" && typeof value.size === "number" && typeof value.stream.bind(value) === "function";
526
- };
527
- //#endregion
528
- //#region ../../src/core/providers/TypeProvider.ts
529
- Settings.Set({ correctiveParse: true });
530
- var TypeGuard = class {
531
- isBigInt = (value) => Type.IsString(value) && "format" in value && value.format === "bigint";
532
- isUUID = (value) => Type.IsString(value) && "format" in value && value.format === "uuid";
533
- isObject = Type.IsObject;
534
- isNumber = Type.IsNumber;
535
- isString = Type.IsString;
536
- isBoolean = Type.IsBoolean;
537
- isAny = Type.IsAny;
538
- isArray = Type.IsArray;
539
- isOptional = Type.IsOptional;
540
- isUnion = Type.IsUnion;
541
- isInteger = Type.IsInteger;
542
- isNull = Type.IsNull;
543
- isUndefined = Type.IsUndefined;
544
- isUnsafe = Type.IsUnsafe;
545
- isRecord = Type.IsRecord;
546
- isTuple = Type.IsTuple;
547
- isVoid = Type.IsVoid;
548
- isLiteral = Type.IsLiteral;
549
- isSchema = Type.IsSchema;
550
- isScalar = (schema) => this.isString(schema) || this.isNumber(schema) || this.isInteger(schema) || this.isBoolean(schema);
551
- isFile = isTypeFile;
552
- isDateTime = (schema) => {
553
- return t.schema.isString(schema) && schema.format === "date-time";
554
- };
555
- isDate = (schema) => {
556
- return t.schema.isString(schema) && schema.format === "date";
557
- };
558
- isTime = (schema) => {
559
- return t.schema.isString(schema) && schema.format === "time";
560
- };
561
- isDuration = (schema) => {
562
- return t.schema.isString(schema) && schema.format === "duration";
563
- };
564
- };
565
- var TypeProvider = class TypeProvider {
566
- static format = Format;
567
- static {
568
- Format.Set("bigint", (value) => TypeProvider.isValidBigInt(value));
569
- }
570
- static translateError(error, _locale) {
571
- return error.cause.message;
572
- }
573
- static setLocale(_locale) {}
574
- static isValidBigInt(value) {
575
- if (typeof value === "number") return Number.isInteger(value);
576
- if (!value.trim()) return false;
577
- if (!/^-?\d+$/.test(value)) return false;
578
- try {
579
- BigInt(value);
580
- return true;
581
- } catch {
582
- return false;
583
- }
584
- }
585
- /**
586
- * Default maximum length for strings.
587
- *
588
- * It can be set to a larger value:
589
- * ```ts
590
- * TypeProvider.DEFAULT_STRING_MAX_LENGTH = 1000000;
591
- * TypeProvider.DEFAULT_STRING_MAX_LENGTH = undefined; // no limit (not recommended)
592
- * ```
593
- */
594
- static DEFAULT_STRING_MAX_LENGTH = 255;
595
- /**
596
- * Maximum length for short strings, such as names or titles.
597
- */
598
- static DEFAULT_SHORT_STRING_MAX_LENGTH = 64;
599
- /**
600
- * Maximum length for long strings, such as descriptions or comments.
601
- * It can be overridden in the string options.
602
- *
603
- * It can be set to a larger value:
604
- * ```ts
605
- * TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH = 2048;
606
- * ```
607
- */
608
- static DEFAULT_LONG_STRING_MAX_LENGTH = 1024;
609
- /**
610
- * Maximum length for rich strings, such as HTML or Markdown.
611
- * This is a large value to accommodate rich text content.
612
- * > It's also the maximum length of PG's TEXT type.
613
- *
614
- * It can be overridden in the string options.
615
- *
616
- * It can be set to a larger value:
617
- * ```ts
618
- * TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH = 1000000;
619
- * ```
620
- */
621
- static DEFAULT_RICH_STRING_MAX_LENGTH = 65535;
622
- /**
623
- * Maximum number of items in an array.
624
- * This is a default value to prevent excessive memory usage.
625
- * It can be overridden in the array options.
626
- */
627
- static DEFAULT_ARRAY_MAX_ITEMS = 1e3;
628
- raw = Type;
629
- any = Type.Any;
630
- void = Type.Void;
631
- undefined = Type.Undefined;
632
- record = Type.Record;
633
- union = Type.Union;
634
- tuple = Type.Tuple;
635
- null = Type.Null;
636
- const = Type.Literal;
637
- options = Type.Options;
638
- /**
639
- * Type guards to check the type of schema.
640
- * This is not a runtime type check, but a compile-time type guard.
641
- *
642
- * @example
643
- * ```ts
644
- * if (t.schema.isString(schema)) {
645
- * // schema is TString
646
- * }
647
- * ```
648
- */
649
- schema = new TypeGuard();
650
- extend(schema, properties, options) {
651
- return Type.Interface(Array.isArray(schema) ? schema : [schema], properties, {
652
- additionalProperties: false,
653
- ...options
654
- });
655
- }
656
- pick(schema, keys, options) {
657
- return Type.Pick(schema, keys, {
658
- additionalProperties: false,
659
- ...options
660
- });
661
- }
662
- omit(schema, keys, options) {
663
- return Type.Omit(schema, keys, {
664
- additionalProperties: false,
665
- ...options
666
- });
667
- }
668
- partial(schema, options) {
669
- return Type.Partial(schema, {
670
- additionalProperties: false,
671
- ...options
672
- });
673
- }
674
- /**
675
- * Create a schema for an object.
676
- * By default, additional properties are not allowed.
677
- *
678
- * @example
679
- * ```ts
680
- * const userSchema = t.object({
681
- * id: t.integer(),
682
- * name: t.string(),
683
- * });
684
- * ```
685
- */
686
- object(properties, options) {
687
- return Type.Object(properties, {
688
- additionalProperties: false,
689
- ...options
690
- });
691
- }
692
- /**
693
- * Create a schema for an array.
694
- * By default, the maximum number of items is limited to prevent excessive memory usage.
695
- *
696
- * @see TypeProvider.DEFAULT_ARRAY_MAX_ITEMS
697
- */
698
- array(schema, options) {
699
- return Type.Array(schema, {
700
- maxItems: TypeProvider.DEFAULT_ARRAY_MAX_ITEMS,
701
- ...options
702
- });
703
- }
704
- /**
705
- * Create a schema for a string.
706
- * For db or input fields, consider using `t.text()` instead, which has length limits.
707
- *
708
- * If you need a string with specific format (e.g. email, uuid), consider using the corresponding method (e.g. `t.email()`, `t.uuid()`).
709
- */
710
- string(options = {}) {
711
- return Type.String({ ...options });
712
- }
713
- /**
714
- * Create a schema for a string with length limits.
715
- * For internal strings without length limits, consider using `t.string()` instead.
716
- *
717
- * Default size is "regular", which has a max length of 255 characters.
718
- */
719
- text(options = {}) {
720
- const { size, ...rest } = options;
721
- const maxLength = size === "short" ? TypeProvider.DEFAULT_SHORT_STRING_MAX_LENGTH : size === "long" ? TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH : size === "rich" ? TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH : TypeProvider.DEFAULT_STRING_MAX_LENGTH;
722
- return Type.String({
723
- maxLength,
724
- "~options": {
725
- trim: options.trim ?? true,
726
- lowercase: options.lowercase ?? false
727
- },
728
- ...rest
729
- });
730
- }
731
- /**
732
- * Create a schema for a JSON object.
733
- * This is a record with string keys and any values.
734
- */
735
- json(options) {
736
- return t.record(t.text(), t.any(), options);
737
- }
738
- /**
739
- * Create a schema for a boolean.
740
- */
741
- boolean(options) {
742
- return Type.Boolean({ ...options });
743
- }
744
- /**
745
- * Create a schema for a number.
746
- */
747
- number(options) {
748
- return Type.Number({ ...options });
749
- }
750
- /**
751
- * Create a schema for an integer.
752
- */
753
- integer(options) {
754
- return Type.Integer({ ...options });
755
- }
756
- int32(options) {
757
- return Type.Integer({
758
- minimum: -2147483648,
759
- maximum: 2147483647,
760
- ...options
761
- });
762
- }
763
- /**
764
- * Mimic a signed 64-bit integer.
765
- *
766
- * This is NOT a true int64, as JavaScript cannot represent all int64 values.
767
- * It is a number that is an integer and between -9007199254740991 and 9007199254740991.
768
- * Use `t.bigint()` for true int64 values represented as strings.
769
- */
770
- int64(options) {
771
- return Type.Number({
772
- format: "int64",
773
- multipleOf: 1,
774
- minimum: -9007199254740991,
775
- maximum: 9007199254740991,
776
- ...options
777
- });
778
- }
779
- /**
780
- * Make a schema optional.
781
- */
782
- optional(schema) {
783
- return Type.Optional(schema);
784
- }
785
- /**
786
- * Make a schema nullable.
787
- */
788
- nullable(schema, options) {
789
- return Type.Union([Type.Null(), schema], options);
790
- }
791
- /**
792
- * Create a schema that maps all properties of an object schema to nullable.
793
- */
794
- nullify = (schema, options) => Type.Mapped(Type.Identifier("K"), Type.KeyOf(schema), Type.Ref("K"), Type.Union([Type.Index(schema, Type.Ref("K")), Type.Null()]), options);
795
- /**
796
- * Create a schema for a string enum.
797
- *
798
- * By default, this creates a real PostgreSQL ENUM type in the database.
799
- * Use `{ mode: "text" }` to store as a TEXT column instead.
800
- *
801
- * @example
802
- * ```ts
803
- * // PostgreSQL ENUM type (default)
804
- * status: t.enum(["pending", "active", "archived"])
805
- *
806
- * // TEXT column
807
- * status: t.enum(["pending", "active", "archived"], { mode: "text" })
808
- *
809
- * // Shared enum name across tables
810
- * status: t.enum(["enabled", "disabled"], { name: "shared_status_enum" })
811
- * ```
812
- */
813
- enum(values, options) {
814
- const { mode, name, ...textOptions } = options ?? {};
815
- const schema = Type.Unsafe(t.text({
816
- enum: values,
817
- pattern: values.map((v) => `^${v}$`).join("|"),
818
- ...textOptions
819
- }));
820
- if (mode === "text") Object.assign(schema, { mode: "text" });
821
- else Object.assign(schema, { enumName: name });
822
- return schema;
823
- }
824
- /**
825
- * Create a schema for a bigint represented as a string.
826
- * This is a string that validates bigint format (e.g. "123456789").
827
- */
828
- bigint(options) {
829
- return t.string({
830
- ...options,
831
- format: "bigint"
832
- });
833
- }
834
- /**
835
- * Create a schema for a URL represented as a string.
836
- */
837
- url(options) {
838
- return this.string({
839
- ...options,
840
- format: "url"
841
- });
842
- }
843
- /**
844
- * Create a schema for binary data represented as a base64 string.
845
- */
846
- binary(options = {}) {
847
- return this.string({
848
- ...options,
849
- format: "binary"
850
- });
851
- }
852
- /**
853
- * Create a schema for uuid.
854
- */
855
- uuid(options) {
856
- return this.string({
857
- ...options,
858
- format: "uuid"
859
- });
860
- }
861
- /**
862
- * Create a schema for a file-like object.
863
- *
864
- * File like mimics the File API in browsers, but is adapted to work in Node.js as well.
865
- *
866
- * Implementation of file-like objects is handled by "alepha/file" package.
867
- */
868
- file(options) {
869
- return Type.Unsafe(Type.Any({
870
- [OPTIONS]: options,
871
- format: "binary"
872
- }));
873
- }
874
- /**
875
- * @experimental
876
- */
877
- stream() {
878
- return Type.Unsafe(Type.Any({
879
- format: "stream",
880
- type: "string"
881
- }));
882
- }
883
- email(options) {
884
- return this.text({
885
- ...options,
886
- format: "email",
887
- trim: true,
888
- lowercase: true
889
- });
890
- }
891
- e164(options) {
892
- return this.text({
893
- ...options,
894
- description: "Phone number in E.164 format, e.g. +1234567890.",
895
- pattern: "^\\+[1-9]\\d{1,14}$"
896
- });
897
- }
898
- bcp47(options) {
899
- return this.text({
900
- ...options,
901
- description: "BCP 47 language tag, e.g. en, en-US, fr, fr-CA.",
902
- pattern: "^[a-z]{2,3}(?:-[A-Z]{2})?$"
903
- });
904
- }
905
- /**
906
- * Create a schema for short text, such as names or titles.
907
- * Default max length is 64 characters.
908
- */
909
- shortText(options) {
910
- return this.text({
911
- size: "short",
912
- ...options
913
- });
914
- }
915
- /**
916
- * Create a schema for long text, such as descriptions or comments.
917
- * Default max length is 1024 characters.
918
- */
919
- longText(options) {
920
- return this.text({
921
- size: "long",
922
- ...options
923
- });
924
- }
925
- /**
926
- * Create a schema for rich text, such as HTML or Markdown.
927
- * Default max length is 65535 characters.
928
- */
929
- richText(options) {
930
- return this.text({
931
- size: "rich",
932
- ...options
933
- });
934
- }
935
- /**
936
- * Create a schema for a constant case string e.g. LIKE_THIS.
937
- */
938
- constantCase = (options) => this.text({
939
- pattern: "^[A-Z_-]+$",
940
- ...options
941
- });
942
- /**
943
- * Create a schema for an object with a value and label.
944
- */
945
- valueLabel = (options) => this.object({
946
- value: this.constantCase({ description: "Machine-readable value." }),
947
- label: this.text({ description: "Human-readable label." }),
948
- description: this.optional(this.text({
949
- description: "Description of the value.",
950
- size: "long"
951
- }))
952
- }, options);
953
- datetime = (options) => t.text({
954
- ...options,
955
- format: "date-time"
956
- });
957
- date = (options) => t.text({
958
- ...options,
959
- format: "date"
960
- });
961
- time = (options) => t.text({
962
- ...options,
963
- format: "time"
964
- });
965
- duration = (options) => t.text({
966
- ...options,
967
- format: "duration"
968
- });
969
- };
970
- const t = new TypeProvider();
971
- //#endregion
972
845
  //#region ../../src/core/providers/KeylessJsonSchemaCodec.ts
973
846
  /**
974
847
  * KeylessJsonSchemaCodec provides schema-driven JSON encoding without keys.
@@ -1086,14 +959,14 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1086
959
  }
1087
960
  interpretEncode(schema, value) {
1088
961
  if (this.isLeaf(schema)) return value;
1089
- if (t.schema.isBigInt(schema)) return `${value}n`;
1090
- if (t.schema.isArray(schema)) {
962
+ if (z.schema.isBigInt(schema)) return `${value}n`;
963
+ if (z.schema.isArray(schema)) {
1091
964
  const arrSchema = schema;
1092
965
  if (!Array.isArray(value)) return value;
1093
- if (t.schema.isScalar(arrSchema.items)) return value;
966
+ if (z.schema.isScalar(arrSchema.items)) return value;
1094
967
  return value.map((e) => this.interpretEncode(arrSchema.items, e));
1095
968
  }
1096
- if (t.schema.isObject(schema)) {
969
+ if (z.schema.isObject(schema)) {
1097
970
  const result = [];
1098
971
  for (const { key, isOpt, isNullable, inner } of this.getObjectFields(schema)) {
1099
972
  const v = value[key];
@@ -1103,7 +976,7 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1103
976
  }
1104
977
  return result;
1105
978
  }
1106
- if (t.schema.isOptional(schema) || t.schema.isUnion(schema)) {
979
+ if (z.schema.isOptional(schema) || z.schema.isUnion(schema)) {
1107
980
  const inner = this.unwrap(schema);
1108
981
  if (this.isNullable(schema)) return value !== null ? this.interpretEncode(inner, value) : null;
1109
982
  return value !== void 0 ? this.interpretEncode(inner, value) : null;
@@ -1112,15 +985,15 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1112
985
  }
1113
986
  interpretDecode(schema, ctx) {
1114
987
  if (this.isLeaf(schema)) return ctx.arr[ctx.i++];
1115
- if (t.schema.isBigInt(schema)) return BigInt(ctx.arr[ctx.i++].slice(0, -1));
1116
- if (t.schema.isArray(schema)) {
988
+ if (z.schema.isBigInt(schema)) return BigInt(ctx.arr[ctx.i++].slice(0, -1));
989
+ if (z.schema.isArray(schema)) {
1117
990
  const arrSchema = schema;
1118
991
  const arr = ctx.arr[ctx.i++];
1119
992
  if (!Array.isArray(arr)) return arr;
1120
- if (t.schema.isObject(arrSchema.items)) return arr.map((e) => this.interpretDecodeFromValue(arrSchema.items, e));
993
+ if (z.schema.isObject(arrSchema.items)) return arr.map((e) => this.interpretDecodeFromValue(arrSchema.items, e));
1121
994
  return arr;
1122
995
  }
1123
- if (t.schema.isObject(schema)) {
996
+ if (z.schema.isObject(schema)) {
1124
997
  const result = {};
1125
998
  for (const { key, isOpt, isNullable, inner } of this.getObjectFields(schema)) {
1126
999
  const val = ctx.arr[ctx.i++];
@@ -1131,37 +1004,37 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1131
1004
  }
1132
1005
  return result;
1133
1006
  }
1134
- if (t.schema.isOptional(schema) || t.schema.isUnion(schema)) {
1007
+ if (z.schema.isOptional(schema) || z.schema.isUnion(schema)) {
1135
1008
  const inner = this.unwrap(schema);
1136
1009
  const val = ctx.arr[ctx.i++];
1137
1010
  if (val === null) return this.isNullable(schema) ? null : void 0;
1138
- if (t.schema.isObject(inner) || t.schema.isArray(inner)) return this.interpretDecodeFromValue(inner, val);
1011
+ if (z.schema.isObject(inner) || z.schema.isArray(inner)) return this.interpretDecodeFromValue(inner, val);
1139
1012
  return val;
1140
1013
  }
1141
1014
  return ctx.arr[ctx.i++];
1142
1015
  }
1143
1016
  interpretDecodeFromValue(schema, value) {
1144
1017
  if (this.isLeaf(schema)) return value;
1145
- if (t.schema.isBigInt(schema)) return BigInt(value.slice(0, -1));
1146
- if (t.schema.isArray(schema)) {
1018
+ if (z.schema.isBigInt(schema)) return BigInt(value.slice(0, -1));
1019
+ if (z.schema.isArray(schema)) {
1147
1020
  if (!Array.isArray(value)) return value;
1148
1021
  const arrSchema = schema;
1149
- if (t.schema.isObject(arrSchema.items)) return value.map((e) => this.interpretDecodeFromValue(arrSchema.items, e));
1022
+ if (z.schema.isObject(arrSchema.items)) return value.map((e) => this.interpretDecodeFromValue(arrSchema.items, e));
1150
1023
  return value;
1151
1024
  }
1152
- if (t.schema.isObject(schema)) {
1025
+ if (z.schema.isObject(schema)) {
1153
1026
  const props = schema.properties;
1154
1027
  const keys = Object.keys(props);
1155
1028
  const result = {};
1156
1029
  for (let idx = 0; idx < keys.length; idx++) {
1157
1030
  const k = keys[idx];
1158
1031
  const prop = props[k];
1159
- const isOpt = t.schema.isOptional(prop);
1032
+ const isOpt = z.schema.isOptional(prop);
1160
1033
  const inner = this.unwrap(prop);
1161
1034
  const v = value[idx];
1162
1035
  if (isOpt && v === null) continue;
1163
- if (t.schema.isObject(inner)) result[k] = this.interpretDecodeFromValue(inner, v);
1164
- else if (t.schema.isBigInt(inner)) result[k] = BigInt(v.slice(0, -1));
1036
+ if (z.schema.isObject(inner)) result[k] = this.interpretDecodeFromValue(inner, v);
1037
+ else if (z.schema.isBigInt(inner)) result[k] = BigInt(v.slice(0, -1));
1165
1038
  else result[k] = v;
1166
1039
  }
1167
1040
  return result;
@@ -1170,14 +1043,14 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1170
1043
  }
1171
1044
  genEnc(schema, ve) {
1172
1045
  if (this.isLeaf(schema)) return ve;
1173
- if (t.schema.isBigInt(schema)) return `${ve}+'n'`;
1174
- if (t.schema.isArray(schema)) {
1046
+ if (z.schema.isBigInt(schema)) return `${ve}+'n'`;
1047
+ if (z.schema.isArray(schema)) {
1175
1048
  const arrSchema = schema;
1176
1049
  const itemEnc = this.genEnc(arrSchema.items, "e");
1177
- if (t.schema.isScalar(arrSchema.items)) return ve;
1050
+ if (z.schema.isScalar(arrSchema.items)) return ve;
1178
1051
  return `${ve}.map(e=>${itemEnc})`;
1179
1052
  }
1180
- if (t.schema.isObject(schema)) {
1053
+ if (z.schema.isObject(schema)) {
1181
1054
  const parts = [];
1182
1055
  for (const { key, isOpt, isNullable, inner } of this.getObjectFields(schema)) {
1183
1056
  const access = `${ve}[${JSON.stringify(key)}]`;
@@ -1188,7 +1061,7 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1188
1061
  }
1189
1062
  return `[${parts.join(",")}]`;
1190
1063
  }
1191
- if (t.schema.isOptional(schema) || t.schema.isUnion(schema)) {
1064
+ if (z.schema.isOptional(schema) || z.schema.isUnion(schema)) {
1192
1065
  const inner = this.unwrap(schema);
1193
1066
  const innerEnc = this.genEnc(inner, ve);
1194
1067
  if (this.isNullable(schema)) return `${ve}!==null?${innerEnc}:null`;
@@ -1202,13 +1075,13 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1202
1075
  code: "",
1203
1076
  result: "a[i++]"
1204
1077
  };
1205
- if (t.schema.isBigInt(schema)) return {
1078
+ if (z.schema.isBigInt(schema)) return {
1206
1079
  code: "",
1207
1080
  result: "BigInt(a[i++].slice(0,-1))"
1208
1081
  };
1209
- if (t.schema.isArray(schema)) {
1082
+ if (z.schema.isArray(schema)) {
1210
1083
  const arrSchema = schema;
1211
- if (t.schema.isObject(arrSchema.items)) return {
1084
+ if (z.schema.isObject(arrSchema.items)) return {
1212
1085
  code: "",
1213
1086
  result: `a[i++].map(e=>${this.genDecFromValue(arrSchema.items, "e")})`
1214
1087
  };
@@ -1217,9 +1090,9 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1217
1090
  result: "a[i++]"
1218
1091
  };
1219
1092
  }
1220
- if (t.schema.isObject(schema)) {
1093
+ if (z.schema.isObject(schema)) {
1221
1094
  const fields = this.getObjectFields(schema);
1222
- if (fields.every(({ isOpt, isNullable, inner }) => !isOpt && !isNullable && !t.schema.isObject(inner) && !t.schema.isArray(inner))) return {
1095
+ if (fields.every(({ isOpt, isNullable, inner }) => !isOpt && !isNullable && !z.schema.isObject(inner) && !z.schema.isArray(inner))) return {
1223
1096
  code: "",
1224
1097
  result: `{${fields.map(({ key }) => `${JSON.stringify(key)}:a[i++]`).join(",")}}`
1225
1098
  };
@@ -1232,12 +1105,12 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1232
1105
  } else if (isNullable) {
1233
1106
  const nested = this.genDecFromValue(inner, "t");
1234
1107
  code += `{const t=a[i++];if(t===null){${v}[${sk}]=null;}else{${v}[${sk}]=${nested};}}`;
1235
- } else if (t.schema.isObject(inner)) {
1108
+ } else if (z.schema.isObject(inner)) {
1236
1109
  const nested = this.genDecFromValue(inner, "a[i++]");
1237
1110
  code += `${v}[${sk}]=${nested};`;
1238
- } else if (t.schema.isArray(inner)) {
1111
+ } else if (z.schema.isArray(inner)) {
1239
1112
  const arrSchema = inner;
1240
- if (t.schema.isObject(arrSchema.items)) {
1113
+ if (z.schema.isObject(arrSchema.items)) {
1241
1114
  const itemTransform = this.genDecFromValue(arrSchema.items, "e");
1242
1115
  code += `${v}[${sk}]=a[i++].map(e=>${itemTransform});`;
1243
1116
  } else code += `${v}[${sk}]=a[i++];`;
@@ -1248,7 +1121,7 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1248
1121
  result: v
1249
1122
  };
1250
1123
  }
1251
- if (t.schema.isOptional(schema) || t.schema.isUnion(schema)) {
1124
+ if (z.schema.isOptional(schema) || z.schema.isUnion(schema)) {
1252
1125
  const inner = this.unwrap(schema);
1253
1126
  const innerDec = this.genDec(inner);
1254
1127
  return {
@@ -1263,16 +1136,16 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1263
1136
  }
1264
1137
  genDecFromValue(schema, expr) {
1265
1138
  if (this.isLeaf(schema)) return expr;
1266
- if (t.schema.isBigInt(schema)) return `BigInt(${expr}.slice(0,-1))`;
1267
- if (t.schema.isArray(schema)) {
1139
+ if (z.schema.isBigInt(schema)) return `BigInt(${expr}.slice(0,-1))`;
1140
+ if (z.schema.isArray(schema)) {
1268
1141
  const items = schema.items;
1269
- if (t.schema.isObject(items) || t.schema.isBigInt(items)) {
1142
+ if (z.schema.isObject(items) || z.schema.isBigInt(items)) {
1270
1143
  const v = this.nextVar();
1271
1144
  return `${expr}.map(${v}=>${this.genDecFromValue(items, v)})`;
1272
1145
  }
1273
1146
  return expr;
1274
1147
  }
1275
- if (t.schema.isObject(schema)) {
1148
+ if (z.schema.isObject(schema)) {
1276
1149
  const props = schema.properties;
1277
1150
  const keys = Object.keys(props);
1278
1151
  const v = this.nextVar();
@@ -1280,24 +1153,24 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1280
1153
  const inner = this.unwrap(props[k]);
1281
1154
  const innerExpr = `${v}[${idx}]`;
1282
1155
  const sk = JSON.stringify(k);
1283
- if (t.schema.isObject(inner)) return `${sk}:${this.genDecFromValue(inner, innerExpr)}`;
1284
- if (t.schema.isBigInt(inner)) return `${sk}:BigInt(${innerExpr}.slice(0,-1))`;
1156
+ if (z.schema.isObject(inner)) return `${sk}:${this.genDecFromValue(inner, innerExpr)}`;
1157
+ if (z.schema.isBigInt(inner)) return `${sk}:BigInt(${innerExpr}.slice(0,-1))`;
1285
1158
  return `${sk}:${innerExpr}`;
1286
1159
  }).join(",")}}))()`;
1287
1160
  }
1288
1161
  return expr;
1289
1162
  }
1290
1163
  isLeaf(schema) {
1291
- return t.schema.isScalar(schema) || this.isEnum(schema);
1164
+ return z.schema.isScalar(schema) || this.isEnum(schema);
1292
1165
  }
1293
1166
  getObjectFields(schema) {
1294
1167
  const props = schema.properties;
1295
- const req = new Set(schema.required || []);
1168
+ const req = new Set(z.schema.requiredKeys(schema));
1296
1169
  return Object.keys(props).map((key) => {
1297
1170
  const ps = props[key];
1298
1171
  return {
1299
1172
  key,
1300
- isOpt: !req.has(key) || t.schema.isOptional(ps),
1173
+ isOpt: !req.has(key) || z.schema.isOptional(ps),
1301
1174
  isNullable: this.isNullable(ps),
1302
1175
  inner: this.unwrap(ps)
1303
1176
  };
@@ -1307,26 +1180,39 @@ var KeylessJsonSchemaCodec = class extends SchemaCodec {
1307
1180
  return "enum" in schema && Array.isArray(schema.enum) && (schema.enum?.length ?? 0) > 0;
1308
1181
  }
1309
1182
  isNullable(schema) {
1310
- if (!t.schema.isUnion(schema)) return false;
1311
- return schema.anyOf?.some((s) => t.schema.isNull(s)) ?? false;
1183
+ let cur = schema;
1184
+ while (cur) {
1185
+ if (z.schema.isNullable(cur)) return true;
1186
+ if (z.schema.isOptional(cur) && typeof cur.unwrap === "function") {
1187
+ cur = cur.unwrap();
1188
+ continue;
1189
+ }
1190
+ break;
1191
+ }
1192
+ if (z.schema.isUnion(schema)) return schema.anyOf?.some((s) => z.schema.isNull(s)) ?? false;
1193
+ return false;
1312
1194
  }
1313
1195
  unwrap(schema) {
1314
- if ("anyOf" in schema && Array.isArray(schema.anyOf)) return schema.anyOf.find((s) => !t.schema.isNull(s)) || schema;
1315
- return schema;
1196
+ const peeled = z.schema.unwrap(schema);
1197
+ if (z.schema.isUnion(peeled)) {
1198
+ const unionSchema = peeled;
1199
+ if (Array.isArray(unionSchema.anyOf)) return unionSchema.anyOf.find((s) => !z.schema.isNull(s)) || peeled;
1200
+ }
1201
+ return peeled;
1316
1202
  }
1317
1203
  /**
1318
1204
  * Reconstruct an object from a parsed array (for when input is already parsed).
1319
1205
  */
1320
1206
  reconstructObject(schema, arr) {
1321
- if (!t.schema.isObject(schema)) return arr;
1207
+ if (!z.schema.isObject(schema)) return arr;
1322
1208
  const result = {};
1323
1209
  let i = 0;
1324
1210
  for (const { key, isOpt, isNullable, inner } of this.getObjectFields(schema)) {
1325
1211
  const val = arr[i++];
1326
1212
  if (isOpt) {
1327
- if (val !== null) result[key] = t.schema.isObject(inner) ? this.reconstructObject(inner, val) : val;
1328
- } else if (isNullable) result[key] = val === null ? null : t.schema.isObject(inner) ? this.reconstructObject(inner, val) : val;
1329
- else result[key] = t.schema.isObject(inner) ? this.reconstructObject(inner, val) : val;
1213
+ if (val !== null) result[key] = z.schema.isObject(inner) ? this.reconstructObject(inner, val) : val;
1214
+ } else if (isNullable) result[key] = val === null ? null : z.schema.isObject(inner) ? this.reconstructObject(inner, val) : val;
1215
+ else result[key] = z.schema.isObject(inner) ? this.reconstructObject(inner, val) : val;
1330
1216
  }
1331
1217
  return result;
1332
1218
  }
@@ -1345,7 +1231,7 @@ var TypeBoxError = class extends AlephaError {
1345
1231
  message: "must be defined"
1346
1232
  };
1347
1233
  else this.value = {
1348
- path: error.instancePath,
1234
+ path: error.instancePath ?? "",
1349
1235
  message: error.message
1350
1236
  };
1351
1237
  this.cause = error;
@@ -1353,93 +1239,42 @@ var TypeBoxError = class extends AlephaError {
1353
1239
  };
1354
1240
  //#endregion
1355
1241
  //#region ../../src/core/providers/SchemaValidator.ts
1242
+ /**
1243
+ * Validates + coerces a value against a zod schema.
1244
+ *
1245
+ * Trimming / lowercasing / defaults / unknown-key stripping all live in the
1246
+ * schema itself now (zod), so this is a thin wrapper over `schema.parse`.
1247
+ * No typebox `Compile`, no `eval` — safe inside Cloudflare Workers.
1248
+ */
1356
1249
  var SchemaValidator = class {
1357
- cache = /* @__PURE__ */ new Map();
1358
- useEval = true;
1359
- /**
1360
- * Validate the value against the provided schema.
1361
- *
1362
- * Validation create a new value by applying some preprocessing. (e.g., trimming text)
1363
- */
1364
- validate(schema, value, options = {}) {
1365
- const newValue = this.beforeParse(schema, value, {
1366
- trim: options.trim ?? true,
1367
- nullToUndefined: options.nullToUndefined ?? true,
1368
- deleteUndefined: options.deleteUndefined ?? true
1369
- });
1370
- try {
1371
- if (!this.useEval) return Value.Parse(schema, newValue);
1372
- return this.getValidator(schema).Parse(newValue);
1373
- } catch (error) {
1374
- if (error.cause?.errors?.[0]) throw new TypeBoxError(error.cause.errors[0]);
1375
- throw error;
1250
+ validate(schema, value, _options = {}) {
1251
+ const result = schema.safeParse(value);
1252
+ if (!result.success) {
1253
+ const issue = result.error.issues[0];
1254
+ const path = issue?.path?.length ? issue.path.join("/") : "";
1255
+ let message = issue?.message ?? "Validation failed";
1256
+ if (issue?.code === "invalid_type" && /received undefined/i.test(message) && path) message = `'${path}' is required`;
1257
+ throw new TypeBoxError({
1258
+ message,
1259
+ instancePath: path ? `/${path}` : "",
1260
+ params: issue
1261
+ });
1376
1262
  }
1263
+ return result.data;
1377
1264
  }
1378
- /**
1379
- * Deep clone a schema. Useful when a schema is going to be mutated.
1380
- */
1381
- clone(schema) {
1382
- return Value.Clone(schema);
1383
- }
1384
- getValidator(schema) {
1385
- if (this.cache.has(schema)) return this.cache.get(schema);
1386
- const validator = Compile(schema);
1387
- this.cache.set(schema, validator);
1388
- return validator;
1265
+ safeValidate(schema, value) {
1266
+ return schema.safeParse(value);
1389
1267
  }
1390
- /**
1391
- * Preprocess the value based on the schema before validation.
1392
- *
1393
- * - If the value is `null` and the schema does not allow `null`, it converts it to `undefined`.
1394
- * - If the value is a string and the schema has a `~options.trim` flag, it trims whitespace from the string.
1395
- */
1396
- beforeParse(schema, value, options) {
1397
- if (!schema) return value;
1398
- if (value === null && !this.isSchemaNullable(schema) && options.nullToUndefined) return;
1399
- if (!schema.type && schema.anyOf) schema = schema.anyOf.find((s) => s.type !== "null" && s.type !== "undefined") || schema;
1400
- if (Array.isArray(value)) return value.map((it) => this.beforeParse(schema.items, it, options));
1401
- if (typeof value === "string" && schema.type === "string") {
1402
- let str = value;
1403
- if (options.trim && schema["~options"]?.trim) str = str.trim();
1404
- if (schema["~options"]?.lowercase) str = str.toLowerCase();
1405
- return str;
1406
- }
1407
- if (typeof value === "object" && value !== null && schema.type === "object") {
1408
- const obj = {};
1409
- for (const key in value) {
1410
- const newValue = this.beforeParse(schema.properties?.[key], value[key], options);
1411
- if (newValue === void 0 && options.deleteUndefined) continue;
1412
- obj[key] = newValue;
1413
- }
1414
- return obj;
1415
- }
1416
- return value;
1268
+ /** Zod schemas are immutable — clone is a pass-through. */
1269
+ clone(schema) {
1270
+ return schema;
1417
1271
  }
1418
1272
  /**
1419
- * Used by `beforeParse` to determine if a schema allows null values.
1273
+ * Legacy pre-processing entry point. Coercion now happens inside `parse`,
1274
+ * so this is a no-op kept for call-site compatibility.
1420
1275
  */
1421
- isSchemaNullable = (schema) => {
1422
- if (!schema) return false;
1423
- if (schema.type === "null") return true;
1424
- if (Array.isArray(schema.type) && schema.type.includes("null")) return true;
1425
- if (schema.anyOf) return schema.anyOf.some((it) => this.isSchemaNullable(it));
1426
- if (schema.oneOf) return schema.oneOf.some((it) => this.isSchemaNullable(it));
1427
- if (schema.allOf) return schema.allOf.some((it) => this.isSchemaNullable(it));
1428
- return false;
1429
- };
1430
- onConfigure = $hook({
1431
- on: "configure",
1432
- handler: () => {
1433
- this.useEval = this.canEval();
1434
- }
1435
- });
1436
- canEval() {
1437
- try {
1438
- Compile(t.object({ test: t.string() })).Parse({ test: "value" });
1439
- return true;
1440
- } catch {
1441
- return false;
1442
- }
1276
+ beforeParse(_schema, value, _options) {
1277
+ return value;
1443
1278
  }
1444
1279
  };
1445
1280
  //#endregion
@@ -1743,16 +1578,16 @@ var EventManager = class {
1743
1578
  * You control how state is structured and validated.
1744
1579
  *
1745
1580
  * Features:
1746
- * - Set a schema for validation
1747
- * - Set a default value for initial state
1748
- * - Rules, like read-only, custom validation, etc.
1749
- * - Automatic getter access in services with {@link $use}
1581
+ * - Schema validation on every write (invalid writes throw)
1582
+ * - Default value for initial state
1583
+ * - Automatic getter access in services with {@link $state}
1750
1584
  * - SSR support (server state automatically serialized and hydrated on client)
1751
- * - React integration (useAtom hook for automatic component re-renders)
1752
- * - Middleware
1753
- * - Persistence adapters (localStorage, Redis, database, file system, cookie, etc.)
1754
- * - State migrations (version upgrades when schema changes)
1755
- * - Documentation generation & devtools integration
1585
+ * - React integration (useStore / useSelector hooks for automatic re-renders)
1586
+ * - Derived values with {@link $computed} (useComputed hook)
1587
+ * - Persistence adapters: cookie (SSR-safe), localStorage, sessionStorage
1588
+ * - `serverOnly` flag to keep an atom out of the hydration payload
1589
+ * - reset / watch helpers on the state manager
1590
+ * - Documentation generation & devtools integration (mutation log)
1756
1591
  *
1757
1592
  * Common use cases:
1758
1593
  * - user preferences
@@ -1765,6 +1600,7 @@ var EventManager = class {
1765
1600
  * If you need to store complex data, consider using identifiers or references instead.
1766
1601
  */
1767
1602
  const $atom = (options) => {
1603
+ if (options.serverOnly && options.persist) throw new AlephaError(`Atom "${options.name}" declares both serverOnly and persist: "${options.persist}", which is a contradiction: serverOnly only guarantees exclusion from the SSR hydration payload, while every persist adapter (cookie, localStorage, sessionStorage) targets the browser by definition — cookie persistence ships the value in a Set-Cookie response header, and web-storage persistence IS the browser. Combining them silently leaks the value through the persistence channel instead of the hydration payload. Remove \`serverOnly\` or \`persist\` from atom "${options.name}".`);
1768
1604
  return new Atom(options);
1769
1605
  };
1770
1606
  var Atom = class {
@@ -1781,11 +1617,108 @@ var Atom = class {
1781
1617
  };
1782
1618
  $atom[KIND] = "atom";
1783
1619
  //#endregion
1620
+ //#region ../../src/core/primitives/$computed.ts
1621
+ /**
1622
+ * Define a derived, read-only value computed from one or more atoms
1623
+ * (or other computed values).
1624
+ *
1625
+ * Dependencies are declared statically, which keeps the data flow explicit
1626
+ * and lets subscribers know exactly which mutations invalidate the value.
1627
+ *
1628
+ * Computed values are never stored, serialized, hydrated, or persisted —
1629
+ * they are recomputed from their dependencies on every read, so they are
1630
+ * always correct inside request-scoped (fork) state on the server.
1631
+ *
1632
+ * ```ts
1633
+ * const cartTotal = $computed({
1634
+ * name: "cartTotal",
1635
+ * deps: [cartAtom],
1636
+ * get: (cart) => cart.items.reduce((sum, it) => sum + it.price, 0),
1637
+ * });
1638
+ *
1639
+ * alepha.store.get(cartTotal); // number
1640
+ * ```
1641
+ *
1642
+ * ### Footgun: a `serverOnly` dependency breaks hydration
1643
+ *
1644
+ * A computed whose deps include a `serverOnly` atom will NOT agree across the
1645
+ * SSR boundary. `serverOnly` keeps the atom out of the hydration payload, so
1646
+ * the server derives the value from the atom's real value while the browser
1647
+ * re-derives it from the atom's *default* — React then hydrates a DOM that
1648
+ * does not match the markup it received (a hydration mismatch, and a
1649
+ * silently wrong value afterwards).
1650
+ *
1651
+ * Either keep the computed server-side only (read it via `alepha.store.get`,
1652
+ * never through `useComputed`), or derive it from atoms that ship to the
1653
+ * browser. Note this cuts the other way too: if the value is safe to send to
1654
+ * the browser, the dependency should not have been `serverOnly` to begin
1655
+ * with.
1656
+ */
1657
+ const $computed = (options) => {
1658
+ return new Computed(options);
1659
+ };
1660
+ var Computed = class Computed {
1661
+ options;
1662
+ constructor(options) {
1663
+ this.options = options;
1664
+ }
1665
+ get key() {
1666
+ return this.options.name;
1667
+ }
1668
+ /**
1669
+ * Reentrancy guard for {@link keys}. Deps are declared as a `readonly`
1670
+ * array at construction time, so a cycle can't be built through the
1671
+ * public API — but the array itself isn't frozen, so nothing stops a
1672
+ * caller from reaching in and creating one anyway. Without this guard,
1673
+ * a cycle would recurse until the JS engine throws a native
1674
+ * `RangeError`, which violates the repo's "never throw a bare `Error`"
1675
+ * convention.
1676
+ */
1677
+ resolvingKeys = false;
1678
+ /**
1679
+ * Reentrancy guard for {@link compute}, same rationale as
1680
+ * {@link resolvingKeys}.
1681
+ */
1682
+ computing = false;
1683
+ /**
1684
+ * Transitive atom keys this computed value depends on. Subscribers
1685
+ * (useComputed, StateManager.watch) use this to know which `state:mutate`
1686
+ * events invalidate the value.
1687
+ */
1688
+ keys() {
1689
+ if (this.resolvingKeys) throw new AlephaError(`Circular $computed dependency detected at "${this.key}". A computed cannot depend on itself, even transitively.`);
1690
+ this.resolvingKeys = true;
1691
+ try {
1692
+ const out = [];
1693
+ for (const dep of this.options.deps) if (dep instanceof Computed) out.push(...dep.keys());
1694
+ else out.push(dep.key);
1695
+ return [...new Set(out)];
1696
+ } finally {
1697
+ this.resolvingKeys = false;
1698
+ }
1699
+ }
1700
+ /**
1701
+ * Resolve the value using the given dependency resolver.
1702
+ */
1703
+ compute(resolve) {
1704
+ if (this.computing) throw new AlephaError(`Circular $computed dependency detected at "${this.key}". A computed cannot depend on itself, even transitively.`);
1705
+ this.computing = true;
1706
+ try {
1707
+ const values = this.options.deps.map(resolve);
1708
+ return this.options.get(...values);
1709
+ } finally {
1710
+ this.computing = false;
1711
+ }
1712
+ }
1713
+ };
1714
+ $computed[KIND] = "computed";
1715
+ //#endregion
1784
1716
  //#region ../../src/core/providers/StateManager.ts
1785
1717
  var StateManager = class {
1786
1718
  als = $inject(AlsProvider);
1787
1719
  events = $inject(EventManager);
1788
1720
  codec = $inject(JsonSchemaCodec);
1721
+ validator = $inject(SchemaValidator);
1789
1722
  atoms = /* @__PURE__ */ new Map();
1790
1723
  store = {};
1791
1724
  constructor(store = {}) {
@@ -1805,12 +1738,14 @@ var StateManager = class {
1805
1738
  const exported = {};
1806
1739
  if (scope === "current") {
1807
1740
  if (this.als?.exists()) for (const atom of this.atoms.values()) {
1741
+ if (atom.options.serverOnly) continue;
1808
1742
  const value = this.als.get(atom.key, "current");
1809
1743
  if (value !== void 0) exported[atom.key] = value;
1810
1744
  }
1811
1745
  return exported;
1812
1746
  }
1813
1747
  for (const [key, atom] of this.atoms.entries()) {
1748
+ if (atom.options.serverOnly) continue;
1814
1749
  const value = this.get(atom, scope);
1815
1750
  if (value !== void 0) exported[key] = value;
1816
1751
  }
@@ -1831,15 +1766,172 @@ var StateManager = class {
1831
1766
  });
1832
1767
  return atoms;
1833
1768
  }
1769
+ /**
1770
+ * Return the registered atom for a state key, if any.
1771
+ */
1772
+ getAtom(key) {
1773
+ return this.atoms.get(key);
1774
+ }
1775
+ /**
1776
+ * Every atom registered so far, whatever store layer (if any) currently
1777
+ * holds its value.
1778
+ *
1779
+ * This is the order-independent way to discover atoms. The
1780
+ * `"state:register"` event fires exactly once per key and `EventManager`
1781
+ * has no replay buffer, so a service instantiated after an atom registered
1782
+ * never hears about it — a real hazard, since `$module.register()`
1783
+ * registers `atoms[]` BEFORE it wires `imports[]` and injects `services[]`.
1784
+ * Services that act on atoms (e.g. the cookie persistence adapter) must
1785
+ * read this registry on demand rather than build their own map from the
1786
+ * event.
1787
+ */
1788
+ listAtoms() {
1789
+ return [...this.atoms.values()];
1790
+ }
1834
1791
  register(atom) {
1792
+ if (atom instanceof Computed) throw new AlephaError(`Cannot register computed value "${atom.key}" as an atom. Computed values are derived from their dependencies on every read — they are never stored, serialized, hydrated, or persisted. Register its dependency atoms instead.`);
1835
1793
  const key = atom.key;
1836
- if (!this.atoms.has(key)) {
1837
- this.atoms.set(key, atom);
1838
- if (!(key in this.store)) this.set(key, atom.options.default, { skipContext: true });
1839
- }
1794
+ if (this.atoms.has(key)) return this;
1795
+ this.atoms.set(key, atom);
1796
+ const layer = this.als?.getLayer(key);
1797
+ if (layer) this.decodeExisting(atom, key, layer);
1798
+ if (key in this.store) this.decodeExisting(atom, key, this.store);
1799
+ else this.seedDefault(atom, key);
1800
+ this.bindWebStorage(atom);
1801
+ this.events?.emit("state:register", { atom }, { catch: true }).catch(() => null);
1840
1802
  return this;
1841
1803
  }
1804
+ /**
1805
+ * Install the atom's declared default into the app-level store.
1806
+ *
1807
+ * Deliberately bypasses {@link set}, for two reasons:
1808
+ *
1809
+ * 1. `set()` short-circuits when the new value equals the currently
1810
+ * *resolved* value (`prevValue === value` for non-objects) — inside a
1811
+ * fork that already holds the same primitive value, the app-store write
1812
+ * would simply never happen.
1813
+ * 2. A registration seed is initialisation, NOT a mutation, so it must not
1814
+ * emit `state:mutate`. Persistence adapters listen on that event: an
1815
+ * atom registering lazily mid-request would otherwise emit a mutation
1816
+ * carrying its *default*, and the cookie adapter would dutifully write
1817
+ * it back as a `Set-Cookie` — overwriting the very cookie the request
1818
+ * arrived with.
1819
+ *
1820
+ * A `undefined` default (only reachable for an optional schema) is not
1821
+ * written at all, so the key stays absent from the store — matching the
1822
+ * previous behaviour of `set(key, undefined)`.
1823
+ */
1824
+ seedDefault(atom, key) {
1825
+ const value = this.cloneDefault(atom);
1826
+ if (value === void 0) return;
1827
+ this.store[key] = value;
1828
+ }
1829
+ /**
1830
+ * A fresh, schema-validated copy of the atom's declared default.
1831
+ *
1832
+ * `atom.options.default` is a module-level object shared by every
1833
+ * container and every request in the process. Handing that exact reference
1834
+ * to the store would let an ordinary `store.mut(atom, s => ...)` mutate the
1835
+ * declaration itself, permanently and process-wide. Every other write path
1836
+ * round-trips through the validator (zod always returns a new object), so
1837
+ * these must too.
1838
+ */
1839
+ cloneDefault(atom) {
1840
+ if (atom.options.default === void 0) return;
1841
+ return this.validator.validate(atom.schema, atom.options.default);
1842
+ }
1843
+ /**
1844
+ * Decode a value that already exists under an atom's key at registration
1845
+ * time, in place, in whichever layer it physically lives (an ALS fork
1846
+ * layer or the app store) — never flattening a fork-scoped value into the
1847
+ * app-level store.
1848
+ *
1849
+ * On schema mismatch, falls back to the atom's default (written into that
1850
+ * same layer) and emits a warning: a bad seed silently reverting a whole
1851
+ * atom to its defaults should be visible, not indistinguishable from
1852
+ * "nothing was ever set".
1853
+ */
1854
+ decodeExisting(atom, key, layer) {
1855
+ const current = layer[key];
1856
+ if (current === void 0) return;
1857
+ const result = this.validator.safeValidate(atom.schema, current);
1858
+ if (result.success) {
1859
+ layer[key] = result.data;
1860
+ return;
1861
+ }
1862
+ this.logger?.warn(`Atom "${String(key)}" received an invalid seed value at registration, falling back to its default.`, { issues: result.error.issues });
1863
+ layer[key] = this.cloneDefault(atom);
1864
+ }
1865
+ /**
1866
+ * Web-storage persistence (localStorage / sessionStorage) for atoms
1867
+ * declared with `persist`. Best-effort: quota errors and privacy modes
1868
+ * are swallowed. Cookie persistence is NOT handled here — it needs the
1869
+ * HTTP request cycle and lives in `alepha/server/cookies`
1870
+ * (AtomCookiePersistence), which discovers its atoms through
1871
+ * {@link listAtoms}. Both adapters are therefore registration-order
1872
+ * independent: one `persist` option, one reliability contract.
1873
+ */
1874
+ bindWebStorage(atom) {
1875
+ const persist = atom.options.persist;
1876
+ if (persist !== "localStorage" && persist !== "sessionStorage") return;
1877
+ const storage = this.getWebStorage(persist);
1878
+ if (!storage) {
1879
+ this.logger?.warn(`Atom "${atom.key}" uses ${persist} persistence, which is unavailable in this environment. Use persist: "cookie" for SSR apps.`);
1880
+ return;
1881
+ }
1882
+ const key = atom.key;
1883
+ try {
1884
+ const raw = storage.getItem(atom.key);
1885
+ if (raw != null) {
1886
+ const result = this.validator.safeValidate(atom.schema, JSON.parse(raw));
1887
+ if (result.success) this.store[key] = result.data;
1888
+ else this.safeRemoveItem(storage, atom.key);
1889
+ }
1890
+ } catch {
1891
+ this.safeRemoveItem(storage, atom.key);
1892
+ }
1893
+ this.events.on("state:mutate", ({ key: mutatedKey, value }) => {
1894
+ if (mutatedKey !== atom.key) return;
1895
+ try {
1896
+ if (value === void 0) storage.removeItem(atom.key);
1897
+ else storage.setItem(atom.key, JSON.stringify(value));
1898
+ } catch {}
1899
+ });
1900
+ }
1901
+ /**
1902
+ * Best-effort `Storage#removeItem`. Some privacy modes throw on every
1903
+ * Storage method, including `removeItem` — this must never escape a
1904
+ * recovery `catch`, or persistence stops being best-effort.
1905
+ */
1906
+ safeRemoveItem(storage, key) {
1907
+ try {
1908
+ storage.removeItem(key);
1909
+ } catch {}
1910
+ }
1911
+ /**
1912
+ * Resolve a Web Storage area, or undefined when unavailable (server,
1913
+ * privacy mode that throws on access).
1914
+ */
1915
+ getWebStorage(kind) {
1916
+ try {
1917
+ if (typeof window === "undefined") return;
1918
+ return kind === "localStorage" ? window.localStorage : window.sessionStorage;
1919
+ } catch {
1920
+ return;
1921
+ }
1922
+ }
1923
+ /**
1924
+ * Best-effort logger lookup. `StateManager` lives in `core`, which cannot
1925
+ * depend on the logger module, so this reads the `"alepha.logger"` state
1926
+ * key directly (set by `Alepha.create()`, see `Alepha.ts`) instead of
1927
+ * injecting a logger service. May be `undefined` during early boot, before
1928
+ * the logger is wired up — callers must stay null-safe.
1929
+ */
1930
+ get logger() {
1931
+ return this.get("alepha.logger");
1932
+ }
1842
1933
  get(target, scope) {
1934
+ if (target instanceof Computed) return target.compute((dep) => this.get(dep, scope));
1843
1935
  if (target instanceof Atom) this.register(target);
1844
1936
  const key = target instanceof Atom ? target.key : target;
1845
1937
  const store = this.store;
@@ -1847,9 +1939,12 @@ var StateManager = class {
1847
1939
  return this.als?.exists() ? this.als.get(key, scope) ?? (scope ? void 0 : store[key]) : store[key];
1848
1940
  }
1849
1941
  set(target, value, options) {
1942
+ if (target instanceof Computed) throw new AlephaError(`Cannot set computed value "${target.key}". Mutate its dependencies instead.`);
1850
1943
  if (target instanceof Atom) this.register(target);
1851
1944
  const key = target instanceof Atom ? target.key : target;
1852
1945
  const store = this.store;
1946
+ const atom = target instanceof Atom ? target : this.atoms.get(key);
1947
+ if (atom && value !== void 0 && options?.skipValidation !== true) value = this.validator.validate(atom.schema, value);
1853
1948
  const prevValue = this.get(key);
1854
1949
  if (prevValue === value && typeof value !== "object") return this;
1855
1950
  if (options?.skipContext !== true && this.als?.exists()) this.als.set(key, value);
@@ -1861,6 +1956,31 @@ var StateManager = class {
1861
1956
  }, { catch: true }).catch(() => null);
1862
1957
  return this;
1863
1958
  }
1959
+ /**
1960
+ * Reset an atom back to its declared default value.
1961
+ */
1962
+ reset(atom) {
1963
+ this.register(atom);
1964
+ return this.set(atom, atom.options.default);
1965
+ }
1966
+ watch(target, callback) {
1967
+ if (target instanceof Computed) {
1968
+ const keys = new Set(target.keys());
1969
+ let prev = this.get(target);
1970
+ return this.events.on("state:mutate", (ev) => {
1971
+ if (!keys.has(ev.key)) return;
1972
+ const next = this.get(target);
1973
+ const last = prev;
1974
+ prev = next;
1975
+ callback(next, last);
1976
+ });
1977
+ }
1978
+ if (target instanceof Atom) this.register(target);
1979
+ const key = target instanceof Atom ? target.key : target;
1980
+ return this.events.on("state:mutate", (ev) => {
1981
+ if (ev.key === key) callback(ev.value, ev.prevValue);
1982
+ });
1983
+ }
1864
1984
  mut(target, mutator) {
1865
1985
  const updated = mutator(this.get(target));
1866
1986
  return this.set(target, updated);
@@ -1963,8 +2083,8 @@ var StateManager = class {
1963
2083
  * // But you should use $env() primitive to get typed values from the environment.
1964
2084
  * class App {
1965
2085
  * env = $env(
1966
- * t.object({
1967
- * MY_VAR: t.text(),
2086
+ * z.object({
2087
+ * MY_VAR: z.text(),
1968
2088
  * })
1969
2089
  * );
1970
2090
  * }
@@ -2187,6 +2307,13 @@ var Alepha = class Alepha {
2187
2307
  return this;
2188
2308
  }
2189
2309
  /**
2310
+ * Reset an atom back to its declared default value.
2311
+ */
2312
+ reset(target) {
2313
+ this.store.reset(target);
2314
+ return this;
2315
+ }
2316
+ /**
2190
2317
  * True when start() is called.
2191
2318
  *
2192
2319
  * -> No more services can be added, it's over, bye!
@@ -2510,7 +2637,7 @@ var Alepha = class Alepha {
2510
2637
  if (!match.parents.includes(parent) && parent !== service) match.parents.push(parent);
2511
2638
  return match.instance;
2512
2639
  }
2513
- if (this.started) {
2640
+ if (this.started && registry === this.registry) {
2514
2641
  const mod = service[MODULE]?.name;
2515
2642
  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 ?` : ""}`);
2516
2643
  }
@@ -2571,7 +2698,7 @@ var Alepha = class Alepha {
2571
2698
  */
2572
2699
  parseEnv(schema) {
2573
2700
  if (this.cacheEnv.has(schema)) return this.cacheEnv.get(schema);
2574
- const config = this.codec.validate(schema, this.env);
2701
+ const config = this.codec.validate(schema, coerceObject(schema, this.env));
2575
2702
  const sortedKeys = Object.keys(config).sort((a, b) => b.length - a.length);
2576
2703
  let changed = true;
2577
2704
  for (let pass = 0; changed && pass < 10; pass++) {
@@ -2625,13 +2752,17 @@ var Alepha = class Alepha {
2625
2752
  const env = {};
2626
2753
  for (const [schema] of this.cacheEnv.entries()) {
2627
2754
  const ref = schema;
2628
- for (const [key, value] of Object.entries(ref.properties)) {
2755
+ const shape = ref.properties ?? {};
2756
+ const required = new Set(z.schema.requiredKeys(ref));
2757
+ for (const [key, value] of Object.entries(shape)) {
2629
2758
  const prop = value;
2759
+ const inner = z.schema.unwrap(prop);
2760
+ const enumValues = z.schema.isEnum(inner) ? z.schema.enumValues(inner) : void 0;
2630
2761
  env[key] = {
2631
- description: prop.description,
2632
- default: prop.default,
2633
- required: ref.required?.includes(key) ?? void 0,
2634
- enum: prop.enum ? [...prop.enum] : void 0
2762
+ description: inner?.description ?? prop?.description,
2763
+ default: z.schema.getDefault(prop),
2764
+ required: required.has(key) ? true : void 0,
2765
+ enum: enumValues?.length ? [...enumValues] : void 0
2635
2766
  };
2636
2767
  }
2637
2768
  }
@@ -2766,222 +2897,86 @@ function createPagination(entities, limit = 10, offset = 0, sort) {
2766
2897
  };
2767
2898
  }
2768
2899
  //#endregion
2769
- //#region ../../src/core/helpers/jsonSchemaToTypeBox.ts
2900
+ //#region ../../src/core/helpers/FileLike.ts
2901
+ const isTypeFile = (value) => {
2902
+ return !!value && typeof value === "object" && z.schema.format(value) === "binary";
2903
+ };
2904
+ const isFileLike = (value) => {
2905
+ return !!value && typeof value === "object" && !Array.isArray(value) && typeof value.name === "string" && typeof value.type === "string" && typeof value.size === "number" && typeof value.stream.bind(value) === "function";
2906
+ };
2907
+ //#endregion
2908
+ //#region ../../src/core/helpers/jsonSchemaToZod.ts
2770
2909
  /**
2771
- * Converts a JSON Schema object to a TypeBox schema using Alepha's type system.
2772
- *
2773
- * This is useful when receiving JSON Schema from an API (e.g., configuration schemas)
2774
- * and needing to use them with TypeBox-based form rendering or validation.
2775
- *
2776
- * **Supports:**
2777
- * - Basic types: string, number, integer, boolean, null, object, array
2778
- * - String formats: email, uuid, date-time, date, time, url/uri, binary, bigint, duration, color
2779
- * - Enums (string enums)
2780
- * - Nested objects with required/optional properties
2781
- * - Arrays with item schemas
2782
- * - Common validation options: minLength, maxLength, minimum, maximum, pattern
2783
- * - anyOf/oneOf/allOf with nullable patterns (e.g., `anyOf: [type, null]` → `t.nullable(type)`)
2784
- * - Alepha ~options (trim, lowercase) pass-through
2785
- *
2786
- * **Not supported:**
2787
- * - $ref (references)
2788
- * - additionalProperties, patternProperties
2789
- * - Complex composition schemas (multiple non-null types in anyOf/oneOf/allOf)
2790
- *
2791
- * @param schema - JSON Schema object to convert
2792
- * @returns TypeBox TSchema
2793
- *
2794
- * @example
2795
- * ```ts
2796
- * const jsonSchema = {
2797
- * type: "object",
2798
- * properties: {
2799
- * email: { type: "string", format: "email" },
2800
- * age: { type: "integer", minimum: 0 },
2801
- * active: { type: "boolean" },
2802
- * },
2803
- * required: ["email"]
2804
- * };
2805
- *
2806
- * const typeBoxSchema = jsonSchemaToTypeBox(jsonSchema);
2807
- * // Equivalent to:
2808
- * // t.object({
2809
- * // email: t.email(),
2810
- * // age: t.optional(t.integer({ minimum: 0 })),
2811
- * // active: t.optional(t.boolean()),
2812
- * // })
2813
- * ```
2910
+ * Convert a JSON Schema object into a zod schema (the inverse of
2911
+ * `z.toJSONSchema`). zod 4 has no native `fromJSONSchema`, so this provides the
2912
+ * round-trip needed by dynamic, schema-driven UIs (e.g. devtools forms built
2913
+ * from an entity's or action's published JSON Schema).
2914
+ *
2915
+ * Covers the JSON Schema subset Alepha emits: object/array/string (+formats),
2916
+ * number/integer, boolean, null, enum, and `anyOf`/`oneOf` (including the
2917
+ * nullable `anyOf: [..., { type: "null" }]` shape). Anything unrecognized falls
2918
+ * back to `z.any()`.
2814
2919
  */
2815
- function jsonSchemaToTypeBox(schema) {
2816
- if (schema.const !== void 0) return t.const(schema.const);
2817
- if (schema.enum && Array.isArray(schema.enum)) {
2818
- if (schema.enum.every((v) => typeof v === "string")) return t.enum(schema.enum, filterUndefined({
2819
- title: schema.title,
2820
- description: schema.description,
2821
- default: schema.default
2822
- }));
2823
- return t.union(schema.enum.map((v) => t.const(v)));
2824
- }
2825
- if (schema.anyOf && Array.isArray(schema.anyOf)) {
2826
- const nullSchema = schema.anyOf.find((s) => s.type === "null");
2827
- const nonNullSchemas = schema.anyOf.filter((s) => s.type !== "null");
2828
- if (nullSchema && nonNullSchemas.length === 1) {
2829
- const converted = jsonSchemaToTypeBox(nonNullSchemas[0]);
2830
- return t.nullable(converted);
2831
- }
2832
- return t.union(schema.anyOf.map((s) => jsonSchemaToTypeBox(s)));
2833
- }
2834
- if (schema.allOf && Array.isArray(schema.allOf)) {
2835
- const nullSchema = schema.allOf.find((s) => s.type === "null");
2836
- const nonNullSchemas = schema.allOf.filter((s) => s.type !== "null");
2837
- if (nullSchema && nonNullSchemas.length === 1) {
2838
- const converted = jsonSchemaToTypeBox(nonNullSchemas[0]);
2839
- return t.nullable(converted);
2840
- }
2841
- if (nonNullSchemas.length > 0) return jsonSchemaToTypeBox(nonNullSchemas[0]);
2842
- }
2843
- if (schema.oneOf && Array.isArray(schema.oneOf)) {
2844
- const nullSchema = schema.oneOf.find((s) => s.type === "null");
2845
- const nonNullSchemas = schema.oneOf.filter((s) => s.type !== "null");
2846
- if (nullSchema && nonNullSchemas.length === 1) {
2847
- const converted = jsonSchemaToTypeBox(nonNullSchemas[0]);
2848
- return t.nullable(converted);
2849
- }
2850
- return t.union(schema.oneOf.map((s) => jsonSchemaToTypeBox(s)));
2851
- }
2852
- switch (Array.isArray(schema.type) ? schema.type[0] : schema.type) {
2853
- case "string": return convertString(schema);
2854
- case "number": return convertNumber(schema);
2855
- case "integer": return convertInteger(schema);
2856
- case "boolean": return convertBoolean(schema);
2857
- case "null": return t.null();
2858
- case "object": return convertObject(schema);
2859
- case "array": return convertArray(schema);
2860
- default:
2861
- if (schema.properties) return convertObject(schema);
2862
- return t.any();
2920
+ const jsonSchemaToZod = (schema) => {
2921
+ if (!schema || typeof schema !== "object") return z.any();
2922
+ const variants = schema.anyOf ?? schema.oneOf;
2923
+ if (Array.isArray(variants) && variants.length > 0) {
2924
+ const nonNull = variants.filter((v) => v?.type !== "null" && v !== null);
2925
+ const nullable = nonNull.length !== variants.length;
2926
+ const mapped = nonNull.map(jsonSchemaToZod);
2927
+ let result = mapped.length === 1 ? mapped[0] : z.union(mapped);
2928
+ if (nullable) result = result.nullable();
2929
+ return result;
2863
2930
  }
2864
- }
2865
- /**
2866
- * Remove undefined values from an object.
2867
- */
2868
- function filterUndefined(obj) {
2869
- return Object.fromEntries(Object.entries(obj).filter(([_, v]) => v !== void 0));
2870
- }
2871
- /**
2872
- * Convert JSON Schema string type to TypeBox.
2873
- */
2874
- function convertString(schema) {
2875
- const baseOptions = filterUndefined({
2876
- title: schema.title,
2877
- description: schema.description,
2878
- default: schema.default,
2879
- minLength: schema.minLength,
2880
- maxLength: schema.maxLength,
2881
- pattern: schema.pattern
2882
- });
2883
- const options = schema["~options"] ? {
2884
- ...baseOptions,
2885
- "~options": schema["~options"]
2886
- } : baseOptions;
2887
- switch (schema.format) {
2888
- case "email": return t.email(options);
2889
- case "uuid": return t.uuid(options);
2890
- case "date-time": return t.datetime(options);
2891
- case "date": return t.date(options);
2892
- case "time": return t.time(options);
2893
- case "url":
2894
- case "uri": return t.url(options);
2895
- case "binary": return t.binary(options);
2896
- case "bigint": return t.bigint(options);
2897
- case "duration": return t.duration(options);
2898
- case "color": return t.text({
2899
- ...options,
2900
- format: "color"
2901
- });
2902
- case "e164": return t.e164(options);
2903
- case "bcp47": return t.bcp47(options);
2904
- default:
2905
- if (schema.format) return t.string({
2906
- ...options,
2907
- format: schema.format
2908
- });
2909
- return t.string(options);
2931
+ if (Array.isArray(schema.enum) && schema.enum.length > 0) {
2932
+ const values = schema.enum.filter((v) => typeof v === "string");
2933
+ if (values.length === schema.enum.length) return z.enum(values);
2934
+ }
2935
+ switch (schema.type) {
2936
+ case "object": {
2937
+ const required = Array.isArray(schema.required) ? schema.required : [];
2938
+ const shape = {};
2939
+ for (const [key, value] of Object.entries(schema.properties ?? {})) {
2940
+ const child = jsonSchemaToZod(value);
2941
+ shape[key] = required.includes(key) ? child : child.optional();
2942
+ }
2943
+ return z.object(shape);
2944
+ }
2945
+ case "array": return z.array(jsonSchemaToZod(schema.items ?? {}));
2946
+ case "string": {
2947
+ switch (schema.format) {
2948
+ case "uuid": return z.uuid();
2949
+ case "email": return z.email();
2950
+ case "url":
2951
+ case "uri": return z.url();
2952
+ case "date-time": return z.datetime();
2953
+ case "date": return z.date();
2954
+ case "time": return z.time();
2955
+ case "binary": return z.binary();
2956
+ }
2957
+ let str = z.string();
2958
+ if (typeof schema.minLength === "number") str = str.min(schema.minLength);
2959
+ if (typeof schema.maxLength === "number") str = str.max(schema.maxLength);
2960
+ if (typeof schema.pattern === "string") str = str.regex(new RegExp(schema.pattern));
2961
+ return str;
2962
+ }
2963
+ case "integer": {
2964
+ let int = z.integer();
2965
+ if (typeof schema.minimum === "number") int = int.min(schema.minimum);
2966
+ if (typeof schema.maximum === "number") int = int.max(schema.maximum);
2967
+ return int;
2968
+ }
2969
+ case "number": {
2970
+ let num = z.number();
2971
+ if (typeof schema.minimum === "number") num = num.min(schema.minimum);
2972
+ if (typeof schema.maximum === "number") num = num.max(schema.maximum);
2973
+ return num;
2974
+ }
2975
+ case "boolean": return z.boolean();
2976
+ case "null": return z.null();
2977
+ default: return z.any();
2910
2978
  }
2911
- }
2912
- /**
2913
- * Convert JSON Schema number type to TypeBox.
2914
- */
2915
- function convertNumber(schema) {
2916
- return t.number(filterUndefined({
2917
- title: schema.title,
2918
- description: schema.description,
2919
- default: schema.default,
2920
- minimum: schema.minimum,
2921
- maximum: schema.maximum,
2922
- exclusiveMinimum: schema.exclusiveMinimum,
2923
- exclusiveMaximum: schema.exclusiveMaximum,
2924
- multipleOf: schema.multipleOf
2925
- }));
2926
- }
2927
- /**
2928
- * Convert JSON Schema integer type to TypeBox.
2929
- */
2930
- function convertInteger(schema) {
2931
- return t.integer(filterUndefined({
2932
- title: schema.title,
2933
- description: schema.description,
2934
- default: schema.default,
2935
- minimum: schema.minimum,
2936
- maximum: schema.maximum,
2937
- exclusiveMinimum: schema.exclusiveMinimum,
2938
- exclusiveMaximum: schema.exclusiveMaximum,
2939
- multipleOf: schema.multipleOf
2940
- }));
2941
- }
2942
- /**
2943
- * Convert JSON Schema boolean type to TypeBox.
2944
- */
2945
- function convertBoolean(schema) {
2946
- return t.boolean(filterUndefined({
2947
- title: schema.title,
2948
- description: schema.description,
2949
- default: schema.default
2950
- }));
2951
- }
2952
- /**
2953
- * Convert JSON Schema object type to TypeBox.
2954
- */
2955
- function convertObject(schema) {
2956
- if (!schema.properties) return t.json(filterUndefined({
2957
- title: schema.title,
2958
- description: schema.description
2959
- }));
2960
- const required = new Set(schema.required ?? []);
2961
- const properties = {};
2962
- for (const [key, propSchema] of Object.entries(schema.properties)) {
2963
- let converted = jsonSchemaToTypeBox(propSchema);
2964
- if (!required.has(key)) converted = t.optional(converted);
2965
- properties[key] = converted;
2966
- }
2967
- return t.object(properties, filterUndefined({
2968
- title: schema.title,
2969
- description: schema.description
2970
- }));
2971
- }
2972
- /**
2973
- * Convert JSON Schema array type to TypeBox.
2974
- */
2975
- function convertArray(schema) {
2976
- const itemSchema = schema.items ? jsonSchemaToTypeBox(schema.items) : t.any();
2977
- return t.array(itemSchema, filterUndefined({
2978
- title: schema.title,
2979
- description: schema.description,
2980
- minItems: schema.minItems,
2981
- maxItems: schema.maxItems,
2982
- uniqueItems: schema.uniqueItems
2983
- }));
2984
- }
2979
+ };
2985
2980
  //#endregion
2986
2981
  //#region ../../src/core/primitives/$env.ts
2987
2982
  /**
@@ -3000,8 +2995,8 @@ function convertArray(schema) {
3000
2995
  * log = $logger();
3001
2996
  *
3002
2997
  * // program expect a var env "HELLO" as string to works
3003
- * env = $env(t.object({
3004
- * HELLO: t.text()
2998
+ * env = $env(z.object({
2999
+ * HELLO: z.text()
3005
3000
  * }));
3006
3001
  *
3007
3002
  * sayHello = () => this.log.info("Hello ${this.env.HELLO}")
@@ -3012,7 +3007,7 @@ function convertArray(schema) {
3012
3007
  */
3013
3008
  const $env = (type) => {
3014
3009
  const { alepha } = $context();
3015
- if (!t.schema.isObject(type)) throw new AlephaError("Type must be an TObject");
3010
+ if (!z.schema.isObject(type)) throw new AlephaError("Type must be an TObject");
3016
3011
  return alepha.parseEnv(type);
3017
3012
  };
3018
3013
  //#endregion
@@ -3258,7 +3253,7 @@ const $scope = () => {
3258
3253
  *
3259
3254
  * @example
3260
3255
  * ```ts
3261
- * const userState = $atom({ schema: t.object({ name: t.text(), role: t.text() }) });
3256
+ * const userState = $atom({ schema: z.object({ name: z.text(), role: z.text() }) });
3262
3257
  *
3263
3258
  * class UserComponent {
3264
3259
  * user = $state(userState); // Reactive reference to atom state
@@ -3280,39 +3275,30 @@ const $state = (atom) => {
3280
3275
  };
3281
3276
  //#endregion
3282
3277
  //#region ../../src/core/schemas/pageQuerySchema.ts
3283
- const pageQuerySchema = t.object({
3284
- page: t.optional(t.integer({
3285
- description: "The page number to retrieve.",
3286
- minimum: 0,
3287
- default: 0
3288
- })),
3289
- size: t.optional(t.integer({
3290
- description: "The number of items per page.",
3291
- minimum: 1,
3292
- maximum: 100,
3293
- default: 10
3294
- })),
3295
- sort: t.optional(t.text({ description: "Sort by field(s). Multiple columns separated by comma. Prefix with '-' for DESC. Examples: 'name' (ASC), '-createdAt' (DESC), 'role,-name' (role ASC, name DESC)" }))
3278
+ const pageQuerySchema = z.object({
3279
+ page: z.integer().min(0).describe("The page number to retrieve.").default(0).optional(),
3280
+ size: z.integer().min(1).max(100).describe("The number of items per page.").default(10).optional(),
3281
+ sort: z.text({ description: "Sort by field(s). Multiple columns separated by comma. Prefix with '-' for DESC. Examples: 'name' (ASC), '-createdAt' (DESC), 'role,-name' (role ASC, name DESC)" }).optional()
3296
3282
  });
3297
3283
  //#endregion
3298
3284
  //#region ../../src/core/schemas/pageSchema.ts
3299
- const pageMetadataSchema = t.object({
3300
- number: t.integer({ description: "Page number, starting from 0" }),
3301
- size: t.integer({ description: "Number of items per page (requested page size)" }),
3302
- offset: t.integer({ description: "Offset in the dataset (page × size)" }),
3303
- numberOfElements: t.integer({ description: "Number of elements in THIS page (content.length). Different from totalElements which is the total across all pages." }),
3304
- totalElements: t.optional(t.integer({ description: "Total number of elements across all pages. Only available when counting is enabled." })),
3305
- totalPages: t.optional(t.integer({ description: "Total number of pages. Only available when `totalElements` is present." })),
3306
- isEmpty: t.boolean({ description: "Indicates if the current page has no items (numberOfElements === 0)" }),
3307
- isFirst: t.boolean({ description: "Indicates if this is the first page (number === 0)" }),
3308
- isLast: t.boolean({ description: "Indicates if this is the last page (no more pages after this)" }),
3309
- sort: t.optional(t.object({
3310
- sorted: t.boolean({ description: "Whether the results are sorted" }),
3311
- fields: t.array(t.object({
3312
- field: t.text({ description: "The field used for sorting" }),
3313
- direction: t.enum(["asc", "desc"], { description: "The direction of the sort. Either 'asc' or 'desc'" })
3285
+ const pageMetadataSchema = z.object({
3286
+ number: z.integer().describe("Page number, starting from 0"),
3287
+ size: z.integer().describe("Number of items per page (requested page size)"),
3288
+ offset: z.integer().describe("Offset in the dataset (page × size)"),
3289
+ numberOfElements: z.integer().describe("Number of elements in THIS page (content.length). Different from totalElements which is the total across all pages."),
3290
+ totalElements: z.integer().describe("Total number of elements across all pages. Only available when counting is enabled.").optional(),
3291
+ totalPages: z.integer().describe("Total number of pages. Only available when `totalElements` is present.").optional(),
3292
+ isEmpty: z.boolean().describe("Indicates if the current page has no items (numberOfElements === 0)"),
3293
+ isFirst: z.boolean().describe("Indicates if this is the first page (number === 0)"),
3294
+ isLast: z.boolean().describe("Indicates if this is the last page (no more pages after this)"),
3295
+ sort: z.object({
3296
+ sorted: z.boolean().describe("Whether the results are sorted"),
3297
+ fields: z.array(z.object({
3298
+ field: z.text({ description: "The field used for sorting" }),
3299
+ direction: z.enum(["asc", "desc"]).describe("The direction of the sort. Either 'asc' or 'desc'")
3314
3300
  }))
3315
- }))
3301
+ }).optional()
3316
3302
  });
3317
3303
  /**
3318
3304
  * Create a pagination schema for the given object schema.
@@ -3322,7 +3308,7 @@ const pageMetadataSchema = t.object({
3322
3308
  *
3323
3309
  * @example
3324
3310
  * ```ts
3325
- * const userSchema = t.object({ id: t.integer(), name: t.text() });
3311
+ * const userSchema = z.object({ id: z.integer(), name: z.text() });
3326
3312
  * const userPageSchema = pageSchema(userSchema);
3327
3313
  * ```
3328
3314
  *
@@ -3336,10 +3322,10 @@ const pageMetadataSchema = t.object({
3336
3322
  * })
3337
3323
  * ```
3338
3324
  */
3339
- const pageSchema = (objectSchema, options) => t.object({
3340
- content: t.array(objectSchema),
3325
+ const pageSchema = (objectSchema) => z.object({
3326
+ content: z.array(objectSchema),
3341
3327
  page: pageMetadataSchema
3342
- }, options);
3328
+ });
3343
3329
  TypeProvider.prototype.page = (itemSchema) => pageSchema(itemSchema);
3344
3330
  //#endregion
3345
3331
  //#region ../../src/core/index.ts
@@ -3434,6 +3420,6 @@ const run = (entry, opts) => {
3434
3420
  };
3435
3421
  AlsProvider.create = () => new AsyncLocalStorage();
3436
3422
  //#endregion
3437
- export { $atom, $context, $env, $hook, $inject, $memoize, $mode, $module, $pipeline, $scope, $state, ALS_PARENT, Alepha, AlephaCore, AlephaError, AlsProvider, AppNotStartedError, Atom, CircularDependencyError, CodecManager, ContainerLockedError, EventManager, Format, HookPrimitive, InjectPrimitive, Json, JsonSchemaCodec, KIND, KeylessJsonSchemaCodec, Module, OPTIONS, PipelineHandler, PipelinePrimitive, Primitive, SchemaCodec, SchemaValidator, StateManager, TooLateSubstitutionError, Type, TypeBoxError, TypeGuard, TypeProvider, __alephaRef, createMiddleware, createPagination, createPrimitive, isClass, isFileLike, isTypeFile, jsonSchemaToTypeBox, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
3423
+ export { $atom, $computed, $context, $env, $hook, $inject, $memoize, $mode, $module, $pipeline, $scope, $state, ALS_PARENT, Alepha, AlephaCore, AlephaError, AlsProvider, AppNotStartedError, Atom, CircularDependencyError, CodecManager, Computed, ContainerLockedError, EventManager, HookPrimitive, InjectPrimitive, Json, JsonSchemaCodec, KIND, KeylessJsonSchemaCodec, Module, OPTIONS, PipelineHandler, PipelinePrimitive, Primitive, SchemaCodec, SchemaValidator, StateManager, TooLateSubstitutionError, Type, TypeBoxError, TypeProvider, Z_LIMITS, __alephaRef, coerceObject, coerceScalar, createMiddleware, createPagination, createPrimitive, isClass, isFileLike, isTypeFile, jsonSchemaToZod, pageMetadataSchema, pageQuerySchema, pageSchema, run, z };
3438
3424
 
3439
3425
  //# sourceMappingURL=index.js.map