alepha 0.11.9 → 0.11.11

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 (167) hide show
  1. package/README.md +61 -17
  2. package/dist/index.cjs +17089 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +1 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.js +17088 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +42 -365
  9. package/src/assets/biomeJson.ts +33 -0
  10. package/src/assets/tsconfigJson.ts +18 -0
  11. package/src/assets/viteConfigTs.ts +14 -0
  12. package/src/commands/BiomeCommands.ts +41 -0
  13. package/src/commands/CoreCommands.ts +169 -0
  14. package/src/commands/DrizzleCommands.ts +228 -0
  15. package/src/commands/VerifyCommands.ts +44 -0
  16. package/src/commands/ViteCommands.ts +119 -0
  17. package/src/index.ts +35 -0
  18. package/src/services/ProcessRunner.ts +89 -0
  19. package/src/services/ProjectUtils.ts +508 -0
  20. package/src/version.ts +7 -0
  21. package/api/files.cjs +0 -8
  22. package/api/files.d.ts +0 -438
  23. package/api/files.js +0 -1
  24. package/api/jobs.cjs +0 -8
  25. package/api/jobs.d.ts +0 -327
  26. package/api/jobs.js +0 -1
  27. package/api/notifications.cjs +0 -8
  28. package/api/notifications.d.ts +0 -263
  29. package/api/notifications.js +0 -1
  30. package/api/users.cjs +0 -8
  31. package/api/users.d.ts +0 -923
  32. package/api/users.js +0 -1
  33. package/api/verifications.cjs +0 -8
  34. package/api/verifications.d.ts +0 -1
  35. package/api/verifications.js +0 -1
  36. package/batch.cjs +0 -8
  37. package/batch.d.ts +0 -154
  38. package/batch.js +0 -1
  39. package/bucket.cjs +0 -8
  40. package/bucket.d.ts +0 -520
  41. package/bucket.js +0 -1
  42. package/cache/redis.cjs +0 -8
  43. package/cache/redis.d.ts +0 -40
  44. package/cache/redis.js +0 -1
  45. package/cache.cjs +0 -8
  46. package/cache.d.ts +0 -288
  47. package/cache.js +0 -1
  48. package/command.cjs +0 -8
  49. package/command.d.ts +0 -269
  50. package/command.js +0 -1
  51. package/core.cjs +0 -8
  52. package/core.d.ts +0 -1904
  53. package/core.js +0 -1
  54. package/datetime.cjs +0 -8
  55. package/datetime.d.ts +0 -144
  56. package/datetime.js +0 -1
  57. package/devtools.cjs +0 -8
  58. package/devtools.d.ts +0 -252
  59. package/devtools.js +0 -1
  60. package/email.cjs +0 -8
  61. package/email.d.ts +0 -187
  62. package/email.js +0 -1
  63. package/fake.cjs +0 -8
  64. package/fake.d.ts +0 -73
  65. package/fake.js +0 -1
  66. package/file.cjs +0 -8
  67. package/file.d.ts +0 -528
  68. package/file.js +0 -1
  69. package/lock/redis.cjs +0 -8
  70. package/lock/redis.d.ts +0 -24
  71. package/lock/redis.js +0 -1
  72. package/lock.cjs +0 -8
  73. package/lock.d.ts +0 -552
  74. package/lock.js +0 -1
  75. package/logger.cjs +0 -8
  76. package/logger.d.ts +0 -287
  77. package/logger.js +0 -1
  78. package/postgres.cjs +0 -8
  79. package/postgres.d.ts +0 -2143
  80. package/postgres.js +0 -1
  81. package/queue/redis.cjs +0 -8
  82. package/queue/redis.d.ts +0 -29
  83. package/queue/redis.js +0 -1
  84. package/queue.cjs +0 -8
  85. package/queue.d.ts +0 -760
  86. package/queue.js +0 -1
  87. package/react/auth.cjs +0 -8
  88. package/react/auth.d.ts +0 -504
  89. package/react/auth.js +0 -1
  90. package/react/form.cjs +0 -8
  91. package/react/form.d.ts +0 -211
  92. package/react/form.js +0 -1
  93. package/react/head.cjs +0 -8
  94. package/react/head.d.ts +0 -120
  95. package/react/head.js +0 -1
  96. package/react/i18n.cjs +0 -8
  97. package/react/i18n.d.ts +0 -168
  98. package/react/i18n.js +0 -1
  99. package/react.cjs +0 -8
  100. package/react.d.ts +0 -1263
  101. package/react.js +0 -1
  102. package/redis.cjs +0 -8
  103. package/redis.d.ts +0 -82
  104. package/redis.js +0 -1
  105. package/retry.cjs +0 -8
  106. package/retry.d.ts +0 -162
  107. package/retry.js +0 -1
  108. package/router.cjs +0 -8
  109. package/router.d.ts +0 -45
  110. package/router.js +0 -1
  111. package/scheduler.cjs +0 -8
  112. package/scheduler.d.ts +0 -145
  113. package/scheduler.js +0 -1
  114. package/security.cjs +0 -8
  115. package/security.d.ts +0 -586
  116. package/security.js +0 -1
  117. package/server/cache.cjs +0 -8
  118. package/server/cache.d.ts +0 -163
  119. package/server/cache.js +0 -1
  120. package/server/compress.cjs +0 -8
  121. package/server/compress.d.ts +0 -38
  122. package/server/compress.js +0 -1
  123. package/server/cookies.cjs +0 -8
  124. package/server/cookies.d.ts +0 -144
  125. package/server/cookies.js +0 -1
  126. package/server/cors.cjs +0 -8
  127. package/server/cors.d.ts +0 -45
  128. package/server/cors.js +0 -1
  129. package/server/health.cjs +0 -8
  130. package/server/health.d.ts +0 -58
  131. package/server/health.js +0 -1
  132. package/server/helmet.cjs +0 -8
  133. package/server/helmet.d.ts +0 -98
  134. package/server/helmet.js +0 -1
  135. package/server/links.cjs +0 -8
  136. package/server/links.d.ts +0 -322
  137. package/server/links.js +0 -1
  138. package/server/metrics.cjs +0 -8
  139. package/server/metrics.d.ts +0 -35
  140. package/server/metrics.js +0 -1
  141. package/server/multipart.cjs +0 -8
  142. package/server/multipart.d.ts +0 -42
  143. package/server/multipart.js +0 -1
  144. package/server/proxy.cjs +0 -8
  145. package/server/proxy.d.ts +0 -234
  146. package/server/proxy.js +0 -1
  147. package/server/security.cjs +0 -8
  148. package/server/security.d.ts +0 -92
  149. package/server/security.js +0 -1
  150. package/server/static.cjs +0 -8
  151. package/server/static.d.ts +0 -119
  152. package/server/static.js +0 -1
  153. package/server/swagger.cjs +0 -8
  154. package/server/swagger.d.ts +0 -161
  155. package/server/swagger.js +0 -1
  156. package/server.cjs +0 -8
  157. package/server.d.ts +0 -849
  158. package/server.js +0 -1
  159. package/topic/redis.cjs +0 -8
  160. package/topic/redis.d.ts +0 -42
  161. package/topic/redis.js +0 -1
  162. package/topic.cjs +0 -8
  163. package/topic.d.ts +0 -819
  164. package/topic.js +0 -1
  165. package/vite.cjs +0 -8
  166. package/vite.d.ts +0 -186
  167. package/vite.js +0 -1
package/postgres.d.ts DELETED
@@ -1,2143 +0,0 @@
1
- import * as _alepha_core10 from "alepha";
2
- import { Alepha, AlephaError, Descriptor, KIND, Page, Page as Page$1, PageQuery, PageQuery as PageQuery$1, Service, Static, StaticEncode, TBigInt, TInteger, TNull, TNumber, TNumberOptions, TObject, TObjectOptions, TOptional, TPage, TSchema, TString, TStringOptions, TUnion, TUnsafe, pageQuerySchema, pageSchema } from "alepha";
3
- import { DateTime, DateTimeProvider } from "alepha/datetime";
4
- import * as drizzle_orm0 from "drizzle-orm";
5
- import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, sql } from "drizzle-orm";
6
- import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
7
- import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSchema, PgSelectBase, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, UpdateDeleteAction } from "drizzle-orm/pg-core";
8
- import * as _alepha_logger0 from "alepha/logger";
9
- import * as _alepha_lock0 from "alepha/lock";
10
- import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
11
- import postgres from "postgres";
12
- import * as pg$1 from "drizzle-orm/sqlite-core";
13
- import { SQLiteColumnBuilderBase } from "drizzle-orm/sqlite-core";
14
- import * as _alepha_retry0 from "alepha/retry";
15
- import { DatabaseSync } from "node:sqlite";
16
- import { PgTransactionConfig } from "drizzle-orm/pg-core/session";
17
- import * as typebox2 from "typebox";
18
- import * as DrizzleKit from "drizzle-kit/api";
19
- import { UpdateDeleteAction as UpdateDeleteAction$1 } from "drizzle-orm/pg-core/foreign-keys";
20
- export * from "drizzle-orm/pg-core";
21
-
22
- //#region src/schemas/insertSchema.d.ts
23
- /**
24
- * Transforms a TObject schema for insert operations.
25
- * All default properties at the root level are made optional.
26
- *
27
- * @example
28
- * Before: { name: string; age: number(default=0); }
29
- * After: { name: string; age?: number; }
30
- */
31
- type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"]]: T["properties"][K] extends {
32
- [PG_DEFAULT]: any;
33
- } | {
34
- "~optional": true;
35
- } ? TOptional<T["properties"][K]> : T["properties"][K] }>;
36
- declare const insertSchema: <T extends TObject>(obj: T) => TObjectInsert<T>;
37
- //#endregion
38
- //#region src/schemas/updateSchema.d.ts
39
- /**
40
- * Transforms a TObject schema for update operations.
41
- * All optional properties at the root level are made nullable (i.e., `T | null`).
42
- * This allows an API endpoint to explicitly accept `null` to clear an optional field in the database.
43
- *
44
- * @example
45
- * Before: { name?: string; age: number; }
46
- * After: { name?: string | null; age: number; }
47
- */
48
- type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"]]: T["properties"][K] extends TOptional<infer U> ? TOptional<TUnion<[U, TNull]>> : T["properties"][K] }>;
49
- declare const updateSchema: <T extends TObject>(schema: T) => TObjectUpdate<T>;
50
- //#endregion
51
- //#region src/descriptors/$entity.d.ts
52
- /**
53
- * Creates a database entity descriptor that defines table structure using TypeBox schemas.
54
- *
55
- * @example
56
- * ```ts
57
- * import { t } from "alepha";
58
- * import { $entity } from "alepha/postgres";
59
- *
60
- * const userEntity = $entity({
61
- * name: "users",
62
- * schema: t.object({
63
- * id: pg.primaryKey(),
64
- * name: t.text(),
65
- * email: t.email(),
66
- * }),
67
- * });
68
- * ```
69
- */
70
- declare const $entity: {
71
- <TSchema$1 extends TObject>(options: EntityDescriptorOptions<TSchema$1>): EntityDescriptor<TSchema$1>;
72
- [KIND]: typeof EntityDescriptor;
73
- };
74
- interface EntityDescriptorOptions<T extends TObject, Keys = keyof Static<T>> {
75
- /**
76
- * The database table name that will be created for this entity.
77
- * If not provided, name will be inferred from the $repository variable name.
78
- */
79
- name: string;
80
- /**
81
- * TypeBox schema defining the table structure and column types.
82
- */
83
- schema: T;
84
- /**
85
- * Database indexes to create for query optimization.
86
- */
87
- indexes?: (Keys | {
88
- /**
89
- * Single column to index.
90
- */
91
- column: Keys;
92
- /**
93
- * Whether this should be a unique index (enforces uniqueness constraint).
94
- */
95
- unique?: boolean;
96
- /**
97
- * Custom name for the index. If not provided, generates name automatically.
98
- */
99
- name?: string;
100
- } | {
101
- /**
102
- * Multiple columns for composite index (order matters for query optimization).
103
- */
104
- columns: Keys[];
105
- /**
106
- * Whether this should be a unique index (enforces uniqueness constraint).
107
- */
108
- unique?: boolean;
109
- /**
110
- * Custom name for the index. If not provided, generates name automatically.
111
- */
112
- name?: string;
113
- })[];
114
- /**
115
- * Foreign key constraints to maintain referential integrity.
116
- */
117
- foreignKeys?: Array<{
118
- /**
119
- * Optional name for the foreign key constraint.
120
- */
121
- name?: string;
122
- /**
123
- * Local columns that reference the foreign table.
124
- */
125
- columns: Array<keyof Static<T>>;
126
- /**
127
- * Referenced columns in the foreign table.
128
- * Must be EntityColumn references from other entities.
129
- */
130
- foreignColumns: Array<() => EntityColumn<any>>;
131
- }>;
132
- /**
133
- * Additional table constraints for data validation.
134
- *
135
- * Constraints enforce business rules at the database level, providing
136
- * an additional layer of data integrity beyond application validation.
137
- *
138
- * **Constraint Types**:
139
- * - **Unique constraints**: Prevent duplicate values across columns
140
- * - **Check constraints**: Enforce custom validation rules with SQL expressions
141
- *
142
- * @example
143
- * ```ts
144
- * constraints: [
145
- * {
146
- * name: "unique_user_email",
147
- * columns: ["email"],
148
- * unique: true
149
- * },
150
- * {
151
- * name: "valid_age_range",
152
- * columns: ["age"],
153
- * check: sql`age >= 0 AND age <= 150`
154
- * },
155
- * {
156
- * name: "unique_user_username_per_tenant",
157
- * columns: ["tenantId", "username"],
158
- * unique: true
159
- * }
160
- * ]
161
- * ```
162
- */
163
- constraints?: Array<{
164
- /**
165
- * Columns involved in this constraint.
166
- */
167
- columns: Array<keyof Static<T>>;
168
- /**
169
- * Optional name for the constraint.
170
- */
171
- name?: string;
172
- /**
173
- * Whether this is a unique constraint.
174
- */
175
- unique?: boolean | {};
176
- /**
177
- * SQL expression for check constraint validation.
178
- */
179
- check?: SQL;
180
- }>;
181
- /**
182
- * Advanced Drizzle ORM configuration for complex table setups.
183
- */
184
- config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
185
- }
186
- declare class EntityDescriptor<T extends TObject = TObject> {
187
- readonly options: EntityDescriptorOptions<T>;
188
- constructor(options: EntityDescriptorOptions<T>);
189
- alias(alias: string): this;
190
- get cols(): EntityColumns<T>;
191
- get name(): string;
192
- get schema(): T;
193
- get insertSchema(): TObjectInsert<T>;
194
- get updateSchema(): TObjectUpdate<T>;
195
- }
196
- /**
197
- * Convert a schema to columns.
198
- */
199
- type FromSchema<T extends TObject> = { [key in keyof T["properties"]]: PgColumnBuilderBase };
200
- type SchemaToTableConfig<T extends TObject> = {
201
- name: string;
202
- schema: string | undefined;
203
- columns: { [key in keyof T["properties"]]: PgColumn };
204
- dialect: string;
205
- };
206
- type EntityColumn<T extends TObject> = {
207
- name: string;
208
- entity: EntityDescriptor<T>;
209
- };
210
- type EntityColumns<T extends TObject> = { [key in keyof T["properties"]]: EntityColumn<T> };
211
- //#endregion
212
- //#region src/constants/PG_SYMBOLS.d.ts
213
- declare const PG_DEFAULT: unique symbol;
214
- declare const PG_PRIMARY_KEY: unique symbol;
215
- declare const PG_CREATED_AT: unique symbol;
216
- declare const PG_UPDATED_AT: unique symbol;
217
- declare const PG_DELETED_AT: unique symbol;
218
- declare const PG_VERSION: unique symbol;
219
- declare const PG_IDENTITY: unique symbol;
220
- declare const PG_ENUM: unique symbol;
221
- declare const PG_REF: unique symbol;
222
- /**
223
- * @deprecated Use `PG_IDENTITY` instead.
224
- */
225
- declare const PG_SERIAL: unique symbol;
226
- type PgDefault = typeof PG_DEFAULT;
227
- type PgRef = typeof PG_REF;
228
- type PgPrimaryKey = typeof PG_PRIMARY_KEY;
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
- /**
240
- * @deprecated Use `PG_IDENTITY` instead.
241
- */
242
- [PG_SERIAL]: {};
243
- };
244
- type PgSymbolKeys = keyof PgSymbols;
245
- type PgIdentityOptions = {
246
- mode: "always" | "byDefault";
247
- } & PgSequenceOptions & {
248
- name?: string;
249
- };
250
- interface PgEnumOptions {
251
- name?: string;
252
- }
253
- interface PgRefOptions {
254
- ref: () => {
255
- name: string;
256
- entity: EntityDescriptor;
257
- };
258
- actions?: {
259
- onUpdate?: UpdateDeleteAction;
260
- onDelete?: UpdateDeleteAction;
261
- };
262
- }
263
- //#endregion
264
- //#region src/errors/DbError.d.ts
265
- declare class DbError extends AlephaError {
266
- name: string;
267
- constructor(message: string, cause?: unknown);
268
- }
269
- //#endregion
270
- //#region src/helpers/pgAttr.d.ts
271
- /**
272
- * Decorates a typebox schema with a Postgres attribute.
273
- *
274
- * > It's just a fancy way to add Symbols to a field.
275
- *
276
- * @example
277
- * ```ts
278
- * import { t } from "alepha";
279
- * import { PG_UPDATED_AT } from "../constants/PG_SYMBOLS";
280
- *
281
- * export const updatedAtSchema = pgAttr(
282
- * t.datetime(), PG_UPDATED_AT,
283
- * );
284
- * ```
285
- */
286
- declare const pgAttr: <T extends TSchema, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
287
- /**
288
- * Retrieves the fields of a schema that have a specific attribute.
289
- */
290
- declare const getAttrFields: (schema: TObject, name: PgSymbolKeys) => PgAttrField[];
291
- /**
292
- * Type representation.
293
- */
294
- type PgAttr<T extends TSchema, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
295
- interface PgAttrField {
296
- key: string;
297
- type: TSchema;
298
- data: any;
299
- nested?: any[];
300
- one?: boolean;
301
- }
302
- //#endregion
303
- //#region src/interfaces/FilterOperators.d.ts
304
- interface FilterOperators<TValue> {
305
- /**
306
- * Test that two values are 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 null, you may want to use
311
- * `isNull` instead.
312
- *
313
- * ## Examples
314
- *
315
- * ```ts
316
- * // Select cars made by Ford
317
- * db.select().from(cars)
318
- * .where(eq(cars.make, 'Ford'))
319
- * ```
320
- *
321
- * @see isNull for a way to test equality to NULL.
322
- */
323
- eq?: TValue;
324
- /**
325
- * Test that two values are not equal.
326
- *
327
- * Remember that the SQL standard dictates that
328
- * two NULL values are not equal, so if you want to test
329
- * whether a value is not null, you may want to use
330
- * `isNotNull` instead.
331
- *
332
- * ## Examples
333
- *
334
- * ```ts
335
- * // Select cars not made by Ford
336
- * db.select().from(cars)
337
- * .where(ne(cars.make, 'Ford'))
338
- * ```
339
- *
340
- * @see isNotNull for a way to test whether a value is not null.
341
- */
342
- ne?: TValue;
343
- /**
344
- * Test that the first expression passed is greater than
345
- * the second expression.
346
- *
347
- * ## Examples
348
- *
349
- * ```ts
350
- * // Select cars made after 2000.
351
- * db.select().from(cars)
352
- * .where(gt(cars.year, 2000))
353
- * ```
354
- *
355
- * @see gte for greater-than-or-equal
356
- */
357
- gt?: TValue;
358
- /**
359
- * Test that the first expression passed is greater than
360
- * or equal to the second expression. Use `gt` to
361
- * test whether an expression is strictly greater
362
- * than another.
363
- *
364
- * ## Examples
365
- *
366
- * ```ts
367
- * // Select cars made on or after 2000.
368
- * db.select().from(cars)
369
- * .where(gte(cars.year, 2000))
370
- * ```
371
- *
372
- * @see gt for a strictly greater-than condition
373
- */
374
- gte?: TValue;
375
- /**
376
- * Test that the first expression passed is less than
377
- * the second expression.
378
- *
379
- * ## Examples
380
- *
381
- * ```ts
382
- * // Select cars made before 2000.
383
- * db.select().from(cars)
384
- * .where(lt(cars.year, 2000))
385
- * ```
386
- *
387
- * @see lte for greater-than-or-equal
388
- */
389
- lt?: TValue;
390
- /**
391
- * Test that the first expression passed is less than
392
- * or equal to the second expression.
393
- *
394
- * ## Examples
395
- *
396
- * ```ts
397
- * // Select cars made before 2000.
398
- * db.select().from(cars)
399
- * .where(lte(cars.year, 2000))
400
- * ```
401
- *
402
- * @see lt for a strictly less-than condition
403
- */
404
- lte?: TValue;
405
- /**
406
- * Test whether the first parameter, a column or expression,
407
- * has a value from a list passed as the second argument.
408
- *
409
- * ## Throws
410
- *
411
- * The argument passed in the second array can't be empty:
412
- * if an empty is provided, this method will throw.
413
- *
414
- * ## Examples
415
- *
416
- * ```ts
417
- * // Select cars made by Ford or GM.
418
- * db.select().from(cars)
419
- * .where(inArray(cars.make, ['Ford', 'GM']))
420
- * ```
421
- *
422
- * @see notInArray for the inverse of this test
423
- */
424
- inArray?: TValue[];
425
- /**
426
- * Test whether the first parameter, a column or expression,
427
- * has a value that is not present in a list passed as the
428
- * second argument.
429
- *
430
- * ## Throws
431
- *
432
- * The argument passed in the second array can't be empty:
433
- * if an empty is provided, this method will throw.
434
- *
435
- * ## Examples
436
- *
437
- * ```ts
438
- * // Select cars made by any company except Ford or GM.
439
- * db.select().from(cars)
440
- * .where(notInArray(cars.make, ['Ford', 'GM']))
441
- * ```
442
- *
443
- * @see inArray for the inverse of this test
444
- */
445
- notInArray?: TValue[];
446
- /**
447
- * Test whether an expression is not NULL. By the SQL standard,
448
- * NULL is neither equal nor not equal to itself, so
449
- * it's recommended to use `isNull` and `notIsNull` for
450
- * comparisons to NULL.
451
- *
452
- * ## Examples
453
- *
454
- * ```ts
455
- * // Select cars that have been discontinued.
456
- * db.select().from(cars)
457
- * .where(isNotNull(cars.discontinuedAt))
458
- * ```
459
- *
460
- * @see isNull for the inverse of this test
461
- */
462
- isNotNull?: true;
463
- /**
464
- * Test whether an expression is NULL. By the SQL standard,
465
- * NULL is neither equal nor not equal to itself, so
466
- * it's recommended to use `isNull` and `notIsNull` for
467
- * comparisons to NULL.
468
- *
469
- * ## Examples
470
- *
471
- * ```ts
472
- * // Select cars that have no discontinuedAt date.
473
- * db.select().from(cars)
474
- * .where(isNull(cars.discontinuedAt))
475
- * ```
476
- *
477
- * @see isNotNull for the inverse of this test
478
- */
479
- isNull?: true;
480
- /**
481
- * Test whether an expression is between two values. This
482
- * is an easier way to express range tests, which would be
483
- * expressed mathematically as `x <= a <= y` but in SQL
484
- * would have to be like `a >= x AND a <= y`.
485
- *
486
- * Between is inclusive of the endpoints: if `column`
487
- * is equal to `min` or `max`, it will be TRUE.
488
- *
489
- * ## Examples
490
- *
491
- * ```ts
492
- * // Select cars made between 1990 and 2000
493
- * db.select().from(cars)
494
- * .where(between(cars.year, 1990, 2000))
495
- * ```
496
- *
497
- * @see notBetween for the inverse of this test
498
- */
499
- between?: [number, number];
500
- /**
501
- * Test whether an expression is not between two values.
502
- *
503
- * This, like `between`, includes its endpoints, so if
504
- * the `column` is equal to `min` or `max`, in this case
505
- * it will evaluate to FALSE.
506
- *
507
- * ## Examples
508
- *
509
- * ```ts
510
- * // Exclude cars made in the 1970s
511
- * db.select().from(cars)
512
- * .where(notBetween(cars.year, 1970, 1979))
513
- * ```
514
- *
515
- * @see between for the inverse of this test
516
- */
517
- notBetween?: [number, number];
518
- /**
519
- * Compare a column to a pattern, which can include `%` and `_`
520
- * characters to match multiple variations. Including `%`
521
- * in the pattern matches zero or more characters, and including
522
- * `_` will match a single character.
523
- *
524
- * ## Examples
525
- *
526
- * ```ts
527
- * // Select all cars with 'Turbo' in their names.
528
- * db.select().from(cars)
529
- * .where(like(cars.name, '%Turbo%'))
530
- * ```
531
- *
532
- * @see ilike for a case-insensitive version of this condition
533
- */
534
- like?: string;
535
- /**
536
- * The inverse of like - this tests that a given column
537
- * does not match a pattern, 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
- * ## Examples
543
- *
544
- * ```ts
545
- * // Select all cars that don't have "ROver" in their name.
546
- * db.select().from(cars)
547
- * .where(notLike(cars.name, '%Rover%'))
548
- * ```
549
- *
550
- * @see like for the inverse condition
551
- * @see notIlike for a case-insensitive version of this condition
552
- */
553
- notLike?: string;
554
- /**
555
- * Case-insensitively compare a column to a pattern,
556
- * which can include `%` and `_`
557
- * characters to match multiple variations. Including `%`
558
- * in the pattern matches zero or more characters, and including
559
- * `_` will match a single character.
560
- *
561
- * Unlike like, this performs a case-insensitive comparison.
562
- *
563
- * ## Examples
564
- *
565
- * ```ts
566
- * // Select all cars with 'Turbo' in their names.
567
- * db.select().from(cars)
568
- * .where(ilike(cars.name, '%Turbo%'))
569
- * ```
570
- *
571
- * @see like for a case-sensitive version of this condition
572
- */
573
- ilike?: string;
574
- /**
575
- * The inverse of ilike - this case-insensitively tests that a given column
576
- * does not match a pattern, which can include `%` and `_`
577
- * characters to match multiple variations. Including `%`
578
- * in the pattern matches zero or more characters, and including
579
- * `_` will match a single character.
580
- *
581
- * ## Examples
582
- *
583
- * ```ts
584
- * // Select all cars that don't have "Rover" in their name.
585
- * db.select().from(cars)
586
- * .where(notLike(cars.name, '%Rover%'))
587
- * ```
588
- *
589
- * @see ilike for the inverse condition
590
- * @see notLike for a case-sensitive version of this condition
591
- */
592
- notIlike?: string;
593
- /**
594
- * Test that a column or expression contains all elements of
595
- * the list passed as the second argument.
596
- *
597
- * ## Throws
598
- *
599
- * The argument passed in the second array can't be empty:
600
- * if an empty is provided, this method will throw.
601
- *
602
- * ## Examples
603
- *
604
- * ```ts
605
- * // Select posts where its tags contain "Typescript" and "ORM".
606
- * db.select().from(posts)
607
- * .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
608
- * ```
609
- *
610
- * @see arrayContained to find if an array contains all elements of a column or expression
611
- * @see arrayOverlaps to find if a column or expression contains any elements of an array
612
- */
613
- arrayContains?: TValue;
614
- /**
615
- * Test that the list passed as the second argument contains
616
- * all elements of a column or expression.
617
- *
618
- * ## Throws
619
- *
620
- * The argument passed in the second array can't be empty:
621
- * if an empty is provided, this method will throw.
622
- *
623
- * ## Examples
624
- *
625
- * ```ts
626
- * // Select posts where its tags contain "Typescript", "ORM" or both,
627
- * // but filtering posts that have additional tags.
628
- * db.select().from(posts)
629
- * .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
630
- * ```
631
- *
632
- * @see arrayContains to find if a column or expression contains all elements of an array
633
- * @see arrayOverlaps to find if a column or expression contains any elements of an array
634
- */
635
- arrayContained?: TValue;
636
- /**
637
- * Test that a column or expression contains any elements of
638
- * the list passed as the second argument.
639
- *
640
- * ## Throws
641
- *
642
- * The argument passed in the second array can't be empty:
643
- * if an empty is provided, this method will throw.
644
- *
645
- * ## Examples
646
- *
647
- * ```ts
648
- * // Select posts where its tags contain "Typescript", "ORM" or both.
649
- * db.select().from(posts)
650
- * .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
651
- * ```
652
- *
653
- * @see arrayContains to find if a column or expression contains all elements of an array
654
- * @see arrayContained to find if an array contains all elements of a column or expression
655
- */
656
- arrayOverlaps?: TValue;
657
- }
658
- //#endregion
659
- //#region src/interfaces/PgQueryWhere.d.ts
660
- type PgQueryWhere<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = (PgQueryWhereOperators<T> & PgQueryWhereConditions<T>) | (PgQueryWhereRelations<Relations> & PgQueryWhereOperators<T> & PgQueryWhereConditions<T, Relations>);
661
- type PgQueryWhereOrSQL<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = SQLWrapper | PgQueryWhere<T, Relations>;
662
- type PgQueryWhereOperators<T extends TObject> = { [Key in keyof Static<T>]?: FilterOperators<Static<T>[Key]> | Static<T>[Key] | (Static<T>[Key] extends object ? NestedJsonbQuery<Static<T>[Key]> : never) };
663
- type PgQueryWhereConditions<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = {
664
- /**
665
- * Combine a list of conditions with the `and` operator. Conditions
666
- * that are equal `undefined` are automatically ignored.
667
- *
668
- * ## Examples
669
- *
670
- * ```ts
671
- * db.select().from(cars)
672
- * .where(
673
- * and(
674
- * eq(cars.make, 'Volvo'),
675
- * eq(cars.year, 1950),
676
- * )
677
- * )
678
- * ```
679
- */
680
- and?: Array<PgQueryWhereOrSQL<T, Relations>>;
681
- /**
682
- * Combine a list of conditions with the `or` operator. Conditions
683
- * that are equal `undefined` are automatically ignored.
684
- *
685
- * ## Examples
686
- *
687
- * ```ts
688
- * db.select().from(cars)
689
- * .where(
690
- * or(
691
- * eq(cars.make, 'GM'),
692
- * eq(cars.make, 'Ford'),
693
- * )
694
- * )
695
- * ```
696
- */
697
- or?: Array<PgQueryWhereOrSQL<T, Relations>>;
698
- /**
699
- * Negate the meaning of an expression using the `not` keyword.
700
- *
701
- * ## Examples
702
- *
703
- * ```ts
704
- * // Select cars _not_ made by GM or Ford.
705
- * db.select().from(cars)
706
- * .where(not(inArray(cars.make, ['GM', 'Ford'])))
707
- * ```
708
- */
709
- not?: PgQueryWhereOrSQL<T, Relations>;
710
- /**
711
- * Test whether a subquery evaluates to have any rows.
712
- *
713
- * ## Examples
714
- *
715
- * ```ts
716
- * // Users whose `homeCity` column has a match in a cities
717
- * // table.
718
- * db
719
- * .select()
720
- * .from(users)
721
- * .where(
722
- * exists(db.select()
723
- * .from(cities)
724
- * .where(eq(users.homeCity, cities.id))),
725
- * );
726
- * ```
727
- *
728
- * @see notExists for the inverse of this test
729
- */
730
- exists?: SQLWrapper;
731
- };
732
- type PgQueryWhereRelations<Relations extends PgRelationMap<TObject> | undefined = undefined> = Relations extends PgRelationMap<TObject> ? { [K in keyof Relations]?: PgQueryWhere<Relations[K]["join"]["schema"], Relations[K]["with"]> } : {};
733
- /**
734
- * Recursively allow nested queries for JSONB object/array types
735
- */
736
- type NestedJsonbQuery<T> = T extends object ? T extends Array<infer U> ? U extends object ? { [K in keyof U]?: FilterOperators<U[K]> | U[K] } : FilterOperators<U> | U : { [K in keyof T]?: FilterOperators<T[K]> | T[K] | (T[K] extends object ? NestedJsonbQuery<T[K]> : never) } : FilterOperators<T> | T;
737
- //#endregion
738
- //#region src/interfaces/PgQuery.d.ts
739
- /**
740
- * Order direction for sorting
741
- */
742
- type OrderDirection = "asc" | "desc";
743
- /**
744
- * Single order by clause with column and direction
745
- */
746
- interface OrderByClause<T> {
747
- column: keyof T;
748
- direction?: OrderDirection;
749
- }
750
- /**
751
- * Order by parameter - supports 3 modes:
752
- * 1. String: orderBy: "name" (defaults to ASC)
753
- * 2. Single object: orderBy: { column: "name", direction: "desc" }
754
- * 3. Array: orderBy: [{ column: "name", direction: "asc" }, { column: "age", direction: "desc" }]
755
- */
756
- type OrderBy<T> = keyof T | OrderByClause<T> | Array<OrderByClause<T>>;
757
- /**
758
- * Generic query interface for PostgreSQL entities
759
- */
760
- interface PgQuery<T extends TObject = TObject> {
761
- distinct?: (keyof Static<T>)[];
762
- columns?: (keyof Static<T>)[];
763
- where?: PgQueryWhereOrSQL<T>;
764
- limit?: number;
765
- offset?: number;
766
- orderBy?: OrderBy<Static<T>>;
767
- groupBy?: (keyof Static<T>)[];
768
- }
769
- type PgStatic<T extends TObject, Relations extends PgRelationMap<T>> = Static<T> & { [K in keyof Relations]: Static<Relations[K]["join"]["schema"]> & (Relations[K]["with"] extends PgRelationMap<TObject> ? PgStatic<Relations[K]["join"]["schema"], Relations[K]["with"]> : {}) };
770
- interface PgQueryRelations<T extends TObject = TObject, Relations extends PgRelationMap<T> | undefined = undefined> extends PgQuery<T> {
771
- with?: Relations;
772
- where?: PgQueryWhereOrSQL<T, Relations>;
773
- }
774
- type PgRelationMap<Base extends TObject> = Record<string, PgRelation<Base>>;
775
- type PgRelation<Base extends TObject> = {
776
- type?: "left" | "inner" | "right";
777
- join: {
778
- schema: TObject;
779
- name: string;
780
- };
781
- on: SQLWrapper | [keyof Static<Base>, {
782
- name: string;
783
- }];
784
- with?: PgRelationMap<TObject>;
785
- };
786
- //#endregion
787
- //#region src/descriptors/$sequence.d.ts
788
- /**
789
- * Creates a PostgreSQL sequence descriptor for generating unique numeric values.
790
- */
791
- declare const $sequence: {
792
- (options?: SequenceDescriptorOptions): SequenceDescriptor;
793
- [KIND]: typeof SequenceDescriptor;
794
- };
795
- interface SequenceDescriptorOptions extends PgSequenceOptions {
796
- /**
797
- * The name of the sequence. If not provided, the property key will be used.
798
- */
799
- name?: string;
800
- provider?: DatabaseProvider;
801
- }
802
- declare class SequenceDescriptor extends Descriptor<SequenceDescriptorOptions> {
803
- readonly provider: DatabaseProvider;
804
- onInit(): void;
805
- get name(): string;
806
- next(): Promise<number>;
807
- current(): Promise<number>;
808
- protected $provider(): DatabaseProvider;
809
- }
810
- //#endregion
811
- //#region src/services/ModelBuilder.d.ts
812
- /**
813
- * Database-specific table configuration functions
814
- */
815
- interface TableConfigBuilders<TConfig> {
816
- index: (name: string) => {
817
- on: (...columns: any[]) => TConfig;
818
- };
819
- uniqueIndex: (name: string) => {
820
- on: (...columns: any[]) => TConfig;
821
- };
822
- unique: (name: string) => {
823
- on: (...columns: any[]) => TConfig;
824
- };
825
- check: (name: string, sql: SQL) => TConfig;
826
- foreignKey: (config: {
827
- name: string;
828
- columns: any[];
829
- foreignColumns: any[];
830
- }) => TConfig;
831
- }
832
- /**
833
- * Abstract base class for transforming Alepha Descriptors (Entity, Sequence, etc...)
834
- * into drizzle models (tables, enums, sequences, etc...).
835
- */
836
- declare abstract class ModelBuilder {
837
- /**
838
- * Build a table from an entity descriptor.
839
- */
840
- abstract buildTable(entity: EntityDescriptor, options: {
841
- tables: Map<string, unknown>;
842
- enums: Map<string, unknown>;
843
- schema: string;
844
- }): void;
845
- /**
846
- * Build a sequence from a sequence descriptor.
847
- */
848
- abstract buildSequence(sequence: SequenceDescriptor, options: {
849
- sequences: Map<string, unknown>;
850
- schema: string;
851
- }): void;
852
- /**
853
- * Convert camelCase to snake_case for column names.
854
- */
855
- protected toColumnName(str: string): string;
856
- /**
857
- * Build the table configuration function for any database.
858
- * This includes indexes, foreign keys, constraints, and custom config.
859
- *
860
- * @param entity - The entity descriptor
861
- * @param builders - Database-specific builder functions
862
- * @param tableResolver - Function to resolve entity references to table columns
863
- * @param customConfigHandler - Optional handler for custom config
864
- */
865
- protected buildTableConfig<TConfig, TSelf>(entity: EntityDescriptor, builders: TableConfigBuilders<TConfig>, tableResolver?: (entityName: string) => any, customConfigHandler?: (config: any, self: TSelf) => TConfig[]): ((self: TSelf) => TConfig[]) | undefined;
866
- }
867
- //#endregion
868
- //#region src/providers/DrizzleKitProvider.d.ts
869
- declare class DrizzleKitProvider {
870
- protected readonly log: _alepha_logger0.Logger;
871
- protected readonly alepha: Alepha;
872
- /**
873
- * Synchronize database with current schema definitions.
874
- *
875
- * In development mode, it will generate and execute migrations based on the current state.
876
- * In testing mode, it will generate migrations from scratch without applying them.
877
- *
878
- * Does nothing in production mode, you must handle migrations manually.
879
- */
880
- synchronize(provider: DatabaseProvider): Promise<void>;
881
- /**
882
- * Mostly used for testing purposes. You can generate SQL migration statements without executing them.
883
- */
884
- generateMigration(provider: DatabaseProvider, prevSnapshot?: any): Promise<{
885
- statements: string[];
886
- models: Record<string, unknown>;
887
- snapshot?: any;
888
- }>;
889
- /**
890
- * Load all tables, enums, sequences, etc. from the provider's repositories.
891
- */
892
- getModels(provider: DatabaseProvider): Record<string, unknown>;
893
- /**
894
- * Load the migration snapshot from the database.
895
- */
896
- protected loadDevMigrations(provider: DatabaseProvider): Promise<DevMigrations | undefined>;
897
- protected saveDevMigrations(provider: DatabaseProvider, curr: Record<string, any>, devMigrations?: DevMigrations): Promise<void>;
898
- protected executeStatements(statements: string[], provider: DatabaseProvider, catchErrors?: boolean): Promise<void>;
899
- protected createSchemaIfNotExists(provider: DatabaseProvider, schemaName: string): Promise<void>;
900
- /**
901
- * Try to load the official Drizzle Kit API.
902
- * If not available, fallback to the local kit import.
903
- */
904
- protected importDrizzleKit(): typeof DrizzleKit;
905
- }
906
- declare const devMigrationsSchema: typebox2.TObject<{
907
- id: typebox2.TNumber;
908
- name: typebox2.TString;
909
- snapshot: typebox2.TString;
910
- created_at: typebox2.TString;
911
- }>;
912
- type DevMigrations = Static<typeof devMigrationsSchema>;
913
- //#endregion
914
- //#region src/providers/drivers/DatabaseProvider.d.ts
915
- type SQLLike = SQLWrapper | string;
916
- declare abstract class DatabaseProvider {
917
- protected readonly alepha: Alepha;
918
- protected readonly log: _alepha_logger0.Logger;
919
- protected abstract readonly builder: ModelBuilder;
920
- protected abstract readonly kit: DrizzleKitProvider;
921
- abstract readonly db: PgDatabase<any>;
922
- abstract readonly dialect: "postgresql" | "sqlite";
923
- abstract readonly url: string;
924
- readonly enums: Map<string, unknown>;
925
- readonly tables: Map<string, unknown>;
926
- readonly sequences: Map<string, unknown>;
927
- get name(): string;
928
- get schema(): string;
929
- table<T extends TObject>(entity: EntityDescriptor<T>): PgTableWithColumns<SchemaToTableConfig<T>>;
930
- registerEntity(entity: EntityDescriptor): void;
931
- registerSequence(sequence: SequenceDescriptor): void;
932
- abstract execute(statement: SQLLike): Promise<Record<string, unknown>[]>;
933
- run<T extends TObject>(statement: SQLLike, schema: T): Promise<Array<Static<T>>>;
934
- /**
935
- * Get migrations folder path - can be overridden
936
- */
937
- protected getMigrationsFolder(): string;
938
- /**
939
- * Base migration orchestration - handles environment logic
940
- */
941
- protected migrateDatabase(): Promise<void>;
942
- /**
943
- * Production: run migrations from folder
944
- */
945
- protected runProductionMigration(migrationsFolder: string): Promise<void>;
946
- /**
947
- * Test: always synchronize
948
- */
949
- protected runTestMigration(): Promise<void>;
950
- /**
951
- * Development: default to synchronize (can be overridden)
952
- */
953
- protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
954
- /**
955
- * Common synchronization with error handling
956
- */
957
- protected synchronizeSchema(): Promise<void>;
958
- /**
959
- * Provider-specific migration execution
960
- * MUST be implemented by each provider
961
- */
962
- protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
963
- }
964
- //#endregion
965
- //#region src/services/PgJsonQueryManager.d.ts
966
- /**
967
- * Manages JSONB query generation for nested object and array queries in PostgreSQL.
968
- * This class handles complex nested queries using PostgreSQL's JSONB operators.
969
- */
970
- declare class PgJsonQueryManager {
971
- /**
972
- * Check if a query contains nested JSONB queries.
973
- * A nested query is when the value is an object with operator keys.
974
- */
975
- hasNestedQuery(where: PgQueryWhere<TObject>): boolean;
976
- /**
977
- * Build a JSONB query condition for nested object queries.
978
- * Supports deep nesting like: { profile: { contact: { email: { eq: "test@example.com" } } } }
979
- *
980
- * @param column The JSONB column
981
- * @param path The path to the nested property (e.g., ['profile', 'contact', 'email'])
982
- * @param operator The filter operator (e.g., { eq: "test@example.com" })
983
- * @param dialect Database dialect (postgresql or sqlite)
984
- * @param columnSchema Optional schema of the JSON column for type inference
985
- * @returns SQL condition
986
- */
987
- buildJsonbCondition(column: PgColumn, path: string[], operator: FilterOperators<any>, dialect: "postgresql" | "sqlite", columnSchema?: any): SQL | undefined;
988
- /**
989
- * Build JSONB array query conditions.
990
- * Supports queries like: { addresses: { city: { eq: "Wonderland" } } }
991
- * which translates to: EXISTS (SELECT 1 FROM jsonb_array_elements(addresses) elem WHERE elem->>'city' = 'Wonderland')
992
- *
993
- * @param dialect Database dialect (postgresql or sqlite)
994
- * Note: SQLite array queries are not yet supported
995
- */
996
- buildJsonbArrayCondition(column: PgColumn, path: string[], arrayPath: string, operator: FilterOperators<any>, dialect: "postgresql" | "sqlite"): SQL | undefined;
997
- /**
998
- * Apply a filter operator to a JSONB value.
999
- * @param dialect Database dialect for appropriate casting syntax
1000
- * @param fieldType Optional field type from schema for smart casting
1001
- */
1002
- private applyOperatorToJsonValue;
1003
- /**
1004
- * Parse a nested query object and extract the path and operator.
1005
- * For example: { profile: { contact: { email: { eq: "test@example.com" } } } }
1006
- * Returns: { path: ['profile', 'contact', 'email'], operator: { eq: "test@example.com" } }
1007
- */
1008
- parseNestedQuery(nestedQuery: any, currentPath?: string[]): Array<{
1009
- path: string[];
1010
- operator: FilterOperators<any>;
1011
- }>;
1012
- /**
1013
- * Determine if a property is a JSONB column based on the schema.
1014
- * A column is JSONB if it's defined as an object or array in the TypeBox schema.
1015
- */
1016
- isJsonbColumn(schema: TObject, columnName: string): boolean;
1017
- /**
1018
- * Check if an array property contains primitive types (string, number, boolean, etc.)
1019
- * rather than objects. Primitive arrays should use native Drizzle operators.
1020
- * @returns true if the array contains primitives, false if it contains objects
1021
- */
1022
- isPrimitiveArray(schema: TObject, columnName: string): boolean;
1023
- /**
1024
- * Get the type of a field by navigating through a schema path.
1025
- * Used for smart type casting in SQL queries.
1026
- *
1027
- * @param columnSchema The schema of the JSON column (e.g., t.object({ age: t.int() }))
1028
- * @param path The path to navigate (e.g., ['contact', 'email'])
1029
- * @returns The type string (e.g., 'integer', 'number', 'string') or undefined if not found
1030
- */
1031
- private getFieldType;
1032
- /**
1033
- * Check if a nested path points to an array property.
1034
- */
1035
- isArrayProperty(schema: TObject, path: string[]): boolean;
1036
- }
1037
- //#endregion
1038
- //#region src/services/QueryManager.d.ts
1039
- declare class QueryManager {
1040
- protected readonly jsonQueryManager: PgJsonQueryManager;
1041
- protected readonly alepha: Alepha;
1042
- /**
1043
- * Convert a query object to a SQL query.
1044
- */
1045
- toSQL(query: PgQueryWhereOrSQL<TObject>, options: {
1046
- schema: TObject;
1047
- col: (key: string) => PgColumn;
1048
- joins?: PgJoin[];
1049
- dialect: "postgresql" | "sqlite";
1050
- }): SQL | undefined;
1051
- /**
1052
- * Build a JSONB query for nested object/array queries.
1053
- */
1054
- protected buildJsonbQuery(column: PgColumn, nestedQuery: any, schema: TObject, columnName: string, dialect: "postgresql" | "sqlite"): SQL | undefined;
1055
- /**
1056
- * Check if an object has any filter operator properties.
1057
- */
1058
- protected hasFilterOperatorProperties(obj: any): boolean;
1059
- /**
1060
- * Map a filter operator to a SQL query.
1061
- */
1062
- mapOperatorToSql(operator: FilterOperators<any> | any, column: PgColumn, columnSchema?: TObject, columnName?: string): SQL | undefined;
1063
- /**
1064
- * Parse pagination sort string to orderBy format.
1065
- * Format: "firstName,-lastName" -> [{ column: "firstName", direction: "asc" }, { column: "lastName", direction: "desc" }]
1066
- * - Columns separated by comma
1067
- * - Prefix with '-' for DESC direction
1068
- *
1069
- * @param sort Pagination sort string
1070
- * @returns OrderBy array or single object
1071
- */
1072
- parsePaginationSort(sort: string): Array<{
1073
- column: string;
1074
- direction: "asc" | "desc";
1075
- }> | {
1076
- column: string;
1077
- direction: "asc" | "desc";
1078
- };
1079
- /**
1080
- * Normalize orderBy parameter to array format.
1081
- * Supports 3 modes:
1082
- * 1. String: "name" -> [{ column: "name", direction: "asc" }]
1083
- * 2. Object: { column: "name", direction: "desc" } -> [{ column: "name", direction: "desc" }]
1084
- * 3. Array: [{ column: "name" }, { column: "age", direction: "desc" }] -> normalized array
1085
- *
1086
- * @param orderBy The orderBy parameter
1087
- * @returns Normalized array of order by clauses
1088
- */
1089
- normalizeOrderBy(orderBy: any): Array<{
1090
- column: string;
1091
- direction: "asc" | "desc";
1092
- }>;
1093
- /**
1094
- * Create a pagination object.
1095
- *
1096
- * @deprecated Use `createPagination` from @alepha/core instead.
1097
- * This method now delegates to the framework-level helper.
1098
- *
1099
- * @param entities The entities to paginate.
1100
- * @param limit The limit of the pagination.
1101
- * @param offset The offset of the pagination.
1102
- * @param sort Optional sort metadata to include in response.
1103
- */
1104
- createPagination<T>(entities: T[], limit?: number, offset?: number, sort?: Array<{
1105
- column: string;
1106
- direction: "asc" | "desc";
1107
- }>): _alepha_core10.Page<T>;
1108
- }
1109
- interface PgJoin {
1110
- table: string;
1111
- schema: TObject;
1112
- key: string;
1113
- col: (key: string) => PgColumn;
1114
- parent?: string;
1115
- }
1116
- //#endregion
1117
- //#region src/services/PgRelationManager.d.ts
1118
- declare class PgRelationManager {
1119
- /**
1120
- * Recursively build joins for the query builder based on the relations map
1121
- */
1122
- buildJoins(provider: DatabaseProvider, builder: PgSelectBase<any, any, any>, joins: Array<PgJoin>, withRelations: PgRelationMap<TObject>, table: PgTableWithColumns<any>, parentKey?: string): void;
1123
- /**
1124
- * Map a row with its joined relations based on the joins definition
1125
- */
1126
- mapRowWithJoins(record: Record<string, unknown>, row: Record<string, unknown>, schema: TObject, joins: PgJoin[], parentKey?: string): Record<string, unknown>;
1127
- /**
1128
- * Check if all values in an object are null (indicates a left join with no match)
1129
- */
1130
- private isAllNull;
1131
- /**
1132
- * Build a schema that includes all join properties recursively
1133
- */
1134
- buildSchemaWithJoins(baseSchema: TObject, joins: PgJoin[], parentPath?: string): TObject;
1135
- }
1136
- //#endregion
1137
- //#region src/services/Repository.d.ts
1138
- declare abstract class Repository<T extends TObject> {
1139
- readonly entity: EntityDescriptor<T>;
1140
- readonly provider: DatabaseProvider;
1141
- protected readonly relationManager: PgRelationManager;
1142
- protected readonly queryManager: QueryManager;
1143
- protected readonly dateTimeProvider: DateTimeProvider;
1144
- protected readonly alepha: Alepha;
1145
- constructor(entity: EntityDescriptor<T>, provider?: typeof DatabaseProvider);
1146
- /**
1147
- * Represents the primary key of the table.
1148
- * - Key is the name of the primary key column.
1149
- * - Type is the type (TypeBox) of the primary key column.
1150
- *
1151
- * ID is mandatory. If the table does not have a primary key, it will throw an error.
1152
- */
1153
- get id(): {
1154
- type: TSchema;
1155
- key: keyof T["properties"];
1156
- col: PgColumn;
1157
- };
1158
- /**
1159
- * Get Drizzle table object.
1160
- */
1161
- get table(): PgTableWithColumns<SchemaToTableConfig<T>>;
1162
- /**
1163
- * Get SQL table name. (from Drizzle table object)
1164
- */
1165
- get tableName(): string;
1166
- /**
1167
- * Getter for the database connection from the database provider.
1168
- */
1169
- protected get db(): PgDatabase<any>;
1170
- /**
1171
- * Execute a SQL query.
1172
- *
1173
- * This method allows executing raw SQL queries against the database.
1174
- * This is by far the easiest way to run custom queries that are not covered by the repository's built-in methods!
1175
- *
1176
- * You must use the `sql` tagged template function from Drizzle ORM to create the query. https://orm.drizzle.team/docs/sql
1177
- *
1178
- * @example
1179
- * ```ts
1180
- * class App {
1181
- * repository = $repository({ ... });
1182
- * async getAdults() {
1183
- * const users = repository.table; // Drizzle table object
1184
- * await repository.query(sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
1185
- * // or better
1186
- * await repository.query((users) => sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
1187
- * }
1188
- * }
1189
- * ```
1190
- */
1191
- query<R extends TObject = T>(query: SQLLike | ((table: PgTableWithColumns<SchemaToTableConfig<T>>, db: PgDatabase<any>) => SQLLike), schema?: R): Promise<Static<R>[]>;
1192
- /**
1193
- * Map raw database fields to entity fields. (handles column name differences)
1194
- */
1195
- protected mapRawFieldsToEntity(row: Record<string, unknown>): any;
1196
- /**
1197
- * Get a Drizzle column from the table by his name.
1198
- */
1199
- protected col(name: keyof StaticEncode<T>): PgColumn;
1200
- /**
1201
- * Run a transaction.
1202
- */
1203
- transaction<T>(transaction: (tx: PgTransaction<any, Record<string, any>, any>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
1204
- /**
1205
- * Start a SELECT query on the table.
1206
- */
1207
- protected select(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, {
1208
- [x: string]: unknown;
1209
- }[], {
1210
- [x: string]: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
1211
- }>;
1212
- /**
1213
- * Start a SELECT DISTINCT query on the table.
1214
- */
1215
- protected selectDistinct(opts?: StatementOptions, columns?: (keyof Static<T>)[]): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, any>, "partial", Record<string, "not-null">, false, never, {
1216
- [x: string]: any;
1217
- }[], {
1218
- [x: string]: any;
1219
- }>;
1220
- /**
1221
- * Start an INSERT query on the table.
1222
- */
1223
- protected insert(opts?: StatementOptions): drizzle_orm_pg_core0.PgInsertBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any, false>;
1224
- /**
1225
- * Start an UPDATE query on the table.
1226
- */
1227
- protected update(opts?: StatementOptions): drizzle_orm_pg_core0.PgUpdateBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any>;
1228
- /**
1229
- * Start a DELETE query on the table.
1230
- */
1231
- protected delete(opts?: StatementOptions): drizzle_orm_pg_core0.PgDeleteBase<PgTableWithColumns<SchemaToTableConfig<T>>, any, undefined, undefined, false, never>;
1232
- /**
1233
- * Create a Drizzle `select` query based on a JSON query object.
1234
- *
1235
- * > This method is the base for `find`, `findOne`, `findById`, and `paginate`.
1236
- */
1237
- find<R extends PgRelationMap<T>>(query?: PgQueryRelations<T, R>, opts?: StatementOptions): Promise<PgStatic<T, R>[]>;
1238
- /**
1239
- * Find a single entity.
1240
- */
1241
- findOne<R extends PgRelationMap<T>>(query: Pick<PgQueryRelations<T, R>, "with" | "where">, opts?: StatementOptions): Promise<PgStatic<T, R>>;
1242
- /**
1243
- * Find entities with pagination.
1244
- *
1245
- * It uses the same parameters as `find()`, but adds pagination metadata to the response.
1246
- *
1247
- * > Pagination CAN also do a count query to get the total number of elements.
1248
- */
1249
- paginate<R extends PgRelationMap<T>>(pagination?: PageQuery$1, query?: PgQueryRelations<T, R>, opts?: StatementOptions & {
1250
- count?: boolean;
1251
- }): Promise<Page$1<PgStatic<T, R>>>;
1252
- /**
1253
- * Find an entity by ID.
1254
- *
1255
- * This is a convenience method for `findOne` with a where clause on the primary key.
1256
- * If you need more complex queries, use `findOne` instead.
1257
- */
1258
- findById(id: string | number, opts?: StatementOptions): Promise<Static<T>>;
1259
- /**
1260
- * Helper to create a type-safe query object.
1261
- */
1262
- createQuery(): PgQuery<T>;
1263
- /**
1264
- * Helper to create a type-safe where clause.
1265
- */
1266
- createQueryWhere(): PgQueryWhere<T>;
1267
- /**
1268
- * Create an entity.
1269
- *
1270
- * @param data The entity to create.
1271
- * @param opts The options for creating the entity.
1272
- * @returns The ID of the created entity.
1273
- */
1274
- create(data: Static<TObjectInsert<T>>, opts?: StatementOptions): Promise<Static<T>>;
1275
- /**
1276
- * Create many entities.
1277
- *
1278
- * @param values The entities to create.
1279
- * @param opts The statement options.
1280
- * @returns The created entities.
1281
- */
1282
- createMany(values: Array<Static<TObjectInsert<T>>>, opts?: StatementOptions): Promise<Static<T>[]>;
1283
- /**
1284
- * Find an entity and update it.
1285
- */
1286
- updateOne(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
1287
- /**
1288
- * Save a given entity.
1289
- *
1290
- * @example
1291
- * ```ts
1292
- * const entity = await repository.findById(1);
1293
- * entity.name = "New Name"; // update a field
1294
- * delete entity.description; // delete a field
1295
- * await repository.save(entity);
1296
- * ```
1297
- *
1298
- * Difference with `updateById/updateOne`:
1299
- *
1300
- * - requires the entity to be fetched first (whole object is expected)
1301
- * - check pg.version() if present -> optimistic locking
1302
- * - validate entity against schema
1303
- * - undefined values will be set to null, not ignored!
1304
- *
1305
- * @see {@link PgVersionMismatchError}
1306
- */
1307
- save(entity: Static<T>, opts?: StatementOptions): Promise<void>;
1308
- /**
1309
- * Find an entity by ID and update it.
1310
- */
1311
- updateById(id: string | number, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
1312
- /**
1313
- * Find many entities and update all of them.
1314
- */
1315
- updateMany(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Array<number | string>>;
1316
- /**
1317
- * Find many and delete all of them.
1318
- * @returns Array of deleted entity IDs
1319
- */
1320
- deleteMany(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
1321
- /**
1322
- * Delete all entities.
1323
- * @returns Array of deleted entity IDs
1324
- */
1325
- clear(opts?: StatementOptions): Promise<Array<number | string>>;
1326
- /**
1327
- * Delete the given entity.
1328
- *
1329
- * You must fetch the entity first in order to delete it.
1330
- * @returns Array containing the deleted entity ID
1331
- */
1332
- destroy(entity: Static<T>, opts?: StatementOptions): Promise<Array<number | string>>;
1333
- /**
1334
- * Find an entity and delete it.
1335
- * @returns Array of deleted entity IDs (should contain at most one ID)
1336
- */
1337
- deleteOne(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
1338
- /**
1339
- * Find an entity by ID and delete it.
1340
- * @returns Array containing the deleted entity ID
1341
- * @throws PgEntityNotFoundError if the entity is not found
1342
- */
1343
- deleteById(id: string | number, opts?: StatementOptions): Promise<Array<number | string>>;
1344
- /**
1345
- * Count entities.
1346
- */
1347
- count(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<number>;
1348
- protected conflictMessagePattern: string;
1349
- protected handleError(error: unknown, message: string): DbError;
1350
- protected withDeletedAt(where: PgQueryWhereOrSQL<T>, opts?: {
1351
- force?: boolean;
1352
- }): PgQueryWhereOrSQL<T>;
1353
- protected deletedAt(): PgAttrField | undefined;
1354
- /**
1355
- * Convert something to valid Pg Insert Value.
1356
- */
1357
- protected cast(data: any, insert: boolean): PgInsertValue<PgTableWithColumns<SchemaToTableConfig<T>>>;
1358
- /**
1359
- * Transform a row from the database into a clean entity.
1360
- */
1361
- protected clean<T extends TObject>(row: Record<string, unknown>, schema: T): Static<T>;
1362
- /**
1363
- * Clean a row with joins recursively
1364
- */
1365
- protected cleanWithJoins<T extends TObject>(row: Record<string, unknown>, schema: T, joins: PgJoin[], parentPath?: string): Static<T>;
1366
- /**
1367
- * Convert a where clause to SQL.
1368
- */
1369
- protected toSQL(where: PgQueryWhereOrSQL<T>, joins?: PgJoin[]): SQL | undefined;
1370
- /**
1371
- * Get the where clause for an ID.
1372
- *
1373
- * @param id The ID to get the where clause for.
1374
- * @returns The where clause for the ID.
1375
- */
1376
- protected getWhereId(id: string | number): PgQueryWhere<T>;
1377
- /**
1378
- * Find a primary key in the schema.
1379
- */
1380
- protected getPrimaryKey(schema: TObject): {
1381
- key: string;
1382
- col: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
1383
- type: TSchema;
1384
- };
1385
- }
1386
- /**
1387
- * The options for a statement.
1388
- */
1389
- interface StatementOptions {
1390
- /**
1391
- * Transaction to use.
1392
- */
1393
- tx?: PgTransaction<any, Record<string, any>>;
1394
- /**
1395
- * Lock strength.
1396
- */
1397
- for?: LockStrength | {
1398
- config: LockConfig;
1399
- strength: LockStrength;
1400
- };
1401
- /**
1402
- * If true, ignore soft delete.
1403
- */
1404
- force?: boolean;
1405
- /**
1406
- * Force the current time.
1407
- */
1408
- now?: DateTime | string;
1409
- }
1410
- //#endregion
1411
- //#region src/descriptors/$repository.d.ts
1412
- /**
1413
- * Get the repository for the given entity.
1414
- */
1415
- declare const $repository: <T extends TObject>(entity: EntityDescriptor<T>) => Repository<T>;
1416
- //#endregion
1417
- //#region src/descriptors/$transaction.d.ts
1418
- /**
1419
- * Creates a transaction descriptor for database operations requiring atomicity and consistency.
1420
- *
1421
- * This descriptor provides a convenient way to wrap database operations in PostgreSQL
1422
- * transactions, ensuring ACID properties and automatic retry logic for version conflicts.
1423
- * It integrates seamlessly with the repository pattern and provides built-in handling
1424
- * for optimistic locking scenarios with automatic retry on version mismatches.
1425
- *
1426
- * **Important Notes**:
1427
- * - All operations within the transaction handler are atomic
1428
- * - Automatic retry on `PgVersionMismatchError` for optimistic locking
1429
- * - Pass `{ tx }` option to all repository operations within the transaction
1430
- * - Transactions are automatically rolled back on any unhandled error
1431
- * - Use appropriate isolation levels based on your consistency requirements
1432
- */
1433
- declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry0.RetryDescriptorFn<(...args: T) => Promise<R>>;
1434
- interface TransactionDescriptorOptions<T extends any[], R> {
1435
- /**
1436
- * Transaction handler function that contains all database operations to be executed atomically.
1437
- *
1438
- * This function:
1439
- * - Receives a transaction object as the first parameter
1440
- * - Should pass the transaction to all repository operations via `{ tx }` option
1441
- * - All operations within are automatically rolled back if any error occurs
1442
- * - Has access to the full Alepha dependency injection container
1443
- * - Will be automatically retried if a `PgVersionMismatchError` occurs
1444
- *
1445
- * **Transaction Guidelines**:
1446
- * - Keep transactions as short as possible to minimize lock contention
1447
- * - Always pass the `tx` parameter to repository operations
1448
- * - Handle expected business errors gracefully
1449
- * - Log important operations for debugging and audit trails
1450
- * - Consider the impact of long-running transactions on performance
1451
- *
1452
- * **Error Handling**:
1453
- * - Throwing any error will automatically roll back the transaction
1454
- * - `PgVersionMismatchError` triggers automatic retry logic
1455
- * - Other database errors will be propagated after rollback
1456
- * - Use try-catch within the handler for business-specific error handling
1457
- *
1458
- * @param tx - The PostgreSQL transaction object to use for all database operations
1459
- * @param ...args - Additional arguments passed to the transaction function
1460
- * @returns Promise resolving to the transaction result
1461
- *
1462
- * @example
1463
- * ```ts
1464
- * handler: async (tx, orderId: string, newStatus: string) => {
1465
- * // Get the current order (with transaction)
1466
- * const order = await this.orders.findById(orderId, { tx });
1467
- *
1468
- * // Validate business rules
1469
- * if (!this.isValidStatusTransition(order.status, newStatus)) {
1470
- * throw new Error(`Invalid status transition: ${order.status} -> ${newStatus}`);
1471
- * }
1472
- *
1473
- * // Update order status (with transaction)
1474
- * const updatedOrder = await this.orders.updateById(
1475
- * orderId,
1476
- * { status: newStatus },
1477
- * { tx }
1478
- * );
1479
- *
1480
- * // Create audit log (with transaction)
1481
- * await this.auditLogs.create({
1482
- * id: generateUUID(),
1483
- * entityId: orderId,
1484
- * action: 'status_change',
1485
- * oldValue: order.status,
1486
- * newValue: newStatus,
1487
- * timestamp: new Date().toISOString()
1488
- * }, { tx });
1489
- *
1490
- * return updatedOrder;
1491
- * }
1492
- * ```
1493
- */
1494
- handler: (tx: PgTransaction<any, any, any>, ...args: T) => Promise<R>;
1495
- /**
1496
- * PostgreSQL transaction configuration options.
1497
- *
1498
- * This allows you to customize transaction behavior including:
1499
- * - **Isolation Level**: Controls visibility of concurrent transaction changes
1500
- * - **Access Mode**: Whether the transaction is read-only or read-write
1501
- * - **Deferrable**: For serializable transactions, allows deferring to avoid conflicts
1502
- *
1503
- * **Isolation Levels**:
1504
- * - **read_uncommitted**: Lowest isolation, allows dirty reads (rarely used)
1505
- * - **read_committed**: Default level, prevents dirty reads
1506
- * - **repeatable_read**: Prevents dirty and non-repeatable reads
1507
- * - **serializable**: Highest isolation, full ACID compliance
1508
- *
1509
- * **Access Modes**:
1510
- * - **read_write**: Default, allows both read and write operations
1511
- * - **read_only**: Only allows read operations, can provide performance benefits
1512
- *
1513
- * **When to Use Different Isolation Levels**:
1514
- * - **read_committed**: Most common operations, good balance of consistency and performance
1515
- * - **repeatable_read**: When you need consistent reads throughout the transaction
1516
- * - **serializable**: Critical financial operations, when absolute consistency is required
1517
- *
1518
- * @example
1519
- * ```ts
1520
- * config: {
1521
- * isolationLevel: 'serializable', // Highest consistency for financial operations
1522
- * accessMode: 'read_write'
1523
- * }
1524
- * ```
1525
- *
1526
- * @example
1527
- * ```ts
1528
- * config: {
1529
- * isolationLevel: 'read_committed', // Default level for most operations
1530
- * accessMode: 'read_only' // Performance optimization for read-only operations
1531
- * }
1532
- * ```
1533
- */
1534
- config?: PgTransactionConfig;
1535
- }
1536
- type TransactionContext = PgTransaction<any, any, any>;
1537
- //#endregion
1538
- //#region src/errors/PgConflictError.d.ts
1539
- declare class PgConflictError extends DbError {
1540
- readonly name = "PgConflictError";
1541
- readonly status = 409;
1542
- }
1543
- //#endregion
1544
- //#region src/errors/PgEntityNotFoundError.d.ts
1545
- declare class PgEntityNotFoundError extends DbError {
1546
- readonly name = "EntityNotFoundError";
1547
- readonly status = 404;
1548
- constructor(entityName: string);
1549
- }
1550
- //#endregion
1551
- //#region src/errors/PgMigrationError.d.ts
1552
- declare class PgMigrationError extends DbError {
1553
- readonly name = "PgMigrationError";
1554
- constructor(cause?: unknown);
1555
- }
1556
- //#endregion
1557
- //#region src/errors/PgVersionMismatchError.d.ts
1558
- /**
1559
- * Error thrown when there is a version mismatch.
1560
- * It's thrown by {@link RepositoryDescriptor#save} when the updated entity version does not match the one in the database.
1561
- * This is used for optimistic concurrency control.
1562
- */
1563
- declare class PgVersionMismatchError extends DbError {
1564
- readonly name = "PgVersionMismatchError";
1565
- constructor(table: string, id: any);
1566
- }
1567
- //#endregion
1568
- //#region src/helpers/parseQueryString.d.ts
1569
- /**
1570
- * Parse a string query into a PgQueryWhere object.
1571
- *
1572
- * Supported syntax:
1573
- * - Simple equality: "name=John"
1574
- * - Operators: "age>18", "age>=18", "age<65", "age<=65", "status!=active"
1575
- * - LIKE patterns: "name~John" (like), "name~*John" (ilike)
1576
- * - NULL checks: "deletedAt=null", "email!=null"
1577
- * - IN arrays: "status=[pending,active]"
1578
- * - AND conditions: "name=John&age>18"
1579
- * - OR conditions: "name=John|email=john@example.com"
1580
- * - Nested AND/OR: "(name=John|name=Jane)&age>18"
1581
- * - JSONB nested: "profile.city=Paris"
1582
- *
1583
- * @example
1584
- * ```ts
1585
- * // Simple equality
1586
- * parseQueryString("name=John")
1587
- * // => { name: { eq: "John" } }
1588
- *
1589
- * // Multiple conditions
1590
- * parseQueryString("name=John&age>18")
1591
- * // => { and: [{ name: { eq: "John" } }, { age: { gt: 18 } }] }
1592
- *
1593
- * // OR conditions
1594
- * parseQueryString("status=active|status=pending")
1595
- * // => { or: [{ status: { eq: "active" } }, { status: { eq: "pending" } }] }
1596
- *
1597
- * // Complex nested
1598
- * parseQueryString("(name=John|name=Jane)&age>18&status!=archived")
1599
- * // => { and: [
1600
- * // { or: [{ name: { eq: "John" } }, { name: { eq: "Jane" } }] },
1601
- * // { age: { gt: 18 } },
1602
- * // { status: { ne: "archived" } }
1603
- * // ] }
1604
- *
1605
- * // JSONB nested query
1606
- * parseQueryString("profile.city=Paris&profile.age>25")
1607
- * // => { profile: { city: { eq: "Paris" }, age: { gt: 25 } } }
1608
- * ```
1609
- */
1610
- declare function parseQueryString<T extends TObject>(query: string): PgQueryWhere<T>;
1611
- /**
1612
- * Helper function to build query strings programmatically
1613
- *
1614
- * @example
1615
- * ```ts
1616
- * buildQueryString({
1617
- * and: [
1618
- * { name: "eq:John" },
1619
- * { age: "gt:18" }
1620
- * ]
1621
- * })
1622
- * // => "name=John&age>18"
1623
- * ```
1624
- */
1625
- declare function buildQueryString(where: any): string;
1626
- //#endregion
1627
- //#region src/services/PostgresModelBuilder.d.ts
1628
- declare class PostgresModelBuilder extends ModelBuilder {
1629
- protected schemas: Map<string, drizzle_orm_pg_core0.PgSchema<string>>;
1630
- protected getPgSchema(name: string): any;
1631
- buildTable(entity: EntityDescriptor<any>, options: {
1632
- tables: Map<string, unknown>;
1633
- enums: Map<string, unknown>;
1634
- schema: string;
1635
- }): void;
1636
- buildSequence(sequence: SequenceDescriptor, options: {
1637
- sequences: Map<string, unknown>;
1638
- schema: string;
1639
- }): void;
1640
- /**
1641
- * Get PostgreSQL-specific config builder for the table.
1642
- */
1643
- protected getTableConfig(entity: EntityDescriptor, tables: Map<string, unknown>): ((self: BuildExtraConfigColumns<string, any, "pg">) => PgTableExtraConfigValue[]) | undefined;
1644
- schemaToPgColumns: <T extends TObject>(tableName: string, schema: T, nsp: PgSchema, enums: Map<string, unknown>, tables: Map<string, unknown>) => FromSchema<T>;
1645
- mapFieldToColumn: (tableName: string, fieldName: string, value: TSchema, nsp: PgSchema, enums: Map<string, any>) => any;
1646
- /**
1647
- * Map a string to a PG column.
1648
- *
1649
- * @param key The key of the field.
1650
- * @param value The value of the field.
1651
- */
1652
- mapStringToColumn: (key: string, value: TSchema) => drizzle_orm_pg_core0.PgUUIDBuilderInitial<string> | drizzle_orm_pg_core0.PgCustomColumnBuilder<{
1653
- name: string;
1654
- dataType: "custom";
1655
- columnType: "PgCustomColumn";
1656
- data: Buffer<ArrayBufferLike>;
1657
- driverParam: unknown;
1658
- enumValues: undefined;
1659
- }> | drizzle_orm_pg_core0.PgTimestampStringBuilderInitial<string> | drizzle_orm_pg_core0.PgDateStringBuilderInitial<string> | drizzle_orm_pg_core0.PgTextBuilderInitial<string, [string, ...string[]]>;
1660
- }
1661
- //#endregion
1662
- //#region src/providers/drivers/NodePostgresProvider.d.ts
1663
- declare module "alepha" {
1664
- interface Env extends Partial<Static<typeof envSchema>> {}
1665
- }
1666
- declare const envSchema: _alepha_core10.TObject<{
1667
- /**
1668
- * Main configuration for database connection.
1669
- * Accept a string in the format of a Postgres connection URL.
1670
- * Example: postgres://user:password@localhost:5432/database
1671
- * or
1672
- * Example: postgres://user:password@localhost:5432/database?sslmode=require
1673
- */
1674
- DATABASE_URL: _alepha_core10.TOptional<_alepha_core10.TString>;
1675
- /**
1676
- * In addition to the DATABASE_URL, you can specify the postgres schema name.
1677
- *
1678
- * It will monkey patch drizzle tables.
1679
- */
1680
- POSTGRES_SCHEMA: _alepha_core10.TOptional<_alepha_core10.TString>;
1681
- }>;
1682
- declare class NodePostgresProvider extends DatabaseProvider {
1683
- static readonly SSL_MODES: readonly ["require", "allow", "prefer", "verify-full"];
1684
- protected readonly log: _alepha_logger0.Logger;
1685
- protected readonly env: {
1686
- DATABASE_URL?: string | undefined;
1687
- POSTGRES_SCHEMA?: string | undefined;
1688
- };
1689
- protected readonly kit: DrizzleKitProvider;
1690
- protected readonly builder: PostgresModelBuilder;
1691
- protected client?: postgres.Sql;
1692
- protected pg?: PostgresJsDatabase;
1693
- readonly dialect = "postgresql";
1694
- get name(): string;
1695
- /**
1696
- * In testing mode, the schema name will be generated and deleted after the test.
1697
- */
1698
- protected schemaForTesting: string | undefined;
1699
- get url(): string;
1700
- /**
1701
- * Execute a SQL statement.
1702
- */
1703
- execute(statement: SQLLike): Promise<Array<Record<string, unknown>>>;
1704
- /**
1705
- * Get Postgres schema used by this provider.
1706
- */
1707
- get schema(): string;
1708
- /**
1709
- * Get the Drizzle Postgres database instance.
1710
- */
1711
- get db(): PostgresJsDatabase;
1712
- protected executeMigrations(migrationsFolder: string): Promise<void>;
1713
- protected readonly onStart: _alepha_core10.HookDescriptor<"start">;
1714
- protected readonly onStop: _alepha_core10.HookDescriptor<"stop">;
1715
- connect(): Promise<void>;
1716
- close(): Promise<void>;
1717
- protected migrate: _alepha_lock0.LockDescriptor<() => Promise<void>>;
1718
- /**
1719
- * Map the DATABASE_URL to postgres client options.
1720
- */
1721
- protected getClientOptions(): postgres.Options<any>;
1722
- protected ssl(url: URL): "require" | "allow" | "prefer" | "verify-full" | undefined;
1723
- /**
1724
- * For testing purposes, generate a unique schema name.
1725
- * The schema name will be generated based on the current date and time.
1726
- * It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
1727
- */
1728
- protected generateTestSchemaName(): string;
1729
- }
1730
- //#endregion
1731
- //#region src/services/SqliteModelBuilder.d.ts
1732
- declare class SqliteModelBuilder extends ModelBuilder {
1733
- buildTable(entity: EntityDescriptor<any>, options: {
1734
- tables: Map<string, unknown>;
1735
- enums: Map<string, unknown>;
1736
- schema: string;
1737
- }): void;
1738
- buildSequence(sequence: SequenceDescriptor, options: {
1739
- sequences: Map<string, unknown>;
1740
- schema: string;
1741
- }): void;
1742
- /**
1743
- * Get SQLite-specific config builder for the table.
1744
- */
1745
- protected getTableConfig(entity: EntityDescriptor, tables: Map<string, unknown>): ((self: BuildColumns<string, any, "sqlite">) => any) | undefined;
1746
- schemaToSqliteColumns: <T extends TObject>(tableName: string, schema: T, enums: Map<string, unknown>, tables: Map<string, unknown>) => SchemaToSqliteBuilder<T>;
1747
- mapFieldToSqliteColumn: (tableName: string, fieldName: string, value: TSchema, enums: Map<string, any>) => pg$1.SQLiteIntegerBuilderInitial<string> | pg$1.SQLiteNumericBuilderInitial<string> | pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
1748
- name: string;
1749
- dataType: "custom";
1750
- columnType: "SQLiteCustomColumn";
1751
- data: string;
1752
- driverParam: string;
1753
- enumValues: undefined;
1754
- }>, string> | pg$1.SQLiteCustomColumnBuilder<{
1755
- name: string;
1756
- dataType: "custom";
1757
- columnType: "SQLiteCustomColumn";
1758
- data: string;
1759
- driverParam: number;
1760
- enumValues: undefined;
1761
- }> | pg$1.SQLiteCustomColumnBuilder<{
1762
- name: string;
1763
- dataType: "custom";
1764
- columnType: "SQLiteCustomColumn";
1765
- data: boolean;
1766
- driverParam: number;
1767
- enumValues: undefined;
1768
- }> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
1769
- name: string;
1770
- dataType: "custom";
1771
- columnType: "SQLiteCustomColumn";
1772
- data: {
1773
- [x: string]: unknown;
1774
- [x: number]: unknown;
1775
- [x: symbol]: unknown;
1776
- };
1777
- driverParam: string;
1778
- enumValues: undefined;
1779
- }>, {
1780
- [x: string]: unknown;
1781
- [x: number]: unknown;
1782
- [x: symbol]: unknown;
1783
- }> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
1784
- name: string;
1785
- dataType: "custom";
1786
- columnType: "SQLiteCustomColumn";
1787
- data: Record<string, unknown>;
1788
- driverParam: string;
1789
- enumValues: undefined;
1790
- }>, Record<string, unknown>> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
1791
- name: string;
1792
- dataType: "custom";
1793
- columnType: "SQLiteCustomColumn";
1794
- data: any;
1795
- driverParam: string;
1796
- enumValues: undefined;
1797
- }>, any> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
1798
- name: string;
1799
- dataType: "custom";
1800
- columnType: "SQLiteCustomColumn";
1801
- data: unknown[];
1802
- driverParam: string;
1803
- enumValues: undefined;
1804
- }>, unknown[]>;
1805
- mapStringToSqliteColumn: (key: string, value: TString) => pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
1806
- name: string;
1807
- dataType: "custom";
1808
- columnType: "SQLiteCustomColumn";
1809
- data: string;
1810
- driverParam: string;
1811
- enumValues: undefined;
1812
- }>, string> | pg$1.SQLiteCustomColumnBuilder<{
1813
- name: string;
1814
- dataType: "custom";
1815
- columnType: "SQLiteCustomColumn";
1816
- data: string;
1817
- driverParam: number;
1818
- enumValues: undefined;
1819
- }>;
1820
- sqliteJson: <TDocument extends TSchema>(name: string, document: TDocument) => drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
1821
- name: string;
1822
- dataType: "custom";
1823
- columnType: "SQLiteCustomColumn";
1824
- data: typebox2.StaticType<[], "Decode", {}, {}, TDocument>;
1825
- driverParam: string;
1826
- enumValues: undefined;
1827
- }>, typebox2.StaticType<[], "Decode", {}, {}, TDocument>>;
1828
- sqliteDateTime: {
1829
- <TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
1830
- name: "";
1831
- dataType: "custom";
1832
- columnType: "SQLiteCustomColumn";
1833
- data: string;
1834
- driverParam: number;
1835
- enumValues: undefined;
1836
- }>;
1837
- <TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
1838
- name: TName;
1839
- dataType: "custom";
1840
- columnType: "SQLiteCustomColumn";
1841
- data: string;
1842
- driverParam: number;
1843
- enumValues: undefined;
1844
- }>;
1845
- };
1846
- sqliteBool: {
1847
- <TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
1848
- name: "";
1849
- dataType: "custom";
1850
- columnType: "SQLiteCustomColumn";
1851
- data: boolean;
1852
- driverParam: number;
1853
- enumValues: undefined;
1854
- }>;
1855
- <TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
1856
- name: TName;
1857
- dataType: "custom";
1858
- columnType: "SQLiteCustomColumn";
1859
- data: boolean;
1860
- driverParam: number;
1861
- enumValues: undefined;
1862
- }>;
1863
- };
1864
- sqliteDate: {
1865
- <TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
1866
- name: "";
1867
- dataType: "custom";
1868
- columnType: "SQLiteCustomColumn";
1869
- data: string;
1870
- driverParam: number;
1871
- enumValues: undefined;
1872
- }>;
1873
- <TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
1874
- name: TName;
1875
- dataType: "custom";
1876
- columnType: "SQLiteCustomColumn";
1877
- data: string;
1878
- driverParam: number;
1879
- enumValues: undefined;
1880
- }>;
1881
- };
1882
- }
1883
- type SchemaToSqliteBuilder<T extends TObject> = { [key in keyof T["properties"]]: SQLiteColumnBuilderBase };
1884
- //#endregion
1885
- //#region src/providers/drivers/NodeSqliteProvider.d.ts
1886
- /**
1887
- * Configuration options for the Node.js SQLite database provider.
1888
- */
1889
- declare const nodeSqliteOptions: _alepha_core10.Atom<typebox2.TObject<{
1890
- path: typebox2.TOptional<typebox2.TString>;
1891
- }>, "alepha.postgres.node-sqlite.options">;
1892
- type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
1893
- declare module "alepha" {
1894
- interface State {
1895
- [nodeSqliteOptions.key]: NodeSqliteProviderOptions;
1896
- }
1897
- }
1898
- /**
1899
- * Add a fake support for SQLite in Node.js based on Postgres interfaces.
1900
- *
1901
- * This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
1902
- * This is NOT recommended for production use.
1903
- */
1904
- declare class NodeSqliteProvider extends DatabaseProvider {
1905
- protected readonly kit: DrizzleKitProvider;
1906
- protected readonly log: _alepha_logger0.Logger;
1907
- protected readonly env: {
1908
- DATABASE_URL?: string | undefined;
1909
- };
1910
- protected readonly builder: SqliteModelBuilder;
1911
- protected readonly options: Readonly<{
1912
- path?: string | undefined;
1913
- }>;
1914
- protected sqlite: DatabaseSync;
1915
- get name(): string;
1916
- readonly dialect = "sqlite";
1917
- get url(): string;
1918
- execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
1919
- readonly db: PgDatabase<any>;
1920
- protected readonly onStart: _alepha_core10.HookDescriptor<"start">;
1921
- protected executeMigrations(migrationsFolder: string): Promise<void>;
1922
- }
1923
- //#endregion
1924
- //#region src/providers/PostgresTypeProvider.d.ts
1925
- declare class PostgresTypeProvider {
1926
- readonly attr: <T extends TSchema, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
1927
- /**
1928
- * Creates a primary key with an identity column.
1929
- */
1930
- readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1931
- /**
1932
- * Creates a primary key with a big identity column. (default)
1933
- */
1934
- readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1935
- /**
1936
- * Creates a primary key with a UUID column.
1937
- */
1938
- readonly uuidPrimaryKey: () => PgAttr<PgAttr<TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1939
- /**
1940
- * Creates a primary key for a given type. Supports:
1941
- * - `t.int()` -> PG INT (default)
1942
- * - `t.bigint()` -> PG BIGINT
1943
- * - `t.uuid()` -> PG UUID
1944
- */
1945
- primaryKey(): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
1946
- primaryKey(type: TString, options?: TStringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
1947
- primaryKey(type: TInteger, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
1948
- primaryKey(type: TNumber, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
1949
- primaryKey(type: TBigInt, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TBigInt, PgPrimaryKey>, PgDefault>;
1950
- /**
1951
- * Wrap a schema with "default" attribute.
1952
- * This is used to set a default value for a column in the database.
1953
- */
1954
- readonly default: <T extends TSchema>(type: T, value?: Static<T>) => PgAttr<T, PgDefault>;
1955
- /**
1956
- * Creates a column 'version'.
1957
- *
1958
- * This is used to track the version of a row in the database.
1959
- *
1960
- * You can use it for optimistic concurrency control (OCC) with {@link RepositoryDescriptor#save}.
1961
- *
1962
- * @see {@link RepositoryDescriptor#save}
1963
- * @see {@link PgVersionMismatchError}
1964
- */
1965
- readonly version: (options?: TNumberOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
1966
- /**
1967
- * Creates a column Created At. So just a datetime column with a default value of the current timestamp.
1968
- */
1969
- readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1970
- /**
1971
- * Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
1972
- */
1973
- readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1974
- /**
1975
- * Creates a column Deleted At for soft delete functionality.
1976
- * This is used to mark rows as deleted without actually removing them from the database.
1977
- * The column is nullable - NULL means not deleted, timestamp means deleted.
1978
- */
1979
- readonly deletedAt: (options?: TStringOptions) => PgAttr<typebox2.TOptional<TString>, typeof PG_DELETED_AT>;
1980
- /**
1981
- * Creates a Postgres ENUM type.
1982
- *
1983
- * > By default, `t.enum()` is mapped to a TEXT column in Postgres.
1984
- * > Using this method, you can create a real ENUM type in the database.
1985
- *
1986
- * @example
1987
- * ```ts
1988
- * const statusEnum = pg.enum(["pending", "active", "archived"], { name: "status_enum" });
1989
- * ```
1990
- */
1991
- readonly enum: <T extends string[]>(values: [...T], pgEnumOptions?: PgEnumOptions, typeOptions?: TStringOptions) => PgAttr<TUnsafe<T[number]>, typeof PG_ENUM>;
1992
- /**
1993
- * Creates a reference to another table or schema. Basically a foreign key.
1994
- */
1995
- readonly ref: <T extends TSchema>(type: T, ref: () => any, actions?: {
1996
- onUpdate?: UpdateDeleteAction$1;
1997
- onDelete?: UpdateDeleteAction$1;
1998
- }) => PgAttr<T, PgRef>;
1999
- /**
2000
- * Creates a page schema for a given object schema.
2001
- * It's used by {@link RepositoryDescriptor#paginate} method.
2002
- */
2003
- readonly page: <T extends TObject>(resource: T, options?: TObjectOptions) => TPage<T>;
2004
- }
2005
- declare const pg: PostgresTypeProvider;
2006
- //#endregion
2007
- //#region src/providers/RepositoryProvider.d.ts
2008
- declare class RepositoryProvider {
2009
- protected readonly alepha: Alepha;
2010
- protected readonly registry: Map<EntityDescriptor<any>, Service<Repository<any>>>;
2011
- getRepositories(provider?: DatabaseProvider): Repository<TObject<typebox2.TProperties>>[];
2012
- createClassRepository<T extends TObject>(entity: EntityDescriptor<T>): Service<Repository<T>>;
2013
- }
2014
- //#endregion
2015
- //#region src/schemas/legacyIdSchema.d.ts
2016
- /**
2017
- * @deprecated Use `pg.primaryKey()` instead.
2018
- */
2019
- declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<typebox2.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
2020
- //#endregion
2021
- //#region src/types/schema.d.ts
2022
- /**
2023
- * Postgres schema type.
2024
- */
2025
- declare const schema: <TDocument extends TSchema>(name: string, document: TDocument) => drizzle_orm0.$Type<drizzle_orm_pg_core0.PgCustomColumnBuilder<{
2026
- name: string;
2027
- dataType: "custom";
2028
- columnType: "PgCustomColumn";
2029
- data: typebox2.StaticType<[], "Decode", {}, {}, TDocument>;
2030
- driverParam: string;
2031
- enumValues: undefined;
2032
- }>, typebox2.StaticType<[], "Decode", {}, {}, TDocument>>;
2033
- //#endregion
2034
- //#region src/index.d.ts
2035
- declare module "alepha" {
2036
- interface Hooks {
2037
- /**
2038
- * Fires before creating an entity in the repository.
2039
- */
2040
- "repository:create:before": {
2041
- tableName: string;
2042
- data: any;
2043
- };
2044
- /**
2045
- * Fires after creating an entity in the repository.
2046
- */
2047
- "repository:create:after": {
2048
- tableName: string;
2049
- data: any;
2050
- entity: any;
2051
- };
2052
- /**
2053
- * Fires before updating entities in the repository.
2054
- */
2055
- "repository:update:before": {
2056
- tableName: string;
2057
- where: any;
2058
- data: any;
2059
- };
2060
- /**
2061
- * Fires after updating entities in the repository.
2062
- */
2063
- "repository:update:after": {
2064
- tableName: string;
2065
- where: any;
2066
- data: any;
2067
- entities: any[];
2068
- };
2069
- /**
2070
- * Fires before deleting entities from the repository.
2071
- */
2072
- "repository:delete:before": {
2073
- tableName: string;
2074
- where: any;
2075
- };
2076
- /**
2077
- * Fires after deleting entities from the repository.
2078
- */
2079
- "repository:delete:after": {
2080
- tableName: string;
2081
- where: any;
2082
- ids: Array<string | number>;
2083
- };
2084
- /**
2085
- * Fires before reading entities from the repository.
2086
- */
2087
- "repository:read:before": {
2088
- tableName: string;
2089
- query: any;
2090
- };
2091
- /**
2092
- * Fires after reading entities from the repository.
2093
- */
2094
- "repository:read:after": {
2095
- tableName: string;
2096
- query: any;
2097
- entities: any[];
2098
- };
2099
- }
2100
- }
2101
- /**
2102
- * Postgres client based on Drizzle ORM, Alepha type-safe friendly.
2103
- *
2104
- * ```ts
2105
- * const users = $entity({
2106
- * name: "users",
2107
- * schema: t.object({
2108
- * id: pg.primaryKey(),
2109
- * name: t.text(),
2110
- * email: t.text(),
2111
- * }),
2112
- * });
2113
- *
2114
- * class Db {
2115
- * users = $repository(users);
2116
- * }
2117
- *
2118
- * const db = alepha.inject(Db);
2119
- * const user = await db.users.one({ name: { eq: "John Doe" } });
2120
- * ```
2121
- *
2122
- * This is not a full ORM, but rather a set of tools to work with Postgres databases in a type-safe way.
2123
- *
2124
- * It provides:
2125
- * - A type-safe way to define entities and repositories. (via `$entity` and `$repository`)
2126
- * - Custom query builders and filters.
2127
- * - Built-in special columns like `createdAt`, `updatedAt`, `deletedAt`, `version`.
2128
- * - Automatic JSONB support.
2129
- * - Automatic synchronization of entities with the database schema (for testing and development).
2130
- * - Fallback to raw SQL via Drizzle ORM `sql` function.
2131
- *
2132
- * Migrations are supported via Drizzle ORM, you need to use the `drizzle-kit` CLI tool to generate and run migrations.
2133
- *
2134
- * @see {@link $entity}
2135
- * @see {@link $sequence}
2136
- * @see {@link $repository}
2137
- * @see {@link $transaction}
2138
- * @module alepha.postgres
2139
- */
2140
- declare const AlephaPostgres: _alepha_core10.Service<_alepha_core10.Module>;
2141
- //#endregion
2142
- export { $entity, $repository, $sequence, $transaction, AlephaPostgres, DatabaseProvider, DbError, DrizzleKitProvider, EntityColumn, EntityColumns, EntityDescriptor, EntityDescriptorOptions, FilterOperators, FromSchema, NodePostgresProvider, NodeSqliteProvider, NodeSqliteProviderOptions, OrderBy, OrderByClause, OrderDirection, PG_CREATED_AT, PG_DEFAULT, PG_DELETED_AT, PG_ENUM, PG_IDENTITY, PG_PRIMARY_KEY, PG_REF, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, type Page, type PageQuery, PgAttr, PgAttrField, PgConflictError, PgDefault, PgEntityNotFoundError, PgEnumOptions, PgIdentityOptions, PgMigrationError, PgPrimaryKey, PgQuery, PgQueryRelations, PgQueryWhere, PgQueryWhereOrSQL, PgRef, PgRefOptions, PgRelation, PgRelationMap, PgStatic, PgSymbolKeys, PgSymbols, PgVersionMismatchError, PostgresTypeProvider, Repository, RepositoryProvider, SQLLike, SchemaToTableConfig, SequenceDescriptor, SequenceDescriptorOptions, StatementOptions, TObjectInsert, TObjectUpdate, TransactionContext, TransactionDescriptorOptions, buildQueryString, drizzle_orm0 as drizzle, getAttrFields, insertSchema, legacyIdSchema, nodeSqliteOptions, pageQuerySchema, pageSchema, parseQueryString, pg, pgAttr, schema, sql, updateSchema };
2143
- //# sourceMappingURL=index.d.ts.map