alepha 0.20.5 → 0.20.6

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 (192) hide show
  1. package/dist/api/audits/index.d.ts +391 -359
  2. package/dist/api/audits/index.d.ts.map +1 -1
  3. package/dist/api/audits/index.js +23 -1
  4. package/dist/api/audits/index.js.map +1 -1
  5. package/dist/api/files/index.d.ts +18 -0
  6. package/dist/api/files/index.d.ts.map +1 -1
  7. package/dist/api/files/index.js +51 -0
  8. package/dist/api/files/index.js.map +1 -1
  9. package/dist/api/jobs/index.browser.js +33 -14
  10. package/dist/api/jobs/index.browser.js.map +1 -1
  11. package/dist/api/jobs/index.d.ts +452 -155
  12. package/dist/api/jobs/index.d.ts.map +1 -1
  13. package/dist/api/jobs/index.js +474 -159
  14. package/dist/api/jobs/index.js.map +1 -1
  15. package/dist/api/keys/index.d.ts +28 -0
  16. package/dist/api/keys/index.d.ts.map +1 -1
  17. package/dist/api/keys/index.js +53 -0
  18. package/dist/api/keys/index.js.map +1 -1
  19. package/dist/api/notifications/index.d.ts +29 -1
  20. package/dist/api/notifications/index.d.ts.map +1 -1
  21. package/dist/api/notifications/index.js +55 -13
  22. package/dist/api/notifications/index.js.map +1 -1
  23. package/dist/api/organizations/index.js.map +1 -1
  24. package/dist/api/parameters/index.d.ts +17 -2
  25. package/dist/api/parameters/index.d.ts.map +1 -1
  26. package/dist/api/parameters/index.js +37 -0
  27. package/dist/api/parameters/index.js.map +1 -1
  28. package/dist/api/payments/index.js.map +1 -1
  29. package/dist/api/users/index.d.ts +168 -27
  30. package/dist/api/users/index.d.ts.map +1 -1
  31. package/dist/api/users/index.js +237 -28
  32. package/dist/api/users/index.js.map +1 -1
  33. package/dist/api/verifications/index.d.ts +3 -3
  34. package/dist/api/verifications/index.js.map +1 -1
  35. package/dist/batch/index.js.map +1 -1
  36. package/dist/bucket/index.d.ts +18 -0
  37. package/dist/bucket/index.d.ts.map +1 -1
  38. package/dist/bucket/index.js +47 -0
  39. package/dist/bucket/index.js.map +1 -1
  40. package/dist/bucket/index.workerd.js +24 -0
  41. package/dist/bucket/index.workerd.js.map +1 -1
  42. package/dist/cache/core/index.d.ts +20 -3
  43. package/dist/cache/core/index.d.ts.map +1 -1
  44. package/dist/cache/core/index.js.map +1 -1
  45. package/dist/cache/core/index.workerd.js.map +1 -1
  46. package/dist/cache/database/index.d.ts +155 -0
  47. package/dist/cache/database/index.d.ts.map +1 -0
  48. package/dist/cache/database/index.js +266 -0
  49. package/dist/cache/database/index.js.map +1 -0
  50. package/dist/cache/redis/index.js.map +1 -1
  51. package/dist/captcha/index.js.map +1 -1
  52. package/dist/cli/config/index.js.map +1 -1
  53. package/dist/cli/core/index.d.ts +34 -4
  54. package/dist/cli/core/index.d.ts.map +1 -1
  55. package/dist/cli/core/index.js +85 -6
  56. package/dist/cli/core/index.js.map +1 -1
  57. package/dist/cli/devtools/index.js.map +1 -1
  58. package/dist/cli/platform/index.js +1 -1
  59. package/dist/cli/platform/index.js.map +1 -1
  60. package/dist/cli/vendor/index.js.map +1 -1
  61. package/dist/command/index.d.ts +1 -1
  62. package/dist/command/index.js.map +1 -1
  63. package/dist/core/index.browser.js.map +1 -1
  64. package/dist/core/index.js.map +1 -1
  65. package/dist/core/index.native.js.map +1 -1
  66. package/dist/core/index.workerd.js.map +1 -1
  67. package/dist/crypto/index.browser.js.map +1 -1
  68. package/dist/crypto/index.js.map +1 -1
  69. package/dist/datetime/index.js.map +1 -1
  70. package/dist/email/brevo/index.js.map +1 -1
  71. package/dist/email/core/index.js.map +1 -1
  72. package/dist/email/core/index.workerd.js.map +1 -1
  73. package/dist/email/smtp/index.js.map +1 -1
  74. package/dist/fake/index.js.map +1 -1
  75. package/dist/lock/core/index.js.map +1 -1
  76. package/dist/lock/redis/index.js.map +1 -1
  77. package/dist/logger/index.js.map +1 -1
  78. package/dist/mcp/index.js.map +1 -1
  79. package/dist/orm/core/index.browser.js.map +1 -1
  80. package/dist/orm/core/index.bun.js.map +1 -1
  81. package/dist/orm/core/index.js.map +1 -1
  82. package/dist/orm/postgres/index.bun.js.map +1 -1
  83. package/dist/orm/postgres/index.js.map +1 -1
  84. package/dist/queue/core/index.js.map +1 -1
  85. package/dist/queue/core/index.workerd.js.map +1 -1
  86. package/dist/queue/redis/index.js.map +1 -1
  87. package/dist/react/auth/index.browser.js.map +1 -1
  88. package/dist/react/auth/index.js.map +1 -1
  89. package/dist/react/core/index.js.map +1 -1
  90. package/dist/react/form/index.js +2 -0
  91. package/dist/react/form/index.js.map +1 -1
  92. package/dist/react/head/index.browser.js.map +1 -1
  93. package/dist/react/head/index.js.map +1 -1
  94. package/dist/react/i18n/index.js.map +1 -1
  95. package/dist/react/intro/index.js.map +1 -1
  96. package/dist/react/router/index.browser.js.map +1 -1
  97. package/dist/react/router/index.js.map +1 -1
  98. package/dist/react/testing/index.js.map +1 -1
  99. package/dist/react/ui/index.js.map +1 -1
  100. package/dist/react/websocket/index.js.map +1 -1
  101. package/dist/redis/index.bun.js.map +1 -1
  102. package/dist/redis/index.js.map +1 -1
  103. package/dist/retry/index.js.map +1 -1
  104. package/dist/router/index.js.map +1 -1
  105. package/dist/scheduler/index.d.ts +22 -0
  106. package/dist/scheduler/index.d.ts.map +1 -1
  107. package/dist/scheduler/index.js +12 -0
  108. package/dist/scheduler/index.js.map +1 -1
  109. package/dist/scheduler/index.workerd.js +12 -0
  110. package/dist/scheduler/index.workerd.js.map +1 -1
  111. package/dist/security/index.browser.js.map +1 -1
  112. package/dist/security/index.js.map +1 -1
  113. package/dist/server/auth/index.js.map +1 -1
  114. package/dist/server/cookies/index.browser.js.map +1 -1
  115. package/dist/server/cookies/index.js.map +1 -1
  116. package/dist/server/core/index.browser.js.map +1 -1
  117. package/dist/server/core/index.js.map +1 -1
  118. package/dist/server/cors/index.js.map +1 -1
  119. package/dist/server/etag/index.js.map +1 -1
  120. package/dist/server/health/index.js.map +1 -1
  121. package/dist/server/links/index.browser.js.map +1 -1
  122. package/dist/server/links/index.js.map +1 -1
  123. package/dist/server/metrics/index.js.map +1 -1
  124. package/dist/server/proxy/index.js.map +1 -1
  125. package/dist/server/rate-limit/index.js.map +1 -1
  126. package/dist/server/static/index.js.map +1 -1
  127. package/dist/server/swagger/index.js.map +1 -1
  128. package/dist/sms/index.js.map +1 -1
  129. package/dist/system/index.browser.js.map +1 -1
  130. package/dist/system/index.js.map +1 -1
  131. package/dist/system/index.workerd.js.map +1 -1
  132. package/dist/topic/core/index.js.map +1 -1
  133. package/dist/topic/redis/index.js.map +1 -1
  134. package/dist/websocket/index.browser.js +4 -0
  135. package/dist/websocket/index.browser.js.map +1 -1
  136. package/dist/websocket/index.js +10 -0
  137. package/dist/websocket/index.js.map +1 -1
  138. package/package.json +19 -9
  139. package/src/api/audits/controllers/AdminAuditController.ts +29 -0
  140. package/src/api/files/controllers/FileController.ts +24 -0
  141. package/src/api/files/services/FileService.ts +41 -0
  142. package/src/api/jobs/__tests__/$job.spec.ts +427 -2
  143. package/src/api/jobs/entities/jobExecutionEntity.ts +3 -3
  144. package/src/api/jobs/index.ts +47 -10
  145. package/src/api/jobs/primitives/$job.ts +22 -9
  146. package/src/api/jobs/providers/DirectJobDispatcher.ts +71 -0
  147. package/src/api/jobs/providers/JobDispatcher.ts +49 -0
  148. package/src/api/jobs/providers/JobProvider.ts +365 -142
  149. package/src/api/jobs/providers/JobQueueProvider.ts +43 -18
  150. package/src/api/jobs/schemas/jobConfigAtom.ts +4 -3
  151. package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +11 -0
  152. package/src/api/jobs/schemas/jobRegistrationSchema.ts +4 -2
  153. package/src/api/jobs/services/JobService.ts +21 -11
  154. package/src/api/keys/controllers/AdminApiKeyController.ts +23 -0
  155. package/src/api/keys/services/ApiKeyService.ts +42 -0
  156. package/src/api/notifications/__tests__/AlephaApiNotifications.spec.ts +63 -0
  157. package/src/api/notifications/controllers/AdminNotificationController.ts +48 -1
  158. package/src/api/notifications/index.ts +13 -3
  159. package/src/api/notifications/jobs/NotificationJobs.ts +0 -6
  160. package/src/api/parameters/controllers/AdminParameterController.ts +26 -0
  161. package/src/api/parameters/services/ParameterProvider.ts +18 -0
  162. package/src/api/users/__tests__/Registration-emailMode.spec.ts +203 -0
  163. package/src/api/users/__tests__/UsernameSlugger.spec.ts +138 -0
  164. package/src/api/users/atoms/realmAuthSettingsAtom.ts +41 -3
  165. package/src/api/users/controllers/AdminSessionController.ts +29 -0
  166. package/src/api/users/controllers/AdminUserController.ts +32 -0
  167. package/src/api/users/index.ts +3 -0
  168. package/src/api/users/services/CredentialService.ts +5 -0
  169. package/src/api/users/services/RegistrationService.ts +49 -1
  170. package/src/api/users/services/SessionCrudService.ts +16 -0
  171. package/src/api/users/services/SessionService.ts +17 -59
  172. package/src/api/users/services/UsernameSlugger.ts +195 -0
  173. package/src/bucket/primitives/$bucket.ts +21 -0
  174. package/src/bucket/providers/CloudflareR2Provider.ts +15 -0
  175. package/src/bucket/providers/FileStorageProvider.ts +9 -0
  176. package/src/bucket/providers/LocalFileStorageProvider.ts +14 -0
  177. package/src/bucket/providers/MemoryFileStorageProvider.ts +9 -0
  178. package/src/bucket/providers/NodeS3BucketProvider.ts +35 -0
  179. package/src/cache/core/primitives/$cache.ts +20 -3
  180. package/src/cache/database/__tests__/DatabaseCacheProvider.behavior.spec.ts +203 -0
  181. package/src/cache/database/__tests__/DatabaseCacheProvider.spec.ts +110 -0
  182. package/src/cache/database/entities/cacheEntries.ts +55 -0
  183. package/src/cache/database/index.ts +36 -0
  184. package/src/cache/database/providers/DatabaseCacheProvider.ts +348 -0
  185. package/src/cli/core/services/ProjectScaffolder.ts +0 -2
  186. package/src/cli/core/tasks/BuildCloudflareTask.ts +17 -3
  187. package/src/cli/core/tasks/BuildSitemapTask.ts +7 -0
  188. package/src/cli/core/tasks/BuildVercelTask.ts +82 -3
  189. package/src/cli/platform/__tests__/detectResources.spec.ts +96 -0
  190. package/src/cli/platform/commands/platform.ts +7 -1
  191. package/src/scheduler/index.ts +14 -0
  192. package/src/scheduler/providers/CronProvider.ts +13 -0
@@ -1,361 +1,57 @@
1
1
  import * as _$alepha from "alepha";
2
2
  import { Alepha, KIND, Primitive, Static, TNull, TObject, TOptional, TSchema, TUnion } from "alepha";
3
- import * as _$alepha_server0 from "alepha/server";
4
- import { ServerRequest } from "alepha/server";
5
3
  import * as _$alepha_orm0 from "alepha/orm";
6
4
  import { Page } from "alepha/orm";
5
+ import * as _$alepha_server0 from "alepha/server";
6
+ import { ServerRequest } from "alepha/server";
7
7
  import * as _$alepha_logger0 from "alepha/logger";
8
8
  import { BuildExtraConfigColumns, SQL } from "drizzle-orm";
9
9
  import { PgColumnBuilderBase, PgSequenceOptions, PgTableExtraConfigValue, UpdateDeleteAction } from "drizzle-orm/pg-core";
10
- //#region ../../src/orm/core/schemas/insertSchema.d.ts
10
+ //#region ../../src/api/audits/entities/audits.d.ts
11
11
  /**
12
- * Transforms a TObject schema for insert operations.
13
- * All default properties at the root level are made optional.
14
- * Generated columns are excluded entirely.
15
- *
16
- * @example
17
- * Before: { name: string; age: number(default=0); fullName: generated }
18
- * After: { name: string; age?: number; }
12
+ * Audit severity levels for categorizing events.
19
13
  */
20
- type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"] as T["properties"][K] extends {
21
- [PG_GENERATED]: any;
22
- } ? never : K]: T["properties"][K] extends {
23
- [PG_DEFAULT]: any;
24
- } | {
25
- "~optional": true;
26
- } ? TOptional<T["properties"][K]> : T["properties"][K] }>;
27
- //#endregion
28
- //#region ../../src/orm/core/schemas/updateSchema.d.ts
14
+ declare const auditSeveritySchema: _$alepha.TUnsafe<"info" | "warning" | "critical">;
15
+ type AuditSeverity = Static<typeof auditSeveritySchema>;
29
16
  /**
30
- * Transforms a TObject schema for update operations.
31
- * All optional properties at the root level are made nullable (i.e., `T | null`).
32
- * Generated columns are excluded entirely.
17
+ * Audit log entity for tracking important system events.
33
18
  *
34
- * @example
35
- * Before: { name?: string; age: number; fullName: generated }
36
- * After: { name?: string | null; age: number; }
19
+ * Stores comprehensive audit information including:
20
+ * - Who performed the action (userId, userRealm)
21
+ * - What happened (type, action, resource)
22
+ * - When it happened (createdAt)
23
+ * - Context and details (metadata, ipAddress, userAgent)
37
24
  */
38
- type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"] as T["properties"][K] extends {
39
- [PG_GENERATED]: any;
40
- } ? never : K]: T["properties"][K] extends TOptional<infer U> ? TOptional<TUnion<[U, TNull]>> : T["properties"][K] }>;
41
- //#endregion
42
- //#region ../../src/orm/core/primitives/$entity.d.ts
43
- interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
25
+ declare const audits: _$alepha_orm0.EntityPrimitive<_$alepha.TObject<{
26
+ id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
27
+ createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
44
28
  /**
45
- * The database table name that will be created for this entity.
46
- * If not provided, name will be inferred from the $repository variable name.
29
+ * Audit event type (e.g., "auth", "user", "payment", "system").
30
+ * Used for categorizing and filtering audit events.
47
31
  */
48
- name: string;
32
+ type: _$alepha.TString;
49
33
  /**
50
- * TypeBox schema defining the table structure and column types.
34
+ * Specific action performed (e.g., "login", "logout", "create", "update", "delete").
51
35
  */
52
- schema: T;
36
+ action: _$alepha.TString;
53
37
  /**
54
- * Database indexes to create for query optimization.
38
+ * Severity level of the event.
55
39
  */
56
- indexes?: (Keys | {
57
- /**
58
- * Single column to index.
59
- */
60
- column: Keys;
61
- /**
62
- * Whether this should be a unique index (enforces uniqueness constraint).
63
- */
64
- unique?: boolean;
65
- /**
66
- * Custom name for the index. If not provided, generates name automatically.
67
- */
68
- name?: string;
69
- /**
70
- * Partial index condition. Only rows matching this SQL expression are indexed.
71
- */
72
- where?: SQL;
73
- } | {
74
- /**
75
- * Multiple columns for composite index (order matters for query optimization).
76
- */
77
- columns: Keys[];
78
- /**
79
- * Whether this should be a unique index (enforces uniqueness constraint).
80
- */
81
- unique?: boolean;
82
- /**
83
- * Custom name for the index. If not provided, generates name automatically.
84
- */
85
- name?: string;
86
- /**
87
- * Partial index condition. Only rows matching this SQL expression are indexed.
88
- */
89
- where?: SQL;
90
- } | {
91
- /**
92
- * SQL expressions for expression-based indexes.
93
- *
94
- * Can include column references and SQL functions like `LOWER()`, `UPPER()`, etc.
95
- * Columns and expressions can be mixed together.
96
- *
97
- * @example
98
- * ```ts
99
- * // Case-insensitive unique username per realm
100
- * indexes: [{
101
- * expressions: (self) => [self.realm, sql`LOWER(${self.username})`],
102
- * unique: true,
103
- * name: "users_realm_username_lower_idx",
104
- * }]
105
- * ```
106
- */
107
- expressions: (self: Record<Keys & string, any>) => (SQL | any)[];
108
- /**
109
- * Whether this should be a unique index (enforces uniqueness constraint).
110
- */
111
- unique?: boolean;
112
- /**
113
- * Custom name for the index. If not provided, generates name automatically.
114
- */
115
- name: string;
116
- /**
117
- * Partial index condition. Only rows matching this SQL expression are indexed.
118
- */
119
- where?: SQL;
120
- })[];
40
+ severity: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof _$alepha_orm0.PG_DEFAULT>;
121
41
  /**
122
- * Foreign key constraints to maintain referential integrity.
42
+ * User ID who performed the action (null for system events).
123
43
  */
124
- foreignKeys?: Array<{
125
- /**
126
- * Optional name for the foreign key constraint.
127
- */
128
- name?: string;
129
- /**
130
- * Local columns that reference the foreign table.
131
- */
132
- columns: Array<keyof Static<T>>;
133
- /**
134
- * Referenced columns in the foreign table.
135
- * Must be EntityColumn references from other entities.
136
- */
137
- foreignColumns: Array<() => EntityColumn<any>>;
138
- }>;
44
+ userId: _$alepha.TOptional<_$alepha.TString>;
139
45
  /**
140
- * Additional table constraints for data validation.
141
- *
142
- * Constraints enforce business rules at the database level, providing
143
- * an additional layer of data integrity beyond application validation.
144
- *
145
- * **Constraint Types**:
146
- * - **Unique constraints**: Prevent duplicate values across columns
147
- * - **Check constraints**: Enforce custom validation rules with SQL expressions
148
- *
149
- * @example
150
- * ```ts
151
- * constraints: [
152
- * {
153
- * name: "unique_user_email",
154
- * columns: ["email"],
155
- * unique: true
156
- * },
157
- * {
158
- * name: "valid_age_range",
159
- * columns: ["age"],
160
- * check: sql`age >= 0 AND age <= 150`
161
- * },
162
- * {
163
- * name: "unique_user_username_per_tenant",
164
- * columns: ["tenantId", "username"],
165
- * unique: true
166
- * }
167
- * ]
168
- * ```
46
+ * User realm for multi-tenant support.
169
47
  */
170
- constraints?: Array<{
171
- /**
172
- * Columns involved in this constraint.
173
- */
174
- columns: Array<keyof Static<T>>;
175
- /**
176
- * Optional name for the constraint.
177
- */
178
- name?: string;
179
- /**
180
- * Whether this is a unique constraint.
181
- */
182
- unique?: boolean | {};
183
- /**
184
- * SQL expression for check constraint validation.
185
- */
186
- check?: SQL;
187
- }>;
48
+ userRealm: _$alepha.TOptional<_$alepha.TString>;
188
49
  /**
189
- * Advanced Drizzle ORM configuration for complex table setups.
50
+ * User email at the time of the event (denormalized for history).
190
51
  */
191
- config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
192
- }
193
- declare class EntityPrimitive<T extends TObject = TObject> {
194
- readonly options: EntityPrimitiveOptions<T>;
195
- constructor(options: EntityPrimitiveOptions<T>);
196
- alias(alias: string): this;
197
- get cols(): EntityColumns<T>;
198
- get name(): string;
199
- get schema(): T;
200
- get insertSchema(): TObjectInsert<T>;
201
- get updateSchema(): TObjectUpdate<T>;
202
- }
203
- /**
204
- * Convert a schema to columns.
205
- */
206
- type FromSchema<T extends TObject> = { [key in keyof T["properties"]]: PgColumnBuilderBase };
207
- type EntityColumn<T extends TObject> = {
208
- name: string;
209
- entity: EntityPrimitive<T>;
210
- };
211
- type EntityColumns<T extends TObject> = { [key in keyof T["properties"]]: EntityColumn<T> };
212
- //#endregion
213
- //#region ../../src/orm/core/constants/PG_SYMBOLS.d.ts
214
- declare const PG_DEFAULT: unique symbol;
215
- declare const PG_PRIMARY_KEY: unique symbol;
216
- declare const PG_CREATED_AT: unique symbol;
217
- declare const PG_UPDATED_AT: unique symbol;
218
- declare const PG_DELETED_AT: unique symbol;
219
- declare const PG_VERSION: unique symbol;
220
- declare const PG_IDENTITY: unique symbol;
221
- declare const PG_ENUM: unique symbol;
222
- declare const PG_REF: unique symbol;
223
- declare const PG_GENERATED: unique symbol;
224
- declare const PG_ORGANIZATION: unique symbol;
225
- /**
226
- * @deprecated Use `PG_IDENTITY` instead.
227
- */
228
- declare const PG_SERIAL: unique symbol;
229
- type PgSymbols = {
230
- [PG_DEFAULT]: {};
231
- [PG_PRIMARY_KEY]: {};
232
- [PG_CREATED_AT]: {};
233
- [PG_UPDATED_AT]: {};
234
- [PG_DELETED_AT]: {};
235
- [PG_VERSION]: {};
236
- [PG_IDENTITY]: PgIdentityOptions;
237
- [PG_REF]: PgRefOptions;
238
- [PG_ENUM]: PgEnumOptions;
239
- [PG_GENERATED]: PgGeneratedOptions;
240
- [PG_ORGANIZATION]: {};
52
+ userEmail: _$alepha.TOptional<_$alepha.TString>;
241
53
  /**
242
- * @deprecated Use `PG_IDENTITY` instead.
243
- */
244
- [PG_SERIAL]: {};
245
- };
246
- type PgSymbolKeys = keyof PgSymbols;
247
- type PgIdentityOptions = {
248
- mode: "always" | "byDefault";
249
- } & PgSequenceOptions & {
250
- name?: string;
251
- };
252
- interface PgEnumOptions {
253
- name?: string;
254
- description?: string;
255
- }
256
- interface PgGeneratedOptions {
257
- /**
258
- * SQL expression for the generated column.
259
- */
260
- expression: SQL;
261
- /**
262
- * Storage mode for the generated column.
263
- * - `"stored"` — value is computed on write and stored on disk (default for PostgreSQL).
264
- * - `"virtual"` — value is computed on read (default for SQLite).
265
- */
266
- mode?: "stored" | "virtual";
267
- }
268
- interface PgRefOptions {
269
- ref: () => {
270
- name: string;
271
- entity: EntityPrimitive;
272
- };
273
- actions?: {
274
- onUpdate?: UpdateDeleteAction;
275
- onDelete?: UpdateDeleteAction;
276
- };
277
- }
278
- //#endregion
279
- //#region ../../src/orm/core/helpers/pgAttr.d.ts
280
- /**
281
- * Type representation.
282
- */
283
- type PgAttr<T extends TSchema, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
284
- //#endregion
285
- //#region ../../src/orm/core/schemas/databaseEnvSchema.d.ts
286
- /**
287
- * Base database environment schema.
288
- *
289
- * Defines the `DATABASE_URL` connection string used by all ORM providers
290
- * to determine the database driver and connection target.
291
- *
292
- * Supported URL formats:
293
- * - `sqlite://:memory:` or `sqlite://./path/to/db` — SQLite (Node.js or Bun)
294
- * - `postgres://user:password@host:port/database` — PostgreSQL (Node.js or Bun)
295
- * - `pglite://:memory:` or `pglite://./path` — PGlite (embedded Postgres)
296
- * - `d1://BINDING_NAME` — Cloudflare D1
297
- * - `hyperdrive://BINDING_NAME` — Cloudflare Hyperdrive
298
- */
299
- declare const databaseEnvSchema: _$alepha.TObject<{
300
- DATABASE_URL: _$alepha.TOptional<_$alepha.TString>;
301
- /**
302
- * Enable or disable push-based schema synchronization (drizzle-kit push).
303
- *
304
- * Defaults to `true` in development and test, `false` in production.
305
- * Set to `false` in development to skip automatic schema sync
306
- * (e.g. when managing migrations manually).
307
- */
308
- DATABASE_SYNC: _$alepha.TOptional<_$alepha.TBoolean>;
309
- }>;
310
- declare module "alepha" {
311
- interface Env extends Partial<Static<typeof databaseEnvSchema>> {}
312
- } //# sourceMappingURL=databaseEnvSchema.d.ts.map
313
- //#endregion
314
- //#region ../../src/api/audits/entities/audits.d.ts
315
- /**
316
- * Audit severity levels for categorizing events.
317
- */
318
- declare const auditSeveritySchema: _$alepha.TUnsafe<"info" | "warning" | "critical">;
319
- type AuditSeverity = Static<typeof auditSeveritySchema>;
320
- /**
321
- * Audit log entity for tracking important system events.
322
- *
323
- * Stores comprehensive audit information including:
324
- * - Who performed the action (userId, userRealm)
325
- * - What happened (type, action, resource)
326
- * - When it happened (createdAt)
327
- * - Context and details (metadata, ipAddress, userAgent)
328
- */
329
- declare const audits: _$alepha_orm0.EntityPrimitive<_$alepha.TObject<{
330
- id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
331
- createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
332
- /**
333
- * Audit event type (e.g., "auth", "user", "payment", "system").
334
- * Used for categorizing and filtering audit events.
335
- */
336
- type: _$alepha.TString;
337
- /**
338
- * Specific action performed (e.g., "login", "logout", "create", "update", "delete").
339
- */
340
- action: _$alepha.TString;
341
- /**
342
- * Severity level of the event.
343
- */
344
- severity: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof _$alepha_orm0.PG_DEFAULT>;
345
- /**
346
- * User ID who performed the action (null for system events).
347
- */
348
- userId: _$alepha.TOptional<_$alepha.TString>;
349
- /**
350
- * User realm for multi-tenant support.
351
- */
352
- userRealm: _$alepha.TOptional<_$alepha.TString>;
353
- /**
354
- * User email at the time of the event (denormalized for history).
355
- */
356
- userEmail: _$alepha.TOptional<_$alepha.TString>;
357
- /**
358
- * Resource type affected (e.g., "user", "order", "file").
54
+ * Resource type affected (e.g., "user", "order", "file").
359
55
  */
360
56
  resourceType: _$alepha.TOptional<_$alepha.TString>;
361
57
  /**
@@ -721,6 +417,26 @@ declare class AdminAuditController {
721
417
  protected readonly url = "/audits";
722
418
  protected readonly group = "admin:audits";
723
419
  protected readonly auditService: AuditService;
420
+ protected readonly repo: _$alepha_orm0.Repository<_$alepha.TObject<{
421
+ id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
422
+ createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
423
+ type: _$alepha.TString;
424
+ action: _$alepha.TString;
425
+ severity: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof _$alepha_orm0.PG_DEFAULT>;
426
+ userId: _$alepha.TOptional<_$alepha.TString>;
427
+ userRealm: _$alepha.TOptional<_$alepha.TString>;
428
+ userEmail: _$alepha.TOptional<_$alepha.TString>;
429
+ resourceType: _$alepha.TOptional<_$alepha.TString>;
430
+ resourceId: _$alepha.TOptional<_$alepha.TString>;
431
+ description: _$alepha.TOptional<_$alepha.TString>;
432
+ metadata: _$alepha.TOptional<_$alepha.TRecord<string, _$alepha.TAny>>;
433
+ ipAddress: _$alepha.TOptional<_$alepha.TString>;
434
+ userAgent: _$alepha.TOptional<_$alepha.TString>;
435
+ sessionId: _$alepha.TOptional<_$alepha.TString>;
436
+ requestId: _$alepha.TOptional<_$alepha.TString>;
437
+ success: _$alepha_orm0.PgAttr<_$alepha.TBoolean, typeof _$alepha_orm0.PG_DEFAULT>;
438
+ errorMessage: _$alepha.TOptional<_$alepha.TString>;
439
+ }>>;
724
440
  /**
725
441
  * Find audit entries with filtering and pagination.
726
442
  */
@@ -742,11 +458,11 @@ declare class AdminAuditController {
742
458
  search: _$alepha.TOptional<_$alepha.TString>;
743
459
  }>;
744
460
  response: _$alepha.TPage<_$alepha.TObject<{
745
- id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
746
- createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
461
+ id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
462
+ createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
747
463
  type: _$alepha.TString;
748
464
  action: _$alepha.TString;
749
- severity: PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof PG_DEFAULT>;
465
+ severity: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof _$alepha_orm0.PG_DEFAULT>;
750
466
  userId: _$alepha.TOptional<_$alepha.TString>;
751
467
  userRealm: _$alepha.TOptional<_$alepha.TString>;
752
468
  userEmail: _$alepha.TOptional<_$alepha.TString>;
@@ -758,7 +474,7 @@ declare class AdminAuditController {
758
474
  userAgent: _$alepha.TOptional<_$alepha.TString>;
759
475
  sessionId: _$alepha.TOptional<_$alepha.TString>;
760
476
  requestId: _$alepha.TOptional<_$alepha.TString>;
761
- success: PgAttr<_$alepha.TBoolean, typeof PG_DEFAULT>;
477
+ success: _$alepha_orm0.PgAttr<_$alepha.TBoolean, typeof _$alepha_orm0.PG_DEFAULT>;
762
478
  errorMessage: _$alepha.TOptional<_$alepha.TString>;
763
479
  }>>;
764
480
  }>;
@@ -770,11 +486,11 @@ declare class AdminAuditController {
770
486
  id: _$alepha.TString;
771
487
  }>;
772
488
  response: _$alepha.TObject<{
773
- id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
774
- createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
489
+ id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
490
+ createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
775
491
  type: _$alepha.TString;
776
492
  action: _$alepha.TString;
777
- severity: PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof PG_DEFAULT>;
493
+ severity: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof _$alepha_orm0.PG_DEFAULT>;
778
494
  userId: _$alepha.TOptional<_$alepha.TString>;
779
495
  userRealm: _$alepha.TOptional<_$alepha.TString>;
780
496
  userEmail: _$alepha.TOptional<_$alepha.TString>;
@@ -786,10 +502,22 @@ declare class AdminAuditController {
786
502
  userAgent: _$alepha.TOptional<_$alepha.TString>;
787
503
  sessionId: _$alepha.TOptional<_$alepha.TString>;
788
504
  requestId: _$alepha.TOptional<_$alepha.TString>;
789
- success: PgAttr<_$alepha.TBoolean, typeof PG_DEFAULT>;
505
+ success: _$alepha_orm0.PgAttr<_$alepha.TBoolean, typeof _$alepha_orm0.PG_DEFAULT>;
790
506
  errorMessage: _$alepha.TOptional<_$alepha.TString>;
791
507
  }>;
792
508
  }>;
509
+ /**
510
+ * Delete many audit entries by id in one repository call. Use with care —
511
+ * audit logs are usually retained for compliance reasons.
512
+ */
513
+ readonly deleteAudits: _$alepha_server0.ActionPrimitiveFn<{
514
+ body: _$alepha.TObject<{
515
+ ids: _$alepha.TArray<_$alepha.TString>;
516
+ }>;
517
+ response: _$alepha.TObject<{
518
+ deleted: _$alepha.TArray<_$alepha.TString>;
519
+ }>;
520
+ }>;
793
521
  /**
794
522
  * Create a new audit entry.
795
523
  * System-only — this permission should never be assigned to human roles.
@@ -814,11 +542,11 @@ declare class AdminAuditController {
814
542
  errorMessage: _$alepha.TOptional<_$alepha.TString>;
815
543
  }>;
816
544
  response: _$alepha.TObject<{
817
- id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
818
- createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
545
+ id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
546
+ createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
819
547
  type: _$alepha.TString;
820
548
  action: _$alepha.TString;
821
- severity: PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof PG_DEFAULT>;
549
+ severity: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof _$alepha_orm0.PG_DEFAULT>;
822
550
  userId: _$alepha.TOptional<_$alepha.TString>;
823
551
  userRealm: _$alepha.TOptional<_$alepha.TString>;
824
552
  userEmail: _$alepha.TOptional<_$alepha.TString>;
@@ -830,7 +558,7 @@ declare class AdminAuditController {
830
558
  userAgent: _$alepha.TOptional<_$alepha.TString>;
831
559
  sessionId: _$alepha.TOptional<_$alepha.TString>;
832
560
  requestId: _$alepha.TOptional<_$alepha.TString>;
833
- success: PgAttr<_$alepha.TBoolean, typeof PG_DEFAULT>;
561
+ success: _$alepha_orm0.PgAttr<_$alepha.TBoolean, typeof _$alepha_orm0.PG_DEFAULT>;
834
562
  errorMessage: _$alepha.TOptional<_$alepha.TString>;
835
563
  }>;
836
564
  }>;
@@ -843,9 +571,9 @@ declare class AdminAuditController {
843
571
  }>;
844
572
  query: _$alepha.TObject<{
845
573
  type: _$alepha.TOptional<_$alepha.TString>;
846
- search: _$alepha.TOptional<_$alepha.TString>;
847
574
  action: _$alepha.TOptional<_$alepha.TString>;
848
575
  severity: _$alepha.TOptional<_$alepha.TUnsafe<"info" | "warning" | "critical">>;
576
+ search: _$alepha.TOptional<_$alepha.TString>;
849
577
  sort: _$alepha.TOptional<_$alepha.TString>;
850
578
  userRealm: _$alepha.TOptional<_$alepha.TString>;
851
579
  resourceType: _$alepha.TOptional<_$alepha.TString>;
@@ -857,11 +585,11 @@ declare class AdminAuditController {
857
585
  to: _$alepha.TOptional<_$alepha.TString>;
858
586
  }>;
859
587
  response: _$alepha.TPage<_$alepha.TObject<{
860
- id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
861
- createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
588
+ id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
589
+ createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
862
590
  type: _$alepha.TString;
863
591
  action: _$alepha.TString;
864
- severity: PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof PG_DEFAULT>;
592
+ severity: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof _$alepha_orm0.PG_DEFAULT>;
865
593
  userId: _$alepha.TOptional<_$alepha.TString>;
866
594
  userRealm: _$alepha.TOptional<_$alepha.TString>;
867
595
  userEmail: _$alepha.TOptional<_$alepha.TString>;
@@ -873,7 +601,7 @@ declare class AdminAuditController {
873
601
  userAgent: _$alepha.TOptional<_$alepha.TString>;
874
602
  sessionId: _$alepha.TOptional<_$alepha.TString>;
875
603
  requestId: _$alepha.TOptional<_$alepha.TString>;
876
- success: PgAttr<_$alepha.TBoolean, typeof PG_DEFAULT>;
604
+ success: _$alepha_orm0.PgAttr<_$alepha.TBoolean, typeof _$alepha_orm0.PG_DEFAULT>;
877
605
  errorMessage: _$alepha.TOptional<_$alepha.TString>;
878
606
  }>>;
879
607
  }>;
@@ -887,9 +615,9 @@ declare class AdminAuditController {
887
615
  }>;
888
616
  query: _$alepha.TObject<{
889
617
  type: _$alepha.TOptional<_$alepha.TString>;
890
- search: _$alepha.TOptional<_$alepha.TString>;
891
618
  action: _$alepha.TOptional<_$alepha.TString>;
892
619
  severity: _$alepha.TOptional<_$alepha.TUnsafe<"info" | "warning" | "critical">>;
620
+ search: _$alepha.TOptional<_$alepha.TString>;
893
621
  sort: _$alepha.TOptional<_$alepha.TString>;
894
622
  userId: _$alepha.TOptional<_$alepha.TString>;
895
623
  userRealm: _$alepha.TOptional<_$alepha.TString>;
@@ -900,11 +628,11 @@ declare class AdminAuditController {
900
628
  to: _$alepha.TOptional<_$alepha.TString>;
901
629
  }>;
902
630
  response: _$alepha.TPage<_$alepha.TObject<{
903
- id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
904
- createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
631
+ id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
632
+ createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
905
633
  type: _$alepha.TString;
906
634
  action: _$alepha.TString;
907
- severity: PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof PG_DEFAULT>;
635
+ severity: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof _$alepha_orm0.PG_DEFAULT>;
908
636
  userId: _$alepha.TOptional<_$alepha.TString>;
909
637
  userRealm: _$alepha.TOptional<_$alepha.TString>;
910
638
  userEmail: _$alepha.TOptional<_$alepha.TString>;
@@ -916,7 +644,7 @@ declare class AdminAuditController {
916
644
  userAgent: _$alepha.TOptional<_$alepha.TString>;
917
645
  sessionId: _$alepha.TOptional<_$alepha.TString>;
918
646
  requestId: _$alepha.TOptional<_$alepha.TString>;
919
- success: PgAttr<_$alepha.TBoolean, typeof PG_DEFAULT>;
647
+ success: _$alepha_orm0.PgAttr<_$alepha.TBoolean, typeof _$alepha_orm0.PG_DEFAULT>;
920
648
  errorMessage: _$alepha.TOptional<_$alepha.TString>;
921
649
  }>>;
922
650
  }>;
@@ -939,11 +667,11 @@ declare class AdminAuditController {
939
667
  }>;
940
668
  successRate: _$alepha.TNumber;
941
669
  recentFailures: _$alepha.TArray<_$alepha.TObject<{
942
- id: PgAttr<PgAttr<_$alepha.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
943
- createdAt: PgAttr<PgAttr<_$alepha.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
670
+ id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
671
+ createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
944
672
  type: _$alepha.TString;
945
673
  action: _$alepha.TString;
946
- severity: PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof PG_DEFAULT>;
674
+ severity: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"info" | "warning" | "critical">, typeof _$alepha_orm0.PG_DEFAULT>;
947
675
  userId: _$alepha.TOptional<_$alepha.TString>;
948
676
  userRealm: _$alepha.TOptional<_$alepha.TString>;
949
677
  userEmail: _$alepha.TOptional<_$alepha.TString>;
@@ -955,7 +683,7 @@ declare class AdminAuditController {
955
683
  userAgent: _$alepha.TOptional<_$alepha.TString>;
956
684
  sessionId: _$alepha.TOptional<_$alepha.TString>;
957
685
  requestId: _$alepha.TOptional<_$alepha.TString>;
958
- success: PgAttr<_$alepha.TBoolean, typeof PG_DEFAULT>;
686
+ success: _$alepha_orm0.PgAttr<_$alepha.TBoolean, typeof _$alepha_orm0.PG_DEFAULT>;
959
687
  errorMessage: _$alepha.TOptional<_$alepha.TString>;
960
688
  }>>;
961
689
  }>;
@@ -1096,6 +824,310 @@ declare const $audit: {
1096
824
  [KIND]: typeof AuditPrimitive;
1097
825
  };
1098
826
  //#endregion
827
+ //#region ../../src/orm/core/schemas/insertSchema.d.ts
828
+ /**
829
+ * Transforms a TObject schema for insert operations.
830
+ * All default properties at the root level are made optional.
831
+ * Generated columns are excluded entirely.
832
+ *
833
+ * @example
834
+ * Before: { name: string; age: number(default=0); fullName: generated }
835
+ * After: { name: string; age?: number; }
836
+ */
837
+ type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"] as T["properties"][K] extends {
838
+ [PG_GENERATED]: any;
839
+ } ? never : K]: T["properties"][K] extends {
840
+ [PG_DEFAULT]: any;
841
+ } | {
842
+ "~optional": true;
843
+ } ? TOptional<T["properties"][K]> : T["properties"][K] }>;
844
+ //#endregion
845
+ //#region ../../src/orm/core/schemas/updateSchema.d.ts
846
+ /**
847
+ * Transforms a TObject schema for update operations.
848
+ * All optional properties at the root level are made nullable (i.e., `T | null`).
849
+ * Generated columns are excluded entirely.
850
+ *
851
+ * @example
852
+ * Before: { name?: string; age: number; fullName: generated }
853
+ * After: { name?: string | null; age: number; }
854
+ */
855
+ type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"] as T["properties"][K] extends {
856
+ [PG_GENERATED]: any;
857
+ } ? never : K]: T["properties"][K] extends TOptional<infer U> ? TOptional<TUnion<[U, TNull]>> : T["properties"][K] }>;
858
+ //#endregion
859
+ //#region ../../src/orm/core/primitives/$entity.d.ts
860
+ interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
861
+ /**
862
+ * The database table name that will be created for this entity.
863
+ * If not provided, name will be inferred from the $repository variable name.
864
+ */
865
+ name: string;
866
+ /**
867
+ * TypeBox schema defining the table structure and column types.
868
+ */
869
+ schema: T;
870
+ /**
871
+ * Database indexes to create for query optimization.
872
+ */
873
+ indexes?: (Keys | {
874
+ /**
875
+ * Single column to index.
876
+ */
877
+ column: Keys;
878
+ /**
879
+ * Whether this should be a unique index (enforces uniqueness constraint).
880
+ */
881
+ unique?: boolean;
882
+ /**
883
+ * Custom name for the index. If not provided, generates name automatically.
884
+ */
885
+ name?: string;
886
+ /**
887
+ * Partial index condition. Only rows matching this SQL expression are indexed.
888
+ */
889
+ where?: SQL;
890
+ } | {
891
+ /**
892
+ * Multiple columns for composite index (order matters for query optimization).
893
+ */
894
+ columns: Keys[];
895
+ /**
896
+ * Whether this should be a unique index (enforces uniqueness constraint).
897
+ */
898
+ unique?: boolean;
899
+ /**
900
+ * Custom name for the index. If not provided, generates name automatically.
901
+ */
902
+ name?: string;
903
+ /**
904
+ * Partial index condition. Only rows matching this SQL expression are indexed.
905
+ */
906
+ where?: SQL;
907
+ } | {
908
+ /**
909
+ * SQL expressions for expression-based indexes.
910
+ *
911
+ * Can include column references and SQL functions like `LOWER()`, `UPPER()`, etc.
912
+ * Columns and expressions can be mixed together.
913
+ *
914
+ * @example
915
+ * ```ts
916
+ * // Case-insensitive unique username per realm
917
+ * indexes: [{
918
+ * expressions: (self) => [self.realm, sql`LOWER(${self.username})`],
919
+ * unique: true,
920
+ * name: "users_realm_username_lower_idx",
921
+ * }]
922
+ * ```
923
+ */
924
+ expressions: (self: Record<Keys & string, any>) => (SQL | any)[];
925
+ /**
926
+ * Whether this should be a unique index (enforces uniqueness constraint).
927
+ */
928
+ unique?: boolean;
929
+ /**
930
+ * Custom name for the index. If not provided, generates name automatically.
931
+ */
932
+ name: string;
933
+ /**
934
+ * Partial index condition. Only rows matching this SQL expression are indexed.
935
+ */
936
+ where?: SQL;
937
+ })[];
938
+ /**
939
+ * Foreign key constraints to maintain referential integrity.
940
+ */
941
+ foreignKeys?: Array<{
942
+ /**
943
+ * Optional name for the foreign key constraint.
944
+ */
945
+ name?: string;
946
+ /**
947
+ * Local columns that reference the foreign table.
948
+ */
949
+ columns: Array<keyof Static<T>>;
950
+ /**
951
+ * Referenced columns in the foreign table.
952
+ * Must be EntityColumn references from other entities.
953
+ */
954
+ foreignColumns: Array<() => EntityColumn<any>>;
955
+ }>;
956
+ /**
957
+ * Additional table constraints for data validation.
958
+ *
959
+ * Constraints enforce business rules at the database level, providing
960
+ * an additional layer of data integrity beyond application validation.
961
+ *
962
+ * **Constraint Types**:
963
+ * - **Unique constraints**: Prevent duplicate values across columns
964
+ * - **Check constraints**: Enforce custom validation rules with SQL expressions
965
+ *
966
+ * @example
967
+ * ```ts
968
+ * constraints: [
969
+ * {
970
+ * name: "unique_user_email",
971
+ * columns: ["email"],
972
+ * unique: true
973
+ * },
974
+ * {
975
+ * name: "valid_age_range",
976
+ * columns: ["age"],
977
+ * check: sql`age >= 0 AND age <= 150`
978
+ * },
979
+ * {
980
+ * name: "unique_user_username_per_tenant",
981
+ * columns: ["tenantId", "username"],
982
+ * unique: true
983
+ * }
984
+ * ]
985
+ * ```
986
+ */
987
+ constraints?: Array<{
988
+ /**
989
+ * Columns involved in this constraint.
990
+ */
991
+ columns: Array<keyof Static<T>>;
992
+ /**
993
+ * Optional name for the constraint.
994
+ */
995
+ name?: string;
996
+ /**
997
+ * Whether this is a unique constraint.
998
+ */
999
+ unique?: boolean | {};
1000
+ /**
1001
+ * SQL expression for check constraint validation.
1002
+ */
1003
+ check?: SQL;
1004
+ }>;
1005
+ /**
1006
+ * Advanced Drizzle ORM configuration for complex table setups.
1007
+ */
1008
+ config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
1009
+ }
1010
+ declare class EntityPrimitive<T extends TObject = TObject> {
1011
+ readonly options: EntityPrimitiveOptions<T>;
1012
+ constructor(options: EntityPrimitiveOptions<T>);
1013
+ alias(alias: string): this;
1014
+ get cols(): EntityColumns<T>;
1015
+ get name(): string;
1016
+ get schema(): T;
1017
+ get insertSchema(): TObjectInsert<T>;
1018
+ get updateSchema(): TObjectUpdate<T>;
1019
+ }
1020
+ /**
1021
+ * Convert a schema to columns.
1022
+ */
1023
+ type FromSchema<T extends TObject> = { [key in keyof T["properties"]]: PgColumnBuilderBase };
1024
+ type EntityColumn<T extends TObject> = {
1025
+ name: string;
1026
+ entity: EntityPrimitive<T>;
1027
+ };
1028
+ type EntityColumns<T extends TObject> = { [key in keyof T["properties"]]: EntityColumn<T> };
1029
+ //#endregion
1030
+ //#region ../../src/orm/core/constants/PG_SYMBOLS.d.ts
1031
+ declare const PG_DEFAULT: unique symbol;
1032
+ declare const PG_PRIMARY_KEY: unique symbol;
1033
+ declare const PG_CREATED_AT: unique symbol;
1034
+ declare const PG_UPDATED_AT: unique symbol;
1035
+ declare const PG_DELETED_AT: unique symbol;
1036
+ declare const PG_VERSION: unique symbol;
1037
+ declare const PG_IDENTITY: unique symbol;
1038
+ declare const PG_ENUM: unique symbol;
1039
+ declare const PG_REF: unique symbol;
1040
+ declare const PG_GENERATED: unique symbol;
1041
+ declare const PG_ORGANIZATION: unique symbol;
1042
+ /**
1043
+ * @deprecated Use `PG_IDENTITY` instead.
1044
+ */
1045
+ declare const PG_SERIAL: unique symbol;
1046
+ type PgSymbols = {
1047
+ [PG_DEFAULT]: {};
1048
+ [PG_PRIMARY_KEY]: {};
1049
+ [PG_CREATED_AT]: {};
1050
+ [PG_UPDATED_AT]: {};
1051
+ [PG_DELETED_AT]: {};
1052
+ [PG_VERSION]: {};
1053
+ [PG_IDENTITY]: PgIdentityOptions;
1054
+ [PG_REF]: PgRefOptions;
1055
+ [PG_ENUM]: PgEnumOptions;
1056
+ [PG_GENERATED]: PgGeneratedOptions;
1057
+ [PG_ORGANIZATION]: {};
1058
+ /**
1059
+ * @deprecated Use `PG_IDENTITY` instead.
1060
+ */
1061
+ [PG_SERIAL]: {};
1062
+ };
1063
+ type PgSymbolKeys = keyof PgSymbols;
1064
+ type PgIdentityOptions = {
1065
+ mode: "always" | "byDefault";
1066
+ } & PgSequenceOptions & {
1067
+ name?: string;
1068
+ };
1069
+ interface PgEnumOptions {
1070
+ name?: string;
1071
+ description?: string;
1072
+ }
1073
+ interface PgGeneratedOptions {
1074
+ /**
1075
+ * SQL expression for the generated column.
1076
+ */
1077
+ expression: SQL;
1078
+ /**
1079
+ * Storage mode for the generated column.
1080
+ * - `"stored"` — value is computed on write and stored on disk (default for PostgreSQL).
1081
+ * - `"virtual"` — value is computed on read (default for SQLite).
1082
+ */
1083
+ mode?: "stored" | "virtual";
1084
+ }
1085
+ interface PgRefOptions {
1086
+ ref: () => {
1087
+ name: string;
1088
+ entity: EntityPrimitive;
1089
+ };
1090
+ actions?: {
1091
+ onUpdate?: UpdateDeleteAction;
1092
+ onDelete?: UpdateDeleteAction;
1093
+ };
1094
+ }
1095
+ //#endregion
1096
+ //#region ../../src/orm/core/helpers/pgAttr.d.ts
1097
+ /**
1098
+ * Type representation.
1099
+ */
1100
+ type PgAttr<T extends TSchema, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
1101
+ //#endregion
1102
+ //#region ../../src/orm/core/schemas/databaseEnvSchema.d.ts
1103
+ /**
1104
+ * Base database environment schema.
1105
+ *
1106
+ * Defines the `DATABASE_URL` connection string used by all ORM providers
1107
+ * to determine the database driver and connection target.
1108
+ *
1109
+ * Supported URL formats:
1110
+ * - `sqlite://:memory:` or `sqlite://./path/to/db` — SQLite (Node.js or Bun)
1111
+ * - `postgres://user:password@host:port/database` — PostgreSQL (Node.js or Bun)
1112
+ * - `pglite://:memory:` or `pglite://./path` — PGlite (embedded Postgres)
1113
+ * - `d1://BINDING_NAME` — Cloudflare D1
1114
+ * - `hyperdrive://BINDING_NAME` — Cloudflare Hyperdrive
1115
+ */
1116
+ declare const databaseEnvSchema: _$alepha.TObject<{
1117
+ DATABASE_URL: _$alepha.TOptional<_$alepha.TString>;
1118
+ /**
1119
+ * Enable or disable push-based schema synchronization (drizzle-kit push).
1120
+ *
1121
+ * Defaults to `true` in development and test, `false` in production.
1122
+ * Set to `false` in development to skip automatic schema sync
1123
+ * (e.g. when managing migrations manually).
1124
+ */
1125
+ DATABASE_SYNC: _$alepha.TOptional<_$alepha.TBoolean>;
1126
+ }>;
1127
+ declare module "alepha" {
1128
+ interface Env extends Partial<Static<typeof databaseEnvSchema>> {}
1129
+ } //# sourceMappingURL=databaseEnvSchema.d.ts.map
1130
+ //#endregion
1099
1131
  //#region ../../src/api/audits/schemas/auditResourceSchema.d.ts
1100
1132
  /**
1101
1133
  * Resource schema for audit log responses.