alepha 0.14.3 → 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 (317) hide show
  1. package/README.md +2 -5
  2. package/dist/api/audits/index.d.ts +620 -811
  3. package/dist/api/audits/index.d.ts.map +1 -1
  4. package/dist/api/files/index.d.ts +185 -377
  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 -435
  9. package/dist/api/jobs/index.d.ts.map +1 -1
  10. package/dist/api/notifications/index.d.ts +238 -429
  11. package/dist/api/notifications/index.d.ts.map +1 -1
  12. package/dist/api/parameters/index.d.ts +236 -427
  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 +1010 -1196
  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 +17 -17
  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 +384 -285
  32. package/dist/cli/index.d.ts.map +1 -1
  33. package/dist/cli/index.js +1113 -623
  34. package/dist/cli/index.js.map +1 -1
  35. package/dist/command/index.d.ts +299 -300
  36. package/dist/command/index.d.ts.map +1 -1
  37. package/dist/command/index.js +13 -9
  38. package/dist/command/index.js.map +1 -1
  39. package/dist/core/index.browser.js +445 -103
  40. package/dist/core/index.browser.js.map +1 -1
  41. package/dist/core/index.d.ts +733 -625
  42. package/dist/core/index.d.ts.map +1 -1
  43. package/dist/core/index.js +446 -103
  44. package/dist/core/index.js.map +1 -1
  45. package/dist/core/index.native.js +445 -103
  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/logger/index.js +12 -2
  67. package/dist/logger/index.js.map +1 -1
  68. package/dist/mcp/index.d.ts +197 -197
  69. package/dist/mcp/index.d.ts.map +1 -1
  70. package/dist/mcp/index.js +1 -1
  71. package/dist/mcp/index.js.map +1 -1
  72. package/dist/orm/chunk-DtkW-qnP.js +38 -0
  73. package/dist/orm/index.browser.js.map +1 -1
  74. package/dist/orm/index.bun.js +2814 -0
  75. package/dist/orm/index.bun.js.map +1 -0
  76. package/dist/orm/index.d.ts +1228 -1216
  77. package/dist/orm/index.d.ts.map +1 -1
  78. package/dist/orm/index.js +2041 -1967
  79. package/dist/orm/index.js.map +1 -1
  80. package/dist/queue/core/index.d.ts +248 -248
  81. package/dist/queue/core/index.d.ts.map +1 -1
  82. package/dist/queue/redis/index.d.ts.map +1 -1
  83. package/dist/redis/index.bun.js +285 -0
  84. package/dist/redis/index.bun.js.map +1 -0
  85. package/dist/redis/index.d.ts +118 -136
  86. package/dist/redis/index.d.ts.map +1 -1
  87. package/dist/redis/index.js +18 -38
  88. package/dist/redis/index.js.map +1 -1
  89. package/dist/retry/index.d.ts +69 -69
  90. package/dist/retry/index.d.ts.map +1 -1
  91. package/dist/router/index.d.ts +6 -6
  92. package/dist/router/index.d.ts.map +1 -1
  93. package/dist/scheduler/index.d.ts +25 -25
  94. package/dist/scheduler/index.d.ts.map +1 -1
  95. package/dist/security/index.browser.js +5 -1
  96. package/dist/security/index.browser.js.map +1 -1
  97. package/dist/security/index.d.ts +417 -254
  98. package/dist/security/index.d.ts.map +1 -1
  99. package/dist/security/index.js +386 -86
  100. package/dist/security/index.js.map +1 -1
  101. package/dist/server/auth/index.d.ts +110 -110
  102. package/dist/server/auth/index.d.ts.map +1 -1
  103. package/dist/server/auth/index.js +20 -20
  104. package/dist/server/auth/index.js.map +1 -1
  105. package/dist/server/cache/index.d.ts +62 -47
  106. package/dist/server/cache/index.d.ts.map +1 -1
  107. package/dist/server/cache/index.js +56 -3
  108. package/dist/server/cache/index.js.map +1 -1
  109. package/dist/server/compress/index.d.ts +6 -0
  110. package/dist/server/compress/index.d.ts.map +1 -1
  111. package/dist/server/compress/index.js +36 -1
  112. package/dist/server/compress/index.js.map +1 -1
  113. package/dist/server/cookies/index.d.ts +6 -6
  114. package/dist/server/cookies/index.d.ts.map +1 -1
  115. package/dist/server/cookies/index.js +3 -3
  116. package/dist/server/cookies/index.js.map +1 -1
  117. package/dist/server/core/index.browser.js +2 -2
  118. package/dist/server/core/index.browser.js.map +1 -1
  119. package/dist/server/core/index.d.ts +242 -150
  120. package/dist/server/core/index.d.ts.map +1 -1
  121. package/dist/server/core/index.js +294 -125
  122. package/dist/server/core/index.js.map +1 -1
  123. package/dist/server/cors/index.d.ts +11 -12
  124. package/dist/server/cors/index.d.ts.map +1 -1
  125. package/dist/server/health/index.d.ts +0 -1
  126. package/dist/server/health/index.d.ts.map +1 -1
  127. package/dist/server/helmet/index.d.ts +2 -2
  128. package/dist/server/helmet/index.d.ts.map +1 -1
  129. package/dist/server/links/index.browser.js.map +1 -1
  130. package/dist/server/links/index.d.ts +123 -124
  131. package/dist/server/links/index.d.ts.map +1 -1
  132. package/dist/server/links/index.js +1 -2
  133. package/dist/server/links/index.js.map +1 -1
  134. package/dist/server/metrics/index.d.ts.map +1 -1
  135. package/dist/server/multipart/index.d.ts +6 -6
  136. package/dist/server/multipart/index.d.ts.map +1 -1
  137. package/dist/server/proxy/index.d.ts +102 -103
  138. package/dist/server/proxy/index.d.ts.map +1 -1
  139. package/dist/server/rate-limit/index.d.ts +16 -16
  140. package/dist/server/rate-limit/index.d.ts.map +1 -1
  141. package/dist/server/static/index.d.ts +44 -44
  142. package/dist/server/static/index.d.ts.map +1 -1
  143. package/dist/server/static/index.js +4 -0
  144. package/dist/server/static/index.js.map +1 -1
  145. package/dist/server/swagger/index.d.ts +48 -49
  146. package/dist/server/swagger/index.d.ts.map +1 -1
  147. package/dist/server/swagger/index.js +3 -5
  148. package/dist/server/swagger/index.js.map +1 -1
  149. package/dist/sms/index.d.ts +13 -11
  150. package/dist/sms/index.d.ts.map +1 -1
  151. package/dist/sms/index.js +7 -7
  152. package/dist/sms/index.js.map +1 -1
  153. package/dist/thread/index.d.ts +71 -72
  154. package/dist/thread/index.d.ts.map +1 -1
  155. package/dist/topic/core/index.d.ts +318 -318
  156. package/dist/topic/core/index.d.ts.map +1 -1
  157. package/dist/topic/redis/index.d.ts +6 -6
  158. package/dist/topic/redis/index.d.ts.map +1 -1
  159. package/dist/vite/index.d.ts +5805 -249
  160. package/dist/vite/index.d.ts.map +1 -1
  161. package/dist/vite/index.js +599 -513
  162. package/dist/vite/index.js.map +1 -1
  163. package/dist/websocket/index.browser.js +6 -6
  164. package/dist/websocket/index.browser.js.map +1 -1
  165. package/dist/websocket/index.d.ts +247 -247
  166. package/dist/websocket/index.d.ts.map +1 -1
  167. package/dist/websocket/index.js +6 -6
  168. package/dist/websocket/index.js.map +1 -1
  169. package/package.json +9 -14
  170. package/src/api/files/controllers/AdminFileStatsController.ts +0 -1
  171. package/src/api/users/atoms/realmAuthSettingsAtom.ts +5 -0
  172. package/src/api/users/controllers/{UserRealmController.ts → RealmController.ts} +11 -11
  173. package/src/api/users/entities/users.ts +1 -1
  174. package/src/api/users/index.ts +8 -8
  175. package/src/api/users/primitives/{$userRealm.ts → $realm.ts} +17 -19
  176. package/src/api/users/providers/{UserRealmProvider.ts → RealmProvider.ts} +26 -30
  177. package/src/api/users/schemas/{userRealmConfigSchema.ts → realmConfigSchema.ts} +2 -2
  178. package/src/api/users/services/CredentialService.ts +7 -7
  179. package/src/api/users/services/IdentityService.ts +4 -4
  180. package/src/api/users/services/RegistrationService.spec.ts +25 -27
  181. package/src/api/users/services/RegistrationService.ts +38 -27
  182. package/src/api/users/services/SessionCrudService.ts +3 -3
  183. package/src/api/users/services/SessionService.spec.ts +3 -3
  184. package/src/api/users/services/SessionService.ts +28 -9
  185. package/src/api/users/services/UserService.ts +7 -7
  186. package/src/batch/providers/BatchProvider.ts +1 -2
  187. package/src/cli/apps/AlephaCli.ts +0 -2
  188. package/src/cli/apps/AlephaPackageBuilderCli.ts +38 -19
  189. package/src/cli/assets/apiHelloControllerTs.ts +18 -0
  190. package/src/cli/assets/apiIndexTs.ts +16 -0
  191. package/src/cli/assets/claudeMd.ts +303 -0
  192. package/src/cli/assets/mainBrowserTs.ts +2 -2
  193. package/src/cli/assets/mainServerTs.ts +24 -0
  194. package/src/cli/assets/webAppRouterTs.ts +15 -0
  195. package/src/cli/assets/webHelloComponentTsx.ts +16 -0
  196. package/src/cli/assets/webIndexTs.ts +16 -0
  197. package/src/cli/atoms/buildOptions.ts +88 -0
  198. package/src/cli/commands/build.ts +70 -87
  199. package/src/cli/commands/db.ts +21 -22
  200. package/src/cli/commands/deploy.ts +17 -5
  201. package/src/cli/commands/dev.ts +22 -14
  202. package/src/cli/commands/format.ts +8 -2
  203. package/src/cli/commands/gen/env.ts +53 -0
  204. package/src/cli/commands/gen/openapi.ts +1 -1
  205. package/src/cli/commands/gen/resource.ts +15 -0
  206. package/src/cli/commands/gen.ts +7 -1
  207. package/src/cli/commands/init.ts +74 -30
  208. package/src/cli/commands/lint.ts +8 -2
  209. package/src/cli/commands/test.ts +8 -3
  210. package/src/cli/commands/typecheck.ts +5 -1
  211. package/src/cli/commands/verify.ts +5 -3
  212. package/src/cli/defineConfig.ts +49 -7
  213. package/src/cli/index.ts +0 -1
  214. package/src/cli/services/AlephaCliUtils.ts +39 -589
  215. package/src/cli/services/PackageManagerUtils.ts +301 -0
  216. package/src/cli/services/ProjectScaffolder.ts +306 -0
  217. package/src/command/helpers/Runner.spec.ts +2 -2
  218. package/src/command/helpers/Runner.ts +16 -4
  219. package/src/command/primitives/$command.ts +0 -6
  220. package/src/command/providers/CliProvider.ts +1 -3
  221. package/src/core/Alepha.ts +42 -0
  222. package/src/core/__tests__/Alepha-graph.spec.ts +4 -0
  223. package/src/core/index.shared.ts +1 -0
  224. package/src/core/index.ts +2 -0
  225. package/src/core/primitives/$hook.ts +6 -2
  226. package/src/core/primitives/$module.spec.ts +4 -0
  227. package/src/core/providers/AlsProvider.ts +1 -1
  228. package/src/core/providers/CodecManager.spec.ts +12 -6
  229. package/src/core/providers/CodecManager.ts +26 -6
  230. package/src/core/providers/EventManager.ts +169 -13
  231. package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +621 -0
  232. package/src/core/providers/KeylessJsonSchemaCodec.ts +407 -0
  233. package/src/core/providers/StateManager.spec.ts +27 -16
  234. package/src/email/providers/LocalEmailProvider.spec.ts +111 -87
  235. package/src/email/providers/LocalEmailProvider.ts +52 -15
  236. package/src/email/providers/NodemailerEmailProvider.ts +167 -56
  237. package/src/file/errors/FileError.ts +7 -0
  238. package/src/file/index.ts +9 -1
  239. package/src/file/providers/MemoryFileSystemProvider.ts +393 -0
  240. package/src/logger/index.ts +15 -3
  241. package/src/mcp/transports/StdioMcpTransport.ts +1 -1
  242. package/src/orm/index.browser.ts +1 -19
  243. package/src/orm/index.bun.ts +77 -0
  244. package/src/orm/index.shared-server.ts +22 -0
  245. package/src/orm/index.shared.ts +15 -0
  246. package/src/orm/index.ts +13 -39
  247. package/src/orm/providers/drivers/BunPostgresProvider.ts +3 -5
  248. package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -1
  249. package/src/orm/providers/drivers/CloudflareD1Provider.ts +4 -0
  250. package/src/orm/providers/drivers/DatabaseProvider.ts +4 -0
  251. package/src/orm/providers/drivers/PglitePostgresProvider.ts +4 -0
  252. package/src/orm/services/Repository.ts +8 -0
  253. package/src/queue/core/providers/WorkerProvider.spec.ts +48 -32
  254. package/src/redis/index.bun.ts +35 -0
  255. package/src/redis/providers/BunRedisProvider.ts +12 -43
  256. package/src/redis/providers/BunRedisSubscriberProvider.ts +2 -3
  257. package/src/redis/providers/NodeRedisProvider.ts +16 -34
  258. package/src/{server/security → security}/__tests__/BasicAuth.spec.ts +11 -11
  259. package/src/{server/security → security}/__tests__/ServerSecurityProvider-realm.spec.ts +21 -16
  260. package/src/{server/security/providers → security/__tests__}/ServerSecurityProvider.spec.ts +5 -5
  261. package/src/security/index.browser.ts +5 -0
  262. package/src/security/index.ts +90 -7
  263. package/src/security/primitives/{$realm.spec.ts → $issuer.spec.ts} +11 -11
  264. package/src/security/primitives/{$realm.ts → $issuer.ts} +20 -17
  265. package/src/security/primitives/$role.ts +5 -5
  266. package/src/security/primitives/$serviceAccount.spec.ts +5 -5
  267. package/src/security/primitives/$serviceAccount.ts +3 -3
  268. package/src/{server/security → security}/providers/ServerSecurityProvider.ts +5 -7
  269. package/src/server/auth/primitives/$auth.ts +10 -10
  270. package/src/server/auth/primitives/$authCredentials.ts +3 -3
  271. package/src/server/auth/primitives/$authGithub.ts +3 -3
  272. package/src/server/auth/primitives/$authGoogle.ts +3 -3
  273. package/src/server/auth/providers/ServerAuthProvider.ts +13 -13
  274. package/src/server/cache/providers/ServerCacheProvider.spec.ts +183 -0
  275. package/src/server/cache/providers/ServerCacheProvider.ts +95 -10
  276. package/src/server/compress/providers/ServerCompressProvider.ts +61 -2
  277. package/src/server/cookies/providers/ServerCookiesProvider.ts +3 -3
  278. package/src/server/core/helpers/ServerReply.ts +2 -2
  279. package/src/server/core/providers/NodeHttpServerProvider.ts +25 -6
  280. package/src/server/core/providers/ServerBodyParserProvider.ts +19 -23
  281. package/src/server/core/providers/ServerLoggerProvider.ts +23 -19
  282. package/src/server/core/providers/ServerProvider.ts +155 -22
  283. package/src/server/core/providers/ServerRouterProvider.ts +259 -115
  284. package/src/server/core/providers/ServerTimingProvider.ts +2 -2
  285. package/src/server/links/index.ts +1 -1
  286. package/src/server/links/providers/LinkProvider.ts +1 -1
  287. package/src/server/static/providers/ServerStaticProvider.ts +10 -0
  288. package/src/server/swagger/index.ts +1 -1
  289. package/src/server/swagger/providers/ServerSwaggerProvider.ts +5 -8
  290. package/src/sms/providers/LocalSmsProvider.spec.ts +153 -111
  291. package/src/sms/providers/LocalSmsProvider.ts +8 -7
  292. package/src/vite/helpers/boot.ts +28 -17
  293. package/src/vite/helpers/importViteReact.ts +13 -0
  294. package/src/vite/index.ts +1 -21
  295. package/src/vite/plugins/viteAlephaDev.ts +16 -1
  296. package/src/vite/plugins/viteAlephaSsrPreload.ts +222 -0
  297. package/src/vite/tasks/buildClient.ts +11 -0
  298. package/src/vite/tasks/buildServer.ts +59 -4
  299. package/src/vite/tasks/devServer.ts +71 -0
  300. package/src/vite/tasks/generateCloudflare.ts +7 -0
  301. package/src/vite/tasks/index.ts +2 -1
  302. package/dist/server/security/index.browser.js +0 -13
  303. package/dist/server/security/index.browser.js.map +0 -1
  304. package/dist/server/security/index.d.ts +0 -173
  305. package/dist/server/security/index.d.ts.map +0 -1
  306. package/dist/server/security/index.js +0 -311
  307. package/dist/server/security/index.js.map +0 -1
  308. package/src/cli/assets/appRouterTs.ts +0 -9
  309. package/src/cli/assets/mainTs.ts +0 -13
  310. package/src/cli/assets/viteConfigTs.ts +0 -14
  311. package/src/cli/commands/run.ts +0 -24
  312. package/src/server/security/index.browser.ts +0 -10
  313. package/src/server/security/index.ts +0 -94
  314. package/src/vite/plugins/viteAlepha.ts +0 -37
  315. package/src/vite/plugins/viteAlephaBuild.ts +0 -281
  316. /package/src/{server/security → security}/primitives/$basicAuth.ts +0 -0
  317. /package/src/{server/security → security}/providers/ServerBasicAuthProvider.ts +0 -0
@@ -9,16 +9,12 @@ import { AuditService } from "alepha/api/audits";
9
9
  import * as alepha_logger5 from "alepha/logger";
10
10
  import * as alepha_bucket0 from "alepha/bucket";
11
11
  import * as alepha_server_links0 from "alepha/server/links";
12
+ import { OAuth2Profile, ServerAuthProvider, WithLinkFn, WithLoginFn } from "alepha/server/auth";
12
13
  import * as alepha_cache0 from "alepha/cache";
13
14
  import { DateTime, DateTimeProvider } from "alepha/datetime";
14
- import { CryptoProvider, RealmPrimitive, RealmPrimitiveOptions, UserAccount } from "alepha/security";
15
- import { OAuth2Profile, ServerAuthProvider, WithLinkFn, WithLoginFn } from "alepha/server/auth";
15
+ import { CryptoProvider, IssuerPrimitive, IssuerPrimitiveOptions, UserAccount } from "alepha/security";
16
16
  import { FileSystemProvider } from "alepha/file";
17
17
  import { FileController } from "alepha/api/files";
18
- import "bun";
19
- import "bun:sqlite";
20
- import "drizzle-orm/bun-sql";
21
- import "drizzle-orm/bun-sqlite";
22
18
  import "drizzle-orm/d1";
23
19
  import * as drizzle_orm0 from "drizzle-orm";
24
20
  import { BuildExtraConfigColumns, SQL, SQLWrapper } from "drizzle-orm";
@@ -27,10 +23,7 @@ import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, Pg
27
23
  import { PgTransactionConfig } from "drizzle-orm/pg-core/session";
28
24
  import * as DrizzleKit from "drizzle-kit/api";
29
25
  import "alepha/retry";
30
- import "alepha/lock";
31
26
  import "drizzle-orm/sqlite-core";
32
- import "drizzle-orm/postgres-js";
33
- import "postgres";
34
27
 
35
28
  //#region ../../src/api/users/atoms/realmAuthSettingsAtom.d.ts
36
29
  declare const realmAuthSettingsAtom: alepha23.Atom<alepha23.TObject<{
@@ -42,6 +35,7 @@ declare const realmAuthSettingsAtom: alepha23.Atom<alepha23.TObject<{
42
35
  emailRequired: alepha23.TBoolean;
43
36
  usernameEnabled: alepha23.TBoolean;
44
37
  usernameRequired: alepha23.TBoolean;
38
+ usernameRegExp: alepha23.TString;
45
39
  phoneEnabled: alepha23.TBoolean;
46
40
  phoneRequired: alepha23.TBoolean;
47
41
  verifyEmailRequired: alepha23.TBoolean;
@@ -89,114 +83,114 @@ type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"]]:
89
83
  //#region ../../src/orm/primitives/$entity.d.ts
90
84
  interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
91
85
  /**
92
- * The database table name that will be created for this entity.
93
- * If not provided, name will be inferred from the $repository variable name.
94
- */
86
+ * The database table name that will be created for this entity.
87
+ * If not provided, name will be inferred from the $repository variable name.
88
+ */
95
89
  name: string;
96
90
  /**
97
- * TypeBox schema defining the table structure and column types.
98
- */
91
+ * TypeBox schema defining the table structure and column types.
92
+ */
99
93
  schema: T;
100
94
  /**
101
- * Database indexes to create for query optimization.
102
- */
95
+ * Database indexes to create for query optimization.
96
+ */
103
97
  indexes?: (Keys | {
104
98
  /**
105
- * Single column to index.
106
- */
99
+ * Single column to index.
100
+ */
107
101
  column: Keys;
108
102
  /**
109
- * Whether this should be a unique index (enforces uniqueness constraint).
110
- */
103
+ * Whether this should be a unique index (enforces uniqueness constraint).
104
+ */
111
105
  unique?: boolean;
112
106
  /**
113
- * Custom name for the index. If not provided, generates name automatically.
114
- */
107
+ * Custom name for the index. If not provided, generates name automatically.
108
+ */
115
109
  name?: string;
116
110
  } | {
117
111
  /**
118
- * Multiple columns for composite index (order matters for query optimization).
119
- */
112
+ * Multiple columns for composite index (order matters for query optimization).
113
+ */
120
114
  columns: Keys[];
121
115
  /**
122
- * Whether this should be a unique index (enforces uniqueness constraint).
123
- */
116
+ * Whether this should be a unique index (enforces uniqueness constraint).
117
+ */
124
118
  unique?: boolean;
125
119
  /**
126
- * Custom name for the index. If not provided, generates name automatically.
127
- */
120
+ * Custom name for the index. If not provided, generates name automatically.
121
+ */
128
122
  name?: string;
129
123
  })[];
130
124
  /**
131
- * Foreign key constraints to maintain referential integrity.
132
- */
125
+ * Foreign key constraints to maintain referential integrity.
126
+ */
133
127
  foreignKeys?: Array<{
134
128
  /**
135
- * Optional name for the foreign key constraint.
136
- */
129
+ * Optional name for the foreign key constraint.
130
+ */
137
131
  name?: string;
138
132
  /**
139
- * Local columns that reference the foreign table.
140
- */
133
+ * Local columns that reference the foreign table.
134
+ */
141
135
  columns: Array<keyof Static<T>>;
142
136
  /**
143
- * Referenced columns in the foreign table.
144
- * Must be EntityColumn references from other entities.
145
- */
137
+ * Referenced columns in the foreign table.
138
+ * Must be EntityColumn references from other entities.
139
+ */
146
140
  foreignColumns: Array<() => EntityColumn<any>>;
147
141
  }>;
148
142
  /**
149
- * Additional table constraints for data validation.
150
- *
151
- * Constraints enforce business rules at the database level, providing
152
- * an additional layer of data integrity beyond application validation.
153
- *
154
- * **Constraint Types**:
155
- * - **Unique constraints**: Prevent duplicate values across columns
156
- * - **Check constraints**: Enforce custom validation rules with SQL expressions
157
- *
158
- * @example
159
- * ```ts
160
- * constraints: [
161
- * {
162
- * name: "unique_user_email",
163
- * columns: ["email"],
164
- * unique: true
165
- * },
166
- * {
167
- * name: "valid_age_range",
168
- * columns: ["age"],
169
- * check: sql`age >= 0 AND age <= 150`
170
- * },
171
- * {
172
- * name: "unique_user_username_per_tenant",
173
- * columns: ["tenantId", "username"],
174
- * unique: true
175
- * }
176
- * ]
177
- * ```
178
- */
143
+ * Additional table constraints for data validation.
144
+ *
145
+ * Constraints enforce business rules at the database level, providing
146
+ * an additional layer of data integrity beyond application validation.
147
+ *
148
+ * **Constraint Types**:
149
+ * - **Unique constraints**: Prevent duplicate values across columns
150
+ * - **Check constraints**: Enforce custom validation rules with SQL expressions
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * constraints: [
155
+ * {
156
+ * name: "unique_user_email",
157
+ * columns: ["email"],
158
+ * unique: true
159
+ * },
160
+ * {
161
+ * name: "valid_age_range",
162
+ * columns: ["age"],
163
+ * check: sql`age >= 0 AND age <= 150`
164
+ * },
165
+ * {
166
+ * name: "unique_user_username_per_tenant",
167
+ * columns: ["tenantId", "username"],
168
+ * unique: true
169
+ * }
170
+ * ]
171
+ * ```
172
+ */
179
173
  constraints?: Array<{
180
174
  /**
181
- * Columns involved in this constraint.
182
- */
175
+ * Columns involved in this constraint.
176
+ */
183
177
  columns: Array<keyof Static<T>>;
184
178
  /**
185
- * Optional name for the constraint.
186
- */
179
+ * Optional name for the constraint.
180
+ */
187
181
  name?: string;
188
182
  /**
189
- * Whether this is a unique constraint.
190
- */
183
+ * Whether this is a unique constraint.
184
+ */
191
185
  unique?: boolean | {};
192
186
  /**
193
- * SQL expression for check constraint validation.
194
- */
187
+ * SQL expression for check constraint validation.
188
+ */
195
189
  check?: SQL;
196
190
  }>;
197
191
  /**
198
- * Advanced Drizzle ORM configuration for complex table setups.
199
- */
192
+ * Advanced Drizzle ORM configuration for complex table setups.
193
+ */
200
194
  config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
201
195
  }
202
196
  declare class EntityPrimitive<T extends TObject = TObject> {
@@ -250,8 +244,8 @@ type PgSymbols = {
250
244
  [PG_REF]: PgRefOptions;
251
245
  [PG_ENUM]: PgEnumOptions;
252
246
  /**
253
- * @deprecated Use `PG_IDENTITY` instead.
254
- */
247
+ * @deprecated Use `PG_IDENTITY` instead.
248
+ */
255
249
  [PG_SERIAL]: {};
256
250
  };
257
251
  type PgSymbolKeys = keyof PgSymbols;
@@ -284,416 +278,416 @@ declare class DbError extends AlephaError {
284
278
  //#region ../../src/orm/interfaces/FilterOperators.d.ts
285
279
  interface FilterOperators<TValue> {
286
280
  /**
287
- * Test that two values are equal.
288
- *
289
- * Remember that the SQL standard dictates that
290
- * two NULL values are not equal, so if you want to test
291
- * whether a value is null, you may want to use
292
- * `isNull` instead.
293
- *
294
- * ## Examples
295
- *
296
- * ```ts
297
- * // Select cars made by Ford
298
- * db.select().from(cars)
299
- * .where(eq(cars.make, 'Ford'))
300
- * ```
301
- *
302
- * @see isNull for a way to test equality to NULL.
303
- */
281
+ * Test that two values are equal.
282
+ *
283
+ * Remember that the SQL standard dictates that
284
+ * two NULL values are not equal, so if you want to test
285
+ * whether a value is null, you may want to use
286
+ * `isNull` instead.
287
+ *
288
+ * ## Examples
289
+ *
290
+ * ```ts
291
+ * // Select cars made by Ford
292
+ * db.select().from(cars)
293
+ * .where(eq(cars.make, 'Ford'))
294
+ * ```
295
+ *
296
+ * @see isNull for a way to test equality to NULL.
297
+ */
304
298
  eq?: TValue;
305
299
  /**
306
- * Test that two values are not equal.
307
- *
308
- * Remember that the SQL standard dictates that
309
- * two NULL values are not equal, so if you want to test
310
- * whether a value is not null, you may want to use
311
- * `isNotNull` instead.
312
- *
313
- * ## Examples
314
- *
315
- * ```ts
316
- * // Select cars not made by Ford
317
- * db.select().from(cars)
318
- * .where(ne(cars.make, 'Ford'))
319
- * ```
320
- *
321
- * @see isNotNull for a way to test whether a value is not null.
322
- */
300
+ * Test that two values are not equal.
301
+ *
302
+ * Remember that the SQL standard dictates that
303
+ * two NULL values are not equal, so if you want to test
304
+ * whether a value is not null, you may want to use
305
+ * `isNotNull` instead.
306
+ *
307
+ * ## Examples
308
+ *
309
+ * ```ts
310
+ * // Select cars not made by Ford
311
+ * db.select().from(cars)
312
+ * .where(ne(cars.make, 'Ford'))
313
+ * ```
314
+ *
315
+ * @see isNotNull for a way to test whether a value is not null.
316
+ */
323
317
  ne?: TValue;
324
318
  /**
325
- * Test that the first expression passed is greater than
326
- * the second expression.
327
- *
328
- * ## Examples
329
- *
330
- * ```ts
331
- * // Select cars made after 2000.
332
- * db.select().from(cars)
333
- * .where(gt(cars.year, 2000))
334
- * ```
335
- *
336
- * @see gte for greater-than-or-equal
337
- */
319
+ * Test that the first expression passed is greater than
320
+ * the second expression.
321
+ *
322
+ * ## Examples
323
+ *
324
+ * ```ts
325
+ * // Select cars made after 2000.
326
+ * db.select().from(cars)
327
+ * .where(gt(cars.year, 2000))
328
+ * ```
329
+ *
330
+ * @see gte for greater-than-or-equal
331
+ */
338
332
  gt?: TValue;
339
333
  /**
340
- * Test that the first expression passed is greater than
341
- * or equal to the second expression. Use `gt` to
342
- * test whether an expression is strictly greater
343
- * than another.
344
- *
345
- * ## Examples
346
- *
347
- * ```ts
348
- * // Select cars made on or after 2000.
349
- * db.select().from(cars)
350
- * .where(gte(cars.year, 2000))
351
- * ```
352
- *
353
- * @see gt for a strictly greater-than condition
354
- */
334
+ * Test that the first expression passed is greater than
335
+ * or equal to the second expression. Use `gt` to
336
+ * test whether an expression is strictly greater
337
+ * than another.
338
+ *
339
+ * ## Examples
340
+ *
341
+ * ```ts
342
+ * // Select cars made on or after 2000.
343
+ * db.select().from(cars)
344
+ * .where(gte(cars.year, 2000))
345
+ * ```
346
+ *
347
+ * @see gt for a strictly greater-than condition
348
+ */
355
349
  gte?: TValue;
356
350
  /**
357
- * Test that the first expression passed is less than
358
- * the second expression.
359
- *
360
- * ## Examples
361
- *
362
- * ```ts
363
- * // Select cars made before 2000.
364
- * db.select().from(cars)
365
- * .where(lt(cars.year, 2000))
366
- * ```
367
- *
368
- * @see lte for greater-than-or-equal
369
- */
351
+ * Test that the first expression passed is less than
352
+ * the second expression.
353
+ *
354
+ * ## Examples
355
+ *
356
+ * ```ts
357
+ * // Select cars made before 2000.
358
+ * db.select().from(cars)
359
+ * .where(lt(cars.year, 2000))
360
+ * ```
361
+ *
362
+ * @see lte for greater-than-or-equal
363
+ */
370
364
  lt?: TValue;
371
365
  /**
372
- * Test that the first expression passed is less than
373
- * or equal to the second expression.
374
- *
375
- * ## Examples
376
- *
377
- * ```ts
378
- * // Select cars made before 2000.
379
- * db.select().from(cars)
380
- * .where(lte(cars.year, 2000))
381
- * ```
382
- *
383
- * @see lt for a strictly less-than condition
384
- */
366
+ * Test that the first expression passed is less than
367
+ * or equal to the second expression.
368
+ *
369
+ * ## Examples
370
+ *
371
+ * ```ts
372
+ * // Select cars made before 2000.
373
+ * db.select().from(cars)
374
+ * .where(lte(cars.year, 2000))
375
+ * ```
376
+ *
377
+ * @see lt for a strictly less-than condition
378
+ */
385
379
  lte?: TValue;
386
380
  /**
387
- * Test whether the first parameter, a column or expression,
388
- * has a value from a list passed as the second argument.
389
- *
390
- * ## Throws
391
- *
392
- * The argument passed in the second array can't be empty:
393
- * if an empty is provided, this method will throw.
394
- *
395
- * ## Examples
396
- *
397
- * ```ts
398
- * // Select cars made by Ford or GM.
399
- * db.select().from(cars)
400
- * .where(inArray(cars.make, ['Ford', 'GM']))
401
- * ```
402
- *
403
- * @see notInArray for the inverse of this test
404
- */
381
+ * Test whether the first parameter, a column or expression,
382
+ * has a value from a list passed as the second argument.
383
+ *
384
+ * ## Throws
385
+ *
386
+ * The argument passed in the second array can't be empty:
387
+ * if an empty is provided, this method will throw.
388
+ *
389
+ * ## Examples
390
+ *
391
+ * ```ts
392
+ * // Select cars made by Ford or GM.
393
+ * db.select().from(cars)
394
+ * .where(inArray(cars.make, ['Ford', 'GM']))
395
+ * ```
396
+ *
397
+ * @see notInArray for the inverse of this test
398
+ */
405
399
  inArray?: TValue[];
406
400
  /**
407
- * Test whether the first parameter, a column or expression,
408
- * has a value that is not present in a list passed as the
409
- * second argument.
410
- *
411
- * ## Throws
412
- *
413
- * The argument passed in the second array can't be empty:
414
- * if an empty is provided, this method will throw.
415
- *
416
- * ## Examples
417
- *
418
- * ```ts
419
- * // Select cars made by any company except Ford or GM.
420
- * db.select().from(cars)
421
- * .where(notInArray(cars.make, ['Ford', 'GM']))
422
- * ```
423
- *
424
- * @see inArray for the inverse of this test
425
- */
401
+ * Test whether the first parameter, a column or expression,
402
+ * has a value that is not present in a list passed as the
403
+ * second argument.
404
+ *
405
+ * ## Throws
406
+ *
407
+ * The argument passed in the second array can't be empty:
408
+ * if an empty is provided, this method will throw.
409
+ *
410
+ * ## Examples
411
+ *
412
+ * ```ts
413
+ * // Select cars made by any company except Ford or GM.
414
+ * db.select().from(cars)
415
+ * .where(notInArray(cars.make, ['Ford', 'GM']))
416
+ * ```
417
+ *
418
+ * @see inArray for the inverse of this test
419
+ */
426
420
  notInArray?: TValue[];
427
421
  /**
428
- * Test whether an expression is not NULL. By the SQL standard,
429
- * NULL is neither equal nor not equal to itself, so
430
- * it's recommended to use `isNull` and `notIsNull` for
431
- * comparisons to NULL.
432
- *
433
- * ## Examples
434
- *
435
- * ```ts
436
- * // Select cars that have been discontinued.
437
- * db.select().from(cars)
438
- * .where(isNotNull(cars.discontinuedAt))
439
- * ```
440
- *
441
- * @see isNull for the inverse of this test
442
- */
422
+ * Test whether an expression is not NULL. By the SQL standard,
423
+ * NULL is neither equal nor not equal to itself, so
424
+ * it's recommended to use `isNull` and `notIsNull` for
425
+ * comparisons to NULL.
426
+ *
427
+ * ## Examples
428
+ *
429
+ * ```ts
430
+ * // Select cars that have been discontinued.
431
+ * db.select().from(cars)
432
+ * .where(isNotNull(cars.discontinuedAt))
433
+ * ```
434
+ *
435
+ * @see isNull for the inverse of this test
436
+ */
443
437
  isNotNull?: true;
444
438
  /**
445
- * Test whether an expression is NULL. By the SQL standard,
446
- * NULL is neither equal nor not equal to itself, so
447
- * it's recommended to use `isNull` and `notIsNull` for
448
- * comparisons to NULL.
449
- *
450
- * ## Examples
451
- *
452
- * ```ts
453
- * // Select cars that have no discontinuedAt date.
454
- * db.select().from(cars)
455
- * .where(isNull(cars.discontinuedAt))
456
- * ```
457
- *
458
- * @see isNotNull for the inverse of this test
459
- */
439
+ * Test whether an expression is NULL. By the SQL standard,
440
+ * NULL is neither equal nor not equal to itself, so
441
+ * it's recommended to use `isNull` and `notIsNull` for
442
+ * comparisons to NULL.
443
+ *
444
+ * ## Examples
445
+ *
446
+ * ```ts
447
+ * // Select cars that have no discontinuedAt date.
448
+ * db.select().from(cars)
449
+ * .where(isNull(cars.discontinuedAt))
450
+ * ```
451
+ *
452
+ * @see isNotNull for the inverse of this test
453
+ */
460
454
  isNull?: true;
461
455
  /**
462
- * Test whether an expression is between two values. This
463
- * is an easier way to express range tests, which would be
464
- * expressed mathematically as `x <= a <= y` but in SQL
465
- * would have to be like `a >= x AND a <= y`.
466
- *
467
- * Between is inclusive of the endpoints: if `column`
468
- * is equal to `min` or `max`, it will be TRUE.
469
- *
470
- * ## Examples
471
- *
472
- * ```ts
473
- * // Select cars made between 1990 and 2000
474
- * db.select().from(cars)
475
- * .where(between(cars.year, 1990, 2000))
476
- * ```
477
- *
478
- * @see notBetween for the inverse of this test
479
- */
456
+ * Test whether an expression is between two values. This
457
+ * is an easier way to express range tests, which would be
458
+ * expressed mathematically as `x <= a <= y` but in SQL
459
+ * would have to be like `a >= x AND a <= y`.
460
+ *
461
+ * Between is inclusive of the endpoints: if `column`
462
+ * is equal to `min` or `max`, it will be TRUE.
463
+ *
464
+ * ## Examples
465
+ *
466
+ * ```ts
467
+ * // Select cars made between 1990 and 2000
468
+ * db.select().from(cars)
469
+ * .where(between(cars.year, 1990, 2000))
470
+ * ```
471
+ *
472
+ * @see notBetween for the inverse of this test
473
+ */
480
474
  between?: [number, number];
481
475
  /**
482
- * Test whether an expression is not between two values.
483
- *
484
- * This, like `between`, includes its endpoints, so if
485
- * the `column` is equal to `min` or `max`, in this case
486
- * it will evaluate to FALSE.
487
- *
488
- * ## Examples
489
- *
490
- * ```ts
491
- * // Exclude cars made in the 1970s
492
- * db.select().from(cars)
493
- * .where(notBetween(cars.year, 1970, 1979))
494
- * ```
495
- *
496
- * @see between for the inverse of this test
497
- */
476
+ * Test whether an expression is not between two values.
477
+ *
478
+ * This, like `between`, includes its endpoints, so if
479
+ * the `column` is equal to `min` or `max`, in this case
480
+ * it will evaluate to FALSE.
481
+ *
482
+ * ## Examples
483
+ *
484
+ * ```ts
485
+ * // Exclude cars made in the 1970s
486
+ * db.select().from(cars)
487
+ * .where(notBetween(cars.year, 1970, 1979))
488
+ * ```
489
+ *
490
+ * @see between for the inverse of this test
491
+ */
498
492
  notBetween?: [number, number];
499
493
  /**
500
- * Compare a column to a pattern, which can include `%` and `_`
501
- * characters to match multiple variations. Including `%`
502
- * in the pattern matches zero or more characters, and including
503
- * `_` will match a single character.
504
- *
505
- * ## Examples
506
- *
507
- * ```ts
508
- * // Select all cars with 'Turbo' in their names.
509
- * db.select().from(cars)
510
- * .where(like(cars.name, '%Turbo%'))
511
- * ```
512
- *
513
- * @see ilike for a case-insensitive version of this condition
514
- */
494
+ * Compare a column to a pattern, which can include `%` and `_`
495
+ * characters to match multiple variations. Including `%`
496
+ * in the pattern matches zero or more characters, and including
497
+ * `_` will match a single character.
498
+ *
499
+ * ## Examples
500
+ *
501
+ * ```ts
502
+ * // Select all cars with 'Turbo' in their names.
503
+ * db.select().from(cars)
504
+ * .where(like(cars.name, '%Turbo%'))
505
+ * ```
506
+ *
507
+ * @see ilike for a case-insensitive version of this condition
508
+ */
515
509
  like?: string;
516
510
  /**
517
- * The inverse of like - this tests that a given column
518
- * does not match a pattern, which can include `%` and `_`
519
- * characters to match multiple variations. Including `%`
520
- * in the pattern matches zero or more characters, and including
521
- * `_` will match a single character.
522
- *
523
- * ## Examples
524
- *
525
- * ```ts
526
- * // Select all cars that don't have "ROver" in their name.
527
- * db.select().from(cars)
528
- * .where(notLike(cars.name, '%Rover%'))
529
- * ```
530
- *
531
- * @see like for the inverse condition
532
- * @see notIlike for a case-insensitive version of this condition
533
- */
511
+ * The inverse of like - this tests that a given column
512
+ * does not match a pattern, which can include `%` and `_`
513
+ * characters to match multiple variations. Including `%`
514
+ * in the pattern matches zero or more characters, and including
515
+ * `_` will match a single character.
516
+ *
517
+ * ## Examples
518
+ *
519
+ * ```ts
520
+ * // Select all cars that don't have "ROver" in their name.
521
+ * db.select().from(cars)
522
+ * .where(notLike(cars.name, '%Rover%'))
523
+ * ```
524
+ *
525
+ * @see like for the inverse condition
526
+ * @see notIlike for a case-insensitive version of this condition
527
+ */
534
528
  notLike?: string;
535
529
  /**
536
- * Case-insensitively compare a column to a pattern,
537
- * which can include `%` and `_`
538
- * characters to match multiple variations. Including `%`
539
- * in the pattern matches zero or more characters, and including
540
- * `_` will match a single character.
541
- *
542
- * Unlike like, this performs a case-insensitive comparison.
543
- *
544
- * ## Examples
545
- *
546
- * ```ts
547
- * // Select all cars with 'Turbo' in their names.
548
- * db.select().from(cars)
549
- * .where(ilike(cars.name, '%Turbo%'))
550
- * ```
551
- *
552
- * @see like for a case-sensitive version of this condition
553
- */
530
+ * Case-insensitively compare a column to a pattern,
531
+ * which can include `%` and `_`
532
+ * characters to match multiple variations. Including `%`
533
+ * in the pattern matches zero or more characters, and including
534
+ * `_` will match a single character.
535
+ *
536
+ * Unlike like, this performs a case-insensitive comparison.
537
+ *
538
+ * ## Examples
539
+ *
540
+ * ```ts
541
+ * // Select all cars with 'Turbo' in their names.
542
+ * db.select().from(cars)
543
+ * .where(ilike(cars.name, '%Turbo%'))
544
+ * ```
545
+ *
546
+ * @see like for a case-sensitive version of this condition
547
+ */
554
548
  ilike?: string;
555
549
  /**
556
- * The inverse of ilike - this case-insensitively tests that a given column
557
- * does not match a pattern, which can include `%` and `_`
558
- * characters to match multiple variations. Including `%`
559
- * in the pattern matches zero or more characters, and including
560
- * `_` will match a single character.
561
- *
562
- * ## Examples
563
- *
564
- * ```ts
565
- * // Select all cars that don't have "Rover" in their name.
566
- * db.select().from(cars)
567
- * .where(notLike(cars.name, '%Rover%'))
568
- * ```
569
- *
570
- * @see ilike for the inverse condition
571
- * @see notLike for a case-sensitive version of this condition
572
- */
550
+ * The inverse of ilike - this case-insensitively tests that a given column
551
+ * does not match a pattern, which can include `%` and `_`
552
+ * characters to match multiple variations. Including `%`
553
+ * in the pattern matches zero or more characters, and including
554
+ * `_` will match a single character.
555
+ *
556
+ * ## Examples
557
+ *
558
+ * ```ts
559
+ * // Select all cars that don't have "Rover" in their name.
560
+ * db.select().from(cars)
561
+ * .where(notLike(cars.name, '%Rover%'))
562
+ * ```
563
+ *
564
+ * @see ilike for the inverse condition
565
+ * @see notLike for a case-sensitive version of this condition
566
+ */
573
567
  notIlike?: string;
574
568
  /**
575
- * Syntactic sugar for case-insensitive substring matching.
576
- * Automatically wraps the value with `%` wildcards on both sides.
577
- *
578
- * Equivalent to: `ilike: '%value%'`
579
- *
580
- * ## Examples
581
- *
582
- * ```ts
583
- * // Select all cars with "Turbo" anywhere in their name.
584
- * db.select().from(cars)
585
- * .where({ name: { contains: 'Turbo' } })
586
- * // Same as: .where(ilike(cars.name, '%Turbo%'))
587
- * ```
588
- *
589
- * @see ilike for manual pattern matching
590
- * @see startsWith for prefix matching
591
- * @see endsWith for suffix matching
592
- */
569
+ * Syntactic sugar for case-insensitive substring matching.
570
+ * Automatically wraps the value with `%` wildcards on both sides.
571
+ *
572
+ * Equivalent to: `ilike: '%value%'`
573
+ *
574
+ * ## Examples
575
+ *
576
+ * ```ts
577
+ * // Select all cars with "Turbo" anywhere in their name.
578
+ * db.select().from(cars)
579
+ * .where({ name: { contains: 'Turbo' } })
580
+ * // Same as: .where(ilike(cars.name, '%Turbo%'))
581
+ * ```
582
+ *
583
+ * @see ilike for manual pattern matching
584
+ * @see startsWith for prefix matching
585
+ * @see endsWith for suffix matching
586
+ */
593
587
  contains?: string;
594
588
  /**
595
- * Syntactic sugar for case-insensitive prefix matching.
596
- * Automatically appends a `%` wildcard to the end of the value.
597
- *
598
- * Equivalent to: `ilike: 'value%'`
599
- *
600
- * ## Examples
601
- *
602
- * ```ts
603
- * // Select all cars whose names start with "Ford".
604
- * db.select().from(cars)
605
- * .where({ name: { startsWith: 'Ford' } })
606
- * // Same as: .where(ilike(cars.name, 'Ford%'))
607
- * ```
608
- *
609
- * @see ilike for manual pattern matching
610
- * @see contains for substring matching
611
- * @see endsWith for suffix matching
612
- */
589
+ * Syntactic sugar for case-insensitive prefix matching.
590
+ * Automatically appends a `%` wildcard to the end of the value.
591
+ *
592
+ * Equivalent to: `ilike: 'value%'`
593
+ *
594
+ * ## Examples
595
+ *
596
+ * ```ts
597
+ * // Select all cars whose names start with "Ford".
598
+ * db.select().from(cars)
599
+ * .where({ name: { startsWith: 'Ford' } })
600
+ * // Same as: .where(ilike(cars.name, 'Ford%'))
601
+ * ```
602
+ *
603
+ * @see ilike for manual pattern matching
604
+ * @see contains for substring matching
605
+ * @see endsWith for suffix matching
606
+ */
613
607
  startsWith?: string;
614
608
  /**
615
- * Syntactic sugar for case-insensitive suffix matching.
616
- * Automatically prepends a `%` wildcard to the beginning of the value.
617
- *
618
- * Equivalent to: `ilike: '%value'`
619
- *
620
- * ## Examples
621
- *
622
- * ```ts
623
- * // Select all cars whose names end with "Turbo".
624
- * db.select().from(cars)
625
- * .where({ name: { endsWith: 'Turbo' } })
626
- * // Same as: .where(ilike(cars.name, '%Turbo'))
627
- * ```
628
- *
629
- * @see ilike for manual pattern matching
630
- * @see contains for substring matching
631
- * @see startsWith for prefix matching
632
- */
609
+ * Syntactic sugar for case-insensitive suffix matching.
610
+ * Automatically prepends a `%` wildcard to the beginning of the value.
611
+ *
612
+ * Equivalent to: `ilike: '%value'`
613
+ *
614
+ * ## Examples
615
+ *
616
+ * ```ts
617
+ * // Select all cars whose names end with "Turbo".
618
+ * db.select().from(cars)
619
+ * .where({ name: { endsWith: 'Turbo' } })
620
+ * // Same as: .where(ilike(cars.name, '%Turbo'))
621
+ * ```
622
+ *
623
+ * @see ilike for manual pattern matching
624
+ * @see contains for substring matching
625
+ * @see startsWith for prefix matching
626
+ */
633
627
  endsWith?: string;
634
628
  /**
635
- * Test that a column or expression contains all elements of
636
- * the list passed as the second argument.
637
- *
638
- * ## Throws
639
- *
640
- * The argument passed in the second array can't be empty:
641
- * if an empty is provided, this method will throw.
642
- *
643
- * ## Examples
644
- *
645
- * ```ts
646
- * // Select posts where its tags contain "Typescript" and "ORM".
647
- * db.select().from(posts)
648
- * .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
649
- * ```
650
- *
651
- * @see arrayContained to find if an array contains all elements of a column or expression
652
- * @see arrayOverlaps to find if a column or expression contains any elements of an array
653
- */
629
+ * Test that a column or expression contains all elements of
630
+ * the list passed as the second argument.
631
+ *
632
+ * ## Throws
633
+ *
634
+ * The argument passed in the second array can't be empty:
635
+ * if an empty is provided, this method will throw.
636
+ *
637
+ * ## Examples
638
+ *
639
+ * ```ts
640
+ * // Select posts where its tags contain "Typescript" and "ORM".
641
+ * db.select().from(posts)
642
+ * .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
643
+ * ```
644
+ *
645
+ * @see arrayContained to find if an array contains all elements of a column or expression
646
+ * @see arrayOverlaps to find if a column or expression contains any elements of an array
647
+ */
654
648
  arrayContains?: TValue;
655
649
  /**
656
- * Test that the list passed as the second argument contains
657
- * all elements of a column or expression.
658
- *
659
- * ## Throws
660
- *
661
- * The argument passed in the second array can't be empty:
662
- * if an empty is provided, this method will throw.
663
- *
664
- * ## Examples
665
- *
666
- * ```ts
667
- * // Select posts where its tags contain "Typescript", "ORM" or both,
668
- * // but filtering posts that have additional tags.
669
- * db.select().from(posts)
670
- * .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
671
- * ```
672
- *
673
- * @see arrayContains to find if a column or expression contains all elements of an array
674
- * @see arrayOverlaps to find if a column or expression contains any elements of an array
675
- */
650
+ * Test that the list passed as the second argument contains
651
+ * all elements of a column or expression.
652
+ *
653
+ * ## Throws
654
+ *
655
+ * The argument passed in the second array can't be empty:
656
+ * if an empty is provided, this method will throw.
657
+ *
658
+ * ## Examples
659
+ *
660
+ * ```ts
661
+ * // Select posts where its tags contain "Typescript", "ORM" or both,
662
+ * // but filtering posts that have additional tags.
663
+ * db.select().from(posts)
664
+ * .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
665
+ * ```
666
+ *
667
+ * @see arrayContains to find if a column or expression contains all elements of an array
668
+ * @see arrayOverlaps to find if a column or expression contains any elements of an array
669
+ */
676
670
  arrayContained?: TValue;
677
671
  /**
678
- * Test that a column or expression contains any elements of
679
- * the list passed as the second argument.
680
- *
681
- * ## Throws
682
- *
683
- * The argument passed in the second array can't be empty:
684
- * if an empty is provided, this method will throw.
685
- *
686
- * ## Examples
687
- *
688
- * ```ts
689
- * // Select posts where its tags contain "Typescript", "ORM" or both.
690
- * db.select().from(posts)
691
- * .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
692
- * ```
693
- *
694
- * @see arrayContains to find if a column or expression contains all elements of an array
695
- * @see arrayContained to find if an array contains all elements of a column or expression
696
- */
672
+ * Test that a column or expression contains any elements of
673
+ * the list passed as the second argument.
674
+ *
675
+ * ## Throws
676
+ *
677
+ * The argument passed in the second array can't be empty:
678
+ * if an empty is provided, this method will throw.
679
+ *
680
+ * ## Examples
681
+ *
682
+ * ```ts
683
+ * // Select posts where its tags contain "Typescript", "ORM" or both.
684
+ * db.select().from(posts)
685
+ * .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
686
+ * ```
687
+ *
688
+ * @see arrayContains to find if a column or expression contains all elements of an array
689
+ * @see arrayContained to find if an array contains all elements of a column or expression
690
+ */
697
691
  arrayOverlaps?: TValue;
698
692
  }
699
693
  //#endregion
@@ -752,71 +746,71 @@ type PgQueryWhereOrSQL<T extends TObject, Relations extends PgRelationMap<TObjec
752
746
  type PgQueryWhereOperators<T extends TObject> = { [Key in keyof Static<T>]?: FilterOperators<Static<T>[Key]> | Static<T>[Key] };
753
747
  type PgQueryWhereConditions<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = {
754
748
  /**
755
- * Combine a list of conditions with the `and` operator. Conditions
756
- * that are equal `undefined` are automatically ignored.
757
- *
758
- * ## Examples
759
- *
760
- * ```ts
761
- * db.select().from(cars)
762
- * .where(
763
- * and(
764
- * eq(cars.make, 'Volvo'),
765
- * eq(cars.year, 1950),
766
- * )
767
- * )
768
- * ```
769
- */
749
+ * Combine a list of conditions with the `and` operator. Conditions
750
+ * that are equal `undefined` are automatically ignored.
751
+ *
752
+ * ## Examples
753
+ *
754
+ * ```ts
755
+ * db.select().from(cars)
756
+ * .where(
757
+ * and(
758
+ * eq(cars.make, 'Volvo'),
759
+ * eq(cars.year, 1950),
760
+ * )
761
+ * )
762
+ * ```
763
+ */
770
764
  and?: Array<PgQueryWhereOrSQL<T, Relations>>;
771
765
  /**
772
- * Combine a list of conditions with the `or` operator. Conditions
773
- * that are equal `undefined` are automatically ignored.
774
- *
775
- * ## Examples
776
- *
777
- * ```ts
778
- * db.select().from(cars)
779
- * .where(
780
- * or(
781
- * eq(cars.make, 'GM'),
782
- * eq(cars.make, 'Ford'),
783
- * )
784
- * )
785
- * ```
786
- */
766
+ * Combine a list of conditions with the `or` operator. Conditions
767
+ * that are equal `undefined` are automatically ignored.
768
+ *
769
+ * ## Examples
770
+ *
771
+ * ```ts
772
+ * db.select().from(cars)
773
+ * .where(
774
+ * or(
775
+ * eq(cars.make, 'GM'),
776
+ * eq(cars.make, 'Ford'),
777
+ * )
778
+ * )
779
+ * ```
780
+ */
787
781
  or?: Array<PgQueryWhereOrSQL<T, Relations>>;
788
782
  /**
789
- * Negate the meaning of an expression using the `not` keyword.
790
- *
791
- * ## Examples
792
- *
793
- * ```ts
794
- * // Select cars _not_ made by GM or Ford.
795
- * db.select().from(cars)
796
- * .where(not(inArray(cars.make, ['GM', 'Ford'])))
797
- * ```
798
- */
783
+ * Negate the meaning of an expression using the `not` keyword.
784
+ *
785
+ * ## Examples
786
+ *
787
+ * ```ts
788
+ * // Select cars _not_ made by GM or Ford.
789
+ * db.select().from(cars)
790
+ * .where(not(inArray(cars.make, ['GM', 'Ford'])))
791
+ * ```
792
+ */
799
793
  not?: PgQueryWhereOrSQL<T, Relations>;
800
794
  /**
801
- * Test whether a subquery evaluates to have any rows.
802
- *
803
- * ## Examples
804
- *
805
- * ```ts
806
- * // Users whose `homeCity` column has a match in a cities
807
- * // table.
808
- * db
809
- * .select()
810
- * .from(users)
811
- * .where(
812
- * exists(db.select()
813
- * .from(cities)
814
- * .where(eq(users.homeCity, cities.id))),
815
- * );
816
- * ```
817
- *
818
- * @see notExists for the inverse of this test
819
- */
795
+ * Test whether a subquery evaluates to have any rows.
796
+ *
797
+ * ## Examples
798
+ *
799
+ * ```ts
800
+ * // Users whose `homeCity` column has a match in a cities
801
+ * // table.
802
+ * db
803
+ * .select()
804
+ * .from(users)
805
+ * .where(
806
+ * exists(db.select()
807
+ * .from(cities)
808
+ * .where(eq(users.homeCity, cities.id))),
809
+ * );
810
+ * ```
811
+ *
812
+ * @see notExists for the inverse of this test
813
+ */
820
814
  exists?: SQLWrapper;
821
815
  };
822
816
  type PgQueryWhereRelations<Relations extends PgRelationMap<TObject> | undefined = undefined> = Relations extends PgRelationMap<TObject> ? { [K in keyof Relations]?: PgQueryWhere<Relations[K]["join"]["schema"], Relations[K]["with"]> } : {};
@@ -837,8 +831,8 @@ interface PgAttrField {
837
831
  //#region ../../src/orm/primitives/$sequence.d.ts
838
832
  interface SequencePrimitiveOptions extends PgSequenceOptions {
839
833
  /**
840
- * The name of the sequence. If not provided, the property key will be used.
841
- */
834
+ * The name of the sequence. If not provided, the property key will be used.
835
+ */
842
836
  name?: string;
843
837
  provider?: DatabaseProvider;
844
838
  }
@@ -878,33 +872,33 @@ interface TableConfigBuilders<TConfig> {
878
872
  */
879
873
  declare abstract class ModelBuilder {
880
874
  /**
881
- * Build a table from an entity primitive.
882
- */
875
+ * Build a table from an entity primitive.
876
+ */
883
877
  abstract buildTable(entity: EntityPrimitive, options: {
884
878
  tables: Map<string, unknown>;
885
879
  enums: Map<string, unknown>;
886
880
  schema: string;
887
881
  }): void;
888
882
  /**
889
- * Build a sequence from a sequence primitive.
890
- */
883
+ * Build a sequence from a sequence primitive.
884
+ */
891
885
  abstract buildSequence(sequence: SequencePrimitive, options: {
892
886
  sequences: Map<string, unknown>;
893
887
  schema: string;
894
888
  }): void;
895
889
  /**
896
- * Convert camelCase to snake_case for column names.
897
- */
890
+ * Convert camelCase to snake_case for column names.
891
+ */
898
892
  protected toColumnName(str: string): string;
899
893
  /**
900
- * Build the table configuration function for any database.
901
- * This includes indexes, foreign keys, constraints, and custom config.
902
- *
903
- * @param entity - The entity primitive
904
- * @param builders - Database-specific builder functions
905
- * @param tableResolver - Function to resolve entity references to table columns
906
- * @param customConfigHandler - Optional handler for custom config
907
- */
894
+ * Build the table configuration function for any database.
895
+ * This includes indexes, foreign keys, constraints, and custom config.
896
+ *
897
+ * @param entity - The entity primitive
898
+ * @param builders - Database-specific builder functions
899
+ * @param tableResolver - Function to resolve entity references to table columns
900
+ * @param customConfigHandler - Optional handler for custom config
901
+ */
908
902
  protected buildTableConfig<TConfig, TSelf>(entity: EntityPrimitive, builders: TableConfigBuilders<TConfig>, tableResolver?: (entityName: string) => any, customConfigHandler?: (config: any, self: TSelf) => TConfig[]): ((self: TSelf) => TConfig[]) | undefined;
909
903
  }
910
904
  //#endregion
@@ -913,37 +907,37 @@ declare class DrizzleKitProvider {
913
907
  protected readonly log: alepha_logger5.Logger;
914
908
  protected readonly alepha: Alepha;
915
909
  /**
916
- * Synchronize database with current schema definitions.
917
- *
918
- * In development mode, it will generate and execute migrations based on the current state.
919
- * In testing mode, it will generate migrations from scratch without applying them.
920
- *
921
- * Does nothing in production mode, you must handle migrations manually.
922
- */
910
+ * Synchronize database with current schema definitions.
911
+ *
912
+ * In development mode, it will generate and execute migrations based on the current state.
913
+ * In testing mode, it will generate migrations from scratch without applying them.
914
+ *
915
+ * Does nothing in production mode, you must handle migrations manually.
916
+ */
923
917
  synchronize(provider: DatabaseProvider): Promise<void>;
924
918
  /**
925
- * Mostly used for testing purposes. You can generate SQL migration statements without executing them.
926
- */
919
+ * Mostly used for testing purposes. You can generate SQL migration statements without executing them.
920
+ */
927
921
  generateMigration(provider: DatabaseProvider, prevSnapshot?: any): Promise<{
928
922
  statements: string[];
929
923
  models: Record<string, unknown>;
930
924
  snapshot?: any;
931
925
  }>;
932
926
  /**
933
- * Load all tables, enums, sequences, etc. from the provider's repositories.
934
- */
927
+ * Load all tables, enums, sequences, etc. from the provider's repositories.
928
+ */
935
929
  getModels(provider: DatabaseProvider): Record<string, unknown>;
936
930
  /**
937
- * Load the migration snapshot from the database.
938
- */
931
+ * Load the migration snapshot from the database.
932
+ */
939
933
  protected loadDevMigrations(provider: DatabaseProvider): Promise<DevMigrations | undefined>;
940
934
  protected saveDevMigrations(provider: DatabaseProvider, curr: Record<string, any>, devMigrations?: DevMigrations): Promise<void>;
941
935
  protected executeStatements(statements: string[], provider: DatabaseProvider, catchErrors?: boolean): Promise<void>;
942
936
  protected createSchemaIfNotExists(provider: DatabaseProvider, schemaName: string): Promise<void>;
943
937
  /**
944
- * Try to load the official Drizzle Kit API.
945
- * If not available, fallback to the local kit import.
946
- */
938
+ * Try to load the official Drizzle Kit API.
939
+ * If not available, fallback to the local kit import.
940
+ */
947
941
  importDrizzleKit(): typeof DrizzleKit;
948
942
  }
949
943
  declare const devMigrationsSchema: alepha23.TObject<{
@@ -968,6 +962,7 @@ declare abstract class DatabaseProvider {
968
962
  readonly tables: Map<string, unknown>;
969
963
  readonly sequences: Map<string, unknown>;
970
964
  get name(): string;
965
+ get driver(): string;
971
966
  get schema(): string;
972
967
  table<T extends TObject>(entity: EntityPrimitive<T>): PgTableWithColumns<SchemaToTableConfig<T>>;
973
968
  registerEntity(entity: EntityPrimitive): void;
@@ -975,39 +970,39 @@ declare abstract class DatabaseProvider {
975
970
  abstract execute(statement: SQLLike): Promise<Record<string, unknown>[]>;
976
971
  run<T extends TObject>(statement: SQLLike, schema: T): Promise<Array<Static<T>>>;
977
972
  /**
978
- * Get migrations folder path - can be overridden
979
- */
973
+ * Get migrations folder path - can be overridden
974
+ */
980
975
  protected getMigrationsFolder(): string;
981
976
  /**
982
- * Base migration orchestration - handles environment logic
983
- */
977
+ * Base migration orchestration - handles environment logic
978
+ */
984
979
  migrate(): Promise<void>;
985
980
  /**
986
- * Production: run migrations from folder
987
- */
981
+ * Production: run migrations from folder
982
+ */
988
983
  protected runProductionMigration(migrationsFolder: string): Promise<void>;
989
984
  /**
990
- * Test: always synchronize
991
- */
985
+ * Test: always synchronize
986
+ */
992
987
  protected runTestMigration(): Promise<void>;
993
988
  /**
994
- * Development: default to synchronize (can be overridden)
995
- */
989
+ * Development: default to synchronize (can be overridden)
990
+ */
996
991
  protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
997
992
  /**
998
- * Common synchronization with error handling
999
- */
993
+ * Common synchronization with error handling
994
+ */
1000
995
  protected synchronizeSchema(): Promise<void>;
1001
996
  /**
1002
- * Provider-specific migration execution
1003
- * MUST be implemented by each provider
1004
- */
997
+ * Provider-specific migration execution
998
+ * MUST be implemented by each provider
999
+ */
1005
1000
  protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
1006
1001
  /**
1007
- * For testing purposes, generate a unique schema name.
1008
- * The schema name will be generated based on the current date and time.
1009
- * It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
1010
- */
1002
+ * For testing purposes, generate a unique schema name.
1003
+ * The schema name will be generated based on the current date and time.
1004
+ * It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
1005
+ */
1011
1006
  protected generateTestSchemaName(): string;
1012
1007
  }
1013
1008
  //#endregion
@@ -1015,8 +1010,8 @@ declare abstract class DatabaseProvider {
1015
1010
  declare class QueryManager {
1016
1011
  protected readonly alepha: Alepha;
1017
1012
  /**
1018
- * Convert a query object to a SQL query.
1019
- */
1013
+ * Convert a query object to a SQL query.
1014
+ */
1020
1015
  toSQL(query: PgQueryWhereOrSQL<TObject>, options: {
1021
1016
  schema: TObject;
1022
1017
  col: (key: string) => PgColumn;
@@ -1024,22 +1019,22 @@ declare class QueryManager {
1024
1019
  dialect: "postgresql" | "sqlite";
1025
1020
  }): SQL | undefined;
1026
1021
  /**
1027
- * Check if an object has any filter operator properties.
1028
- */
1022
+ * Check if an object has any filter operator properties.
1023
+ */
1029
1024
  protected hasFilterOperatorProperties(obj: any): boolean;
1030
1025
  /**
1031
- * Map a filter operator to a SQL query.
1032
- */
1026
+ * Map a filter operator to a SQL query.
1027
+ */
1033
1028
  mapOperatorToSql(operator: FilterOperators<any> | any, column: PgColumn, columnSchema?: TObject, columnName?: string, dialect?: "postgresql" | "sqlite"): SQL | undefined;
1034
1029
  /**
1035
- * Parse pagination sort string to orderBy format.
1036
- * Format: "firstName,-lastName" -> [{ column: "firstName", direction: "asc" }, { column: "lastName", direction: "desc" }]
1037
- * - Columns separated by comma
1038
- * - Prefix with '-' for DESC direction
1039
- *
1040
- * @param sort Pagination sort string
1041
- * @returns OrderBy array or single object
1042
- */
1030
+ * Parse pagination sort string to orderBy format.
1031
+ * Format: "firstName,-lastName" -> [{ column: "firstName", direction: "asc" }, { column: "lastName", direction: "desc" }]
1032
+ * - Columns separated by comma
1033
+ * - Prefix with '-' for DESC direction
1034
+ *
1035
+ * @param sort Pagination sort string
1036
+ * @returns OrderBy array or single object
1037
+ */
1043
1038
  parsePaginationSort(sort: string): Array<{
1044
1039
  column: string;
1045
1040
  direction: "asc" | "desc";
@@ -1048,30 +1043,30 @@ declare class QueryManager {
1048
1043
  direction: "asc" | "desc";
1049
1044
  };
1050
1045
  /**
1051
- * Normalize orderBy parameter to array format.
1052
- * Supports 3 modes:
1053
- * 1. String: "name" -> [{ column: "name", direction: "asc" }]
1054
- * 2. Object: { column: "name", direction: "desc" } -> [{ column: "name", direction: "desc" }]
1055
- * 3. Array: [{ column: "name" }, { column: "age", direction: "desc" }] -> normalized array
1056
- *
1057
- * @param orderBy The orderBy parameter
1058
- * @returns Normalized array of order by clauses
1059
- */
1046
+ * Normalize orderBy parameter to array format.
1047
+ * Supports 3 modes:
1048
+ * 1. String: "name" -> [{ column: "name", direction: "asc" }]
1049
+ * 2. Object: { column: "name", direction: "desc" } -> [{ column: "name", direction: "desc" }]
1050
+ * 3. Array: [{ column: "name" }, { column: "age", direction: "desc" }] -> normalized array
1051
+ *
1052
+ * @param orderBy The orderBy parameter
1053
+ * @returns Normalized array of order by clauses
1054
+ */
1060
1055
  normalizeOrderBy(orderBy: any): Array<{
1061
1056
  column: string;
1062
1057
  direction: "asc" | "desc";
1063
1058
  }>;
1064
1059
  /**
1065
- * Create a pagination object.
1066
- *
1067
- * @deprecated Use `createPagination` from alepha instead.
1068
- * This method now delegates to the framework-level helper.
1069
- *
1070
- * @param entities The entities to paginate.
1071
- * @param limit The limit of the pagination.
1072
- * @param offset The offset of the pagination.
1073
- * @param sort Optional sort metadata to include in response.
1074
- */
1060
+ * Create a pagination object.
1061
+ *
1062
+ * @deprecated Use `createPagination` from alepha instead.
1063
+ * This method now delegates to the framework-level helper.
1064
+ *
1065
+ * @param entities The entities to paginate.
1066
+ * @param limit The limit of the pagination.
1067
+ * @param offset The offset of the pagination.
1068
+ * @param sort Optional sort metadata to include in response.
1069
+ */
1075
1070
  createPagination<T>(entities: T[], limit?: number, offset?: number, sort?: Array<{
1076
1071
  column: string;
1077
1072
  direction: "asc" | "desc";
@@ -1088,20 +1083,20 @@ interface PgJoin {
1088
1083
  //#region ../../src/orm/services/PgRelationManager.d.ts
1089
1084
  declare class PgRelationManager {
1090
1085
  /**
1091
- * Recursively build joins for the query builder based on the relations map
1092
- */
1086
+ * Recursively build joins for the query builder based on the relations map
1087
+ */
1093
1088
  buildJoins(provider: DatabaseProvider, builder: PgSelectBase<any, any, any>, joins: Array<PgJoin>, withRelations: PgRelationMap<TObject>, table: PgTableWithColumns<any>, parentKey?: string): void;
1094
1089
  /**
1095
- * Map a row with its joined relations based on the joins definition
1096
- */
1090
+ * Map a row with its joined relations based on the joins definition
1091
+ */
1097
1092
  mapRowWithJoins(record: Record<string, unknown>, row: Record<string, unknown>, schema: TObject, joins: PgJoin[], parentKey?: string): Record<string, unknown>;
1098
1093
  /**
1099
- * Check if all values in an object are null (indicates a left join with no match)
1100
- */
1094
+ * Check if all values in an object are null (indicates a left join with no match)
1095
+ */
1101
1096
  private isAllNull;
1102
1097
  /**
1103
- * Build a schema that includes all join properties recursively
1104
- */
1098
+ * Build a schema that includes all join properties recursively
1099
+ */
1105
1100
  buildSchemaWithJoins(baseSchema: TObject, joins: PgJoin[], parentPath?: string): TObject;
1106
1101
  }
1107
1102
  //#endregion
@@ -1109,216 +1104,217 @@ declare class PgRelationManager {
1109
1104
  declare abstract class Repository$1<T extends TObject> {
1110
1105
  readonly entity: EntityPrimitive<T>;
1111
1106
  readonly provider: DatabaseProvider;
1107
+ protected readonly log: alepha_logger5.Logger;
1112
1108
  protected readonly relationManager: PgRelationManager;
1113
1109
  protected readonly queryManager: QueryManager;
1114
1110
  protected readonly dateTimeProvider: DateTimeProvider;
1115
1111
  protected readonly alepha: Alepha;
1116
1112
  constructor(entity: EntityPrimitive<T>, provider?: typeof DatabaseProvider);
1117
1113
  /**
1118
- * Represents the primary key of the table.
1119
- * - Key is the name of the primary key column.
1120
- * - Type is the type (TypeBox) of the primary key column.
1121
- *
1122
- * ID is mandatory. If the table does not have a primary key, it will throw an error.
1123
- */
1114
+ * Represents the primary key of the table.
1115
+ * - Key is the name of the primary key column.
1116
+ * - Type is the type (TypeBox) of the primary key column.
1117
+ *
1118
+ * ID is mandatory. If the table does not have a primary key, it will throw an error.
1119
+ */
1124
1120
  get id(): {
1125
1121
  type: TSchema;
1126
1122
  key: keyof T["properties"];
1127
1123
  col: PgColumn;
1128
1124
  };
1129
1125
  /**
1130
- * Get Drizzle table object.
1131
- */
1126
+ * Get Drizzle table object.
1127
+ */
1132
1128
  get table(): PgTableWithColumns<SchemaToTableConfig<T>>;
1133
1129
  /**
1134
- * Get SQL table name. (from Drizzle table object)
1135
- */
1130
+ * Get SQL table name. (from Drizzle table object)
1131
+ */
1136
1132
  get tableName(): string;
1137
1133
  /**
1138
- * Getter for the database connection from the database provider.
1139
- */
1134
+ * Getter for the database connection from the database provider.
1135
+ */
1140
1136
  protected get db(): PgDatabase<any>;
1141
1137
  /**
1142
- * Execute a SQL query.
1143
- *
1144
- * This method allows executing raw SQL queries against the database.
1145
- * This is by far the easiest way to run custom queries that are not covered by the repository's built-in methods!
1146
- *
1147
- * You must use the `sql` tagged template function from Drizzle ORM to create the query. https://orm.drizzle.team/docs/sql
1148
- *
1149
- * @example
1150
- * ```ts
1151
- * class App {
1152
- * repository = $repository({ ... });
1153
- * async getAdults() {
1154
- * const users = repository.table; // Drizzle table object
1155
- * await repository.query(sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
1156
- * // or better
1157
- * await repository.query((users) => sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
1158
- * }
1159
- * }
1160
- * ```
1161
- */
1138
+ * Execute a SQL query.
1139
+ *
1140
+ * This method allows executing raw SQL queries against the database.
1141
+ * This is by far the easiest way to run custom queries that are not covered by the repository's built-in methods!
1142
+ *
1143
+ * You must use the `sql` tagged template function from Drizzle ORM to create the query. https://orm.drizzle.team/docs/sql
1144
+ *
1145
+ * @example
1146
+ * ```ts
1147
+ * class App {
1148
+ * repository = $repository({ ... });
1149
+ * async getAdults() {
1150
+ * const users = repository.table; // Drizzle table object
1151
+ * await repository.query(sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
1152
+ * // or better
1153
+ * await repository.query((users) => sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
1154
+ * }
1155
+ * }
1156
+ * ```
1157
+ */
1162
1158
  query<R extends TObject = T>(query: SQLLike | ((table: PgTableWithColumns<SchemaToTableConfig<T>>, db: PgDatabase<any>) => SQLLike), schema?: R): Promise<Static<R>[]>;
1163
1159
  /**
1164
- * Map raw database fields to entity fields. (handles column name differences)
1165
- */
1160
+ * Map raw database fields to entity fields. (handles column name differences)
1161
+ */
1166
1162
  protected mapRawFieldsToEntity(row: Record<string, unknown>): any;
1167
1163
  /**
1168
- * Get a Drizzle column from the table by his name.
1169
- */
1164
+ * Get a Drizzle column from the table by his name.
1165
+ */
1170
1166
  protected col(name: keyof StaticEncode<T>): PgColumn;
1171
1167
  /**
1172
- * Run a transaction.
1173
- */
1168
+ * Run a transaction.
1169
+ */
1174
1170
  transaction<T>(transaction: (tx: PgTransaction<any, Record<string, any>, any>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
1175
1171
  /**
1176
- * Start a SELECT query on the table.
1177
- */
1172
+ * Start a SELECT query on the table.
1173
+ */
1178
1174
  protected rawSelect(opts?: StatementOptions): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
1179
1175
  [x: string]: unknown;
1180
1176
  }[], {
1181
1177
  [x: string]: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
1182
1178
  }>;
1183
1179
  /**
1184
- * Start a SELECT DISTINCT query on the table.
1185
- */
1180
+ * Start a SELECT DISTINCT query on the table.
1181
+ */
1186
1182
  protected rawSelectDistinct(opts?: StatementOptions, columns?: (keyof Static<T>)[]): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, any>, "partial", Record<string, "not-null">, false, never, {
1187
1183
  [x: string]: any;
1188
1184
  }[], {
1189
1185
  [x: string]: any;
1190
1186
  }>;
1191
1187
  /**
1192
- * Start an INSERT query on the table.
1193
- */
1188
+ * Start an INSERT query on the table.
1189
+ */
1194
1190
  protected rawInsert(opts?: StatementOptions): drizzle_orm_pg_core0.PgInsertBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any, false>;
1195
1191
  /**
1196
- * Start an UPDATE query on the table.
1197
- */
1192
+ * Start an UPDATE query on the table.
1193
+ */
1198
1194
  protected rawUpdate(opts?: StatementOptions): drizzle_orm_pg_core0.PgUpdateBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any>;
1199
1195
  /**
1200
- * Start a DELETE query on the table.
1201
- */
1196
+ * Start a DELETE query on the table.
1197
+ */
1202
1198
  protected rawDelete(opts?: StatementOptions): drizzle_orm_pg_core0.PgDeleteBase<PgTableWithColumns<SchemaToTableConfig<T>>, any, undefined, undefined, false, never>;
1203
1199
  /**
1204
- * Create a Drizzle `select` query based on a JSON query object.
1205
- *
1206
- * > This method is the base for `find`, `findOne`, `findById`, and `paginate`.
1207
- */
1200
+ * Create a Drizzle `select` query based on a JSON query object.
1201
+ *
1202
+ * > This method is the base for `find`, `findOne`, `findById`, and `paginate`.
1203
+ */
1208
1204
  findMany<R extends PgRelationMap<T>>(query?: PgQueryRelations<T, R>, opts?: StatementOptions): Promise<PgStatic<T, R>[]>;
1209
1205
  /**
1210
- * Find a single entity.
1211
- */
1206
+ * Find a single entity.
1207
+ */
1212
1208
  findOne<R extends PgRelationMap<T>>(query: Pick<PgQueryRelations<T, R>, "with" | "where">, opts?: StatementOptions): Promise<PgStatic<T, R>>;
1213
1209
  /**
1214
- * Find entities with pagination.
1215
- *
1216
- * It uses the same parameters as `find()`, but adds pagination metadata to the response.
1217
- *
1218
- * > Pagination CAN also do a count query to get the total number of elements.
1219
- */
1210
+ * Find entities with pagination.
1211
+ *
1212
+ * It uses the same parameters as `find()`, but adds pagination metadata to the response.
1213
+ *
1214
+ * > Pagination CAN also do a count query to get the total number of elements.
1215
+ */
1220
1216
  paginate<R extends PgRelationMap<T>>(pagination?: PageQuery, query?: PgQueryRelations<T, R>, opts?: StatementOptions & {
1221
1217
  count?: boolean;
1222
1218
  }): Promise<Page<PgStatic<T, R>>>;
1223
1219
  /**
1224
- * Find an entity by ID.
1225
- *
1226
- * This is a convenience method for `findOne` with a where clause on the primary key.
1227
- * If you need more complex queries, use `findOne` instead.
1228
- */
1220
+ * Find an entity by ID.
1221
+ *
1222
+ * This is a convenience method for `findOne` with a where clause on the primary key.
1223
+ * If you need more complex queries, use `findOne` instead.
1224
+ */
1229
1225
  findById(id: string | number, opts?: StatementOptions): Promise<Static<T>>;
1230
1226
  /**
1231
- * Helper to create a type-safe query object.
1232
- */
1227
+ * Helper to create a type-safe query object.
1228
+ */
1233
1229
  createQuery(): PgQuery<T>;
1234
1230
  /**
1235
- * Helper to create a type-safe where clause.
1236
- */
1231
+ * Helper to create a type-safe where clause.
1232
+ */
1237
1233
  createQueryWhere(): PgQueryWhere<T>;
1238
1234
  /**
1239
- * Create an entity.
1240
- *
1241
- * @param data The entity to create.
1242
- * @param opts The options for creating the entity.
1243
- * @returns The ID of the created entity.
1244
- */
1235
+ * Create an entity.
1236
+ *
1237
+ * @param data The entity to create.
1238
+ * @param opts The options for creating the entity.
1239
+ * @returns The ID of the created entity.
1240
+ */
1245
1241
  create(data: Static<TObjectInsert<T>>, opts?: StatementOptions): Promise<Static<T>>;
1246
1242
  /**
1247
- * Create many entities.
1248
- *
1249
- * Inserts are batched in chunks of 1000 to avoid hitting database limits.
1250
- *
1251
- * @param values The entities to create.
1252
- * @param opts The statement options.
1253
- * @returns The created entities.
1254
- */
1243
+ * Create many entities.
1244
+ *
1245
+ * Inserts are batched in chunks of 1000 to avoid hitting database limits.
1246
+ *
1247
+ * @param values The entities to create.
1248
+ * @param opts The statement options.
1249
+ * @returns The created entities.
1250
+ */
1255
1251
  createMany(values: Array<Static<TObjectInsert<T>>>, opts?: StatementOptions & {
1256
1252
  batchSize?: number;
1257
1253
  }): Promise<Static<T>[]>;
1258
1254
  /**
1259
- * Find an entity and update it.
1260
- */
1255
+ * Find an entity and update it.
1256
+ */
1261
1257
  updateOne(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
1262
1258
  /**
1263
- * Save a given entity.
1264
- *
1265
- * @example
1266
- * ```ts
1267
- * const entity = await repository.findById(1);
1268
- * entity.name = "New Name"; // update a field
1269
- * delete entity.description; // delete a field
1270
- * await repository.save(entity);
1271
- * ```
1272
- *
1273
- * Difference with `updateById/updateOne`:
1274
- *
1275
- * - requires the entity to be fetched first (whole object is expected)
1276
- * - check pg.version() if present -> optimistic locking
1277
- * - validate entity against schema
1278
- * - undefined values will be set to null, not ignored!
1279
- *
1280
- * @see {@link DbVersionMismatchError}
1281
- */
1259
+ * Save a given entity.
1260
+ *
1261
+ * @example
1262
+ * ```ts
1263
+ * const entity = await repository.findById(1);
1264
+ * entity.name = "New Name"; // update a field
1265
+ * delete entity.description; // delete a field
1266
+ * await repository.save(entity);
1267
+ * ```
1268
+ *
1269
+ * Difference with `updateById/updateOne`:
1270
+ *
1271
+ * - requires the entity to be fetched first (whole object is expected)
1272
+ * - check pg.version() if present -> optimistic locking
1273
+ * - validate entity against schema
1274
+ * - undefined values will be set to null, not ignored!
1275
+ *
1276
+ * @see {@link DbVersionMismatchError}
1277
+ */
1282
1278
  save(entity: Static<T>, opts?: StatementOptions): Promise<void>;
1283
1279
  /**
1284
- * Find an entity by ID and update it.
1285
- */
1280
+ * Find an entity by ID and update it.
1281
+ */
1286
1282
  updateById(id: string | number, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
1287
1283
  /**
1288
- * Find many entities and update all of them.
1289
- */
1284
+ * Find many entities and update all of them.
1285
+ */
1290
1286
  updateMany(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Array<number | string>>;
1291
1287
  /**
1292
- * Find many and delete all of them.
1293
- * @returns Array of deleted entity IDs
1294
- */
1288
+ * Find many and delete all of them.
1289
+ * @returns Array of deleted entity IDs
1290
+ */
1295
1291
  deleteMany(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
1296
1292
  /**
1297
- * Delete all entities.
1298
- * @returns Array of deleted entity IDs
1299
- */
1293
+ * Delete all entities.
1294
+ * @returns Array of deleted entity IDs
1295
+ */
1300
1296
  clear(opts?: StatementOptions): Promise<Array<number | string>>;
1301
1297
  /**
1302
- * Delete the given entity.
1303
- *
1304
- * You must fetch the entity first in order to delete it.
1305
- * @returns Array containing the deleted entity ID
1306
- */
1298
+ * Delete the given entity.
1299
+ *
1300
+ * You must fetch the entity first in order to delete it.
1301
+ * @returns Array containing the deleted entity ID
1302
+ */
1307
1303
  destroy(entity: Static<T>, opts?: StatementOptions): Promise<Array<number | string>>;
1308
1304
  /**
1309
- * Find an entity and delete it.
1310
- * @returns Array of deleted entity IDs (should contain at most one ID)
1311
- */
1305
+ * Find an entity and delete it.
1306
+ * @returns Array of deleted entity IDs (should contain at most one ID)
1307
+ */
1312
1308
  deleteOne(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
1313
1309
  /**
1314
- * Find an entity by ID and delete it.
1315
- * @returns Array containing the deleted entity ID
1316
- * @throws DbEntityNotFoundError if the entity is not found
1317
- */
1310
+ * Find an entity by ID and delete it.
1311
+ * @returns Array containing the deleted entity ID
1312
+ * @throws DbEntityNotFoundError if the entity is not found
1313
+ */
1318
1314
  deleteById(id: string | number, opts?: StatementOptions): Promise<Array<number | string>>;
1319
1315
  /**
1320
- * Count entities.
1321
- */
1316
+ * Count entities.
1317
+ */
1322
1318
  count(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<number>;
1323
1319
  protected conflictMessagePattern: string;
1324
1320
  protected handleError(error: unknown, message: string): DbError;
@@ -1327,31 +1323,31 @@ declare abstract class Repository$1<T extends TObject> {
1327
1323
  }): PgQueryWhereOrSQL<T>;
1328
1324
  protected deletedAt(): PgAttrField | undefined;
1329
1325
  /**
1330
- * Convert something to valid Pg Insert Value.
1331
- */
1326
+ * Convert something to valid Pg Insert Value.
1327
+ */
1332
1328
  protected cast(data: any, insert: boolean): PgInsertValue<PgTableWithColumns<SchemaToTableConfig<T>>>;
1333
1329
  /**
1334
- * Transform a row from the database into a clean entity.
1335
- */
1330
+ * Transform a row from the database into a clean entity.
1331
+ */
1336
1332
  protected clean<T extends TObject>(row: Record<string, unknown>, schema: T): Static<T>;
1337
1333
  /**
1338
- * Clean a row with joins recursively
1339
- */
1334
+ * Clean a row with joins recursively
1335
+ */
1340
1336
  protected cleanWithJoins<T extends TObject>(row: Record<string, unknown>, schema: T, joins: PgJoin[], parentPath?: string): Static<T>;
1341
1337
  /**
1342
- * Convert a where clause to SQL.
1343
- */
1338
+ * Convert a where clause to SQL.
1339
+ */
1344
1340
  protected toSQL(where: PgQueryWhereOrSQL<T>, joins?: PgJoin[]): SQL | undefined;
1345
1341
  /**
1346
- * Get the where clause for an ID.
1347
- *
1348
- * @param id The ID to get the where clause for.
1349
- * @returns The where clause for the ID.
1350
- */
1342
+ * Get the where clause for an ID.
1343
+ *
1344
+ * @param id The ID to get the where clause for.
1345
+ * @returns The where clause for the ID.
1346
+ */
1351
1347
  protected getWhereId(id: string | number): PgQueryWhere<T>;
1352
1348
  /**
1353
- * Find a primary key in the schema.
1354
- */
1349
+ * Find a primary key in the schema.
1350
+ */
1355
1351
  protected getPrimaryKey(schema: TObject): {
1356
1352
  key: string;
1357
1353
  col: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
@@ -1363,210 +1359,26 @@ declare abstract class Repository$1<T extends TObject> {
1363
1359
  */
1364
1360
  interface StatementOptions {
1365
1361
  /**
1366
- * Transaction to use.
1367
- */
1362
+ * Transaction to use.
1363
+ */
1368
1364
  tx?: PgTransaction<any, Record<string, any>>;
1369
1365
  /**
1370
- * Lock strength.
1371
- */
1366
+ * Lock strength.
1367
+ */
1372
1368
  for?: LockStrength | {
1373
1369
  config: LockConfig;
1374
1370
  strength: LockStrength;
1375
1371
  };
1376
1372
  /**
1377
- * If true, ignore soft delete.
1378
- */
1373
+ * If true, ignore soft delete.
1374
+ */
1379
1375
  force?: boolean;
1380
1376
  /**
1381
- * Force the current time.
1382
- */
1377
+ * Force the current time.
1378
+ */
1383
1379
  now?: DateTime | string;
1384
1380
  }
1385
1381
  //#endregion
1386
- //#region ../../src/orm/providers/drivers/BunPostgresProvider.d.ts
1387
- declare module "alepha" {
1388
- interface Env extends Partial<Static<typeof envSchema$1>> {}
1389
- }
1390
- declare const envSchema$1: alepha23.TObject<{
1391
- /**
1392
- * Main configuration for database connection.
1393
- * Accept a string in the format of a Postgres connection URL.
1394
- * Example: postgres://user:password@localhost:5432/database
1395
- * or
1396
- * Example: postgres://user:password@localhost:5432/database?sslmode=require
1397
- */
1398
- DATABASE_URL: alepha23.TOptional<alepha23.TString>;
1399
- /**
1400
- * In addition to the DATABASE_URL, you can specify the postgres schema name.
1401
- */
1402
- POSTGRES_SCHEMA: alepha23.TOptional<alepha23.TString>;
1403
- }>;
1404
- /**
1405
- * Bun PostgreSQL provider using Drizzle ORM with Bun's native SQL client.
1406
- *
1407
- * This provider uses Bun's built-in SQL class for PostgreSQL connections,
1408
- * which provides excellent performance on the Bun runtime.
1409
- *
1410
- * @example
1411
- * ```ts
1412
- * // Set DATABASE_URL environment variable
1413
- * // DATABASE_URL=postgres://user:password@localhost:5432/database
1414
- *
1415
- * // Or configure programmatically
1416
- * alepha.with({
1417
- * provide: DatabaseProvider,
1418
- * use: BunPostgresProvider,
1419
- * });
1420
- * ```
1421
- */
1422
- //#endregion
1423
- //#region ../../src/orm/providers/drivers/BunSqliteProvider.d.ts
1424
- /**
1425
- * Configuration options for the Bun SQLite database provider.
1426
- */
1427
- declare const bunSqliteOptions: alepha23.Atom<alepha23.TObject<{
1428
- path: alepha23.TOptional<alepha23.TString>;
1429
- }>, "alepha.postgres.bun-sqlite.options">;
1430
- type BunSqliteProviderOptions = Static<typeof bunSqliteOptions.schema>;
1431
- declare module "alepha" {
1432
- interface State {
1433
- [bunSqliteOptions.key]: BunSqliteProviderOptions;
1434
- }
1435
- }
1436
- /**
1437
- * Bun SQLite provider using Drizzle ORM with Bun's native SQLite client.
1438
- *
1439
- * This provider uses Bun's built-in `bun:sqlite` for SQLite connections,
1440
- * which provides excellent performance on the Bun runtime.
1441
- *
1442
- * @example
1443
- * ```ts
1444
- * // Set DATABASE_URL environment variable
1445
- * // DATABASE_URL=sqlite://./my-database.db
1446
- *
1447
- * // Or configure programmatically
1448
- * alepha.with({
1449
- * provide: DatabaseProvider,
1450
- * use: BunSqliteProvider,
1451
- * });
1452
- *
1453
- * // Or use options atom
1454
- * alepha.store.mut(bunSqliteOptions, (old) => ({
1455
- * ...old,
1456
- * path: ":memory:",
1457
- * }));
1458
- * ```
1459
- */
1460
- //#endregion
1461
- //#region ../../src/orm/providers/drivers/NodePostgresProvider.d.ts
1462
- declare module "alepha" {
1463
- interface Env extends Partial<Static<typeof envSchema>> {}
1464
- }
1465
- declare const envSchema: alepha23.TObject<{
1466
- /**
1467
- * Main configuration for database connection.
1468
- * Accept a string in the format of a Postgres connection URL.
1469
- * Example: postgres://user:password@localhost:5432/database
1470
- * or
1471
- * Example: postgres://user:password@localhost:5432/database?sslmode=require
1472
- */
1473
- DATABASE_URL: alepha23.TOptional<alepha23.TString>;
1474
- /**
1475
- * In addition to the DATABASE_URL, you can specify the postgres schema name.
1476
- *
1477
- * It will monkey patch drizzle tables.
1478
- */
1479
- POSTGRES_SCHEMA: alepha23.TOptional<alepha23.TString>;
1480
- }>;
1481
- //#endregion
1482
- //#region ../../src/orm/providers/drivers/NodeSqliteProvider.d.ts
1483
- /**
1484
- * Configuration options for the Node.js SQLite database provider.
1485
- */
1486
- declare const nodeSqliteOptions: alepha23.Atom<alepha23.TObject<{
1487
- path: alepha23.TOptional<alepha23.TString>;
1488
- }>, "alepha.postgres.node-sqlite.options">;
1489
- type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
1490
- declare module "alepha" {
1491
- interface State {
1492
- [nodeSqliteOptions.key]: NodeSqliteProviderOptions;
1493
- }
1494
- }
1495
- /**
1496
- * Add a fake support for SQLite in Node.js based on Postgres interfaces.
1497
- *
1498
- * This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
1499
- * This is NOT recommended for production use.
1500
- */
1501
- //#endregion
1502
- //#region ../../src/orm/index.d.ts
1503
- declare module "alepha" {
1504
- interface Hooks {
1505
- /**
1506
- * Fires before creating an entity in the repository.
1507
- */
1508
- "repository:create:before": {
1509
- tableName: string;
1510
- data: any;
1511
- };
1512
- /**
1513
- * Fires after creating an entity in the repository.
1514
- */
1515
- "repository:create:after": {
1516
- tableName: string;
1517
- data: any;
1518
- entity: any;
1519
- };
1520
- /**
1521
- * Fires before updating entities in the repository.
1522
- */
1523
- "repository:update:before": {
1524
- tableName: string;
1525
- where: any;
1526
- data: any;
1527
- };
1528
- /**
1529
- * Fires after updating entities in the repository.
1530
- */
1531
- "repository:update:after": {
1532
- tableName: string;
1533
- where: any;
1534
- data: any;
1535
- entities: any[];
1536
- };
1537
- /**
1538
- * Fires before deleting entities from the repository.
1539
- */
1540
- "repository:delete:before": {
1541
- tableName: string;
1542
- where: any;
1543
- };
1544
- /**
1545
- * Fires after deleting entities from the repository.
1546
- */
1547
- "repository:delete:after": {
1548
- tableName: string;
1549
- where: any;
1550
- ids: Array<string | number>;
1551
- };
1552
- /**
1553
- * Fires before reading entities from the repository.
1554
- */
1555
- "repository:read:before": {
1556
- tableName: string;
1557
- query: any;
1558
- };
1559
- /**
1560
- * Fires after reading entities from the repository.
1561
- */
1562
- "repository:read:after": {
1563
- tableName: string;
1564
- query: any;
1565
- entities: any[];
1566
- };
1567
- }
1568
- }
1569
- //#endregion
1570
1382
  //#region ../../src/api/users/entities/identities.d.ts
1571
1383
  declare const identities: alepha_orm24.EntityPrimitive<alepha23.TObject<{
1572
1384
  id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
@@ -1619,8 +1431,8 @@ declare const users: alepha_orm24.EntityPrimitive<alepha23.TObject<{
1619
1431
  }>>;
1620
1432
  type UserEntity = Static<typeof users.schema>;
1621
1433
  //#endregion
1622
- //#region ../../src/api/users/primitives/$userRealm.d.ts
1623
- type UserRealmPrimitive = RealmPrimitive & WithLinkFn & WithLoginFn;
1434
+ //#region ../../src/api/users/primitives/$realm.d.ts
1435
+ type RealmPrimitive = IssuerPrimitive & WithLinkFn & WithLoginFn;
1624
1436
  /**
1625
1437
  * Already configured realm for user management.
1626
1438
  *
@@ -1634,23 +1446,23 @@ type UserRealmPrimitive = RealmPrimitive & WithLinkFn & WithLoginFn;
1634
1446
  * Environment Variables:
1635
1447
  * - `APP_SECRET`: Secret key for signing tokens (if not provided in options).
1636
1448
  */
1637
- declare const $userRealm: (options?: UserRealmOptions) => UserRealmPrimitive;
1638
- interface UserRealmOptions {
1449
+ declare const $realm: (options?: RealmOptions) => RealmPrimitive;
1450
+ interface RealmOptions {
1639
1451
  /**
1640
- * Secret key for signing tokens.
1641
- *
1642
- * If not provided, the secret from the SecurityProvider will be used (usually from the APP_SECRET environment variable).
1643
- */
1452
+ * Secret key for signing tokens.
1453
+ *
1454
+ * If not provided, the secret from the SecurityProvider will be used (usually from the APP_SECRET environment variable).
1455
+ */
1644
1456
  secret?: string;
1645
1457
  /**
1646
- * Realm configuration options.
1647
- *
1648
- * It's already pre-configured for user management with admin and user roles.
1649
- */
1650
- realm?: Partial<RealmPrimitiveOptions>;
1458
+ * Issuer configuration options.
1459
+ *
1460
+ * It's already pre-configured for user management with admin and user roles.
1461
+ */
1462
+ issuer?: Partial<IssuerPrimitiveOptions>;
1651
1463
  /**
1652
- * Override entities.
1653
- */
1464
+ * Override entities.
1465
+ */
1654
1466
  entities?: {
1655
1467
  users?: Repository<typeof users.schema>;
1656
1468
  identities?: Repository<typeof identities.schema>;
@@ -1669,18 +1481,18 @@ interface UserRealmOptions {
1669
1481
  };
1670
1482
  }
1671
1483
  //#endregion
1672
- //#region ../../src/api/users/providers/UserRealmProvider.d.ts
1673
- interface UserRealmRepositories {
1484
+ //#region ../../src/api/users/providers/RealmProvider.d.ts
1485
+ interface RealmRepositories {
1674
1486
  identities: Repository<typeof identities.schema>;
1675
1487
  sessions: Repository<typeof sessions.schema>;
1676
1488
  users: Repository<typeof users.schema>;
1677
1489
  }
1678
- interface UserRealm {
1490
+ interface Realm {
1679
1491
  name: string;
1680
- repositories: UserRealmRepositories;
1492
+ repositories: RealmRepositories;
1681
1493
  settings: RealmAuthSettings;
1682
1494
  }
1683
- declare class UserRealmProvider {
1495
+ declare class RealmProvider {
1684
1496
  protected readonly alepha: Alepha;
1685
1497
  protected readonly defaultIdentities: Repository<alepha23.TObject<{
1686
1498
  id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
@@ -1724,17 +1536,17 @@ declare class UserRealmProvider {
1724
1536
  enabled: alepha_orm24.PgAttr<alepha23.TBoolean, typeof alepha_orm24.PG_DEFAULT>;
1725
1537
  emailVerified: alepha_orm24.PgAttr<alepha23.TBoolean, typeof alepha_orm24.PG_DEFAULT>;
1726
1538
  }>>;
1727
- protected realms: Map<string, UserRealm>;
1539
+ protected realms: Map<string, Realm>;
1728
1540
  avatars: alepha_bucket0.BucketPrimitive;
1729
1541
  protected readonly onConfigure: alepha23.HookPrimitive<"configure">;
1730
- register(userRealmName: string, userRealmOptions?: UserRealmOptions): UserRealm;
1731
- /**
1732
- * Gets a registered realm by name, auto-creating default if needed.
1733
- */
1734
- getRealm(userRealmName?: string): UserRealm;
1735
- identityRepository(userRealmName?: string): Repository<typeof identities.schema>;
1736
- sessionRepository(userRealmName?: string): Repository<typeof sessions.schema>;
1737
- userRepository(userRealmName?: string): Repository<typeof users.schema>;
1542
+ register(realmName: string, realmOptions?: RealmOptions): Realm;
1543
+ /**
1544
+ * Gets a registered realm by name, auto-creating default if needed.
1545
+ */
1546
+ getRealm(realmName?: string): Realm;
1547
+ identityRepository(realmName?: string): Repository<typeof identities.schema>;
1548
+ sessionRepository(realmName?: string): Repository<typeof sessions.schema>;
1549
+ userRepository(realmName?: string): Repository<typeof users.schema>;
1738
1550
  }
1739
1551
  //#endregion
1740
1552
  //#region ../../src/api/users/schemas/identityQuerySchema.d.ts
@@ -1750,7 +1562,7 @@ type IdentityQuery = Static<typeof identityQuerySchema>;
1750
1562
  //#region ../../src/api/users/services/IdentityService.d.ts
1751
1563
  declare class IdentityService {
1752
1564
  protected readonly log: alepha_logger5.Logger;
1753
- protected readonly userRealmProvider: UserRealmProvider;
1565
+ protected readonly realmProvider: RealmProvider;
1754
1566
  protected readonly auditService: AuditService;
1755
1567
  identities(userRealmName?: string): alepha_orm24.Repository<alepha23.TObject<{
1756
1568
  id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
@@ -1764,16 +1576,16 @@ declare class IdentityService {
1764
1576
  providerData: alepha23.TOptional<alepha23.TRecord<string, alepha23.TAny>>;
1765
1577
  }>>;
1766
1578
  /**
1767
- * Find identities with pagination and filtering.
1768
- */
1579
+ * Find identities with pagination and filtering.
1580
+ */
1769
1581
  findIdentities(q?: IdentityQuery, userRealmName?: string): Promise<Page$1<IdentityEntity>>;
1770
1582
  /**
1771
- * Get an identity by ID.
1772
- */
1583
+ * Get an identity by ID.
1584
+ */
1773
1585
  getIdentityById(id: string, userRealmName?: string): Promise<IdentityEntity>;
1774
1586
  /**
1775
- * Delete an identity by ID.
1776
- */
1587
+ * Delete an identity by ID.
1588
+ */
1777
1589
  deleteIdentity(id: string, userRealmName?: string): Promise<void>;
1778
1590
  }
1779
1591
  //#endregion
@@ -1783,8 +1595,8 @@ declare class AdminIdentityController {
1783
1595
  protected readonly group = "admin:identities";
1784
1596
  protected readonly identityService: IdentityService;
1785
1597
  /**
1786
- * Find identities with pagination and filtering.
1787
- */
1598
+ * Find identities with pagination and filtering.
1599
+ */
1788
1600
  readonly findIdentities: alepha_server0.ActionPrimitiveFn<{
1789
1601
  query: alepha23.TObject<{
1790
1602
  page: alepha23.TOptional<alepha23.TInteger>;
@@ -1806,8 +1618,8 @@ declare class AdminIdentityController {
1806
1618
  }>>;
1807
1619
  }>;
1808
1620
  /**
1809
- * Get an identity by ID.
1810
- */
1621
+ * Get an identity by ID.
1622
+ */
1811
1623
  readonly getIdentity: alepha_server0.ActionPrimitiveFn<{
1812
1624
  params: alepha23.TObject<{
1813
1625
  id: alepha23.TString;
@@ -1827,8 +1639,8 @@ declare class AdminIdentityController {
1827
1639
  }>;
1828
1640
  }>;
1829
1641
  /**
1830
- * Delete an identity.
1831
- */
1642
+ * Delete an identity.
1643
+ */
1832
1644
  readonly deleteIdentity: alepha_server0.ActionPrimitiveFn<{
1833
1645
  params: alepha23.TObject<{
1834
1646
  id: alepha23.TString;
@@ -1856,7 +1668,7 @@ type SessionQuery = Static<typeof sessionQuerySchema>;
1856
1668
  //#region ../../src/api/users/services/SessionCrudService.d.ts
1857
1669
  declare class SessionCrudService {
1858
1670
  protected readonly log: alepha_logger5.Logger;
1859
- protected readonly userRealmProvider: UserRealmProvider;
1671
+ protected readonly realmProvider: RealmProvider;
1860
1672
  sessions(userRealmName?: string): alepha_orm24.Repository<alepha23.TObject<{
1861
1673
  id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
1862
1674
  version: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TInteger, typeof alepha_orm24.PG_VERSION>, typeof alepha_orm24.PG_DEFAULT>;
@@ -1873,16 +1685,16 @@ declare class SessionCrudService {
1873
1685
  }>>;
1874
1686
  }>>;
1875
1687
  /**
1876
- * Find sessions with pagination and filtering.
1877
- */
1688
+ * Find sessions with pagination and filtering.
1689
+ */
1878
1690
  findSessions(q?: SessionQuery, userRealmName?: string): Promise<Page$1<SessionEntity>>;
1879
1691
  /**
1880
- * Get a session by ID.
1881
- */
1692
+ * Get a session by ID.
1693
+ */
1882
1694
  getSessionById(id: string, userRealmName?: string): Promise<SessionEntity>;
1883
1695
  /**
1884
- * Delete a session by ID.
1885
- */
1696
+ * Delete a session by ID.
1697
+ */
1886
1698
  deleteSession(id: string, userRealmName?: string): Promise<void>;
1887
1699
  }
1888
1700
  //#endregion
@@ -1892,8 +1704,8 @@ declare class AdminSessionController {
1892
1704
  protected readonly group = "admin:sessions";
1893
1705
  protected readonly sessionService: SessionCrudService;
1894
1706
  /**
1895
- * Find sessions with pagination and filtering.
1896
- */
1707
+ * Find sessions with pagination and filtering.
1708
+ */
1897
1709
  readonly findSessions: alepha_server0.ActionPrimitiveFn<{
1898
1710
  query: alepha23.TObject<{
1899
1711
  page: alepha23.TOptional<alepha23.TInteger>;
@@ -1919,8 +1731,8 @@ declare class AdminSessionController {
1919
1731
  }>>;
1920
1732
  }>;
1921
1733
  /**
1922
- * Get a session by ID.
1923
- */
1734
+ * Get a session by ID.
1735
+ */
1924
1736
  readonly getSession: alepha_server0.ActionPrimitiveFn<{
1925
1737
  params: alepha23.TObject<{
1926
1738
  id: alepha23.TString;
@@ -1945,8 +1757,8 @@ declare class AdminSessionController {
1945
1757
  }>;
1946
1758
  }>;
1947
1759
  /**
1948
- * Delete a session.
1949
- */
1760
+ * Delete a session.
1761
+ */
1950
1762
  readonly deleteSession: alepha_server0.ActionPrimitiveFn<{
1951
1763
  params: alepha23.TObject<{
1952
1764
  id: alepha23.TString;
@@ -2040,7 +1852,7 @@ declare class UserService {
2040
1852
  protected readonly log: alepha_logger5.Logger;
2041
1853
  protected readonly verificationController: alepha_server_links0.HttpVirtualClient<VerificationController>;
2042
1854
  protected readonly userNotifications: UserNotifications;
2043
- protected readonly userRealmProvider: UserRealmProvider;
1855
+ protected readonly realmProvider: RealmProvider;
2044
1856
  protected readonly auditService: AuditService;
2045
1857
  users(userRealmName?: string): alepha_orm24.Repository<alepha23.TObject<{
2046
1858
  id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
@@ -2059,41 +1871,41 @@ declare class UserService {
2059
1871
  emailVerified: alepha_orm24.PgAttr<alepha23.TBoolean, typeof alepha_orm24.PG_DEFAULT>;
2060
1872
  }>>;
2061
1873
  /**
2062
- * Request email verification for a user.
2063
- * @param email - The email address to verify.
2064
- * @param userRealmName - Optional realm name.
2065
- * @param method - The verification method: "code" (default) or "link".
2066
- * @param verifyUrl - Base URL for verification link (required when method is "link").
2067
- */
1874
+ * Request email verification for a user.
1875
+ * @param email - The email address to verify.
1876
+ * @param userRealmName - Optional realm name.
1877
+ * @param method - The verification method: "code" (default) or "link".
1878
+ * @param verifyUrl - Base URL for verification link (required when method is "link").
1879
+ */
2068
1880
  requestEmailVerification(email: string, userRealmName?: string, method?: "code" | "link", verifyUrl?: string): Promise<boolean>;
2069
1881
  /**
2070
- * Verify a user's email using a valid verification token.
2071
- * Supports both code (6-digit) and link (UUID) verification tokens.
2072
- */
1882
+ * Verify a user's email using a valid verification token.
1883
+ * Supports both code (6-digit) and link (UUID) verification tokens.
1884
+ */
2073
1885
  verifyEmail(email: string, token: string, userRealmName?: string): Promise<void>;
2074
1886
  /**
2075
- * Check if an email is verified.
2076
- */
1887
+ * Check if an email is verified.
1888
+ */
2077
1889
  isEmailVerified(email: string, userRealmName?: string): Promise<boolean>;
2078
1890
  /**
2079
- * Find users with pagination and filtering.
2080
- */
1891
+ * Find users with pagination and filtering.
1892
+ */
2081
1893
  findUsers(q?: UserQuery, userRealmName?: string): Promise<Page$1<UserEntity>>;
2082
1894
  /**
2083
- * Get a user by ID.
2084
- */
1895
+ * Get a user by ID.
1896
+ */
2085
1897
  getUserById(id: string, userRealmName?: string): Promise<UserEntity>;
2086
1898
  /**
2087
- * Create a new user.
2088
- */
1899
+ * Create a new user.
1900
+ */
2089
1901
  createUser(data: CreateUser, userRealmName?: string): Promise<UserEntity>;
2090
1902
  /**
2091
- * Update an existing user.
2092
- */
1903
+ * Update an existing user.
1904
+ */
2093
1905
  updateUser(id: string, data: UpdateUser, userRealmName?: string): Promise<UserEntity>;
2094
1906
  /**
2095
- * Delete a user by ID.
2096
- */
1907
+ * Delete a user by ID.
1908
+ */
2097
1909
  deleteUser(id: string, userRealmName?: string): Promise<void>;
2098
1910
  }
2099
1911
  //#endregion
@@ -2103,8 +1915,8 @@ declare class AdminUserController {
2103
1915
  protected readonly group = "admin:users";
2104
1916
  protected readonly userService: UserService;
2105
1917
  /**
2106
- * Find users with pagination and filtering.
2107
- */
1918
+ * Find users with pagination and filtering.
1919
+ */
2108
1920
  readonly findUsers: alepha_server0.ActionPrimitiveFn<{
2109
1921
  query: alepha23.TObject<{
2110
1922
  page: alepha23.TOptional<alepha23.TInteger>;
@@ -2135,8 +1947,8 @@ declare class AdminUserController {
2135
1947
  }>>;
2136
1948
  }>;
2137
1949
  /**
2138
- * Get a user by ID.
2139
- */
1950
+ * Get a user by ID.
1951
+ */
2140
1952
  readonly getUser: alepha_server0.ActionPrimitiveFn<{
2141
1953
  params: alepha23.TObject<{
2142
1954
  id: alepha23.TString;
@@ -2162,8 +1974,8 @@ declare class AdminUserController {
2162
1974
  }>;
2163
1975
  }>;
2164
1976
  /**
2165
- * Create a new user.
2166
- */
1977
+ * Create a new user.
1978
+ */
2167
1979
  readonly createUser: alepha_server0.ActionPrimitiveFn<{
2168
1980
  query: alepha23.TObject<{
2169
1981
  userRealmName: alepha23.TOptional<alepha23.TString>;
@@ -2201,8 +2013,8 @@ declare class AdminUserController {
2201
2013
  }>;
2202
2014
  }>;
2203
2015
  /**
2204
- * Update a user.
2205
- */
2016
+ * Update a user.
2017
+ */
2206
2018
  readonly updateUser: alepha_server0.ActionPrimitiveFn<{
2207
2019
  params: alepha23.TObject<{
2208
2020
  id: alepha23.TString;
@@ -2238,8 +2050,8 @@ declare class AdminUserController {
2238
2050
  }>;
2239
2051
  }>;
2240
2052
  /**
2241
- * Delete a user.
2242
- */
2053
+ * Delete a user.
2054
+ */
2243
2055
  readonly deleteUser: alepha_server0.ActionPrimitiveFn<{
2244
2056
  params: alepha23.TObject<{
2245
2057
  id: alepha23.TString;
@@ -2255,6 +2067,70 @@ declare class AdminUserController {
2255
2067
  }>;
2256
2068
  }
2257
2069
  //#endregion
2070
+ //#region ../../src/api/users/controllers/RealmController.d.ts
2071
+ /**
2072
+ * Controller for exposing realm configuration.
2073
+ * Uses $route instead of $action to keep endpoints hidden from API documentation.
2074
+ */
2075
+ declare class RealmController {
2076
+ protected readonly url = "/realms";
2077
+ protected readonly group = "realms";
2078
+ protected readonly realmProvider: RealmProvider;
2079
+ protected readonly serverAuthProvider: ServerAuthProvider;
2080
+ /**
2081
+ * Get realm configuration settings.
2082
+ * This endpoint is not exposed in the API documentation.
2083
+ */
2084
+ readonly getRealmConfig: alepha_server0.ActionPrimitiveFn<{
2085
+ query: alepha23.TObject<{
2086
+ realmName: alepha23.TOptional<alepha23.TString>;
2087
+ }>;
2088
+ response: alepha23.TObject<{
2089
+ settings: alepha23.TObject<{
2090
+ displayName: alepha23.TOptional<alepha23.TString>;
2091
+ description: alepha23.TOptional<alepha23.TString>;
2092
+ logoUrl: alepha23.TOptional<alepha23.TString>;
2093
+ registrationAllowed: alepha23.TBoolean;
2094
+ emailEnabled: alepha23.TBoolean;
2095
+ emailRequired: alepha23.TBoolean;
2096
+ usernameEnabled: alepha23.TBoolean;
2097
+ usernameRequired: alepha23.TBoolean;
2098
+ usernameRegExp: alepha23.TString;
2099
+ phoneEnabled: alepha23.TBoolean;
2100
+ phoneRequired: alepha23.TBoolean;
2101
+ verifyEmailRequired: alepha23.TBoolean;
2102
+ verifyPhoneRequired: alepha23.TBoolean;
2103
+ firstNameLastNameEnabled: alepha23.TBoolean;
2104
+ firstNameLastNameRequired: alepha23.TBoolean;
2105
+ resetPasswordAllowed: alepha23.TBoolean;
2106
+ passwordPolicy: alepha23.TObject<{
2107
+ minLength: alepha23.TInteger;
2108
+ requireUppercase: alepha23.TBoolean;
2109
+ requireLowercase: alepha23.TBoolean;
2110
+ requireNumbers: alepha23.TBoolean;
2111
+ requireSpecialCharacters: alepha23.TBoolean;
2112
+ }>;
2113
+ }>;
2114
+ realmName: alepha23.TString;
2115
+ authenticationMethods: alepha23.TArray<alepha23.TObject<{
2116
+ name: alepha23.TString;
2117
+ type: alepha23.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
2118
+ }>>;
2119
+ }>;
2120
+ }>;
2121
+ readonly checkUsernameAvailability: alepha_server0.ActionPrimitiveFn<{
2122
+ query: alepha23.TObject<{
2123
+ realmName: alepha23.TOptional<alepha23.TString>;
2124
+ }>;
2125
+ body: alepha23.TObject<{
2126
+ username: alepha23.TString;
2127
+ }>;
2128
+ response: alepha23.TObject<{
2129
+ available: alepha23.TBoolean;
2130
+ }>;
2131
+ }>;
2132
+ }
2133
+ //#endregion
2258
2134
  //#region ../../src/api/users/schemas/completePasswordResetRequestSchema.d.ts
2259
2135
  /**
2260
2136
  * Request schema for completing a password reset.
@@ -2299,7 +2175,7 @@ declare class CredentialService {
2299
2175
  protected readonly dateTimeProvider: DateTimeProvider;
2300
2176
  protected readonly verificationController: alepha_server_links0.HttpVirtualClient<VerificationController>;
2301
2177
  protected readonly userNotifications: UserNotifications;
2302
- protected readonly userRealmProvider: UserRealmProvider;
2178
+ protected readonly realmProvider: RealmProvider;
2303
2179
  protected readonly auditService: AuditService;
2304
2180
  protected readonly intentCache: alepha_cache0.CachePrimitiveFn<PasswordResetIntent, any[]>;
2305
2181
  users(userRealmName?: string): Repository$1<alepha23.TObject<{
@@ -2345,36 +2221,36 @@ declare class CredentialService {
2345
2221
  providerData: alepha23.TOptional<alepha23.TRecord<string, alepha23.TAny>>;
2346
2222
  }>>;
2347
2223
  /**
2348
- * Phase 1: Create a password reset intent.
2349
- *
2350
- * Validates the email, checks for existing user with credentials,
2351
- * sends verification code, and stores the intent in cache.
2352
- *
2353
- * @param email - User's email address
2354
- * @param userRealmName - Optional realm name
2355
- * @returns Intent response with intentId and expiration (always returns for security)
2356
- */
2224
+ * Phase 1: Create a password reset intent.
2225
+ *
2226
+ * Validates the email, checks for existing user with credentials,
2227
+ * sends verification code, and stores the intent in cache.
2228
+ *
2229
+ * @param email - User's email address
2230
+ * @param userRealmName - Optional realm name
2231
+ * @returns Intent response with intentId and expiration (always returns for security)
2232
+ */
2357
2233
  createPasswordResetIntent(email: string, userRealmName?: string): Promise<PasswordResetIntentResponse>;
2358
2234
  /**
2359
- * Phase 2: Complete password reset using an intent.
2360
- *
2361
- * Validates the verification code, updates the password,
2362
- * and invalidates all existing sessions.
2363
- *
2364
- * @param body - Request body with intentId, code, and newPassword
2365
- */
2235
+ * Phase 2: Complete password reset using an intent.
2236
+ *
2237
+ * Validates the verification code, updates the password,
2238
+ * and invalidates all existing sessions.
2239
+ *
2240
+ * @param body - Request body with intentId, code, and newPassword
2241
+ */
2366
2242
  completePasswordReset(body: CompletePasswordResetRequest): Promise<void>;
2367
2243
  /**
2368
- * @deprecated Use createPasswordResetIntent instead
2369
- */
2244
+ * @deprecated Use createPasswordResetIntent instead
2245
+ */
2370
2246
  requestPasswordReset(email: string, userRealmName?: string): Promise<boolean>;
2371
2247
  /**
2372
- * @deprecated Use completePasswordReset instead
2373
- */
2248
+ * @deprecated Use completePasswordReset instead
2249
+ */
2374
2250
  validateResetToken(email: string, token: string, _userRealmName?: string): Promise<string>;
2375
2251
  /**
2376
- * @deprecated Use completePasswordReset instead
2377
- */
2252
+ * @deprecated Use completePasswordReset instead
2253
+ */
2378
2254
  resetPassword(email: string, token: string, newPassword: string, userRealmName?: string): Promise<void>;
2379
2255
  }
2380
2256
  //#endregion
@@ -2441,42 +2317,42 @@ declare class RegistrationService {
2441
2317
  protected readonly cryptoProvider: CryptoProvider;
2442
2318
  protected readonly verificationController: alepha_server_links0.HttpVirtualClient<VerificationController>;
2443
2319
  protected readonly userNotifications: UserNotifications;
2444
- protected readonly userRealmProvider: UserRealmProvider;
2320
+ protected readonly realmProvider: RealmProvider;
2445
2321
  protected readonly auditService: AuditService;
2446
2322
  protected readonly intentCache: alepha_cache0.CachePrimitiveFn<RegistrationIntent, any[]>;
2447
2323
  /**
2448
- * Phase 1: Create a registration intent.
2449
- *
2450
- * Validates the registration data, checks for existing users,
2451
- * creates verification sessions, and stores the intent in cache.
2452
- */
2324
+ * Phase 1: Create a registration intent.
2325
+ *
2326
+ * Validates the registration data, checks for existing users,
2327
+ * creates verification sessions, and stores the intent in cache.
2328
+ */
2453
2329
  createRegistrationIntent(body: RegisterRequest, userRealmName?: string): Promise<RegistrationIntentResponse>;
2454
2330
  /**
2455
- * Phase 2: Complete registration using an intent.
2456
- *
2457
- * Validates all requirements (verification codes, captcha),
2458
- * creates the user and credentials, and returns the user.
2459
- */
2331
+ * Phase 2: Complete registration using an intent.
2332
+ *
2333
+ * Validates all requirements (verification codes, captcha),
2334
+ * creates the user and credentials, and returns the user.
2335
+ */
2460
2336
  completeRegistration(body: CompleteRegistrationRequest): Promise<UserEntity>;
2461
2337
  /**
2462
- * Check if username, email, and phone are available.
2463
- */
2338
+ * Check if username, email, and phone are available.
2339
+ */
2464
2340
  protected checkUserAvailability(body: Pick<RegisterRequest, "username" | "email" | "phoneNumber">, userRealmName?: string): Promise<void>;
2465
2341
  /**
2466
- * Send email verification code.
2467
- */
2342
+ * Send email verification code.
2343
+ */
2468
2344
  protected sendEmailVerification(email: string): Promise<void>;
2469
2345
  /**
2470
- * Send phone verification code.
2471
- */
2346
+ * Send phone verification code.
2347
+ */
2472
2348
  protected sendPhoneVerification(phoneNumber: string): Promise<void>;
2473
2349
  /**
2474
- * Verify email code using verification service.
2475
- */
2350
+ * Verify email code using verification service.
2351
+ */
2476
2352
  protected verifyEmailCode(email: string, code: string): Promise<void>;
2477
2353
  /**
2478
- * Verify phone code using verification service.
2479
- */
2354
+ * Verify phone code using verification service.
2355
+ */
2480
2356
  protected verifyPhoneCode(phoneNumber: string, code: string): Promise<void>;
2481
2357
  }
2482
2358
  //#endregion
@@ -2488,9 +2364,9 @@ declare class UserController {
2488
2364
  protected readonly userService: UserService;
2489
2365
  protected readonly registrationService: RegistrationService;
2490
2366
  /**
2491
- * Phase 1: Create a registration intent.
2492
- * Validates data, creates verification sessions, and stores intent in cache.
2493
- */
2367
+ * Phase 1: Create a registration intent.
2368
+ * Validates data, creates verification sessions, and stores intent in cache.
2369
+ */
2494
2370
  readonly createRegistrationIntent: alepha_server0.ActionPrimitiveFn<{
2495
2371
  body: alepha23.TObject<{
2496
2372
  password: alepha23.TString;
@@ -2513,9 +2389,9 @@ declare class UserController {
2513
2389
  }>;
2514
2390
  }>;
2515
2391
  /**
2516
- * Phase 2: Complete registration using an intent.
2517
- * Validates verification codes and creates the user.
2518
- */
2392
+ * Phase 2: Complete registration using an intent.
2393
+ * Validates verification codes and creates the user.
2394
+ */
2519
2395
  readonly createUserFromIntent: alepha_server0.ActionPrimitiveFn<{
2520
2396
  body: alepha23.TObject<{
2521
2397
  intentId: alepha23.TString;
@@ -2541,9 +2417,9 @@ declare class UserController {
2541
2417
  }>;
2542
2418
  }>;
2543
2419
  /**
2544
- * Phase 1: Create a password reset intent.
2545
- * Validates email, sends verification code, and stores intent in cache.
2546
- */
2420
+ * Phase 1: Create a password reset intent.
2421
+ * Validates email, sends verification code, and stores intent in cache.
2422
+ */
2547
2423
  readonly createPasswordResetIntent: alepha_server0.ActionPrimitiveFn<{
2548
2424
  query: alepha23.TObject<{
2549
2425
  userRealmName: alepha23.TOptional<alepha23.TString>;
@@ -2557,9 +2433,9 @@ declare class UserController {
2557
2433
  }>;
2558
2434
  }>;
2559
2435
  /**
2560
- * Phase 2: Complete password reset using an intent.
2561
- * Validates verification code, updates password, and invalidates sessions.
2562
- */
2436
+ * Phase 2: Complete password reset using an intent.
2437
+ * Validates verification code, updates password, and invalidates sessions.
2438
+ */
2563
2439
  readonly completePasswordReset: alepha_server0.ActionPrimitiveFn<{
2564
2440
  body: alepha23.TObject<{
2565
2441
  intentId: alepha23.TString;
@@ -2573,8 +2449,8 @@ declare class UserController {
2573
2449
  }>;
2574
2450
  }>;
2575
2451
  /**
2576
- * @deprecated Use createPasswordResetIntent instead
2577
- */
2452
+ * @deprecated Use createPasswordResetIntent instead
2453
+ */
2578
2454
  requestPasswordReset: alepha_server0.ActionPrimitiveFn<{
2579
2455
  query: alepha23.TObject<{
2580
2456
  userRealmName: alepha23.TOptional<alepha23.TString>;
@@ -2588,8 +2464,8 @@ declare class UserController {
2588
2464
  }>;
2589
2465
  }>;
2590
2466
  /**
2591
- * @deprecated Use completePasswordReset instead
2592
- */
2467
+ * @deprecated Use completePasswordReset instead
2468
+ */
2593
2469
  validateResetToken: alepha_server0.ActionPrimitiveFn<{
2594
2470
  query: alepha23.TObject<{
2595
2471
  email: alepha23.TString;
@@ -2602,8 +2478,8 @@ declare class UserController {
2602
2478
  }>;
2603
2479
  }>;
2604
2480
  /**
2605
- * @deprecated Use completePasswordReset instead
2606
- */
2481
+ * @deprecated Use completePasswordReset instead
2482
+ */
2607
2483
  resetPassword: alepha_server0.ActionPrimitiveFn<{
2608
2484
  query: alepha23.TObject<{
2609
2485
  userRealmName: alepha23.TOptional<alepha23.TString>;
@@ -2619,11 +2495,11 @@ declare class UserController {
2619
2495
  }>;
2620
2496
  }>;
2621
2497
  /**
2622
- * Request email verification.
2623
- * Generates a verification token using verification service and sends an email to the user.
2624
- * @param method - The verification method: "code" (default) sends a 6-digit code, "link" sends a clickable verification link.
2625
- * @param verifyUrl - Required when method is "link". The base URL for the verification link. Token and email will be appended as query params.
2626
- */
2498
+ * Request email verification.
2499
+ * Generates a verification token using verification service and sends an email to the user.
2500
+ * @param method - The verification method: "code" (default) sends a 6-digit code, "link" sends a clickable verification link.
2501
+ * @param verifyUrl - Required when method is "link". The base URL for the verification link. Token and email will be appended as query params.
2502
+ */
2627
2503
  requestEmailVerification: alepha_server0.ActionPrimitiveFn<{
2628
2504
  query: alepha23.TObject<{
2629
2505
  userRealmName: alepha23.TOptional<alepha23.TString>;
@@ -2639,9 +2515,9 @@ declare class UserController {
2639
2515
  }>;
2640
2516
  }>;
2641
2517
  /**
2642
- * Verify email with a valid token.
2643
- * Updates the user's emailVerified status.
2644
- */
2518
+ * Verify email with a valid token.
2519
+ * Updates the user's emailVerified status.
2520
+ */
2645
2521
  verifyEmail: alepha_server0.ActionPrimitiveFn<{
2646
2522
  query: alepha23.TObject<{
2647
2523
  userRealmName: alepha23.TOptional<alepha23.TString>;
@@ -2656,8 +2532,8 @@ declare class UserController {
2656
2532
  }>;
2657
2533
  }>;
2658
2534
  /**
2659
- * Check if an email is verified.
2660
- */
2535
+ * Check if an email is verified.
2536
+ */
2661
2537
  checkEmailVerification: alepha_server0.ActionPrimitiveFn<{
2662
2538
  query: alepha23.TObject<{
2663
2539
  email: alepha23.TString;
@@ -2669,69 +2545,6 @@ declare class UserController {
2669
2545
  }>;
2670
2546
  }
2671
2547
  //#endregion
2672
- //#region ../../src/api/users/controllers/UserRealmController.d.ts
2673
- /**
2674
- * Controller for exposing realm configuration.
2675
- * Uses $route instead of $action to keep endpoints hidden from API documentation.
2676
- */
2677
- declare class UserRealmController {
2678
- protected readonly url = "/realms";
2679
- protected readonly group = "realms";
2680
- protected readonly userRealmProvider: UserRealmProvider;
2681
- protected readonly serverAuthProvider: ServerAuthProvider;
2682
- /**
2683
- * Get realm configuration settings.
2684
- * This endpoint is not exposed in the API documentation.
2685
- */
2686
- readonly getRealmConfig: alepha_server0.ActionPrimitiveFn<{
2687
- query: alepha23.TObject<{
2688
- userRealmName: alepha23.TOptional<alepha23.TString>;
2689
- }>;
2690
- response: alepha23.TObject<{
2691
- settings: alepha23.TObject<{
2692
- displayName: alepha23.TOptional<alepha23.TString>;
2693
- description: alepha23.TOptional<alepha23.TString>;
2694
- logoUrl: alepha23.TOptional<alepha23.TString>;
2695
- registrationAllowed: alepha23.TBoolean;
2696
- emailEnabled: alepha23.TBoolean;
2697
- emailRequired: alepha23.TBoolean;
2698
- usernameEnabled: alepha23.TBoolean;
2699
- usernameRequired: alepha23.TBoolean;
2700
- phoneEnabled: alepha23.TBoolean;
2701
- phoneRequired: alepha23.TBoolean;
2702
- verifyEmailRequired: alepha23.TBoolean;
2703
- verifyPhoneRequired: alepha23.TBoolean;
2704
- firstNameLastNameEnabled: alepha23.TBoolean;
2705
- firstNameLastNameRequired: alepha23.TBoolean;
2706
- resetPasswordAllowed: alepha23.TBoolean;
2707
- passwordPolicy: alepha23.TObject<{
2708
- minLength: alepha23.TInteger;
2709
- requireUppercase: alepha23.TBoolean;
2710
- requireLowercase: alepha23.TBoolean;
2711
- requireNumbers: alepha23.TBoolean;
2712
- requireSpecialCharacters: alepha23.TBoolean;
2713
- }>;
2714
- }>;
2715
- realmName: alepha23.TString;
2716
- authenticationMethods: alepha23.TArray<alepha23.TObject<{
2717
- name: alepha23.TString;
2718
- type: alepha23.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
2719
- }>>;
2720
- }>;
2721
- }>;
2722
- readonly checkUsernameAvailability: alepha_server0.ActionPrimitiveFn<{
2723
- query: alepha23.TObject<{
2724
- userRealmName: alepha23.TOptional<alepha23.TString>;
2725
- }>;
2726
- body: alepha23.TObject<{
2727
- username: alepha23.TString;
2728
- }>;
2729
- response: alepha23.TObject<{
2730
- available: alepha23.TBoolean;
2731
- }>;
2732
- }>;
2733
- }
2734
- //#endregion
2735
2548
  //#region ../../src/api/users/schemas/identityResourceSchema.d.ts
2736
2549
  declare const identityResourceSchema: alepha23.TObject<{
2737
2550
  id: PgAttr<PgAttr<alepha23.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
@@ -2752,6 +2565,41 @@ declare const loginSchema: alepha23.TObject<{
2752
2565
  }>;
2753
2566
  type LoginInput = Static<typeof loginSchema>;
2754
2567
  //#endregion
2568
+ //#region ../../src/api/users/schemas/realmConfigSchema.d.ts
2569
+ declare const realmConfigSchema: alepha23.TObject<{
2570
+ settings: alepha23.TObject<{
2571
+ displayName: alepha23.TOptional<alepha23.TString>;
2572
+ description: alepha23.TOptional<alepha23.TString>;
2573
+ logoUrl: alepha23.TOptional<alepha23.TString>;
2574
+ registrationAllowed: alepha23.TBoolean;
2575
+ emailEnabled: alepha23.TBoolean;
2576
+ emailRequired: alepha23.TBoolean;
2577
+ usernameEnabled: alepha23.TBoolean;
2578
+ usernameRequired: alepha23.TBoolean;
2579
+ usernameRegExp: alepha23.TString;
2580
+ phoneEnabled: alepha23.TBoolean;
2581
+ phoneRequired: alepha23.TBoolean;
2582
+ verifyEmailRequired: alepha23.TBoolean;
2583
+ verifyPhoneRequired: alepha23.TBoolean;
2584
+ firstNameLastNameEnabled: alepha23.TBoolean;
2585
+ firstNameLastNameRequired: alepha23.TBoolean;
2586
+ resetPasswordAllowed: alepha23.TBoolean;
2587
+ passwordPolicy: alepha23.TObject<{
2588
+ minLength: alepha23.TInteger;
2589
+ requireUppercase: alepha23.TBoolean;
2590
+ requireLowercase: alepha23.TBoolean;
2591
+ requireNumbers: alepha23.TBoolean;
2592
+ requireSpecialCharacters: alepha23.TBoolean;
2593
+ }>;
2594
+ }>;
2595
+ realmName: alepha23.TString;
2596
+ authenticationMethods: alepha23.TArray<alepha23.TObject<{
2597
+ name: alepha23.TString;
2598
+ type: alepha23.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
2599
+ }>>;
2600
+ }>;
2601
+ type RealmConfig = Static<typeof realmConfigSchema>;
2602
+ //#endregion
2755
2603
  //#region ../../src/api/users/schemas/registerSchema.d.ts
2756
2604
  declare const registerSchema: alepha23.TObject<{
2757
2605
  username: alepha23.TString;
@@ -2793,40 +2641,6 @@ declare const sessionResourceSchema: alepha23.TObject<{
2793
2641
  }>;
2794
2642
  type SessionResource = Static<typeof sessionResourceSchema>;
2795
2643
  //#endregion
2796
- //#region ../../src/api/users/schemas/userRealmConfigSchema.d.ts
2797
- declare const userRealmConfigSchema: alepha23.TObject<{
2798
- settings: alepha23.TObject<{
2799
- displayName: alepha23.TOptional<alepha23.TString>;
2800
- description: alepha23.TOptional<alepha23.TString>;
2801
- logoUrl: alepha23.TOptional<alepha23.TString>;
2802
- registrationAllowed: alepha23.TBoolean;
2803
- emailEnabled: alepha23.TBoolean;
2804
- emailRequired: alepha23.TBoolean;
2805
- usernameEnabled: alepha23.TBoolean;
2806
- usernameRequired: alepha23.TBoolean;
2807
- phoneEnabled: alepha23.TBoolean;
2808
- phoneRequired: alepha23.TBoolean;
2809
- verifyEmailRequired: alepha23.TBoolean;
2810
- verifyPhoneRequired: alepha23.TBoolean;
2811
- firstNameLastNameEnabled: alepha23.TBoolean;
2812
- firstNameLastNameRequired: alepha23.TBoolean;
2813
- resetPasswordAllowed: alepha23.TBoolean;
2814
- passwordPolicy: alepha23.TObject<{
2815
- minLength: alepha23.TInteger;
2816
- requireUppercase: alepha23.TBoolean;
2817
- requireLowercase: alepha23.TBoolean;
2818
- requireNumbers: alepha23.TBoolean;
2819
- requireSpecialCharacters: alepha23.TBoolean;
2820
- }>;
2821
- }>;
2822
- realmName: alepha23.TString;
2823
- authenticationMethods: alepha23.TArray<alepha23.TObject<{
2824
- name: alepha23.TString;
2825
- type: alepha23.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
2826
- }>>;
2827
- }>;
2828
- type UserRealmConfig = Static<typeof userRealmConfigSchema>;
2829
- //#endregion
2830
2644
  //#region ../../src/api/users/schemas/userResourceSchema.d.ts
2831
2645
  declare const userResourceSchema: alepha23.TObject<{
2832
2646
  id: PgAttr<PgAttr<alepha23.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
@@ -2853,7 +2667,7 @@ declare class SessionService {
2853
2667
  protected readonly dateTimeProvider: DateTimeProvider;
2854
2668
  protected readonly cryptoProvider: CryptoProvider;
2855
2669
  protected readonly log: alepha_logger5.Logger;
2856
- protected readonly userRealmProvider: UserRealmProvider;
2670
+ protected readonly realmProvider: RealmProvider;
2857
2671
  protected readonly fileController: alepha_server_links0.HttpVirtualClient<FileController>;
2858
2672
  protected readonly auditService: AuditService;
2859
2673
  users(userRealmName?: string): Repository$1<alepha23.TObject<{
@@ -2899,13 +2713,13 @@ declare class SessionService {
2899
2713
  providerData: alepha23.TOptional<alepha23.TRecord<string, alepha23.TAny>>;
2900
2714
  }>>;
2901
2715
  /**
2902
- * Random delay to prevent timing attacks (50-200ms)
2903
- * Uses cryptographically secure random number generation
2904
- */
2716
+ * Random delay to prevent timing attacks (50-200ms)
2717
+ * Uses cryptographically secure random number generation
2718
+ */
2905
2719
  protected randomDelay(): Promise<void>;
2906
2720
  /**
2907
- * Validate user credentials and return the user if valid.
2908
- */
2721
+ * Validate user credentials and return the user if valid.
2722
+ */
2909
2723
  login(provider: string, username: string, password: string, userRealmName?: string): Promise<UserEntity>;
2910
2724
  createSession(user: UserAccount, expiresIn: number, userRealmName?: string): Promise<{
2911
2725
  refreshToken: string;
@@ -3005,5 +2819,5 @@ declare class SessionService {
3005
2819
  */
3006
2820
  declare const AlephaApiUsers: alepha23.Service<alepha23.Module>;
3007
2821
  //#endregion
3008
- export { $userRealm, AdminIdentityController, AdminSessionController, AdminUserController, AlephaApiUsers, CompletePasswordResetRequest, CompleteRegistrationRequest, CreateUser, CredentialService, DEFAULT_USER_REALM_NAME, IdentityEntity, IdentityQuery, IdentityResource, IdentityService, LoginInput, PasswordResetIntentResponse, RealmAuthSettings, RegisterInput, RegistrationIntentResponse, RegistrationService, ResetPasswordInput, ResetPasswordRequest, SessionCrudService, SessionEntity, SessionQuery, SessionResource, SessionService, UpdateUser, UserController, UserEntity, UserQuery, UserRealm, UserRealmConfig, UserRealmController, UserRealmOptions, UserRealmPrimitive, UserRealmProvider, UserRealmRepositories, UserResource, UserService, completePasswordResetRequestSchema, completeRegistrationRequestSchema, createUserSchema, identities, identityQuerySchema, identityResourceSchema, loginSchema, passwordResetIntentResponseSchema, realmAuthSettingsAtom, registerSchema, registrationIntentResponseSchema, resetPasswordRequestSchema, resetPasswordSchema, sessionQuerySchema, sessionResourceSchema, sessions, updateUserSchema, userQuerySchema, userRealmConfigSchema, userResourceSchema, users };
2822
+ export { $realm, AdminIdentityController, AdminSessionController, AdminUserController, AlephaApiUsers, CompletePasswordResetRequest, CompleteRegistrationRequest, CreateUser, CredentialService, DEFAULT_USER_REALM_NAME, IdentityEntity, IdentityQuery, IdentityResource, IdentityService, LoginInput, PasswordResetIntentResponse, Realm, RealmAuthSettings, RealmConfig, RealmController, RealmOptions, RealmPrimitive, RealmProvider, RealmRepositories, RegisterInput, RegistrationIntentResponse, RegistrationService, ResetPasswordInput, ResetPasswordRequest, SessionCrudService, SessionEntity, SessionQuery, SessionResource, SessionService, UpdateUser, UserController, UserEntity, UserQuery, UserResource, UserService, completePasswordResetRequestSchema, completeRegistrationRequestSchema, createUserSchema, identities, identityQuerySchema, identityResourceSchema, loginSchema, passwordResetIntentResponseSchema, realmAuthSettingsAtom, realmConfigSchema, registerSchema, registrationIntentResponseSchema, resetPasswordRequestSchema, resetPasswordSchema, sessionQuerySchema, sessionResourceSchema, sessions, updateUserSchema, userQuerySchema, userResourceSchema, users };
3009
2823
  //# sourceMappingURL=index.d.ts.map