alepha 0.7.7 → 0.8.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,27 +1,26 @@
1
- import * as _alepha_core17 from "@alepha/core";
2
- import * as _alepha_core36 from "@alepha/core";
3
- import * as _alepha_core58 from "@alepha/core";
4
- import { Alepha, KIND, Module, OPTIONS, Static, TObject, TSchema as TSchema$1 } from "@alepha/core";
1
+ import * as _alepha_core56 from "alepha";
2
+ import * as _alepha_core20 from "alepha";
3
+ import * as _alepha_core22 from "alepha";
4
+ import { Alepha, KIND, Module, OPTIONS, Static, TObject, TSchema as TSchema$1 } from "alepha";
5
5
  import * as drizzle_orm3 from "drizzle-orm";
6
- import * as drizzle_orm71 from "drizzle-orm";
7
- import * as drizzle_orm1 from "drizzle-orm";
6
+ import * as drizzle_orm8 from "drizzle-orm";
7
+ import * as drizzle_orm2 from "drizzle-orm";
8
8
  import * as drizzle from "drizzle-orm";
9
9
  import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, TableConfig, sql } from "drizzle-orm";
10
- import * as _alepha_lock62 from "@alepha/lock";
10
+ import * as _alepha_lock45 from "alepha/lock";
11
11
  import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
12
12
  import postgres from "postgres";
13
13
  import * as pg$1 from "drizzle-orm/pg-core";
14
- import * as drizzle_orm_pg_core76 from "drizzle-orm/pg-core";
15
- import * as drizzle_orm_pg_core0 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";
16
16
  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_retry2 from "@alepha/retry";
18
- import * as _sinclair_typebox63 from "@sinclair/typebox";
19
- import * as _sinclair_typebox38 from "@sinclair/typebox";
17
+ import * as _alepha_retry19 from "alepha/retry";
18
+ import * as _sinclair_typebox75 from "@sinclair/typebox";
20
19
  import * as _sinclair_typebox85 from "@sinclair/typebox";
21
20
  import * as _sinclair_typebox88 from "@sinclair/typebox";
22
21
  import * as _sinclair_typebox82 from "@sinclair/typebox";
23
- import * as _sinclair_typebox19 from "@sinclair/typebox";
24
- import * as _sinclair_typebox10 from "@sinclair/typebox";
22
+ import * as _sinclair_typebox58 from "@sinclair/typebox";
23
+ import * as _sinclair_typebox49 from "@sinclair/typebox";
25
24
  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";
26
25
  import { PgTransactionConfig as PgTransactionConfig$1 } from "drizzle-orm/pg-core/session";
27
26
  import * as DrizzleKit from "drizzle-kit/api";
@@ -29,9 +28,6 @@ import { MigrationConfig } from "drizzle-orm/migrator";
29
28
  import { UpdateDeleteAction as UpdateDeleteAction$1 } from "drizzle-orm/pg-core/foreign-keys";
30
29
  export * from "drizzle-orm/pg-core";
31
30
 
32
- //#region src/constants/PG_SCHEMA.d.ts
33
- declare const PG_SCHEMA: unique symbol;
34
- //#endregion
35
31
  //#region src/constants/PG_SYMBOLS.d.ts
36
32
  declare const PG_DEFAULT: unique symbol;
37
33
  declare const PG_PRIMARY_KEY: unique symbol;
@@ -83,6 +79,7 @@ interface PgRefOptions {
83
79
  onDelete?: UpdateDeleteAction;
84
80
  };
85
81
  }
82
+ //# sourceMappingURL=PG_SYMBOLS.d.ts.map
86
83
  //#endregion
87
84
  //#region src/interfaces/TInsertObject.d.ts
88
85
  /**
@@ -273,96 +270,10 @@ type PgTableWithColumnsAndSchema<T extends TableConfig, R extends TObject> = PgT
273
270
  get $schema(): R;
274
271
  get $insertSchema(): TInsertObject<R>;
275
272
  };
276
- //#endregion
277
- //#region src/descriptors/$entity.d.ts
278
- interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1, Keys = keyof Static$1<T>> {
279
- /**
280
- * The name of the table. This is the name that will be used in the database.
281
- * @example
282
- * name: "user"
283
- */
284
- name: TTableName;
285
- /**
286
- * The schema of the table. This is a TypeBox schema that describes the columns and their types.
287
- * @example
288
- * schema: t.object({
289
- * id: t.uuid(),
290
- * name: t.string(),
291
- * email: t.string(),
292
- * phoneNumber: t.string(),
293
- * })
294
- */
295
- schema: T;
296
- /**
297
- * The indexes to create for the table. This can be a string or an object with the column name and options.
298
- * @example
299
- * indexes: ["name", { column: "email", unique: true }]
300
- */
301
- indexes?: (Keys | {
302
- column: Keys;
303
- unique?: boolean;
304
- name?: string;
305
- } | {
306
- columns: Keys[];
307
- unique?: boolean;
308
- name?: string;
309
- })[];
310
- relations?: Record<string, {
311
- type: "one" | "many";
312
- table: () => any;
313
- foreignColumn?: keyof Static$1<T>;
314
- }>;
315
- foreignKeys?: Array<{
316
- name?: string;
317
- columns: Array<keyof Static$1<T>>;
318
- foreignColumns: Array<AnyPgColumn>;
319
- }>;
320
- constraints?: Array<{
321
- columns: Array<keyof Static$1<T>>;
322
- name?: string;
323
- unique?: boolean | {};
324
- check?: SQL;
325
- }>;
326
- /**
327
- * Extra configuration for the table. See drizzle-orm documentation for more details.
328
- *
329
- * @param self The table descriptor.
330
- * @returns The extra configuration for the table.
331
- */
332
- config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
333
- }
334
- /**
335
- * Creates a table descriptor for drizzle-orm.
336
- */
337
- declare const $entity: <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>) => PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
338
- type Entity<T extends TObject$1> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
339
- /**
340
- * Create a table with a json schema.
341
- *
342
- * @param name The name of the table.
343
- * @param schema The json schema of the table.
344
- * @param extraConfig Extra configuration for the table.
345
- */
346
- 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>;
347
- type PgTableConfig<TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>> = {
348
- name: TTableName;
349
- schema: any;
350
- columns: BuildColumns<TTableName, TColumnsMap, "pg">;
351
- dialect: "pg";
352
- };
353
- //#endregion
354
- //#region src/providers/drivers/PostgresProvider.d.ts
355
- type SQLLike = SQLWrapper | string;
356
- declare class PostgresProvider {
357
- constructor();
358
- /**
359
- * Get the database instance
360
- */
361
- get db(): PgDatabase<any>;
362
- get schema(): string;
363
- get dialect(): string;
364
- execute(_query: SQLLike): Promise<any[]>;
273
+ interface TableLike<T extends TObject = TObject> {
274
+ $schema: T;
365
275
  }
276
+ //# sourceMappingURL=schemaToPgColumns.d.ts.map
366
277
  //#endregion
367
278
  //#region src/helpers/nullToUndefined.d.ts
368
279
  /**
@@ -377,6 +288,7 @@ declare const nullToUndefined: <T extends object>(value: T) => NullToUndefined<T
377
288
  */
378
289
  type NullToUndefined<T> = T extends null ? undefined : T extends null | undefined | string | number | boolean | symbol | bigint | Function | Date | RegExp ? T : T extends Array<infer U> ? Array<NullToUndefined<U>> : T extends Map<infer K, infer V> ? Map<K, NullToUndefined<V>> : T extends Set<infer U> ? Set<NullToUndefined<U>> : T extends object ? { [K in keyof T]: NullToUndefined<T[K]> } : unknown;
379
290
  type NullifyIfOptional<T> = { [K in keyof T]: undefined extends T[K] ? T[K] | null : T[K] };
291
+ //# sourceMappingURL=nullToUndefined.d.ts.map
380
292
  //#endregion
381
293
  //#region src/interfaces/FilterOperators.d.ts
382
294
  interface FilterOperators<TValue> {
@@ -733,6 +645,7 @@ interface FilterOperators<TValue> {
733
645
  */
734
646
  arrayOverlaps?: TValue;
735
647
  }
648
+ //# sourceMappingURL=FilterOperators.d.ts.map
736
649
  //#endregion
737
650
  //#region src/interfaces/InferInsert.d.ts
738
651
  /**
@@ -749,6 +662,7 @@ type StaticEntry<T extends TObject$1> = { [K in keyof T["properties"] as T["prop
749
662
  } | {
750
663
  [OptionalKind]: "Optional";
751
664
  } ? never : K]: Static$1<T["properties"][K]> };
665
+ //# sourceMappingURL=InferInsert.d.ts.map
752
666
  //#endregion
753
667
  //#region src/interfaces/PgQueryWhere.d.ts
754
668
  type PgQueryWhere<T extends object> = { [Key in keyof T]?: FilterOperators<T[Key]> } & {
@@ -820,6 +734,7 @@ type PgQueryWhere<T extends object> = { [Key in keyof T]?: FilterOperators<T[Key
820
734
  */
821
735
  exists?: SQLWrapper;
822
736
  };
737
+ //# sourceMappingURL=PgQueryWhere.d.ts.map
823
738
  //#endregion
824
739
  //#region src/interfaces/PgQuery.d.ts
825
740
  interface PgQuery<T extends TObject$1, Select extends (keyof Static$1<T>)[] = []> {
@@ -848,14 +763,28 @@ type PgQueryWith<T extends TObject$1 | TArray> = true | {
848
763
  [key: string]: PgQueryWith<T>;
849
764
  };
850
765
  };
766
+ //# sourceMappingURL=PgQuery.d.ts.map
767
+ //#endregion
768
+ //#region src/providers/drivers/PostgresProvider.d.ts
769
+ type SQLLike = SQLWrapper | string;
770
+ declare abstract class PostgresProvider {
771
+ protected readonly alepha: Alepha;
772
+ abstract get db(): PgDatabase<any>;
773
+ abstract get schema(): string;
774
+ abstract get dialect(): string;
775
+ abstract execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static$1<T> : any>>;
776
+ mapResult<T extends TObject$1 = any>(result: Array<any>, schema?: T): Array<T extends TObject$1 ? Static$1<T> : any>;
777
+ }
778
+ //# sourceMappingURL=PostgresProvider.d.ts.map
851
779
  //#endregion
852
780
  //#region src/schemas/pageQuerySchema.d.ts
853
- declare const pageQuerySchema: _sinclair_typebox63.TObject<{
854
- page: _sinclair_typebox63.TOptional<_sinclair_typebox63.TNumber>;
855
- size: _sinclair_typebox63.TOptional<_sinclair_typebox63.TNumber>;
856
- sort: _sinclair_typebox63.TOptional<_sinclair_typebox63.TString>;
781
+ declare const pageQuerySchema: _sinclair_typebox75.TObject<{
782
+ page: _sinclair_typebox75.TOptional<_sinclair_typebox75.TNumber>;
783
+ size: _sinclair_typebox75.TOptional<_sinclair_typebox75.TNumber>;
784
+ sort: _sinclair_typebox75.TOptional<_sinclair_typebox75.TString>;
857
785
  }>;
858
786
  type PageQuery = Static<typeof pageQuerySchema>;
787
+ //# sourceMappingURL=pageQuerySchema.d.ts.map
859
788
  //#endregion
860
789
  //#region src/schemas/pageSchema.d.ts
861
790
  /**
@@ -893,6 +822,7 @@ type Page<T> = {
893
822
  countDuration?: number;
894
823
  };
895
824
  };
825
+ //# sourceMappingURL=pageSchema.d.ts.map
896
826
  //#endregion
897
827
  //#region src/services/Repository.d.ts
898
828
  declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTableSchema extends TObject$1> {
@@ -901,7 +831,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
901
831
  protected readonly env: {
902
832
  POSTGRES_PAGINATION_COUNT_ENABLED: boolean;
903
833
  };
904
- static of: <TEntity extends TableConfig$1, TSchema extends TObject$1>(opts: PgTableWithColumnsAndSchema<TEntity, TSchema$2>) => (new () => Repository<PgTableWithColumns<TEntity>, TSchema$2>);
834
+ static of: <TEntity extends TableConfig$1, TTableSchema_1 extends TObject$1>(opts: PgTableWithColumnsAndSchema<TEntity, TTableSchema_1>) => (new () => Repository<PgTableWithColumns<TEntity>, TTableSchema_1>);
905
835
  /**
906
836
  * Register Repository as a valid descriptor.
907
837
  * - Required for $repository to work.
@@ -950,8 +880,8 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
950
880
  /**
951
881
  * Getter for the database connection from the database provider.
952
882
  */
953
- get db(): PgDatabase<any, Record<string, never>, drizzle_orm71.ExtractTablesWithRelations<Record<string, never>>>;
954
- organization(): PgColumn;
883
+ protected get db(): PgDatabase<any, Record<string, never>, drizzle_orm8.ExtractTablesWithRelations<Record<string, never>>>;
884
+ protected organization(): PgColumn;
955
885
  /**
956
886
  * Execute a SQL query.
957
887
  *
@@ -978,29 +908,29 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
978
908
  *
979
909
  * @returns The SELECT query builder.
980
910
  */
981
- protected select(opts?: StatementOptions): drizzle_orm_pg_core76.PgSelectBase<string, Record<string, PgColumn<drizzle_orm71.ColumnBaseConfig<drizzle_orm71.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
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, {
982
912
  [x: string]: unknown;
983
913
  }[], {
984
- [x: string]: PgColumn<drizzle_orm71.ColumnBaseConfig<drizzle_orm71.ColumnDataType, string>, {}, {}>;
914
+ [x: string]: PgColumn<drizzle_orm8.ColumnBaseConfig<drizzle_orm8.ColumnDataType, string>, {}, {}>;
985
915
  }>;
986
916
  /**
987
917
  * Start an INSERT query on the table.
988
918
  *
989
919
  * @returns The INSERT query builder.
990
920
  */
991
- protected insert(opts?: StatementOptions): drizzle_orm_pg_core76.PgInsertBuilder<TTable, any, false>;
921
+ protected insert(opts?: StatementOptions): drizzle_orm_pg_core13.PgInsertBuilder<TTable, any, false>;
992
922
  /**
993
923
  * Start an UPDATE query on the table.
994
924
  *
995
925
  * @returns The UPDATE query builder.
996
926
  */
997
- protected update(opts?: StatementOptions): drizzle_orm_pg_core76.PgUpdateBuilder<TTable, any>;
927
+ protected update(opts?: StatementOptions): drizzle_orm_pg_core13.PgUpdateBuilder<TTable, any>;
998
928
  /**
999
929
  * Start a DELETE query on the table.
1000
930
  *
1001
931
  * @returns The DELETE query builder.
1002
932
  */
1003
- protected delete(opts?: StatementOptions): drizzle_orm_pg_core76.PgDeleteBase<TTable, any, undefined, undefined, false, never>;
933
+ protected delete(opts?: StatementOptions): drizzle_orm_pg_core13.PgDeleteBase<TTable, any, undefined, undefined, false, never>;
1004
934
  /**
1005
935
  * Find entities.
1006
936
  *
@@ -1114,7 +1044,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
1114
1044
  * @param schema The schema to use.
1115
1045
  * @param col The column to use.
1116
1046
  */
1117
- jsonQueryToSql(query: PgQueryWhere<Static$1<TTableSchema>>, schema?: TObject$1, col?: (key: string) => PgColumn): SQL | undefined;
1047
+ protected jsonQueryToSql(query: PgQueryWhere<Static$1<TTableSchema>>, schema?: TObject$1, col?: (key: string) => PgColumn): SQL | undefined;
1118
1048
  /**
1119
1049
  * Map a filter operator to a SQL query.
1120
1050
  *
@@ -1158,7 +1088,7 @@ declare class Repository<TTable extends PgTableWithColumns<TableConfig$1>, TTabl
1158
1088
  */
1159
1089
  protected getPrimaryKey(schema: TObject$1): {
1160
1090
  key: string;
1161
- col: PgColumn<drizzle_orm71.ColumnBaseConfig<drizzle_orm71.ColumnDataType, string>, {}, {}>;
1091
+ col: PgColumn<drizzle_orm8.ColumnBaseConfig<drizzle_orm8.ColumnDataType, string>, {}, {}>;
1162
1092
  type: TSchema$2;
1163
1093
  };
1164
1094
  }
@@ -1192,6 +1122,104 @@ interface PgAttrField {
1192
1122
  data: any;
1193
1123
  nested?: any[];
1194
1124
  }
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
+ type DbDescriptorOptions<T extends {
1134
+ [key: string]: TableLike;
1135
+ }> = {
1136
+ entities?: T;
1137
+ };
1138
+ type DbDescriptor<T extends {
1139
+ [key: string]: TableLike;
1140
+ }> = { [key in keyof T]: Repository<any, T[key]["$schema"]> } & Pick<PostgresProvider, "execute">;
1141
+ declare const $db: <T extends {
1142
+ [key: string]: TableLike;
1143
+ }>(options?: DbDescriptorOptions<T>) => DbDescriptor<T>;
1144
+ //# sourceMappingURL=$db.d.ts.map
1145
+ //#endregion
1146
+ //#region src/descriptors/$entity.d.ts
1147
+ interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1, Keys = keyof Static$1<T>> {
1148
+ /**
1149
+ * The name of the table. This is the name that will be used in the database.
1150
+ * @example
1151
+ * name: "user"
1152
+ */
1153
+ name: TTableName;
1154
+ /**
1155
+ * The schema of the table. This is a TypeBox schema that describes the columns and their types.
1156
+ * @example
1157
+ * schema: t.object({
1158
+ * id: t.uuid(),
1159
+ * name: t.string(),
1160
+ * email: t.string(),
1161
+ * phoneNumber: t.string(),
1162
+ * })
1163
+ */
1164
+ schema: T;
1165
+ /**
1166
+ * The indexes to create for the table. This can be a string or an object with the column name and options.
1167
+ * @example
1168
+ * indexes: ["name", { column: "email", unique: true }]
1169
+ */
1170
+ indexes?: (Keys | {
1171
+ column: Keys;
1172
+ unique?: boolean;
1173
+ name?: string;
1174
+ } | {
1175
+ columns: Keys[];
1176
+ unique?: boolean;
1177
+ name?: string;
1178
+ })[];
1179
+ relations?: Record<string, {
1180
+ type: "one" | "many";
1181
+ table: () => any;
1182
+ foreignColumn?: keyof Static$1<T>;
1183
+ }>;
1184
+ foreignKeys?: Array<{
1185
+ name?: string;
1186
+ columns: Array<keyof Static$1<T>>;
1187
+ foreignColumns: Array<AnyPgColumn>;
1188
+ }>;
1189
+ constraints?: Array<{
1190
+ columns: Array<keyof Static$1<T>>;
1191
+ name?: string;
1192
+ unique?: boolean | {};
1193
+ check?: SQL;
1194
+ }>;
1195
+ /**
1196
+ * Extra configuration for the table. See drizzle-orm documentation for more details.
1197
+ *
1198
+ * @param self The table descriptor.
1199
+ * @returns The extra configuration for the table.
1200
+ */
1201
+ config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
1202
+ }
1203
+ /**
1204
+ * Creates a table descriptor for drizzle-orm.
1205
+ */
1206
+ declare const $entity: <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>) => PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
1207
+ type Entity<T extends TObject$1> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
1208
+ /**
1209
+ * Create a table with a json schema.
1210
+ *
1211
+ * @param name The name of the table.
1212
+ * @param schema The json schema of the table.
1213
+ * @param extraConfig Extra configuration for the table.
1214
+ */
1215
+ 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>;
1216
+ type PgTableConfig<TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>> = {
1217
+ name: TTableName;
1218
+ schema: any;
1219
+ columns: BuildColumns<TTableName, TColumnsMap, "pg">;
1220
+ dialect: "pg";
1221
+ };
1222
+ //# sourceMappingURL=$entity.d.ts.map
1195
1223
  //#endregion
1196
1224
  //#region src/descriptors/$repository.d.ts
1197
1225
  interface RepositoryDescriptorOptions<TEntity extends TableConfig, TSchema extends TObject> {
@@ -1211,6 +1239,7 @@ declare const $repository: {
1211
1239
  <TEntity extends TableConfig, TSchema extends TObject>(optionsOrTable: RepositoryDescriptorOptions<TEntity, TSchema> | PgTableWithColumnsAndSchema<TEntity, TSchema>): Repository<PgTableWithColumnsAndSchema<TEntity, TSchema>, TSchema>;
1212
1240
  [KIND]: string;
1213
1241
  };
1242
+ //# sourceMappingURL=$repository.d.ts.map
1214
1243
  //#endregion
1215
1244
  //#region src/descriptors/$sequence.d.ts
1216
1245
  declare const KEY = "SEQUENCE";
@@ -1240,7 +1269,8 @@ interface TransactionDescriptorOptions<T extends any[], R> {
1240
1269
  config?: PgTransactionConfig$1;
1241
1270
  }
1242
1271
  type TransactionContext = PgTransaction<any, any, any>;
1243
- declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry2.RetryDescriptor<(...args: T) => Promise<R>>;
1272
+ declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry19.RetryDescriptor<(...args: T) => Promise<R>>;
1273
+ //# sourceMappingURL=$transaction.d.ts.map
1244
1274
  //#endregion
1245
1275
  //#region src/errors/EntityNotFoundError.d.ts
1246
1276
  declare class EntityNotFoundError extends Error {
@@ -1248,15 +1278,16 @@ declare class EntityNotFoundError extends Error {
1248
1278
  readonly status = 404;
1249
1279
  constructor(entityName: string);
1250
1280
  }
1281
+ //# sourceMappingURL=EntityNotFoundError.d.ts.map
1251
1282
  //#endregion
1252
1283
  //#region src/providers/RepositoryDescriptorProvider.d.ts
1253
1284
  declare class RepositoryDescriptorProvider {
1254
- protected readonly log: _alepha_core17.Logger;
1285
+ protected readonly log: _alepha_core56.Logger;
1255
1286
  protected readonly alepha: Alepha;
1256
1287
  protected readonly repositories: Array<Repository<any, TObject$1>>;
1257
1288
  constructor();
1258
1289
  clearRepositories(): Promise<void>;
1259
- protected readonly configure: _alepha_core17.HookDescriptor<"configure">;
1290
+ protected readonly configure: _alepha_core56.HookDescriptor<"configure">;
1260
1291
  /**
1261
1292
  * Get all repositories.
1262
1293
  *
@@ -1286,10 +1317,11 @@ declare class RepositoryDescriptorProvider {
1286
1317
  */
1287
1318
  protected processRepositoryDescriptors(): Promise<void>;
1288
1319
  }
1320
+ //# sourceMappingURL=RepositoryDescriptorProvider.d.ts.map
1289
1321
  //#endregion
1290
1322
  //#region src/providers/DrizzleKitProvider.d.ts
1291
1323
  declare class DrizzleKitProvider {
1292
- protected readonly log: _alepha_core36.Logger;
1324
+ protected readonly log: _alepha_core20.Logger;
1293
1325
  protected readonly alepha: Alepha;
1294
1326
  protected readonly repositoryProvider: RepositoryDescriptorProvider;
1295
1327
  push(provider: PostgresProvider, schema?: string): Promise<void>;
@@ -1321,51 +1353,52 @@ declare class DrizzleKitProvider {
1321
1353
  */
1322
1354
  protected importDrizzleKit(): Promise<typeof DrizzleKit>;
1323
1355
  }
1356
+ //# sourceMappingURL=DrizzleKitProvider.d.ts.map
1324
1357
  //#endregion
1325
1358
  //#region src/providers/drivers/NodePostgresProvider.d.ts
1326
1359
  declare module "alepha" {
1327
1360
  interface Env extends Partial<Static<typeof envSchema>> {}
1328
1361
  }
1329
- declare const envSchema: _alepha_core58.TObject<{
1330
- PG_HOST: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
1331
- PG_USERNAME: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
1332
- PG_DATABASE: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
1333
- PG_PASSWORD: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
1334
- PG_PORT: _sinclair_typebox38.TOptional<_sinclair_typebox38.TNumber>;
1335
- DATABASE_URL: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
1336
- DATABASE_MIGRATIONS_FOLDER: _sinclair_typebox38.TString;
1362
+ declare const envSchema: TObject$1<{
1363
+ PG_HOST: _alepha_core22.TOptional<_alepha_core22.TString>;
1364
+ PG_USERNAME: _alepha_core22.TOptional<_alepha_core22.TString>;
1365
+ PG_DATABASE: _alepha_core22.TOptional<_alepha_core22.TString>;
1366
+ PG_PASSWORD: _alepha_core22.TOptional<_alepha_core22.TString>;
1367
+ PG_PORT: _alepha_core22.TOptional<_alepha_core22.TNumber>;
1368
+ DATABASE_URL: _alepha_core22.TOptional<_alepha_core22.TString>;
1369
+ DATABASE_MIGRATIONS_FOLDER: _alepha_core22.TString;
1337
1370
  /**
1338
1371
  * The schema to use.
1339
1372
  * Accept a string.
1340
1373
  */
1341
- POSTGRES_SCHEMA: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
1374
+ POSTGRES_SCHEMA: _alepha_core22.TOptional<_alepha_core22.TString>;
1342
1375
  /**
1343
1376
  * Synchronize the database schema with the models.
1344
1377
  * Accept a boolean or a postgres schema name.
1345
1378
  *
1346
1379
  * @default false
1347
1380
  */
1348
- POSTGRES_SYNCHRONIZE: _sinclair_typebox38.TOptional<_sinclair_typebox38.TBoolean>;
1381
+ POSTGRES_SYNCHRONIZE: _alepha_core22.TOptional<_alepha_core22.TBoolean>;
1349
1382
  /**
1350
1383
  * Push the schema to the database.
1351
1384
  *
1352
1385
  * @default false
1353
1386
  */
1354
- POSTGRES_PUSH_SCHEMA: _sinclair_typebox38.TOptional<_sinclair_typebox38.TBoolean>;
1387
+ POSTGRES_PUSH_SCHEMA: _alepha_core22.TOptional<_alepha_core22.TBoolean>;
1355
1388
  /**
1356
1389
  * Reject unauthorized SSL connections.
1357
1390
  *
1358
1391
  * @default false
1359
1392
  */
1360
- POSTGRES_REJECT_UNAUTHORIZED: _sinclair_typebox38.TBoolean;
1393
+ POSTGRES_REJECT_UNAUTHORIZED: _alepha_core22.TBoolean;
1361
1394
  }>;
1362
1395
  interface NodePostgresProviderState {
1363
1396
  client: postgres.Sql;
1364
1397
  db: PostgresJsDatabase;
1365
1398
  }
1366
- declare class NodePostgresProvider implements PostgresProvider {
1399
+ declare class NodePostgresProvider extends PostgresProvider {
1367
1400
  readonly dialect = "postgres";
1368
- protected readonly log: _alepha_core58.Logger;
1401
+ protected readonly log: _alepha_core22.Logger;
1369
1402
  protected readonly env: {
1370
1403
  DATABASE_URL?: string | undefined;
1371
1404
  PG_HOST?: string | undefined;
@@ -1387,16 +1420,16 @@ declare class NodePostgresProvider implements PostgresProvider {
1387
1420
  */
1388
1421
  protected testingSchemaName?: string;
1389
1422
  get db(): PostgresJsDatabase;
1390
- protected readonly configure: _alepha_core58.HookDescriptor<"start">;
1391
- protected readonly stop: _alepha_core58.HookDescriptor<"stop">;
1423
+ protected readonly configure: _alepha_core22.HookDescriptor<"start">;
1424
+ protected readonly stop: _alepha_core22.HookDescriptor<"stop">;
1392
1425
  /**
1393
1426
  * Get Postgres schema.
1394
1427
  */
1395
1428
  get schema(): string;
1396
- execute(query: SQLLike): Promise<any[]>;
1429
+ execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static<T> : any>>;
1397
1430
  connect(): Promise<void>;
1398
1431
  close(): Promise<void>;
1399
- protected migrate: _alepha_lock62.LockDescriptor<() => Promise<void>>;
1432
+ protected migrate: _alepha_lock45.LockDescriptor<() => Promise<void>>;
1400
1433
  protected createClient(): NodePostgresProviderState;
1401
1434
  protected getMigrationOptions(): MigrationConfig;
1402
1435
  protected getClientOptions(): postgres.Options<any>;
@@ -1412,15 +1445,20 @@ type PgAttr<T extends TSchema$1, TAttr extends PgSymbolKeys> = T & { [K in TAttr
1412
1445
  //#endregion
1413
1446
  //#region src/schemas/createdAtSchema.d.ts
1414
1447
  declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox85.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1448
+ //# sourceMappingURL=createdAtSchema.d.ts.map
1449
+
1415
1450
  //#endregion
1416
1451
  //#region src/schemas/legacyIdSchema.d.ts
1417
1452
  /**
1418
1453
  * @deprecated Use `pg.primaryKey()` instead.
1419
1454
  */
1420
1455
  declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox88.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1456
+ //# sourceMappingURL=legacyIdSchema.d.ts.map
1421
1457
  //#endregion
1422
1458
  //#region src/schemas/updatedAtSchema.d.ts
1423
1459
  declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox82.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1460
+ //# sourceMappingURL=updatedAtSchema.d.ts.map
1461
+
1424
1462
  //#endregion
1425
1463
  //#region src/schemas/entitySchema.d.ts
1426
1464
  /**
@@ -1429,9 +1467,9 @@ declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox82.TString, typeof
1429
1467
  * Add some common SQL properties to an object.
1430
1468
  */
1431
1469
  declare const entitySchema: TObject$1<{
1432
- id: PgAttr<PgAttr<PgAttr<_sinclair_typebox19.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1433
- createdAt: PgAttr<PgAttr<_sinclair_typebox19.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1434
- updatedAt: PgAttr<PgAttr<_sinclair_typebox19.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1470
+ id: PgAttr<PgAttr<PgAttr<_sinclair_typebox58.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
1471
+ createdAt: PgAttr<PgAttr<_sinclair_typebox58.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1472
+ updatedAt: PgAttr<PgAttr<_sinclair_typebox58.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1435
1473
  }>;
1436
1474
  /**
1437
1475
  * TypeBox Entity Type.
@@ -1453,9 +1491,10 @@ type BaseEntityKeys = keyof BaseEntity;
1453
1491
  * The keys of the base entity.
1454
1492
  */
1455
1493
  declare const entityKeys: readonly ["id", "createdAt", "updatedAt"];
1494
+ //# sourceMappingURL=entitySchema.d.ts.map
1456
1495
  //#endregion
1457
1496
  //#region src/providers/PostgresTypeProvider.d.ts
1458
- declare module "alepha/core" {
1497
+ declare module "alepha" {
1459
1498
  interface TypeProvider {
1460
1499
  pg: PostgresTypeProvider;
1461
1500
  }
@@ -1465,20 +1504,19 @@ declare class PostgresTypeProvider {
1465
1504
  /**
1466
1505
  * Creates a primary key with an identity column.
1467
1506
  */
1468
- readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox10.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1507
+ readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox49.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1469
1508
  /**
1470
1509
  * Creates a primary key with a big identity column. (default)
1471
1510
  */
1472
- readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox10.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1511
+ readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox49.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1473
1512
  /**
1474
1513
  * Creates a primary key with a UUID column.
1475
1514
  */
1476
- readonly uuidPrimaryKey: () => PgAttr<PgAttr<_sinclair_typebox10.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1515
+ readonly uuidPrimaryKey: () => PgAttr<PgAttr<_sinclair_typebox49.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
1477
1516
  /**
1478
- *
1479
1517
  * @alias bigIdentityPrimaryKey
1480
1518
  */
1481
- readonly primaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox10.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1519
+ readonly primaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox49.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
1482
1520
  /**
1483
1521
  * Wrap a schema with "default" attribute.
1484
1522
  * This is used to set a default value for a column in the database.
@@ -1489,15 +1527,15 @@ declare class PostgresTypeProvider {
1489
1527
  * This is used to track the version of a row in the database.
1490
1528
  * You can use it for optimistic concurrency control.
1491
1529
  */
1492
- readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<_sinclair_typebox10.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
1530
+ readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<_sinclair_typebox49.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
1493
1531
  /**
1494
1532
  * Creates a column Created At. So just a datetime column with a default value of the current timestamp.
1495
1533
  */
1496
- readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox10.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1534
+ readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox49.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
1497
1535
  /**
1498
1536
  * Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
1499
1537
  */
1500
- readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox10.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1538
+ readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox49.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
1501
1539
  /**
1502
1540
  * @deprecated Build your own entity schema.
1503
1541
  */
@@ -1537,12 +1575,13 @@ declare class PostgresTypeProvider {
1537
1575
  readonly many: <T extends TObject$1, Config extends TableConfig$1>(table: PgTableWithColumnsAndSchema<Config, T>, foreignKey: keyof T["properties"]) => TOptionalWithFlag<PgAttr<PgAttr<TArray<T>, PgMany>, PgDefault>, true>;
1538
1576
  }
1539
1577
  declare const pg: PostgresTypeProvider;
1578
+ //# sourceMappingURL=PostgresTypeProvider.d.ts.map
1540
1579
  //#endregion
1541
1580
  //#region src/types/schema.d.ts
1542
1581
  /**
1543
1582
  * Postgres schema type.
1544
1583
  */
1545
- declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) => drizzle_orm1.$Type<drizzle_orm_pg_core0.PgCustomColumnBuilder<{
1584
+ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) => drizzle_orm2.$Type<drizzle_orm_pg_core1.PgCustomColumnBuilder<{
1546
1585
  name: string;
1547
1586
  dataType: "custom";
1548
1587
  columnType: "PgCustomColumn";
@@ -1554,8 +1593,13 @@ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDoc
1554
1593
  }>, (TDocument & {
1555
1594
  params: [];
1556
1595
  })["static"]>;
1596
+ //# sourceMappingURL=schema.d.ts.map
1597
+
1557
1598
  //#endregion
1558
1599
  //#region src/index.d.ts
1600
+ declare module "alepha" {
1601
+ function $inject<T extends TableConfig, R extends TObject>(type: PgTableWithColumnsAndSchema<T, R>): Repository<PgTableWithColumnsAndSchema<T, R>, R>;
1602
+ }
1559
1603
  declare class AlephaPostgres implements Module {
1560
1604
  readonly name = "alepha.postgres";
1561
1605
  readonly env: {
@@ -1563,6 +1607,8 @@ declare class AlephaPostgres implements Module {
1563
1607
  };
1564
1608
  readonly $services: (alepha: Alepha) => void;
1565
1609
  }
1610
+ //# sourceMappingURL=index.d.ts.map
1611
+
1566
1612
  //#endregion
1567
- 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, Repository, RepositoryDescriptorOptions, RepositoryDescriptorProvider, SQLLike, SequenceDescriptor, SequenceDescriptorOptions, StatementOptions, TEntity$1 as TEntity, TInsertObject, TPage, TransactionContext, TransactionDescriptorOptions, camelToSnakeCase, drizzle, entityKeys, entitySchema, mapFieldToColumn, mapStringToColumn, nullToUndefined, pageQuerySchema, pageSchema, pg, pgTableSchema, schema, schemaToPgColumns, sql };
1613
+ 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 };
1568
1614
  //# sourceMappingURL=index.d.ts.map