alepha 0.11.5 → 0.11.6
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/api/files.d.ts +167 -167
- package/api/jobs.d.ts +226 -154
- package/api/notifications.d.ts +100 -100
- package/api/users.d.ts +477 -477
- package/batch.d.ts +59 -493
- package/bucket.d.ts +20 -11
- package/cache/redis.d.ts +1 -1
- package/cache.d.ts +1 -1
- package/command.d.ts +24 -7
- package/core.d.ts +219 -169
- package/datetime.d.ts +1 -1
- package/devtools.d.ts +292 -254
- package/email.d.ts +45 -2
- package/fake.d.ts +1 -1
- package/file.d.ts +1 -1
- package/lock/redis.d.ts +1 -1
- package/lock.d.ts +1 -1
- package/logger.d.ts +6 -3
- package/package.json +51 -51
- package/postgres.d.ts +473 -188
- package/queue/redis.d.ts +1 -1
- package/queue.d.ts +1 -1
- package/react/auth.d.ts +7 -2
- package/react/form.d.ts +35 -15
- package/react/head.d.ts +1 -1
- package/react/i18n.d.ts +2 -2
- package/react.d.ts +58 -35
- package/redis.d.ts +10 -10
- package/retry.d.ts +84 -21
- package/scheduler.d.ts +1 -1
- package/security.d.ts +29 -29
- package/server/cache.d.ts +1 -1
- package/server/compress.d.ts +9 -3
- package/server/cookies.d.ts +1 -1
- package/server/cors.d.ts +28 -10
- package/server/health.d.ts +1 -1
- package/server/helmet.d.ts +44 -15
- package/server/links.d.ts +8 -2
- package/server/metrics.d.ts +1 -1
- package/server/multipart.d.ts +1 -1
- package/server/proxy.d.ts +1 -1
- package/server/security.d.ts +8 -3
- package/server/static.d.ts +1 -1
- package/server/swagger.d.ts +19 -6
- package/server.d.ts +20 -20
- package/topic/redis.d.ts +1 -1
- package/topic.d.ts +1 -1
- package/ui.d.ts +127 -24
package/postgres.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import * as _alepha_core10 from "alepha";
|
|
2
|
-
import { Alepha, AlephaError, Descriptor,
|
|
2
|
+
import { Alepha, AlephaError, Descriptor, KIND, Page, Page as Page$1, PageQuery, PageQuery as PageQuery$1, Service, Static, StaticEncode, TBigInt, TInteger, TNull, TNumber, TNumberOptions, TObject, TObjectOptions, TOptional, TPage, TSchema, TString, TStringOptions, TUnion, TUnsafe, pageQuerySchema, pageSchema } from "alepha";
|
|
3
3
|
import { DateTime, DateTimeProvider } from "alepha/datetime";
|
|
4
4
|
import * as drizzle_orm0 from "drizzle-orm";
|
|
5
|
-
import { BuildExtraConfigColumns, SQL, SQLWrapper, sql } from "drizzle-orm";
|
|
5
|
+
import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, sql } from "drizzle-orm";
|
|
6
6
|
import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
|
|
7
|
-
import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSchema, PgSelectBase, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction,
|
|
7
|
+
import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSchema, PgSelectBase, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
8
8
|
import * as _alepha_logger0 from "alepha/logger";
|
|
9
9
|
import * as _alepha_lock0 from "alepha/lock";
|
|
10
10
|
import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
11
11
|
import postgres from "postgres";
|
|
12
|
+
import * as pg$1 from "drizzle-orm/sqlite-core";
|
|
13
|
+
import { SQLiteColumnBuilderBase } from "drizzle-orm/sqlite-core";
|
|
12
14
|
import * as _alepha_retry0 from "alepha/retry";
|
|
13
|
-
import
|
|
14
|
-
import { PgTransactionConfig
|
|
15
|
+
import { DatabaseSync } from "node:sqlite";
|
|
16
|
+
import { PgTransactionConfig } from "drizzle-orm/pg-core/session";
|
|
17
|
+
import * as typebox1 from "typebox";
|
|
15
18
|
import * as DrizzleKit from "drizzle-kit/api";
|
|
16
|
-
import { MigrationConfig } from "drizzle-orm/migrator";
|
|
17
19
|
import * as dayjs0 from "dayjs";
|
|
18
20
|
import { UpdateDeleteAction as UpdateDeleteAction$1 } from "drizzle-orm/pg-core/foreign-keys";
|
|
19
21
|
export * from "drizzle-orm/pg-core";
|
|
@@ -260,8 +262,8 @@ interface PgRefOptions {
|
|
|
260
262
|
};
|
|
261
263
|
}
|
|
262
264
|
//#endregion
|
|
263
|
-
//#region src/errors/
|
|
264
|
-
declare class
|
|
265
|
+
//#region src/errors/DbError.d.ts
|
|
266
|
+
declare class DbError extends AlephaError {
|
|
265
267
|
name: string;
|
|
266
268
|
constructor(message: string, cause?: unknown);
|
|
267
269
|
}
|
|
@@ -864,32 +866,102 @@ declare abstract class ModelBuilder {
|
|
|
864
866
|
protected buildTableConfig<TConfig, TSelf>(entity: EntityDescriptor, builders: TableConfigBuilders<TConfig>, tableResolver?: (entityName: string) => any, customConfigHandler?: (config: any, self: TSelf) => TConfig[]): ((self: TSelf) => TConfig[]) | undefined;
|
|
865
867
|
}
|
|
866
868
|
//#endregion
|
|
869
|
+
//#region src/providers/DrizzleKitProvider.d.ts
|
|
870
|
+
declare class DrizzleKitProvider {
|
|
871
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
872
|
+
protected readonly alepha: Alepha;
|
|
873
|
+
/**
|
|
874
|
+
* Synchronize database with current schema definitions.
|
|
875
|
+
*
|
|
876
|
+
* In development mode, it will generate and execute migrations based on the current state.
|
|
877
|
+
* In testing mode, it will generate migrations from scratch without applying them.
|
|
878
|
+
*
|
|
879
|
+
* Does nothing in production mode, you must handle migrations manually.
|
|
880
|
+
*/
|
|
881
|
+
synchronize(provider: DatabaseProvider): Promise<void>;
|
|
882
|
+
/**
|
|
883
|
+
* Mostly used for testing purposes. You can generate SQL migration statements without executing them.
|
|
884
|
+
*/
|
|
885
|
+
generateMigration(provider: DatabaseProvider, prevSnapshot?: any): Promise<{
|
|
886
|
+
statements: string[];
|
|
887
|
+
models: Record<string, unknown>;
|
|
888
|
+
snapshot?: any;
|
|
889
|
+
}>;
|
|
890
|
+
/**
|
|
891
|
+
* Load all tables, enums, sequences, etc. from the provider's repositories.
|
|
892
|
+
*/
|
|
893
|
+
getModels(provider: DatabaseProvider): Record<string, unknown>;
|
|
894
|
+
/**
|
|
895
|
+
* Load the migration snapshot from the database.
|
|
896
|
+
*/
|
|
897
|
+
protected loadDevMigrations(provider: DatabaseProvider): Promise<DevMigrations | undefined>;
|
|
898
|
+
protected saveDevMigrations(provider: DatabaseProvider, curr: Record<string, any>, devMigrations?: DevMigrations): Promise<void>;
|
|
899
|
+
protected executeStatements(statements: string[], provider: DatabaseProvider, catchErrors?: boolean): Promise<void>;
|
|
900
|
+
protected createSchemaIfNotExists(provider: DatabaseProvider, schemaName: string): Promise<void>;
|
|
901
|
+
/**
|
|
902
|
+
* Try to load the official Drizzle Kit API.
|
|
903
|
+
* If not available, fallback to the local kit import.
|
|
904
|
+
*/
|
|
905
|
+
protected importDrizzleKit(): typeof DrizzleKit;
|
|
906
|
+
}
|
|
907
|
+
declare const devMigrationsSchema: typebox1.TObject<{
|
|
908
|
+
id: typebox1.TNumber;
|
|
909
|
+
name: typebox1.TString;
|
|
910
|
+
snapshot: typebox1.TString;
|
|
911
|
+
created_at: typebox1.TString;
|
|
912
|
+
}>;
|
|
913
|
+
type DevMigrations = Static<typeof devMigrationsSchema>;
|
|
914
|
+
//#endregion
|
|
867
915
|
//#region src/providers/drivers/DatabaseProvider.d.ts
|
|
868
916
|
type SQLLike = SQLWrapper | string;
|
|
869
917
|
declare abstract class DatabaseProvider {
|
|
870
918
|
protected readonly alepha: Alepha;
|
|
919
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
871
920
|
protected abstract readonly builder: ModelBuilder;
|
|
921
|
+
protected abstract readonly kit: DrizzleKitProvider;
|
|
872
922
|
abstract readonly db: PgDatabase<any>;
|
|
873
|
-
abstract readonly dialect: "
|
|
923
|
+
abstract readonly dialect: "postgresql" | "sqlite";
|
|
874
924
|
readonly enums: Map<string, unknown>;
|
|
875
925
|
readonly tables: Map<string, unknown>;
|
|
876
926
|
readonly sequences: Map<string, unknown>;
|
|
877
|
-
|
|
927
|
+
get name(): string;
|
|
878
928
|
get schema(): string;
|
|
929
|
+
table<T extends TObject>(entity: EntityDescriptor<T>): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
879
930
|
registerEntity(entity: EntityDescriptor): void;
|
|
880
931
|
registerSequence(sequence: SequenceDescriptor): void;
|
|
881
932
|
abstract execute(statement: SQLLike): Promise<Record<string, unknown>[]>;
|
|
882
933
|
run<T extends TObject>(statement: SQLLike, schema: T): Promise<Array<Static<T>>>;
|
|
934
|
+
/**
|
|
935
|
+
* Get migrations folder path - can be overridden
|
|
936
|
+
*/
|
|
937
|
+
protected getMigrationsFolder(): string;
|
|
938
|
+
/**
|
|
939
|
+
* Base migration orchestration - handles environment logic
|
|
940
|
+
*/
|
|
941
|
+
protected migrateDatabase(): Promise<void>;
|
|
942
|
+
/**
|
|
943
|
+
* Production: run migrations from folder
|
|
944
|
+
*/
|
|
945
|
+
protected runProductionMigration(migrationsFolder: string): Promise<void>;
|
|
946
|
+
/**
|
|
947
|
+
* Test: always synchronize
|
|
948
|
+
*/
|
|
949
|
+
protected runTestMigration(): Promise<void>;
|
|
950
|
+
/**
|
|
951
|
+
* Development: default to synchronize (can be overridden)
|
|
952
|
+
*/
|
|
953
|
+
protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
|
|
954
|
+
/**
|
|
955
|
+
* Common synchronization with error handling
|
|
956
|
+
*/
|
|
957
|
+
protected synchronizeSchema(): Promise<void>;
|
|
958
|
+
/**
|
|
959
|
+
* Provider-specific migration execution
|
|
960
|
+
* MUST be implemented by each provider
|
|
961
|
+
*/
|
|
962
|
+
protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
|
|
883
963
|
}
|
|
884
964
|
//#endregion
|
|
885
|
-
//#region src/schemas/pageQuerySchema.d.ts
|
|
886
|
-
declare const pageQuerySchema: typebox11.TObject<{
|
|
887
|
-
page: typebox11.TOptional<typebox11.TInteger>;
|
|
888
|
-
size: typebox11.TOptional<typebox11.TInteger>;
|
|
889
|
-
sort: typebox11.TOptional<typebox11.TString>;
|
|
890
|
-
}>;
|
|
891
|
-
type PageQuery = Static<typeof pageQuerySchema>;
|
|
892
|
-
//#endregion
|
|
893
965
|
//#region src/services/PgJsonQueryManager.d.ts
|
|
894
966
|
/**
|
|
895
967
|
* Manages JSONB query generation for nested object and array queries in PostgreSQL.
|
|
@@ -908,17 +980,24 @@ declare class PgJsonQueryManager {
|
|
|
908
980
|
* @param column The JSONB column
|
|
909
981
|
* @param path The path to the nested property (e.g., ['profile', 'contact', 'email'])
|
|
910
982
|
* @param operator The filter operator (e.g., { eq: "test@example.com" })
|
|
983
|
+
* @param dialect Database dialect (postgresql or sqlite)
|
|
984
|
+
* @param columnSchema Optional schema of the JSON column for type inference
|
|
911
985
|
* @returns SQL condition
|
|
912
986
|
*/
|
|
913
|
-
buildJsonbCondition(column: PgColumn, path: string[], operator: FilterOperators<any
|
|
987
|
+
buildJsonbCondition(column: PgColumn, path: string[], operator: FilterOperators<any>, dialect: "postgresql" | "sqlite", columnSchema?: any): SQL | undefined;
|
|
914
988
|
/**
|
|
915
989
|
* Build JSONB array query conditions.
|
|
916
990
|
* Supports queries like: { addresses: { city: { eq: "Wonderland" } } }
|
|
917
991
|
* which translates to: EXISTS (SELECT 1 FROM jsonb_array_elements(addresses) elem WHERE elem->>'city' = 'Wonderland')
|
|
992
|
+
*
|
|
993
|
+
* @param dialect Database dialect (postgresql or sqlite)
|
|
994
|
+
* Note: SQLite array queries are not yet supported
|
|
918
995
|
*/
|
|
919
|
-
buildJsonbArrayCondition(column: PgColumn, path: string[], arrayPath: string, operator: FilterOperators<any
|
|
996
|
+
buildJsonbArrayCondition(column: PgColumn, path: string[], arrayPath: string, operator: FilterOperators<any>, dialect: "postgresql" | "sqlite"): SQL | undefined;
|
|
920
997
|
/**
|
|
921
998
|
* Apply a filter operator to a JSONB value.
|
|
999
|
+
* @param dialect Database dialect for appropriate casting syntax
|
|
1000
|
+
* @param fieldType Optional field type from schema for smart casting
|
|
922
1001
|
*/
|
|
923
1002
|
private applyOperatorToJsonValue;
|
|
924
1003
|
/**
|
|
@@ -941,14 +1020,23 @@ declare class PgJsonQueryManager {
|
|
|
941
1020
|
* @returns true if the array contains primitives, false if it contains objects
|
|
942
1021
|
*/
|
|
943
1022
|
isPrimitiveArray(schema: TObject, columnName: string): boolean;
|
|
1023
|
+
/**
|
|
1024
|
+
* Get the type of a field by navigating through a schema path.
|
|
1025
|
+
* Used for smart type casting in SQL queries.
|
|
1026
|
+
*
|
|
1027
|
+
* @param columnSchema The schema of the JSON column (e.g., t.object({ age: t.int() }))
|
|
1028
|
+
* @param path The path to navigate (e.g., ['contact', 'email'])
|
|
1029
|
+
* @returns The type string (e.g., 'integer', 'number', 'string') or undefined if not found
|
|
1030
|
+
*/
|
|
1031
|
+
private getFieldType;
|
|
944
1032
|
/**
|
|
945
1033
|
* Check if a nested path points to an array property.
|
|
946
1034
|
*/
|
|
947
1035
|
isArrayProperty(schema: TObject, path: string[]): boolean;
|
|
948
1036
|
}
|
|
949
1037
|
//#endregion
|
|
950
|
-
//#region src/services/
|
|
951
|
-
declare class
|
|
1038
|
+
//#region src/services/QueryManager.d.ts
|
|
1039
|
+
declare class QueryManager {
|
|
952
1040
|
protected readonly jsonQueryManager: PgJsonQueryManager;
|
|
953
1041
|
protected readonly alepha: Alepha;
|
|
954
1042
|
/**
|
|
@@ -958,11 +1046,12 @@ declare class PgQueryManager {
|
|
|
958
1046
|
schema: TObject;
|
|
959
1047
|
col: (key: string) => PgColumn;
|
|
960
1048
|
joins?: PgJoin[];
|
|
1049
|
+
dialect: "postgresql" | "sqlite";
|
|
961
1050
|
}): SQL | undefined;
|
|
962
1051
|
/**
|
|
963
1052
|
* Build a JSONB query for nested object/array queries.
|
|
964
1053
|
*/
|
|
965
|
-
protected buildJsonbQuery(column: PgColumn, nestedQuery: any, schema: TObject, columnName: string): SQL | undefined;
|
|
1054
|
+
protected buildJsonbQuery(column: PgColumn, nestedQuery: any, schema: TObject, columnName: string, dialect: "postgresql" | "sqlite"): SQL | undefined;
|
|
966
1055
|
/**
|
|
967
1056
|
* Check if an object has any filter operator properties.
|
|
968
1057
|
*/
|
|
@@ -1045,91 +1134,15 @@ declare class PgRelationManager {
|
|
|
1045
1134
|
buildSchemaWithJoins(baseSchema: TObject, joins: PgJoin[], parentPath?: string): TObject;
|
|
1046
1135
|
}
|
|
1047
1136
|
//#endregion
|
|
1048
|
-
//#region src/
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
* This descriptor provides a comprehensive, type-safe interface for performing all
|
|
1053
|
-
* database operations on entities defined with $entity. It offers a rich set of
|
|
1054
|
-
* CRUD operations, advanced querying capabilities, pagination, transactions, and
|
|
1055
|
-
* built-in support for audit trails and soft deletes.
|
|
1056
|
-
*/
|
|
1057
|
-
declare const $repository: {
|
|
1058
|
-
<T extends TObject>(optionsOrEntity: EntityDescriptor<T> | EntityDescriptorOptions<T> | RepositoryDescriptorOptions<T>): RepositoryDescriptor<T>;
|
|
1059
|
-
[KIND]: typeof RepositoryDescriptor;
|
|
1060
|
-
};
|
|
1061
|
-
interface RepositoryDescriptorOptions<T extends TObject> {
|
|
1062
|
-
/**
|
|
1063
|
-
* The entity table definition created with $entity.
|
|
1064
|
-
*
|
|
1065
|
-
* This table:
|
|
1066
|
-
* - Must be created using the $entity descriptor
|
|
1067
|
-
* - Defines the schema, indexes, and constraints for the repository
|
|
1068
|
-
* - Provides type information for all repository operations
|
|
1069
|
-
* - Must include exactly one primary key field
|
|
1070
|
-
*
|
|
1071
|
-
* The repository will automatically:
|
|
1072
|
-
* - Generate typed CRUD operations based on the entity schema
|
|
1073
|
-
* - Handle audit fields like createdAt, updatedAt, deletedAt
|
|
1074
|
-
* - Support optimistic locking if version field is present
|
|
1075
|
-
* - Provide soft delete functionality if deletedAt field exists
|
|
1076
|
-
*
|
|
1077
|
-
* **Entity Requirements**:
|
|
1078
|
-
* - Must have been created with $entity descriptor
|
|
1079
|
-
* - Schema must include a primary key field marked with `pg.primaryKey()`
|
|
1080
|
-
* - Corresponding database table must exist (created via migrations)
|
|
1081
|
-
*
|
|
1082
|
-
* @example
|
|
1083
|
-
* ```ts
|
|
1084
|
-
* const User = $entity({
|
|
1085
|
-
* name: "users",
|
|
1086
|
-
* schema: t.object({
|
|
1087
|
-
* id: pg.primaryKey(t.uuid()),
|
|
1088
|
-
* email: t.text({ format: "email" }),
|
|
1089
|
-
* name: t.text()
|
|
1090
|
-
* })
|
|
1091
|
-
* });
|
|
1092
|
-
*
|
|
1093
|
-
* const userRepository = $repository({ table: User });
|
|
1094
|
-
* ```
|
|
1095
|
-
*/
|
|
1096
|
-
entity: EntityDescriptor<T>;
|
|
1097
|
-
/**
|
|
1098
|
-
* Override the default PostgreSQL database provider.
|
|
1099
|
-
*
|
|
1100
|
-
* By default, the repository will use the injected PostgresProvider from the
|
|
1101
|
-
* dependency injection container. Use this option to:
|
|
1102
|
-
* - Connect to a different database
|
|
1103
|
-
* - Use a specific connection pool
|
|
1104
|
-
* - Implement custom database behavior
|
|
1105
|
-
* - Support multi-tenant architectures with database per tenant
|
|
1106
|
-
*
|
|
1107
|
-
* **Common Use Cases**:
|
|
1108
|
-
* - Multi-database applications
|
|
1109
|
-
* - Read replicas for query optimization
|
|
1110
|
-
* - Different databases for different entity types
|
|
1111
|
-
* - Testing with separate test databases
|
|
1112
|
-
*
|
|
1113
|
-
* @default Uses injected PostgresProvider
|
|
1114
|
-
*
|
|
1115
|
-
* @example ReadOnlyPostgresProvider
|
|
1116
|
-
* @example TenantSpecificPostgresProvider
|
|
1117
|
-
* @example TestDatabaseProvider
|
|
1118
|
-
*/
|
|
1119
|
-
provider?: DatabaseProvider;
|
|
1120
|
-
name?: string;
|
|
1121
|
-
}
|
|
1122
|
-
declare class RepositoryDescriptor<T extends TObject = TObject> extends Descriptor<RepositoryDescriptorOptions<T>> {
|
|
1137
|
+
//#region src/services/Repository.d.ts
|
|
1138
|
+
declare abstract class Repository<T extends TObject> {
|
|
1139
|
+
readonly entity: EntityDescriptor<T>;
|
|
1140
|
+
readonly provider: DatabaseProvider;
|
|
1123
1141
|
protected readonly relationManager: PgRelationManager;
|
|
1124
|
-
protected readonly queryManager:
|
|
1142
|
+
protected readonly queryManager: QueryManager;
|
|
1125
1143
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
1126
1144
|
protected readonly alepha: Alepha;
|
|
1127
|
-
|
|
1128
|
-
constructor(args: DescriptorArgs<RepositoryDescriptorOptions<T>>);
|
|
1129
|
-
/**
|
|
1130
|
-
* Get the entity descriptor associated with this repository.
|
|
1131
|
-
*/
|
|
1132
|
-
get entity(): EntityDescriptor<T>;
|
|
1145
|
+
constructor(entity: EntityDescriptor<T>, provider?: typeof DatabaseProvider);
|
|
1133
1146
|
/**
|
|
1134
1147
|
* Represents the primary key of the table.
|
|
1135
1148
|
* - Key is the name of the primary key column.
|
|
@@ -1233,9 +1246,9 @@ declare class RepositoryDescriptor<T extends TObject = TObject> extends Descript
|
|
|
1233
1246
|
*
|
|
1234
1247
|
* > Pagination CAN also do a count query to get the total number of elements.
|
|
1235
1248
|
*/
|
|
1236
|
-
paginate<R extends PgRelationMap<T>>(pagination?: PageQuery, query?: PgQueryRelations<T, R>, opts?: StatementOptions & {
|
|
1249
|
+
paginate<R extends PgRelationMap<T>>(pagination?: PageQuery$1, query?: PgQueryRelations<T, R>, opts?: StatementOptions & {
|
|
1237
1250
|
count?: boolean;
|
|
1238
|
-
}): Promise<Page<PgStatic<T, R>>>;
|
|
1251
|
+
}): Promise<Page$1<PgStatic<T, R>>>;
|
|
1239
1252
|
/**
|
|
1240
1253
|
* Find an entity by ID.
|
|
1241
1254
|
*
|
|
@@ -1334,7 +1347,7 @@ declare class RepositoryDescriptor<T extends TObject = TObject> extends Descript
|
|
|
1334
1347
|
*/
|
|
1335
1348
|
count(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<number>;
|
|
1336
1349
|
protected conflictMessagePattern: string;
|
|
1337
|
-
protected handleError(error: unknown, message: string):
|
|
1350
|
+
protected handleError(error: unknown, message: string): DbError;
|
|
1338
1351
|
protected withDeletedAt(where: PgQueryWhereOrSQL<T>, opts?: {
|
|
1339
1352
|
force?: boolean;
|
|
1340
1353
|
}): PgQueryWhereOrSQL<T>;
|
|
@@ -1375,7 +1388,6 @@ declare class RepositoryDescriptor<T extends TObject = TObject> extends Descript
|
|
|
1375
1388
|
col: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
1376
1389
|
type: TSchema;
|
|
1377
1390
|
};
|
|
1378
|
-
protected $provider(): DatabaseProvider;
|
|
1379
1391
|
}
|
|
1380
1392
|
/**
|
|
1381
1393
|
* The options for a statement.
|
|
@@ -1402,6 +1414,12 @@ interface StatementOptions {
|
|
|
1402
1414
|
now?: DateTime;
|
|
1403
1415
|
}
|
|
1404
1416
|
//#endregion
|
|
1417
|
+
//#region src/descriptors/$repository.d.ts
|
|
1418
|
+
/**
|
|
1419
|
+
* Get the repository for the given entity.
|
|
1420
|
+
*/
|
|
1421
|
+
declare const $repository: <T extends TObject>(entity: EntityDescriptor<T>) => Repository<T>;
|
|
1422
|
+
//#endregion
|
|
1405
1423
|
//#region src/descriptors/$transaction.d.ts
|
|
1406
1424
|
/**
|
|
1407
1425
|
* Creates a transaction descriptor for database operations requiring atomicity and consistency.
|
|
@@ -1519,25 +1537,25 @@ interface TransactionDescriptorOptions<T extends any[], R> {
|
|
|
1519
1537
|
* }
|
|
1520
1538
|
* ```
|
|
1521
1539
|
*/
|
|
1522
|
-
config?: PgTransactionConfig
|
|
1540
|
+
config?: PgTransactionConfig;
|
|
1523
1541
|
}
|
|
1524
1542
|
type TransactionContext = PgTransaction<any, any, any>;
|
|
1525
1543
|
//#endregion
|
|
1526
1544
|
//#region src/errors/PgConflictError.d.ts
|
|
1527
|
-
declare class PgConflictError extends
|
|
1545
|
+
declare class PgConflictError extends DbError {
|
|
1528
1546
|
readonly name = "PgConflictError";
|
|
1529
1547
|
readonly status = 409;
|
|
1530
1548
|
}
|
|
1531
1549
|
//#endregion
|
|
1532
1550
|
//#region src/errors/PgEntityNotFoundError.d.ts
|
|
1533
|
-
declare class PgEntityNotFoundError extends
|
|
1551
|
+
declare class PgEntityNotFoundError extends DbError {
|
|
1534
1552
|
readonly name = "EntityNotFoundError";
|
|
1535
1553
|
readonly status = 404;
|
|
1536
1554
|
constructor(entityName: string);
|
|
1537
1555
|
}
|
|
1538
1556
|
//#endregion
|
|
1539
1557
|
//#region src/errors/PgMigrationError.d.ts
|
|
1540
|
-
declare class PgMigrationError extends
|
|
1558
|
+
declare class PgMigrationError extends DbError {
|
|
1541
1559
|
readonly name = "PgMigrationError";
|
|
1542
1560
|
constructor(cause?: unknown);
|
|
1543
1561
|
}
|
|
@@ -1548,56 +1566,69 @@ declare class PgMigrationError extends PgError {
|
|
|
1548
1566
|
* It's thrown by {@link RepositoryDescriptor#save} when the updated entity version does not match the one in the database.
|
|
1549
1567
|
* This is used for optimistic concurrency control.
|
|
1550
1568
|
*/
|
|
1551
|
-
declare class PgVersionMismatchError extends
|
|
1569
|
+
declare class PgVersionMismatchError extends DbError {
|
|
1552
1570
|
readonly name = "PgVersionMismatchError";
|
|
1553
1571
|
constructor(table: string, id: any);
|
|
1554
1572
|
}
|
|
1555
1573
|
//#endregion
|
|
1556
|
-
//#region src/
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1574
|
+
//#region src/helpers/parseQueryString.d.ts
|
|
1575
|
+
/**
|
|
1576
|
+
* Parse a string query into a PgQueryWhere object.
|
|
1577
|
+
*
|
|
1578
|
+
* Supported syntax:
|
|
1579
|
+
* - Simple equality: "name=John"
|
|
1580
|
+
* - Operators: "age>18", "age>=18", "age<65", "age<=65", "status!=active"
|
|
1581
|
+
* - LIKE patterns: "name~John" (like), "name~*John" (ilike)
|
|
1582
|
+
* - NULL checks: "deletedAt=null", "email!=null"
|
|
1583
|
+
* - IN arrays: "status=[pending,active]"
|
|
1584
|
+
* - AND conditions: "name=John&age>18"
|
|
1585
|
+
* - OR conditions: "name=John|email=john@example.com"
|
|
1586
|
+
* - Nested AND/OR: "(name=John|name=Jane)&age>18"
|
|
1587
|
+
* - JSONB nested: "profile.city=Paris"
|
|
1588
|
+
*
|
|
1589
|
+
* @example
|
|
1590
|
+
* ```ts
|
|
1591
|
+
* // Simple equality
|
|
1592
|
+
* parseQueryString("name=John")
|
|
1593
|
+
* // => { name: { eq: "John" } }
|
|
1594
|
+
*
|
|
1595
|
+
* // Multiple conditions
|
|
1596
|
+
* parseQueryString("name=John&age>18")
|
|
1597
|
+
* // => { and: [{ name: { eq: "John" } }, { age: { gt: 18 } }] }
|
|
1598
|
+
*
|
|
1599
|
+
* // OR conditions
|
|
1600
|
+
* parseQueryString("status=active|status=pending")
|
|
1601
|
+
* // => { or: [{ status: { eq: "active" } }, { status: { eq: "pending" } }] }
|
|
1602
|
+
*
|
|
1603
|
+
* // Complex nested
|
|
1604
|
+
* parseQueryString("(name=John|name=Jane)&age>18&status!=archived")
|
|
1605
|
+
* // => { and: [
|
|
1606
|
+
* // { or: [{ name: { eq: "John" } }, { name: { eq: "Jane" } }] },
|
|
1607
|
+
* // { age: { gt: 18 } },
|
|
1608
|
+
* // { status: { ne: "archived" } }
|
|
1609
|
+
* // ] }
|
|
1610
|
+
*
|
|
1611
|
+
* // JSONB nested query
|
|
1612
|
+
* parseQueryString("profile.city=Paris&profile.age>25")
|
|
1613
|
+
* // => { profile: { city: { eq: "Paris" }, age: { gt: 25 } } }
|
|
1614
|
+
* ```
|
|
1615
|
+
*/
|
|
1616
|
+
declare function parseQueryString<T extends TObject>(query: string): PgQueryWhere<T>;
|
|
1617
|
+
/**
|
|
1618
|
+
* Helper function to build query strings programmatically
|
|
1619
|
+
*
|
|
1620
|
+
* @example
|
|
1621
|
+
* ```ts
|
|
1622
|
+
* buildQueryString({
|
|
1623
|
+
* and: [
|
|
1624
|
+
* { name: "eq:John" },
|
|
1625
|
+
* { age: "gt:18" }
|
|
1626
|
+
* ]
|
|
1627
|
+
* })
|
|
1628
|
+
* // => "name=John&age>18"
|
|
1629
|
+
* ```
|
|
1630
|
+
*/
|
|
1631
|
+
declare function buildQueryString(where: any): string;
|
|
1601
1632
|
//#endregion
|
|
1602
1633
|
//#region src/services/PostgresModelBuilder.d.ts
|
|
1603
1634
|
declare class PostgresModelBuilder extends ModelBuilder {
|
|
@@ -1653,53 +1684,41 @@ declare const envSchema: _alepha_core10.TObject<{
|
|
|
1653
1684
|
* It will monkey patch drizzle tables.
|
|
1654
1685
|
*/
|
|
1655
1686
|
POSTGRES_SCHEMA: _alepha_core10.TOptional<_alepha_core10.TString>;
|
|
1656
|
-
/**
|
|
1657
|
-
* Synchronize the database schema with the models.
|
|
1658
|
-
* It uses a custom implementation, it's not related to `drizzle-kit push` command.
|
|
1659
|
-
* It will generate the migration script and save it to the DB.
|
|
1660
|
-
*
|
|
1661
|
-
* This is recommended for development and testing purposes only.
|
|
1662
|
-
*/
|
|
1663
|
-
POSTGRES_SYNCHRONIZE: _alepha_core10.TOptional<_alepha_core10.TBoolean>;
|
|
1664
1687
|
}>;
|
|
1665
|
-
interface NodePostgresProviderOptions {
|
|
1666
|
-
migrations: MigrationConfig;
|
|
1667
|
-
connection: postgres.Options<any>;
|
|
1668
|
-
}
|
|
1669
1688
|
declare class NodePostgresProvider extends DatabaseProvider {
|
|
1670
1689
|
static readonly SSL_MODES: readonly ["require", "allow", "prefer", "verify-full"];
|
|
1671
|
-
readonly dialect = "postgres";
|
|
1672
1690
|
protected readonly log: _alepha_logger0.Logger;
|
|
1673
1691
|
protected readonly env: {
|
|
1674
1692
|
DATABASE_URL?: string | undefined;
|
|
1675
1693
|
POSTGRES_SCHEMA?: string | undefined;
|
|
1676
|
-
POSTGRES_SYNCHRONIZE?: boolean | undefined;
|
|
1677
1694
|
};
|
|
1678
|
-
protected readonly alepha: Alepha;
|
|
1679
1695
|
protected readonly kit: DrizzleKitProvider;
|
|
1680
1696
|
protected readonly builder: PostgresModelBuilder;
|
|
1681
1697
|
protected client?: postgres.Sql;
|
|
1682
1698
|
protected pg?: PostgresJsDatabase;
|
|
1683
|
-
readonly
|
|
1699
|
+
readonly dialect = "postgresql";
|
|
1684
1700
|
/**
|
|
1685
1701
|
* In testing mode, the schema name will be generated and deleted after the test.
|
|
1686
1702
|
*/
|
|
1687
1703
|
protected schemaForTesting: string | undefined;
|
|
1704
|
+
/**
|
|
1705
|
+
* Execute a SQL statement.
|
|
1706
|
+
*/
|
|
1688
1707
|
execute(statement: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
1689
1708
|
/**
|
|
1690
|
-
* Get Postgres schema.
|
|
1709
|
+
* Get Postgres schema used by this provider.
|
|
1691
1710
|
*/
|
|
1692
1711
|
get schema(): string;
|
|
1712
|
+
/**
|
|
1713
|
+
* Get the Drizzle Postgres database instance.
|
|
1714
|
+
*/
|
|
1693
1715
|
get db(): PostgresJsDatabase;
|
|
1716
|
+
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1694
1717
|
protected readonly onStart: _alepha_core10.HookDescriptor<"start">;
|
|
1695
1718
|
protected readonly onStop: _alepha_core10.HookDescriptor<"stop">;
|
|
1696
1719
|
connect(): Promise<void>;
|
|
1697
1720
|
close(): Promise<void>;
|
|
1698
1721
|
protected migrate: _alepha_lock0.LockDescriptor<() => Promise<void>>;
|
|
1699
|
-
/**
|
|
1700
|
-
* Generate a minimal migration configuration.
|
|
1701
|
-
*/
|
|
1702
|
-
protected getMigrationOptions(): MigrationConfig;
|
|
1703
1722
|
/**
|
|
1704
1723
|
* Map the DATABASE_URL to postgres client options.
|
|
1705
1724
|
*/
|
|
@@ -1713,6 +1732,198 @@ declare class NodePostgresProvider extends DatabaseProvider {
|
|
|
1713
1732
|
protected generateTestSchemaName(): string;
|
|
1714
1733
|
}
|
|
1715
1734
|
//#endregion
|
|
1735
|
+
//#region src/services/SqliteModelBuilder.d.ts
|
|
1736
|
+
declare class SqliteModelBuilder extends ModelBuilder {
|
|
1737
|
+
buildTable(entity: EntityDescriptor<any>, options: {
|
|
1738
|
+
tables: Map<string, unknown>;
|
|
1739
|
+
enums: Map<string, unknown>;
|
|
1740
|
+
schema: string;
|
|
1741
|
+
}): void;
|
|
1742
|
+
buildSequence(sequence: SequenceDescriptor, options: {
|
|
1743
|
+
sequences: Map<string, unknown>;
|
|
1744
|
+
schema: string;
|
|
1745
|
+
}): void;
|
|
1746
|
+
/**
|
|
1747
|
+
* Get SQLite-specific config builder for the table.
|
|
1748
|
+
*/
|
|
1749
|
+
protected getTableConfig(entity: EntityDescriptor, tables: Map<string, unknown>): ((self: BuildColumns<string, any, "sqlite">) => any) | undefined;
|
|
1750
|
+
schemaToSqliteColumns: <T extends TObject>(tableName: string, schema: T, enums: Map<string, unknown>, tables: Map<string, unknown>) => SchemaToSqliteBuilder<T>;
|
|
1751
|
+
mapFieldToSqliteColumn: (tableName: string, fieldName: string, value: TSchema, enums: Map<string, any>) => pg$1.SQLiteIntegerBuilderInitial<string> | pg$1.SQLiteNumericBuilderInitial<string> | pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1752
|
+
name: string;
|
|
1753
|
+
dataType: "custom";
|
|
1754
|
+
columnType: "SQLiteCustomColumn";
|
|
1755
|
+
data: string;
|
|
1756
|
+
driverParam: string;
|
|
1757
|
+
enumValues: undefined;
|
|
1758
|
+
}>, string> | pg$1.SQLiteCustomColumnBuilder<{
|
|
1759
|
+
name: string;
|
|
1760
|
+
dataType: "custom";
|
|
1761
|
+
columnType: "SQLiteCustomColumn";
|
|
1762
|
+
data: string;
|
|
1763
|
+
driverParam: number;
|
|
1764
|
+
enumValues: undefined;
|
|
1765
|
+
}> | pg$1.SQLiteCustomColumnBuilder<{
|
|
1766
|
+
name: string;
|
|
1767
|
+
dataType: "custom";
|
|
1768
|
+
columnType: "SQLiteCustomColumn";
|
|
1769
|
+
data: boolean;
|
|
1770
|
+
driverParam: number;
|
|
1771
|
+
enumValues: undefined;
|
|
1772
|
+
}> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1773
|
+
name: string;
|
|
1774
|
+
dataType: "custom";
|
|
1775
|
+
columnType: "SQLiteCustomColumn";
|
|
1776
|
+
data: {
|
|
1777
|
+
[x: string]: unknown;
|
|
1778
|
+
[x: number]: unknown;
|
|
1779
|
+
[x: symbol]: unknown;
|
|
1780
|
+
};
|
|
1781
|
+
driverParam: string;
|
|
1782
|
+
enumValues: undefined;
|
|
1783
|
+
}>, {
|
|
1784
|
+
[x: string]: unknown;
|
|
1785
|
+
[x: number]: unknown;
|
|
1786
|
+
[x: symbol]: unknown;
|
|
1787
|
+
}> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1788
|
+
name: string;
|
|
1789
|
+
dataType: "custom";
|
|
1790
|
+
columnType: "SQLiteCustomColumn";
|
|
1791
|
+
data: Record<string, unknown>;
|
|
1792
|
+
driverParam: string;
|
|
1793
|
+
enumValues: undefined;
|
|
1794
|
+
}>, Record<string, unknown>> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1795
|
+
name: string;
|
|
1796
|
+
dataType: "custom";
|
|
1797
|
+
columnType: "SQLiteCustomColumn";
|
|
1798
|
+
data: any;
|
|
1799
|
+
driverParam: string;
|
|
1800
|
+
enumValues: undefined;
|
|
1801
|
+
}>, any> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1802
|
+
name: string;
|
|
1803
|
+
dataType: "custom";
|
|
1804
|
+
columnType: "SQLiteCustomColumn";
|
|
1805
|
+
data: unknown[];
|
|
1806
|
+
driverParam: string;
|
|
1807
|
+
enumValues: undefined;
|
|
1808
|
+
}>, unknown[]>;
|
|
1809
|
+
mapStringToSqliteColumn: (key: string, value: TString) => pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1810
|
+
name: string;
|
|
1811
|
+
dataType: "custom";
|
|
1812
|
+
columnType: "SQLiteCustomColumn";
|
|
1813
|
+
data: string;
|
|
1814
|
+
driverParam: string;
|
|
1815
|
+
enumValues: undefined;
|
|
1816
|
+
}>, string> | pg$1.SQLiteCustomColumnBuilder<{
|
|
1817
|
+
name: string;
|
|
1818
|
+
dataType: "custom";
|
|
1819
|
+
columnType: "SQLiteCustomColumn";
|
|
1820
|
+
data: string;
|
|
1821
|
+
driverParam: number;
|
|
1822
|
+
enumValues: undefined;
|
|
1823
|
+
}>;
|
|
1824
|
+
sqliteJson: <TDocument extends TSchema>(name: string, document: TDocument) => drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1825
|
+
name: string;
|
|
1826
|
+
dataType: "custom";
|
|
1827
|
+
columnType: "SQLiteCustomColumn";
|
|
1828
|
+
data: typebox1.StaticType<[], "Decode", {}, {}, TDocument>;
|
|
1829
|
+
driverParam: string;
|
|
1830
|
+
enumValues: undefined;
|
|
1831
|
+
}>, typebox1.StaticType<[], "Decode", {}, {}, TDocument>>;
|
|
1832
|
+
sqliteDateTime: {
|
|
1833
|
+
<TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
|
|
1834
|
+
name: "";
|
|
1835
|
+
dataType: "custom";
|
|
1836
|
+
columnType: "SQLiteCustomColumn";
|
|
1837
|
+
data: string;
|
|
1838
|
+
driverParam: number;
|
|
1839
|
+
enumValues: undefined;
|
|
1840
|
+
}>;
|
|
1841
|
+
<TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
|
|
1842
|
+
name: TName;
|
|
1843
|
+
dataType: "custom";
|
|
1844
|
+
columnType: "SQLiteCustomColumn";
|
|
1845
|
+
data: string;
|
|
1846
|
+
driverParam: number;
|
|
1847
|
+
enumValues: undefined;
|
|
1848
|
+
}>;
|
|
1849
|
+
};
|
|
1850
|
+
sqliteBool: {
|
|
1851
|
+
<TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
|
|
1852
|
+
name: "";
|
|
1853
|
+
dataType: "custom";
|
|
1854
|
+
columnType: "SQLiteCustomColumn";
|
|
1855
|
+
data: boolean;
|
|
1856
|
+
driverParam: number;
|
|
1857
|
+
enumValues: undefined;
|
|
1858
|
+
}>;
|
|
1859
|
+
<TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
|
|
1860
|
+
name: TName;
|
|
1861
|
+
dataType: "custom";
|
|
1862
|
+
columnType: "SQLiteCustomColumn";
|
|
1863
|
+
data: boolean;
|
|
1864
|
+
driverParam: number;
|
|
1865
|
+
enumValues: undefined;
|
|
1866
|
+
}>;
|
|
1867
|
+
};
|
|
1868
|
+
sqliteDate: {
|
|
1869
|
+
<TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
|
|
1870
|
+
name: "";
|
|
1871
|
+
dataType: "custom";
|
|
1872
|
+
columnType: "SQLiteCustomColumn";
|
|
1873
|
+
data: string;
|
|
1874
|
+
driverParam: number;
|
|
1875
|
+
enumValues: undefined;
|
|
1876
|
+
}>;
|
|
1877
|
+
<TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
|
|
1878
|
+
name: TName;
|
|
1879
|
+
dataType: "custom";
|
|
1880
|
+
columnType: "SQLiteCustomColumn";
|
|
1881
|
+
data: string;
|
|
1882
|
+
driverParam: number;
|
|
1883
|
+
enumValues: undefined;
|
|
1884
|
+
}>;
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
type SchemaToSqliteBuilder<T extends TObject> = { [key in keyof T["properties"]]: SQLiteColumnBuilderBase };
|
|
1888
|
+
//#endregion
|
|
1889
|
+
//#region src/providers/drivers/NodeSqliteProvider.d.ts
|
|
1890
|
+
/**
|
|
1891
|
+
* Configuration options for the Node.js SQLite database provider.
|
|
1892
|
+
*/
|
|
1893
|
+
declare const nodeSqliteOptions: _alepha_core10.Atom<typebox1.TObject<{
|
|
1894
|
+
path: typebox1.TOptional<typebox1.TString>;
|
|
1895
|
+
}>, "alepha.postgres.node-sqlite.options">;
|
|
1896
|
+
type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
|
|
1897
|
+
declare module "alepha" {
|
|
1898
|
+
interface State {
|
|
1899
|
+
[nodeSqliteOptions.key]: NodeSqliteProviderOptions;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Add a fake support for SQLite in Node.js based on Postgres interfaces.
|
|
1904
|
+
*
|
|
1905
|
+
* This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
|
|
1906
|
+
* This is NOT recommended for production use.
|
|
1907
|
+
*/
|
|
1908
|
+
declare class NodeSqliteProvider extends DatabaseProvider {
|
|
1909
|
+
protected readonly kit: DrizzleKitProvider;
|
|
1910
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
1911
|
+
protected readonly env: {
|
|
1912
|
+
DATABASE_URL?: string | undefined;
|
|
1913
|
+
};
|
|
1914
|
+
protected readonly builder: SqliteModelBuilder;
|
|
1915
|
+
protected readonly options: Readonly<{
|
|
1916
|
+
path?: string | undefined;
|
|
1917
|
+
}>;
|
|
1918
|
+
protected sqlite: DatabaseSync;
|
|
1919
|
+
readonly dialect = "sqlite";
|
|
1920
|
+
get path(): string;
|
|
1921
|
+
execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
1922
|
+
readonly db: PgDatabase<any>;
|
|
1923
|
+
protected readonly onStart: _alepha_core10.HookDescriptor<"start">;
|
|
1924
|
+
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1925
|
+
}
|
|
1926
|
+
//#endregion
|
|
1716
1927
|
//#region src/providers/PostgresTypeProvider.d.ts
|
|
1717
1928
|
declare class PostgresTypeProvider {
|
|
1718
1929
|
readonly attr: <T extends TSchema, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
|
|
@@ -1758,17 +1969,17 @@ declare class PostgresTypeProvider {
|
|
|
1758
1969
|
/**
|
|
1759
1970
|
* Creates a column Created At. So just a datetime column with a default value of the current timestamp.
|
|
1760
1971
|
*/
|
|
1761
|
-
readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<
|
|
1972
|
+
readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<typebox1.TCodec<TString, dayjs0.Dayjs>, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1762
1973
|
/**
|
|
1763
1974
|
* Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
|
|
1764
1975
|
*/
|
|
1765
|
-
readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<
|
|
1976
|
+
readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<typebox1.TCodec<TString, dayjs0.Dayjs>, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1766
1977
|
/**
|
|
1767
1978
|
* Creates a column Deleted At for soft delete functionality.
|
|
1768
1979
|
* This is used to mark rows as deleted without actually removing them from the database.
|
|
1769
1980
|
* The column is nullable - NULL means not deleted, timestamp means deleted.
|
|
1770
1981
|
*/
|
|
1771
|
-
readonly deletedAt: (options?: TStringOptions) => PgAttr<
|
|
1982
|
+
readonly deletedAt: (options?: TStringOptions) => PgAttr<typebox1.TOptional<typebox1.TCodec<TString, dayjs0.Dayjs>>, typeof PG_DELETED_AT>;
|
|
1772
1983
|
/**
|
|
1773
1984
|
* Creates a Postgres ENUM type.
|
|
1774
1985
|
*
|
|
@@ -1796,11 +2007,19 @@ declare class PostgresTypeProvider {
|
|
|
1796
2007
|
}
|
|
1797
2008
|
declare const pg: PostgresTypeProvider;
|
|
1798
2009
|
//#endregion
|
|
2010
|
+
//#region src/providers/RepositoryProvider.d.ts
|
|
2011
|
+
declare class RepositoryProvider {
|
|
2012
|
+
protected readonly alepha: Alepha;
|
|
2013
|
+
protected readonly registry: Map<EntityDescriptor<any>, Service<Repository<any>>>;
|
|
2014
|
+
getRepositories(provider?: DatabaseProvider): Repository<TObject<typebox1.TProperties>>[];
|
|
2015
|
+
createClassRepository<T extends TObject>(entity: EntityDescriptor<T>): Service<Repository<T>>;
|
|
2016
|
+
}
|
|
2017
|
+
//#endregion
|
|
1799
2018
|
//#region src/schemas/legacyIdSchema.d.ts
|
|
1800
2019
|
/**
|
|
1801
2020
|
* @deprecated Use `pg.primaryKey()` instead.
|
|
1802
2021
|
*/
|
|
1803
|
-
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<
|
|
2022
|
+
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<typebox1.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1804
2023
|
//#endregion
|
|
1805
2024
|
//#region src/types/schema.d.ts
|
|
1806
2025
|
/**
|
|
@@ -1810,12 +2029,78 @@ declare const schema: <TDocument extends TSchema>(name: string, document: TDocum
|
|
|
1810
2029
|
name: string;
|
|
1811
2030
|
dataType: "custom";
|
|
1812
2031
|
columnType: "PgCustomColumn";
|
|
1813
|
-
data:
|
|
2032
|
+
data: typebox1.StaticType<[], "Decode", {}, {}, TDocument>;
|
|
1814
2033
|
driverParam: string;
|
|
1815
2034
|
enumValues: undefined;
|
|
1816
|
-
}>,
|
|
2035
|
+
}>, typebox1.StaticType<[], "Decode", {}, {}, TDocument>>;
|
|
1817
2036
|
//#endregion
|
|
1818
2037
|
//#region src/index.d.ts
|
|
2038
|
+
declare module "alepha" {
|
|
2039
|
+
interface Hooks {
|
|
2040
|
+
/**
|
|
2041
|
+
* Fires before creating an entity in the repository.
|
|
2042
|
+
*/
|
|
2043
|
+
"repository:create:before": {
|
|
2044
|
+
tableName: string;
|
|
2045
|
+
data: any;
|
|
2046
|
+
};
|
|
2047
|
+
/**
|
|
2048
|
+
* Fires after creating an entity in the repository.
|
|
2049
|
+
*/
|
|
2050
|
+
"repository:create:after": {
|
|
2051
|
+
tableName: string;
|
|
2052
|
+
data: any;
|
|
2053
|
+
entity: any;
|
|
2054
|
+
};
|
|
2055
|
+
/**
|
|
2056
|
+
* Fires before updating entities in the repository.
|
|
2057
|
+
*/
|
|
2058
|
+
"repository:update:before": {
|
|
2059
|
+
tableName: string;
|
|
2060
|
+
where: any;
|
|
2061
|
+
data: any;
|
|
2062
|
+
};
|
|
2063
|
+
/**
|
|
2064
|
+
* Fires after updating entities in the repository.
|
|
2065
|
+
*/
|
|
2066
|
+
"repository:update:after": {
|
|
2067
|
+
tableName: string;
|
|
2068
|
+
where: any;
|
|
2069
|
+
data: any;
|
|
2070
|
+
entities: any[];
|
|
2071
|
+
};
|
|
2072
|
+
/**
|
|
2073
|
+
* Fires before deleting entities from the repository.
|
|
2074
|
+
*/
|
|
2075
|
+
"repository:delete:before": {
|
|
2076
|
+
tableName: string;
|
|
2077
|
+
where: any;
|
|
2078
|
+
};
|
|
2079
|
+
/**
|
|
2080
|
+
* Fires after deleting entities from the repository.
|
|
2081
|
+
*/
|
|
2082
|
+
"repository:delete:after": {
|
|
2083
|
+
tableName: string;
|
|
2084
|
+
where: any;
|
|
2085
|
+
ids: Array<string | number>;
|
|
2086
|
+
};
|
|
2087
|
+
/**
|
|
2088
|
+
* Fires before reading entities from the repository.
|
|
2089
|
+
*/
|
|
2090
|
+
"repository:read:before": {
|
|
2091
|
+
tableName: string;
|
|
2092
|
+
query: any;
|
|
2093
|
+
};
|
|
2094
|
+
/**
|
|
2095
|
+
* Fires after reading entities from the repository.
|
|
2096
|
+
*/
|
|
2097
|
+
"repository:read:after": {
|
|
2098
|
+
tableName: string;
|
|
2099
|
+
query: any;
|
|
2100
|
+
entities: any[];
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
1819
2104
|
/**
|
|
1820
2105
|
* Postgres client based on Drizzle ORM, Alepha type-safe friendly.
|
|
1821
2106
|
*
|
|
@@ -1855,7 +2140,7 @@ declare const schema: <TDocument extends TSchema>(name: string, document: TDocum
|
|
|
1855
2140
|
* @see {@link $transaction}
|
|
1856
2141
|
* @module alepha.postgres
|
|
1857
2142
|
*/
|
|
1858
|
-
declare const AlephaPostgres: _alepha_core10.Service<_alepha_core10.Module
|
|
2143
|
+
declare const AlephaPostgres: _alepha_core10.Service<_alepha_core10.Module>;
|
|
1859
2144
|
//#endregion
|
|
1860
|
-
export { $entity, $repository, $sequence, $transaction, AlephaPostgres, DatabaseProvider, DrizzleKitProvider, EntityColumn, EntityColumns, EntityDescriptor, EntityDescriptorOptions, FilterOperators, FromSchema, NodePostgresProvider,
|
|
2145
|
+
export { $entity, $repository, $sequence, $transaction, AlephaPostgres, DatabaseProvider, DbError, DrizzleKitProvider, EntityColumn, EntityColumns, EntityDescriptor, EntityDescriptorOptions, FilterOperators, FromSchema, NodePostgresProvider, NodeSqliteProvider, NodeSqliteProviderOptions, OrderBy, OrderByClause, OrderDirection, PG_CREATED_AT, PG_DEFAULT, PG_DELETED_AT, PG_ENUM, PG_IDENTITY, PG_PRIMARY_KEY, PG_REF, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, type Page, type PageQuery, PgAttr, PgAttrField, PgConflictError, PgDefault, PgEntityNotFoundError, PgEnumOptions, PgIdentityOptions, PgMigrationError, PgPrimaryKey, PgQuery, PgQueryRelations, PgQueryWhere, PgQueryWhereOrSQL, PgRef, PgRefOptions, PgRelation, PgRelationMap, PgStatic, PgSymbolKeys, PgSymbols, PgVersionMismatchError, PostgresTypeProvider, Repository, RepositoryProvider, SQLLike, SchemaToTableConfig, SequenceDescriptor, SequenceDescriptorOptions, StatementOptions, TObjectInsert, TObjectUpdate, TransactionContext, TransactionDescriptorOptions, buildQueryString, drizzle_orm0 as drizzle, getAttrFields, insertSchema, legacyIdSchema, nodeSqliteOptions, pageQuerySchema, pageSchema, parseQueryString, pg, pgAttr, schema, sql, updateSchema };
|
|
1861
2146
|
//# sourceMappingURL=index.d.ts.map
|