alepha 0.9.2 → 0.9.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alepha",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -15,50 +15,49 @@
15
15
  "main": "./core.js",
16
16
  "types": "./core.d.ts",
17
17
  "dependencies": {
18
- "@alepha/batch": "0.9.2",
19
- "@alepha/bucket": "0.9.2",
20
- "@alepha/cache": "0.9.2",
21
- "@alepha/cache-redis": "0.9.2",
22
- "@alepha/command": "0.9.2",
23
- "@alepha/core": "0.9.2",
24
- "@alepha/datetime": "0.9.2",
25
- "@alepha/file": "0.9.2",
26
- "@alepha/lock": "0.9.2",
27
- "@alepha/lock-redis": "0.9.2",
28
- "@alepha/postgres": "0.9.2",
29
- "@alepha/queue": "0.9.2",
30
- "@alepha/queue-redis": "0.9.2",
31
- "@alepha/react": "0.9.2",
32
- "@alepha/react-auth": "0.9.2",
33
- "@alepha/react-form": "0.9.2",
34
- "@alepha/react-head": "0.9.2",
35
- "@alepha/react-i18n": "0.9.2",
36
- "@alepha/redis": "0.9.2",
37
- "@alepha/retry": "0.9.2",
38
- "@alepha/router": "0.9.2",
39
- "@alepha/scheduler": "0.9.2",
40
- "@alepha/security": "0.9.2",
41
- "@alepha/server": "0.9.2",
42
- "@alepha/server-cache": "0.9.2",
43
- "@alepha/server-compress": "0.9.2",
44
- "@alepha/server-cookies": "0.9.2",
45
- "@alepha/server-cors": "0.9.2",
46
- "@alepha/server-health": "0.9.2",
47
- "@alepha/server-helmet": "0.9.2",
48
- "@alepha/server-links": "0.9.2",
49
- "@alepha/server-metrics": "0.9.2",
50
- "@alepha/server-multipart": "0.9.2",
51
- "@alepha/server-proxy": "0.9.2",
52
- "@alepha/server-security": "0.9.2",
53
- "@alepha/server-static": "0.9.2",
54
- "@alepha/server-swagger": "0.9.2",
55
- "@alepha/testing": "0.9.2",
56
- "@alepha/topic": "0.9.2",
57
- "@alepha/topic-redis": "0.9.2",
58
- "@alepha/vite": "0.9.2"
18
+ "@alepha/batch": "0.9.3",
19
+ "@alepha/bucket": "0.9.3",
20
+ "@alepha/cache": "0.9.3",
21
+ "@alepha/cache-redis": "0.9.3",
22
+ "@alepha/command": "0.9.3",
23
+ "@alepha/core": "0.9.3",
24
+ "@alepha/datetime": "0.9.3",
25
+ "@alepha/file": "0.9.3",
26
+ "@alepha/lock": "0.9.3",
27
+ "@alepha/lock-redis": "0.9.3",
28
+ "@alepha/postgres": "0.9.3",
29
+ "@alepha/queue": "0.9.3",
30
+ "@alepha/queue-redis": "0.9.3",
31
+ "@alepha/react": "0.9.3",
32
+ "@alepha/react-auth": "0.9.3",
33
+ "@alepha/react-form": "0.9.3",
34
+ "@alepha/react-head": "0.9.3",
35
+ "@alepha/react-i18n": "0.9.3",
36
+ "@alepha/redis": "0.9.3",
37
+ "@alepha/retry": "0.9.3",
38
+ "@alepha/router": "0.9.3",
39
+ "@alepha/scheduler": "0.9.3",
40
+ "@alepha/security": "0.9.3",
41
+ "@alepha/server": "0.9.3",
42
+ "@alepha/server-cache": "0.9.3",
43
+ "@alepha/server-compress": "0.9.3",
44
+ "@alepha/server-cookies": "0.9.3",
45
+ "@alepha/server-cors": "0.9.3",
46
+ "@alepha/server-health": "0.9.3",
47
+ "@alepha/server-helmet": "0.9.3",
48
+ "@alepha/server-links": "0.9.3",
49
+ "@alepha/server-metrics": "0.9.3",
50
+ "@alepha/server-multipart": "0.9.3",
51
+ "@alepha/server-proxy": "0.9.3",
52
+ "@alepha/server-security": "0.9.3",
53
+ "@alepha/server-static": "0.9.3",
54
+ "@alepha/server-swagger": "0.9.3",
55
+ "@alepha/topic": "0.9.3",
56
+ "@alepha/topic-redis": "0.9.3",
57
+ "@alepha/vite": "0.9.3"
59
58
  },
60
59
  "devDependencies": {
61
- "tsdown": "^0.13.0"
60
+ "tsdown": "^0.13.2"
62
61
  },
63
62
  "scripts": {
64
63
  "build": "node build.ts"
@@ -259,11 +258,6 @@
259
258
  "require": "./server/swagger.cjs",
260
259
  "types": "./server/swagger.d.ts"
261
260
  },
262
- "./testing": {
263
- "import": "./testing.js",
264
- "require": "./testing.cjs",
265
- "types": "./testing.d.ts"
266
- },
267
261
  "./topic": {
268
262
  "import": "./topic.js",
269
263
  "require": "./topic.cjs",
@@ -319,7 +313,6 @@
319
313
  "server-security",
320
314
  "server-static",
321
315
  "server-swagger",
322
- "testing",
323
316
  "topic",
324
317
  "topic-redis",
325
318
  "vite"
package/postgres.d.ts CHANGED
@@ -1,29 +1,28 @@
1
- import * as _alepha_core24 from "alepha";
2
- import * as _alepha_core0$1 from "alepha";
1
+ import * as _alepha_core13 from "alepha";
3
2
  import * as _alepha_core1 from "alepha";
3
+ import * as _alepha_core2 from "alepha";
4
4
  import * as _alepha_core0 from "alepha";
5
- import { Alepha, Descriptor, KIND, Service, Static, TObject, TSchema as TSchema$1 } from "alepha";
6
- import * as drizzle_orm7 from "drizzle-orm";
7
- import * as drizzle_orm0$1 from "drizzle-orm";
5
+ import { Alepha, AlephaError, Descriptor, KIND, Service, Static, TObject, TSchema as TSchema$1 } from "alepha";
8
6
  import * as drizzle_orm0 from "drizzle-orm";
7
+ import * as drizzle_orm2 from "drizzle-orm";
8
+ import * as drizzle_orm9 from "drizzle-orm";
9
9
  import * as drizzle from "drizzle-orm";
10
10
  import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, TableConfig, sql } from "drizzle-orm";
11
11
  import * as pg$1 from "drizzle-orm/pg-core";
12
- import * as drizzle_orm_pg_core0$1 from "drizzle-orm/pg-core";
13
- import * as drizzle_orm_pg_core4 from "drizzle-orm/pg-core";
14
12
  import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
13
+ import * as drizzle_orm_pg_core4 from "drizzle-orm/pg-core";
14
+ import * as drizzle_orm_pg_core3 from "drizzle-orm/pg-core";
15
15
  import { AnyPgColumn, AnyPgTable, LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, PgTransactionConfig, TableConfig as TableConfig$1, UpdateDeleteAction } from "drizzle-orm/pg-core";
16
16
  import * as _alepha_lock0 from "alepha/lock";
17
17
  import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
18
18
  import postgres from "postgres";
19
19
  import * as _alepha_retry0 from "alepha/retry";
20
+ import * as _sinclair_typebox2 from "@sinclair/typebox";
20
21
  import * as _sinclair_typebox9 from "@sinclair/typebox";
21
- import * as _sinclair_typebox16 from "@sinclair/typebox";
22
- import * as _sinclair_typebox17 from "@sinclair/typebox";
23
- import * as _sinclair_typebox18 from "@sinclair/typebox";
24
- import * as _sinclair_typebox6 from "@sinclair/typebox";
22
+ import * as _sinclair_typebox10 from "@sinclair/typebox";
23
+ import * as _sinclair_typebox11 from "@sinclair/typebox";
25
24
  import * as _sinclair_typebox0 from "@sinclair/typebox";
26
- import { Evaluate, IntegerOptions, Kind, NumberOptions, ObjectOptions, OptionalKind, Static as Static$1, StringOptions, TAdditionalProperties, TArray, TBoolean, TInteger, TIntersect, TObject as TObject$1, TOptional, TOptionalWithFlag, TPick, TProperties, TReadonly, TRecord, TSchema as TSchema$2 } from "@sinclair/typebox";
25
+ import { Evaluate, IntegerOptions, Kind, NumberOptions, ObjectOptions, OptionalKind, Static as Static$1, StringOptions, TAdditionalProperties, TArray, TBoolean, TInteger, TIntersect, TNumber, TObject as TObject$1, TOptional, TOptionalWithFlag, TPick, TProperties, TReadonly, TRecord, TSchema as TSchema$2, TString } from "@sinclair/typebox";
27
26
  import { PgTransactionConfig as PgTransactionConfig$1 } from "drizzle-orm/pg-core/session";
28
27
  import * as DrizzleKit from "drizzle-kit/api";
29
28
  import { MigrationConfig } from "drizzle-orm/migrator";
@@ -122,14 +121,14 @@ declare const schemaToPgColumns: <T extends TObject>(schema: T) => FromSchema<T>
122
121
  * @param value The value of the field.
123
122
  * @returns The PG column.
124
123
  */
125
- declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSerialBuilderInitial<string> | pg$1.PgIntegerBuilderInitial<string> | drizzle_orm7.IsIdentity<pg$1.PgBigInt53BuilderInitial<"">, "always"> | pg$1.PgNumericBuilderInitial<string> | pg$1.PgTimestampBuilderInitial<string> | pg$1.PgUUIDBuilderInitial<string> | pg$1.PgCustomColumnBuilder<{
124
+ declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSerialBuilderInitial<string> | pg$1.PgIntegerBuilderInitial<string> | pg$1.PgBigInt53BuilderInitial<string> | pg$1.PgNumericBuilderInitial<string> | pg$1.PgTimestampBuilderInitial<string> | pg$1.PgUUIDBuilderInitial<string> | pg$1.PgCustomColumnBuilder<{
126
125
  name: string;
127
126
  dataType: "custom";
128
127
  columnType: "PgCustomColumn";
129
128
  data: Buffer<ArrayBufferLike>;
130
129
  driverParam: unknown;
131
130
  enumValues: undefined;
132
- }> | pg$1.PgTimestampStringBuilderInitial<string> | pg$1.PgDateStringBuilderInitial<string> | pg$1.PgTextBuilderInitial<string, [string, ...string[]]> | pg$1.PgBooleanBuilderInitial<string> | drizzle_orm7.$Type<pg$1.PgCustomColumnBuilder<{
131
+ }> | pg$1.PgTimestampStringBuilderInitial<string> | pg$1.PgDateStringBuilderInitial<string> | pg$1.PgTextBuilderInitial<string, [string, ...string[]]> | pg$1.PgBooleanBuilderInitial<string> | drizzle_orm0.$Type<pg$1.PgCustomColumnBuilder<{
133
132
  name: string;
134
133
  dataType: "custom";
135
134
  columnType: "PgCustomColumn";
@@ -142,14 +141,14 @@ declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSeria
142
141
  }>, {
143
142
  [x: string]: unknown;
144
143
  [x: number]: unknown;
145
- }> | drizzle_orm7.$Type<pg$1.PgCustomColumnBuilder<{
144
+ }> | drizzle_orm0.$Type<pg$1.PgCustomColumnBuilder<{
146
145
  name: string;
147
146
  dataType: "custom";
148
147
  columnType: "PgCustomColumn";
149
148
  data: {};
150
149
  driverParam: string;
151
150
  enumValues: undefined;
152
- }>, {}> | drizzle_orm7.$Type<pg$1.PgCustomColumnBuilder<{
151
+ }>, {}> | drizzle_orm0.$Type<pg$1.PgCustomColumnBuilder<{
153
152
  name: string;
154
153
  dataType: "custom";
155
154
  columnType: "PgCustomColumn";
@@ -283,7 +282,27 @@ interface TableLike<T extends TObject = TObject> {
283
282
  //#endregion
284
283
  //#region src/descriptors/$entity.d.ts
285
284
  /**
286
- * Creates a table descriptor for drizzle-orm.
285
+ * Declare a new entity in the database.
286
+ * This descriptor alone does not create the table, it only describes it.
287
+ * It must be used with `$repository` to create the table and perform operations on it.
288
+ *
289
+ * This is a convenience function to create a table with a json schema.
290
+ * For now, it creates a drizzle-orm table under the hood.
291
+ * ```ts
292
+ * import { $entity } from "alepha/postgres";
293
+ *
294
+ * const User = $entity({
295
+ * name: "user",
296
+ * schema: t.object({
297
+ * id: pg.primaryKey(t.uuid()),
298
+ * name: t.string(),
299
+ * email: t.string(),
300
+ * }),
301
+ * indexes: ["email"],
302
+ * });
303
+ * ```
304
+ *
305
+ * @stability 2
287
306
  */
288
307
  declare const $entity: {
289
308
  <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>): PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
@@ -321,11 +340,6 @@ interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1
321
340
  unique?: boolean;
322
341
  name?: string;
323
342
  })[];
324
- relations?: Record<string, {
325
- type: "one" | "many";
326
- table: () => any;
327
- foreignColumn?: keyof Static$1<T>;
328
- }>;
329
343
  foreignKeys?: Array<{
330
344
  name?: string;
331
345
  columns: Array<keyof Static$1<T>>;
@@ -365,6 +379,7 @@ type PgTableConfig<TTableName extends string, TSchema extends TObject$1, TColumn
365
379
  //#region src/helpers/nullToUndefined.d.ts
366
380
  /**
367
381
  * Replaces all null values in an object with undefined.
382
+ * We need this for converting all nulls from Drizzle outputs.
368
383
  *
369
384
  * @param value - The object to be processed.
370
385
  * @return A new object with all null values replaced with undefined.
@@ -860,15 +875,14 @@ declare abstract class PostgresProvider {
860
875
  abstract get schema(): string;
861
876
  abstract get dialect(): string;
862
877
  abstract execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static$1<T> : any>>;
863
- mapResult<T extends TObject$1 = any>(result: Array<any>, schema?: T): Array<T extends TObject$1 ? Static$1<T> : any>;
864
878
  }
865
879
  //# sourceMappingURL=PostgresProvider.d.ts.map
866
880
  //#endregion
867
881
  //#region src/schemas/pageQuerySchema.d.ts
868
- declare const pageQuerySchema: _sinclair_typebox9.TObject<{
869
- page: _sinclair_typebox9.TOptional<_sinclair_typebox9.TNumber>;
870
- size: _sinclair_typebox9.TOptional<_sinclair_typebox9.TNumber>;
871
- sort: _sinclair_typebox9.TOptional<_sinclair_typebox9.TString>;
882
+ declare const pageQuerySchema: _sinclair_typebox2.TObject<{
883
+ page: _sinclair_typebox2.TOptional<_sinclair_typebox2.TNumber>;
884
+ size: _sinclair_typebox2.TOptional<_sinclair_typebox2.TNumber>;
885
+ sort: _sinclair_typebox2.TOptional<_sinclair_typebox2.TString>;
872
886
  }>;
873
887
  type PageQuery = Static<typeof pageQuerySchema>;
874
888
  //# sourceMappingURL=pageQuerySchema.d.ts.map
@@ -913,7 +927,7 @@ type Page<T> = {
913
927
  //#endregion
914
928
  //#region src/descriptors/$repository.d.ts
915
929
  /**
916
- *
930
+ * @stability 3
917
931
  */
918
932
  declare const $repository: {
919
933
  <EntityTableConfig extends TableConfig, EntitySchema extends TObject$1>(optionsOrTable: RepositoryDescriptorOptions<EntityTableConfig, EntitySchema> | PgTableWithColumnsAndSchema<EntityTableConfig, EntitySchema>): RepositoryDescriptor<EntityTableConfig, EntitySchema>;
@@ -960,7 +974,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
960
974
  /**
961
975
  * Getter for the database connection from the database provider.
962
976
  */
963
- protected get db(): PgDatabase<any, Record<string, never>, drizzle_orm0$1.ExtractTablesWithRelations<Record<string, never>>>;
977
+ protected get db(): PgDatabase<any, Record<string, never>, drizzle_orm2.ExtractTablesWithRelations<Record<string, never>>>;
964
978
  protected organization(): PgColumn;
965
979
  /**
966
980
  * Execute a SQL query.
@@ -988,29 +1002,29 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
988
1002
  *
989
1003
  * @returns The SELECT query builder.
990
1004
  */
991
- protected select(opts?: StatementOptions): drizzle_orm_pg_core0$1.PgSelectBase<string, Record<string, PgColumn<drizzle_orm0$1.ColumnBaseConfig<drizzle_orm0$1.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
1005
+ protected select(opts?: StatementOptions): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, PgColumn<drizzle_orm2.ColumnBaseConfig<drizzle_orm2.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
992
1006
  [x: string]: unknown;
993
1007
  }[], {
994
- [x: string]: PgColumn<drizzle_orm0$1.ColumnBaseConfig<drizzle_orm0$1.ColumnDataType, string>, {}, {}>;
1008
+ [x: string]: PgColumn<drizzle_orm2.ColumnBaseConfig<drizzle_orm2.ColumnDataType, string>, {}, {}>;
995
1009
  }>;
996
1010
  /**
997
1011
  * Start an INSERT query on the table.
998
1012
  *
999
1013
  * @returns The INSERT query builder.
1000
1014
  */
1001
- protected insert(opts?: StatementOptions): drizzle_orm_pg_core0$1.PgInsertBuilder<PgTableWithColumns<EntityTableConfig>, any, false>;
1015
+ protected insert(opts?: StatementOptions): drizzle_orm_pg_core0.PgInsertBuilder<PgTableWithColumns<EntityTableConfig>, any, false>;
1002
1016
  /**
1003
1017
  * Start an UPDATE query on the table.
1004
1018
  *
1005
1019
  * @returns The UPDATE query builder.
1006
1020
  */
1007
- protected update(opts?: StatementOptions): drizzle_orm_pg_core0$1.PgUpdateBuilder<PgTableWithColumns<EntityTableConfig>, any>;
1021
+ protected update(opts?: StatementOptions): drizzle_orm_pg_core0.PgUpdateBuilder<PgTableWithColumns<EntityTableConfig>, any>;
1008
1022
  /**
1009
1023
  * Start a DELETE query on the table.
1010
1024
  *
1011
1025
  * @returns The DELETE query builder.
1012
1026
  */
1013
- protected delete(opts?: StatementOptions): drizzle_orm_pg_core0$1.PgDeleteBase<PgTableWithColumns<EntityTableConfig>, any, undefined, undefined, false, never>;
1027
+ protected delete(opts?: StatementOptions): drizzle_orm_pg_core0.PgDeleteBase<PgTableWithColumns<EntityTableConfig>, any, undefined, undefined, false, never>;
1014
1028
  /**
1015
1029
  * Find entities.
1016
1030
  *
@@ -1072,7 +1086,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1072
1086
  updateOne(query: PgQueryWhere<Static$1<EntitySchema>>, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>> | {
1073
1087
  $append: Partial<NullifyIfOptional<Static$1<EntitySchema>>>;
1074
1088
  }, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1075
- save(data: InferInsert<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1089
+ save(data: Static$1<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1076
1090
  /**
1077
1091
  * Update an entity by ID.
1078
1092
  *
@@ -1168,7 +1182,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1168
1182
  */
1169
1183
  protected getPrimaryKey(schema: TObject$1): {
1170
1184
  key: string;
1171
- col: PgColumn<drizzle_orm0$1.ColumnBaseConfig<drizzle_orm0$1.ColumnDataType, string>, {}, {}>;
1185
+ col: PgColumn<drizzle_orm2.ColumnBaseConfig<drizzle_orm2.ColumnDataType, string>, {}, {}>;
1172
1186
  type: TSchema$2;
1173
1187
  };
1174
1188
  }
@@ -1205,6 +1219,9 @@ interface PgAttrField {
1205
1219
  //# sourceMappingURL=$repository.d.ts.map
1206
1220
  //#endregion
1207
1221
  //#region src/descriptors/$sequence.d.ts
1222
+ /**
1223
+ * @stability 1
1224
+ */
1208
1225
  declare const $sequence: {
1209
1226
  (options?: SequenceDescriptorOptions): SequenceDescriptor;
1210
1227
  [KIND]: typeof SequenceDescriptor;
@@ -1229,7 +1246,7 @@ declare class SequenceDescriptor extends Descriptor<SequenceDescriptorOptions> {
1229
1246
  //#endregion
1230
1247
  //#region src/descriptors/$transaction.d.ts
1231
1248
  /**
1232
- *
1249
+ * @stability 2
1233
1250
  */
1234
1251
  declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry0.RetryDescriptorFn<(...args: T) => Promise<R>>;
1235
1252
  interface TransactionDescriptorOptions<T extends any[], R> {
@@ -1239,17 +1256,17 @@ interface TransactionDescriptorOptions<T extends any[], R> {
1239
1256
  type TransactionContext = PgTransaction<any, any, any>;
1240
1257
  //# sourceMappingURL=$transaction.d.ts.map
1241
1258
  //#endregion
1242
- //#region src/errors/EntityNotFoundError.d.ts
1243
- declare class EntityNotFoundError extends Error {
1244
- readonly code = "ERR_RESOURCE_NOTFOUND";
1259
+ //#region src/errors/PgEntityNotFoundError.d.ts
1260
+ declare class PgEntityNotFoundError extends AlephaError {
1261
+ readonly name = "EntityNotFoundError";
1245
1262
  readonly status = 404;
1246
1263
  constructor(entityName: string);
1247
1264
  }
1248
- //# sourceMappingURL=EntityNotFoundError.d.ts.map
1265
+ //# sourceMappingURL=PgEntityNotFoundError.d.ts.map
1249
1266
  //#endregion
1250
1267
  //#region src/providers/RepositoryDescriptorProvider.d.ts
1251
1268
  declare class RepositoryDescriptorProvider {
1252
- protected readonly log: _alepha_core24.Logger;
1269
+ protected readonly log: _alepha_core13.Logger;
1253
1270
  protected readonly alepha: Alepha;
1254
1271
  get repositories(): RepositoryDescriptor<TableConfig$1, TObject$1>[];
1255
1272
  constructor();
@@ -1275,10 +1292,11 @@ declare class RepositoryDescriptorProvider {
1275
1292
  //#endregion
1276
1293
  //#region src/providers/DrizzleKitProvider.d.ts
1277
1294
  declare class DrizzleKitProvider {
1278
- protected readonly log: _alepha_core0$1.Logger;
1295
+ protected readonly log: _alepha_core1.Logger;
1279
1296
  protected readonly alepha: Alepha;
1280
1297
  protected readonly repositoryProvider: RepositoryDescriptorProvider;
1281
1298
  push(provider: PostgresProvider, schema?: string): Promise<void>;
1299
+ setPgSchema(provider: PostgresProvider): Promise<void>;
1282
1300
  /**
1283
1301
  * Try to generate migrations from scratch based on the models.
1284
1302
  * Then, execute the migrations.
@@ -1314,81 +1332,98 @@ declare module "alepha" {
1314
1332
  interface Env extends Partial<Static<typeof envSchema>> {}
1315
1333
  }
1316
1334
  declare const envSchema: TObject$1<{
1317
- PG_HOST: _alepha_core1.TOptional<_alepha_core1.TString>;
1318
- PG_USERNAME: _alepha_core1.TOptional<_alepha_core1.TString>;
1319
- PG_DATABASE: _alepha_core1.TOptional<_alepha_core1.TString>;
1320
- PG_PASSWORD: _alepha_core1.TOptional<_alepha_core1.TString>;
1321
- PG_PORT: _alepha_core1.TOptional<_alepha_core1.TNumber>;
1322
- DATABASE_URL: _alepha_core1.TOptional<_alepha_core1.TString>;
1323
- DATABASE_MIGRATIONS_FOLDER: _alepha_core1.TString;
1324
1335
  /**
1325
- * The schema to use.
1326
- * Accept a string.
1336
+ * Main configuration for database connection.
1337
+ * Accept a string in the format of a Postgres connection URL.
1338
+ * Example: postgres://user:password@localhost:5432/database
1339
+ * or
1340
+ * Example: postgres://user:password@localhost:5432/database?sslmode=require
1327
1341
  */
1328
- POSTGRES_SCHEMA: _alepha_core1.TOptional<_alepha_core1.TString>;
1342
+ DATABASE_URL: _alepha_core2.TOptional<_alepha_core2.TString>;
1329
1343
  /**
1330
- * Synchronize the database schema with the models.
1331
- * Accept a boolean or a postgres schema name.
1344
+ * In addition to the DATABASE_URL, you can specify the postgres schema name.
1332
1345
  *
1333
- * @default false
1346
+ * It will monkey patch drizzle tables.
1334
1347
  */
1335
- POSTGRES_SYNCHRONIZE: _alepha_core1.TOptional<_alepha_core1.TBoolean>;
1348
+ POSTGRES_SCHEMA: _alepha_core2.TOptional<_alepha_core2.TString>;
1336
1349
  /**
1337
- * Push the schema to the database.
1350
+ * Synchronize the database schema with the models.
1351
+ * It uses a custom implementation, it's not related to `drizzle-kit push` command.
1352
+ * It will generate the migration script and save it to the DB.
1353
+ *
1354
+ * This is recommended for development and testing purposes only.
1338
1355
  *
1339
1356
  * @default false
1340
1357
  */
1341
- POSTGRES_PUSH_SCHEMA: _alepha_core1.TOptional<_alepha_core1.TBoolean>;
1358
+ POSTGRES_SYNCHRONIZE: _alepha_core2.TOptional<_alepha_core2.TBoolean>;
1342
1359
  /**
1343
- * Reject unauthorized SSL connections.
1360
+ * Push the schema to the database.
1361
+ * It's like `drizzle-kit push` command.
1362
+ * It will introspect the models from DB and generate the SQL statements to create or update the tables.
1344
1363
  *
1345
1364
  * @default false
1346
1365
  */
1347
- POSTGRES_REJECT_UNAUTHORIZED: _alepha_core1.TBoolean;
1366
+ POSTGRES_PUSH: _alepha_core2.TOptional<_alepha_core2.TBoolean>;
1348
1367
  }>;
1349
- interface NodePostgresProviderState {
1350
- client: postgres.Sql;
1351
- db: PostgresJsDatabase;
1368
+ interface NodePostgresProviderOptions {
1369
+ migrations: MigrationConfig;
1370
+ connection: postgres.Options<any>;
1352
1371
  }
1353
1372
  declare class NodePostgresProvider extends PostgresProvider {
1354
1373
  readonly dialect = "postgres";
1355
- protected readonly log: _alepha_core1.Logger;
1374
+ protected readonly sslModes: readonly ["require", "allow", "prefer", "verify-full"];
1375
+ protected readonly log: _alepha_core2.Logger;
1356
1376
  protected readonly env: {
1357
- PG_HOST?: string | undefined;
1358
- PG_USERNAME?: string | undefined;
1359
- PG_DATABASE?: string | undefined;
1360
- PG_PASSWORD?: string | undefined;
1361
- PG_PORT?: number | undefined;
1362
1377
  DATABASE_URL?: string | undefined;
1363
1378
  POSTGRES_SCHEMA?: string | undefined;
1364
1379
  POSTGRES_SYNCHRONIZE?: boolean | undefined;
1365
- POSTGRES_PUSH_SCHEMA?: boolean | undefined;
1366
- DATABASE_MIGRATIONS_FOLDER: string;
1367
- POSTGRES_REJECT_UNAUTHORIZED: boolean;
1380
+ POSTGRES_PUSH?: boolean | undefined;
1368
1381
  };
1369
1382
  protected readonly alepha: Alepha;
1370
1383
  protected readonly kit: DrizzleKitProvider;
1371
- protected state?: NodePostgresProviderState;
1384
+ protected client?: postgres.Sql;
1385
+ protected pg?: PostgresJsDatabase;
1386
+ readonly options: NodePostgresProviderOptions;
1372
1387
  /**
1373
1388
  * In testing mode, the schema name will be generated and deleted after the test.
1374
1389
  */
1375
- protected testingSchemaName?: string;
1376
- get db(): PostgresJsDatabase;
1377
- protected readonly configure: _alepha_core1.HookDescriptor<"start">;
1378
- protected readonly stop: _alepha_core1.HookDescriptor<"stop">;
1390
+ protected schemaForTesting?: string;
1379
1391
  /**
1380
1392
  * Get Postgres schema.
1381
1393
  */
1382
1394
  get schema(): string;
1395
+ get db(): PostgresJsDatabase;
1396
+ protected readonly configure: _alepha_core2.HookDescriptor<"start">;
1397
+ protected readonly stop: _alepha_core2.HookDescriptor<"stop">;
1383
1398
  execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static<T> : any>>;
1384
1399
  connect(): Promise<void>;
1385
1400
  close(): Promise<void>;
1386
1401
  protected migrate: _alepha_lock0.LockDescriptor<() => Promise<void>>;
1387
- protected createClient(): NodePostgresProviderState;
1402
+ protected createClient(): {
1403
+ client: postgres.Sql<{}>;
1404
+ db: PostgresJsDatabase<Record<string, never>> & {
1405
+ $client: postgres.Sql<{}>;
1406
+ };
1407
+ };
1408
+ /**
1409
+ * Generate a minimal migration configuration.
1410
+ */
1388
1411
  protected getMigrationOptions(): MigrationConfig;
1412
+ /**
1413
+ * Map the DATABASE_URL to postgres client options.
1414
+ */
1389
1415
  protected getClientOptions(): postgres.Options<any>;
1390
- protected sslModes: readonly ["require", "allow", "prefer", "verify-full"];
1391
- protected ssl(url: URL | undefined): "require" | "allow" | "prefer" | "verify-full" | undefined;
1416
+ protected ssl(url: URL): "require" | "allow" | "prefer" | "verify-full" | undefined;
1417
+ /**
1418
+ * For testing purposes, generate a unique schema name.
1419
+ * The schema name will be generated based on the current date and time.
1420
+ * It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
1421
+ *
1422
+ * TODO: investigate for adding the test file name to the schema name if possible.
1423
+ * TODO: options to skip deletion on failure, in order to inspect the schema?
1424
+ */
1425
+ protected generateTestSchemaName(): string;
1426
+ protected mapResult<T extends TObject$1 = any>(result: Array<any>, schema?: T): Array<T extends TObject$1 ? Static<T> : any>;
1392
1427
  }
1393
1428
  //#endregion
1394
1429
  //#region src/helpers/pgAttr.d.ts
@@ -1398,7 +1433,7 @@ declare class NodePostgresProvider extends PostgresProvider {
1398
1433
  type PgAttr<T extends TSchema$1, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
1399
1434
  //#endregion
1400
1435
  //#region src/schemas/createdAtSchema.d.ts
1401
- declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox16.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1436
+ declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox9.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1402
1437
  //# sourceMappingURL=createdAtSchema.d.ts.map
1403
1438
 
1404
1439
  //#endregion
@@ -1406,11 +1441,11 @@ declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox16.TString, typeof
1406
1441
  /**
1407
1442
  * @deprecated Use `pg.primaryKey()` instead.
1408
1443
  */
1409
- declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox17.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1444
+ declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox10.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1410
1445
  //# sourceMappingURL=legacyIdSchema.d.ts.map
1411
1446
  //#endregion
1412
1447
  //#region src/schemas/updatedAtSchema.d.ts
1413
- declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox18.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1448
+ declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox11.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1414
1449
  //# sourceMappingURL=updatedAtSchema.d.ts.map
1415
1450
 
1416
1451
  //#endregion
@@ -1421,9 +1456,9 @@ declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox18.TString, typeof
1421
1456
  * Add some common SQL properties to an object.
1422
1457
  */
1423
1458
  declare const entitySchema: TObject$1<{
1424
- id: PgAttr<PgAttr<PgAttr<_sinclair_typebox6.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1425
- createdAt: PgAttr<PgAttr<_sinclair_typebox6.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1426
- updatedAt: PgAttr<PgAttr<_sinclair_typebox6.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1459
+ id: PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1460
+ createdAt: PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1461
+ updatedAt: PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1427
1462
  }>;
1428
1463
  /**
1429
1464
  * TypeBox Entity Type.
@@ -1458,19 +1493,21 @@ declare class PostgresTypeProvider {
1458
1493
  /**
1459
1494
  * Creates a primary key with an identity column.
1460
1495
  */
1461
- readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1496
+ readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1462
1497
  /**
1463
1498
  * Creates a primary key with a big identity column. (default)
1464
1499
  */
1465
- readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1500
+ readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1466
1501
  /**
1467
1502
  * Creates a primary key with a UUID column.
1468
1503
  */
1469
- readonly uuidPrimaryKey: () => PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1504
+ readonly uuidPrimaryKey: () => PgAttr<PgAttr<TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1470
1505
  /**
1471
- * @alias bigIdentityPrimaryKey
1506
+ *
1472
1507
  */
1473
- readonly primaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1508
+ primaryKey(type: TString): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
1509
+ primaryKey(type: TInteger): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
1510
+ primaryKey(type: TNumber): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
1474
1511
  /**
1475
1512
  * Wrap a schema with "default" attribute.
1476
1513
  * This is used to set a default value for a column in the database.
@@ -1481,15 +1518,15 @@ declare class PostgresTypeProvider {
1481
1518
  * This is used to track the version of a row in the database.
1482
1519
  * You can use it for optimistic concurrency control.
1483
1520
  */
1484
- readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<_sinclair_typebox0.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
1521
+ readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
1485
1522
  /**
1486
1523
  * Creates a column Created At. So just a datetime column with a default value of the current timestamp.
1487
1524
  */
1488
- readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1525
+ readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1489
1526
  /**
1490
1527
  * Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
1491
1528
  */
1492
- readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1529
+ readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1493
1530
  /**
1494
1531
  * @deprecated Build your own entity schema.
1495
1532
  */
@@ -1535,7 +1572,7 @@ declare const pg: PostgresTypeProvider;
1535
1572
  /**
1536
1573
  * Postgres schema type.
1537
1574
  */
1538
- declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) => drizzle_orm0.$Type<drizzle_orm_pg_core0.PgCustomColumnBuilder<{
1575
+ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) => drizzle_orm9.$Type<drizzle_orm_pg_core3.PgCustomColumnBuilder<{
1539
1576
  name: string;
1540
1577
  dataType: "custom";
1541
1578
  columnType: "PgCustomColumn";
@@ -1563,9 +1600,9 @@ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDoc
1563
1600
  * @see {@link $transaction}
1564
1601
  * @module alepha.postgres
1565
1602
  */
1566
- declare const AlephaPostgres: _alepha_core0.ModuleDescriptor;
1603
+ declare const AlephaPostgres: _alepha_core0.Service<_alepha_core0.Module>;
1567
1604
  //# sourceMappingURL=index.d.ts.map
1568
1605
 
1569
1606
  //#endregion
1570
- export { $entity, $repository, $sequence, $transaction, AlephaPostgres, BaseEntity, BaseEntityKeys, DrizzleKitProvider, Entity, EntityDescriptorOptions, EntityNotFoundError, ExtractManyRelations, FilterOperators, FromSchema, NodePostgresProvider, NodePostgresProviderState, NullToUndefined, NullifyIfOptional, PG_CREATED_AT, PG_DEFAULT, PG_IDENTITY, PG_MANY, PG_ONE, PG_PRIMARY_KEY, PG_REF, PG_SCHEMA, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, Page, PageQuery, PgAttrField, PgDefault, PgIdentityOptions, PgMany, PgManyOptions, PgPrimaryKey, PgQuery, PgQueryResult, PgQueryWhere, PgQueryWhereWithMany, PgQueryWith, PgQueryWithMap, PgRef, PgRefOptions, PgSymbolKeys, PgSymbols, PgTableConfig, PgTableWithColumnsAndSchema, PostgresProvider, PostgresTypeProvider, RemoveManyRelations, RepositoryDescriptor, RepositoryDescriptorOptions, RepositoryDescriptorProvider, SQLLike, SequenceDescriptor, SequenceDescriptorOptions, StatementOptions, TEntity, TInsertObject, TPage, TableLike, TransactionContext, TransactionDescriptorOptions, camelToSnakeCase, drizzle, entityKeys, entitySchema, mapFieldToColumn, mapStringToColumn, nullToUndefined, pageQuerySchema, pageSchema, pg, pgTableSchema, schema, schemaToPgColumns, sql };
1607
+ export { $entity, $repository, $sequence, $transaction, AlephaPostgres, BaseEntity, BaseEntityKeys, DrizzleKitProvider, Entity, EntityDescriptorOptions, ExtractManyRelations, FilterOperators, FromSchema, NodePostgresProvider, NodePostgresProviderOptions, NullToUndefined, NullifyIfOptional, PG_CREATED_AT, PG_DEFAULT, PG_IDENTITY, PG_MANY, PG_ONE, PG_PRIMARY_KEY, PG_REF, PG_SCHEMA, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, Page, PageQuery, PgAttrField, PgDefault, PgEntityNotFoundError, PgIdentityOptions, PgMany, PgManyOptions, PgPrimaryKey, PgQuery, PgQueryResult, PgQueryWhere, PgQueryWhereWithMany, PgQueryWith, PgQueryWithMap, PgRef, PgRefOptions, PgSymbolKeys, PgSymbols, PgTableConfig, PgTableWithColumnsAndSchema, PostgresProvider, PostgresTypeProvider, RemoveManyRelations, RepositoryDescriptor, RepositoryDescriptorOptions, RepositoryDescriptorProvider, SQLLike, SequenceDescriptor, SequenceDescriptorOptions, StatementOptions, TEntity, TInsertObject, TPage, TableLike, TransactionContext, TransactionDescriptorOptions, camelToSnakeCase, drizzle, entityKeys, entitySchema, mapFieldToColumn, mapStringToColumn, nullToUndefined, pageQuerySchema, pageSchema, pg, pgTableSchema, schema, schemaToPgColumns, sql };
1571
1608
  //# sourceMappingURL=index.d.ts.map
package/queue/redis.d.ts CHANGED
@@ -23,7 +23,7 @@ declare class RedisQueueProvider implements QueueProvider {
23
23
  * @see {@link RedisQueueProvider}
24
24
  * @module alepha.queue.redis
25
25
  */
26
- declare const AlephaQueueRedis: _alepha_core0.ModuleDescriptor;
26
+ declare const AlephaQueueRedis: _alepha_core0.Service<_alepha_core0.Module>;
27
27
  //# sourceMappingURL=index.d.ts.map
28
28
 
29
29
  //#endregion