alepha 0.9.5 → 0.10.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,5 +1,5 @@
1
1
  import * as _alepha_core1 from "alepha";
2
- import { Alepha, AlephaError, Descriptor, KIND, Service, Static, TNull, TObject, TOptional, TSchema as TSchema$1, TUnion } from "alepha";
2
+ import { Alepha, AlephaError, Descriptor, KIND, Service, Static, TArray, TBigInt, TBoolean, TInteger, TKeysToIndexer, TNull, TNumber, TNumberOptions, TObject, TObjectOptions, TOptional, TOptionalAdd, TPick, TRecord, TSchema as TSchema$1, TString, TStringOptions, TUnion } from "alepha";
3
3
  import * as drizzle_orm6 from "drizzle-orm";
4
4
  import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, TableConfig, sql } from "drizzle-orm";
5
5
  import * as pg$1 from "drizzle-orm/pg-core";
@@ -10,8 +10,7 @@ import * as _alepha_lock0 from "alepha/lock";
10
10
  import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
11
11
  import postgres from "postgres";
12
12
  import * as _alepha_retry0 from "alepha/retry";
13
- import * as _sinclair_typebox0 from "@sinclair/typebox";
14
- import { Evaluate, IntegerOptions, Kind, NumberOptions, ObjectOptions, OptionalKind, Static as Static$1, StringOptions, TAdditionalProperties, TArray, TBoolean, TInteger, TIntersect, TNumber, TObject as TObject$1, TOptional as TOptional$1, TOptionalWithFlag, TPick, TProperties, TReadonly, TRecord, TSchema as TSchema$2, TString } from "@sinclair/typebox";
13
+ import * as typebox1 from "typebox";
15
14
  import { PgTransactionConfig as PgTransactionConfig$1 } from "drizzle-orm/pg-core/session";
16
15
  import * as DrizzleKit from "drizzle-kit/api";
17
16
  import { MigrationConfig } from "drizzle-orm/migrator";
@@ -67,41 +66,19 @@ interface PgRefOptions {
67
66
  //#endregion
68
67
  //#region src/schemas/insertSchema.d.ts
69
68
  /**
70
- * Fork of the original typebox schema "TObject".
71
- */
72
- interface TObjectInsert<T extends TObject$1> extends TSchema$2, ObjectOptions {
73
- [Kind]: "Object";
74
- static: ObjectStatic<{ [K in keyof T["properties"] as T["properties"][K] extends {
75
- [PG_DEFAULT]: any;
76
- } ? never : K]: T["properties"][K] }, this["params"]>;
77
- additionalProperties?: TAdditionalProperties;
78
- type: "object";
79
- required?: string[];
80
- properties: { [K in keyof T["properties"] as T["properties"][K] extends {
81
- [PG_DEFAULT]: any;
82
- } ? never : K]: T["properties"][K] };
83
- }
84
- type ReadonlyOptionalPropertyKeys<T extends TProperties> = { [K in keyof T]: T[K] extends TReadonly<TSchema$2> ? T[K] extends TOptional$1<T[K]> ? K : never : never }[keyof T];
85
- type ReadonlyPropertyKeys<T extends TProperties> = { [K in keyof T]: T[K] extends TReadonly<TSchema$2> ? T[K] extends TOptional$1<T[K]> ? never : K : never }[keyof T];
86
- type OptionalPropertyKeys<T extends TProperties> = { [K in keyof T]: T[K] extends TOptional$1<TSchema$2> ? T[K] extends TReadonly<T[K]> ? never : K : never }[keyof T];
87
- type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
88
- type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>>;
89
- type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, { [K in keyof T]: Static$1<T[K], P> }>;
90
- declare const insertSchema: <T extends TObject$1>(obj: T) => TObjectInsert<T>;
91
- /**
92
- * Enhance Typebox with a support of "Default" (PG_DEFAULT).
69
+ * Transforms a TObject schema for insert operations.
70
+ * All default properties at the root level are made optional.
71
+ *
72
+ * @example
73
+ * Before: { name: string; age: number(default=0); }
74
+ * After: { name: string; age?: number; }
93
75
  */
94
- type StaticInsert<T extends TObject$1> = StaticEntry<T> & StaticDefaultEntry<T>;
95
- type StaticDefaultEntry<T extends TObject$1> = { [K in keyof T["properties"] as T["properties"][K] extends {
76
+ type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"]]: T["properties"][K] extends {
96
77
  [PG_DEFAULT]: any;
97
78
  } | {
98
- [OptionalKind]: "Optional";
99
- } ? K : never]?: Static$1<T["properties"][K]> };
100
- type StaticEntry<T extends TObject$1> = { [K in keyof T["properties"] as T["properties"][K] extends {
101
- [PG_DEFAULT]: any;
102
- } | {
103
- [OptionalKind]: "Optional";
104
- } ? never : K]: Static$1<T["properties"][K]> };
79
+ "~optional": true;
80
+ } ? TOptional<T["properties"][K]> : T["properties"][K] }>;
81
+ declare const insertSchema: <T extends TObject>(obj: T) => TObjectInsert<T>;
105
82
  //#endregion
106
83
  //#region src/schemas/updateSchema.d.ts
107
84
  /**
@@ -127,7 +104,7 @@ declare const schemaToPgColumns: <T extends TObject>(schema: T) => FromSchema<T>
127
104
  * @param value The value of the field.
128
105
  * @returns The PG column.
129
106
  */
130
- declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSerialBuilderInitial<string> | pg$1.PgIntegerBuilderInitial<string> | pg$1.PgBigInt53BuilderInitial<string> | pg$1.PgNumericBuilderInitial<string> | pg$1.PgTimestampBuilderInitial<string> | pg$1.PgUUIDBuilderInitial<string> | pg$1.PgCustomColumnBuilder<{
107
+ declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSerialBuilderInitial<string> | pg$1.PgIntegerBuilderInitial<string> | drizzle_orm6.IsIdentity<pg$1.PgBigInt64BuilderInitial<"">, "byDefault"> | drizzle_orm6.IsIdentity<pg$1.PgBigInt64BuilderInitial<"">, "always"> | pg$1.PgBigInt53BuilderInitial<string> | pg$1.PgNumericBuilderInitial<string> | pg$1.PgTimestampBuilderInitial<string> | pg$1.PgUUIDBuilderInitial<string> | pg$1.PgCustomColumnBuilder<{
131
108
  name: string;
132
109
  dataType: "custom";
133
110
  columnType: "PgCustomColumn";
@@ -141,20 +118,15 @@ declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSeria
141
118
  data: {
142
119
  [x: string]: unknown;
143
120
  [x: number]: unknown;
121
+ [x: symbol]: unknown;
144
122
  };
145
123
  driverParam: string;
146
124
  enumValues: undefined;
147
125
  }>, {
148
126
  [x: string]: unknown;
149
127
  [x: number]: unknown;
128
+ [x: symbol]: unknown;
150
129
  }> | drizzle_orm6.$Type<pg$1.PgCustomColumnBuilder<{
151
- name: string;
152
- dataType: "custom";
153
- columnType: "PgCustomColumn";
154
- data: {};
155
- driverParam: string;
156
- enumValues: undefined;
157
- }>, {}> | drizzle_orm6.$Type<pg$1.PgCustomColumnBuilder<{
158
130
  name: string;
159
131
  dataType: "custom";
160
132
  columnType: "PgCustomColumn";
@@ -494,10 +466,10 @@ type PgTableWithColumnsAndSchema<T extends TableConfig, R extends TObject> = PgT
494
466
  * @stability 2
495
467
  */
496
468
  declare const $entity: {
497
- <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>): PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
469
+ <TTableName extends string, TSchema extends TObject, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>): PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
498
470
  [KIND]: string;
499
471
  };
500
- interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1, Keys = keyof Static$1<T>> {
472
+ interface EntityDescriptorOptions<TTableName extends string, T extends TObject, Keys = keyof Static<T>> {
501
473
  /**
502
474
  * The database table name that will be created for this entity.
503
475
  *
@@ -659,7 +631,7 @@ interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1
659
631
  /**
660
632
  * Local columns that reference the foreign table.
661
633
  */
662
- columns: Array<keyof Static$1<T>>;
634
+ columns: Array<keyof Static<T>>;
663
635
  /**
664
636
  * Referenced columns in the foreign table.
665
637
  */
@@ -706,7 +678,7 @@ interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1
706
678
  /**
707
679
  * Columns involved in this constraint.
708
680
  */
709
- columns: Array<keyof Static$1<T>>;
681
+ columns: Array<keyof Static<T>>;
710
682
  /**
711
683
  * Optional name for the constraint.
712
684
  */
@@ -761,8 +733,8 @@ interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1
761
733
  */
762
734
  config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
763
735
  }
764
- type Entity<T extends TObject$1> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
765
- type PgTableConfig<TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>> = {
736
+ type Entity<T extends TObject> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
737
+ type PgTableConfig<TTableName extends string, TSchema extends TObject, TColumnsMap extends FromSchema<TSchema>> = {
766
738
  name: TTableName;
767
739
  schema: any;
768
740
  columns: BuildColumns<TTableName, TColumnsMap, "pg">;
@@ -1216,16 +1188,15 @@ type PgQueryWhere<T extends object> = { [Key in keyof T]?: FilterOperators<T[Key
1216
1188
  };
1217
1189
  //#endregion
1218
1190
  //#region src/interfaces/PgQuery.d.ts
1219
- interface PgQuery<T extends TObject$1, Select extends (keyof Static$1<T>)[] = []> {
1220
- columns?: Select;
1191
+ interface PgQuery<T extends TObject> {
1221
1192
  distinct?: boolean;
1222
- where?: PgQueryWhereOrSQL<Static$1<T>>;
1193
+ where?: PgQueryWhereOrSQL<Static<T>>;
1223
1194
  limit?: number;
1224
1195
  offset?: number;
1225
- sort?: { [key in keyof Static$1<T>]?: "asc" | "desc" };
1226
- groupBy?: (keyof Static$1<T>)[];
1196
+ sort?: { [key in keyof Static<T>]?: "asc" | "desc" };
1197
+ groupBy?: (keyof Static<T>)[];
1227
1198
  }
1228
- type PgQueryResult<T extends TObject$1, Select extends (keyof Static$1<T>)[]> = TPick<T, Select>;
1199
+ type PgQueryResult<T extends TObject, Select extends (keyof Static<T>)[]> = TPick<T, TKeysToIndexer<Select>>;
1229
1200
  //#endregion
1230
1201
  //#region src/providers/drivers/PostgresProvider.d.ts
1231
1202
  type SQLLike = SQLWrapper | string;
@@ -1234,35 +1205,38 @@ declare abstract class PostgresProvider {
1234
1205
  abstract get db(): PgDatabase<any>;
1235
1206
  abstract get schema(): string;
1236
1207
  abstract get dialect(): string;
1237
- abstract execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static$1<T> : any>>;
1208
+ abstract execute<T extends TObject | undefined = undefined>(query: SQLLike, schema?: T): Promise<Array<T extends TObject ? Static<T> : any>>;
1238
1209
  }
1239
1210
  //#endregion
1240
1211
  //#region src/schemas/pageQuerySchema.d.ts
1241
- declare const pageQuerySchema: _sinclair_typebox0.TObject<{
1242
- page: _sinclair_typebox0.TOptional<_sinclair_typebox0.TNumber>;
1243
- size: _sinclair_typebox0.TOptional<_sinclair_typebox0.TNumber>;
1244
- sort: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
1212
+ declare const pageQuerySchema: typebox1.TObject<{
1213
+ page: typebox1.TOptional<typebox1.TInteger>;
1214
+ size: typebox1.TOptional<typebox1.TInteger>;
1215
+ sort: typebox1.TOptional<typebox1.TString>;
1245
1216
  }>;
1246
1217
  type PageQuery = Static<typeof pageQuerySchema>;
1247
1218
  //#endregion
1248
1219
  //#region src/schemas/pageSchema.d.ts
1249
1220
  /**
1250
- * Page Schema
1221
+ * Create a pagination schema for the given object schema.
1222
+ *
1223
+ * @example
1224
+ * const userSchema = t.object({ id: t.int(), name: t.string() });
1225
+ * const pagedUserSchema = pageSchema(userSchema);
1251
1226
  *
1252
- * @param objectSchema
1253
- * @param options
1227
+ * @see {@link $repository#paginate}
1254
1228
  */
1255
- declare const pageSchema: <T extends TObject$1 | TIntersect | TRecord>(objectSchema: T, options?: ObjectOptions) => TPage<T>;
1256
- type TPage<T extends TObject$1 | TIntersect | TRecord> = TObject$1<{
1229
+ declare const pageSchema: <T extends TObject | TRecord>(objectSchema: T, options?: TObjectOptions) => TPage<T>;
1230
+ type TPage<T extends TObject | TRecord> = TObject<{
1257
1231
  content: TArray<T>;
1258
- can: TObject$1<{
1232
+ can: TObject<{
1259
1233
  next: TBoolean;
1260
1234
  previous: TBoolean;
1261
1235
  }>;
1262
- page: TObject$1<{
1236
+ page: TObject<{
1263
1237
  number: TInteger;
1264
1238
  size: TInteger;
1265
- totalElements: TOptionalWithFlag<TInteger, true>;
1239
+ totalElements: TOptionalAdd<TInteger>;
1266
1240
  }>;
1267
1241
  }>;
1268
1242
  type Page<T> = {
@@ -1593,10 +1567,10 @@ type Page<T> = {
1593
1567
  * @stability 3
1594
1568
  */
1595
1569
  declare const $repository: {
1596
- <EntityTableConfig extends TableConfig, EntitySchema extends TObject$1>(optionsOrTable: RepositoryDescriptorOptions<EntityTableConfig, EntitySchema> | PgTableWithColumnsAndSchema<EntityTableConfig, EntitySchema>): RepositoryDescriptor<EntityTableConfig, EntitySchema>;
1570
+ <EntityTableConfig extends TableConfig, EntitySchema extends TObject>(optionsOrTable: RepositoryDescriptorOptions<EntityTableConfig, EntitySchema> | PgTableWithColumnsAndSchema<EntityTableConfig, EntitySchema>): RepositoryDescriptor<EntityTableConfig, EntitySchema>;
1597
1571
  [KIND]: typeof RepositoryDescriptor;
1598
1572
  };
1599
- interface RepositoryDescriptorOptions<EntityTableConfig extends TableConfig, EntitySchema extends TObject$1> {
1573
+ interface RepositoryDescriptorOptions<EntityTableConfig extends TableConfig, EntitySchema extends TObject> {
1600
1574
  /**
1601
1575
  * The entity table definition created with $entity.
1602
1576
  *
@@ -1656,10 +1630,10 @@ interface RepositoryDescriptorOptions<EntityTableConfig extends TableConfig, Ent
1656
1630
  */
1657
1631
  provider?: Service<PostgresProvider>;
1658
1632
  }
1659
- declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, EntitySchema extends TObject$1> extends Descriptor<RepositoryDescriptorOptions<EntityTableConfig, EntitySchema>> {
1633
+ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, EntitySchema extends TObject> extends Descriptor<RepositoryDescriptorOptions<EntityTableConfig, EntitySchema>> {
1660
1634
  protected readonly dateTimeProvider: DateTimeProvider;
1661
- readonly provider: PostgresProvider;
1662
1635
  protected readonly alepha: Alepha;
1636
+ readonly provider: PostgresProvider;
1663
1637
  readonly schema: EntitySchema;
1664
1638
  readonly schemaInsert: TObjectInsert<EntitySchema>;
1665
1639
  /**
@@ -1670,7 +1644,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1670
1644
  * ID is mandatory. If the table does not have a primary key, it will throw an error.
1671
1645
  */
1672
1646
  readonly id: {
1673
- type: TSchema$2;
1647
+ type: TSchema$1;
1674
1648
  key: keyof EntitySchema["properties"];
1675
1649
  col: PgColumn;
1676
1650
  };
@@ -1689,7 +1663,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1689
1663
  /**
1690
1664
  * Execute a SQL query.
1691
1665
  */
1692
- query<T extends TObject$1 = EntitySchema>(query: SQLLike | ((table: PgTableWithColumns<EntityTableConfig>, db: PgDatabase<any>) => SQLLike), schema?: T): Promise<Static$1<T>[]>;
1666
+ query<T extends TObject = EntitySchema>(query: SQLLike | ((table: PgTableWithColumns<EntityTableConfig>, db: PgDatabase<any>) => SQLLike), schema?: T): Promise<Static<T>[]>;
1693
1667
  protected mapRawFieldsToEntity(row: any[]): any;
1694
1668
  /**
1695
1669
  * Get a Drizzle column from the table by his name.
@@ -1745,7 +1719,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1745
1719
  * @param opts The statement options.
1746
1720
  * @returns The found entities.
1747
1721
  */
1748
- find<Select extends (keyof Static$1<EntitySchema>)[]>(query?: PgQuery<EntitySchema, Select>, opts?: StatementOptions): Promise<Static$1<PgQueryResult<EntitySchema, Select>>[]>;
1722
+ find(query?: PgQuery<EntitySchema>, opts?: StatementOptions): Promise<Static<EntitySchema>[]>;
1749
1723
  /**
1750
1724
  * Find a single entity.
1751
1725
  *
@@ -1753,19 +1727,19 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1753
1727
  * @param opts The statement options.
1754
1728
  * @returns The found entity.
1755
1729
  */
1756
- findOne<T extends Static$1<EntitySchema> = Static$1<EntitySchema>>(where: PgQueryWhere<T>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1730
+ findOne<T extends Static<EntitySchema> = Static<EntitySchema>>(where: PgQueryWhere<T>, opts?: StatementOptions): Promise<Static<EntitySchema>>;
1757
1731
  /**
1758
1732
  * Find an entity by ID.
1759
1733
  */
1760
- findById(id: string | number, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1734
+ findById(id: string | number, opts?: StatementOptions): Promise<Static<EntitySchema>>;
1761
1735
  /**
1762
1736
  * Paginate entities.
1763
1737
  */
1764
1738
  paginate(pagination?: PageQuery, query?: PgQuery<EntitySchema>, opts?: StatementOptions & {
1765
1739
  count?: boolean;
1766
- }): Promise<Page<Static$1<EntitySchema>>>;
1740
+ }): Promise<Page<Static<EntitySchema>>>;
1767
1741
  createQuery(query?: PgQuery<EntitySchema>): PgQuery<EntitySchema>;
1768
- createQueryWhere(where?: PgQueryWhere<Static$1<EntitySchema>>): PgQueryWhere<Static$1<EntitySchema>>;
1742
+ createQueryWhere(where?: PgQueryWhere<Static<EntitySchema>>): PgQueryWhere<Static<EntitySchema>>;
1769
1743
  /**
1770
1744
  * Create an entity.
1771
1745
  *
@@ -1773,7 +1747,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1773
1747
  * @param opts The options for creating the entity.
1774
1748
  * @returns The ID of the created entity.
1775
1749
  */
1776
- create(data: StaticInsert<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1750
+ create(data: Static<TObjectInsert<EntitySchema>>, opts?: StatementOptions): Promise<Static<EntitySchema>>;
1777
1751
  /**
1778
1752
  * Create many entities.
1779
1753
  *
@@ -1781,11 +1755,11 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1781
1755
  * @param opts The statement options.
1782
1756
  * @returns The created entities.
1783
1757
  */
1784
- createMany(values: Array<StaticInsert<EntitySchema>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>[]>;
1758
+ createMany(values: Array<Static<TObjectInsert<EntitySchema>>>, opts?: StatementOptions): Promise<Static<EntitySchema>[]>;
1785
1759
  /**
1786
1760
  * Find an entity and update it.
1787
1761
  */
1788
- updateOne(where: PgQueryWhereOrSQL<Static$1<EntitySchema>>, data: Partial<Static$1<TObjectUpdate<EntitySchema>>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1762
+ updateOne(where: PgQueryWhereOrSQL<Static<EntitySchema>>, data: Partial<Static<TObjectUpdate<EntitySchema>>>, opts?: StatementOptions): Promise<Static<EntitySchema>>;
1789
1763
  /**
1790
1764
  * Save a given entity.
1791
1765
  *
@@ -1807,19 +1781,19 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1807
1781
  * @see {@link PostgresTypeProvider#version}
1808
1782
  * @see {@link PgVersionMismatchError}
1809
1783
  */
1810
- save(entity: Static$1<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1784
+ save(entity: Static<EntitySchema>, opts?: StatementOptions): Promise<Static<EntitySchema>>;
1811
1785
  /**
1812
1786
  * Find an entity by ID and update it.
1813
1787
  */
1814
- updateById(id: string | number, data: Partial<Static$1<TObjectUpdate<EntitySchema>>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
1788
+ updateById(id: string | number, data: Partial<Static<TObjectUpdate<EntitySchema>>>, opts?: StatementOptions): Promise<Static<EntitySchema>>;
1815
1789
  /**
1816
1790
  * Find many entities and update all of them.
1817
1791
  */
1818
- updateMany(where: PgQueryWhereOrSQL<Static$1<EntitySchema>>, data: Partial<Static$1<TObjectUpdate<EntitySchema>>>, opts?: StatementOptions): Promise<void>;
1792
+ updateMany(where: PgQueryWhereOrSQL<Static<EntitySchema>>, data: Partial<Static<TObjectUpdate<EntitySchema>>>, opts?: StatementOptions): Promise<void>;
1819
1793
  /**
1820
1794
  * Find many and delete all of them.
1821
1795
  */
1822
- deleteMany(where?: PgQueryWhere<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<void>;
1796
+ deleteMany(where?: PgQueryWhere<Static<EntitySchema>>, opts?: StatementOptions): Promise<void>;
1823
1797
  /**
1824
1798
  * Delete all entities.
1825
1799
  */
@@ -1829,11 +1803,11 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1829
1803
  *
1830
1804
  * You must fetch the entity first in order to delete it.
1831
1805
  */
1832
- destroy(entity: Static$1<EntitySchema>, opts?: StatementOptions): Promise<void>;
1806
+ destroy(entity: Static<EntitySchema>, opts?: StatementOptions): Promise<void>;
1833
1807
  /**
1834
1808
  * Find an entity and delete it.
1835
1809
  */
1836
- deleteOne(where?: PgQueryWhere<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<void>;
1810
+ deleteOne(where?: PgQueryWhere<Static<EntitySchema>>, opts?: StatementOptions): Promise<void>;
1837
1811
  /**
1838
1812
  * Find an entity by ID and delete it.
1839
1813
  */
@@ -1841,14 +1815,12 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1841
1815
  /**
1842
1816
  * Count entities.
1843
1817
  */
1844
- count(where?: PgQueryWhereOrSQL<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<number>;
1818
+ count(where?: PgQueryWhereOrSQL<Static<EntitySchema>>, opts?: StatementOptions): Promise<number>;
1845
1819
  protected conflictMessagePattern: string;
1846
1820
  protected handleError(error: unknown, message: string): PgError;
1847
- protected withDeletedAt(where: PgQueryWhereOrSQL<Static$1<EntitySchema>>, opts?: {
1821
+ protected withDeletedAt(where: PgQueryWhereOrSQL<Static<EntitySchema>>, opts?: {
1848
1822
  force?: boolean;
1849
- }): PgQueryWhereOrSQL<(EntitySchema & {
1850
- params: [];
1851
- })["static"]>;
1823
+ }): PgQueryWhereOrSQL<Static<EntitySchema>>;
1852
1824
  protected get organization(): undefined;
1853
1825
  protected deletedAt(): PgAttrField | undefined;
1854
1826
  /**
@@ -1858,7 +1830,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1858
1830
  * @param schema The schema to use.
1859
1831
  * @param col The column to use.
1860
1832
  */
1861
- protected jsonQueryToSql(query: PgQueryWhereOrSQL<Static$1<EntitySchema>>, schema?: TObject$1, col?: (key: string) => PgColumn): SQL | undefined;
1833
+ protected jsonQueryToSql(query: PgQueryWhereOrSQL<Static<EntitySchema>>, schema?: TObject, col?: (key: string) => PgColumn): SQL | undefined;
1862
1834
  /**
1863
1835
  * Map a filter operator to a SQL query.
1864
1836
  *
@@ -1874,7 +1846,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1874
1846
  * @param limit The limit of the pagination.
1875
1847
  * @param offset The offset of the pagination.
1876
1848
  */
1877
- protected createPagination(entities: Static$1<EntitySchema>[], limit?: number, offset?: number): Page<Static$1<EntitySchema>>;
1849
+ protected createPagination(entities: Static<EntitySchema>[], limit?: number, offset?: number): Page<Static<EntitySchema>>;
1878
1850
  /**
1879
1851
  * Convert something to valid Pg Insert Value.
1880
1852
  */
@@ -1886,24 +1858,24 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
1886
1858
  * @param schema The schema to use.
1887
1859
  * @returns The cleaned row.
1888
1860
  */
1889
- protected clean<T extends TObject$1 = EntitySchema>(row: any, schema?: T): Static$1<T>;
1861
+ protected clean<T extends TObject = EntitySchema>(row: any, schema?: T): Static<T>;
1890
1862
  /**
1891
1863
  * Get the where clause for an ID.
1892
1864
  *
1893
1865
  * @param id The ID to get the where clause for.
1894
1866
  * @returns The where clause for the ID.
1895
1867
  */
1896
- protected getWhereId(id: string | number): PgQueryWhere<Static$1<EntitySchema>>;
1868
+ protected getWhereId(id: string | number): PgQueryWhere<Static<EntitySchema>>;
1897
1869
  /**
1898
1870
  * Find a primary key in the schema.
1899
1871
  *
1900
1872
  * @param schema
1901
1873
  * @protected
1902
1874
  */
1903
- protected getPrimaryKey(schema: TObject$1): {
1875
+ protected getPrimaryKey(schema: TObject): {
1904
1876
  key: string;
1905
1877
  col: PgColumn<drizzle_orm6.ColumnBaseConfig<drizzle_orm6.ColumnDataType, string>, {}, {}>;
1906
- type: TSchema$2;
1878
+ type: TSchema$1;
1907
1879
  };
1908
1880
  }
1909
1881
  /**
@@ -2792,13 +2764,13 @@ declare class PgEntityNotFoundError extends PgError {
2792
2764
  declare class RepositoryProvider {
2793
2765
  protected readonly log: _alepha_logger1.Logger;
2794
2766
  protected readonly alepha: Alepha;
2795
- protected get repositories(): RepositoryDescriptor<TableConfig$1, TObject$1>[];
2767
+ protected get repositories(): RepositoryDescriptor<TableConfig$1, TObject>[];
2796
2768
  /**
2797
2769
  * Get all repositories.
2798
2770
  *
2799
2771
  * @param provider - Filter by provider.
2800
2772
  */
2801
- getRepositories(provider?: PostgresProvider): RepositoryDescriptor<TableConfig$1, TObject$1>[];
2773
+ getRepositories(provider?: PostgresProvider): RepositoryDescriptor<TableConfig$1, TObject>[];
2802
2774
  /**
2803
2775
  * Get all tables from the repositories.
2804
2776
  *
@@ -2851,7 +2823,7 @@ declare class DrizzleKitProvider {
2851
2823
  declare module "alepha" {
2852
2824
  interface Env extends Partial<Static<typeof envSchema>> {}
2853
2825
  }
2854
- declare const envSchema: TObject$1<{
2826
+ declare const envSchema: TObject<{
2855
2827
  /**
2856
2828
  * Main configuration for database connection.
2857
2829
  * Accept a string in the format of a Postgres connection URL.
@@ -2915,7 +2887,7 @@ declare class NodePostgresProvider extends PostgresProvider {
2915
2887
  get db(): PostgresJsDatabase;
2916
2888
  protected readonly configure: _alepha_core1.HookDescriptor<"start">;
2917
2889
  protected readonly stop: _alepha_core1.HookDescriptor<"stop">;
2918
- execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static<T> : any>>;
2890
+ execute<T extends TObject | undefined = undefined>(query: SQLLike, schema?: T): Promise<Array<T extends TObject ? Static<T> : any>>;
2919
2891
  connect(): Promise<void>;
2920
2892
  close(): Promise<void>;
2921
2893
  protected migrate: _alepha_lock0.LockDescriptor<() => Promise<void>>;
@@ -2943,25 +2915,20 @@ declare class NodePostgresProvider extends PostgresProvider {
2943
2915
  * TODO: options to skip deletion on failure, in order to inspect the schema?
2944
2916
  */
2945
2917
  protected generateTestSchemaName(): string;
2946
- protected mapResult<T extends TObject$1 = any>(result: Array<any>, schema?: T): Array<T extends TObject$1 ? Static<T> : any>;
2918
+ protected mapResult<T extends TObject = any>(result: Array<any>, schema?: T): Array<T extends TObject ? Static<T> : any>;
2947
2919
  }
2948
2920
  //#endregion
2949
2921
  //#region src/providers/PostgresTypeProvider.d.ts
2950
- declare module "alepha" {
2951
- interface TypeProvider {
2952
- pg: PostgresTypeProvider;
2953
- }
2954
- }
2955
2922
  declare class PostgresTypeProvider {
2956
- readonly attr: <T extends TSchema$2, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
2923
+ readonly attr: <T extends TSchema$1, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
2957
2924
  /**
2958
2925
  * Creates a primary key with an identity column.
2959
2926
  */
2960
- readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
2927
+ readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
2961
2928
  /**
2962
2929
  * Creates a primary key with a big identity column. (default)
2963
2930
  */
2964
- readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
2931
+ readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
2965
2932
  /**
2966
2933
  * Creates a primary key with a UUID column.
2967
2934
  */
@@ -2973,14 +2940,15 @@ declare class PostgresTypeProvider {
2973
2940
  * - `t.uuid()` -> PG UUID
2974
2941
  */
2975
2942
  primaryKey(): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
2976
- primaryKey(type: TString, options?: StringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
2977
- primaryKey(type: TInteger, options?: IntegerOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
2978
- primaryKey(type: TNumber, options?: NumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
2943
+ primaryKey(type: TString, options?: TStringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
2944
+ primaryKey(type: TInteger, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
2945
+ primaryKey(type: TNumber, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
2946
+ primaryKey(type: TBigInt, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TBigInt, PgPrimaryKey>, PgDefault>;
2979
2947
  /**
2980
2948
  * Wrap a schema with "default" attribute.
2981
2949
  * This is used to set a default value for a column in the database.
2982
2950
  */
2983
- readonly default: <T extends TSchema$2>(type: T, value?: Static$1<T>) => PgAttr<T, PgDefault>;
2951
+ readonly default: <T extends TSchema$1>(type: T, value?: Static<T>) => PgAttr<T, PgDefault>;
2984
2952
  /**
2985
2953
  * Creates a column 'version'.
2986
2954
  *
@@ -2991,25 +2959,25 @@ declare class PostgresTypeProvider {
2991
2959
  * @see {@link RepositoryDescriptor#save}
2992
2960
  * @see {@link PgVersionMismatchError}
2993
2961
  */
2994
- readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
2962
+ readonly version: (options?: TNumberOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
2995
2963
  /**
2996
2964
  * Creates a column Created At. So just a datetime column with a default value of the current timestamp.
2997
2965
  */
2998
- readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
2966
+ readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
2999
2967
  /**
3000
2968
  * Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
3001
2969
  */
3002
- readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
2970
+ readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
3003
2971
  /**
3004
2972
  * Creates a column Deleted At for soft delete functionality.
3005
2973
  * This is used to mark rows as deleted without actually removing them from the database.
3006
2974
  * The column is nullable - NULL means not deleted, timestamp means deleted.
3007
2975
  */
3008
- readonly deletedAt: (options?: StringOptions) => PgAttr<_sinclair_typebox0.TOptional<TString>, typeof PG_DELETED_AT>;
2976
+ readonly deletedAt: (options?: TStringOptions) => PgAttr<typebox1.TOptional<TString>, typeof PG_DELETED_AT>;
3009
2977
  /**
3010
2978
  * Creates a reference to another table or schema. Basically a foreign key.
3011
2979
  */
3012
- readonly ref: <T extends TSchema$2>(type: T, ref: () => any, actions?: {
2980
+ readonly ref: <T extends TSchema$1>(type: T, ref: () => any, actions?: {
3013
2981
  onUpdate?: UpdateDeleteAction$1;
3014
2982
  onDelete?: UpdateDeleteAction$1;
3015
2983
  }) => PgAttr<T, PgRef>;
@@ -3017,7 +2985,7 @@ declare class PostgresTypeProvider {
3017
2985
  * Creates a page schema for a given object schema.
3018
2986
  * It's used by {@link RepositoryDescriptor#paginate} method.
3019
2987
  */
3020
- readonly page: <T extends TObject$1>(resource: T, options?: ObjectOptions) => TPage<T>;
2988
+ readonly page: <T extends TObject>(resource: T, options?: TObjectOptions) => TPage<T>;
3021
2989
  }
3022
2990
  declare const pg: PostgresTypeProvider;
3023
2991
  //#endregion
@@ -3025,24 +2993,20 @@ declare const pg: PostgresTypeProvider;
3025
2993
  /**
3026
2994
  * @deprecated Use `pg.primaryKey()` instead.
3027
2995
  */
3028
- declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
2996
+ declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<typebox1.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
3029
2997
  //#endregion
3030
2998
  //#region src/types/schema.d.ts
3031
2999
  /**
3032
3000
  * Postgres schema type.
3033
3001
  */
3034
- declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) => drizzle_orm6.$Type<pg$1.PgCustomColumnBuilder<{
3002
+ declare const schema: <TDocument extends TSchema$1>(name: string, document: TDocument) => drizzle_orm6.$Type<pg$1.PgCustomColumnBuilder<{
3035
3003
  name: string;
3036
3004
  dataType: "custom";
3037
3005
  columnType: "PgCustomColumn";
3038
- data: (TDocument & {
3039
- params: [];
3040
- })["static"];
3006
+ data: Static<TDocument>;
3041
3007
  driverParam: string;
3042
3008
  enumValues: undefined;
3043
- }>, (TDocument & {
3044
- params: [];
3045
- })["static"]>;
3009
+ }>, Static<TDocument>>;
3046
3010
  //#endregion
3047
3011
  //#region src/index.d.ts
3048
3012
  /**
@@ -3087,5 +3051,5 @@ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDoc
3087
3051
  */
3088
3052
  declare const AlephaPostgres: _alepha_core1.Service<_alepha_core1.Module>;
3089
3053
  //#endregion
3090
- export { $entity, $repository, $sequence, $transaction, AlephaPostgres, DrizzleKitProvider, Entity, EntityDescriptorOptions, FilterOperators, FromSchema, NodePostgresProvider, NodePostgresProviderOptions, PG_CREATED_AT, PG_DEFAULT, PG_DELETED_AT, PG_IDENTITY, PG_PRIMARY_KEY, PG_REF, PG_SCHEMA, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, Page, PageQuery, PgDefault, PgEntityNotFoundError, PgIdentityOptions, PgPrimaryKey, PgQuery, PgQueryResult, PgQueryWhere, PgQueryWhereOrSQL, PgRef, PgRefOptions, PgSymbolKeys, PgSymbols, PgTableConfig, PgTableWithColumnsAndSchema, PostgresProvider, PostgresTypeProvider, RepositoryDescriptor, RepositoryDescriptorOptions, RepositoryProvider, SQLLike, SequenceDescriptor, SequenceDescriptorOptions, StatementOptions, StaticDefaultEntry, StaticEntry, StaticInsert, TObjectInsert, TPage, TransactionContext, TransactionDescriptorOptions, camelToSnakeCase, drizzle_orm6 as drizzle, insertSchema, legacyIdSchema, mapFieldToColumn, mapStringToColumn, pageQuerySchema, pageSchema, pg, schema, schemaToPgColumns, sql };
3054
+ export { $entity, $repository, $sequence, $transaction, AlephaPostgres, DrizzleKitProvider, Entity, EntityDescriptorOptions, FilterOperators, FromSchema, NodePostgresProvider, NodePostgresProviderOptions, PG_CREATED_AT, PG_DEFAULT, PG_DELETED_AT, PG_IDENTITY, PG_PRIMARY_KEY, PG_REF, PG_SCHEMA, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, Page, PageQuery, PgDefault, PgEntityNotFoundError, PgIdentityOptions, PgPrimaryKey, PgQuery, PgQueryResult, PgQueryWhere, PgQueryWhereOrSQL, PgRef, PgRefOptions, PgSymbolKeys, PgSymbols, PgTableConfig, PgTableWithColumnsAndSchema, PostgresProvider, PostgresTypeProvider, RepositoryDescriptor, RepositoryDescriptorOptions, RepositoryProvider, SQLLike, SequenceDescriptor, SequenceDescriptorOptions, StatementOptions, TObjectInsert, TPage, TransactionContext, TransactionDescriptorOptions, camelToSnakeCase, drizzle_orm6 as drizzle, insertSchema, legacyIdSchema, mapFieldToColumn, mapStringToColumn, pageQuerySchema, pageSchema, pg, schema, schemaToPgColumns, sql };
3091
3055
  //# sourceMappingURL=index.d.ts.map
package/queue/redis.d.ts CHANGED
@@ -2,11 +2,11 @@ import * as _alepha_core0 from "alepha";
2
2
  import { Static } from "alepha";
3
3
  import { QueueProvider } from "alepha/queue";
4
4
  import { RedisProvider } from "alepha/redis";
5
- import * as _sinclair_typebox0 from "@sinclair/typebox";
5
+ import * as typebox0 from "typebox";
6
6
 
7
7
  //#region src/providers/RedisQueueProvider.d.ts
8
- declare const envSchema: _sinclair_typebox0.TObject<{
9
- REDIS_QUEUE_PREFIX: _sinclair_typebox0.TString;
8
+ declare const envSchema: typebox0.TObject<{
9
+ REDIS_QUEUE_PREFIX: typebox0.TString;
10
10
  }>;
11
11
  declare class RedisQueueProvider implements QueueProvider {
12
12
  protected readonly env: Static<typeof envSchema>;