alepha 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (461) hide show
  1. package/README.md +1 -1
  2. package/dist/api-files/index.d.ts +28 -91
  3. package/dist/api-files/index.js +10 -755
  4. package/dist/api-files/index.js.map +1 -1
  5. package/dist/api-jobs/index.d.ts +67 -67
  6. package/dist/api-jobs/index.js +13 -13
  7. package/dist/api-jobs/index.js.map +1 -1
  8. package/dist/api-notifications/index.d.ts +129 -146
  9. package/dist/api-notifications/index.js +17 -39
  10. package/dist/api-notifications/index.js.map +1 -1
  11. package/dist/api-parameters/index.d.ts +21 -22
  12. package/dist/api-parameters/index.js +22 -22
  13. package/dist/api-parameters/index.js.map +1 -1
  14. package/dist/api-users/index.d.ts +224 -2001
  15. package/dist/api-users/index.js +914 -4787
  16. package/dist/api-users/index.js.map +1 -1
  17. package/dist/api-verifications/index.d.ts +96 -96
  18. package/dist/batch/index.d.ts +13 -13
  19. package/dist/batch/index.js +8 -8
  20. package/dist/batch/index.js.map +1 -1
  21. package/dist/bucket/index.d.ts +14 -14
  22. package/dist/bucket/index.js +12 -12
  23. package/dist/bucket/index.js.map +1 -1
  24. package/dist/cache/index.d.ts +11 -11
  25. package/dist/cache/index.js +9 -9
  26. package/dist/cache/index.js.map +1 -1
  27. package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
  28. package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
  29. package/dist/cli/index.d.ts +31 -37
  30. package/dist/cli/index.js +152 -83
  31. package/dist/cli/index.js.map +1 -1
  32. package/dist/command/index.d.ts +19 -19
  33. package/dist/command/index.js +25 -25
  34. package/dist/command/index.js.map +1 -1
  35. package/dist/core/index.browser.js +218 -218
  36. package/dist/core/index.browser.js.map +1 -1
  37. package/dist/core/index.d.ts +232 -232
  38. package/dist/core/index.js +218 -218
  39. package/dist/core/index.js.map +1 -1
  40. package/dist/core/{index.cjs → index.native.js} +304 -455
  41. package/dist/core/index.native.js.map +1 -0
  42. package/dist/datetime/index.d.ts +9 -9
  43. package/dist/datetime/index.js +7 -7
  44. package/dist/datetime/index.js.map +1 -1
  45. package/dist/email/index.d.ts +16 -16
  46. package/dist/email/index.js +80 -82
  47. package/dist/email/index.js.map +1 -1
  48. package/dist/file/index.js +1 -1
  49. package/dist/file/index.js.map +1 -1
  50. package/dist/lock/index.d.ts +9 -9
  51. package/dist/lock/index.js +8 -8
  52. package/dist/lock/index.js.map +1 -1
  53. package/dist/lock-redis/index.js +3 -66
  54. package/dist/lock-redis/index.js.map +1 -1
  55. package/dist/logger/index.d.ts +5 -5
  56. package/dist/logger/index.js +8 -8
  57. package/dist/logger/index.js.map +1 -1
  58. package/dist/orm/index.browser.js +114 -114
  59. package/dist/orm/index.browser.js.map +1 -1
  60. package/dist/orm/index.d.ts +219 -219
  61. package/dist/orm/index.js +46 -46
  62. package/dist/orm/index.js.map +1 -1
  63. package/dist/queue/index.d.ts +25 -25
  64. package/dist/queue/index.js +20 -20
  65. package/dist/queue/index.js.map +1 -1
  66. package/dist/queue-redis/index.d.ts +2 -2
  67. package/dist/redis/index.d.ts +10 -10
  68. package/dist/retry/index.d.ts +20 -20
  69. package/dist/retry/index.js +9 -9
  70. package/dist/retry/index.js.map +1 -1
  71. package/dist/scheduler/index.d.ts +12 -12
  72. package/dist/scheduler/index.js +9 -9
  73. package/dist/scheduler/index.js.map +1 -1
  74. package/dist/security/index.d.ts +53 -53
  75. package/dist/security/index.js +32 -32
  76. package/dist/security/index.js.map +1 -1
  77. package/dist/server/index.browser.js +1 -1
  78. package/dist/server/index.browser.js.map +1 -1
  79. package/dist/server/index.d.ts +101 -101
  80. package/dist/server/index.js +17 -17
  81. package/dist/server/index.js.map +1 -1
  82. package/dist/server-auth/index.browser.js +4 -982
  83. package/dist/server-auth/index.browser.js.map +1 -1
  84. package/dist/server-auth/index.d.ts +204 -785
  85. package/dist/server-auth/index.js +47 -1239
  86. package/dist/server-auth/index.js.map +1 -1
  87. package/dist/server-cache/index.d.ts +10 -10
  88. package/dist/server-cache/index.js +2 -2
  89. package/dist/server-cache/index.js.map +1 -1
  90. package/dist/server-compress/index.d.ts +4 -4
  91. package/dist/server-compress/index.js +1 -1
  92. package/dist/server-compress/index.js.map +1 -1
  93. package/dist/server-cookies/index.browser.js +8 -8
  94. package/dist/server-cookies/index.browser.js.map +1 -1
  95. package/dist/server-cookies/index.d.ts +17 -17
  96. package/dist/server-cookies/index.js +10 -10
  97. package/dist/server-cookies/index.js.map +1 -1
  98. package/dist/server-cors/index.d.ts +17 -17
  99. package/dist/server-cors/index.js +9 -9
  100. package/dist/server-cors/index.js.map +1 -1
  101. package/dist/server-health/index.d.ts +2 -2
  102. package/dist/server-helmet/index.d.ts +1 -1
  103. package/dist/server-links/index.browser.js +12 -12
  104. package/dist/server-links/index.browser.js.map +1 -1
  105. package/dist/server-links/index.d.ts +59 -251
  106. package/dist/server-links/index.js +23 -502
  107. package/dist/server-links/index.js.map +1 -1
  108. package/dist/server-metrics/index.d.ts +4 -4
  109. package/dist/server-metrics/index.js +170 -174
  110. package/dist/server-metrics/index.js.map +1 -1
  111. package/dist/server-multipart/index.d.ts +2 -2
  112. package/dist/server-proxy/index.d.ts +12 -12
  113. package/dist/server-proxy/index.js +10 -10
  114. package/dist/server-proxy/index.js.map +1 -1
  115. package/dist/server-rate-limit/index.d.ts +22 -22
  116. package/dist/server-rate-limit/index.js +12 -12
  117. package/dist/server-rate-limit/index.js.map +1 -1
  118. package/dist/server-security/index.d.ts +24 -24
  119. package/dist/server-security/index.js +15 -15
  120. package/dist/server-security/index.js.map +1 -1
  121. package/dist/server-static/index.d.ts +14 -14
  122. package/dist/server-static/index.js +8 -8
  123. package/dist/server-static/index.js.map +1 -1
  124. package/dist/server-swagger/index.d.ts +25 -184
  125. package/dist/server-swagger/index.js +21 -724
  126. package/dist/server-swagger/index.js.map +1 -1
  127. package/dist/sms/index.d.ts +14 -14
  128. package/dist/sms/index.js +9 -9
  129. package/dist/sms/index.js.map +1 -1
  130. package/dist/thread/index.d.ts +11 -11
  131. package/dist/thread/index.js +17 -17
  132. package/dist/thread/index.js.map +1 -1
  133. package/dist/topic/index.d.ts +26 -26
  134. package/dist/topic/index.js +16 -16
  135. package/dist/topic/index.js.map +1 -1
  136. package/dist/topic-redis/index.d.ts +1 -1
  137. package/dist/vite/index.d.ts +3 -3
  138. package/dist/vite/index.js +12 -13
  139. package/dist/vite/index.js.map +1 -1
  140. package/dist/websocket/index.browser.js +11 -11
  141. package/dist/websocket/index.browser.js.map +1 -1
  142. package/dist/websocket/index.d.ts +51 -51
  143. package/dist/websocket/index.js +13 -13
  144. package/dist/websocket/index.js.map +1 -1
  145. package/package.json +62 -52
  146. package/src/api-files/services/FileService.ts +5 -7
  147. package/src/api-jobs/index.ts +1 -1
  148. package/src/api-jobs/{descriptors → primitives}/$job.ts +8 -8
  149. package/src/api-jobs/providers/JobProvider.ts +9 -9
  150. package/src/api-jobs/services/JobService.ts +5 -5
  151. package/src/api-notifications/index.ts +5 -15
  152. package/src/api-notifications/{descriptors → primitives}/$notification.ts +10 -10
  153. package/src/api-notifications/services/NotificationSenderService.ts +3 -3
  154. package/src/api-parameters/index.ts +1 -1
  155. package/src/api-parameters/{descriptors → primitives}/$config.ts +7 -12
  156. package/src/api-users/index.ts +1 -1
  157. package/src/api-users/{descriptors → primitives}/$userRealm.ts +8 -8
  158. package/src/api-users/providers/UserRealmProvider.ts +1 -1
  159. package/src/batch/index.ts +3 -3
  160. package/src/batch/{descriptors → primitives}/$batch.ts +13 -16
  161. package/src/bucket/index.ts +8 -8
  162. package/src/bucket/{descriptors → primitives}/$bucket.ts +8 -8
  163. package/src/bucket/providers/LocalFileStorageProvider.ts +3 -3
  164. package/src/cache/index.ts +4 -4
  165. package/src/cache/{descriptors → primitives}/$cache.ts +15 -15
  166. package/src/cli/apps/AlephaPackageBuilderCli.ts +30 -3
  167. package/src/cli/assets/appRouterTs.ts +9 -0
  168. package/src/cli/assets/indexHtml.ts +2 -1
  169. package/src/cli/assets/mainBrowserTs.ts +10 -0
  170. package/src/cli/commands/CoreCommands.ts +6 -5
  171. package/src/cli/commands/DrizzleCommands.ts +69 -61
  172. package/src/cli/commands/VerifyCommands.ts +2 -2
  173. package/src/cli/commands/ViteCommands.ts +6 -1
  174. package/src/cli/services/ProjectUtils.ts +78 -41
  175. package/src/command/index.ts +5 -5
  176. package/src/command/{descriptors → primitives}/$command.ts +9 -12
  177. package/src/command/providers/CliProvider.ts +10 -10
  178. package/src/core/Alepha.ts +30 -33
  179. package/src/core/constants/KIND.ts +1 -1
  180. package/src/core/constants/OPTIONS.ts +1 -1
  181. package/src/core/helpers/{descriptor.ts → primitive.ts} +18 -18
  182. package/src/core/helpers/ref.ts +1 -1
  183. package/src/core/index.shared.ts +8 -8
  184. package/src/core/{descriptors → primitives}/$context.ts +5 -5
  185. package/src/core/{descriptors → primitives}/$hook.ts +4 -4
  186. package/src/core/{descriptors → primitives}/$inject.ts +2 -2
  187. package/src/core/{descriptors → primitives}/$module.ts +9 -9
  188. package/src/core/{descriptors → primitives}/$use.ts +2 -2
  189. package/src/core/providers/CodecManager.ts +1 -1
  190. package/src/core/providers/JsonSchemaCodec.ts +1 -1
  191. package/src/core/providers/StateManager.ts +2 -2
  192. package/src/datetime/index.ts +3 -3
  193. package/src/datetime/{descriptors → primitives}/$interval.ts +6 -6
  194. package/src/email/index.ts +4 -4
  195. package/src/email/{descriptors → primitives}/$email.ts +8 -8
  196. package/src/file/index.ts +1 -1
  197. package/src/lock/index.ts +3 -3
  198. package/src/lock/{descriptors → primitives}/$lock.ts +10 -10
  199. package/src/logger/index.ts +8 -8
  200. package/src/logger/{descriptors → primitives}/$logger.ts +2 -2
  201. package/src/logger/services/Logger.ts +1 -1
  202. package/src/orm/constants/PG_SYMBOLS.ts +2 -2
  203. package/src/orm/index.browser.ts +2 -2
  204. package/src/orm/index.ts +8 -8
  205. package/src/orm/{descriptors → primitives}/$entity.ts +11 -11
  206. package/src/orm/{descriptors → primitives}/$repository.ts +2 -2
  207. package/src/orm/{descriptors → primitives}/$sequence.ts +8 -8
  208. package/src/orm/{descriptors → primitives}/$transaction.ts +4 -4
  209. package/src/orm/providers/DrizzleKitProvider.ts +1 -1
  210. package/src/orm/providers/PostgresTypeProvider.ts +3 -3
  211. package/src/orm/providers/RepositoryProvider.ts +4 -4
  212. package/src/orm/providers/drivers/DatabaseProvider.ts +7 -7
  213. package/src/orm/services/ModelBuilder.ts +9 -9
  214. package/src/orm/services/PgRelationManager.ts +2 -2
  215. package/src/orm/services/PostgresModelBuilder.ts +5 -5
  216. package/src/orm/services/Repository.ts +7 -7
  217. package/src/orm/services/SqliteModelBuilder.ts +5 -5
  218. package/src/queue/index.ts +7 -7
  219. package/src/queue/{descriptors → primitives}/$consumer.ts +15 -15
  220. package/src/queue/{descriptors → primitives}/$queue.ts +12 -12
  221. package/src/queue/providers/WorkerProvider.ts +7 -7
  222. package/src/retry/index.ts +3 -3
  223. package/src/retry/{descriptors → primitives}/$retry.ts +19 -17
  224. package/src/scheduler/index.ts +3 -3
  225. package/src/scheduler/{descriptors → primitives}/$scheduler.ts +9 -9
  226. package/src/scheduler/providers/CronProvider.ts +1 -1
  227. package/src/security/index.ts +9 -9
  228. package/src/security/{descriptors → primitives}/$permission.ts +7 -7
  229. package/src/security/{descriptors → primitives}/$realm.ts +6 -12
  230. package/src/security/{descriptors → primitives}/$role.ts +12 -12
  231. package/src/security/{descriptors → primitives}/$serviceAccount.ts +8 -8
  232. package/src/server/index.browser.ts +1 -1
  233. package/src/server/index.ts +14 -14
  234. package/src/server/{descriptors → primitives}/$action.ts +13 -13
  235. package/src/server/{descriptors → primitives}/$route.ts +9 -9
  236. package/src/server/providers/NodeHttpServerProvider.ts +2 -2
  237. package/src/server/services/HttpClient.ts +1 -1
  238. package/src/server-auth/index.browser.ts +1 -1
  239. package/src/server-auth/index.ts +6 -6
  240. package/src/server-auth/{descriptors → primitives}/$auth.ts +10 -10
  241. package/src/server-auth/{descriptors → primitives}/$authCredentials.ts +4 -4
  242. package/src/server-auth/{descriptors → primitives}/$authGithub.ts +4 -4
  243. package/src/server-auth/{descriptors → primitives}/$authGoogle.ts +4 -4
  244. package/src/server-auth/providers/ServerAuthProvider.ts +4 -4
  245. package/src/server-cache/providers/ServerCacheProvider.ts +7 -7
  246. package/src/server-compress/providers/ServerCompressProvider.ts +3 -3
  247. package/src/server-cookies/index.browser.ts +2 -2
  248. package/src/server-cookies/index.ts +5 -5
  249. package/src/server-cookies/{descriptors → primitives}/$cookie.browser.ts +12 -12
  250. package/src/server-cookies/{descriptors → primitives}/$cookie.ts +13 -13
  251. package/src/server-cookies/providers/ServerCookiesProvider.ts +4 -4
  252. package/src/server-cookies/services/CookieParser.ts +1 -1
  253. package/src/server-cors/index.ts +3 -3
  254. package/src/server-cors/{descriptors → primitives}/$cors.ts +11 -13
  255. package/src/server-cors/providers/ServerCorsProvider.ts +5 -5
  256. package/src/server-links/index.browser.ts +5 -5
  257. package/src/server-links/index.ts +9 -9
  258. package/src/server-links/{descriptors → primitives}/$remote.ts +11 -11
  259. package/src/server-links/providers/LinkProvider.ts +7 -7
  260. package/src/server-links/providers/{RemoteDescriptorProvider.ts → RemotePrimitiveProvider.ts} +6 -6
  261. package/src/server-links/providers/ServerLinksProvider.ts +3 -3
  262. package/src/server-proxy/index.ts +3 -3
  263. package/src/server-proxy/{descriptors → primitives}/$proxy.ts +8 -8
  264. package/src/server-proxy/providers/ServerProxyProvider.ts +4 -4
  265. package/src/server-rate-limit/index.ts +6 -6
  266. package/src/server-rate-limit/{descriptors → primitives}/$rateLimit.ts +13 -13
  267. package/src/server-rate-limit/providers/ServerRateLimitProvider.ts +5 -5
  268. package/src/server-security/index.ts +3 -3
  269. package/src/server-security/{descriptors → primitives}/$basicAuth.ts +13 -13
  270. package/src/server-security/providers/ServerBasicAuthProvider.ts +5 -5
  271. package/src/server-security/providers/ServerSecurityProvider.ts +4 -4
  272. package/src/server-static/index.ts +3 -3
  273. package/src/server-static/{descriptors → primitives}/$serve.ts +8 -10
  274. package/src/server-static/providers/ServerStaticProvider.ts +6 -6
  275. package/src/server-swagger/index.ts +5 -5
  276. package/src/server-swagger/{descriptors → primitives}/$swagger.ts +9 -9
  277. package/src/server-swagger/providers/ServerSwaggerProvider.ts +11 -10
  278. package/src/sms/index.ts +4 -4
  279. package/src/sms/{descriptors → primitives}/$sms.ts +8 -8
  280. package/src/thread/index.ts +3 -3
  281. package/src/thread/{descriptors → primitives}/$thread.ts +13 -13
  282. package/src/thread/providers/ThreadProvider.ts +7 -9
  283. package/src/topic/index.ts +5 -5
  284. package/src/topic/{descriptors → primitives}/$subscriber.ts +14 -14
  285. package/src/topic/{descriptors → primitives}/$topic.ts +10 -10
  286. package/src/topic/providers/TopicProvider.ts +4 -4
  287. package/src/vite/helpers/boot.ts +3 -3
  288. package/src/vite/tasks/copyAssets.ts +1 -1
  289. package/src/vite/tasks/generateSitemap.ts +3 -3
  290. package/src/vite/tasks/prerenderPages.ts +2 -2
  291. package/src/vite/tasks/runAlepha.ts +2 -2
  292. package/src/websocket/index.browser.ts +3 -3
  293. package/src/websocket/index.shared.ts +2 -2
  294. package/src/websocket/index.ts +4 -4
  295. package/src/websocket/interfaces/WebSocketInterfaces.ts +3 -3
  296. package/src/websocket/{descriptors → primitives}/$channel.ts +10 -10
  297. package/src/websocket/{descriptors → primitives}/$websocket.ts +8 -8
  298. package/src/websocket/providers/NodeWebSocketServerProvider.ts +7 -7
  299. package/src/websocket/providers/WebSocketServerProvider.ts +3 -3
  300. package/src/websocket/services/WebSocketClient.ts +5 -5
  301. package/dist/api-files/index.cjs +0 -1293
  302. package/dist/api-files/index.cjs.map +0 -1
  303. package/dist/api-files/index.d.cts +0 -829
  304. package/dist/api-jobs/index.cjs +0 -274
  305. package/dist/api-jobs/index.cjs.map +0 -1
  306. package/dist/api-jobs/index.d.cts +0 -654
  307. package/dist/api-notifications/index.cjs +0 -380
  308. package/dist/api-notifications/index.cjs.map +0 -1
  309. package/dist/api-notifications/index.d.cts +0 -289
  310. package/dist/api-parameters/index.cjs +0 -66
  311. package/dist/api-parameters/index.cjs.map +0 -1
  312. package/dist/api-parameters/index.d.cts +0 -84
  313. package/dist/api-users/index.cjs +0 -6009
  314. package/dist/api-users/index.cjs.map +0 -1
  315. package/dist/api-users/index.d.cts +0 -4740
  316. package/dist/api-verifications/index.cjs +0 -407
  317. package/dist/api-verifications/index.cjs.map +0 -1
  318. package/dist/api-verifications/index.d.cts +0 -207
  319. package/dist/batch/index.cjs +0 -408
  320. package/dist/batch/index.cjs.map +0 -1
  321. package/dist/batch/index.d.cts +0 -330
  322. package/dist/bin/index.cjs +0 -17
  323. package/dist/bin/index.cjs.map +0 -1
  324. package/dist/bin/index.d.cts +0 -1
  325. package/dist/bucket/index.cjs +0 -303
  326. package/dist/bucket/index.cjs.map +0 -1
  327. package/dist/bucket/index.d.cts +0 -355
  328. package/dist/cache/index.cjs +0 -241
  329. package/dist/cache/index.cjs.map +0 -1
  330. package/dist/cache/index.d.cts +0 -202
  331. package/dist/cache-redis/index.cjs +0 -84
  332. package/dist/cache-redis/index.cjs.map +0 -1
  333. package/dist/cache-redis/index.d.cts +0 -40
  334. package/dist/cli/chunk-DSlc6foC.cjs +0 -43
  335. package/dist/cli/dist-BBPjuQ56.js +0 -2778
  336. package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
  337. package/dist/cli/index.cjs +0 -1241
  338. package/dist/cli/index.cjs.map +0 -1
  339. package/dist/cli/index.d.cts +0 -422
  340. package/dist/command/index.cjs +0 -693
  341. package/dist/command/index.cjs.map +0 -1
  342. package/dist/command/index.d.cts +0 -340
  343. package/dist/core/index.cjs.map +0 -1
  344. package/dist/core/index.d.cts +0 -1927
  345. package/dist/datetime/index.cjs +0 -318
  346. package/dist/datetime/index.cjs.map +0 -1
  347. package/dist/datetime/index.d.cts +0 -145
  348. package/dist/email/index.cjs +0 -10874
  349. package/dist/email/index.cjs.map +0 -1
  350. package/dist/email/index.d.cts +0 -186
  351. package/dist/fake/index.cjs +0 -34641
  352. package/dist/fake/index.cjs.map +0 -1
  353. package/dist/fake/index.d.cts +0 -74
  354. package/dist/file/index.cjs +0 -1212
  355. package/dist/file/index.cjs.map +0 -1
  356. package/dist/file/index.d.cts +0 -698
  357. package/dist/lock/index.cjs +0 -226
  358. package/dist/lock/index.cjs.map +0 -1
  359. package/dist/lock/index.d.cts +0 -361
  360. package/dist/lock-redis/index.cjs +0 -113
  361. package/dist/lock-redis/index.cjs.map +0 -1
  362. package/dist/lock-redis/index.d.cts +0 -24
  363. package/dist/logger/index.cjs +0 -521
  364. package/dist/logger/index.cjs.map +0 -1
  365. package/dist/logger/index.d.cts +0 -281
  366. package/dist/orm/index.cjs +0 -2986
  367. package/dist/orm/index.cjs.map +0 -1
  368. package/dist/orm/index.d.cts +0 -2213
  369. package/dist/queue/index.cjs +0 -1044
  370. package/dist/queue/index.cjs.map +0 -1
  371. package/dist/queue/index.d.cts +0 -1265
  372. package/dist/queue-redis/index.cjs +0 -873
  373. package/dist/queue-redis/index.cjs.map +0 -1
  374. package/dist/queue-redis/index.d.cts +0 -82
  375. package/dist/redis/index.cjs +0 -153
  376. package/dist/redis/index.cjs.map +0 -1
  377. package/dist/redis/index.d.cts +0 -82
  378. package/dist/retry/index.cjs +0 -146
  379. package/dist/retry/index.cjs.map +0 -1
  380. package/dist/retry/index.d.cts +0 -172
  381. package/dist/router/index.cjs +0 -111
  382. package/dist/router/index.cjs.map +0 -1
  383. package/dist/router/index.d.cts +0 -46
  384. package/dist/scheduler/index.cjs +0 -576
  385. package/dist/scheduler/index.cjs.map +0 -1
  386. package/dist/scheduler/index.d.cts +0 -145
  387. package/dist/security/index.cjs +0 -2402
  388. package/dist/security/index.cjs.map +0 -1
  389. package/dist/security/index.d.cts +0 -598
  390. package/dist/server/index.cjs +0 -1680
  391. package/dist/server/index.cjs.map +0 -1
  392. package/dist/server/index.d.cts +0 -810
  393. package/dist/server-auth/index.cjs +0 -3146
  394. package/dist/server-auth/index.cjs.map +0 -1
  395. package/dist/server-auth/index.d.cts +0 -1164
  396. package/dist/server-cache/index.cjs +0 -252
  397. package/dist/server-cache/index.cjs.map +0 -1
  398. package/dist/server-cache/index.d.cts +0 -164
  399. package/dist/server-compress/index.cjs +0 -141
  400. package/dist/server-compress/index.cjs.map +0 -1
  401. package/dist/server-compress/index.d.cts +0 -38
  402. package/dist/server-cookies/index.cjs +0 -234
  403. package/dist/server-cookies/index.cjs.map +0 -1
  404. package/dist/server-cookies/index.d.cts +0 -144
  405. package/dist/server-cors/index.cjs +0 -201
  406. package/dist/server-cors/index.cjs.map +0 -1
  407. package/dist/server-cors/index.d.cts +0 -140
  408. package/dist/server-health/index.cjs +0 -62
  409. package/dist/server-health/index.cjs.map +0 -1
  410. package/dist/server-health/index.d.cts +0 -58
  411. package/dist/server-helmet/index.cjs +0 -131
  412. package/dist/server-helmet/index.cjs.map +0 -1
  413. package/dist/server-helmet/index.d.cts +0 -97
  414. package/dist/server-links/index.cjs +0 -992
  415. package/dist/server-links/index.cjs.map +0 -1
  416. package/dist/server-links/index.d.cts +0 -513
  417. package/dist/server-metrics/index.cjs +0 -4535
  418. package/dist/server-metrics/index.cjs.map +0 -1
  419. package/dist/server-metrics/index.d.cts +0 -35
  420. package/dist/server-multipart/index.cjs +0 -237
  421. package/dist/server-multipart/index.cjs.map +0 -1
  422. package/dist/server-multipart/index.d.cts +0 -50
  423. package/dist/server-proxy/index.cjs +0 -186
  424. package/dist/server-proxy/index.cjs.map +0 -1
  425. package/dist/server-proxy/index.d.cts +0 -234
  426. package/dist/server-rate-limit/index.cjs +0 -241
  427. package/dist/server-rate-limit/index.cjs.map +0 -1
  428. package/dist/server-rate-limit/index.d.cts +0 -183
  429. package/dist/server-security/index.cjs +0 -316
  430. package/dist/server-security/index.cjs.map +0 -1
  431. package/dist/server-security/index.d.cts +0 -173
  432. package/dist/server-static/index.cjs +0 -170
  433. package/dist/server-static/index.cjs.map +0 -1
  434. package/dist/server-static/index.d.cts +0 -121
  435. package/dist/server-swagger/index.cjs +0 -1021
  436. package/dist/server-swagger/index.cjs.map +0 -1
  437. package/dist/server-swagger/index.d.cts +0 -382
  438. package/dist/sms/index.cjs +0 -221
  439. package/dist/sms/index.cjs.map +0 -1
  440. package/dist/sms/index.d.cts +0 -130
  441. package/dist/thread/index.cjs +0 -350
  442. package/dist/thread/index.cjs.map +0 -1
  443. package/dist/thread/index.d.cts +0 -260
  444. package/dist/topic/index.cjs +0 -282
  445. package/dist/topic/index.cjs.map +0 -1
  446. package/dist/topic/index.d.cts +0 -523
  447. package/dist/topic-redis/index.cjs +0 -71
  448. package/dist/topic-redis/index.cjs.map +0 -1
  449. package/dist/topic-redis/index.d.cts +0 -42
  450. package/dist/vite/index.cjs +0 -1077
  451. package/dist/vite/index.cjs.map +0 -1
  452. package/dist/vite/index.d.cts +0 -542
  453. package/dist/websocket/index.cjs +0 -1117
  454. package/dist/websocket/index.cjs.map +0 -1
  455. package/dist/websocket/index.d.cts +0 -861
  456. package/src/api-notifications/providers/MemorySmsProvider.ts +0 -20
  457. package/src/api-notifications/providers/SmsProvider.ts +0 -8
  458. /package/src/core/{descriptors → primitives}/$atom.ts +0 -0
  459. /package/src/core/{descriptors → primitives}/$env.ts +0 -0
  460. /package/src/server-auth/{descriptors → primitives}/$authApple.ts +0 -0
  461. /package/src/server-links/{descriptors → primitives}/$client.ts +0 -0
@@ -1,693 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
-
27
- //#endregion
28
- let alepha = require("alepha");
29
- let node_process = require("node:process");
30
- let node_readline_promises = require("node:readline/promises");
31
- let alepha_logger = require("alepha/logger");
32
- let alepha_datetime = require("alepha/datetime");
33
- let node_child_process = require("node:child_process");
34
- let node_fs_promises = require("node:fs/promises");
35
- node_fs_promises = __toESM(node_fs_promises);
36
-
37
- //#region src/command/descriptors/$command.ts
38
- /**
39
- * Declares a CLI command.
40
- *
41
- * This descriptor allows you to define a command, its flags, and its handler
42
- * within your Alepha application structure.
43
- */
44
- const $command = (options) => (0, alepha.createDescriptor)(CommandDescriptor, options);
45
- var CommandDescriptor = class extends alepha.Descriptor {
46
- flags = this.options.flags ?? alepha.t.object({});
47
- aliases = this.options.aliases ?? [];
48
- get name() {
49
- if (this.options.root) return "";
50
- return this.options.name ?? `${this.config.propertyKey}`;
51
- }
52
- };
53
- $command[alepha.KIND] = CommandDescriptor;
54
-
55
- //#endregion
56
- //#region src/command/helpers/Asker.ts
57
- var Asker = class {
58
- log = (0, alepha_logger.$logger)();
59
- ask;
60
- alepha = (0, alepha.$inject)(alepha.Alepha);
61
- constructor() {
62
- this.ask = this.createAskMethod();
63
- }
64
- createAskMethod() {
65
- const askFn = async (question, options = {}) => {
66
- return await this.prompt(question, options);
67
- };
68
- return askFn;
69
- }
70
- async prompt(question, options) {
71
- const rl = this.createPromptInterface();
72
- let value;
73
- try {
74
- do
75
- try {
76
- const answer = await rl.question(`${question}\n> `);
77
- if (options.schema) value = this.alepha.codec.decode(options.schema, answer ? answer.trim() : void 0);
78
- else value = String(answer.trim());
79
- if (options.validate) options.validate(value);
80
- } catch (error) {
81
- if (error instanceof alepha.AlephaError) {
82
- this.log.error(`${error.message}\n`);
83
- value = void 0;
84
- } else throw error;
85
- }
86
- while (value === void 0);
87
- } finally {
88
- rl.close();
89
- }
90
- return value;
91
- }
92
- createPromptInterface() {
93
- return (0, node_readline_promises.createInterface)({
94
- input: node_process.stdin,
95
- output: node_process.stdout
96
- });
97
- }
98
- };
99
-
100
- //#endregion
101
- //#region src/command/helpers/PrettyPrint.ts
102
- var PrettyPrint = class {
103
- dateTimeProvider = (0, alepha.$inject)(alepha_datetime.DateTimeProvider);
104
- spinnerInterval;
105
- frames = [
106
- "⠋",
107
- "⠙",
108
- "⠹",
109
- "⠸",
110
- "⠼",
111
- "⠴",
112
- "⠦",
113
- "⠧",
114
- "⠇",
115
- "⠏"
116
- ];
117
- tasks = /* @__PURE__ */ new Map();
118
- lastLineCount = 0;
119
- header;
120
- commandStartTime;
121
- colors = {
122
- reset: "\x1B[0m",
123
- cyan: "\x1B[36m",
124
- green: "\x1B[32m",
125
- red: "\x1B[31m",
126
- dim: "\x1B[2m"
127
- };
128
- /**
129
- * Start a new command session with header
130
- */
131
- startCommand(cliName, commandName) {
132
- this.header = commandName ? `${cliName} ${commandName}` : cliName;
133
- this.commandStartTime = Date.now();
134
- this.tasks.clear();
135
- this.lastLineCount = 0;
136
- process.stdout.write(`┌─ ${this.header}\n`);
137
- }
138
- /**
139
- * End the command session with footer
140
- */
141
- endCommand() {
142
- if (this.commandStartTime) {
143
- const totalDuration = ((Date.now() - this.commandStartTime) / 1e3).toFixed(1);
144
- process.stdout.write(`└─ Done in ${totalDuration}s\n`);
145
- }
146
- this.header = void 0;
147
- this.commandStartTime = void 0;
148
- }
149
- /**
150
- * Start an animated spinner with a task name
151
- */
152
- startSpinner(id, taskName) {
153
- this.tasks.set(id, {
154
- taskName,
155
- frameIndex: 0,
156
- status: "running"
157
- });
158
- if (!this.spinnerInterval) this.spinnerInterval = this.dateTimeProvider.createInterval(() => this.updateDisplay(), 80, true);
159
- this.updateDisplay();
160
- }
161
- /**
162
- * Stop the spinner and show success with a tick
163
- */
164
- success(id, taskName, duration) {
165
- const task = this.tasks.get(id);
166
- if (task) {
167
- task.status = "success";
168
- if (taskName) task.taskName = taskName;
169
- if (duration) task.duration = duration;
170
- this.updateDisplay();
171
- }
172
- this.checkIfAllDone();
173
- }
174
- /**
175
- * Stop the spinner and show error with a cross
176
- */
177
- error(id, taskName) {
178
- const task = this.tasks.get(id);
179
- if (task) {
180
- task.status = "error";
181
- if (taskName) task.taskName = taskName;
182
- this.updateDisplay();
183
- }
184
- this.checkIfAllDone();
185
- }
186
- /**
187
- * Update the display for all tasks
188
- */
189
- updateDisplay() {
190
- if (this.lastLineCount > 0) for (let i = 0; i < this.lastLineCount; i++) process.stdout.write("\x1B[1A\x1B[2K");
191
- const taskArray = Array.from(this.tasks.values());
192
- const prefix = this.header ? "│ " : "";
193
- for (const task of taskArray) {
194
- let line = prefix;
195
- if (task.status === "running") {
196
- const frame = this.frames[task.frameIndex];
197
- line += `${this.colors.cyan}${frame}${this.colors.reset} ${this.colors.dim}${task.taskName}${this.colors.reset}`;
198
- task.frameIndex = (task.frameIndex + 1) % this.frames.length;
199
- } else if (task.status === "success") {
200
- const durationStr = task.duration ? ` ${this.colors.dim}${task.duration}${this.colors.reset}` : "";
201
- line += `${this.colors.green}✓${this.colors.reset} ${task.taskName}${durationStr}`;
202
- } else if (task.status === "error") line += `${this.colors.red}✗${this.colors.reset} ${task.taskName}`;
203
- process.stdout.write(`${line}\n`);
204
- }
205
- this.lastLineCount = taskArray.length;
206
- }
207
- /**
208
- * Check if all tasks are done and stop the interval
209
- */
210
- checkIfAllDone() {
211
- if (!Array.from(this.tasks.values()).some((task) => task.status === "running") && this.spinnerInterval) {
212
- this.dateTimeProvider.clearInterval(this.spinnerInterval);
213
- this.spinnerInterval = void 0;
214
- }
215
- }
216
- /**
217
- * Stop the spinner without showing any symbol
218
- */
219
- stopSpinner() {
220
- if (this.spinnerInterval) {
221
- this.dateTimeProvider.clearInterval(this.spinnerInterval);
222
- this.spinnerInterval = void 0;
223
- }
224
- }
225
- /**
226
- * Clear all tasks
227
- */
228
- clear() {
229
- this.tasks.clear();
230
- this.stopSpinner();
231
- this.lastLineCount = 0;
232
- }
233
- };
234
-
235
- //#endregion
236
- //#region src/command/errors/CommandError.ts
237
- var CommandError = class extends alepha.AlephaError {
238
- name = "CommandError";
239
- };
240
-
241
- //#endregion
242
- //#region src/command/helpers/Runner.ts
243
- var Runner = class {
244
- log = (0, alepha_logger.$logger)();
245
- timers = [];
246
- startTime = Date.now();
247
- prettyPrint = (0, alepha.$inject)(PrettyPrint);
248
- alepha = (0, alepha.$inject)(alepha.Alepha);
249
- run;
250
- cliName = "";
251
- commandName = "";
252
- firstTaskStarted = false;
253
- constructor() {
254
- this.run = this.createRunMethod();
255
- }
256
- get useDynamicLogger() {
257
- if (this.alepha.isCI()) return false;
258
- return this.alepha.env.LOG_FORMAT === "raw";
259
- }
260
- /**
261
- * Start a new command session with header (for pretty print mode)
262
- */
263
- startCommand(cliName, commandName) {
264
- this.cliName = cliName;
265
- this.commandName = commandName;
266
- }
267
- createRunMethod() {
268
- const runFn = async (cmd, options) => {
269
- if (this.useDynamicLogger && !this.firstTaskStarted) this.prettyPrint.startCommand(this.cliName, this.commandName);
270
- this.firstTaskStarted = true;
271
- if (Array.isArray(cmd)) return await this.execute(cmd.map((it) => typeof it === "string" ? {
272
- name: it,
273
- handler: () => this.exec(it)
274
- } : it));
275
- const name = (typeof options === "object" ? options.alias : void 0) ?? (typeof cmd === "string" ? cmd : cmd.name);
276
- const handler = typeof options === "function" ? options : typeof cmd === "string" ? () => this.exec(cmd) : cmd.handler;
277
- return await this.execute({
278
- name,
279
- handler
280
- });
281
- };
282
- runFn.rm = async (files, options = {}) => {
283
- if (Array.isArray(files) || files.includes("*")) return runFn({
284
- name: options.alias ?? `rm -rf ${Array.isArray(files) ? files.join(" ") : files}`,
285
- handler: async () => {
286
- for await (const file of (0, node_fs_promises.glob)(files)) {
287
- this.log.trace(`Removing ${file}`);
288
- await (0, node_fs_promises.rm)(file, {
289
- recursive: true,
290
- force: true
291
- });
292
- }
293
- }
294
- });
295
- this.log.trace(`Removing ${files}`);
296
- return runFn({
297
- name: options.alias ?? `rm -rf ${files}`,
298
- handler: () => (0, node_fs_promises.rm)(files, {
299
- recursive: true,
300
- force: true
301
- })
302
- });
303
- };
304
- runFn.cp = async (source, dist, options = {}) => {
305
- this.log.trace(`Copying ${source} to ${dist}`);
306
- return runFn({
307
- name: options.alias ?? `cp -r ${source} ${dist}`,
308
- handler: () => (0, node_fs_promises.cp)(source, dist, { recursive: true })
309
- }, options);
310
- };
311
- return runFn;
312
- }
313
- async exec(cmd) {
314
- return await new Promise((resolve, reject) => {
315
- (0, node_child_process.exec)(cmd, { env: {
316
- ...process.env,
317
- LOG_FORMAT: "pretty"
318
- } }, (err, stdout) => {
319
- if (err) {
320
- err.stdout = stdout;
321
- reject(err);
322
- } else resolve(stdout);
323
- });
324
- });
325
- }
326
- /**
327
- * Executes one or more tasks.
328
- *
329
- * @param task - A single task or an array of tasks to run in parallel.
330
- */
331
- async execute(task) {
332
- if (Array.isArray(task)) {
333
- await Promise.all(task.map((t$2) => this.executeTask(t$2)));
334
- return "";
335
- } else return await this.executeTask(task);
336
- }
337
- /**
338
- * Prints a summary of all executed tasks and their durations.
339
- */
340
- summary() {
341
- if (this.useDynamicLogger && this.firstTaskStarted) {
342
- this.prettyPrint.endCommand();
343
- return;
344
- }
345
- if (this.timers.length === 0) return;
346
- this.log.info("");
347
- const totalTime = ((Date.now() - this.startTime) / 1e3).toFixed(1);
348
- this.log.info(`Total time: ${totalTime}s`);
349
- this.log.info(``);
350
- }
351
- async executeTask(task) {
352
- const now = Date.now();
353
- const taskId = task.name;
354
- if (this.useDynamicLogger) this.prettyPrint.startSpinner(taskId, task.name);
355
- else this.log.info(`Starting '${task.name}' ...`);
356
- let stdout = "";
357
- try {
358
- stdout = String(await task.handler() ?? "");
359
- } catch (error) {
360
- if (this.useDynamicLogger) this.prettyPrint.error(taskId, task.name);
361
- if (error instanceof Error && "stdout" in error) this.log.info(`\n\n${error.stdout}`);
362
- throw new CommandError(`Task '${task.name}' failed`, { cause: error });
363
- }
364
- if (stdout) this.log.trace(stdout);
365
- const duration = ((Date.now() - now) / 1e3).toFixed(1);
366
- if (this.useDynamicLogger) this.prettyPrint.success(taskId, task.name, `${duration}s`);
367
- else this.log.info(`Finished '${task.name}' after ${duration}s`);
368
- this.timers.push({
369
- name: task.name,
370
- duration: `${duration}s`
371
- });
372
- return stdout;
373
- }
374
- renderTable(data) {
375
- if (data.length === 0) return;
376
- const col1Width = Math.max(...data.map(([col1]) => col1.length), 7);
377
- const col2Width = Math.max(...data.map(([, col2]) => col2.length), 8);
378
- const divider = `+${"-".repeat(col1Width + 2)}+${"-".repeat(col2Width + 2)}+`;
379
- this.log.info(divider);
380
- this.log.info(`| ${"Command".padEnd(col1Width)} | ${"Duration".padEnd(col2Width)} |`);
381
- this.log.info(divider);
382
- for (const [col1, col2] of data) this.log.info(`| ${col1.padEnd(col1Width)} | ${col2.padEnd(col2Width)} |`);
383
- this.log.info(divider);
384
- }
385
- };
386
-
387
- //#endregion
388
- //#region src/command/providers/CliProvider.ts
389
- const envSchema = alepha.t.object({
390
- CLI_NAME: alepha.t.text({
391
- default: "cli",
392
- description: "Name of the CLI application."
393
- }),
394
- CLI_DESCRIPTION: alepha.t.text({
395
- default: "",
396
- description: "Description of the CLI application."
397
- })
398
- });
399
- /**
400
- * CLI provider configuration atom
401
- */
402
- const cliOptions = (0, alepha.$atom)({
403
- name: "alepha.command.cli.options",
404
- schema: alepha.t.object({
405
- name: alepha.t.optional(alepha.t.string({ description: "Name of the CLI application." })),
406
- description: alepha.t.optional(alepha.t.string({ description: "Description of the CLI application." })),
407
- argv: alepha.t.optional(alepha.t.array(alepha.t.string(), { description: "Command line arguments to parse." }))
408
- }),
409
- default: {}
410
- });
411
- var CliProvider = class {
412
- env = (0, alepha.$env)(envSchema);
413
- alepha = (0, alepha.$inject)(alepha.Alepha);
414
- log = (0, alepha_logger.$logger)();
415
- runner = (0, alepha.$inject)(Runner);
416
- asker = (0, alepha.$inject)(Asker);
417
- options = (0, alepha.$use)(cliOptions);
418
- get name() {
419
- return this.options.name || this.env.CLI_NAME;
420
- }
421
- get description() {
422
- return this.options.description || this.env.CLI_DESCRIPTION;
423
- }
424
- get argv() {
425
- return this.options.argv || (typeof process !== "undefined" ? process.argv.slice(2) : []);
426
- }
427
- globalFlags = { help: {
428
- aliases: ["h", "help"],
429
- description: "Show this help message",
430
- schema: alepha.t.boolean()
431
- } };
432
- onReady = (0, alepha.$hook)({
433
- on: "ready",
434
- handler: async () => {
435
- const argv = [...this.argv];
436
- const commandName = argv.find((arg) => !arg.startsWith("-")) ?? "";
437
- let command = this.findCommand(commandName);
438
- if (this.parseFlags(argv, Object.entries(this.getAllGlobalFlags()).map(([key, value]) => ({
439
- key,
440
- ...value
441
- }))).help) {
442
- this.printHelp(command);
443
- return;
444
- }
445
- if (!command) {
446
- const rootCommand = this.findCommand("");
447
- if (rootCommand?.options.args) command = rootCommand;
448
- else {
449
- if (commandName !== "") {
450
- this.log.error(`Unknown command: '${commandName}'`);
451
- this.printHelp();
452
- }
453
- return;
454
- }
455
- }
456
- const commandFlags = this.parseCommandFlags(argv, command.flags);
457
- const commandArgs = this.parseCommandArgs(argv, command.options.args);
458
- await this.alepha.context.run(async () => {
459
- this.log.debug(`Executing command '${command.name}'...`, {
460
- flags: commandFlags,
461
- args: commandArgs
462
- });
463
- const runner = this.runner;
464
- runner.startCommand(this.name, command.name);
465
- const args = {
466
- flags: commandFlags,
467
- args: commandArgs,
468
- run: runner.run,
469
- ask: this.asker.ask,
470
- fs: node_fs_promises,
471
- glob: node_fs_promises.glob,
472
- root: process.cwd()
473
- };
474
- await command.options.handler(args);
475
- if (command.options.summary !== false) runner.summary();
476
- this.log.debug(`Command '${command.name}' executed successfully.`);
477
- });
478
- }
479
- });
480
- get commands() {
481
- return this.alepha.descriptors($command);
482
- }
483
- findCommand(name) {
484
- return this.commands.find((command) => command.name === name || command.aliases.includes(name));
485
- }
486
- /**
487
- * Get all global flags including those from the root command (name === "")
488
- */
489
- getAllGlobalFlags() {
490
- const rootCommand = this.commands.find((cmd) => cmd.name === "");
491
- const allGlobalFlags = { ...this.globalFlags };
492
- if (rootCommand) for (const [key, value] of Object.entries(rootCommand.flags.properties)) allGlobalFlags[key] = {
493
- aliases: [key, ...value.aliases ?? (value.alias ? [value.alias] : void 0) ?? []],
494
- description: value.description,
495
- schema: value
496
- };
497
- return allGlobalFlags;
498
- }
499
- parseCommandFlags(argv, schema) {
500
- const flagDefs = Object.entries(schema.properties).map(([key, value]) => ({
501
- key,
502
- aliases: [key, ...value.aliases ?? (value.alias ? [value.alias] : void 0) ?? []],
503
- description: value.description,
504
- schema: value
505
- }));
506
- const parsed = this.parseFlags(argv, flagDefs);
507
- for (const [key, value] of Object.entries(schema.properties)) if (!(key in parsed) && alepha.t.schema.isOptional(value)) {
508
- const innerSchema = value;
509
- if (innerSchema && "default" in innerSchema) parsed[key] = innerSchema.default;
510
- }
511
- try {
512
- return this.alepha.codec.decode(schema, parsed);
513
- } catch (error) {
514
- if (error instanceof alepha.TypeBoxError) throw new CommandError(`Invalid flag: ${error.cause.instancePath || "command"} ${error.cause.message}`);
515
- throw error;
516
- }
517
- }
518
- parseFlags(argv, flagDefs) {
519
- const result = {};
520
- for (const arg of argv.filter((a) => a.startsWith("-"))) {
521
- const [rawKey, ...valueParts] = arg.replace(/^-{1,2}/, "").split("=");
522
- const value = valueParts.join("=");
523
- const def = flagDefs.find((d) => d.aliases.includes(rawKey));
524
- if (!def) continue;
525
- if (alepha.t.schema.isBoolean(def.schema)) result[def.key] = true;
526
- else if (value) try {
527
- if (alepha.t.schema.isObject(def.schema) || alepha.t.schema.isArray(def.schema)) result[def.key] = JSON.parse(value);
528
- else result[def.key] = value;
529
- } catch {
530
- throw new CommandError(`Invalid JSON value for flag --${rawKey}`);
531
- }
532
- else throw new CommandError(`Flag --${rawKey} requires a value.`);
533
- }
534
- return result;
535
- }
536
- parseCommandArgs(argv, schema) {
537
- if (!schema) return;
538
- const argsOnly = argv.filter((arg) => !arg.startsWith("-")).slice(1);
539
- try {
540
- if (alepha.t.schema.isOptional(schema)) {
541
- if (argsOnly.length === 0) return;
542
- return this.parseArgumentValue(argsOnly[0], schema);
543
- } else if (alepha.t.schema.isTuple(schema) && schema.items) {
544
- const result = [];
545
- const items = schema.items;
546
- for (let i = 0; i < items.length; i++) {
547
- const itemSchema = items[i];
548
- if (i < argsOnly.length) result.push(this.parseArgumentValue(argsOnly[i], itemSchema));
549
- else if (alepha.t.schema.isOptional(itemSchema)) result.push(void 0);
550
- else throw new CommandError(`Missing required argument at position ${i + 1}`);
551
- }
552
- return result;
553
- } else {
554
- if (argsOnly.length === 0) throw new CommandError("Missing required argument");
555
- return this.parseArgumentValue(argsOnly[0], schema);
556
- }
557
- } catch (error) {
558
- if (error instanceof alepha.TypeBoxError) throw new CommandError(`Invalid argument: ${error.value.message}`);
559
- throw error;
560
- }
561
- }
562
- parseArgumentValue(value, schema) {
563
- if (alepha.t.schema.isString(schema)) return value;
564
- if (alepha.t.schema.isNumber(schema) || alepha.t.schema.isInteger(schema)) {
565
- const num = Number(value);
566
- if (Number.isNaN(num)) throw new CommandError(`Expected number, got "${value}"`);
567
- if (alepha.t.schema.isInteger(schema) && !Number.isInteger(num)) throw new CommandError(`Expected integer, got "${value}"`);
568
- return num;
569
- }
570
- if (alepha.t.schema.isBoolean(schema)) {
571
- const lower = value.toLowerCase();
572
- if (lower === "true" || lower === "1") return true;
573
- if (lower === "false" || lower === "0") return false;
574
- throw new CommandError(`Expected boolean, got "${value}"`);
575
- }
576
- return value;
577
- }
578
- generateArgsUsage(schema) {
579
- if (!schema) return "";
580
- if (alepha.t.schema.isOptional(schema)) {
581
- const typeName$1 = this.getTypeName(schema);
582
- return ` [${"title" in schema ? schema.title : "arg1"}${typeName$1}]`;
583
- }
584
- if (alepha.t.schema.isTuple(schema) && schema.items) return ` ${schema.items.map((item, index) => {
585
- const argName = `arg${index + 1}`;
586
- const typeName$1 = this.getTypeName(item);
587
- if (alepha.t.schema.isOptional(item)) return `[${argName}${typeName$1}]`;
588
- return `<${argName}${typeName$1}>`;
589
- }).join(" ")}`;
590
- const typeName = this.getTypeName(schema);
591
- return ` <${"title" in schema ? schema.title : "arg1"}${typeName}>`;
592
- }
593
- getTypeName(schema) {
594
- if (!schema) return "";
595
- if (alepha.t.schema.isString(schema)) return "";
596
- if (alepha.t.schema.isNumber(schema)) return ": number";
597
- if (alepha.t.schema.isInteger(schema)) return ": integer";
598
- if (alepha.t.schema.isBoolean(schema)) return ": boolean";
599
- return "";
600
- }
601
- printHelp(command) {
602
- const cliName = this.name || "cli";
603
- this.log.info("");
604
- if (command?.name) {
605
- const argsUsage = this.generateArgsUsage(command.options.args);
606
- const usage = `${cliName} ${command.name}${argsUsage}`.trim();
607
- this.log.info(`Usage: \`${usage}\``);
608
- if (command.options.description) {
609
- this.log.info(``);
610
- this.log.info(`\t${command.options.description}`);
611
- }
612
- this.log.info("");
613
- this.log.info("Flags:");
614
- const flags = [...Object.entries(command.flags.properties).map(([key, value]) => ({
615
- key,
616
- schema: value,
617
- aliases: value.alias ?? [key],
618
- description: value.description
619
- })), ...Object.entries(this.getAllGlobalFlags()).map(([key, value]) => ({
620
- key,
621
- ...value
622
- }))];
623
- const maxFlagLength = this.getMaxFlagLength(flags);
624
- for (const { aliases, description } of flags) {
625
- const flagStr = (Array.isArray(aliases) ? aliases : [aliases]).map((a) => a.length === 1 ? `-${a}` : `--${a}`).join(", ");
626
- this.log.info(` ${flagStr.padEnd(maxFlagLength)} # ${description ?? ""}`);
627
- }
628
- } else {
629
- this.log.info(this.description || "Available commands:");
630
- this.log.info("");
631
- this.log.info("Commands:");
632
- const maxCmdLength = this.getMaxCmdLength(this.commands);
633
- for (const command$1 of this.commands) {
634
- if (command$1.name === "") continue;
635
- const fullCmdStr = `${[command$1.name, ...command$1.aliases].join(", ")}${this.generateArgsUsage(command$1.options.args)}`;
636
- this.log.info(` ${cliName} ${fullCmdStr.padEnd(maxCmdLength)} # ${command$1.options.description ?? ""}`);
637
- }
638
- this.log.info("");
639
- this.log.info("Flags:");
640
- const globalFlags = Object.values(this.getAllGlobalFlags());
641
- const maxFlagLength = this.getMaxFlagLength(globalFlags);
642
- for (const { aliases, description } of globalFlags) {
643
- const flagStr = aliases.map((a) => a.length === 1 ? `-${a}` : `--${a}`).join(", ");
644
- this.log.info(` ${flagStr.padEnd(maxFlagLength)} # ${description ?? ""}`);
645
- }
646
- }
647
- this.log.info("");
648
- }
649
- getMaxCmdLength(commands) {
650
- return Math.max(...commands.map((c) => {
651
- return `${[c.name, ...c.aliases].join(", ")}${this.generateArgsUsage(c.options.args)}`.length;
652
- }));
653
- }
654
- getMaxFlagLength(flags) {
655
- return Math.max(...flags.map((f) => {
656
- return (Array.isArray(f.aliases) ? f.aliases : [f.aliases]).map((a) => a.length === 1 ? `-${a}` : `--${a}`).join(", ").length;
657
- }));
658
- }
659
- };
660
-
661
- //#endregion
662
- //#region src/command/index.ts
663
- /**
664
- * This module provides a powerful way to build command-line interfaces
665
- * directly within your Alepha application, using declarative descriptors.
666
- *
667
- * It allows you to define commands using the `$command` descriptor.
668
- *
669
- * @see {@link $command}
670
- * @module alepha.command
671
- */
672
- const AlephaCommand = (0, alepha.$module)({
673
- name: "alepha.command",
674
- descriptors: [$command],
675
- services: [
676
- CliProvider,
677
- Runner,
678
- Asker,
679
- PrettyPrint
680
- ]
681
- });
682
-
683
- //#endregion
684
- exports.$command = $command;
685
- exports.AlephaCommand = AlephaCommand;
686
- exports.Asker = Asker;
687
- exports.CliProvider = CliProvider;
688
- exports.CommandDescriptor = CommandDescriptor;
689
- exports.CommandError = CommandError;
690
- exports.PrettyPrint = PrettyPrint;
691
- exports.Runner = Runner;
692
- exports.cliOptions = cliOptions;
693
- //# sourceMappingURL=index.cjs.map