alepha 0.14.4 → 0.15.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 (277) hide show
  1. package/README.md +1 -4
  2. package/dist/api/audits/index.d.ts +619 -731
  3. package/dist/api/audits/index.d.ts.map +1 -1
  4. package/dist/api/files/index.d.ts +185 -298
  5. package/dist/api/files/index.d.ts.map +1 -1
  6. package/dist/api/files/index.js +0 -1
  7. package/dist/api/files/index.js.map +1 -1
  8. package/dist/api/jobs/index.d.ts +245 -356
  9. package/dist/api/jobs/index.d.ts.map +1 -1
  10. package/dist/api/notifications/index.d.ts +238 -350
  11. package/dist/api/notifications/index.d.ts.map +1 -1
  12. package/dist/api/parameters/index.d.ts +499 -611
  13. package/dist/api/parameters/index.d.ts.map +1 -1
  14. package/dist/api/users/index.browser.js +1 -2
  15. package/dist/api/users/index.browser.js.map +1 -1
  16. package/dist/api/users/index.d.ts +1697 -1804
  17. package/dist/api/users/index.d.ts.map +1 -1
  18. package/dist/api/users/index.js +178 -151
  19. package/dist/api/users/index.js.map +1 -1
  20. package/dist/api/verifications/index.d.ts +132 -132
  21. package/dist/api/verifications/index.d.ts.map +1 -1
  22. package/dist/batch/index.d.ts +122 -122
  23. package/dist/batch/index.d.ts.map +1 -1
  24. package/dist/batch/index.js +1 -2
  25. package/dist/batch/index.js.map +1 -1
  26. package/dist/bucket/index.d.ts +163 -163
  27. package/dist/bucket/index.d.ts.map +1 -1
  28. package/dist/cache/core/index.d.ts +46 -46
  29. package/dist/cache/core/index.d.ts.map +1 -1
  30. package/dist/cache/redis/index.d.ts.map +1 -1
  31. package/dist/cli/index.d.ts +302 -299
  32. package/dist/cli/index.d.ts.map +1 -1
  33. package/dist/cli/index.js +966 -564
  34. package/dist/cli/index.js.map +1 -1
  35. package/dist/command/index.d.ts +303 -299
  36. package/dist/command/index.d.ts.map +1 -1
  37. package/dist/command/index.js +11 -7
  38. package/dist/command/index.js.map +1 -1
  39. package/dist/core/index.browser.js +419 -99
  40. package/dist/core/index.browser.js.map +1 -1
  41. package/dist/core/index.d.ts +718 -625
  42. package/dist/core/index.d.ts.map +1 -1
  43. package/dist/core/index.js +420 -99
  44. package/dist/core/index.js.map +1 -1
  45. package/dist/core/index.native.js +419 -99
  46. package/dist/core/index.native.js.map +1 -1
  47. package/dist/datetime/index.d.ts +44 -44
  48. package/dist/datetime/index.d.ts.map +1 -1
  49. package/dist/datetime/index.js +4 -4
  50. package/dist/datetime/index.js.map +1 -1
  51. package/dist/email/index.d.ts +97 -50
  52. package/dist/email/index.d.ts.map +1 -1
  53. package/dist/email/index.js +129 -33
  54. package/dist/email/index.js.map +1 -1
  55. package/dist/fake/index.d.ts +7981 -14
  56. package/dist/fake/index.d.ts.map +1 -1
  57. package/dist/file/index.d.ts +523 -390
  58. package/dist/file/index.d.ts.map +1 -1
  59. package/dist/file/index.js +253 -1
  60. package/dist/file/index.js.map +1 -1
  61. package/dist/lock/core/index.d.ts +208 -208
  62. package/dist/lock/core/index.d.ts.map +1 -1
  63. package/dist/lock/redis/index.d.ts.map +1 -1
  64. package/dist/logger/index.d.ts +25 -26
  65. package/dist/logger/index.d.ts.map +1 -1
  66. package/dist/mcp/index.d.ts +197 -197
  67. package/dist/mcp/index.d.ts.map +1 -1
  68. package/dist/orm/chunk-DtkW-qnP.js +38 -0
  69. package/dist/orm/index.browser.js.map +1 -1
  70. package/dist/orm/index.bun.js +2814 -0
  71. package/dist/orm/index.bun.js.map +1 -0
  72. package/dist/orm/index.d.ts +1205 -1057
  73. package/dist/orm/index.d.ts.map +1 -1
  74. package/dist/orm/index.js +2056 -1753
  75. package/dist/orm/index.js.map +1 -1
  76. package/dist/queue/core/index.d.ts +248 -248
  77. package/dist/queue/core/index.d.ts.map +1 -1
  78. package/dist/queue/redis/index.d.ts.map +1 -1
  79. package/dist/redis/index.bun.js +285 -0
  80. package/dist/redis/index.bun.js.map +1 -0
  81. package/dist/redis/index.d.ts +118 -136
  82. package/dist/redis/index.d.ts.map +1 -1
  83. package/dist/redis/index.js +18 -38
  84. package/dist/redis/index.js.map +1 -1
  85. package/dist/retry/index.d.ts +69 -69
  86. package/dist/retry/index.d.ts.map +1 -1
  87. package/dist/router/index.d.ts +6 -6
  88. package/dist/router/index.d.ts.map +1 -1
  89. package/dist/scheduler/index.d.ts +25 -25
  90. package/dist/scheduler/index.d.ts.map +1 -1
  91. package/dist/security/index.browser.js +5 -1
  92. package/dist/security/index.browser.js.map +1 -1
  93. package/dist/security/index.d.ts +417 -254
  94. package/dist/security/index.d.ts.map +1 -1
  95. package/dist/security/index.js +386 -86
  96. package/dist/security/index.js.map +1 -1
  97. package/dist/server/auth/index.d.ts +277 -277
  98. package/dist/server/auth/index.d.ts.map +1 -1
  99. package/dist/server/auth/index.js +20 -20
  100. package/dist/server/auth/index.js.map +1 -1
  101. package/dist/server/cache/index.d.ts +60 -57
  102. package/dist/server/cache/index.d.ts.map +1 -1
  103. package/dist/server/cache/index.js +1 -1
  104. package/dist/server/cache/index.js.map +1 -1
  105. package/dist/server/compress/index.d.ts +3 -3
  106. package/dist/server/compress/index.d.ts.map +1 -1
  107. package/dist/server/cookies/index.d.ts +6 -6
  108. package/dist/server/cookies/index.d.ts.map +1 -1
  109. package/dist/server/cookies/index.js +3 -3
  110. package/dist/server/cookies/index.js.map +1 -1
  111. package/dist/server/core/index.d.ts +242 -150
  112. package/dist/server/core/index.d.ts.map +1 -1
  113. package/dist/server/core/index.js +288 -122
  114. package/dist/server/core/index.js.map +1 -1
  115. package/dist/server/cors/index.d.ts +11 -12
  116. package/dist/server/cors/index.d.ts.map +1 -1
  117. package/dist/server/health/index.d.ts +0 -1
  118. package/dist/server/health/index.d.ts.map +1 -1
  119. package/dist/server/helmet/index.d.ts +2 -2
  120. package/dist/server/helmet/index.d.ts.map +1 -1
  121. package/dist/server/links/index.browser.js.map +1 -1
  122. package/dist/server/links/index.d.ts +84 -85
  123. package/dist/server/links/index.d.ts.map +1 -1
  124. package/dist/server/links/index.js +1 -2
  125. package/dist/server/links/index.js.map +1 -1
  126. package/dist/server/metrics/index.d.ts.map +1 -1
  127. package/dist/server/multipart/index.d.ts +6 -6
  128. package/dist/server/multipart/index.d.ts.map +1 -1
  129. package/dist/server/proxy/index.d.ts +102 -103
  130. package/dist/server/proxy/index.d.ts.map +1 -1
  131. package/dist/server/rate-limit/index.d.ts +16 -16
  132. package/dist/server/rate-limit/index.d.ts.map +1 -1
  133. package/dist/server/static/index.d.ts +44 -44
  134. package/dist/server/static/index.d.ts.map +1 -1
  135. package/dist/server/swagger/index.d.ts +48 -49
  136. package/dist/server/swagger/index.d.ts.map +1 -1
  137. package/dist/server/swagger/index.js +1 -2
  138. package/dist/server/swagger/index.js.map +1 -1
  139. package/dist/sms/index.d.ts +13 -11
  140. package/dist/sms/index.d.ts.map +1 -1
  141. package/dist/sms/index.js +7 -7
  142. package/dist/sms/index.js.map +1 -1
  143. package/dist/thread/index.d.ts +71 -72
  144. package/dist/thread/index.d.ts.map +1 -1
  145. package/dist/topic/core/index.d.ts +318 -318
  146. package/dist/topic/core/index.d.ts.map +1 -1
  147. package/dist/topic/redis/index.d.ts +6 -6
  148. package/dist/topic/redis/index.d.ts.map +1 -1
  149. package/dist/vite/index.d.ts +5720 -159
  150. package/dist/vite/index.d.ts.map +1 -1
  151. package/dist/vite/index.js +41 -18
  152. package/dist/vite/index.js.map +1 -1
  153. package/dist/websocket/index.browser.js +6 -6
  154. package/dist/websocket/index.browser.js.map +1 -1
  155. package/dist/websocket/index.d.ts +247 -247
  156. package/dist/websocket/index.d.ts.map +1 -1
  157. package/dist/websocket/index.js +6 -6
  158. package/dist/websocket/index.js.map +1 -1
  159. package/package.json +9 -14
  160. package/src/api/files/controllers/AdminFileStatsController.ts +0 -1
  161. package/src/api/users/atoms/realmAuthSettingsAtom.ts +5 -0
  162. package/src/api/users/controllers/{UserRealmController.ts → RealmController.ts} +11 -11
  163. package/src/api/users/entities/users.ts +1 -1
  164. package/src/api/users/index.ts +8 -8
  165. package/src/api/users/primitives/{$userRealm.ts → $realm.ts} +17 -19
  166. package/src/api/users/providers/{UserRealmProvider.ts → RealmProvider.ts} +26 -30
  167. package/src/api/users/schemas/{userRealmConfigSchema.ts → realmConfigSchema.ts} +2 -2
  168. package/src/api/users/services/CredentialService.ts +7 -7
  169. package/src/api/users/services/IdentityService.ts +4 -4
  170. package/src/api/users/services/RegistrationService.spec.ts +25 -27
  171. package/src/api/users/services/RegistrationService.ts +38 -27
  172. package/src/api/users/services/SessionCrudService.ts +3 -3
  173. package/src/api/users/services/SessionService.spec.ts +3 -3
  174. package/src/api/users/services/SessionService.ts +28 -9
  175. package/src/api/users/services/UserService.ts +7 -7
  176. package/src/batch/providers/BatchProvider.ts +1 -2
  177. package/src/cli/apps/AlephaPackageBuilderCli.ts +38 -19
  178. package/src/cli/assets/apiHelloControllerTs.ts +18 -0
  179. package/src/cli/assets/apiIndexTs.ts +16 -0
  180. package/src/cli/assets/claudeMd.ts +303 -0
  181. package/src/cli/assets/mainBrowserTs.ts +2 -2
  182. package/src/cli/assets/mainServerTs.ts +24 -0
  183. package/src/cli/assets/webAppRouterTs.ts +15 -0
  184. package/src/cli/assets/webHelloComponentTsx.ts +16 -0
  185. package/src/cli/assets/webIndexTs.ts +16 -0
  186. package/src/cli/commands/build.ts +41 -21
  187. package/src/cli/commands/db.ts +21 -18
  188. package/src/cli/commands/deploy.ts +17 -5
  189. package/src/cli/commands/dev.ts +13 -17
  190. package/src/cli/commands/format.ts +8 -2
  191. package/src/cli/commands/init.ts +74 -29
  192. package/src/cli/commands/lint.ts +8 -2
  193. package/src/cli/commands/test.ts +8 -2
  194. package/src/cli/commands/typecheck.ts +5 -1
  195. package/src/cli/commands/verify.ts +4 -2
  196. package/src/cli/services/AlephaCliUtils.ts +39 -600
  197. package/src/cli/services/PackageManagerUtils.ts +301 -0
  198. package/src/cli/services/ProjectScaffolder.ts +306 -0
  199. package/src/command/helpers/Runner.ts +15 -3
  200. package/src/core/__tests__/Alepha-graph.spec.ts +4 -0
  201. package/src/core/index.shared.ts +1 -0
  202. package/src/core/index.ts +2 -0
  203. package/src/core/primitives/$hook.ts +6 -2
  204. package/src/core/primitives/$module.spec.ts +4 -0
  205. package/src/core/providers/AlsProvider.ts +1 -1
  206. package/src/core/providers/CodecManager.spec.ts +12 -6
  207. package/src/core/providers/CodecManager.ts +26 -6
  208. package/src/core/providers/EventManager.ts +169 -13
  209. package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +621 -0
  210. package/src/core/providers/KeylessJsonSchemaCodec.ts +407 -0
  211. package/src/core/providers/StateManager.spec.ts +27 -16
  212. package/src/email/providers/LocalEmailProvider.spec.ts +111 -87
  213. package/src/email/providers/LocalEmailProvider.ts +52 -15
  214. package/src/email/providers/NodemailerEmailProvider.ts +167 -56
  215. package/src/file/errors/FileError.ts +7 -0
  216. package/src/file/index.ts +9 -1
  217. package/src/file/providers/MemoryFileSystemProvider.ts +393 -0
  218. package/src/orm/index.browser.ts +1 -19
  219. package/src/orm/index.bun.ts +77 -0
  220. package/src/orm/index.shared-server.ts +22 -0
  221. package/src/orm/index.shared.ts +15 -0
  222. package/src/orm/index.ts +19 -39
  223. package/src/orm/providers/drivers/BunPostgresProvider.ts +3 -5
  224. package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -1
  225. package/src/orm/providers/drivers/CloudflareD1Provider.ts +4 -0
  226. package/src/orm/providers/drivers/DatabaseProvider.ts +4 -0
  227. package/src/orm/providers/drivers/PglitePostgresProvider.ts +4 -0
  228. package/src/orm/services/Repository.ts +8 -0
  229. package/src/redis/index.bun.ts +35 -0
  230. package/src/redis/providers/BunRedisProvider.ts +12 -43
  231. package/src/redis/providers/BunRedisSubscriberProvider.ts +2 -3
  232. package/src/redis/providers/NodeRedisProvider.ts +16 -34
  233. package/src/{server/security → security}/__tests__/BasicAuth.spec.ts +11 -11
  234. package/src/{server/security → security}/__tests__/ServerSecurityProvider-realm.spec.ts +21 -16
  235. package/src/{server/security/providers → security/__tests__}/ServerSecurityProvider.spec.ts +5 -5
  236. package/src/security/index.browser.ts +5 -0
  237. package/src/security/index.ts +90 -7
  238. package/src/security/primitives/{$realm.spec.ts → $issuer.spec.ts} +11 -11
  239. package/src/security/primitives/{$realm.ts → $issuer.ts} +20 -17
  240. package/src/security/primitives/$role.ts +5 -5
  241. package/src/security/primitives/$serviceAccount.spec.ts +5 -5
  242. package/src/security/primitives/$serviceAccount.ts +3 -3
  243. package/src/{server/security → security}/providers/ServerSecurityProvider.ts +5 -7
  244. package/src/server/auth/primitives/$auth.ts +10 -10
  245. package/src/server/auth/primitives/$authCredentials.ts +3 -3
  246. package/src/server/auth/primitives/$authGithub.ts +3 -3
  247. package/src/server/auth/primitives/$authGoogle.ts +3 -3
  248. package/src/server/auth/providers/ServerAuthProvider.ts +13 -13
  249. package/src/server/cache/providers/ServerCacheProvider.ts +1 -1
  250. package/src/server/cookies/providers/ServerCookiesProvider.ts +3 -3
  251. package/src/server/core/providers/NodeHttpServerProvider.ts +25 -6
  252. package/src/server/core/providers/ServerBodyParserProvider.ts +19 -23
  253. package/src/server/core/providers/ServerLoggerProvider.ts +23 -19
  254. package/src/server/core/providers/ServerProvider.ts +144 -21
  255. package/src/server/core/providers/ServerRouterProvider.ts +259 -115
  256. package/src/server/core/providers/ServerTimingProvider.ts +2 -2
  257. package/src/server/links/index.ts +1 -1
  258. package/src/server/links/providers/LinkProvider.ts +1 -1
  259. package/src/server/swagger/index.ts +1 -1
  260. package/src/sms/providers/LocalSmsProvider.spec.ts +153 -111
  261. package/src/sms/providers/LocalSmsProvider.ts +8 -7
  262. package/src/vite/helpers/boot.ts +28 -17
  263. package/src/vite/tasks/buildServer.ts +12 -1
  264. package/src/vite/tasks/devServer.ts +3 -1
  265. package/src/vite/tasks/generateCloudflare.ts +7 -0
  266. package/dist/server/security/index.browser.js +0 -13
  267. package/dist/server/security/index.browser.js.map +0 -1
  268. package/dist/server/security/index.d.ts +0 -173
  269. package/dist/server/security/index.d.ts.map +0 -1
  270. package/dist/server/security/index.js +0 -311
  271. package/dist/server/security/index.js.map +0 -1
  272. package/src/cli/assets/appRouterTs.ts +0 -9
  273. package/src/cli/assets/mainTs.ts +0 -13
  274. package/src/server/security/index.browser.ts +0 -10
  275. package/src/server/security/index.ts +0 -94
  276. /package/src/{server/security → security}/primitives/$basicAuth.ts +0 -0
  277. /package/src/{server/security → security}/providers/ServerBasicAuthProvider.ts +0 -0
@@ -1,9 +1,9 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- import { Validator } from "typebox/compile";
3
2
  import * as typebox0 from "typebox";
4
3
  import { Static as Static$1, StaticDecode, StaticDecode as Static, StaticEncode, StaticEncode as StaticEncode$1, TAny, TAny as TAny$1, TArray, TArray as TArray$1, TArrayOptions, TBigInt, TBoolean, TBoolean as TBoolean$1, TInteger, TInteger as TInteger$1, TInterface, TKeysToIndexer, TKeysToIndexer as TKeysToIndexer$1, TNull, TNull as TNull$1, TNumber, TNumber as TNumber$1, TNumberOptions, TNumberOptions as TNumberOptions$1, TObject, TObject as TObject$1, TObjectOptions, TObjectOptions as TObjectOptions$1, TOmit, TOptional, TOptionalAdd, TOptionalAdd as TOptionalAdd$1, TPartial, TPick, TPick as TPick$1, TProperties, TProperties as TProperties$1, TRecord, TRecord as TRecord$1, TSchema, TSchema as TSchema$1, TSchemaOptions, TString, TString as TString$1, TStringOptions, TStringOptions as TStringOptions$1, TTuple, TUnion, TUnion as TUnion$1, TUnsafe, TUnsafe as TUnsafe$1, TVoid, Type } from "typebox";
5
4
  import Format from "typebox/format";
6
5
  import * as Value from "typebox/value";
6
+ import { Validator } from "typebox/compile";
7
7
  import { TLocalizedValidationError } from "typebox/error";
8
8
  import { Readable } from "node:stream";
9
9
  import { ReadableStream as ReadableStream$1 } from "node:stream/web";
@@ -45,19 +45,19 @@ type AbstractClass<T extends object = any> = abstract new (...args: any[]) => T;
45
45
  */
46
46
  interface ServiceSubstitution<T extends object = any> {
47
47
  /**
48
- * Every time someone asks for this class, it will be provided with the 'use' class.
49
- */
48
+ * Every time someone asks for this class, it will be provided with the 'use' class.
49
+ */
50
50
  provide: Service<T>;
51
51
  /**
52
- * Service to use instead of the 'provide' service.
53
- *
54
- * Syntax is inspired by Angular's DI system.
55
- */
52
+ * Service to use instead of the 'provide' service.
53
+ *
54
+ * Syntax is inspired by Angular's DI system.
55
+ */
56
56
  use: Service<T>;
57
57
  /**
58
- * If true, if the service already exists -> just ignore the substitution and do not throw an error.
59
- * Mostly used for plugins to enforce a substitution without throwing an error.
60
- */
58
+ * If true, if the service already exists -> just ignore the substitution and do not throw an error.
59
+ * Mostly used for plugins to enforce a substitution without throwing an error.
60
+ */
61
61
  optional?: boolean;
62
62
  }
63
63
  /**
@@ -90,8 +90,8 @@ declare abstract class Primitive<T extends object = {}> {
90
90
  readonly config: PrimitiveConfig;
91
91
  constructor(args: PrimitiveArgs<T>);
92
92
  /**
93
- * Called automatically by Alepha after the primitive is created.
94
- */
93
+ * Called automatically by Alepha after the primitive is created.
94
+ */
95
95
  protected onInit(): void;
96
96
  }
97
97
  type PrimitiveFactory<TPrimitive extends Primitive = Primitive> = {
@@ -155,55 +155,55 @@ interface TypeBoxErrorParams {
155
155
  //#region ../../src/core/helpers/FileLike.d.ts
156
156
  interface FileLike {
157
157
  /**
158
- * Filename.
159
- * @default "file"
160
- */
158
+ * Filename.
159
+ * @default "file"
160
+ */
161
161
  name: string;
162
162
  /**
163
- * Mandatory MIME type of the file.
164
- * @default "application/octet-stream"
165
- */
163
+ * Mandatory MIME type of the file.
164
+ * @default "application/octet-stream"
165
+ */
166
166
  type: string;
167
167
  /**
168
- * Size of the file in bytes.
169
- *
170
- * Always 0 for streams, as the size is not known until the stream is fully read.
171
- *
172
- * @default 0
173
- */
168
+ * Size of the file in bytes.
169
+ *
170
+ * Always 0 for streams, as the size is not known until the stream is fully read.
171
+ *
172
+ * @default 0
173
+ */
174
174
  size: number;
175
175
  /**
176
- * Last modified timestamp in milliseconds since epoch.
177
- *
178
- * Always the current timestamp for streams, as the last modified time is not known.
179
- * We use this field to ensure compatibility with File API.
180
- *
181
- * @default Date.now()
182
- */
176
+ * Last modified timestamp in milliseconds since epoch.
177
+ *
178
+ * Always the current timestamp for streams, as the last modified time is not known.
179
+ * We use this field to ensure compatibility with File API.
180
+ *
181
+ * @default Date.now()
182
+ */
183
183
  lastModified: number;
184
184
  /**
185
- * Returns a ReadableStream or Node.js Readable stream of the file content.
186
- *
187
- * For streams, this is the original stream.
188
- */
185
+ * Returns a ReadableStream or Node.js Readable stream of the file content.
186
+ *
187
+ * For streams, this is the original stream.
188
+ */
189
189
  stream(): StreamLike;
190
190
  /**
191
- * Returns the file content as an ArrayBuffer.
192
- *
193
- * For streams, this reads the entire stream into memory.
194
- */
191
+ * Returns the file content as an ArrayBuffer.
192
+ *
193
+ * For streams, this reads the entire stream into memory.
194
+ */
195
195
  arrayBuffer(): Promise<ArrayBuffer>;
196
196
  /**
197
- * Returns the file content as a string.
198
- *
199
- * For streams, this reads the entire stream into memory and converts it to a string.
200
- */
197
+ * Returns the file content as a string.
198
+ *
199
+ * For streams, this reads the entire stream into memory and converts it to a string.
200
+ */
201
201
  text(): Promise<string>;
202
202
  /**
203
- * Optional file path, if the file is stored on disk.
204
- *
205
- * This is not from the File API, but rather a custom field to indicate where the file is stored.
206
- */
203
+ * Optional file path, if the file is stored on disk.
204
+ *
205
+ * This is not from the File API, but rather a custom field to indicate where the file is stored.
206
+ */
207
207
  filepath?: string;
208
208
  }
209
209
  /**
@@ -259,47 +259,47 @@ declare class TypeProvider {
259
259
  static setLocale(locale: string): void;
260
260
  static isValidBigInt(value: string | number): boolean;
261
261
  /**
262
- * Default maximum length for strings.
263
- *
264
- * It can be set to a larger value:
265
- * ```ts
266
- * TypeProvider.DEFAULT_STRING_MAX_LENGTH = 1000000;
267
- * TypeProvider.DEFAULT_STRING_MAX_LENGTH = undefined; // no limit (not recommended)
268
- * ```
269
- */
262
+ * Default maximum length for strings.
263
+ *
264
+ * It can be set to a larger value:
265
+ * ```ts
266
+ * TypeProvider.DEFAULT_STRING_MAX_LENGTH = 1000000;
267
+ * TypeProvider.DEFAULT_STRING_MAX_LENGTH = undefined; // no limit (not recommended)
268
+ * ```
269
+ */
270
270
  static DEFAULT_STRING_MAX_LENGTH: number | undefined;
271
271
  /**
272
- * Maximum length for short strings, such as names or titles.
273
- */
272
+ * Maximum length for short strings, such as names or titles.
273
+ */
274
274
  static DEFAULT_SHORT_STRING_MAX_LENGTH: number | undefined;
275
275
  /**
276
- * Maximum length for long strings, such as descriptions or comments.
277
- * It can be overridden in the string options.
278
- *
279
- * It can be set to a larger value:
280
- * ```ts
281
- * TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH = 2048;
282
- * ```
283
- */
276
+ * Maximum length for long strings, such as descriptions or comments.
277
+ * It can be overridden in the string options.
278
+ *
279
+ * It can be set to a larger value:
280
+ * ```ts
281
+ * TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH = 2048;
282
+ * ```
283
+ */
284
284
  static DEFAULT_LONG_STRING_MAX_LENGTH: number | undefined;
285
285
  /**
286
- * Maximum length for rich strings, such as HTML or Markdown.
287
- * This is a large value to accommodate rich text content.
288
- * > It's also the maximum length of PG's TEXT type.
289
- *
290
- * It can be overridden in the string options.
291
- *
292
- * It can be set to a larger value:
293
- * ```ts
294
- * TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH = 1000000;
295
- * ```
296
- */
286
+ * Maximum length for rich strings, such as HTML or Markdown.
287
+ * This is a large value to accommodate rich text content.
288
+ * > It's also the maximum length of PG's TEXT type.
289
+ *
290
+ * It can be overridden in the string options.
291
+ *
292
+ * It can be set to a larger value:
293
+ * ```ts
294
+ * TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH = 1000000;
295
+ * ```
296
+ */
297
297
  static DEFAULT_RICH_STRING_MAX_LENGTH: number | undefined;
298
298
  /**
299
- * Maximum number of items in an array.
300
- * This is a default value to prevent excessive memory usage.
301
- * It can be overridden in the array options.
302
- */
299
+ * Maximum number of items in an array.
300
+ * This is a default value to prevent excessive memory usage.
301
+ * It can be overridden in the array options.
302
+ */
303
303
  static DEFAULT_ARRAY_MAX_ITEMS: number;
304
304
  raw: typeof Type;
305
305
  any: typeof Type.Any;
@@ -312,16 +312,16 @@ declare class TypeProvider {
312
312
  const: typeof Type.Literal;
313
313
  options: typeof Type.Options;
314
314
  /**
315
- * Type guards to check the type of schema.
316
- * This is not a runtime type check, but a compile-time type guard.
317
- *
318
- * @example
319
- * ```ts
320
- * if (t.schema.isString(schema)) {
321
- * // schema is TString
322
- * }
323
- * ```
324
- */
315
+ * Type guards to check the type of schema.
316
+ * This is not a runtime type check, but a compile-time type guard.
317
+ *
318
+ * @example
319
+ * ```ts
320
+ * if (t.schema.isString(schema)) {
321
+ * // schema is TString
322
+ * }
323
+ * ```
324
+ */
325
325
  readonly schema: TypeGuard;
326
326
  extend<T extends TSchema$1[], U extends TProperties$1>(schema: [...T], properties: U, options?: TSchemaOptions): TInterface<T, U>;
327
327
  extend<T extends TObject$1, U extends TProperties$1>(schema: T, properties: U, options?: TSchemaOptions): TInterface<[T], U>;
@@ -329,76 +329,76 @@ declare class TypeProvider {
329
329
  omit<T extends TObject$1, Indexer extends PropertyKey[]>(schema: T, keys: [...Indexer], options?: TObjectOptions$1): TOmit<T, TKeysToIndexer$1<Indexer>>;
330
330
  partial<T extends TSchema$1>(schema: T, options?: TSchemaOptions): TPartial<T>;
331
331
  /**
332
- * Create a schema for an object.
333
- * By default, additional properties are not allowed.
334
- *
335
- * @example
336
- * ```ts
337
- * const userSchema = t.object({
338
- * id: t.integer(),
339
- * name: t.string(),
340
- * });
341
- * ```
342
- */
332
+ * Create a schema for an object.
333
+ * By default, additional properties are not allowed.
334
+ *
335
+ * @example
336
+ * ```ts
337
+ * const userSchema = t.object({
338
+ * id: t.integer(),
339
+ * name: t.string(),
340
+ * });
341
+ * ```
342
+ */
343
343
  object<T extends TProperties$1>(properties: T, options?: TObjectOptions$1): TObject$1<T>;
344
344
  /**
345
- * Create a schema for an array.
346
- * By default, the maximum number of items is limited to prevent excessive memory usage.
347
- *
348
- * @see TypeProvider.DEFAULT_ARRAY_MAX_ITEMS
349
- */
345
+ * Create a schema for an array.
346
+ * By default, the maximum number of items is limited to prevent excessive memory usage.
347
+ *
348
+ * @see TypeProvider.DEFAULT_ARRAY_MAX_ITEMS
349
+ */
350
350
  array<T extends TSchema$1>(schema: T, options?: TArrayOptions): TArray$1<T>;
351
351
  /**
352
- * Create a schema for a string.
353
- * For db or input fields, consider using `t.text()` instead, which has length limits.
354
- *
355
- * If you need a string with specific format (e.g. email, uuid), consider using the corresponding method (e.g. `t.email()`, `t.uuid()`).
356
- */
352
+ * Create a schema for a string.
353
+ * For db or input fields, consider using `t.text()` instead, which has length limits.
354
+ *
355
+ * If you need a string with specific format (e.g. email, uuid), consider using the corresponding method (e.g. `t.email()`, `t.uuid()`).
356
+ */
357
357
  string(options?: TStringOptions$1): TString$1;
358
358
  /**
359
- * Create a schema for a string with length limits.
360
- * For internal strings without length limits, consider using `t.string()` instead.
361
- *
362
- * Default size is "regular", which has a max length of 255 characters.
363
- */
359
+ * Create a schema for a string with length limits.
360
+ * For internal strings without length limits, consider using `t.string()` instead.
361
+ *
362
+ * Default size is "regular", which has a max length of 255 characters.
363
+ */
364
364
  text(options?: TTextOptions): TString$1;
365
365
  /**
366
- * Create a schema for a JSON object.
367
- * This is a record with string keys and any values.
368
- */
366
+ * Create a schema for a JSON object.
367
+ * This is a record with string keys and any values.
368
+ */
369
369
  json<T = any>(options?: TSchemaOptions): TRecord$1<string, TAny$1>;
370
370
  /**
371
- * Create a schema for a boolean.
372
- */
371
+ * Create a schema for a boolean.
372
+ */
373
373
  boolean(options?: TSchemaOptions): TBoolean$1;
374
374
  /**
375
- * Create a schema for a number.
376
- */
375
+ * Create a schema for a number.
376
+ */
377
377
  number(options?: TNumberOptions$1): TNumber$1;
378
378
  /**
379
- * Create a schema for an integer.
380
- */
379
+ * Create a schema for an integer.
380
+ */
381
381
  integer(options?: TNumberOptions$1): TInteger$1;
382
382
  int32(options?: TNumberOptions$1): TInteger$1;
383
383
  /**
384
- * Mimic a signed 64-bit integer.
385
- *
386
- * This is NOT a true int64, as JavaScript cannot represent all int64 values.
387
- * It is a number that is an integer and between -9007199254740991 and 9007199254740991.
388
- * Use `t.bigint()` for true int64 values represented as strings.
389
- */
384
+ * Mimic a signed 64-bit integer.
385
+ *
386
+ * This is NOT a true int64, as JavaScript cannot represent all int64 values.
387
+ * It is a number that is an integer and between -9007199254740991 and 9007199254740991.
388
+ * Use `t.bigint()` for true int64 values represented as strings.
389
+ */
390
390
  int64(options?: TNumberOptions$1): TNumber$1;
391
391
  /**
392
- * Make a schema optional.
393
- */
392
+ * Make a schema optional.
393
+ */
394
394
  optional<T extends TSchema$1>(schema: T): TOptionalAdd$1<T>;
395
395
  /**
396
- * Make a schema nullable.
397
- */
396
+ * Make a schema nullable.
397
+ */
398
398
  nullable<T extends TSchema$1>(schema: T, options?: TObjectOptions$1): TUnion$1<[TNull$1, T]>;
399
399
  /**
400
- * Create a schema that maps all properties of an object schema to nullable.
401
- */
400
+ * Create a schema that maps all properties of an object schema to nullable.
401
+ */
402
402
  nullify: <T extends TSchema$1>(schema: T, options?: TObjectOptions$1) => typebox0.TMappedInstantiate<{}, {
403
403
  callstack: [];
404
404
  }, Type.TIdentifier<"K">, typebox0.TKeyOfInstantiate<{}, {
@@ -407,65 +407,65 @@ declare class TypeProvider {
407
407
  callstack: [];
408
408
  }, T, Type.TRef<"K">>, TNull$1]>>;
409
409
  /**
410
- * Create a schema for a string enum.
411
- */
410
+ * Create a schema for a string enum.
411
+ */
412
412
  enum<T extends string[]>(values: [...T], options?: TTextOptions): TUnsafe$1<T[number]>;
413
413
  /**
414
- * Create a schema for a bigint represented as a string.
415
- * This is a string that validates bigint format (e.g. "123456789").
416
- */
414
+ * Create a schema for a bigint represented as a string.
415
+ * This is a string that validates bigint format (e.g. "123456789").
416
+ */
417
417
  bigint(options?: TStringOptions$1): TString$1;
418
418
  /**
419
- * Create a schema for a URL represented as a string.
420
- */
419
+ * Create a schema for a URL represented as a string.
420
+ */
421
421
  url(options?: TStringOptions$1): TString$1;
422
422
  /**
423
- * Create a schema for binary data represented as a base64 string.
424
- */
423
+ * Create a schema for binary data represented as a base64 string.
424
+ */
425
425
  binary(options: TStringOptions$1): TString$1;
426
426
  /**
427
- * Create a schema for uuid.
428
- */
427
+ * Create a schema for uuid.
428
+ */
429
429
  uuid(options?: TStringOptions$1): TString$1;
430
430
  /**
431
- * Create a schema for a file-like object.
432
- *
433
- * File like mimics the File API in browsers, but is adapted to work in Node.js as well.
434
- *
435
- * Implementation of file-like objects is handled by "alepha/file" package.
436
- */
431
+ * Create a schema for a file-like object.
432
+ *
433
+ * File like mimics the File API in browsers, but is adapted to work in Node.js as well.
434
+ *
435
+ * Implementation of file-like objects is handled by "alepha/file" package.
436
+ */
437
437
  file(options?: {
438
438
  maxSize?: number;
439
439
  }): TFile;
440
440
  /**
441
- * @experimental
442
- */
441
+ * @experimental
442
+ */
443
443
  stream(): TStream;
444
444
  email(options?: TStringOptions$1): TString$1;
445
445
  e164(options?: TStringOptions$1): TString$1;
446
446
  bcp47(options?: TStringOptions$1): TString$1;
447
447
  /**
448
- * Create a schema for short text, such as names or titles.
449
- * Default max length is 64 characters.
450
- */
448
+ * Create a schema for short text, such as names or titles.
449
+ * Default max length is 64 characters.
450
+ */
451
451
  shortText(options?: TStringOptions$1): TString$1;
452
452
  /**
453
- * Create a schema for long text, such as descriptions or comments.
454
- * Default max length is 1024 characters.
455
- */
453
+ * Create a schema for long text, such as descriptions or comments.
454
+ * Default max length is 1024 characters.
455
+ */
456
456
  longText(options?: TStringOptions$1): TString$1;
457
457
  /**
458
- * Create a schema for rich text, such as HTML or Markdown.
459
- * Default max length is 65535 characters.
460
- */
458
+ * Create a schema for rich text, such as HTML or Markdown.
459
+ * Default max length is 65535 characters.
460
+ */
461
461
  richText(options?: TStringOptions$1): TString$1;
462
462
  /**
463
- * Create a schema for a string enum e.g. LIKE_THIS.
464
- */
463
+ * Create a schema for a string enum e.g. LIKE_THIS.
464
+ */
465
465
  snakeCase: (options?: TStringOptions$1) => TString$1;
466
466
  /**
467
- * Create a schema for an object with a value and label.
468
- */
467
+ * Create a schema for an object with a value and label.
468
+ */
469
469
  valueLabel: (options?: TObjectOptions$1) => TObject$1<{
470
470
  value: TString$1;
471
471
  label: TString$1;
@@ -479,29 +479,29 @@ declare class TypeProvider {
479
479
  type TextLength = "short" | "regular" | "long" | "rich";
480
480
  interface TTextOptions extends TStringOptions$1 {
481
481
  /**
482
- * Predefined size of the text.
483
- *
484
- * - `short` - short text, such as names or titles. Default max length is 64 characters.
485
- * - `regular` - regular text, such as single-line input. Default max length is 255 characters.
486
- * - `long` - long text, such as descriptions or comments. Default max length is 1024 characters.
487
- * - `rich` - rich text, such as HTML or Markdown. Default max length is 65535 characters.
488
- *
489
- * You can override the default max length by specifying `maxLength` in the options.
490
- *
491
- * @default "regular"
492
- */
482
+ * Predefined size of the text.
483
+ *
484
+ * - `short` - short text, such as names or titles. Default max length is 64 characters.
485
+ * - `regular` - regular text, such as single-line input. Default max length is 255 characters.
486
+ * - `long` - long text, such as descriptions or comments. Default max length is 1024 characters.
487
+ * - `rich` - rich text, such as HTML or Markdown. Default max length is 65535 characters.
488
+ *
489
+ * You can override the default max length by specifying `maxLength` in the options.
490
+ *
491
+ * @default "regular"
492
+ */
493
493
  size?: TextLength;
494
494
  /**
495
- * Trim whitespace from both ends of the string.
496
- *
497
- * @default true
498
- */
495
+ * Trim whitespace from both ends of the string.
496
+ *
497
+ * @default true
498
+ */
499
499
  trim?: boolean;
500
500
  /**
501
- * Convert the string to lowercase.
502
- *
503
- * @default false
504
- */
501
+ * Convert the string to lowercase.
502
+ *
503
+ * @default false
504
+ */
505
505
  lowercase?: boolean;
506
506
  }
507
507
  declare const t: TypeProvider;
@@ -577,25 +577,25 @@ declare const $inject: <T extends object>(type: Service<T>, opts?: InjectOptions
577
577
  declare class InjectPrimitive extends Primitive {}
578
578
  interface InjectOptions<T extends object = any> {
579
579
  /**
580
- * - 'transient' → Always a new instance on every inject. Zero caching.
581
- * - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)
582
- * - 'scoped' → One instance per AsyncLocalStorage context.
583
- * - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...
584
- * - You can also start a manual scope via alepha.context.run(() => { ... }).
585
- * - When the scope ends, the scoped registry is discarded.
586
- *
587
- * @default "singleton"
588
- */
580
+ * - 'transient' → Always a new instance on every inject. Zero caching.
581
+ * - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)
582
+ * - 'scoped' → One instance per AsyncLocalStorage context.
583
+ * - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...
584
+ * - You can also start a manual scope via alepha.context.run(() => { ... }).
585
+ * - When the scope ends, the scoped registry is discarded.
586
+ *
587
+ * @default "singleton"
588
+ */
589
589
  lifetime?: "transient" | "singleton" | "scoped";
590
590
  /**
591
- * Constructor arguments to pass when creating a new instance.
592
- */
591
+ * Constructor arguments to pass when creating a new instance.
592
+ */
593
593
  args?: ConstructorParameters<InstantiableClass<T>>;
594
594
  /**
595
- * Parent that requested the instance.
596
- *
597
- * @internal
598
- */
595
+ * Parent that requested the instance.
596
+ *
597
+ * @internal
598
+ */
599
599
  parent?: Service | null;
600
600
  }
601
601
  //#endregion
@@ -651,29 +651,29 @@ interface InjectOptions<T extends object = any> {
651
651
  declare const $module: <T extends object = {}>(options: ModulePrimitiveOptions) => Service<Module>;
652
652
  interface ModulePrimitiveOptions {
653
653
  /**
654
- * Name of the module.
655
- *
656
- * It should be in the format of `project.module.submodule`.
657
- */
654
+ * Name of the module.
655
+ *
656
+ * It should be in the format of `project.module.submodule`.
657
+ */
658
658
  name: string;
659
659
  /**
660
- * List all services related to this module.
661
- *
662
- * If you don't declare 'register' function, all services will be registered automatically.
663
- * If you declare 'register' function, you must handle the registration of ALL services manually.
664
- */
660
+ * List all services related to this module.
661
+ *
662
+ * If you don't declare 'register' function, all services will be registered automatically.
663
+ * If you declare 'register' function, you must handle the registration of ALL services manually.
664
+ */
665
665
  services?: Array<Service>;
666
666
  /**
667
- * List of $primitives to register in the module.
668
- */
667
+ * List of $primitives to register in the module.
668
+ */
669
669
  primitives?: Array<PrimitiveFactoryLike>;
670
670
  /**
671
- * By default, module will register ALL services.
672
- * You can override this behavior by providing a register function.
673
- * It's useful when you want to register services conditionally or in a specific order.
674
- *
675
- * Again, if you declare 'register', you must handle the registration of ALL services manually.
676
- */
671
+ * By default, module will register ALL services.
672
+ * You can override this behavior by providing a register function.
673
+ * It's useful when you want to register services conditionally or in a specific order.
674
+ *
675
+ * Again, if you declare 'register', you must handle the registration of ALL services manually.
676
+ */
677
677
  register?: (alepha: Alepha) => void;
678
678
  }
679
679
  /**
@@ -684,14 +684,14 @@ declare abstract class Module {
684
684
  abstract register(alepha: Alepha): void;
685
685
  static NAME_REGEX: RegExp;
686
686
  /**
687
- * Check if a Service is a Module.
688
- */
687
+ * Check if a Service is a Module.
688
+ */
689
689
  static is(ctor: Service): boolean;
690
690
  /**
691
- * Get the Module of a Service.
692
- *
693
- * Returns undefined if the Service is not part of a Module.
694
- */
691
+ * Get the Module of a Service.
692
+ *
693
+ * Returns undefined if the Service is not part of a Module.
694
+ */
695
695
  static of(ctor: Service): Service<Module> | undefined;
696
696
  }
697
697
  /**
@@ -728,16 +728,16 @@ declare class Json {
728
728
  //#region ../../src/core/providers/SchemaCodec.d.ts
729
729
  declare abstract class SchemaCodec {
730
730
  /**
731
- * Encode the value to a string format.
732
- */
731
+ * Encode the value to a string format.
732
+ */
733
733
  abstract encodeToString<T extends TSchema>(schema: T, value: Static<T>): string;
734
734
  /**
735
- * Encode the value to a binary format.
736
- */
735
+ * Encode the value to a binary format.
736
+ */
737
737
  abstract encodeToBinary<T extends TSchema>(schema: T, value: Static<T>): Uint8Array;
738
738
  /**
739
- * Decode string, binary, or other formats to the schema type.
740
- */
739
+ * Decode string, binary, or other formats to the schema type.
740
+ */
741
741
  abstract decode<T>(schema: TSchema, value: unknown): T;
742
742
  }
743
743
  //#endregion
@@ -751,6 +751,61 @@ declare class JsonSchemaCodec extends SchemaCodec {
751
751
  decode<T>(schema: TSchema$1, value: unknown): T;
752
752
  }
753
753
  //#endregion
754
+ //#region ../../src/core/providers/KeylessJsonSchemaCodec.d.ts
755
+ interface KeylessCodec<T = any> {
756
+ encode: (value: T) => string;
757
+ decode: (str: string) => T;
758
+ }
759
+ /**
760
+ * KeylessJsonSchemaCodec provides schema-driven JSON encoding without keys.
761
+ *
762
+ * It uses the schema to determine field order, allowing the encoded output
763
+ * to be a simple JSON array instead of an object with keys.
764
+ *
765
+ * Performance characteristics:
766
+ * - Encode: 0.94-1.53x vs JSON.stringify (faster for complex objects)
767
+ * - Decode: 1.76-2.00x vs JSON.parse
768
+ * - Size: 50-56% smaller than JSON
769
+ */
770
+ declare class KeylessJsonSchemaCodec extends SchemaCodec {
771
+ protected readonly cache: Map<TSchema$1, KeylessCodec<any>>;
772
+ protected readonly encoder: TextEncoder;
773
+ protected readonly decoder: TextDecoder;
774
+ protected varCounter: number;
775
+ /**
776
+ * Encode value to a keyless JSON string.
777
+ */
778
+ encodeToString<T extends TSchema$1>(schema: T, value: Static<T>): string;
779
+ /**
780
+ * Encode value to binary (UTF-8 encoded keyless JSON).
781
+ */
782
+ encodeToBinary<T extends TSchema$1>(schema: T, value: Static<T>): Uint8Array;
783
+ /**
784
+ * Decode keyless JSON string or binary to value.
785
+ */
786
+ decode<T>(schema: TSchema$1, value: unknown): T;
787
+ /**
788
+ * Get a compiled codec for the given schema.
789
+ * Codecs are cached for reuse.
790
+ */
791
+ protected getCodec<T>(schema: TSchema$1): KeylessCodec<T>;
792
+ protected nextVar(): string;
793
+ protected compile(schema: TSchema$1): KeylessCodec;
794
+ protected genEnc(schema: TSchema$1, ve: string): string;
795
+ protected genDec(schema: TSchema$1): {
796
+ code: string;
797
+ result: string;
798
+ };
799
+ protected genDecFromValue(schema: TSchema$1, expr: string): string;
800
+ protected isEnum(schema: TSchema$1): boolean;
801
+ protected isNullable(schema: TSchema$1): boolean;
802
+ protected unwrap(schema: TSchema$1): TSchema$1;
803
+ /**
804
+ * Reconstruct an object from a parsed array (for when input is already parsed).
805
+ */
806
+ protected reconstructObject(schema: TSchema$1, arr: any[]): any;
807
+ }
808
+ //#endregion
754
809
  //#region ../../src/core/primitives/$hook.d.ts
755
810
  /**
756
811
  * Registers a new hook.
@@ -797,24 +852,24 @@ declare const $hook: {
797
852
  };
798
853
  interface HookOptions<T extends keyof Hooks> {
799
854
  /**
800
- * The name of the hook. "configure", "start", "ready", "stop", ...
801
- */
855
+ * The name of the hook. "configure", "start", "ready", "stop", ...
856
+ */
802
857
  on: T;
803
858
  /**
804
- * The handler to run when the hook is triggered.
805
- */
859
+ * The handler to run when the hook is triggered.
860
+ */
806
861
  handler: (args: Hooks[T]) => Async<any>;
807
862
  /**
808
- * Force the hook to run first or last on the list of hooks.
809
- */
863
+ * Force the hook to run first or last on the list of hooks.
864
+ */
810
865
  priority?: "first" | "last";
811
866
  /**
812
- * Empty placeholder, not implemented yet. :-)
813
- */
867
+ * Empty placeholder, not implemented yet. :-)
868
+ */
814
869
  before?: object | Array<object>;
815
870
  /**
816
- * Empty placeholder, not implemented yet. :-)
817
- */
871
+ * Empty placeholder, not implemented yet. :-)
872
+ */
818
873
  after?: object | Array<object>;
819
874
  }
820
875
  declare class HookPrimitive<T extends keyof Hooks> extends Primitive<HookOptions<T>> {
@@ -827,22 +882,22 @@ declare class SchemaValidator {
827
882
  protected cache: Map<TSchema$1, Validator<typebox0.TProperties, TSchema$1, unknown, unknown>>;
828
883
  protected useEval: boolean;
829
884
  /**
830
- * Validate the value against the provided schema.
831
- *
832
- * Validation create a new value by applying some preprocessing. (e.g., trimming text)
833
- */
885
+ * Validate the value against the provided schema.
886
+ *
887
+ * Validation create a new value by applying some preprocessing. (e.g., trimming text)
888
+ */
834
889
  validate<T extends TSchema$1>(schema: T, value: unknown, options?: ValidateOptions): Static<T>;
835
890
  protected getValidator<T extends TSchema$1>(schema: T): Validator<{}, T>;
836
891
  /**
837
- * Preprocess the value based on the schema before validation.
838
- *
839
- * - If the value is `null` and the schema does not allow `null`, it converts it to `undefined`.
840
- * - If the value is a string and the schema has a `~options.trim` flag, it trims whitespace from the string.
841
- */
892
+ * Preprocess the value based on the schema before validation.
893
+ *
894
+ * - If the value is `null` and the schema does not allow `null`, it converts it to `undefined`.
895
+ * - If the value is a string and the schema has a `~options.trim` flag, it trims whitespace from the string.
896
+ */
842
897
  beforeParse(schema: any, value: any, options: ValidateOptions): any;
843
898
  /**
844
- * Used by `beforeParse` to determine if a schema allows null values.
845
- */
899
+ * Used by `beforeParse` to determine if a schema allows null values.
900
+ */
846
901
  protected isSchemaNullable: (schema: any) => boolean;
847
902
  protected onConfigure: HookPrimitive<"configure">;
848
903
  protected canEval(): boolean;
@@ -857,35 +912,35 @@ interface ValidateOptions {
857
912
  type Encoding = "object" | "string" | "binary";
858
913
  interface EncodeOptions<T extends Encoding = Encoding> {
859
914
  /**
860
- * The output encoding format:
861
- * - 'string': Returns JSON string
862
- * - 'binary': Returns Uint8Array (for protobuf, msgpack, etc.)
863
- *
864
- * @default "string"
865
- */
915
+ * The output encoding format:
916
+ * - 'string': Returns JSON string
917
+ * - 'binary': Returns Uint8Array (for protobuf, msgpack, etc.)
918
+ *
919
+ * @default "string"
920
+ */
866
921
  as?: T;
867
922
  /**
868
- * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
869
- *
870
- * @default "json"
871
- */
923
+ * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
924
+ *
925
+ * @default "json"
926
+ */
872
927
  encoder?: string;
873
928
  /**
874
- * Validation options to apply before encoding.
875
- */
929
+ * Validation options to apply before encoding.
930
+ */
876
931
  validation?: ValidateOptions | false;
877
932
  }
878
933
  type EncodeResult<T extends TSchema$1, E extends Encoding> = E extends "string" ? string : E extends "binary" ? Uint8Array : StaticEncode$1<T>;
879
934
  interface DecodeOptions {
880
935
  /**
881
- * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
882
- *
883
- * @default "json"
884
- */
936
+ * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
937
+ *
938
+ * @default "json"
939
+ */
885
940
  encoder?: string;
886
941
  /**
887
- * Validation options to apply before encoding.
888
- */
942
+ * Validation options to apply before encoding.
943
+ */
889
944
  validation?: ValidateOptions | false;
890
945
  }
891
946
  /**
@@ -895,76 +950,115 @@ interface DecodeOptions {
895
950
  declare class CodecManager {
896
951
  protected readonly codecs: Map<string, SchemaCodec>;
897
952
  protected readonly jsonCodec: JsonSchemaCodec;
953
+ protected readonly keylessCodec: KeylessJsonSchemaCodec;
898
954
  protected readonly schemaValidator: SchemaValidator;
899
955
  default: string;
900
956
  constructor();
901
957
  /**
902
- * Register a new codec format.
903
- *
904
- * @param name - The name of the codec (e.g., 'json', 'protobuf')
905
- * @param codec - The codec implementation
906
- */
907
- register(name: string, codec: SchemaCodec): void;
908
- /**
909
- * Get a specific codec by name.
910
- *
911
- * @param name - The name of the codec
912
- * @returns The codec instance
913
- * @throws {AlephaError} If the codec is not found
914
- */
958
+ * Register a new codec format.
959
+ */
960
+ register(opts: CodecRegisterOptions): void;
961
+ /**
962
+ * Get a specific codec by name.
963
+ *
964
+ * @param name - The name of the codec
965
+ * @returns The codec instance
966
+ * @throws {AlephaError} If the codec is not found
967
+ */
915
968
  getCodec(name: string): SchemaCodec;
916
969
  /**
917
- * Encode data using the specified codec and output format.
918
- */
970
+ * Encode data using the specified codec and output format.
971
+ */
919
972
  encode<T extends TSchema$1, E extends Encoding = "object">(schema: T, value: unknown, options?: EncodeOptions<E>): EncodeResult<T, E>;
920
973
  /**
921
- * Decode data using the specified codec.
922
- */
974
+ * Decode data using the specified codec.
975
+ */
923
976
  decode<T extends TSchema$1>(schema: T, data: any, options?: DecodeOptions): Static<T>;
924
977
  /**
925
- * Validate decoded data against the schema.
926
- *
927
- * This is automatically called before encoding or after decoding.
928
- */
978
+ * Validate decoded data against the schema.
979
+ *
980
+ * This is automatically called before encoding or after decoding.
981
+ */
929
982
  validate<T extends TSchema$1>(schema: T, value: unknown, options?: ValidateOptions): Static<T>;
930
983
  }
984
+ interface CodecRegisterOptions {
985
+ name: string;
986
+ codec: SchemaCodec;
987
+ default?: boolean;
988
+ }
931
989
  //#endregion
932
990
  //#region ../../src/core/providers/EventManager.d.ts
991
+ /**
992
+ * Compiled event executor - optimized for hot paths.
993
+ * Returns void for sync-only chains, Promise<void> for chains with async hooks.
994
+ */
995
+ type CompiledEventExecutor<T> = (payload: T) => void | Promise<void>;
996
+ /**
997
+ * Options for compiled event executors.
998
+ */
999
+ interface CompileOptions {
1000
+ /**
1001
+ * If true, errors will be caught and logged instead of throwing.
1002
+ * @default false
1003
+ */
1004
+ catch?: boolean;
1005
+ }
933
1006
  declare class EventManager {
934
1007
  logFn?: () => LoggerInterface | undefined;
935
1008
  /**
936
- * List of events that can be triggered. Powered by $hook().
937
- */
1009
+ * List of events that can be triggered. Powered by $hook().
1010
+ */
938
1011
  protected events: Record<string, Array<Hook>>;
939
1012
  constructor(logFn?: () => LoggerInterface | undefined);
940
1013
  protected get log(): LoggerInterface | undefined;
941
1014
  clear(): void;
942
1015
  /**
943
- * Registers a hook for the specified event.
944
- */
1016
+ * Registers a hook for the specified event.
1017
+ */
945
1018
  on<T extends keyof Hooks>(event: T, hookOrFunc: Hook<T> | ((payload: Hooks[T]) => Async<void>)): () => void;
946
1019
  /**
947
- * Emits the specified event with the given payload.
948
- */
1020
+ * Compiles an event into an optimized executor function.
1021
+ *
1022
+ * Call this after all hooks are registered (e.g., after Alepha.start()).
1023
+ * The returned function checks each hook's return value and awaits promises.
1024
+ * Returns undefined if all hooks are sync, or a Promise if any hook returns one.
1025
+ *
1026
+ * @example
1027
+ * ```ts
1028
+ * // At startup (after hooks are registered)
1029
+ * const onRequest = alepha.events.compile("server:onRequest", { catch: true });
1030
+ *
1031
+ * // In hot path - only await if promise returned
1032
+ * const result = onRequest({ request, route });
1033
+ * if (result) await result;
1034
+ * ```
1035
+ */
1036
+ compile<T extends keyof Hooks>(event: T, options?: CompileOptions): CompiledEventExecutor<Hooks[T]>;
1037
+ /**
1038
+ * Emits the specified event with the given payload.
1039
+ *
1040
+ * For hot paths (like HTTP request handling), use compile() instead
1041
+ * to get an optimized executor.
1042
+ */
949
1043
  emit<T extends keyof Hooks>(func: T, payload: Hooks[T], options?: {
950
1044
  /**
951
- * If true, the hooks will be executed in reverse order.
952
- * This is useful for "stop" hooks that should be executed in reverse order.
953
- *
954
- * @default false
955
- */
1045
+ * If true, the hooks will be executed in reverse order.
1046
+ * This is useful for "stop" hooks that should be executed in reverse order.
1047
+ *
1048
+ * @default false
1049
+ */
956
1050
  reverse?: boolean;
957
1051
  /**
958
- * If true, the hooks will be logged with their execution time.
959
- *
960
- * @default false
961
- */
1052
+ * If true, the hooks will be logged with their execution time.
1053
+ *
1054
+ * @default false
1055
+ */
962
1056
  log?: boolean;
963
1057
  /**
964
- * If true, errors will be caught and logged instead of throwing.
965
- *
966
- * @default false
967
- */
1058
+ * If true, errors will be caught and logged instead of throwing.
1059
+ *
1060
+ * @default false
1061
+ */
968
1062
  catch?: boolean;
969
1063
  }): Promise<void>;
970
1064
  }
@@ -984,39 +1078,39 @@ declare class StateManager<State$1 extends object = State> {
984
1078
  getAtoms(context?: boolean): Array<AtomWithValue>;
985
1079
  register(atom: Atom<any>): this;
986
1080
  /**
987
- * Get a value from the state with proper typing
988
- */
1081
+ * Get a value from the state with proper typing
1082
+ */
989
1083
  get<T extends TAtomObject>(target: Atom<T>): Static<T>;
990
1084
  get<Key extends keyof State$1>(target: Key): State$1[Key] | undefined;
991
1085
  /**
992
- * Set a value in the state
993
- */
1086
+ * Set a value in the state
1087
+ */
994
1088
  set<T extends TAtomObject>(target: Atom<T>, value: AtomStatic<T>, options?: SetStateOptions): this;
995
1089
  set<Key extends keyof State$1>(target: Key, value: State$1[Key] | undefined, options?: SetStateOptions): this;
996
1090
  /**
997
- * Mutate a value in the state.
998
- */
1091
+ * Mutate a value in the state.
1092
+ */
999
1093
  mut<T extends TObject$1>(target: Atom<T>, mutator: (current: Static<T>) => Static<T>): this;
1000
1094
  mut<Key extends keyof State$1>(target: Key, mutator: (current: State$1[Key] | undefined) => State$1[Key] | undefined): this;
1001
1095
  /**
1002
- * Check if a key exists in the state
1003
- */
1096
+ * Check if a key exists in the state
1097
+ */
1004
1098
  has<Key extends keyof State$1>(key: Key): boolean;
1005
1099
  /**
1006
- * Delete a key from the state (set to undefined)
1007
- */
1100
+ * Delete a key from the state (set to undefined)
1101
+ */
1008
1102
  del<Key extends keyof State$1>(key: Key): this;
1009
1103
  /**
1010
- * Push a value to an array in the state
1011
- */
1104
+ * Push a value to an array in the state
1105
+ */
1012
1106
  push<Key extends keyof OnlyArray<State$1>>(key: Key, ...value: Array<NonNullable<State$1[Key]> extends Array<infer U> ? U : never>): this;
1013
1107
  /**
1014
- * Clear all state
1015
- */
1108
+ * Clear all state
1109
+ */
1016
1110
  clear(): this;
1017
1111
  /**
1018
- * Get all keys that exist in the state
1019
- */
1112
+ * Get all keys that exist in the state
1113
+ */
1020
1114
  keys(): (keyof State$1)[];
1021
1115
  }
1022
1116
  type OnlyArray<T extends object> = { [K in keyof T]: NonNullable<T[K]> extends Array<any> ? K : never };
@@ -1151,264 +1245,264 @@ interface SetStateOptions {
1151
1245
  */
1152
1246
  declare class Alepha {
1153
1247
  /**
1154
- * Creates a new instance of the Alepha container with some helpers:
1155
- *
1156
- * - merges `process.env` with the provided state.env when available.
1157
- * - populates the test hooks for Vitest or Jest environments when available.
1158
- *
1159
- * If you are not interested about these helpers, you can use the constructor directly.
1160
- */
1248
+ * Creates a new instance of the Alepha container with some helpers:
1249
+ *
1250
+ * - merges `process.env` with the provided state.env when available.
1251
+ * - populates the test hooks for Vitest or Jest environments when available.
1252
+ *
1253
+ * If you are not interested about these helpers, you can use the constructor directly.
1254
+ */
1161
1255
  static create(state?: Partial<State>): Alepha;
1162
1256
  /**
1163
- * Flag indicating whether the App won't accept any further changes.
1164
- * Pass to true when #start() is called.
1165
- */
1257
+ * Flag indicating whether the App won't accept any further changes.
1258
+ * Pass to true when #start() is called.
1259
+ */
1166
1260
  protected locked: boolean;
1167
1261
  /**
1168
- * True if the App has been configured.
1169
- */
1262
+ * True if the App has been configured.
1263
+ */
1170
1264
  protected configured: boolean;
1171
1265
  /**
1172
- * True if the App has started.
1173
- */
1266
+ * True if the App has started.
1267
+ */
1174
1268
  protected started: boolean;
1175
1269
  /**
1176
- * True if the App is ready.
1177
- */
1270
+ * True if the App is ready.
1271
+ */
1178
1272
  protected ready: boolean;
1179
1273
  /**
1180
- * A promise that resolves when the App has started.
1181
- */
1274
+ * A promise that resolves when the App has started.
1275
+ */
1182
1276
  protected starting?: PromiseWithResolvers<this>;
1183
1277
  /**
1184
- * During the instantiation process, we keep a list of pending instantiations.
1185
- * > It allows us to detect circular dependencies.
1186
- */
1278
+ * During the instantiation process, we keep a list of pending instantiations.
1279
+ * > It allows us to detect circular dependencies.
1280
+ */
1187
1281
  protected pendingInstantiations: Service[];
1188
1282
  /**
1189
- * Cache for environment variables.
1190
- * > It allows us to avoid parsing the same schema multiple times.
1191
- */
1283
+ * Cache for environment variables.
1284
+ * > It allows us to avoid parsing the same schema multiple times.
1285
+ */
1192
1286
  protected cacheEnv: Map<TSchema, any>;
1193
1287
  /**
1194
- * List of modules that are registered in the container.
1195
- *
1196
- * Modules are used to group services and provide a way to register them in the container.
1197
- */
1288
+ * List of modules that are registered in the container.
1289
+ *
1290
+ * Modules are used to group services and provide a way to register them in the container.
1291
+ */
1198
1292
  protected modules: Array<Module>;
1199
1293
  /**
1200
- * List of service substitutions.
1201
- *
1202
- * Services registered here will be replaced by the specified service when injected.
1203
- */
1294
+ * List of service substitutions.
1295
+ *
1296
+ * Services registered here will be replaced by the specified service when injected.
1297
+ */
1204
1298
  protected substitutions: Map<Service, {
1205
1299
  use: Service;
1206
1300
  }>;
1207
1301
  /**
1208
- * Registry of primitives.
1209
- */
1302
+ * Registry of primitives.
1303
+ */
1210
1304
  protected primitiveRegistry: Map<Service<Primitive<{}>>, Primitive<{}>[]>;
1211
1305
  /**
1212
- * List of all services + how they are provided.
1213
- */
1306
+ * List of all services + how they are provided.
1307
+ */
1214
1308
  protected registry: Map<Service, ServiceDefinition>;
1215
1309
  /**
1216
- * Node.js feature that allows to store context across asynchronous calls.
1217
- *
1218
- * This is used for logging, tracing, and other context-related features.
1219
- *
1220
- * Mocked for browser environments.
1221
- */
1310
+ * Node.js feature that allows to store context across asynchronous calls.
1311
+ *
1312
+ * This is used for logging, tracing, and other context-related features.
1313
+ *
1314
+ * Mocked for browser environments.
1315
+ */
1222
1316
  context: AlsProvider;
1223
1317
  /**
1224
- * Event manager to handle lifecycle events and custom events.
1225
- */
1318
+ * Event manager to handle lifecycle events and custom events.
1319
+ */
1226
1320
  events: EventManager;
1227
1321
  /**
1228
- * State manager to store arbitrary values.
1229
- */
1322
+ * State manager to store arbitrary values.
1323
+ */
1230
1324
  store: StateManager<State>;
1231
1325
  /**
1232
- * Codec manager for encoding and decoding data with different formats.
1233
- *
1234
- * Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.
1235
- */
1326
+ * Codec manager for encoding and decoding data with different formats.
1327
+ *
1328
+ * Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.
1329
+ */
1236
1330
  codec: CodecManager;
1237
1331
  /**
1238
- * Get logger instance.
1239
- */
1332
+ * Get logger instance.
1333
+ */
1240
1334
  get log(): LoggerInterface | undefined;
1241
1335
  /**
1242
- * The environment variables for the App.
1243
- */
1336
+ * The environment variables for the App.
1337
+ */
1244
1338
  get env(): Readonly<Env>;
1245
1339
  constructor(state?: Partial<State>);
1246
1340
  set<T extends TAtomObject>(target: Atom<T>, value: AtomStatic<T>): this;
1247
1341
  set<Key extends keyof State>(target: Key, value: State[Key] | undefined): this;
1248
1342
  /**
1249
- * True when start() is called.
1250
- *
1251
- * -> No more services can be added, it's over, bye!
1252
- */
1343
+ * True when start() is called.
1344
+ *
1345
+ * -> No more services can be added, it's over, bye!
1346
+ */
1253
1347
  isLocked(): boolean;
1254
1348
  /**
1255
- * Returns whether the App is configured.
1256
- *
1257
- * It means that Alepha#configure() has been called.
1258
- *
1259
- * > By default, configure() is called automatically when start() is called, but you can also call it manually.
1260
- */
1349
+ * Returns whether the App is configured.
1350
+ *
1351
+ * It means that Alepha#configure() has been called.
1352
+ *
1353
+ * > By default, configure() is called automatically when start() is called, but you can also call it manually.
1354
+ */
1261
1355
  isConfigured(): boolean;
1262
1356
  /**
1263
- * Returns whether the App has started.
1264
- *
1265
- * It means that #start() has been called but maybe not all services are ready.
1266
- */
1357
+ * Returns whether the App has started.
1358
+ *
1359
+ * It means that #start() has been called but maybe not all services are ready.
1360
+ */
1267
1361
  isStarted(): boolean;
1268
1362
  /**
1269
- * True if the App is ready. It means that Alepha is started AND ready() hook has beed called.
1270
- */
1363
+ * True if the App is ready. It means that Alepha is started AND ready() hook has beed called.
1364
+ */
1271
1365
  isReady(): boolean;
1272
1366
  /**
1273
- * True if the App is running in a Continuous Integration environment.
1274
- */
1367
+ * True if the App is running in a Continuous Integration environment.
1368
+ */
1275
1369
  isCI(): boolean;
1276
1370
  /**
1277
- * True if the App is running in a browser environment.
1278
- */
1371
+ * True if the App is running in a browser environment.
1372
+ */
1279
1373
  isBrowser(): boolean;
1280
1374
  /**
1281
- * Returns whether the App is running in Vite dev mode.
1282
- */
1375
+ * Returns whether the App is running in Vite dev mode.
1376
+ */
1283
1377
  isViteDev(): boolean;
1284
1378
  isBun(): boolean;
1285
1379
  /**
1286
- * Returns whether the App is running in a serverless environment.
1287
- */
1380
+ * Returns whether the App is running in a serverless environment.
1381
+ */
1288
1382
  isServerless(): boolean;
1289
1383
  /**
1290
- * Returns whether the App is in test mode. (Running in a test environment)
1291
- *
1292
- * > This is automatically set when running tests with Jest or Vitest.
1293
- */
1384
+ * Returns whether the App is in test mode. (Running in a test environment)
1385
+ *
1386
+ * > This is automatically set when running tests with Jest or Vitest.
1387
+ */
1294
1388
  isTest(): boolean;
1295
1389
  /**
1296
- * Returns whether the App is in production mode. (Running in a production environment)
1297
- *
1298
- * > This is automatically set by Vite or Vercel. However, you have to set it manually when running Docker apps.
1299
- */
1390
+ * Returns whether the App is in production mode. (Running in a production environment)
1391
+ *
1392
+ * > This is automatically set by Vite or Vercel. However, you have to set it manually when running Docker apps.
1393
+ */
1300
1394
  isProduction(): boolean;
1301
1395
  /**
1302
- * Starts the App.
1303
- *
1304
- * - Lock any further changes to the container.
1305
- * - Run "configure" hook for all services. Primitives will be processed.
1306
- * - Run "start" hook for all services. Providers will connect/listen/...
1307
- * - Run "ready" hook for all services. This is the point where the App is ready to serve requests.
1308
- *
1309
- * @return A promise that resolves when the App has started.
1310
- */
1396
+ * Starts the App.
1397
+ *
1398
+ * - Lock any further changes to the container.
1399
+ * - Run "configure" hook for all services. Primitives will be processed.
1400
+ * - Run "start" hook for all services. Providers will connect/listen/...
1401
+ * - Run "ready" hook for all services. This is the point where the App is ready to serve requests.
1402
+ *
1403
+ * @return A promise that resolves when the App has started.
1404
+ */
1311
1405
  start(): Promise<this>;
1312
1406
  /**
1313
- * Stops the App.
1314
- *
1315
- * - Run "stop" hook for all services.
1316
- *
1317
- * Stop will NOT reset the container.
1318
- * Stop will NOT unlock the container.
1319
- *
1320
- * > Stop is used to gracefully shut down the application, nothing more. There is no "restart".
1321
- *
1322
- * @return A promise that resolves when the App has stopped.
1323
- */
1407
+ * Stops the App.
1408
+ *
1409
+ * - Run "stop" hook for all services.
1410
+ *
1411
+ * Stop will NOT reset the container.
1412
+ * Stop will NOT unlock the container.
1413
+ *
1414
+ * > Stop is used to gracefully shut down the application, nothing more. There is no "restart".
1415
+ *
1416
+ * @return A promise that resolves when the App has stopped.
1417
+ */
1324
1418
  stop(): Promise<void>;
1325
1419
  /**
1326
- * Check if entry is registered in the container.
1327
- */
1420
+ * Check if entry is registered in the container.
1421
+ */
1328
1422
  has(entry: ServiceEntry, opts?: {
1329
1423
  /**
1330
- * Check if the entry is registered in the pending instantiation stack.
1331
- *
1332
- * @default true
1333
- */
1424
+ * Check if the entry is registered in the pending instantiation stack.
1425
+ *
1426
+ * @default true
1427
+ */
1334
1428
  inStack?: boolean;
1335
1429
  /**
1336
- * Check if the entry is registered in the container registry.
1337
- *
1338
- * @default true
1339
- */
1430
+ * Check if the entry is registered in the container registry.
1431
+ *
1432
+ * @default true
1433
+ */
1340
1434
  inRegistry?: boolean;
1341
1435
  /**
1342
- * Check if the entry is registered in the substitutions.
1343
- *
1344
- * @default true
1345
- */
1436
+ * Check if the entry is registered in the substitutions.
1437
+ *
1438
+ * @default true
1439
+ */
1346
1440
  inSubstitutions?: boolean;
1347
1441
  /**
1348
- * Where to look for registered services.
1349
- *
1350
- * @default this.registry
1351
- */
1442
+ * Where to look for registered services.
1443
+ *
1444
+ * @default this.registry
1445
+ */
1352
1446
  registry?: Map<Service, ServiceDefinition>;
1353
1447
  }): boolean;
1354
1448
  /**
1355
- * Registers the specified service in the container.
1356
- *
1357
- * - If the service is ALREADY registered, the method does nothing.
1358
- * - If the service is NOT registered, a new instance is created and registered.
1359
- *
1360
- * Method is chainable, so you can register multiple services in a single call.
1361
- *
1362
- * > ServiceEntry allows to provide a service **substitution** feature.
1363
- *
1364
- * @example
1365
- * ```ts
1366
- * class A { value = "a"; }
1367
- * class B { value = "b"; }
1368
- * class M { a = $inject(A); }
1369
- *
1370
- * Alepha.create().with({ provide: A, use: B }).get(M).a.value; // "b"
1371
- * ```
1372
- *
1373
- * > **Substitution** is an advanced feature that allows you to replace a service with another service.
1374
- * > It's useful for testing or for providing different implementations of a service.
1375
- * > If you are interested in configuring a service, use Alepha#configure() instead.
1376
- *
1377
- * @param serviceEntry - The service to register in the container.
1378
- * @return Current instance of Alepha.
1379
- */
1449
+ * Registers the specified service in the container.
1450
+ *
1451
+ * - If the service is ALREADY registered, the method does nothing.
1452
+ * - If the service is NOT registered, a new instance is created and registered.
1453
+ *
1454
+ * Method is chainable, so you can register multiple services in a single call.
1455
+ *
1456
+ * > ServiceEntry allows to provide a service **substitution** feature.
1457
+ *
1458
+ * @example
1459
+ * ```ts
1460
+ * class A { value = "a"; }
1461
+ * class B { value = "b"; }
1462
+ * class M { a = $inject(A); }
1463
+ *
1464
+ * Alepha.create().with({ provide: A, use: B }).get(M).a.value; // "b"
1465
+ * ```
1466
+ *
1467
+ * > **Substitution** is an advanced feature that allows you to replace a service with another service.
1468
+ * > It's useful for testing or for providing different implementations of a service.
1469
+ * > If you are interested in configuring a service, use Alepha#configure() instead.
1470
+ *
1471
+ * @param serviceEntry - The service to register in the container.
1472
+ * @return Current instance of Alepha.
1473
+ */
1380
1474
  with<T extends object>(serviceEntry: ServiceEntry<T> | {
1381
1475
  default: ServiceEntry<T>;
1382
1476
  }): this;
1383
1477
  /**
1384
- * Get an instance of the specified service from the container.
1385
- *
1386
- * @see {@link InjectOptions} for the available options.
1387
- */
1478
+ * Get an instance of the specified service from the container.
1479
+ *
1480
+ * @see {@link InjectOptions} for the available options.
1481
+ */
1388
1482
  inject<T extends object>(service: Service<T> | string, opts?: InjectOptions<T>): T;
1389
1483
  /**
1390
- * Applies environment variables to the provided schema and state object.
1391
- *
1392
- * It replaces also all templated $ENV inside string values.
1393
- *
1394
- * @param schema - The schema object to apply environment variables to.
1395
- * @return The schema object with environment variables applied.
1396
- */
1484
+ * Applies environment variables to the provided schema and state object.
1485
+ *
1486
+ * It replaces also all templated $ENV inside string values.
1487
+ *
1488
+ * @param schema - The schema object to apply environment variables to.
1489
+ * @return The schema object with environment variables applied.
1490
+ */
1397
1491
  parseEnv<T extends TObject$1>(schema: T): Static$1<T>;
1398
1492
  /**
1399
- * Get all environment variable schemas and their parsed values.
1400
- *
1401
- * This is useful for DevTools to display all expected environment variables.
1402
- */
1493
+ * Get all environment variable schemas and their parsed values.
1494
+ *
1495
+ * This is useful for DevTools to display all expected environment variables.
1496
+ */
1403
1497
  getEnvSchemas(): Array<{
1404
1498
  schema: TSchema;
1405
1499
  values: Record<string, any>;
1406
1500
  }>;
1407
1501
  /**
1408
- * Dump the current dependency graph of the App.
1409
- *
1410
- * This method returns a record where the keys are the names of the services.
1411
- */
1502
+ * Dump the current dependency graph of the App.
1503
+ *
1504
+ * This method returns a record where the keys are the names of the services.
1505
+ */
1412
1506
  graph(): Record<string, {
1413
1507
  from: string[];
1414
1508
  as?: string[];
@@ -1417,8 +1511,8 @@ declare class Alepha {
1417
1511
  dump(): AlephaDump;
1418
1512
  services<T extends object>(base: Service<T>): Array<T>;
1419
1513
  /**
1420
- * Get all primitives of the specified type.
1421
- */
1514
+ * Get all primitives of the specified type.
1515
+ */
1422
1516
  primitives<TPrimitive extends Primitive>(factory: {
1423
1517
  [KIND]: InstantiableClass<TPrimitive>;
1424
1518
  } | string): Array<TPrimitive>;
@@ -1449,145 +1543,145 @@ interface AlephaDumpEnvVariable {
1449
1543
  */
1450
1544
  interface ServiceDefinition<T extends object = any> {
1451
1545
  /**
1452
- * The instance of the class or type definition.
1453
- * Mostly used for caching / singleton but can be used for other purposes like forcing the instance.
1454
- */
1546
+ * The instance of the class or type definition.
1547
+ * Mostly used for caching / singleton but can be used for other purposes like forcing the instance.
1548
+ */
1455
1549
  instance: T;
1456
1550
  /**
1457
- * List of classes which use this class.
1458
- */
1551
+ * List of classes which use this class.
1552
+ */
1459
1553
  parents: Array<Service | null>;
1460
1554
  }
1461
1555
  interface Env {
1462
1556
  [key: string]: string | boolean | number | undefined;
1463
1557
  /**
1464
- * Optional environment variable that indicates the current environment.
1465
- */
1558
+ * Optional environment variable that indicates the current environment.
1559
+ */
1466
1560
  NODE_ENV?: string;
1467
1561
  /**
1468
- * Optional name of the application.
1469
- */
1562
+ * Optional name of the application.
1563
+ */
1470
1564
  APP_NAME?: string;
1471
1565
  /**
1472
- * Optional root module name.
1473
- */
1566
+ * Optional root module name.
1567
+ */
1474
1568
  MODULE_NAME?: string;
1475
1569
  }
1476
1570
  interface State {
1477
1571
  /**
1478
- * Environment variables for the application.
1479
- */
1572
+ * Environment variables for the application.
1573
+ */
1480
1574
  env?: Readonly<Env>;
1481
1575
  /**
1482
- * Logger instance to be used by the Alepha container.
1483
- *
1484
- * @internal
1485
- */
1576
+ * Logger instance to be used by the Alepha container.
1577
+ *
1578
+ * @internal
1579
+ */
1486
1580
  "alepha.logger"?: LoggerInterface;
1487
1581
  /**
1488
- * If defined, the Alepha container will only register this service and its dependencies.
1489
- *
1490
- * @example
1491
- * ```ts
1492
- * class MigrateCmd {
1493
- * db = $inject(DatabaseProvider);
1494
- * alepha = $inject(Alepha);
1495
- * env = $env(
1496
- * t.object({
1497
- * MIGRATE: t.optional(t.boolean()),
1498
- * }),
1499
- * );
1500
- *
1501
- * constructor() {
1502
- * if (this.env.MIGRATE) {
1503
- * this.alepha.set("alepha.target", MigrateCmd);
1504
- * }
1505
- * }
1506
- *
1507
- * ready = $hook({
1508
- * on: "ready",
1509
- * handler: async () => {
1510
- * if (this.env.MIGRATE) {
1511
- * await this.db.migrate();
1512
- * }
1513
- * },
1514
- * });
1515
- * }
1516
- * ```
1517
- */
1582
+ * If defined, the Alepha container will only register this service and its dependencies.
1583
+ *
1584
+ * @example
1585
+ * ```ts
1586
+ * class MigrateCmd {
1587
+ * db = $inject(DatabaseProvider);
1588
+ * alepha = $inject(Alepha);
1589
+ * env = $env(
1590
+ * t.object({
1591
+ * MIGRATE: t.optional(t.boolean()),
1592
+ * }),
1593
+ * );
1594
+ *
1595
+ * constructor() {
1596
+ * if (this.env.MIGRATE) {
1597
+ * this.alepha.set("alepha.target", MigrateCmd);
1598
+ * }
1599
+ * }
1600
+ *
1601
+ * ready = $hook({
1602
+ * on: "ready",
1603
+ * handler: async () => {
1604
+ * if (this.env.MIGRATE) {
1605
+ * await this.db.migrate();
1606
+ * }
1607
+ * },
1608
+ * });
1609
+ * }
1610
+ * ```
1611
+ */
1518
1612
  "alepha.target"?: Service;
1519
1613
  /**
1520
- * Bind to Vitest 'beforeAll' hook.
1521
- * Used for testing purposes.
1522
- * This is automatically attached if Alepha#create() detects a test environment and global 'beforeAll' is available.
1523
- */
1614
+ * Bind to Vitest 'beforeAll' hook.
1615
+ * Used for testing purposes.
1616
+ * This is automatically attached if Alepha#create() detects a test environment and global 'beforeAll' is available.
1617
+ */
1524
1618
  "alepha.test.beforeAll"?: (run: any) => any;
1525
1619
  /**
1526
- * Bind to Vitest 'afterAll' hook.
1527
- * Used for testing purposes.
1528
- * This is automatically attached if Alepha#create() detects a test environment and global 'afterAll' is available.
1529
- */
1620
+ * Bind to Vitest 'afterAll' hook.
1621
+ * Used for testing purposes.
1622
+ * This is automatically attached if Alepha#create() detects a test environment and global 'afterAll' is available.
1623
+ */
1530
1624
  "alepha.test.afterAll"?: (run: any) => any;
1531
1625
  /**
1532
- * Bind to Vitest 'afterEach' hook.
1533
- * Used for testing purposes.
1534
- * This is automatically attached if Alepha#create() detects a test environment and global 'afterEach' is available.
1535
- */
1626
+ * Bind to Vitest 'afterEach' hook.
1627
+ * Used for testing purposes.
1628
+ * This is automatically attached if Alepha#create() detects a test environment and global 'afterEach' is available.
1629
+ */
1536
1630
  "alepha.test.afterEach"?: (run: any) => any;
1537
1631
  /**
1538
- * Bind to Vitest 'onTestFinished' hook.
1539
- * Used for testing purposes.
1540
- * This is automatically attached if Alepha#create() detects a test environment and global 'onTestFinished' is available.
1541
- */
1632
+ * Bind to Vitest 'onTestFinished' hook.
1633
+ * Used for testing purposes.
1634
+ * This is automatically attached if Alepha#create() detects a test environment and global 'onTestFinished' is available.
1635
+ */
1542
1636
  "alepha.test.onTestFinished"?: (run: any) => any;
1543
1637
  /**
1544
- * List of static assets to be copied to the output directory during the build process.
1545
- *
1546
- * Used for Alepha-based applications that require static assets.
1547
- *
1548
- * See alepha/vite for more details.
1549
- */
1638
+ * List of static assets to be copied to the output directory during the build process.
1639
+ *
1640
+ * Used for Alepha-based applications that require static assets.
1641
+ *
1642
+ * See alepha/vite for more details.
1643
+ */
1550
1644
  "alepha.build.assets"?: Array<string>;
1551
1645
  }
1552
1646
  interface Hooks {
1553
1647
  /**
1554
- * Used for testing purposes.
1555
- */
1648
+ * Used for testing purposes.
1649
+ */
1556
1650
  echo: unknown;
1557
1651
  /**
1558
- * Triggered during the configuration phase. Before the start phase.
1559
- */
1652
+ * Triggered during the configuration phase. Before the start phase.
1653
+ */
1560
1654
  configure: Alepha;
1561
1655
  /**
1562
- * Triggered during the start phase. When `Alepha#start()` is called.
1563
- */
1656
+ * Triggered during the start phase. When `Alepha#start()` is called.
1657
+ */
1564
1658
  start: Alepha;
1565
1659
  /**
1566
- * Triggered during the ready phase. After the start phase.
1567
- */
1660
+ * Triggered during the ready phase. After the start phase.
1661
+ */
1568
1662
  ready: Alepha;
1569
1663
  /**
1570
- * Triggered during the stop phase.
1571
- *
1572
- * - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)
1573
- *
1574
- */
1664
+ * Triggered during the stop phase.
1665
+ *
1666
+ * - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)
1667
+ *
1668
+ */
1575
1669
  stop: Alepha;
1576
1670
  /**
1577
- * Triggered when a state value is mutated.
1578
- */
1671
+ * Triggered when a state value is mutated.
1672
+ */
1579
1673
  "state:mutate": {
1580
1674
  /**
1581
- * The key of the state that was mutated.
1582
- */
1675
+ * The key of the state that was mutated.
1676
+ */
1583
1677
  key: keyof State;
1584
1678
  /**
1585
- * The new value of the state.
1586
- */
1679
+ * The new value of the state.
1680
+ */
1587
1681
  value: any;
1588
1682
  /**
1589
- * The previous value of the state.
1590
- */
1683
+ * The previous value of the state.
1684
+ */
1591
1685
  prevValue: any;
1592
1686
  };
1593
1687
  }
@@ -1702,8 +1796,8 @@ type TPage<T extends TObject | TRecord> = TObject<{
1702
1796
  */
1703
1797
  type Page<T> = {
1704
1798
  /**
1705
- * Array of items on the current page.
1706
- */
1799
+ * Array of items on the current page.
1800
+ */
1707
1801
  content: T[];
1708
1802
  page: Static<typeof pageMetadataSchema>;
1709
1803
  };
@@ -1711,12 +1805,11 @@ type PageMetadata = Static<typeof pageMetadataSchema>;
1711
1805
  declare module "alepha" {
1712
1806
  interface TypeProvider {
1713
1807
  /**
1714
- * Create a schema for a paginated response.
1715
- */
1808
+ * Create a schema for a paginated response.
1809
+ */
1716
1810
  page<T extends TObject | TRecord>(itemSchema: T): TPage<T>;
1717
1811
  }
1718
- }
1719
- //# sourceMappingURL=pageSchema.d.ts.map
1812
+ } //# sourceMappingURL=pageSchema.d.ts.map
1720
1813
  //#endregion
1721
1814
  //#region ../../src/core/helpers/createPagination.d.ts
1722
1815
  /**
@@ -1872,14 +1965,14 @@ declare function jsonSchemaToTypeBox(schema: JsonSchemaObject): TSchema$1;
1872
1965
  */
1873
1966
  interface PageRequest {
1874
1967
  /**
1875
- * The page number to retrieve (0-indexed).
1876
- * @default 0
1877
- */
1968
+ * The page number to retrieve (0-indexed).
1969
+ * @default 0
1970
+ */
1878
1971
  page?: number;
1879
1972
  /**
1880
- * The number of items per page.
1881
- * @default 10
1882
- */
1973
+ * The number of items per page.
1974
+ * @default 10
1975
+ */
1883
1976
  size?: number;
1884
1977
  }
1885
1978
  /**
@@ -1891,13 +1984,13 @@ type SortDirection = "asc" | "desc";
1891
1984
  */
1892
1985
  interface SortField {
1893
1986
  /**
1894
- * The field/column name to sort by.
1895
- */
1987
+ * The field/column name to sort by.
1988
+ */
1896
1989
  field: string;
1897
1990
  /**
1898
- * The sort direction.
1899
- * @default "asc"
1900
- */
1991
+ * The sort direction.
1992
+ * @default "asc"
1993
+ */
1901
1994
  direction: SortDirection;
1902
1995
  }
1903
1996
  //#endregion
@@ -1932,17 +2025,17 @@ interface SortField {
1932
2025
  declare const $context: () => ContextPrimitive;
1933
2026
  interface ContextPrimitive {
1934
2027
  /**
1935
- * Alepha instance.
1936
- */
2028
+ * Alepha instance.
2029
+ */
1937
2030
  alepha: Alepha;
1938
2031
  /**
1939
- * Service definition which is creating this primitive.
1940
- * This is NOT the instance but the service definition.
1941
- */
2032
+ * Service definition which is creating this primitive.
2033
+ * This is NOT the instance but the service definition.
2034
+ */
1942
2035
  service?: Service;
1943
2036
  /**
1944
- * Module definition, if any.
1945
- */
2037
+ * Module definition, if any.
2038
+ */
1946
2039
  module?: Service;
1947
2040
  }
1948
2041
  //#endregion
@@ -2011,27 +2104,27 @@ type PageQuery = Static<typeof pageQuerySchema>;
2011
2104
  //#region ../../src/core/interfaces/Run.d.ts
2012
2105
  interface RunOptions {
2013
2106
  /**
2014
- * Environment variables to be used by the application.
2015
- * It will be merged with the current process environment.
2016
- */
2107
+ * Environment variables to be used by the application.
2108
+ * It will be merged with the current process environment.
2109
+ */
2017
2110
  env?: Env;
2018
2111
  /**
2019
- * A callback that will be executed before the application starts.
2020
- */
2112
+ * A callback that will be executed before the application starts.
2113
+ */
2021
2114
  configure?: (alepha: Alepha) => Async<void>;
2022
2115
  /**
2023
- * A callback that will be executed once the application is ready.
2024
- * This is useful for initializing resources or starting background tasks.
2025
- */
2116
+ * A callback that will be executed once the application is ready.
2117
+ * This is useful for initializing resources or starting background tasks.
2118
+ */
2026
2119
  ready?: (alepha: Alepha) => Async<void>;
2027
2120
  /**
2028
- * If true, the application will .stop() after the ready callback is executed.
2029
- * Useful for one-time tasks!
2030
- */
2121
+ * If true, the application will .stop() after the ready callback is executed.
2122
+ * Useful for one-time tasks!
2123
+ */
2031
2124
  once?: boolean;
2032
2125
  /**
2033
- * If true, the application will run in cluster mode.
2034
- */
2126
+ * If true, the application will run in cluster mode.
2127
+ */
2035
2128
  cluster?: boolean;
2036
2129
  }
2037
2130
  //#endregion
@@ -2053,5 +2146,5 @@ declare const AlephaCore: Service<Module>;
2053
2146
  */
2054
2147
  declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => Alepha;
2055
2148
  //#endregion
2056
- export { $atom, $context, $env, $hook, $inject, $module, $use, AbstractClass, Alepha, AlephaCore, AlephaDump, AlephaDumpEnvVariable, AlephaError, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, Atom, AtomOptions, AtomStatic, AtomWithValue, CircularDependencyError, CodecManager, ContainerLockedError, ContextPrimitive, DecodeOptions, EncodeOptions, EncodeResult, Encoding, Env, EventManager, FileLike, Format, Hook, HookOptions, HookPrimitive, Hooks, InjectOptions, InjectPrimitive, InstantiableClass, JsonSchemaCodec, JsonSchemaObject, KIND, LogLevel, LoggerInterface, MaybePromise, Module, ModulePrimitiveOptions, OPTIONS, Page, PageMetadata, PageQuery, PageRequest, Primitive, PrimitiveArgs, PrimitiveConfig, PrimitiveFactory, PrimitiveFactoryLike, RunFunction, SchemaCodec, Service, ServiceEntry, ServiceSubstitution, SetStateOptions, SortDirection, SortField, State, StateManager, type Static, type StaticDecode, type StaticEncode, StreamLike, type TAny, type TArray, TAtomObject, type TBigInt, type TBoolean, TFile, type TInteger, type TKeysToIndexer, type TNull, type TNumber, type TNumberOptions, type TObject, type TObjectOptions, type TOptional, type TOptionalAdd, TPage, type TPick, type TProperties, type TRecord, type TSchema, TStream, type TString, type TStringOptions, TTextOptions, type TTuple, type TUnion, type TUnsafe, type TVoid, TextLength, TooLateSubstitutionError, Type, TypeBoxError, TypeBoxErrorParams, TypeGuard, TypeProvider, Value, WithModule, createPagination, createPrimitive, isClass, isFileLike, isTypeFile, isUUID, jsonSchemaToTypeBox, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
2149
+ export { $atom, $context, $env, $hook, $inject, $module, $use, AbstractClass, Alepha, AlephaCore, AlephaDump, AlephaDumpEnvVariable, AlephaError, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, Atom, AtomOptions, AtomStatic, AtomWithValue, CircularDependencyError, CodecManager, CodecRegisterOptions, CompileOptions, CompiledEventExecutor, ContainerLockedError, ContextPrimitive, DecodeOptions, EncodeOptions, EncodeResult, Encoding, Env, EventManager, FileLike, Format, Hook, HookOptions, HookPrimitive, Hooks, InjectOptions, InjectPrimitive, InstantiableClass, JsonSchemaCodec, JsonSchemaObject, KIND, KeylessCodec, KeylessJsonSchemaCodec, LogLevel, LoggerInterface, MaybePromise, Module, ModulePrimitiveOptions, OPTIONS, Page, PageMetadata, PageQuery, PageRequest, Primitive, PrimitiveArgs, PrimitiveConfig, PrimitiveFactory, PrimitiveFactoryLike, RunFunction, SchemaCodec, Service, ServiceEntry, ServiceSubstitution, SetStateOptions, SortDirection, SortField, State, StateManager, type Static, type StaticDecode, type StaticEncode, StreamLike, type TAny, type TArray, TAtomObject, type TBigInt, type TBoolean, TFile, type TInteger, type TKeysToIndexer, type TNull, type TNumber, type TNumberOptions, type TObject, type TObjectOptions, type TOptional, type TOptionalAdd, TPage, type TPick, type TProperties, type TRecord, type TSchema, TStream, type TString, type TStringOptions, TTextOptions, type TTuple, type TUnion, type TUnsafe, type TVoid, TextLength, TooLateSubstitutionError, Type, TypeBoxError, TypeBoxErrorParams, TypeGuard, TypeProvider, Value, WithModule, createPagination, createPrimitive, isClass, isFileLike, isTypeFile, isUUID, jsonSchemaToTypeBox, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
2057
2150
  //# sourceMappingURL=index.d.ts.map