alepha 0.9.3 → 0.9.4
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/README.md +46 -0
- package/batch.d.ts +3 -6
- package/bucket.d.ts +7 -14
- package/cache/redis.d.ts +7 -7
- package/cache.d.ts +2 -6
- package/command.d.ts +11 -11
- package/core.d.ts +99 -254
- package/datetime.d.ts +3 -7
- package/file.d.ts +0 -3
- package/lock/redis.d.ts +2 -5
- package/lock.d.ts +8 -15
- package/logger.cjs +8 -0
- package/logger.d.ts +222 -0
- package/logger.js +1 -0
- package/package.json +50 -42
- package/postgres.d.ts +192 -271
- package/queue/redis.d.ts +0 -2
- package/queue.d.ts +11 -19
- package/react/auth.d.ts +217 -134
- package/react/form.d.ts +113 -72
- package/react/head.d.ts +7 -14
- package/react/i18n.d.ts +23 -28
- package/react.d.ts +274 -256
- package/redis.d.ts +12 -12
- package/retry.d.ts +0 -4
- package/router.d.ts +0 -1
- package/scheduler.d.ts +9 -13
- package/security.d.ts +68 -86
- package/server/cache.d.ts +3 -5
- package/server/compress.d.ts +0 -3
- package/server/cookies.d.ts +4 -7
- package/server/cors.d.ts +1 -5
- package/server/health.d.ts +0 -3
- package/server/helmet.d.ts +28 -28
- package/server/links.d.ts +144 -42
- package/server/metrics.d.ts +1 -5
- package/server/multipart.d.ts +0 -2
- package/server/proxy.d.ts +3 -7
- package/server/security.d.ts +6 -7
- package/server/static.d.ts +4 -8
- package/server/swagger.d.ts +2 -6
- package/server.d.ts +72 -96
- package/topic/redis.d.ts +3 -6
- package/topic.d.ts +5 -13
- package/vite.d.ts +5 -7
package/postgres.d.ts
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
import * as _alepha_core13 from "alepha";
|
|
2
1
|
import * as _alepha_core1 from "alepha";
|
|
3
|
-
import * as _alepha_core2 from "alepha";
|
|
4
|
-
import * as _alepha_core0 from "alepha";
|
|
5
2
|
import { Alepha, AlephaError, Descriptor, KIND, Service, Static, TObject, TSchema as TSchema$1 } from "alepha";
|
|
6
|
-
import * as
|
|
7
|
-
import * as drizzle_orm2 from "drizzle-orm";
|
|
8
|
-
import * as drizzle_orm9 from "drizzle-orm";
|
|
9
|
-
import * as drizzle from "drizzle-orm";
|
|
3
|
+
import * as drizzle_orm7 from "drizzle-orm";
|
|
10
4
|
import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, TableConfig, sql } from "drizzle-orm";
|
|
11
5
|
import * as pg$1 from "drizzle-orm/pg-core";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import * as
|
|
15
|
-
import { AnyPgColumn, AnyPgTable, LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, PgTransactionConfig, TableConfig as TableConfig$1, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
6
|
+
import { AnyPgColumn, LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, PgTransactionConfig, SelectedFields, TableConfig as TableConfig$1, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
7
|
+
import { DateTimeProvider } from "alepha/datetime";
|
|
8
|
+
import * as _alepha_logger1 from "alepha/logger";
|
|
16
9
|
import * as _alepha_lock0 from "alepha/lock";
|
|
17
10
|
import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
18
11
|
import postgres from "postgres";
|
|
19
12
|
import * as _alepha_retry0 from "alepha/retry";
|
|
20
|
-
import * as
|
|
21
|
-
import * as _sinclair_typebox9 from "@sinclair/typebox";
|
|
22
|
-
import * as _sinclair_typebox10 from "@sinclair/typebox";
|
|
23
|
-
import * as _sinclair_typebox11 from "@sinclair/typebox";
|
|
24
|
-
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
13
|
+
import * as _sinclair_typebox1 from "@sinclair/typebox";
|
|
25
14
|
import { Evaluate, IntegerOptions, Kind, NumberOptions, ObjectOptions, OptionalKind, Static as Static$1, StringOptions, TAdditionalProperties, TArray, TBoolean, TInteger, TIntersect, TNumber, TObject as TObject$1, TOptional, TOptionalWithFlag, TPick, TProperties, TReadonly, TRecord, TSchema as TSchema$2, TString } from "@sinclair/typebox";
|
|
26
15
|
import { PgTransactionConfig as PgTransactionConfig$1 } from "drizzle-orm/pg-core/session";
|
|
27
16
|
import * as DrizzleKit from "drizzle-kit/api";
|
|
@@ -31,24 +20,21 @@ export * from "drizzle-orm/pg-core";
|
|
|
31
20
|
|
|
32
21
|
//#region src/constants/PG_SCHEMA.d.ts
|
|
33
22
|
declare const PG_SCHEMA: unique symbol;
|
|
34
|
-
//# sourceMappingURL=PG_SCHEMA.d.ts.map
|
|
35
23
|
//#endregion
|
|
36
24
|
//#region src/constants/PG_SYMBOLS.d.ts
|
|
37
25
|
declare const PG_DEFAULT: unique symbol;
|
|
38
26
|
declare const PG_PRIMARY_KEY: unique symbol;
|
|
39
27
|
declare const PG_CREATED_AT: unique symbol;
|
|
40
28
|
declare const PG_UPDATED_AT: unique symbol;
|
|
29
|
+
declare const PG_DELETED_AT: unique symbol;
|
|
41
30
|
declare const PG_VERSION: unique symbol;
|
|
42
31
|
declare const PG_IDENTITY: unique symbol;
|
|
43
|
-
declare const PG_MANY: unique symbol;
|
|
44
|
-
declare const PG_ONE: unique symbol;
|
|
45
32
|
declare const PG_REF: unique symbol;
|
|
46
33
|
/**
|
|
47
34
|
* @deprecated Use `PG_IDENTITY` instead.
|
|
48
35
|
*/
|
|
49
36
|
declare const PG_SERIAL: unique symbol;
|
|
50
37
|
type PgDefault = typeof PG_DEFAULT;
|
|
51
|
-
type PgMany = typeof PG_MANY;
|
|
52
38
|
type PgRef = typeof PG_REF;
|
|
53
39
|
type PgPrimaryKey = typeof PG_PRIMARY_KEY;
|
|
54
40
|
type PgSymbols = {
|
|
@@ -56,10 +42,9 @@ type PgSymbols = {
|
|
|
56
42
|
[PG_PRIMARY_KEY]: {};
|
|
57
43
|
[PG_CREATED_AT]: {};
|
|
58
44
|
[PG_UPDATED_AT]: {};
|
|
45
|
+
[PG_DELETED_AT]: {};
|
|
59
46
|
[PG_VERSION]: {};
|
|
60
47
|
[PG_IDENTITY]: PgIdentityOptions;
|
|
61
|
-
[PG_MANY]: PgManyOptions;
|
|
62
|
-
[PG_ONE]: PgManyOptions;
|
|
63
48
|
[PG_REF]: PgRefOptions;
|
|
64
49
|
/**
|
|
65
50
|
* @deprecated Use `PG_IDENTITY` instead.
|
|
@@ -72,11 +57,6 @@ type PgIdentityOptions = {
|
|
|
72
57
|
} & PgSequenceOptions & {
|
|
73
58
|
name?: string;
|
|
74
59
|
};
|
|
75
|
-
interface PgManyOptions {
|
|
76
|
-
table: AnyPgTable;
|
|
77
|
-
schema: TObject$1;
|
|
78
|
-
foreignKey: string;
|
|
79
|
-
}
|
|
80
60
|
interface PgRefOptions {
|
|
81
61
|
ref: () => AnyPgColumn;
|
|
82
62
|
actions?: {
|
|
@@ -84,7 +64,6 @@ interface PgRefOptions {
|
|
|
84
64
|
onDelete?: UpdateDeleteAction;
|
|
85
65
|
};
|
|
86
66
|
}
|
|
87
|
-
//# sourceMappingURL=PG_SYMBOLS.d.ts.map
|
|
88
67
|
//#endregion
|
|
89
68
|
//#region src/interfaces/TInsertObject.d.ts
|
|
90
69
|
/**
|
|
@@ -111,7 +90,7 @@ type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProp
|
|
|
111
90
|
//#endregion
|
|
112
91
|
//#region src/helpers/schemaToPgColumns.d.ts
|
|
113
92
|
/**
|
|
114
|
-
* Convert a Typebox Schema to Drizzle ORM Postgres columns
|
|
93
|
+
* Convert a Typebox Schema to Drizzle ORM Postgres columns
|
|
115
94
|
*/
|
|
116
95
|
declare const schemaToPgColumns: <T extends TObject>(schema: T) => FromSchema<T>;
|
|
117
96
|
/**
|
|
@@ -128,7 +107,7 @@ declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSeria
|
|
|
128
107
|
data: Buffer<ArrayBufferLike>;
|
|
129
108
|
driverParam: unknown;
|
|
130
109
|
enumValues: undefined;
|
|
131
|
-
}> | pg$1.PgTimestampStringBuilderInitial<string> | pg$1.PgDateStringBuilderInitial<string> | pg$1.PgTextBuilderInitial<string, [string, ...string[]]> | pg$1.PgBooleanBuilderInitial<string> |
|
|
110
|
+
}> | pg$1.PgTimestampStringBuilderInitial<string> | pg$1.PgDateStringBuilderInitial<string> | pg$1.PgTextBuilderInitial<string, [string, ...string[]]> | pg$1.PgBooleanBuilderInitial<string> | drizzle_orm7.$Type<pg$1.PgCustomColumnBuilder<{
|
|
132
111
|
name: string;
|
|
133
112
|
dataType: "custom";
|
|
134
113
|
columnType: "PgCustomColumn";
|
|
@@ -141,14 +120,14 @@ declare const mapFieldToColumn: (name: string, value: TSchema$1) => pg$1.PgSeria
|
|
|
141
120
|
}>, {
|
|
142
121
|
[x: string]: unknown;
|
|
143
122
|
[x: number]: unknown;
|
|
144
|
-
}> |
|
|
123
|
+
}> | drizzle_orm7.$Type<pg$1.PgCustomColumnBuilder<{
|
|
145
124
|
name: string;
|
|
146
125
|
dataType: "custom";
|
|
147
126
|
columnType: "PgCustomColumn";
|
|
148
127
|
data: {};
|
|
149
128
|
driverParam: string;
|
|
150
129
|
enumValues: undefined;
|
|
151
|
-
}>, {}> |
|
|
130
|
+
}>, {}> | drizzle_orm7.$Type<pg$1.PgCustomColumnBuilder<{
|
|
152
131
|
name: string;
|
|
153
132
|
dataType: "custom";
|
|
154
133
|
columnType: "PgCustomColumn";
|
|
@@ -278,7 +257,6 @@ type PgTableWithColumnsAndSchema<T extends TableConfig, R extends TObject> = PgT
|
|
|
278
257
|
interface TableLike<T extends TObject = TObject> {
|
|
279
258
|
$schema: T;
|
|
280
259
|
}
|
|
281
|
-
//# sourceMappingURL=schemaToPgColumns.d.ts.map
|
|
282
260
|
//#endregion
|
|
283
261
|
//#region src/descriptors/$entity.d.ts
|
|
284
262
|
/**
|
|
@@ -360,21 +338,18 @@ interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1
|
|
|
360
338
|
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
361
339
|
}
|
|
362
340
|
type Entity<T extends TObject$1> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
|
|
363
|
-
/**
|
|
364
|
-
* Create a table with a json schema.
|
|
365
|
-
*
|
|
366
|
-
* @param name The name of the table.
|
|
367
|
-
* @param schema The json schema of the table.
|
|
368
|
-
* @param extraConfig Extra configuration for the table.
|
|
369
|
-
*/
|
|
370
|
-
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>;
|
|
371
341
|
type PgTableConfig<TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>> = {
|
|
372
342
|
name: TTableName;
|
|
373
343
|
schema: any;
|
|
374
344
|
columns: BuildColumns<TTableName, TColumnsMap, "pg">;
|
|
375
345
|
dialect: "pg";
|
|
376
346
|
};
|
|
377
|
-
//#
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/errors/PgError.d.ts
|
|
349
|
+
declare class PgError extends AlephaError {
|
|
350
|
+
name: string;
|
|
351
|
+
constructor(message: string, cause?: unknown);
|
|
352
|
+
}
|
|
378
353
|
//#endregion
|
|
379
354
|
//#region src/helpers/nullToUndefined.d.ts
|
|
380
355
|
/**
|
|
@@ -390,7 +365,18 @@ declare const nullToUndefined: <T extends object>(value: T) => NullToUndefined<T
|
|
|
390
365
|
*/
|
|
391
366
|
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;
|
|
392
367
|
type NullifyIfOptional<T> = { [K in keyof T]: undefined extends T[K] ? T[K] | null : T[K] };
|
|
393
|
-
//#
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/helpers/pgAttr.d.ts
|
|
370
|
+
/**
|
|
371
|
+
* Type representation.
|
|
372
|
+
*/
|
|
373
|
+
type PgAttr<T extends TSchema$1, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
374
|
+
interface PgAttrField {
|
|
375
|
+
key: string;
|
|
376
|
+
type: TSchema$1;
|
|
377
|
+
data: any;
|
|
378
|
+
nested?: any[];
|
|
379
|
+
}
|
|
394
380
|
//#endregion
|
|
395
381
|
//#region src/interfaces/FilterOperators.d.ts
|
|
396
382
|
interface FilterOperators<TValue> {
|
|
@@ -747,7 +733,6 @@ interface FilterOperators<TValue> {
|
|
|
747
733
|
*/
|
|
748
734
|
arrayOverlaps?: TValue;
|
|
749
735
|
}
|
|
750
|
-
//# sourceMappingURL=FilterOperators.d.ts.map
|
|
751
736
|
//#endregion
|
|
752
737
|
//#region src/interfaces/InferInsert.d.ts
|
|
753
738
|
/**
|
|
@@ -764,10 +749,10 @@ type StaticEntry<T extends TObject$1> = { [K in keyof T["properties"] as T["prop
|
|
|
764
749
|
} | {
|
|
765
750
|
[OptionalKind]: "Optional";
|
|
766
751
|
} ? never : K]: Static$1<T["properties"][K]> };
|
|
767
|
-
//# sourceMappingURL=InferInsert.d.ts.map
|
|
768
752
|
//#endregion
|
|
769
753
|
//#region src/interfaces/PgQueryWhere.d.ts
|
|
770
|
-
type
|
|
754
|
+
type PgQueryWhereOrSQL<T extends object> = SQLWrapper | PgQueryWhere<T>;
|
|
755
|
+
type PgQueryWhere<T extends object> = { [Key in keyof T]?: FilterOperators<T[Key]> | T[Key] } & {
|
|
771
756
|
/**
|
|
772
757
|
* Combine a list of conditions with the `and` operator. Conditions
|
|
773
758
|
* that are equal `undefined` are automatically ignored.
|
|
@@ -784,7 +769,7 @@ type PgQueryWhere<T extends object> = { [Key in keyof T]?: FilterOperators<T[Key
|
|
|
784
769
|
* )
|
|
785
770
|
* ```
|
|
786
771
|
*/
|
|
787
|
-
and?: Array<
|
|
772
|
+
and?: Array<PgQueryWhereOrSQL<T>>;
|
|
788
773
|
/**
|
|
789
774
|
* Combine a list of conditions with the `or` operator. Conditions
|
|
790
775
|
* that are equal `undefined` are automatically ignored.
|
|
@@ -801,7 +786,7 @@ type PgQueryWhere<T extends object> = { [Key in keyof T]?: FilterOperators<T[Key
|
|
|
801
786
|
* )
|
|
802
787
|
* ```
|
|
803
788
|
*/
|
|
804
|
-
or?: Array<
|
|
789
|
+
or?: Array<PgQueryWhereOrSQL<T>>;
|
|
805
790
|
/**
|
|
806
791
|
* Negate the meaning of an expression using the `not` keyword.
|
|
807
792
|
*
|
|
@@ -813,7 +798,7 @@ type PgQueryWhere<T extends object> = { [Key in keyof T]?: FilterOperators<T[Key
|
|
|
813
798
|
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
|
|
814
799
|
* ```
|
|
815
800
|
*/
|
|
816
|
-
not?:
|
|
801
|
+
not?: PgQueryWhereOrSQL<T>;
|
|
817
802
|
/**
|
|
818
803
|
* Test whether a subquery evaluates to have any rows.
|
|
819
804
|
*
|
|
@@ -836,36 +821,18 @@ type PgQueryWhere<T extends object> = { [Key in keyof T]?: FilterOperators<T[Key
|
|
|
836
821
|
*/
|
|
837
822
|
exists?: SQLWrapper;
|
|
838
823
|
};
|
|
839
|
-
//# sourceMappingURL=PgQueryWhere.d.ts.map
|
|
840
824
|
//#endregion
|
|
841
825
|
//#region src/interfaces/PgQuery.d.ts
|
|
842
826
|
interface PgQuery<T extends TObject$1, Select extends (keyof Static$1<T>)[] = []> {
|
|
843
827
|
columns?: Select;
|
|
844
828
|
distinct?: boolean;
|
|
845
|
-
where?:
|
|
829
|
+
where?: PgQueryWhereOrSQL<Static$1<T>>;
|
|
846
830
|
limit?: number;
|
|
847
831
|
offset?: number;
|
|
848
832
|
sort?: { [key in keyof Static$1<T>]?: "asc" | "desc" };
|
|
849
833
|
groupBy?: (keyof Static$1<T>)[];
|
|
850
|
-
relations?: PgQueryWithMap<T>;
|
|
851
834
|
}
|
|
852
835
|
type PgQueryResult<T extends TObject$1, Select extends (keyof Static$1<T>)[]> = TPick<T, Select>;
|
|
853
|
-
type PgQueryWhereWithMany<T extends TObject$1> = PgQueryWhere<Static$1<RemoveManyRelations<T>>> & ExtractManyRelations<T>;
|
|
854
|
-
type ExtractManyRelations<T extends TObject$1> = { [K in keyof T["properties"] as T["properties"][K] extends {
|
|
855
|
-
[PG_MANY]: any;
|
|
856
|
-
} ? T["properties"][K] extends TArray ? T["properties"][K]["items"] extends TObject$1 ? K : never : never : never]?: PgQueryWhere<Static$1<T["properties"][K]["items"]>> };
|
|
857
|
-
type RemoveManyRelations<T extends TObject$1> = TObject$1<{ [K in keyof T["properties"] as T["properties"][K] extends {
|
|
858
|
-
[PG_MANY]: any;
|
|
859
|
-
} ? never : K]: T["properties"][K] }>;
|
|
860
|
-
type PgQueryWithMap<T extends TObject$1> = { [K in keyof T["properties"] as T["properties"][K] extends {
|
|
861
|
-
[PG_MANY]: any;
|
|
862
|
-
} ? K : never]?: T["properties"][K] extends TObject$1 ? PgQueryWith<T["properties"][K]> : T["properties"][K] extends TArray ? PgQueryWith<T["properties"][K]> : never };
|
|
863
|
-
type PgQueryWith<T extends TObject$1 | TArray> = true | {
|
|
864
|
-
relations?: {
|
|
865
|
-
[key: string]: PgQueryWith<T>;
|
|
866
|
-
};
|
|
867
|
-
};
|
|
868
|
-
//# sourceMappingURL=PgQuery.d.ts.map
|
|
869
836
|
//#endregion
|
|
870
837
|
//#region src/providers/drivers/PostgresProvider.d.ts
|
|
871
838
|
type SQLLike = SQLWrapper | string;
|
|
@@ -876,16 +843,14 @@ declare abstract class PostgresProvider {
|
|
|
876
843
|
abstract get dialect(): string;
|
|
877
844
|
abstract execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static$1<T> : any>>;
|
|
878
845
|
}
|
|
879
|
-
//# sourceMappingURL=PostgresProvider.d.ts.map
|
|
880
846
|
//#endregion
|
|
881
847
|
//#region src/schemas/pageQuerySchema.d.ts
|
|
882
|
-
declare const pageQuerySchema:
|
|
883
|
-
page:
|
|
884
|
-
size:
|
|
885
|
-
sort:
|
|
848
|
+
declare const pageQuerySchema: _sinclair_typebox1.TObject<{
|
|
849
|
+
page: _sinclair_typebox1.TOptional<_sinclair_typebox1.TNumber>;
|
|
850
|
+
size: _sinclair_typebox1.TOptional<_sinclair_typebox1.TNumber>;
|
|
851
|
+
sort: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
|
|
886
852
|
}>;
|
|
887
853
|
type PageQuery = Static<typeof pageQuerySchema>;
|
|
888
|
-
//# sourceMappingURL=pageQuerySchema.d.ts.map
|
|
889
854
|
//#endregion
|
|
890
855
|
//#region src/schemas/pageSchema.d.ts
|
|
891
856
|
/**
|
|
@@ -923,7 +888,6 @@ type Page<T> = {
|
|
|
923
888
|
countDuration?: number;
|
|
924
889
|
};
|
|
925
890
|
};
|
|
926
|
-
//# sourceMappingURL=pageSchema.d.ts.map
|
|
927
891
|
//#endregion
|
|
928
892
|
//#region src/descriptors/$repository.d.ts
|
|
929
893
|
/**
|
|
@@ -944,13 +908,11 @@ interface RepositoryDescriptorOptions<EntityTableConfig extends TableConfig, Ent
|
|
|
944
908
|
provider?: Service<PostgresProvider>;
|
|
945
909
|
}
|
|
946
910
|
declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, EntitySchema extends TObject$1> extends Descriptor<RepositoryDescriptorOptions<EntityTableConfig, EntitySchema>> {
|
|
911
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
947
912
|
readonly provider: PostgresProvider;
|
|
948
913
|
protected readonly alepha: Alepha;
|
|
949
914
|
readonly schema: EntitySchema;
|
|
950
|
-
readonly
|
|
951
|
-
protected readonly env: {
|
|
952
|
-
POSTGRES_PAGINATION_COUNT_ENABLED: boolean;
|
|
953
|
-
};
|
|
915
|
+
readonly schemaInsert: TInsertObject<EntitySchema>;
|
|
954
916
|
/**
|
|
955
917
|
* Represents the primary key of the table.
|
|
956
918
|
* - Key is the name of the primary key column.
|
|
@@ -974,15 +936,11 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
|
|
|
974
936
|
/**
|
|
975
937
|
* Getter for the database connection from the database provider.
|
|
976
938
|
*/
|
|
977
|
-
protected get db(): PgDatabase<any, Record<string, never>,
|
|
978
|
-
protected organization(): PgColumn;
|
|
939
|
+
protected get db(): PgDatabase<any, Record<string, never>, drizzle_orm7.ExtractTablesWithRelations<Record<string, never>>>;
|
|
979
940
|
/**
|
|
980
941
|
* Execute a SQL query.
|
|
981
|
-
*
|
|
982
|
-
* @param query
|
|
983
|
-
* @param schema
|
|
984
942
|
*/
|
|
985
|
-
|
|
943
|
+
query<T extends TObject$1 = EntitySchema>(query: SQLLike | ((table: PgTableWithColumns<EntityTableConfig>, db: PgDatabase<any>) => SQLLike), schema?: T): Promise<Static$1<T>[]>;
|
|
986
944
|
/**
|
|
987
945
|
* Get a Drizzle column from the table by his name.
|
|
988
946
|
*
|
|
@@ -1002,29 +960,34 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
|
|
|
1002
960
|
*
|
|
1003
961
|
* @returns The SELECT query builder.
|
|
1004
962
|
*/
|
|
1005
|
-
protected select(opts?: StatementOptions):
|
|
963
|
+
protected select(opts?: StatementOptions): pg$1.PgSelectBase<string, Record<string, PgColumn<drizzle_orm7.ColumnBaseConfig<drizzle_orm7.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
|
|
964
|
+
[x: string]: unknown;
|
|
965
|
+
}[], {
|
|
966
|
+
[x: string]: PgColumn<drizzle_orm7.ColumnBaseConfig<drizzle_orm7.ColumnDataType, string>, {}, {}>;
|
|
967
|
+
}>;
|
|
968
|
+
protected selectDistinct(opts: StatementOptions | undefined, fields: SelectedFields): pg$1.PgSelectBase<string, SelectedFields, "partial", Record<string, "not-null">, false, never, {
|
|
1006
969
|
[x: string]: unknown;
|
|
1007
970
|
}[], {
|
|
1008
|
-
[x: string]:
|
|
971
|
+
[x: string]: never;
|
|
1009
972
|
}>;
|
|
1010
973
|
/**
|
|
1011
974
|
* Start an INSERT query on the table.
|
|
1012
975
|
*
|
|
1013
976
|
* @returns The INSERT query builder.
|
|
1014
977
|
*/
|
|
1015
|
-
protected insert(opts?: StatementOptions):
|
|
978
|
+
protected insert(opts?: StatementOptions): pg$1.PgInsertBuilder<PgTableWithColumns<EntityTableConfig>, any, false>;
|
|
1016
979
|
/**
|
|
1017
980
|
* Start an UPDATE query on the table.
|
|
1018
981
|
*
|
|
1019
982
|
* @returns The UPDATE query builder.
|
|
1020
983
|
*/
|
|
1021
|
-
protected update(opts?: StatementOptions):
|
|
984
|
+
protected update(opts?: StatementOptions): pg$1.PgUpdateBuilder<PgTableWithColumns<EntityTableConfig>, any>;
|
|
1022
985
|
/**
|
|
1023
986
|
* Start a DELETE query on the table.
|
|
1024
987
|
*
|
|
1025
988
|
* @returns The DELETE query builder.
|
|
1026
989
|
*/
|
|
1027
|
-
protected delete(opts?: StatementOptions):
|
|
990
|
+
protected delete(opts?: StatementOptions): pg$1.PgDeleteBase<PgTableWithColumns<EntityTableConfig>, any, undefined, undefined, false, never>;
|
|
1028
991
|
/**
|
|
1029
992
|
* Find entities.
|
|
1030
993
|
*
|
|
@@ -1043,20 +1006,14 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
|
|
|
1043
1006
|
findOne<T extends Static$1<EntitySchema> = Static$1<EntitySchema>>(where: PgQueryWhere<T>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
|
|
1044
1007
|
/**
|
|
1045
1008
|
* Find an entity by ID.
|
|
1046
|
-
*
|
|
1047
|
-
* @param id
|
|
1048
|
-
* @param opts
|
|
1049
1009
|
*/
|
|
1050
1010
|
findById(id: string | number, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
|
|
1051
1011
|
/**
|
|
1052
1012
|
* Paginate entities.
|
|
1053
|
-
*
|
|
1054
|
-
* @param pageQuery The pagination query.
|
|
1055
|
-
* @param findQuery The find query.
|
|
1056
|
-
* @param opts The statement options.
|
|
1057
|
-
* @returns The paginated entities.
|
|
1058
1013
|
*/
|
|
1059
|
-
paginate(
|
|
1014
|
+
paginate(pagination?: PageQuery, query?: PgQuery<EntitySchema>, opts?: StatementOptions & {
|
|
1015
|
+
skipCount?: boolean;
|
|
1016
|
+
}): Promise<Page<Static$1<EntitySchema>>>;
|
|
1060
1017
|
createQuery(query?: PgQuery<EntitySchema>): PgQuery<EntitySchema>;
|
|
1061
1018
|
createQueryWhere(where?: PgQueryWhere<Static$1<EntitySchema>>): PgQueryWhere<Static$1<EntitySchema>>;
|
|
1062
1019
|
/**
|
|
@@ -1076,61 +1033,72 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
|
|
|
1076
1033
|
*/
|
|
1077
1034
|
createMany(values: Array<InferInsert<EntitySchema>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>[]>;
|
|
1078
1035
|
/**
|
|
1079
|
-
*
|
|
1080
|
-
*
|
|
1081
|
-
* @param query The where clause.
|
|
1082
|
-
* @param data The data to update.
|
|
1083
|
-
* @param opts The statement options.
|
|
1084
|
-
* @returns The updated entity.
|
|
1036
|
+
* Find an entity and update it.
|
|
1085
1037
|
*/
|
|
1086
|
-
updateOne(
|
|
1087
|
-
$append: Partial<NullifyIfOptional<Static$1<EntitySchema>>>;
|
|
1088
|
-
}, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
|
|
1089
|
-
save(data: Static$1<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
|
|
1038
|
+
updateOne(where: PgQueryWhereOrSQL<Static$1<EntitySchema>>, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
|
|
1090
1039
|
/**
|
|
1091
|
-
*
|
|
1040
|
+
* Save a given entity.
|
|
1092
1041
|
*
|
|
1093
|
-
* @
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* ```ts
|
|
1044
|
+
* const entity = await repository.findById(1);
|
|
1045
|
+
* entity.name = "New Name";
|
|
1046
|
+
* await repository.save(entity);
|
|
1047
|
+
* ```
|
|
1048
|
+
*
|
|
1049
|
+
* Difference with `updateById/updateOne`:
|
|
1050
|
+
*
|
|
1051
|
+
* - requires the entity to be fetched first
|
|
1052
|
+
* - check pg.version() if present - optimistic locking
|
|
1053
|
+
* - validate entity against schema
|
|
1054
|
+
*
|
|
1055
|
+
* @see {@link PostgresTypeProvider#version}
|
|
1056
|
+
* @see {@link PgVersionMismatchError}
|
|
1057
|
+
*/
|
|
1058
|
+
save(entity: Static$1<EntitySchema>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
|
|
1059
|
+
/**
|
|
1060
|
+
* Find an entity by ID and update it.
|
|
1096
1061
|
*/
|
|
1097
1062
|
updateById(id: string | number, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>>, opts?: StatementOptions): Promise<Static$1<EntitySchema>>;
|
|
1098
1063
|
/**
|
|
1099
|
-
*
|
|
1100
|
-
*
|
|
1101
|
-
* @param where The where clause.
|
|
1102
|
-
* @param data The data to update.
|
|
1103
|
-
* @param opts The statement options.
|
|
1104
|
-
* @returns The updated entities.
|
|
1064
|
+
* Find many entities and update all of them.
|
|
1105
1065
|
*/
|
|
1106
|
-
updateMany(where:
|
|
1066
|
+
updateMany(where: PgQueryWhereOrSQL<Static$1<EntitySchema>>, data: Partial<NullifyIfOptional<Static$1<EntitySchema>>>, opts?: StatementOptions): Promise<void>;
|
|
1107
1067
|
/**
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
1110
|
-
* @param where Query.
|
|
1111
|
-
* @param opts The statement options.
|
|
1068
|
+
* Find many and delete all of them.
|
|
1112
1069
|
*/
|
|
1113
1070
|
deleteMany(where?: PgQueryWhere<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<void>;
|
|
1114
1071
|
/**
|
|
1115
1072
|
* Delete all entities.
|
|
1116
|
-
* @param opts
|
|
1117
1073
|
*/
|
|
1118
1074
|
clear(opts?: StatementOptions): Promise<void>;
|
|
1119
1075
|
/**
|
|
1120
|
-
* Delete
|
|
1076
|
+
* Delete the given entity.
|
|
1121
1077
|
*
|
|
1122
|
-
*
|
|
1123
|
-
|
|
1078
|
+
* You must fetch the entity first in order to delete it.
|
|
1079
|
+
*/
|
|
1080
|
+
destroy(entity: Static$1<EntitySchema>, opts?: StatementOptions): Promise<void>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Find an entity and delete it.
|
|
1083
|
+
*/
|
|
1084
|
+
deleteOne(where?: PgQueryWhere<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<void>;
|
|
1085
|
+
/**
|
|
1086
|
+
* Find an entity by ID and delete it.
|
|
1124
1087
|
*/
|
|
1125
1088
|
deleteById(id: string | number, opts?: StatementOptions): Promise<void>;
|
|
1126
1089
|
/**
|
|
1127
1090
|
* Count entities.
|
|
1128
|
-
*
|
|
1129
|
-
* @param where The where clause.
|
|
1130
|
-
* @param opts The statement options.
|
|
1131
|
-
* @returns The count of entities.
|
|
1132
1091
|
*/
|
|
1133
|
-
count(where?:
|
|
1092
|
+
count(where?: PgQueryWhereOrSQL<Static$1<EntitySchema>>, opts?: StatementOptions): Promise<number>;
|
|
1093
|
+
protected conflictMessagePattern: string;
|
|
1094
|
+
protected handleError(error: unknown, message: string): PgError;
|
|
1095
|
+
protected withDeletedAt(where: PgQueryWhereOrSQL<Static$1<EntitySchema>>, opts?: {
|
|
1096
|
+
force?: boolean;
|
|
1097
|
+
}): PgQueryWhereOrSQL<(EntitySchema & {
|
|
1098
|
+
params: [];
|
|
1099
|
+
})["static"]>;
|
|
1100
|
+
protected get organization(): undefined;
|
|
1101
|
+
protected deletedAt(): PgAttrField | undefined;
|
|
1134
1102
|
/**
|
|
1135
1103
|
* Convert a query object to a SQL query.
|
|
1136
1104
|
*
|
|
@@ -1138,7 +1106,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
|
|
|
1138
1106
|
* @param schema The schema to use.
|
|
1139
1107
|
* @param col The column to use.
|
|
1140
1108
|
*/
|
|
1141
|
-
protected jsonQueryToSql(query:
|
|
1109
|
+
protected jsonQueryToSql(query: PgQueryWhereOrSQL<Static$1<EntitySchema>>, schema?: TObject$1, col?: (key: string) => PgColumn): SQL | undefined;
|
|
1142
1110
|
/**
|
|
1143
1111
|
* Map a filter operator to a SQL query.
|
|
1144
1112
|
*
|
|
@@ -1146,7 +1114,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
|
|
|
1146
1114
|
* @param column
|
|
1147
1115
|
* @protected
|
|
1148
1116
|
*/
|
|
1149
|
-
protected mapOperatorToSql(operator: FilterOperators<any
|
|
1117
|
+
protected mapOperatorToSql(operator: FilterOperators<any> | any, column: PgColumn): SQL | undefined;
|
|
1150
1118
|
/**
|
|
1151
1119
|
* Create a pagination object.
|
|
1152
1120
|
*
|
|
@@ -1182,7 +1150,7 @@ declare class RepositoryDescriptor<EntityTableConfig extends TableConfig, Entity
|
|
|
1182
1150
|
*/
|
|
1183
1151
|
protected getPrimaryKey(schema: TObject$1): {
|
|
1184
1152
|
key: string;
|
|
1185
|
-
col: PgColumn<
|
|
1153
|
+
col: PgColumn<drizzle_orm7.ColumnBaseConfig<drizzle_orm7.ColumnDataType, string>, {}, {}>;
|
|
1186
1154
|
type: TSchema$2;
|
|
1187
1155
|
};
|
|
1188
1156
|
}
|
|
@@ -1202,21 +1170,10 @@ interface StatementOptions {
|
|
|
1202
1170
|
strength: LockStrength;
|
|
1203
1171
|
};
|
|
1204
1172
|
/**
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1207
|
-
* Multi-tenant support.
|
|
1208
|
-
*
|
|
1209
|
-
* If set, it will be used to filter the results by organization.
|
|
1173
|
+
* If true, ignore soft delete.
|
|
1210
1174
|
*/
|
|
1211
|
-
|
|
1212
|
-
}
|
|
1213
|
-
interface PgAttrField {
|
|
1214
|
-
key: string;
|
|
1215
|
-
type: TSchema$2;
|
|
1216
|
-
data: any;
|
|
1217
|
-
nested?: any[];
|
|
1175
|
+
force?: boolean;
|
|
1218
1176
|
}
|
|
1219
|
-
//# sourceMappingURL=$repository.d.ts.map
|
|
1220
1177
|
//#endregion
|
|
1221
1178
|
//#region src/descriptors/$sequence.d.ts
|
|
1222
1179
|
/**
|
|
@@ -1242,7 +1199,6 @@ declare class SequenceDescriptor extends Descriptor<SequenceDescriptorOptions> {
|
|
|
1242
1199
|
next(): Promise<number>;
|
|
1243
1200
|
current(): Promise<number>;
|
|
1244
1201
|
}
|
|
1245
|
-
//# sourceMappingURL=$sequence.d.ts.map
|
|
1246
1202
|
//#endregion
|
|
1247
1203
|
//#region src/descriptors/$transaction.d.ts
|
|
1248
1204
|
/**
|
|
@@ -1254,23 +1210,19 @@ interface TransactionDescriptorOptions<T extends any[], R> {
|
|
|
1254
1210
|
config?: PgTransactionConfig$1;
|
|
1255
1211
|
}
|
|
1256
1212
|
type TransactionContext = PgTransaction<any, any, any>;
|
|
1257
|
-
//# sourceMappingURL=$transaction.d.ts.map
|
|
1258
1213
|
//#endregion
|
|
1259
1214
|
//#region src/errors/PgEntityNotFoundError.d.ts
|
|
1260
|
-
declare class PgEntityNotFoundError extends
|
|
1215
|
+
declare class PgEntityNotFoundError extends PgError {
|
|
1261
1216
|
readonly name = "EntityNotFoundError";
|
|
1262
1217
|
readonly status = 404;
|
|
1263
1218
|
constructor(entityName: string);
|
|
1264
1219
|
}
|
|
1265
|
-
//# sourceMappingURL=PgEntityNotFoundError.d.ts.map
|
|
1266
1220
|
//#endregion
|
|
1267
|
-
//#region src/providers/
|
|
1268
|
-
declare class
|
|
1269
|
-
protected readonly log:
|
|
1221
|
+
//#region src/providers/RepositoryProvider.d.ts
|
|
1222
|
+
declare class RepositoryProvider {
|
|
1223
|
+
protected readonly log: _alepha_logger1.Logger;
|
|
1270
1224
|
protected readonly alepha: Alepha;
|
|
1271
|
-
get repositories(): RepositoryDescriptor<TableConfig$1, TObject$1>[];
|
|
1272
|
-
constructor();
|
|
1273
|
-
clearRepositories(): Promise<void>;
|
|
1225
|
+
protected get repositories(): RepositoryDescriptor<TableConfig$1, TObject$1>[];
|
|
1274
1226
|
/**
|
|
1275
1227
|
* Get all repositories.
|
|
1276
1228
|
*
|
|
@@ -1282,19 +1234,18 @@ declare class RepositoryDescriptorProvider {
|
|
|
1282
1234
|
*
|
|
1283
1235
|
* @param provider
|
|
1284
1236
|
*/
|
|
1285
|
-
getTables(provider?: PostgresProvider):
|
|
1237
|
+
getTables(provider?: PostgresProvider): pg$1.PgTableWithColumns<TableConfig$1>[];
|
|
1286
1238
|
/**
|
|
1287
|
-
* Get all providers from the repositories.
|
|
1239
|
+
* Get all pg providers from the repositories.
|
|
1288
1240
|
*/
|
|
1289
1241
|
getProviders(): PostgresProvider[];
|
|
1290
1242
|
}
|
|
1291
|
-
//# sourceMappingURL=RepositoryDescriptorProvider.d.ts.map
|
|
1292
1243
|
//#endregion
|
|
1293
1244
|
//#region src/providers/DrizzleKitProvider.d.ts
|
|
1294
1245
|
declare class DrizzleKitProvider {
|
|
1295
|
-
protected readonly log:
|
|
1246
|
+
protected readonly log: _alepha_logger1.Logger;
|
|
1296
1247
|
protected readonly alepha: Alepha;
|
|
1297
|
-
protected readonly repositoryProvider:
|
|
1248
|
+
protected readonly repositoryProvider: RepositoryProvider;
|
|
1298
1249
|
push(provider: PostgresProvider, schema?: string): Promise<void>;
|
|
1299
1250
|
setPgSchema(provider: PostgresProvider): Promise<void>;
|
|
1300
1251
|
/**
|
|
@@ -1325,7 +1276,6 @@ declare class DrizzleKitProvider {
|
|
|
1325
1276
|
*/
|
|
1326
1277
|
protected importDrizzleKit(): Promise<typeof DrizzleKit>;
|
|
1327
1278
|
}
|
|
1328
|
-
//# sourceMappingURL=DrizzleKitProvider.d.ts.map
|
|
1329
1279
|
//#endregion
|
|
1330
1280
|
//#region src/providers/drivers/NodePostgresProvider.d.ts
|
|
1331
1281
|
declare module "alepha" {
|
|
@@ -1339,13 +1289,13 @@ declare const envSchema: TObject$1<{
|
|
|
1339
1289
|
* or
|
|
1340
1290
|
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
1341
1291
|
*/
|
|
1342
|
-
DATABASE_URL:
|
|
1292
|
+
DATABASE_URL: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
1343
1293
|
/**
|
|
1344
1294
|
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
1345
1295
|
*
|
|
1346
1296
|
* It will monkey patch drizzle tables.
|
|
1347
1297
|
*/
|
|
1348
|
-
POSTGRES_SCHEMA:
|
|
1298
|
+
POSTGRES_SCHEMA: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
1349
1299
|
/**
|
|
1350
1300
|
* Synchronize the database schema with the models.
|
|
1351
1301
|
* It uses a custom implementation, it's not related to `drizzle-kit push` command.
|
|
@@ -1355,7 +1305,7 @@ declare const envSchema: TObject$1<{
|
|
|
1355
1305
|
*
|
|
1356
1306
|
* @default false
|
|
1357
1307
|
*/
|
|
1358
|
-
POSTGRES_SYNCHRONIZE:
|
|
1308
|
+
POSTGRES_SYNCHRONIZE: _alepha_core1.TOptional<_alepha_core1.TBoolean>;
|
|
1359
1309
|
/**
|
|
1360
1310
|
* Push the schema to the database.
|
|
1361
1311
|
* It's like `drizzle-kit push` command.
|
|
@@ -1363,7 +1313,7 @@ declare const envSchema: TObject$1<{
|
|
|
1363
1313
|
*
|
|
1364
1314
|
* @default false
|
|
1365
1315
|
*/
|
|
1366
|
-
POSTGRES_PUSH:
|
|
1316
|
+
POSTGRES_PUSH: _alepha_core1.TOptional<_alepha_core1.TBoolean>;
|
|
1367
1317
|
}>;
|
|
1368
1318
|
interface NodePostgresProviderOptions {
|
|
1369
1319
|
migrations: MigrationConfig;
|
|
@@ -1372,7 +1322,7 @@ interface NodePostgresProviderOptions {
|
|
|
1372
1322
|
declare class NodePostgresProvider extends PostgresProvider {
|
|
1373
1323
|
readonly dialect = "postgres";
|
|
1374
1324
|
protected readonly sslModes: readonly ["require", "allow", "prefer", "verify-full"];
|
|
1375
|
-
protected readonly log:
|
|
1325
|
+
protected readonly log: _alepha_logger1.Logger;
|
|
1376
1326
|
protected readonly env: {
|
|
1377
1327
|
DATABASE_URL?: string | undefined;
|
|
1378
1328
|
POSTGRES_SCHEMA?: string | undefined;
|
|
@@ -1393,8 +1343,8 @@ declare class NodePostgresProvider extends PostgresProvider {
|
|
|
1393
1343
|
*/
|
|
1394
1344
|
get schema(): string;
|
|
1395
1345
|
get db(): PostgresJsDatabase;
|
|
1396
|
-
protected readonly configure:
|
|
1397
|
-
protected readonly stop:
|
|
1346
|
+
protected readonly configure: _alepha_core1.HookDescriptor<"start">;
|
|
1347
|
+
protected readonly stop: _alepha_core1.HookDescriptor<"stop">;
|
|
1398
1348
|
execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static<T> : any>>;
|
|
1399
1349
|
connect(): Promise<void>;
|
|
1400
1350
|
close(): Promise<void>;
|
|
@@ -1426,62 +1376,6 @@ declare class NodePostgresProvider extends PostgresProvider {
|
|
|
1426
1376
|
protected mapResult<T extends TObject$1 = any>(result: Array<any>, schema?: T): Array<T extends TObject$1 ? Static<T> : any>;
|
|
1427
1377
|
}
|
|
1428
1378
|
//#endregion
|
|
1429
|
-
//#region src/helpers/pgAttr.d.ts
|
|
1430
|
-
/**
|
|
1431
|
-
* Type representation.
|
|
1432
|
-
*/
|
|
1433
|
-
type PgAttr<T extends TSchema$1, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
1434
|
-
//#endregion
|
|
1435
|
-
//#region src/schemas/createdAtSchema.d.ts
|
|
1436
|
-
declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox9.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1437
|
-
//# sourceMappingURL=createdAtSchema.d.ts.map
|
|
1438
|
-
|
|
1439
|
-
//#endregion
|
|
1440
|
-
//#region src/schemas/legacyIdSchema.d.ts
|
|
1441
|
-
/**
|
|
1442
|
-
* @deprecated Use `pg.primaryKey()` instead.
|
|
1443
|
-
*/
|
|
1444
|
-
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox10.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1445
|
-
//# sourceMappingURL=legacyIdSchema.d.ts.map
|
|
1446
|
-
//#endregion
|
|
1447
|
-
//#region src/schemas/updatedAtSchema.d.ts
|
|
1448
|
-
declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox11.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1449
|
-
//# sourceMappingURL=updatedAtSchema.d.ts.map
|
|
1450
|
-
|
|
1451
|
-
//#endregion
|
|
1452
|
-
//#region src/schemas/entitySchema.d.ts
|
|
1453
|
-
/**
|
|
1454
|
-
* Entity Schema.
|
|
1455
|
-
*
|
|
1456
|
-
* Add some common SQL properties to an object.
|
|
1457
|
-
*/
|
|
1458
|
-
declare const entitySchema: TObject$1<{
|
|
1459
|
-
id: PgAttr<PgAttr<PgAttr<_sinclair_typebox0.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1460
|
-
createdAt: PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1461
|
-
updatedAt: PgAttr<PgAttr<_sinclair_typebox0.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1462
|
-
}>;
|
|
1463
|
-
/**
|
|
1464
|
-
* TypeBox Entity Type.
|
|
1465
|
-
*/
|
|
1466
|
-
type TEntity<T extends TProperties> = TObject$1<T & {
|
|
1467
|
-
id: typeof legacyIdSchema;
|
|
1468
|
-
createdAt: typeof createdAtSchema;
|
|
1469
|
-
updatedAt: typeof updatedAtSchema;
|
|
1470
|
-
}>;
|
|
1471
|
-
/**
|
|
1472
|
-
* The base entity.
|
|
1473
|
-
*/
|
|
1474
|
-
type BaseEntity = Static<typeof entitySchema>;
|
|
1475
|
-
/**
|
|
1476
|
-
* The keys of the base entity.
|
|
1477
|
-
*/
|
|
1478
|
-
type BaseEntityKeys = keyof BaseEntity;
|
|
1479
|
-
/**
|
|
1480
|
-
* The keys of the base entity.
|
|
1481
|
-
*/
|
|
1482
|
-
declare const entityKeys: readonly ["id", "createdAt", "updatedAt"];
|
|
1483
|
-
//# sourceMappingURL=entitySchema.d.ts.map
|
|
1484
|
-
//#endregion
|
|
1485
1379
|
//#region src/providers/PostgresTypeProvider.d.ts
|
|
1486
1380
|
declare module "alepha" {
|
|
1487
1381
|
interface TypeProvider {
|
|
@@ -1503,20 +1397,29 @@ declare class PostgresTypeProvider {
|
|
|
1503
1397
|
*/
|
|
1504
1398
|
readonly uuidPrimaryKey: () => PgAttr<PgAttr<TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
1505
1399
|
/**
|
|
1506
|
-
*
|
|
1400
|
+
* Creates a primary key for a given type. Supports:
|
|
1401
|
+
* - `t.int()` -> PG INT (default)
|
|
1402
|
+
* - `t.bigint()` -> PG BIGINT
|
|
1403
|
+
* - `t.uuid()` -> PG UUID
|
|
1507
1404
|
*/
|
|
1508
|
-
primaryKey(
|
|
1509
|
-
primaryKey(type:
|
|
1510
|
-
primaryKey(type:
|
|
1405
|
+
primaryKey(): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
1406
|
+
primaryKey(type: TString, options?: StringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
|
|
1407
|
+
primaryKey(type: TInteger, options?: IntegerOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
1408
|
+
primaryKey(type: TNumber, options?: NumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
|
|
1511
1409
|
/**
|
|
1512
1410
|
* Wrap a schema with "default" attribute.
|
|
1513
1411
|
* This is used to set a default value for a column in the database.
|
|
1514
1412
|
*/
|
|
1515
1413
|
readonly default: <T extends TSchema$2>(type: T, value?: Static$1<T>) => PgAttr<T, PgDefault>;
|
|
1516
1414
|
/**
|
|
1517
|
-
* Creates a column version.
|
|
1415
|
+
* Creates a column 'version'.
|
|
1416
|
+
*
|
|
1518
1417
|
* This is used to track the version of a row in the database.
|
|
1519
|
-
*
|
|
1418
|
+
*
|
|
1419
|
+
* You can use it for optimistic concurrency control (OCC) with {@link RepositoryDescriptor#save}.
|
|
1420
|
+
*
|
|
1421
|
+
* @see {@link RepositoryDescriptor#save}
|
|
1422
|
+
* @see {@link PgVersionMismatchError}
|
|
1520
1423
|
*/
|
|
1521
1424
|
readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
1522
1425
|
/**
|
|
@@ -1528,51 +1431,45 @@ declare class PostgresTypeProvider {
|
|
|
1528
1431
|
*/
|
|
1529
1432
|
readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1530
1433
|
/**
|
|
1531
|
-
*
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
/**
|
|
1535
|
-
* Creates an insert schema for a given object schema.
|
|
1536
|
-
* - pg.default will be optional
|
|
1434
|
+
* Creates a column Deleted At for soft delete functionality.
|
|
1435
|
+
* This is used to mark rows as deleted without actually removing them from the database.
|
|
1436
|
+
* The column is nullable - NULL means not deleted, timestamp means deleted.
|
|
1537
1437
|
*/
|
|
1538
|
-
readonly
|
|
1438
|
+
readonly deletedAt: (options?: StringOptions) => PgAttr<_sinclair_typebox1.TOptional<TString>, typeof PG_DELETED_AT>;
|
|
1539
1439
|
/**
|
|
1540
|
-
*
|
|
1541
|
-
*/
|
|
1542
|
-
readonly input: <T extends TObject$1>(obj: T) => TInsertObject<T>;
|
|
1543
|
-
/**
|
|
1544
|
-
* Creates a page schema for a given object schema.
|
|
1545
|
-
*/
|
|
1546
|
-
readonly page: <T extends TObject$1>(resource: T, options?: ObjectOptions) => TPage<T>;
|
|
1547
|
-
/**
|
|
1548
|
-
* Creates a reference to another table or schema.
|
|
1440
|
+
* Creates a reference to another table or schema. Basically a foreign key.
|
|
1549
1441
|
*/
|
|
1550
1442
|
readonly ref: <T extends TSchema$2>(type: T, ref: () => any, actions?: {
|
|
1551
1443
|
onUpdate?: UpdateDeleteAction$1;
|
|
1552
1444
|
onDelete?: UpdateDeleteAction$1;
|
|
1553
1445
|
}) => PgAttr<T, PgRef>;
|
|
1554
1446
|
/**
|
|
1555
|
-
*
|
|
1447
|
+
* Convert a schema to a schema for INSERT operations.
|
|
1448
|
+
* It means that:
|
|
1449
|
+
* - All pg.default() will be optional
|
|
1450
|
+
*
|
|
1451
|
+
* @internal
|
|
1556
1452
|
*/
|
|
1557
|
-
|
|
1558
|
-
onUpdate?: UpdateDeleteAction$1;
|
|
1559
|
-
onDelete?: UpdateDeleteAction$1;
|
|
1560
|
-
}) => PgAttr<T, PgRef>;
|
|
1453
|
+
readonly insert: <T extends TObject$1>(obj: T) => TInsertObject<T>;
|
|
1561
1454
|
/**
|
|
1562
|
-
* Creates a
|
|
1563
|
-
*
|
|
1564
|
-
* @experimental
|
|
1455
|
+
* Creates a page schema for a given object schema.
|
|
1456
|
+
* It's used by {@link RepositoryDescriptor#paginate} method.
|
|
1565
1457
|
*/
|
|
1566
|
-
readonly
|
|
1458
|
+
readonly page: <T extends TObject$1>(resource: T, options?: ObjectOptions) => TPage<T>;
|
|
1567
1459
|
}
|
|
1568
1460
|
declare const pg: PostgresTypeProvider;
|
|
1569
|
-
//#
|
|
1461
|
+
//#endregion
|
|
1462
|
+
//#region src/schemas/legacyIdSchema.d.ts
|
|
1463
|
+
/**
|
|
1464
|
+
* @deprecated Use `pg.primaryKey()` instead.
|
|
1465
|
+
*/
|
|
1466
|
+
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox1.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1570
1467
|
//#endregion
|
|
1571
1468
|
//#region src/types/schema.d.ts
|
|
1572
1469
|
/**
|
|
1573
1470
|
* Postgres schema type.
|
|
1574
1471
|
*/
|
|
1575
|
-
declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) =>
|
|
1472
|
+
declare const schema: <TDocument extends TSchema$2>(name: string, document: TDocument) => drizzle_orm7.$Type<pg$1.PgCustomColumnBuilder<{
|
|
1576
1473
|
name: string;
|
|
1577
1474
|
dataType: "custom";
|
|
1578
1475
|
columnType: "PgCustomColumn";
|
|
@@ -1584,25 +1481,49 @@ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDoc
|
|
|
1584
1481
|
}>, (TDocument & {
|
|
1585
1482
|
params: [];
|
|
1586
1483
|
})["static"]>;
|
|
1587
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
1588
|
-
|
|
1589
1484
|
//#endregion
|
|
1590
1485
|
//#region src/index.d.ts
|
|
1591
1486
|
/**
|
|
1592
|
-
*
|
|
1487
|
+
* Postgres client based on Drizzle ORM, Alepha type-safe friendly.
|
|
1488
|
+
*
|
|
1489
|
+
* ```ts
|
|
1490
|
+
* const users = $entity({
|
|
1491
|
+
* name: "users",
|
|
1492
|
+
* schema: t.object({
|
|
1493
|
+
* id: pg.primaryKey(),
|
|
1494
|
+
* name: t.string(),
|
|
1495
|
+
* email: t.string(),
|
|
1496
|
+
* }),
|
|
1497
|
+
* });
|
|
1498
|
+
*
|
|
1499
|
+
* class Db {
|
|
1500
|
+
* users = $repository(users);
|
|
1501
|
+
* }
|
|
1502
|
+
*
|
|
1503
|
+
* const db = alepha.inject(Db);
|
|
1504
|
+
* const user = await db.users.one({ name: { eq: "John Doe" } });
|
|
1505
|
+
* ```
|
|
1593
1506
|
*
|
|
1594
|
-
*
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1507
|
+
* This is not a full ORM, but rather a set of tools to work with Postgres databases in a type-safe way.
|
|
1508
|
+
*
|
|
1509
|
+
* It provides:
|
|
1510
|
+
* - A type-safe way to define entities and repositories. (via `$entity` and `$repository`)
|
|
1511
|
+
* - Custom query builders and filters.
|
|
1512
|
+
* - Built-in special columns like `createdAt`, `updatedAt`, `deletedAt`, `version`.
|
|
1513
|
+
* - Automatic JSONB support.
|
|
1514
|
+
* - Automatic synchronization of entities with the database schema (for testing and development).
|
|
1515
|
+
* - Fallback to raw SQL via Drizzle ORM `sql` function.
|
|
1516
|
+
*
|
|
1517
|
+
* Migrations are supported via Drizzle ORM, you need to use the `drizzle-kit` CLI tool to generate and run migrations.
|
|
1518
|
+
*
|
|
1519
|
+
* Relations are **NOT SUPPORTED** yet. If you need relations, please use the `drizzle-orm` package directly.
|
|
1597
1520
|
*
|
|
1598
1521
|
* @see {@link $entity}
|
|
1599
1522
|
* @see {@link $repository}
|
|
1600
1523
|
* @see {@link $transaction}
|
|
1601
1524
|
* @module alepha.postgres
|
|
1602
1525
|
*/
|
|
1603
|
-
declare const AlephaPostgres:
|
|
1604
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1605
|
-
|
|
1526
|
+
declare const AlephaPostgres: _alepha_core1.Service<_alepha_core1.Module>;
|
|
1606
1527
|
//#endregion
|
|
1607
|
-
export { $entity, $repository, $sequence, $transaction, AlephaPostgres,
|
|
1528
|
+
export { $entity, $repository, $sequence, $transaction, AlephaPostgres, DrizzleKitProvider, Entity, EntityDescriptorOptions, FilterOperators, FromSchema, NodePostgresProvider, NodePostgresProviderOptions, NullToUndefined, NullifyIfOptional, 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, TInsertObject, TPage, TableLike, TransactionContext, TransactionDescriptorOptions, camelToSnakeCase, drizzle_orm7 as drizzle, legacyIdSchema, mapFieldToColumn, mapStringToColumn, nullToUndefined, pageQuerySchema, pageSchema, pg, schema, schemaToPgColumns, sql };
|
|
1608
1529
|
//# sourceMappingURL=index.d.ts.map
|