alepha 0.7.7 → 0.8.1
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/LICENSE +21 -21
- package/README.md +7 -34
- package/batch.cjs +8 -0
- package/batch.d.ts +147 -0
- package/batch.js +1 -0
- package/cache/redis.d.ts +13 -18
- package/cache.d.ts +183 -119
- package/command.cjs +8 -0
- package/command.d.ts +152 -0
- package/command.js +1 -0
- package/core.d.ts +846 -838
- package/datetime.d.ts +78 -78
- package/file.cjs +8 -0
- package/file.d.ts +46 -0
- package/file.js +1 -0
- package/lock/redis.d.ts +10 -12
- package/lock.d.ts +73 -80
- package/package.json +86 -34
- package/postgres.d.ts +348 -170
- package/queue/redis.d.ts +13 -13
- package/queue.d.ts +107 -18
- package/react/auth.d.ts +22 -16
- package/react/head.d.ts +10 -4
- package/react.d.ts +206 -49
- package/redis.d.ts +23 -27
- package/retry.d.ts +75 -54
- package/router.cjs +8 -0
- package/router.d.ts +45 -0
- package/router.js +1 -0
- package/scheduler.d.ts +15 -16
- package/security.d.ts +229 -40
- package/server/cache.d.ts +7 -8
- package/server/compress.cjs +8 -0
- package/server/compress.d.ts +26 -0
- package/server/compress.js +1 -0
- package/server/cookies.d.ts +249 -18
- package/server/cors.d.ts +7 -3
- package/server/health.d.ts +21 -24
- package/server/helmet.cjs +8 -0
- package/server/helmet.d.ts +70 -0
- package/server/helmet.js +1 -0
- package/server/links.d.ts +87 -93
- package/server/metrics.cjs +8 -0
- package/server/metrics.d.ts +35 -0
- package/server/metrics.js +1 -0
- package/server/multipart.cjs +8 -0
- package/server/multipart.d.ts +46 -0
- package/server/multipart.js +1 -0
- package/server/proxy.d.ts +11 -11
- package/server/static.d.ts +70 -55
- package/server/swagger.d.ts +55 -54
- package/server.d.ts +273 -123
- package/topic/redis.d.ts +22 -23
- package/topic.d.ts +26 -19
- package/vite.d.ts +59 -36
package/postgres.d.ts
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import { Alepha, KIND, Module, OPTIONS, Static, TObject, TSchema as TSchema$1 } from "
|
|
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
5
|
import * as drizzle_orm3 from "drizzle-orm";
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
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
|
|
10
|
+
import * as _alepha_lock44 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
|
|
15
|
-
import * as
|
|
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
|
|
18
|
-
import * as
|
|
19
|
-
import * as
|
|
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
20
|
import * as _sinclair_typebox85 from "@sinclair/typebox";
|
|
21
|
-
import * as _sinclair_typebox88 from "@sinclair/typebox";
|
|
22
21
|
import * as _sinclair_typebox82 from "@sinclair/typebox";
|
|
23
|
-
import * as
|
|
24
|
-
import * as
|
|
22
|
+
import * as _sinclair_typebox57 from "@sinclair/typebox";
|
|
23
|
+
import * as _sinclair_typebox48 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
|
-
|
|
277
|
-
|
|
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:
|
|
854
|
-
page:
|
|
855
|
-
size:
|
|
856
|
-
sort:
|
|
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>;
|
|
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,
|
|
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>,
|
|
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):
|
|
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<
|
|
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):
|
|
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):
|
|
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):
|
|
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<
|
|
1091
|
+
col: PgColumn<drizzle_orm8.ColumnBaseConfig<drizzle_orm8.ColumnDataType, string>, {}, {}>;
|
|
1162
1092
|
type: TSchema$2;
|
|
1163
1093
|
};
|
|
1164
1094
|
}
|
|
@@ -1192,28 +1122,134 @@ interface PgAttrField {
|
|
|
1192
1122
|
data: any;
|
|
1193
1123
|
nested?: any[];
|
|
1194
1124
|
}
|
|
1125
|
+
//# sourceMappingURL=Repository.d.ts.map
|
|
1195
1126
|
//#endregion
|
|
1196
|
-
//#region src/
|
|
1197
|
-
|
|
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>> {
|
|
1198
1155
|
/**
|
|
1199
|
-
* The table
|
|
1156
|
+
* The name of the table. This is the name that will be used in the database.
|
|
1157
|
+
* @example
|
|
1158
|
+
* name: "user"
|
|
1200
1159
|
*/
|
|
1201
|
-
|
|
1160
|
+
name: TTableName;
|
|
1202
1161
|
/**
|
|
1203
|
-
*
|
|
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
|
+
* })
|
|
1204
1170
|
*/
|
|
1205
|
-
|
|
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[];
|
|
1206
1209
|
}
|
|
1210
|
+
type Entity<T extends TObject$1> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
|
|
1207
1211
|
/**
|
|
1208
|
-
*
|
|
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
|
+
*
|
|
1209
1230
|
*/
|
|
1210
1231
|
declare const $repository: {
|
|
1211
1232
|
<TEntity extends TableConfig, TSchema extends TObject>(optionsOrTable: RepositoryDescriptorOptions<TEntity, TSchema> | PgTableWithColumnsAndSchema<TEntity, TSchema>): Repository<PgTableWithColumnsAndSchema<TEntity, TSchema>, TSchema>;
|
|
1212
1233
|
[KIND]: string;
|
|
1213
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
|
+
//# sourceMappingURL=$repository.d.ts.map
|
|
1214
1246
|
//#endregion
|
|
1215
1247
|
//#region src/descriptors/$sequence.d.ts
|
|
1216
1248
|
declare const KEY = "SEQUENCE";
|
|
1249
|
+
declare const $sequence: {
|
|
1250
|
+
(options?: SequenceDescriptorOptions): SequenceDescriptor;
|
|
1251
|
+
[KIND]: string;
|
|
1252
|
+
};
|
|
1217
1253
|
interface SequenceDescriptorOptions {
|
|
1218
1254
|
name?: string;
|
|
1219
1255
|
start?: number;
|
|
@@ -1229,18 +1265,18 @@ interface SequenceDescriptor {
|
|
|
1229
1265
|
next(): Promise<number>;
|
|
1230
1266
|
current(): Promise<number>;
|
|
1231
1267
|
}
|
|
1232
|
-
declare const $sequence: {
|
|
1233
|
-
(options?: SequenceDescriptorOptions): SequenceDescriptor;
|
|
1234
|
-
[KIND]: string;
|
|
1235
|
-
};
|
|
1236
1268
|
//#endregion
|
|
1237
1269
|
//#region src/descriptors/$transaction.d.ts
|
|
1270
|
+
/**
|
|
1271
|
+
*
|
|
1272
|
+
*/
|
|
1273
|
+
declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry81.RetryDescriptor<(...args: T) => Promise<R>>;
|
|
1238
1274
|
interface TransactionDescriptorOptions<T extends any[], R> {
|
|
1239
1275
|
handler: (tx: PgTransaction<any, any, any>, ...args: T) => Promise<R>;
|
|
1240
1276
|
config?: PgTransactionConfig$1;
|
|
1241
1277
|
}
|
|
1242
1278
|
type TransactionContext = PgTransaction<any, any, any>;
|
|
1243
|
-
|
|
1279
|
+
//# sourceMappingURL=$transaction.d.ts.map
|
|
1244
1280
|
//#endregion
|
|
1245
1281
|
//#region src/errors/EntityNotFoundError.d.ts
|
|
1246
1282
|
declare class EntityNotFoundError extends Error {
|
|
@@ -1248,15 +1284,16 @@ declare class EntityNotFoundError extends Error {
|
|
|
1248
1284
|
readonly status = 404;
|
|
1249
1285
|
constructor(entityName: string);
|
|
1250
1286
|
}
|
|
1287
|
+
//# sourceMappingURL=EntityNotFoundError.d.ts.map
|
|
1251
1288
|
//#endregion
|
|
1252
1289
|
//#region src/providers/RepositoryDescriptorProvider.d.ts
|
|
1253
1290
|
declare class RepositoryDescriptorProvider {
|
|
1254
|
-
protected readonly log:
|
|
1291
|
+
protected readonly log: _alepha_core55.Logger;
|
|
1255
1292
|
protected readonly alepha: Alepha;
|
|
1256
1293
|
protected readonly repositories: Array<Repository<any, TObject$1>>;
|
|
1257
1294
|
constructor();
|
|
1258
1295
|
clearRepositories(): Promise<void>;
|
|
1259
|
-
protected readonly configure:
|
|
1296
|
+
protected readonly configure: _alepha_core55.HookDescriptor<"configure">;
|
|
1260
1297
|
/**
|
|
1261
1298
|
* Get all repositories.
|
|
1262
1299
|
*
|
|
@@ -1286,10 +1323,11 @@ declare class RepositoryDescriptorProvider {
|
|
|
1286
1323
|
*/
|
|
1287
1324
|
protected processRepositoryDescriptors(): Promise<void>;
|
|
1288
1325
|
}
|
|
1326
|
+
//# sourceMappingURL=RepositoryDescriptorProvider.d.ts.map
|
|
1289
1327
|
//#endregion
|
|
1290
1328
|
//#region src/providers/DrizzleKitProvider.d.ts
|
|
1291
1329
|
declare class DrizzleKitProvider {
|
|
1292
|
-
protected readonly log:
|
|
1330
|
+
protected readonly log: _alepha_core19.Logger;
|
|
1293
1331
|
protected readonly alepha: Alepha;
|
|
1294
1332
|
protected readonly repositoryProvider: RepositoryDescriptorProvider;
|
|
1295
1333
|
push(provider: PostgresProvider, schema?: string): Promise<void>;
|
|
@@ -1321,51 +1359,52 @@ declare class DrizzleKitProvider {
|
|
|
1321
1359
|
*/
|
|
1322
1360
|
protected importDrizzleKit(): Promise<typeof DrizzleKit>;
|
|
1323
1361
|
}
|
|
1362
|
+
//# sourceMappingURL=DrizzleKitProvider.d.ts.map
|
|
1324
1363
|
//#endregion
|
|
1325
1364
|
//#region src/providers/drivers/NodePostgresProvider.d.ts
|
|
1326
1365
|
declare module "alepha" {
|
|
1327
1366
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
1328
1367
|
}
|
|
1329
|
-
declare const envSchema:
|
|
1330
|
-
PG_HOST:
|
|
1331
|
-
PG_USERNAME:
|
|
1332
|
-
PG_DATABASE:
|
|
1333
|
-
PG_PASSWORD:
|
|
1334
|
-
PG_PORT:
|
|
1335
|
-
DATABASE_URL:
|
|
1336
|
-
DATABASE_MIGRATIONS_FOLDER:
|
|
1368
|
+
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;
|
|
1337
1376
|
/**
|
|
1338
1377
|
* The schema to use.
|
|
1339
1378
|
* Accept a string.
|
|
1340
1379
|
*/
|
|
1341
|
-
POSTGRES_SCHEMA:
|
|
1380
|
+
POSTGRES_SCHEMA: _alepha_core21.TOptional<_alepha_core21.TString>;
|
|
1342
1381
|
/**
|
|
1343
1382
|
* Synchronize the database schema with the models.
|
|
1344
1383
|
* Accept a boolean or a postgres schema name.
|
|
1345
1384
|
*
|
|
1346
1385
|
* @default false
|
|
1347
1386
|
*/
|
|
1348
|
-
POSTGRES_SYNCHRONIZE:
|
|
1387
|
+
POSTGRES_SYNCHRONIZE: _alepha_core21.TOptional<_alepha_core21.TBoolean>;
|
|
1349
1388
|
/**
|
|
1350
1389
|
* Push the schema to the database.
|
|
1351
1390
|
*
|
|
1352
1391
|
* @default false
|
|
1353
1392
|
*/
|
|
1354
|
-
POSTGRES_PUSH_SCHEMA:
|
|
1393
|
+
POSTGRES_PUSH_SCHEMA: _alepha_core21.TOptional<_alepha_core21.TBoolean>;
|
|
1355
1394
|
/**
|
|
1356
1395
|
* Reject unauthorized SSL connections.
|
|
1357
1396
|
*
|
|
1358
1397
|
* @default false
|
|
1359
1398
|
*/
|
|
1360
|
-
POSTGRES_REJECT_UNAUTHORIZED:
|
|
1399
|
+
POSTGRES_REJECT_UNAUTHORIZED: _alepha_core21.TBoolean;
|
|
1361
1400
|
}>;
|
|
1362
1401
|
interface NodePostgresProviderState {
|
|
1363
1402
|
client: postgres.Sql;
|
|
1364
1403
|
db: PostgresJsDatabase;
|
|
1365
1404
|
}
|
|
1366
|
-
declare class NodePostgresProvider
|
|
1405
|
+
declare class NodePostgresProvider extends PostgresProvider {
|
|
1367
1406
|
readonly dialect = "postgres";
|
|
1368
|
-
protected readonly log:
|
|
1407
|
+
protected readonly log: _alepha_core21.Logger;
|
|
1369
1408
|
protected readonly env: {
|
|
1370
1409
|
DATABASE_URL?: string | undefined;
|
|
1371
1410
|
PG_HOST?: string | undefined;
|
|
@@ -1387,16 +1426,16 @@ declare class NodePostgresProvider implements PostgresProvider {
|
|
|
1387
1426
|
*/
|
|
1388
1427
|
protected testingSchemaName?: string;
|
|
1389
1428
|
get db(): PostgresJsDatabase;
|
|
1390
|
-
protected readonly configure:
|
|
1391
|
-
protected readonly stop:
|
|
1429
|
+
protected readonly configure: _alepha_core21.HookDescriptor<"start">;
|
|
1430
|
+
protected readonly stop: _alepha_core21.HookDescriptor<"stop">;
|
|
1392
1431
|
/**
|
|
1393
1432
|
* Get Postgres schema.
|
|
1394
1433
|
*/
|
|
1395
1434
|
get schema(): string;
|
|
1396
|
-
execute(query: SQLLike): Promise<any
|
|
1435
|
+
execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static<T> : any>>;
|
|
1397
1436
|
connect(): Promise<void>;
|
|
1398
1437
|
close(): Promise<void>;
|
|
1399
|
-
protected migrate:
|
|
1438
|
+
protected migrate: _alepha_lock44.LockDescriptor<() => Promise<void>>;
|
|
1400
1439
|
protected createClient(): NodePostgresProviderState;
|
|
1401
1440
|
protected getMigrationOptions(): MigrationConfig;
|
|
1402
1441
|
protected getClientOptions(): postgres.Options<any>;
|
|
@@ -1411,16 +1450,21 @@ declare class NodePostgresProvider implements PostgresProvider {
|
|
|
1411
1450
|
type PgAttr<T extends TSchema$1, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
1412
1451
|
//#endregion
|
|
1413
1452
|
//#region src/schemas/createdAtSchema.d.ts
|
|
1414
|
-
declare const createdAtSchema: PgAttr<PgAttr<
|
|
1453
|
+
declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox89.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1454
|
+
//# sourceMappingURL=createdAtSchema.d.ts.map
|
|
1455
|
+
|
|
1415
1456
|
//#endregion
|
|
1416
1457
|
//#region src/schemas/legacyIdSchema.d.ts
|
|
1417
1458
|
/**
|
|
1418
1459
|
* @deprecated Use `pg.primaryKey()` instead.
|
|
1419
1460
|
*/
|
|
1420
|
-
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<
|
|
1461
|
+
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox85.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1462
|
+
//# sourceMappingURL=legacyIdSchema.d.ts.map
|
|
1421
1463
|
//#endregion
|
|
1422
1464
|
//#region src/schemas/updatedAtSchema.d.ts
|
|
1423
1465
|
declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox82.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1466
|
+
//# sourceMappingURL=updatedAtSchema.d.ts.map
|
|
1467
|
+
|
|
1424
1468
|
//#endregion
|
|
1425
1469
|
//#region src/schemas/entitySchema.d.ts
|
|
1426
1470
|
/**
|
|
@@ -1429,9 +1473,9 @@ declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox82.TString, typeof
|
|
|
1429
1473
|
* Add some common SQL properties to an object.
|
|
1430
1474
|
*/
|
|
1431
1475
|
declare const entitySchema: TObject$1<{
|
|
1432
|
-
id: PgAttr<PgAttr<PgAttr<
|
|
1433
|
-
createdAt: PgAttr<PgAttr<
|
|
1434
|
-
updatedAt: PgAttr<PgAttr<
|
|
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>;
|
|
1435
1479
|
}>;
|
|
1436
1480
|
/**
|
|
1437
1481
|
* TypeBox Entity Type.
|
|
@@ -1453,9 +1497,10 @@ type BaseEntityKeys = keyof BaseEntity;
|
|
|
1453
1497
|
* The keys of the base entity.
|
|
1454
1498
|
*/
|
|
1455
1499
|
declare const entityKeys: readonly ["id", "createdAt", "updatedAt"];
|
|
1500
|
+
//# sourceMappingURL=entitySchema.d.ts.map
|
|
1456
1501
|
//#endregion
|
|
1457
1502
|
//#region src/providers/PostgresTypeProvider.d.ts
|
|
1458
|
-
declare module "alepha
|
|
1503
|
+
declare module "alepha" {
|
|
1459
1504
|
interface TypeProvider {
|
|
1460
1505
|
pg: PostgresTypeProvider;
|
|
1461
1506
|
}
|
|
@@ -1465,20 +1510,19 @@ declare class PostgresTypeProvider {
|
|
|
1465
1510
|
/**
|
|
1466
1511
|
* Creates a primary key with an identity column.
|
|
1467
1512
|
*/
|
|
1468
|
-
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<
|
|
1513
|
+
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox48.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1469
1514
|
/**
|
|
1470
1515
|
* Creates a primary key with a big identity column. (default)
|
|
1471
1516
|
*/
|
|
1472
|
-
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<
|
|
1517
|
+
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox48.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1473
1518
|
/**
|
|
1474
1519
|
* Creates a primary key with a UUID column.
|
|
1475
1520
|
*/
|
|
1476
|
-
readonly uuidPrimaryKey: () => PgAttr<PgAttr<
|
|
1521
|
+
readonly uuidPrimaryKey: () => PgAttr<PgAttr<_sinclair_typebox48.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
1477
1522
|
/**
|
|
1478
|
-
*
|
|
1479
1523
|
* @alias bigIdentityPrimaryKey
|
|
1480
1524
|
*/
|
|
1481
|
-
readonly primaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<
|
|
1525
|
+
readonly primaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox48.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1482
1526
|
/**
|
|
1483
1527
|
* Wrap a schema with "default" attribute.
|
|
1484
1528
|
* This is used to set a default value for a column in the database.
|
|
@@ -1489,15 +1533,15 @@ declare class PostgresTypeProvider {
|
|
|
1489
1533
|
* This is used to track the version of a row in the database.
|
|
1490
1534
|
* You can use it for optimistic concurrency control.
|
|
1491
1535
|
*/
|
|
1492
|
-
readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<
|
|
1536
|
+
readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<_sinclair_typebox48.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
1493
1537
|
/**
|
|
1494
1538
|
* Creates a column Created At. So just a datetime column with a default value of the current timestamp.
|
|
1495
1539
|
*/
|
|
1496
|
-
readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<
|
|
1540
|
+
readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox48.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1497
1541
|
/**
|
|
1498
1542
|
* Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
|
|
1499
1543
|
*/
|
|
1500
|
-
readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<
|
|
1544
|
+
readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox48.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1501
1545
|
/**
|
|
1502
1546
|
* @deprecated Build your own entity schema.
|
|
1503
1547
|
*/
|
|
@@ -1537,12 +1581,13 @@ declare class PostgresTypeProvider {
|
|
|
1537
1581
|
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
1582
|
}
|
|
1539
1583
|
declare const pg: PostgresTypeProvider;
|
|
1584
|
+
//# sourceMappingURL=PostgresTypeProvider.d.ts.map
|
|
1540
1585
|
//#endregion
|
|
1541
1586
|
//#region src/types/schema.d.ts
|
|
1542
1587
|
/**
|
|
1543
1588
|
* Postgres schema type.
|
|
1544
1589
|
*/
|
|
1545
|
-
declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) =>
|
|
1590
|
+
declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) => drizzle_orm2.$Type<drizzle_orm_pg_core1.PgCustomColumnBuilder<{
|
|
1546
1591
|
name: string;
|
|
1547
1592
|
dataType: "custom";
|
|
1548
1593
|
columnType: "PgCustomColumn";
|
|
@@ -1554,8 +1599,139 @@ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDoc
|
|
|
1554
1599
|
}>, (TDocument & {
|
|
1555
1600
|
params: [];
|
|
1556
1601
|
})["static"]>;
|
|
1602
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
1603
|
+
|
|
1557
1604
|
//#endregion
|
|
1558
1605
|
//#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
|
+
/**
|
|
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
|
+
* });
|
|
1652
|
+
*
|
|
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
|
+
* ```
|
|
1728
|
+
*
|
|
1729
|
+
* @see {@link $entity}
|
|
1730
|
+
* @see {@link $repository}
|
|
1731
|
+
* @see {@link $db}
|
|
1732
|
+
* @see {@link $transaction}
|
|
1733
|
+
* @module alepha.postgres
|
|
1734
|
+
*/
|
|
1559
1735
|
declare class AlephaPostgres implements Module {
|
|
1560
1736
|
readonly name = "alepha.postgres";
|
|
1561
1737
|
readonly env: {
|
|
@@ -1563,6 +1739,8 @@ declare class AlephaPostgres implements Module {
|
|
|
1563
1739
|
};
|
|
1564
1740
|
readonly $services: (alepha: Alepha) => void;
|
|
1565
1741
|
}
|
|
1742
|
+
//# sourceMappingURL=index.d.ts.map
|
|
1743
|
+
|
|
1566
1744
|
//#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 };
|
|
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 };
|
|
1568
1746
|
//# sourceMappingURL=index.d.ts.map
|