alepha 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/postgres.d.ts CHANGED
@@ -1,26 +1,28 @@
1
- import * as _alepha_core55 from "alepha";
2
- import * as _alepha_core19 from "alepha";
3
- import * as _alepha_core21 from "alepha";
4
- import { Alepha, KIND, Module, OPTIONS, Static, TObject, TSchema as TSchema$1 } from "alepha";
5
- import * as drizzle_orm3 from "drizzle-orm";
6
- import * as drizzle_orm8 from "drizzle-orm";
7
- import * as drizzle_orm2 from "drizzle-orm";
1
+ import * as _alepha_core24 from "alepha";
2
+ import * as _alepha_core0$1 from "alepha";
3
+ import * as _alepha_core1 from "alepha";
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";
8
+ import * as drizzle_orm0 from "drizzle-orm";
8
9
  import * as drizzle from "drizzle-orm";
9
10
  import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, TableConfig, sql } from "drizzle-orm";
10
- import * as _alepha_lock44 from "alepha/lock";
11
- import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
12
- import postgres from "postgres";
13
11
  import * as pg$1 from "drizzle-orm/pg-core";
14
- import * as drizzle_orm_pg_core13 from "drizzle-orm/pg-core";
15
- import * as drizzle_orm_pg_core1 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
+ import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
16
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";
17
- import * as _alepha_retry81 from "alepha/retry";
18
- import * as _sinclair_typebox74 from "@sinclair/typebox";
19
- import * as _sinclair_typebox89 from "@sinclair/typebox";
20
- import * as _sinclair_typebox85 from "@sinclair/typebox";
21
- import * as _sinclair_typebox82 from "@sinclair/typebox";
22
- import * as _sinclair_typebox57 from "@sinclair/typebox";
23
- import * as _sinclair_typebox48 from "@sinclair/typebox";
16
+ import * as _alepha_lock0 from "alepha/lock";
17
+ import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
18
+ import postgres from "postgres";
19
+ import * as _alepha_retry0 from "alepha/retry";
20
+ import * as _sinclair_typebox9 from "@sinclair/typebox";
21
+ import * as _sinclair_typebox17 from "@sinclair/typebox";
22
+ import * as _sinclair_typebox18 from "@sinclair/typebox";
23
+ import * as _sinclair_typebox16 from "@sinclair/typebox";
24
+ import * as _sinclair_typebox6 from "@sinclair/typebox";
25
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
24
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
27
  import { PgTransactionConfig as PgTransactionConfig$1 } from "drizzle-orm/pg-core/session";
26
28
  import * as DrizzleKit from "drizzle-kit/api";
@@ -28,6 +30,10 @@ import { MigrationConfig } from "drizzle-orm/migrator";
28
30
  import { UpdateDeleteAction as UpdateDeleteAction$1 } from "drizzle-orm/pg-core/foreign-keys";
29
31
  export * from "drizzle-orm/pg-core";
30
32
 
33
+ //#region src/constants/PG_SCHEMA.d.ts
34
+ declare const PG_SCHEMA: unique symbol;
35
+ //# sourceMappingURL=PG_SCHEMA.d.ts.map
36
+ //#endregion
31
37
  //#region src/constants/PG_SYMBOLS.d.ts
32
38
  declare const PG_DEFAULT: unique symbol;
33
39
  declare const PG_PRIMARY_KEY: unique symbol;
@@ -116,14 +122,14 @@ declare const schemaToPgColumns: <T extends TObject>(schema: T) => FromSchema<T>
116
122
  * @param value The value of the field.
117
123
  * @returns The PG column.
118
124
  */
119
- declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSerialBuilderInitial<string> | pg$1.PgIntegerBuilderInitial<string> | drizzle_orm3.IsIdentity<pg$1.PgBigInt53BuilderInitial<"">, "always"> | pg$1.PgNumericBuilderInitial<string> | pg$1.PgTimestampBuilderInitial<string> | pg$1.PgUUIDBuilderInitial<string> | pg$1.PgCustomColumnBuilder<{
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<{
120
126
  name: string;
121
127
  dataType: "custom";
122
128
  columnType: "PgCustomColumn";
123
129
  data: Buffer<ArrayBufferLike>;
124
130
  driverParam: unknown;
125
131
  enumValues: undefined;
126
- }> | pg$1.PgTimestampStringBuilderInitial<string> | pg$1.PgDateStringBuilderInitial<string> | pg$1.PgTextBuilderInitial<string, [string, ...string[]]> | pg$1.PgBooleanBuilderInitial<string> | drizzle_orm3.$Type<pg$1.PgCustomColumnBuilder<{
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<{
127
133
  name: string;
128
134
  dataType: "custom";
129
135
  columnType: "PgCustomColumn";
@@ -136,14 +142,14 @@ declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSeria
136
142
  }>, {
137
143
  [x: string]: unknown;
138
144
  [x: number]: unknown;
139
- }> | drizzle_orm3.$Type<pg$1.PgCustomColumnBuilder<{
145
+ }> | drizzle_orm7.$Type<pg$1.PgCustomColumnBuilder<{
140
146
  name: string;
141
147
  dataType: "custom";
142
148
  columnType: "PgCustomColumn";
143
149
  data: {};
144
150
  driverParam: string;
145
151
  enumValues: undefined;
146
- }>, {}> | drizzle_orm3.$Type<pg$1.PgCustomColumnBuilder<{
152
+ }>, {}> | drizzle_orm7.$Type<pg$1.PgCustomColumnBuilder<{
147
153
  name: string;
148
154
  dataType: "custom";
149
155
  columnType: "PgCustomColumn";
@@ -275,6 +281,87 @@ interface TableLike<T extends TObject = TObject> {
275
281
  }
276
282
  //# sourceMappingURL=schemaToPgColumns.d.ts.map
277
283
  //#endregion
284
+ //#region src/descriptors/$entity.d.ts
285
+ /**
286
+ * Creates a table descriptor for drizzle-orm.
287
+ */
288
+ declare const $entity: {
289
+ <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>): PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
290
+ [KIND]: string;
291
+ };
292
+ interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1, Keys = keyof Static$1<T>> {
293
+ /**
294
+ * The name of the table. This is the name that will be used in the database.
295
+ * @example
296
+ * name: "user"
297
+ */
298
+ name: TTableName;
299
+ /**
300
+ * The schema of the table. This is a TypeBox schema that describes the columns and their types.
301
+ * @example
302
+ * schema: t.object({
303
+ * id: t.uuid(),
304
+ * name: t.string(),
305
+ * email: t.string(),
306
+ * phoneNumber: t.string(),
307
+ * })
308
+ */
309
+ schema: T;
310
+ /**
311
+ * The indexes to create for the table. This can be a string or an object with the column name and options.
312
+ * @example
313
+ * indexes: ["name", { column: "email", unique: true }]
314
+ */
315
+ indexes?: (Keys | {
316
+ column: Keys;
317
+ unique?: boolean;
318
+ name?: string;
319
+ } | {
320
+ columns: Keys[];
321
+ unique?: boolean;
322
+ name?: string;
323
+ })[];
324
+ relations?: Record<string, {
325
+ type: "one" | "many";
326
+ table: () => any;
327
+ foreignColumn?: keyof Static$1<T>;
328
+ }>;
329
+ foreignKeys?: Array<{
330
+ name?: string;
331
+ columns: Array<keyof Static$1<T>>;
332
+ foreignColumns: Array<AnyPgColumn>;
333
+ }>;
334
+ constraints?: Array<{
335
+ columns: Array<keyof Static$1<T>>;
336
+ name?: string;
337
+ unique?: boolean | {};
338
+ check?: SQL;
339
+ }>;
340
+ /**
341
+ * Extra configuration for the table. See drizzle-orm documentation for more details.
342
+ *
343
+ * @param self The table descriptor.
344
+ * @returns The extra configuration for the table.
345
+ */
346
+ config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
347
+ }
348
+ type Entity<T extends TObject$1> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
349
+ /**
350
+ * Create a table with a json schema.
351
+ *
352
+ * @param name The name of the table.
353
+ * @param schema The json schema of the table.
354
+ * @param extraConfig Extra configuration for the table.
355
+ */
356
+ declare const pgTableSchema: <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(name: TTableName, schema: TSchema, extraConfig?: (self: BuildExtraConfigColumns<TTableName, TColumnsMap, "pg">) => PgTableExtraConfigValue[]) => PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
357
+ type PgTableConfig<TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>> = {
358
+ name: TTableName;
359
+ schema: any;
360
+ columns: BuildColumns<TTableName, TColumnsMap, "pg">;
361
+ dialect: "pg";
362
+ };
363
+ //# sourceMappingURL=$entity.d.ts.map
364
+ //#endregion
278
365
  //#region src/helpers/nullToUndefined.d.ts
279
366
  /**
280
367
  * Replaces all null values in an object with undefined.
@@ -778,10 +865,10 @@ declare abstract class PostgresProvider {
778
865
  //# sourceMappingURL=PostgresProvider.d.ts.map
779
866
  //#endregion
780
867
  //#region src/schemas/pageQuerySchema.d.ts
781
- declare const pageQuerySchema: _sinclair_typebox74.TObject<{
782
- page: _sinclair_typebox74.TOptional<_sinclair_typebox74.TNumber>;
783
- size: _sinclair_typebox74.TOptional<_sinclair_typebox74.TNumber>;
784
- sort: _sinclair_typebox74.TOptional<_sinclair_typebox74.TString>;
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>;
785
872
  }>;
786
873
  type PageQuery = Static<typeof pageQuerySchema>;
787
874
  //# sourceMappingURL=pageQuerySchema.d.ts.map
@@ -824,19 +911,32 @@ type Page<T> = {
824
911
  };
825
912
  //# sourceMappingURL=pageSchema.d.ts.map
826
913
  //#endregion
827
- //#region src/services/Repository.d.ts
828
- declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTableSchema extends TObject$1> {
914
+ //#region src/descriptors/$repository.d.ts
915
+ /**
916
+ *
917
+ */
918
+ declare const $repository: {
919
+ <EntityTableConfig extends TableConfig, EntitySchema extends TObject$1>(optionsOrTable: RepositoryDescriptorOptions<EntityTableConfig, EntitySchema> | PgTableWithColumnsAndSchema<EntityTableConfig, EntitySchema>): RepositoryDescriptor<EntityTableConfig, EntitySchema>;
920
+ [KIND]: typeof RepositoryDescriptor;
921
+ };
922
+ interface RepositoryDescriptorOptions<EntityTableConfig extends TableConfig, EntitySchema extends TObject$1> {
923
+ /**
924
+ * The table to create the repository for.
925
+ */
926
+ table: PgTableWithColumnsAndSchema<EntityTableConfig, EntitySchema>;
927
+ /**
928
+ * Override default provider.
929
+ */
930
+ provider?: Service<PostgresProvider>;
931
+ }
932
+ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, EntitySchema extends TObject$1> extends Descriptor<RepositoryDescriptorOptions<EntityTableConfig, EntitySchema>> {
829
933
  readonly provider: PostgresProvider;
830
934
  protected readonly alepha: Alepha;
935
+ readonly schema: EntitySchema;
936
+ readonly insertSchema: TInsertObject<EntitySchema>;
831
937
  protected readonly env: {
832
938
  POSTGRES_PAGINATION_COUNT_ENABLED: boolean;
833
939
  };
834
- static of: <TEntity extends TableConfig$1, TTableSchema_1 extends TObject$1>(opts: PgTableWithColumnsAndSchema<TEntity, TTableSchema_1>) => (new () => Repository<PgTableWithColumns<TEntity>, TTableSchema_1>);
835
- /**
836
- * Register Repository as a valid descriptor.
837
- * - Required for $repository to work.
838
- */
839
- [KIND]: string;
840
940
  /**
841
941
  * Represents the primary key of the table.
842
942
  * - Key is the name of the primary key column.
@@ -846,33 +946,13 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
846
946
  */
847
947
  readonly id: {
848
948
  type: TSchema$2;
849
- key: keyof TTableSchema["properties"];
949
+ key: keyof EntitySchema["properties"];
850
950
  col: PgColumn;
851
951
  };
852
- [OPTIONS]: {
853
- table: TTable;
854
- schema: TTableSchema;
855
- };
856
- readonly options: {
857
- table: TTable;
858
- schema: TTableSchema;
859
- };
860
- constructor(options: {
861
- table: TTable;
862
- schema: TTableSchema;
863
- });
864
- /**
865
- * Get the table schema.
866
- */
867
- get schema(): TTableSchema;
868
- /**
869
- * Get the insert schema.
870
- */
871
- get insertSchema(): TInsertObject<TTableSchema>;
872
952
  /**
873
953
  * Get Drizzle table object.
874
954
  */
875
- get table(): TTable;
955
+ get table(): PgTableWithColumns<EntityTableConfig>;
876
956
  /**
877
957
  * Get SQL table name. (from Drizzle table object)
878
958
  */
@@ -880,7 +960,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
880
960
  /**
881
961
  * Getter for the database connection from the database provider.
882
962
  */
883
- protected get db(): PgDatabase<any, Record<string, never>, drizzle_orm8.ExtractTablesWithRelations<Record<string, never>>>;
963
+ protected get db(): PgDatabase<any, Record<string, never>, drizzle_orm0$1.ExtractTablesWithRelations<Record<string, never>>>;
884
964
  protected organization(): PgColumn;
885
965
  /**
886
966
  * Execute a SQL query.
@@ -888,14 +968,14 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
888
968
  * @param query
889
969
  * @param schema
890
970
  */
891
- execute<T extends TObject$1 = TTableSchema>(query: SQLLike | ((table: TTable, db: PgDatabase<any>) => SQLLike), schema?: T): Promise<Static$1<T>[]>;
971
+ execute<T extends TObject$1 = EntitySchema>(query: SQLLike | ((table: PgTableWithColumns<EntityTableConfig>, db: PgDatabase<any>) => SQLLike), schema?: T): Promise<Static$1<T>[]>;
892
972
  /**
893
973
  * Get a Drizzle column from the table by his name.
894
974
  *
895
975
  * @param name - The name of the column to get.
896
976
  * @returns The column from the table.
897
977
  */
898
- protected col(name: keyof TTable["_"]["columns"]): PgColumn;
978
+ protected col(name: keyof PgTableWithColumns<EntityTableConfig>["_"]["columns"]): PgColumn;
899
979
  /**
900
980
  * Run a transaction.
901
981
  *
@@ -908,29 +988,29 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
908
988
  *
909
989
  * @returns The SELECT query builder.
910
990
  */
911
- protected select(opts?: StatementOptions): drizzle_orm_pg_core13.PgSelectBase<string, Record<string, PgColumn<drizzle_orm8.ColumnBaseConfig<drizzle_orm8.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
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, {
912
992
  [x: string]: unknown;
913
993
  }[], {
914
- [x: string]: PgColumn<drizzle_orm8.ColumnBaseConfig<drizzle_orm8.ColumnDataType, string>, {}, {}>;
994
+ [x: string]: PgColumn<drizzle_orm0$1.ColumnBaseConfig<drizzle_orm0$1.ColumnDataType, string>, {}, {}>;
915
995
  }>;
916
996
  /**
917
997
  * Start an INSERT query on the table.
918
998
  *
919
999
  * @returns The INSERT query builder.
920
1000
  */
921
- protected insert(opts?: StatementOptions): drizzle_orm_pg_core13.PgInsertBuilder<TTable, any, false>;
1001
+ protected insert(opts?: StatementOptions): drizzle_orm_pg_core0$1.PgInsertBuilder<PgTableWithColumns<EntityTableConfig>, any, false>;
922
1002
  /**
923
1003
  * Start an UPDATE query on the table.
924
1004
  *
925
1005
  * @returns The UPDATE query builder.
926
1006
  */
927
- protected update(opts?: StatementOptions): drizzle_orm_pg_core13.PgUpdateBuilder<TTable, any>;
1007
+ protected update(opts?: StatementOptions): drizzle_orm_pg_core0$1.PgUpdateBuilder<PgTableWithColumns<EntityTableConfig>, any>;
928
1008
  /**
929
1009
  * Start a DELETE query on the table.
930
1010
  *
931
1011
  * @returns The DELETE query builder.
932
1012
  */
933
- protected delete(opts?: StatementOptions): drizzle_orm_pg_core13.PgDeleteBase<TTable, any, undefined, undefined, false, never>;
1013
+ protected delete(opts?: StatementOptions): drizzle_orm_pg_core0$1.PgDeleteBase<PgTableWithColumns<EntityTableConfig>, any, undefined, undefined, false, never>;
934
1014
  /**
935
1015
  * Find entities.
936
1016
  *
@@ -938,7 +1018,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
938
1018
  * @param opts The statement options.
939
1019
  * @returns The found entities.
940
1020
  */
941
- find<Select extends (keyof Static$1<TTableSchema>)[]>(query?: PgQuery<TTableSchema, Select>, opts?: StatementOptions): Promise<Static$1<PgQueryResult<TTableSchema, Select>>[]>;
1021
+ find<Select extends (keyof Static$1<EntitySchema>)[]>(query?: PgQuery<EntitySchema, Select>, opts?: StatementOptions): Promise<Static$1<PgQueryResult<EntitySchema, Select>>[]>;
942
1022
  /**
943
1023
  * Find a single entity.
944
1024
  *
@@ -946,14 +1026,14 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
946
1026
  * @param opts The statement options.
947
1027
  * @returns The found entity.
948
1028
  */
949
- findOne<T extends Static$1<TTableSchema> = Static$1<TTableSchema>>(where: PgQueryWhere<T>, opts?: StatementOptions): Promise<Static$1<TTableSchema>>;
1029
+ findOne<T extends Static$1<EntitySchema> = Static$1<EntitySchema>>(where: PgQueryWhere<T>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
950
1030
  /**
951
1031
  * Find an entity by ID.
952
1032
  *
953
1033
  * @param id
954
1034
  * @param opts
955
1035
  */
956
- findById(id: string | number, opts?: StatementOptions): Promise<Static$1<TTableSchema>>;
1036
+ findById(id: string | number, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
957
1037
  /**
958
1038
  * Paginate entities.
959
1039
  *
@@ -962,9 +1042,9 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
962
1042
  * @param opts The statement options.
963
1043
  * @returns The paginated entities.
964
1044
  */
965
- paginate(pageQuery?: PageQuery, findQuery?: PgQuery<TTableSchema>, opts?: StatementOptions): Promise<Page<Static$1<TTableSchema>>>;
966
- createQuery(query?: PgQuery<TTableSchema>): PgQuery<TTableSchema>;
967
- createQueryWhere(where?: PgQueryWhere<Static$1<TTableSchema>>): PgQueryWhere<Static$1<TTableSchema>>;
1045
+ paginate(pageQuery?: PageQuery, findQuery?: PgQuery<EntitySchema>, opts?: StatementOptions): Promise<Page<Static$1<EntitySchema>>>;
1046
+ createQuery(query?: PgQuery<EntitySchema>): PgQuery<EntitySchema>;
1047
+ createQueryWhere(where?: PgQueryWhere<Static$1<EntitySchema>>): PgQueryWhere<Static$1<EntitySchema>>;
968
1048
  /**
969
1049
  * Create an entity.
970
1050
  *
@@ -972,7 +1052,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
972
1052
  * @param opts The options for creating the entity.
973
1053
  * @returns The ID of the created entity.
974
1054
  */
975
- create(data: InferInsert<TTableSchema>, opts?: StatementOptions): Promise<Static$1<TTableSchema>>;
1055
+ create(data: InferInsert<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
976
1056
  /**
977
1057
  * Create many entities.
978
1058
  *
@@ -980,7 +1060,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
980
1060
  * @param opts The statement options.
981
1061
  * @returns The created entities.
982
1062
  */
983
- createMany(values: Array<InferInsert<TTableSchema>>, opts?: StatementOptions): Promise<Static$1<TTableSchema>[]>;
1063
+ createMany(values: Array<InferInsert<EntitySchema>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>[]>;
984
1064
  /**
985
1065
  * Update an entity.
986
1066
  *
@@ -989,10 +1069,10 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
989
1069
  * @param opts The statement options.
990
1070
  * @returns The updated entity.
991
1071
  */
992
- updateOne(query: PgQueryWhere<Static$1<TTableSchema>>, data: Partial<NullifyIfOptional<Static$1<TTableSchema>>> | {
993
- $append: Partial<NullifyIfOptional<Static$1<TTableSchema>>>;
994
- }, opts?: StatementOptions): Promise<Static$1<TTableSchema>>;
995
- save(data: InferInsert<TTableSchema>, opts?: StatementOptions): Promise<Static$1<TTableSchema>>;
1072
+ updateOne(query: PgQueryWhere<Static$1<EntitySchema>>, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>> | {
1073
+ $append: Partial<NullifyIfOptional<Static$1<EntitySchema>>>;
1074
+ }, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1075
+ save(data: InferInsert<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
996
1076
  /**
997
1077
  * Update an entity by ID.
998
1078
  *
@@ -1000,7 +1080,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
1000
1080
  * @param data
1001
1081
  * @param opts
1002
1082
  */
1003
- updateById(id: string | number, data: Partial<NullifyIfOptional<Static$1<TTableSchema>>>, opts?: StatementOptions): Promise<Static$1<TTableSchema>>;
1083
+ updateById(id: string | number, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1004
1084
  /**
1005
1085
  * Update entities.
1006
1086
  *
@@ -1009,14 +1089,14 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
1009
1089
  * @param opts The statement options.
1010
1090
  * @returns The updated entities.
1011
1091
  */
1012
- updateMany(where: PgQueryWhere<Static$1<TTableSchema>>, data: Partial<NullifyIfOptional<Static$1<TTableSchema>>>, opts?: StatementOptions): Promise<Static$1<TTableSchema>[]>;
1092
+ updateMany(where: PgQueryWhere<Static$1<EntitySchema>>, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>[]>;
1013
1093
  /**
1014
1094
  * Delete entities.
1015
1095
  *
1016
1096
  * @param where Query.
1017
1097
  * @param opts The statement options.
1018
1098
  */
1019
- deleteMany(where?: PgQueryWhere<Static$1<TTableSchema>>, opts?: StatementOptions): Promise<void>;
1099
+ deleteMany(where?: PgQueryWhere<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<void>;
1020
1100
  /**
1021
1101
  * Delete all entities.
1022
1102
  * @param opts
@@ -1036,7 +1116,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
1036
1116
  * @param opts The statement options.
1037
1117
  * @returns The count of entities.
1038
1118
  */
1039
- count(where?: PgQueryWhere<Static$1<TTableSchema>>, opts?: StatementOptions): Promise<number>;
1119
+ count(where?: PgQueryWhere<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<number>;
1040
1120
  /**
1041
1121
  * Convert a query object to a SQL query.
1042
1122
  *
@@ -1044,7 +1124,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
1044
1124
  * @param schema The schema to use.
1045
1125
  * @param col The column to use.
1046
1126
  */
1047
- protected jsonQueryToSql(query: PgQueryWhere<Static$1<TTableSchema>>, schema?: TObject$1, col?: (key: string) => PgColumn): SQL | undefined;
1127
+ protected jsonQueryToSql(query: PgQueryWhere<Static$1<EntitySchema>>, schema?: TObject$1, col?: (key: string) => PgColumn): SQL | undefined;
1048
1128
  /**
1049
1129
  * Map a filter operator to a SQL query.
1050
1130
  *
@@ -1060,11 +1140,11 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
1060
1140
  * @param limit The limit of the pagination.
1061
1141
  * @param offset The offset of the pagination.
1062
1142
  */
1063
- protected createPagination(entities: Static$1<TTableSchema>[], limit?: number, offset?: number): Page<Static$1<TTableSchema>>;
1143
+ protected createPagination(entities: Static$1<EntitySchema>[], limit?: number, offset?: number): Page<Static$1<EntitySchema>>;
1064
1144
  /**
1065
1145
  * Convert something to valid Pg Insert Value.
1066
1146
  */
1067
- protected cast(data: any, insert: boolean): PgInsertValue<TTable>;
1147
+ protected cast(data: any, insert: boolean): PgInsertValue<PgTableWithColumns<EntityTableConfig>>;
1068
1148
  /**
1069
1149
  * Clean a row. Remove all null values.
1070
1150
  *
@@ -1072,14 +1152,14 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
1072
1152
  * @param schema The schema to use.
1073
1153
  * @returns The cleaned row.
1074
1154
  */
1075
- protected clean<T extends TObject$1 = TTableSchema>(row: any, schema?: T): Static$1<T>;
1155
+ protected clean<T extends TObject$1 = EntitySchema>(row: any, schema?: T): Static$1<T>;
1076
1156
  /**
1077
1157
  * Get the where clause for an ID.
1078
1158
  *
1079
1159
  * @param id The ID to get the where clause for.
1080
1160
  * @returns The where clause for the ID.
1081
1161
  */
1082
- protected getWhereId(id: string | number): PgQueryWhere<Static$1<TTableSchema>>;
1162
+ protected getWhereId(id: string | number): PgQueryWhere<Static$1<EntitySchema>>;
1083
1163
  /**
1084
1164
  * Find a primary key in the schema.
1085
1165
  *
@@ -1088,7 +1168,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
1088
1168
  */
1089
1169
  protected getPrimaryKey(schema: TObject$1): {
1090
1170
  key: string;
1091
- col: PgColumn<drizzle_orm8.ColumnBaseConfig<drizzle_orm8.ColumnDataType, string>, {}, {}>;
1171
+ col: PgColumn<drizzle_orm0$1.ColumnBaseConfig<drizzle_orm0$1.ColumnDataType, string>, {}, {}>;
1092
1172
  type: TSchema$2;
1093
1173
  };
1094
1174
  }
@@ -1122,133 +1202,12 @@ interface PgAttrField {
1122
1202
  data: any;
1123
1203
  nested?: any[];
1124
1204
  }
1125
- //# sourceMappingURL=Repository.d.ts.map
1126
- //#endregion
1127
- //#region src/constants/PG_SCHEMA.d.ts
1128
- declare const PG_SCHEMA: unique symbol;
1129
- //# sourceMappingURL=PG_SCHEMA.d.ts.map
1130
-
1131
- //#endregion
1132
- //#region src/descriptors/$db.d.ts
1133
- /**
1134
- * @experimental
1135
- */
1136
- declare const $db: <T extends {
1137
- [key: string]: TableLike;
1138
- }>(options?: DbDescriptorOptions<T>) => DbDescriptor<T>;
1139
- type DbDescriptorOptions<T extends {
1140
- [key: string]: TableLike;
1141
- }> = {
1142
- entities?: T;
1143
- };
1144
- type DbDescriptor<T extends {
1145
- [key: string]: TableLike;
1146
- }> = { [key in keyof T]: Repository<any, T[key]["$schema"]> } & Pick<PostgresProvider, "execute">;
1147
- //# sourceMappingURL=$db.d.ts.map
1148
- //#endregion
1149
- //#region src/descriptors/$entity.d.ts
1150
- /**
1151
- * Creates a table descriptor for drizzle-orm.
1152
- */
1153
- declare const $entity: <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>) => PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
1154
- interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1, Keys = keyof Static$1<T>> {
1155
- /**
1156
- * The name of the table. This is the name that will be used in the database.
1157
- * @example
1158
- * name: "user"
1159
- */
1160
- name: TTableName;
1161
- /**
1162
- * The schema of the table. This is a TypeBox schema that describes the columns and their types.
1163
- * @example
1164
- * schema: t.object({
1165
- * id: t.uuid(),
1166
- * name: t.string(),
1167
- * email: t.string(),
1168
- * phoneNumber: t.string(),
1169
- * })
1170
- */
1171
- schema: T;
1172
- /**
1173
- * The indexes to create for the table. This can be a string or an object with the column name and options.
1174
- * @example
1175
- * indexes: ["name", { column: "email", unique: true }]
1176
- */
1177
- indexes?: (Keys | {
1178
- column: Keys;
1179
- unique?: boolean;
1180
- name?: string;
1181
- } | {
1182
- columns: Keys[];
1183
- unique?: boolean;
1184
- name?: string;
1185
- })[];
1186
- relations?: Record<string, {
1187
- type: "one" | "many";
1188
- table: () => any;
1189
- foreignColumn?: keyof Static$1<T>;
1190
- }>;
1191
- foreignKeys?: Array<{
1192
- name?: string;
1193
- columns: Array<keyof Static$1<T>>;
1194
- foreignColumns: Array<AnyPgColumn>;
1195
- }>;
1196
- constraints?: Array<{
1197
- columns: Array<keyof Static$1<T>>;
1198
- name?: string;
1199
- unique?: boolean | {};
1200
- check?: SQL;
1201
- }>;
1202
- /**
1203
- * Extra configuration for the table. See drizzle-orm documentation for more details.
1204
- *
1205
- * @param self The table descriptor.
1206
- * @returns The extra configuration for the table.
1207
- */
1208
- config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
1209
- }
1210
- type Entity<T extends TObject$1> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
1211
- /**
1212
- * Create a table with a json schema.
1213
- *
1214
- * @param name The name of the table.
1215
- * @param schema The json schema of the table.
1216
- * @param extraConfig Extra configuration for the table.
1217
- */
1218
- declare const pgTableSchema: <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(name: TTableName, schema: TSchema, extraConfig?: (self: BuildExtraConfigColumns<TTableName, TColumnsMap, "pg">) => PgTableExtraConfigValue[]) => PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
1219
- type PgTableConfig<TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>> = {
1220
- name: TTableName;
1221
- schema: any;
1222
- columns: BuildColumns<TTableName, TColumnsMap, "pg">;
1223
- dialect: "pg";
1224
- };
1225
- //# sourceMappingURL=$entity.d.ts.map
1226
- //#endregion
1227
- //#region src/descriptors/$repository.d.ts
1228
- /**
1229
- *
1230
- */
1231
- declare const $repository: {
1232
- <TEntity extends TableConfig, TSchema extends TObject>(optionsOrTable: RepositoryDescriptorOptions<TEntity, TSchema> | PgTableWithColumnsAndSchema<TEntity, TSchema>): Repository<PgTableWithColumnsAndSchema<TEntity, TSchema>, TSchema>;
1233
- [KIND]: string;
1234
- };
1235
- interface RepositoryDescriptorOptions<TEntity extends TableConfig, TSchema extends TObject> {
1236
- /**
1237
- * The table to create the repository for.
1238
- */
1239
- table: PgTableWithColumnsAndSchema<TEntity, TSchema>;
1240
- /**
1241
- * Override default provider.
1242
- */
1243
- provider?: () => PostgresProvider;
1244
- }
1245
1205
  //# sourceMappingURL=$repository.d.ts.map
1246
1206
  //#endregion
1247
1207
  //#region src/descriptors/$sequence.d.ts
1248
- declare const KEY = "SEQUENCE";
1249
1208
  declare const $sequence: {
1250
1209
  (options?: SequenceDescriptorOptions): SequenceDescriptor;
1251
- [KIND]: string;
1210
+ [KIND]: typeof SequenceDescriptor;
1252
1211
  };
1253
1212
  interface SequenceDescriptorOptions {
1254
1213
  name?: string;
@@ -1258,19 +1217,21 @@ interface SequenceDescriptorOptions {
1258
1217
  max?: number;
1259
1218
  cycle?: boolean;
1260
1219
  }
1261
- interface SequenceDescriptor {
1262
- [KIND]: typeof KEY;
1263
- [OPTIONS]: SequenceDescriptorOptions;
1264
- (): Promise<number>;
1220
+ declare class SequenceDescriptor extends Descriptor<SequenceDescriptorOptions> {
1221
+ protected readonly provider: PostgresProvider;
1222
+ protected created: boolean;
1223
+ get name(): string;
1224
+ protected create(): Promise<void>;
1265
1225
  next(): Promise<number>;
1266
1226
  current(): Promise<number>;
1267
1227
  }
1228
+ //# sourceMappingURL=$sequence.d.ts.map
1268
1229
  //#endregion
1269
1230
  //#region src/descriptors/$transaction.d.ts
1270
1231
  /**
1271
1232
  *
1272
1233
  */
1273
- declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry81.RetryDescriptor<(...args: T) => Promise<R>>;
1234
+ declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry0.RetryDescriptorFn<(...args: T) => Promise<R>>;
1274
1235
  interface TransactionDescriptorOptions<T extends any[], R> {
1275
1236
  handler: (tx: PgTransaction<any, any, any>, ...args: T) => Promise<R>;
1276
1237
  config?: PgTransactionConfig$1;
@@ -1288,46 +1249,33 @@ declare class EntityNotFoundError extends Error {
1288
1249
  //#endregion
1289
1250
  //#region src/providers/RepositoryDescriptorProvider.d.ts
1290
1251
  declare class RepositoryDescriptorProvider {
1291
- protected readonly log: _alepha_core55.Logger;
1252
+ protected readonly log: _alepha_core24.Logger;
1292
1253
  protected readonly alepha: Alepha;
1293
- protected readonly repositories: Array<Repository<any, TObject$1>>;
1254
+ get repositories(): RepositoryDescriptor<TableConfig$1, TObject$1>[];
1294
1255
  constructor();
1295
1256
  clearRepositories(): Promise<void>;
1296
- protected readonly configure: _alepha_core55.HookDescriptor<"configure">;
1297
1257
  /**
1298
1258
  * Get all repositories.
1299
1259
  *
1300
1260
  * @param provider - Filter by provider.
1301
1261
  */
1302
- getRepositories(provider?: PostgresProvider): Repository<PgTableWithColumns<TableConfig$1>, TObject$1>[];
1262
+ getRepositories(provider?: PostgresProvider): RepositoryDescriptor<TableConfig$1, TObject$1>[];
1303
1263
  /**
1304
1264
  * Get all tables from the repositories.
1305
1265
  *
1306
1266
  * @param provider
1307
1267
  */
1308
- getTables(provider?: PostgresProvider): PgTableWithColumns<TableConfig$1>[];
1268
+ getTables(provider?: PostgresProvider): drizzle_orm_pg_core4.PgTableWithColumns<TableConfig$1>[];
1309
1269
  /**
1310
1270
  * Get all providers from the repositories.
1311
1271
  */
1312
1272
  getProviders(): PostgresProvider[];
1313
- /**
1314
- * Process all descriptors.
1315
- *
1316
- * @protected
1317
- */
1318
- protected processDescriptors(): Promise<void>;
1319
- /**
1320
- * Get all models from the repository descriptors.
1321
- *
1322
- * By models, we mean the tables.
1323
- */
1324
- protected processRepositoryDescriptors(): Promise<void>;
1325
1273
  }
1326
1274
  //# sourceMappingURL=RepositoryDescriptorProvider.d.ts.map
1327
1275
  //#endregion
1328
1276
  //#region src/providers/DrizzleKitProvider.d.ts
1329
1277
  declare class DrizzleKitProvider {
1330
- protected readonly log: _alepha_core19.Logger;
1278
+ protected readonly log: _alepha_core0$1.Logger;
1331
1279
  protected readonly alepha: Alepha;
1332
1280
  protected readonly repositoryProvider: RepositoryDescriptorProvider;
1333
1281
  push(provider: PostgresProvider, schema?: string): Promise<void>;
@@ -1366,37 +1314,37 @@ declare module "alepha" {
1366
1314
  interface Env extends Partial<Static<typeof envSchema>> {}
1367
1315
  }
1368
1316
  declare const envSchema: TObject$1<{
1369
- PG_HOST: _alepha_core21.TOptional<_alepha_core21.TString>;
1370
- PG_USERNAME: _alepha_core21.TOptional<_alepha_core21.TString>;
1371
- PG_DATABASE: _alepha_core21.TOptional<_alepha_core21.TString>;
1372
- PG_PASSWORD: _alepha_core21.TOptional<_alepha_core21.TString>;
1373
- PG_PORT: _alepha_core21.TOptional<_alepha_core21.TNumber>;
1374
- DATABASE_URL: _alepha_core21.TOptional<_alepha_core21.TString>;
1375
- DATABASE_MIGRATIONS_FOLDER: _alepha_core21.TString;
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;
1376
1324
  /**
1377
1325
  * The schema to use.
1378
1326
  * Accept a string.
1379
1327
  */
1380
- POSTGRES_SCHEMA: _alepha_core21.TOptional<_alepha_core21.TString>;
1328
+ POSTGRES_SCHEMA: _alepha_core1.TOptional<_alepha_core1.TString>;
1381
1329
  /**
1382
1330
  * Synchronize the database schema with the models.
1383
1331
  * Accept a boolean or a postgres schema name.
1384
1332
  *
1385
1333
  * @default false
1386
1334
  */
1387
- POSTGRES_SYNCHRONIZE: _alepha_core21.TOptional<_alepha_core21.TBoolean>;
1335
+ POSTGRES_SYNCHRONIZE: _alepha_core1.TOptional<_alepha_core1.TBoolean>;
1388
1336
  /**
1389
1337
  * Push the schema to the database.
1390
1338
  *
1391
1339
  * @default false
1392
1340
  */
1393
- POSTGRES_PUSH_SCHEMA: _alepha_core21.TOptional<_alepha_core21.TBoolean>;
1341
+ POSTGRES_PUSH_SCHEMA: _alepha_core1.TOptional<_alepha_core1.TBoolean>;
1394
1342
  /**
1395
1343
  * Reject unauthorized SSL connections.
1396
1344
  *
1397
1345
  * @default false
1398
1346
  */
1399
- POSTGRES_REJECT_UNAUTHORIZED: _alepha_core21.TBoolean;
1347
+ POSTGRES_REJECT_UNAUTHORIZED: _alepha_core1.TBoolean;
1400
1348
  }>;
1401
1349
  interface NodePostgresProviderState {
1402
1350
  client: postgres.Sql;
@@ -1404,14 +1352,14 @@ interface NodePostgresProviderState {
1404
1352
  }
1405
1353
  declare class NodePostgresProvider extends PostgresProvider {
1406
1354
  readonly dialect = "postgres";
1407
- protected readonly log: _alepha_core21.Logger;
1355
+ protected readonly log: _alepha_core1.Logger;
1408
1356
  protected readonly env: {
1409
- DATABASE_URL?: string | undefined;
1410
1357
  PG_HOST?: string | undefined;
1411
1358
  PG_USERNAME?: string | undefined;
1412
1359
  PG_DATABASE?: string | undefined;
1413
1360
  PG_PASSWORD?: string | undefined;
1414
1361
  PG_PORT?: number | undefined;
1362
+ DATABASE_URL?: string | undefined;
1415
1363
  POSTGRES_SCHEMA?: string | undefined;
1416
1364
  POSTGRES_SYNCHRONIZE?: boolean | undefined;
1417
1365
  POSTGRES_PUSH_SCHEMA?: boolean | undefined;
@@ -1426,8 +1374,8 @@ declare class NodePostgresProvider extends PostgresProvider {
1426
1374
  */
1427
1375
  protected testingSchemaName?: string;
1428
1376
  get db(): PostgresJsDatabase;
1429
- protected readonly configure: _alepha_core21.HookDescriptor<"start">;
1430
- protected readonly stop: _alepha_core21.HookDescriptor<"stop">;
1377
+ protected readonly configure: _alepha_core1.HookDescriptor<"start">;
1378
+ protected readonly stop: _alepha_core1.HookDescriptor<"stop">;
1431
1379
  /**
1432
1380
  * Get Postgres schema.
1433
1381
  */
@@ -1435,7 +1383,7 @@ declare class NodePostgresProvider extends PostgresProvider {
1435
1383
  execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static<T> : any>>;
1436
1384
  connect(): Promise<void>;
1437
1385
  close(): Promise<void>;
1438
- protected migrate: _alepha_lock44.LockDescriptor<() => Promise<void>>;
1386
+ protected migrate: _alepha_lock0.LockDescriptor<() => Promise<void>>;
1439
1387
  protected createClient(): NodePostgresProviderState;
1440
1388
  protected getMigrationOptions(): MigrationConfig;
1441
1389
  protected getClientOptions(): postgres.Options<any>;
@@ -1450,7 +1398,7 @@ declare class NodePostgresProvider extends PostgresProvider {
1450
1398
  type PgAttr<T extends TSchema$1, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
1451
1399
  //#endregion
1452
1400
  //#region src/schemas/createdAtSchema.d.ts
1453
- declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox89.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1401
+ declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox17.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1454
1402
  //# sourceMappingURL=createdAtSchema.d.ts.map
1455
1403
 
1456
1404
  //#endregion
@@ -1458,11 +1406,11 @@ declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox89.TString, typeof
1458
1406
  /**
1459
1407
  * @deprecated Use `pg.primaryKey()` instead.
1460
1408
  */
1461
- declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox85.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1409
+ declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox18.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1462
1410
  //# sourceMappingURL=legacyIdSchema.d.ts.map
1463
1411
  //#endregion
1464
1412
  //#region src/schemas/updatedAtSchema.d.ts
1465
- declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox82.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1413
+ declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox16.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1466
1414
  //# sourceMappingURL=updatedAtSchema.d.ts.map
1467
1415
 
1468
1416
  //#endregion
@@ -1473,14 +1421,14 @@ declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox82.TString, typeof
1473
1421
  * Add some common SQL properties to an object.
1474
1422
  */
1475
1423
  declare const entitySchema: TObject$1<{
1476
- id: PgAttr<PgAttr<PgAttr<_sinclair_typebox57.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1477
- createdAt: PgAttr<PgAttr<_sinclair_typebox57.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1478
- updatedAt: PgAttr<PgAttr<_sinclair_typebox57.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
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>;
1479
1427
  }>;
1480
1428
  /**
1481
1429
  * TypeBox Entity Type.
1482
1430
  */
1483
- type TEntity$1<T extends TProperties> = TObject$1<T & {
1431
+ type TEntity<T extends TProperties> = TObject$1<T & {
1484
1432
  id: typeof legacyIdSchema;
1485
1433
  createdAt: typeof createdAtSchema;
1486
1434
  updatedAt: typeof updatedAtSchema;
@@ -1510,19 +1458,19 @@ declare class PostgresTypeProvider {
1510
1458
  /**
1511
1459
  * Creates a primary key with an identity column.
1512
1460
  */
1513
- readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox48.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1461
+ readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1514
1462
  /**
1515
1463
  * Creates a primary key with a big identity column. (default)
1516
1464
  */
1517
- readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox48.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1465
+ readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1518
1466
  /**
1519
1467
  * Creates a primary key with a UUID column.
1520
1468
  */
1521
- readonly uuidPrimaryKey: () => PgAttr<PgAttr<_sinclair_typebox48.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1469
+ readonly uuidPrimaryKey: () => PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1522
1470
  /**
1523
1471
  * @alias bigIdentityPrimaryKey
1524
1472
  */
1525
- readonly primaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox48.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1473
+ readonly primaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1526
1474
  /**
1527
1475
  * Wrap a schema with "default" attribute.
1528
1476
  * This is used to set a default value for a column in the database.
@@ -1533,19 +1481,19 @@ declare class PostgresTypeProvider {
1533
1481
  * This is used to track the version of a row in the database.
1534
1482
  * You can use it for optimistic concurrency control.
1535
1483
  */
1536
- readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<_sinclair_typebox48.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
1484
+ readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<_sinclair_typebox0.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
1537
1485
  /**
1538
1486
  * Creates a column Created At. So just a datetime column with a default value of the current timestamp.
1539
1487
  */
1540
- readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox48.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1488
+ readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1541
1489
  /**
1542
1490
  * Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
1543
1491
  */
1544
- readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox48.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1492
+ readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1545
1493
  /**
1546
1494
  * @deprecated Build your own entity schema.
1547
1495
  */
1548
- readonly entity: <T extends TProperties>(properties: T, options?: ObjectOptions) => TEntity$1<T>;
1496
+ readonly entity: <T extends TProperties>(properties: T, options?: ObjectOptions) => TEntity<T>;
1549
1497
  /**
1550
1498
  * Creates an insert schema for a given object schema.
1551
1499
  * - pg.default will be optional
@@ -1587,7 +1535,7 @@ declare const pg: PostgresTypeProvider;
1587
1535
  /**
1588
1536
  * Postgres schema type.
1589
1537
  */
1590
- declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) => drizzle_orm2.$Type<drizzle_orm_pg_core1.PgCustomColumnBuilder<{
1538
+ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) => drizzle_orm0.$Type<drizzle_orm_pg_core0.PgCustomColumnBuilder<{
1591
1539
  name: string;
1592
1540
  dataType: "custom";
1593
1541
  columnType: "PgCustomColumn";
@@ -1603,144 +1551,21 @@ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDoc
1603
1551
 
1604
1552
  //#endregion
1605
1553
  //#region src/index.d.ts
1606
- declare module "alepha" {
1607
- function $inject<T extends TableConfig, R extends TObject>(type: PgTableWithColumnsAndSchema<T, R>): Repository<PgTableWithColumnsAndSchema<T, R>, R>;
1608
- }
1609
1554
  /**
1610
- * Provides PostgreSQL and SQLite database integration with type-safe ORM capabilities through Drizzle.
1611
- *
1612
- * The postgres module enables declarative database operations using descriptors like `$entity`, `$repository`,
1613
- * and `$db` on class properties. It offers automatic schema generation, type-safe queries, transactions,
1614
- * and database migrations with support for both PostgreSQL and SQLite backends.
1615
- *
1616
- * **Key Features:**
1617
- * - Declarative entity definition with `$entity` descriptor
1618
- * - Type-safe repository pattern with `$repository` descriptor
1619
- * - Database connection management with `$db` descriptor
1620
- * - Automatic schema migrations and type generation
1621
- * - Transaction support with `$transaction` descriptor
1622
- * - Sequence management with `$sequence` descriptor
1623
- * - Full TypeScript integration with compile-time type checking
1624
- *
1625
- * **Basic Usage:**
1626
- * ```ts
1627
- * import { Alepha, run, t } from "alepha";
1628
- * import { AlephaPostgres, $entity, $repository, pg } from "alepha/postgres";
1629
- *
1630
- * // Define database entities
1631
- * const user = $entity({
1632
- * name: "users",
1633
- * schema: t.object({
1634
- * id: pg.primaryKey(),
1635
- * createdAt: pg.createdAt(),
1636
- * name: t.string(),
1637
- * email: t.string(),
1638
- * age: t.optional(t.integer()),
1639
- * }),
1640
- * });
1641
- *
1642
- * const post = $entity({
1643
- * name: "posts",
1644
- * schema: t.object({
1645
- * id: pg.primaryKey(),
1646
- * createdAt: pg.createdAt(),
1647
- * title: t.string(),
1648
- * content: t.string(),
1649
- * authorId: pg.references(t.uint(), () => user.id),
1650
- * }),
1651
- * });
1555
+ * Provides PostgreSQL (and SQLite!) database integration with type-safe ORM capabilities through Drizzle.
1652
1556
  *
1653
- * class Database {
1654
- * users = $repository(user);
1655
- * posts = $repository(post);
1656
- * }
1657
- *
1658
- * const alepha = Alepha.create()
1659
- * .with(AlephaPostgres)
1660
- * .with(Database);
1661
- *
1662
- * run(alepha);
1663
- * ```
1664
- *
1665
- * **Repository Operations:**
1666
- * ```ts
1667
- * class UserService {
1668
- * users = $repository(user);
1669
- *
1670
- * async createUser(userData: { name: string; email: string }) {
1671
- * return await this.users.create(userData);
1672
- * }
1673
- *
1674
- * async findUserByEmail(email: string) {
1675
- * return await this.users.findFirst({
1676
- * where: { email },
1677
- * });
1678
- * }
1679
- *
1680
- * async getUsersWithPosts() {
1681
- * return await this.users.find({
1682
- * with: { posts: true },
1683
- * limit: 10,
1684
- * });
1685
- * }
1686
- *
1687
- * async updateUser(id: number, updates: Partial<{ name: string; age: number }>) {
1688
- * return await this.users.update(id, updates);
1689
- * }
1690
- * }
1691
- * ```
1692
- *
1693
- * **Advanced Database Operations:**
1694
- * ```ts
1695
- * import { $db, $transaction } from "alepha/postgres";
1696
- *
1697
- * class AdvancedDatabase {
1698
- * db = $db({
1699
- * entities: { user, post },
1700
- * });
1701
- *
1702
- * createUserWithPost = $transaction(async () => {
1703
- * const newUser = await this.db.users.create({
1704
- * name: "John Doe",
1705
- * email: "john@example.com",
1706
- * });
1707
- *
1708
- * const newPost = await this.db.posts.create({
1709
- * title: "My First Post",
1710
- * content: "Hello world!",
1711
- * authorId: newUser.id,
1712
- * });
1713
- *
1714
- * return { user: newUser, post: newPost };
1715
- * });
1716
- *
1717
- * async rawQuery() {
1718
- * // Execute raw SQL queries
1719
- * return await this.db.execute(sql`
1720
- * SELECT users.name, COUNT(posts.id) as post_count
1721
- * FROM users
1722
- * LEFT JOIN posts ON users.id = posts.author_id
1723
- * GROUP BY users.id, users.name
1724
- * `);
1725
- * }
1726
- * }
1727
- * ```
1557
+ * The postgres module enables declarative database operations using descriptors like `$entity`, `$repository`.
1558
+ * It offers automatic schema generation, type-safe queries, transactions,
1559
+ * and database migrations with support for PostgreSQLs.
1728
1560
  *
1729
1561
  * @see {@link $entity}
1730
1562
  * @see {@link $repository}
1731
- * @see {@link $db}
1732
1563
  * @see {@link $transaction}
1733
1564
  * @module alepha.postgres
1734
1565
  */
1735
- declare class AlephaPostgres implements Module {
1736
- readonly name = "alepha.postgres";
1737
- readonly env: {
1738
- DATABASE_URL: string;
1739
- };
1740
- readonly $services: (alepha: Alepha) => void;
1741
- }
1566
+ declare const AlephaPostgres: _alepha_core0.ModuleDescriptor;
1742
1567
  //# sourceMappingURL=index.d.ts.map
1743
1568
 
1744
1569
  //#endregion
1745
- export { $db, $entity, $repository, $sequence, $transaction, AlephaPostgres, BaseEntity, BaseEntityKeys, DbDescriptor, DbDescriptorOptions, 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, Repository, RepositoryDescriptorOptions, RepositoryDescriptorProvider, SQLLike, SequenceDescriptor, SequenceDescriptorOptions, StatementOptions, TEntity$1 as TEntity, TInsertObject, TPage, TableLike, TransactionContext, TransactionDescriptorOptions, camelToSnakeCase, drizzle, entityKeys, entitySchema, mapFieldToColumn, mapStringToColumn, nullToUndefined, pageQuerySchema, pageSchema, pg, pgTableSchema, schema, schemaToPgColumns, sql };
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 };
1746
1571
  //# sourceMappingURL=index.d.ts.map