hysteria-orm 10.7.2 → 10.7.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/lib/cli.js +56 -28
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +56 -28
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +109 -30
- package/lib/index.d.ts +109 -30
- package/lib/index.js +56 -28
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -34,6 +34,39 @@ declare abstract class Entity {
|
|
|
34
34
|
static databaseCaseConvention: CaseConvention;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
type CustomLogger = {
|
|
38
|
+
info(message: string): void;
|
|
39
|
+
error(message: string): void;
|
|
40
|
+
warn(message: string): void;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* @description Configuration for logging behavior
|
|
44
|
+
* @warning Logs are synchronous by default and add overhead — do not use in production unless you override with an async custom logger. Logs are mainly for debugging.
|
|
45
|
+
*/
|
|
46
|
+
type LoggerConfig = {
|
|
47
|
+
/**
|
|
48
|
+
* @description Minimum log level. Messages below this level are suppressed.
|
|
49
|
+
* @default "info"
|
|
50
|
+
*/
|
|
51
|
+
level?: "info" | "warn" | "error";
|
|
52
|
+
/**
|
|
53
|
+
* @description Whether to log SQL/Mongo queries.
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
logQueries?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* @description Custom logger instance. When provided, replaces the default console logger.
|
|
59
|
+
*/
|
|
60
|
+
customLogger?: CustomLogger;
|
|
61
|
+
};
|
|
62
|
+
declare class HysteriaLogger {
|
|
63
|
+
static loggerInstance: CustomLogger;
|
|
64
|
+
static setCustomLogger(customLogger: CustomLogger): void;
|
|
65
|
+
static info(message: string): void;
|
|
66
|
+
static error(message: string | Error): void;
|
|
67
|
+
static warn(message: string): void;
|
|
68
|
+
}
|
|
69
|
+
|
|
37
70
|
/**
|
|
38
71
|
* @description Creates a datasource for the selected database type with the provided credentials
|
|
39
72
|
*/
|
|
@@ -56,7 +89,7 @@ interface OracleDBDataSourceInput extends CommonDataSourceInput {
|
|
|
56
89
|
}
|
|
57
90
|
interface CommonDataSourceInput {
|
|
58
91
|
readonly type?: DataSourceType;
|
|
59
|
-
readonly logs?: boolean;
|
|
92
|
+
readonly logs?: boolean | LoggerConfig;
|
|
60
93
|
}
|
|
61
94
|
interface MongoDataSourceInput$1 extends CommonDataSourceInput {
|
|
62
95
|
readonly type: "mongo";
|
|
@@ -185,9 +218,9 @@ declare class MongoQueryBuilder<T extends Collection> {
|
|
|
185
218
|
protected mongoDataSource: MongoDataSource;
|
|
186
219
|
protected collection: Collection$1<T>;
|
|
187
220
|
protected model: typeof Collection;
|
|
188
|
-
protected logs: boolean;
|
|
221
|
+
protected logs: boolean | LoggerConfig;
|
|
189
222
|
protected session?: ReturnType<MongoDataSource["startSession"]>;
|
|
190
|
-
constructor(model: typeof Collection, mongoDataSource: MongoDataSource, _session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean);
|
|
223
|
+
constructor(model: typeof Collection, mongoDataSource: MongoDataSource, _session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean | LoggerConfig);
|
|
191
224
|
one(options?: OneOptions$1): Promise<T | null>;
|
|
192
225
|
oneOrFail(options?: OneOptions$1): Promise<T>;
|
|
193
226
|
many(options?: ManyOptions$1): Promise<T[]>;
|
|
@@ -475,7 +508,7 @@ declare abstract class DataSource {
|
|
|
475
508
|
password: string;
|
|
476
509
|
database: string;
|
|
477
510
|
url: string;
|
|
478
|
-
logs: boolean;
|
|
511
|
+
logs: boolean | LoggerConfig;
|
|
479
512
|
protected constructor(input?: DataSourceInput);
|
|
480
513
|
protected handleCockroachdbSource(input?: PostgresSqlDataSourceInput): void;
|
|
481
514
|
protected handlePostgresSource(input?: PostgresSqlDataSourceInput): void;
|
|
@@ -507,13 +540,13 @@ type MongoUnrestrictedFindManyOptions<T extends Collection> = UnrestrictedMongoF
|
|
|
507
540
|
offset?: number;
|
|
508
541
|
};
|
|
509
542
|
declare class CollectionManager<T extends Collection> {
|
|
510
|
-
protected logs: boolean;
|
|
543
|
+
protected logs: boolean | LoggerConfig;
|
|
511
544
|
protected collection: typeof Collection;
|
|
512
545
|
protected mongoClient: ReturnType<MongoDataSource["getCurrentConnection"]>;
|
|
513
546
|
protected mongoDataSource: MongoDataSource;
|
|
514
547
|
protected collectionInstance: MongoClientImport["Collection"]["prototype"];
|
|
515
548
|
protected session?: ReturnType<MongoDataSource["startSession"]>;
|
|
516
|
-
constructor(_collection: typeof Collection, mongoDataSource: MongoDataSource, session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean);
|
|
549
|
+
constructor(_collection: typeof Collection, mongoDataSource: MongoDataSource, session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean | LoggerConfig);
|
|
517
550
|
/**
|
|
518
551
|
* @description Finds all records that match the input
|
|
519
552
|
*/
|
|
@@ -555,10 +588,11 @@ declare class CollectionManager<T extends Collection> {
|
|
|
555
588
|
}
|
|
556
589
|
|
|
557
590
|
type MongoClientInstance = InstanceType<MongoClientImport["MongoClient"]>;
|
|
591
|
+
|
|
558
592
|
interface MongoDataSourceInput {
|
|
559
593
|
url?: string;
|
|
560
594
|
options?: MongoConnectionOptions;
|
|
561
|
-
logs?: boolean;
|
|
595
|
+
logs?: boolean | LoggerConfig;
|
|
562
596
|
}
|
|
563
597
|
declare class MongoDataSource extends DataSource {
|
|
564
598
|
url: string;
|
|
@@ -1389,9 +1423,11 @@ type SeederConfig = {
|
|
|
1389
1423
|
*/
|
|
1390
1424
|
type SqlDataSourceInputBase<T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}, D extends SqlDataSourceType = SqlDataSourceType> = {
|
|
1391
1425
|
/**
|
|
1392
|
-
* @description Whether to log the sql queries and other debug information
|
|
1426
|
+
* @description Whether to log the sql queries and other debug information. Can be a boolean or a LoggerConfig object for granular control.
|
|
1427
|
+
* @warning Logs are synchronous by default and add overhead — do not use in production unless you override with an async custom logger.
|
|
1428
|
+
* @default false
|
|
1393
1429
|
*/
|
|
1394
|
-
readonly logs?: boolean;
|
|
1430
|
+
readonly logs?: boolean | LoggerConfig;
|
|
1395
1431
|
/**
|
|
1396
1432
|
* @description The connection policies to use for the sql data source that are not configured in the driverOptions
|
|
1397
1433
|
*/
|
|
@@ -1481,7 +1517,7 @@ type UseConnectionInput<D extends SqlDataSourceType = SqlDataSourceType, T exten
|
|
|
1481
1517
|
* @description The type of the database to connect to
|
|
1482
1518
|
*/
|
|
1483
1519
|
readonly type: D;
|
|
1484
|
-
readonly logs?: boolean;
|
|
1520
|
+
readonly logs?: boolean | LoggerConfig;
|
|
1485
1521
|
readonly models?: T;
|
|
1486
1522
|
readonly driverOptions?: SqlDriverSpecificOptions<D>;
|
|
1487
1523
|
connectionPolicies?: ConnectionPolicies;
|
|
@@ -3301,6 +3337,10 @@ type UniqueType = {
|
|
|
3301
3337
|
columns: string[];
|
|
3302
3338
|
name: string;
|
|
3303
3339
|
};
|
|
3340
|
+
type CheckType = {
|
|
3341
|
+
expression: string;
|
|
3342
|
+
name: string;
|
|
3343
|
+
};
|
|
3304
3344
|
/**
|
|
3305
3345
|
* @description A property decorator that constrains the decorated property to type V.
|
|
3306
3346
|
* TypeScript infers K from the property name and T from the class, then checks
|
|
@@ -3317,7 +3357,7 @@ declare abstract class FooterQueryBuilder<T extends Model, S extends Record<stri
|
|
|
3317
3357
|
protected offsetNode: OffsetNode | null;
|
|
3318
3358
|
protected modelColumns: ColumnType[];
|
|
3319
3359
|
protected modelColumnsMap: Map<string, ColumnType>;
|
|
3320
|
-
protected logs: boolean;
|
|
3360
|
+
protected logs: boolean | LoggerConfig;
|
|
3321
3361
|
protected constructor(model: typeof Model, sqlDataSource: SqlDataSource);
|
|
3322
3362
|
/**
|
|
3323
3363
|
* @description Clears the group by query
|
|
@@ -3825,6 +3865,27 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
|
|
|
3825
3865
|
orWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
|
|
3826
3866
|
orWhere(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
|
|
3827
3867
|
orWhere(column: `${string}.${string}`, value: BaseValues): this;
|
|
3868
|
+
/**
|
|
3869
|
+
* @description Adds a WHERE condition comparing two columns.
|
|
3870
|
+
*/
|
|
3871
|
+
whereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
|
|
3872
|
+
whereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, referenceColumn: ModelKey<T>): this;
|
|
3873
|
+
whereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
|
|
3874
|
+
whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType, referenceColumn: `${string}.${string}`): this;
|
|
3875
|
+
/**
|
|
3876
|
+
* @description Adds an AND WHERE condition comparing two columns.
|
|
3877
|
+
*/
|
|
3878
|
+
andWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
|
|
3879
|
+
andWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, referenceColumn: ModelKey<T>): this;
|
|
3880
|
+
andWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
|
|
3881
|
+
andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType, referenceColumn: `${string}.${string}`): this;
|
|
3882
|
+
/**
|
|
3883
|
+
* @description Adds an OR WHERE condition comparing two columns.
|
|
3884
|
+
*/
|
|
3885
|
+
orWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
|
|
3886
|
+
orWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, referenceColumn: ModelKey<T>): this;
|
|
3887
|
+
orWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
|
|
3888
|
+
orWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType, referenceColumn: `${string}.${string}`): this;
|
|
3828
3889
|
/**
|
|
3829
3890
|
* @description Adds a negated WHERE condition to the query.
|
|
3830
3891
|
*/
|
|
@@ -4370,7 +4431,7 @@ type ComposeRawSelect<S extends Record<string, any>, Added extends Record<string
|
|
|
4370
4431
|
* @typeParam Columns - The columns being selected
|
|
4371
4432
|
*/
|
|
4372
4433
|
type ComposeBuildRawSelect<S extends Record<string, any>, Columns extends readonly Selectable[]> = (typeof RAW_SELECT_BRAND extends keyof S ? S : {}) & BuildRawSelectType<Columns>;
|
|
4373
|
-
type WhereOnlyQueryBuilder<T extends Model> = Pick<WhereQueryBuilder<T>, "where" | "andWhere" | "orWhere" | "whereNot" | "andWhereNot" | "orWhereNot" | "whereIn" | "andWhereIn" | "orWhereIn" | "whereNotIn" | "andWhereNotIn" | "orWhereNotIn" | "whereBetween" | "andWhereBetween" | "orWhereBetween" | "whereNotBetween" | "andWhereNotBetween" | "orWhereNotBetween" | "whereNull" | "andWhereNull" | "orWhereNull" | "whereNotNull" | "andWhereNotNull" | "orWhereNotNull" | "whereLike" | "andWhereLike" | "orWhereLike" | "whereILike" | "andWhereILike" | "orWhereILike" | "whereNotLike" | "andWhereNotLike" | "orWhereNotLike" | "whereNotILike" | "andWhereNotILike" | "orWhereNotILike" | "whereRegexp" | "andWhereRegexp" | "orWhereRegexp" | "whereNotRegexp" | "andWhereNotRegexp" | "orWhereNotRegexp" | "whereRaw" | "andWhereRaw" | "orWhereRaw" | "whereExists" | "orWhereExists" | "andWhereExists"> & Pick<JsonQueryBuilder<T>, "whereJson" | "andWhereJson" | "orWhereJson" | "whereJsonContains" | "andWhereJsonContains" | "orWhereJsonContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonRaw" | "andWhereJsonRaw" | "orWhereJsonRaw" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains">;
|
|
4434
|
+
type WhereOnlyQueryBuilder<T extends Model> = Pick<WhereQueryBuilder<T>, "where" | "andWhere" | "orWhere" | "whereNot" | "andWhereNot" | "orWhereNot" | "whereIn" | "andWhereIn" | "orWhereIn" | "whereNotIn" | "andWhereNotIn" | "orWhereNotIn" | "whereBetween" | "andWhereBetween" | "orWhereBetween" | "whereNotBetween" | "andWhereNotBetween" | "orWhereNotBetween" | "whereNull" | "andWhereNull" | "orWhereNull" | "whereNotNull" | "andWhereNotNull" | "orWhereNotNull" | "whereLike" | "andWhereLike" | "orWhereLike" | "whereILike" | "andWhereILike" | "orWhereILike" | "whereNotLike" | "andWhereNotLike" | "orWhereNotLike" | "whereNotILike" | "andWhereNotILike" | "orWhereNotILike" | "whereRegexp" | "andWhereRegexp" | "orWhereRegexp" | "whereNotRegexp" | "andWhereNotRegexp" | "orWhereNotRegexp" | "whereRaw" | "andWhereRaw" | "orWhereRaw" | "whereExists" | "orWhereExists" | "andWhereExists" | "whereNotExists" | "orWhereNotExists" | "andWhereNotExists" | "whereColumn" | "andWhereColumn" | "orWhereColumn"> & Pick<JsonQueryBuilder<T>, "whereJson" | "andWhereJson" | "orWhereJson" | "whereJsonContains" | "andWhereJsonContains" | "orWhereJsonContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonRaw" | "andWhereJsonRaw" | "orWhereJsonRaw" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains">;
|
|
4374
4435
|
type RelationRetrieveMethod<P extends any> = P extends any[] ? "many" : "one";
|
|
4375
4436
|
/**
|
|
4376
4437
|
* Validates a column string for raw query builder select().
|
|
@@ -4953,7 +5014,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
4953
5014
|
declare class ModelManager<T extends Model> {
|
|
4954
5015
|
protected sqlDataSource: SqlDataSource;
|
|
4955
5016
|
protected sqlType: SqlDataSourceType;
|
|
4956
|
-
protected logs: boolean;
|
|
5017
|
+
protected logs: boolean | LoggerConfig;
|
|
4957
5018
|
protected model: typeof Model;
|
|
4958
5019
|
protected modelInstance: T;
|
|
4959
5020
|
protected astParser: AstParser;
|
|
@@ -5050,11 +5111,16 @@ type TablePrimaryKeyInfo = {
|
|
|
5050
5111
|
name?: string;
|
|
5051
5112
|
columns: string[];
|
|
5052
5113
|
};
|
|
5114
|
+
type TableCheckConstraintInfo = {
|
|
5115
|
+
name: string;
|
|
5116
|
+
expression: string;
|
|
5117
|
+
};
|
|
5053
5118
|
type TableSchemaInfo = {
|
|
5054
5119
|
columns: TableColumnInfo[];
|
|
5055
5120
|
indexes: TableIndexInfo[];
|
|
5056
5121
|
foreignKeys: TableForeignKeyInfo[];
|
|
5057
5122
|
primaryKey?: TablePrimaryKeyInfo;
|
|
5123
|
+
checkConstraints: TableCheckConstraintInfo[];
|
|
5058
5124
|
};
|
|
5059
5125
|
type TableForeignKeyInfo = {
|
|
5060
5126
|
name?: string;
|
|
@@ -5554,6 +5620,10 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
5554
5620
|
* @description Introspects table primary key from the database
|
|
5555
5621
|
*/
|
|
5556
5622
|
getPrimaryKeyInfo(table: string): Promise<TablePrimaryKeyInfo | undefined>;
|
|
5623
|
+
/**
|
|
5624
|
+
* @description Introspects table CHECK constraints from the database
|
|
5625
|
+
*/
|
|
5626
|
+
getCheckConstraintInfo(table: string): Promise<TableCheckConstraintInfo[]>;
|
|
5557
5627
|
/**
|
|
5558
5628
|
* @description Acquires an advisory lock
|
|
5559
5629
|
* @description Useful for preventing concurrent operations from running simultaneously
|
|
@@ -6344,6 +6414,7 @@ declare abstract class Model<T extends Model<T> = any> extends Entity {
|
|
|
6344
6414
|
*/
|
|
6345
6415
|
static getIndexes(): IndexType[];
|
|
6346
6416
|
static getUniques(): UniqueType[];
|
|
6417
|
+
static getChecks(): CheckType[];
|
|
6347
6418
|
/**
|
|
6348
6419
|
* @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
|
|
6349
6420
|
* @javascript
|
|
@@ -6477,6 +6548,26 @@ type BaseModelRelationType = {
|
|
|
6477
6548
|
*/
|
|
6478
6549
|
declare function index(indexes: string | string[], indexName?: string): ClassDecorator;
|
|
6479
6550
|
declare function unique(columns: string | string[], constraintName?: string): ClassDecorator;
|
|
6551
|
+
/**
|
|
6552
|
+
* @description Decorator to define a CHECK constraint on the model's table
|
|
6553
|
+
* @param expression - The SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
|
|
6554
|
+
* @param constraintName - Optional custom name for the constraint
|
|
6555
|
+
* @example
|
|
6556
|
+
* ```ts
|
|
6557
|
+
* @check("age >= 0")
|
|
6558
|
+
* class User extends Model {
|
|
6559
|
+
* @column()
|
|
6560
|
+
* age!: number;
|
|
6561
|
+
* }
|
|
6562
|
+
*
|
|
6563
|
+
* @check("price > 0", "products_price_positive")
|
|
6564
|
+
* class Product extends Model {
|
|
6565
|
+
* @column()
|
|
6566
|
+
* price!: number;
|
|
6567
|
+
* }
|
|
6568
|
+
* ```
|
|
6569
|
+
*/
|
|
6570
|
+
declare function check(expression: string, constraintName?: string): ClassDecorator;
|
|
6480
6571
|
/**
|
|
6481
6572
|
* @description Decorator to define a view on the model
|
|
6482
6573
|
* @description This will automatically create a view on the database with the given statement
|
|
@@ -6728,6 +6819,7 @@ declare function getRelations(target: typeof Model): Relation[];
|
|
|
6728
6819
|
declare function getPrimaryKey(target: typeof Model): string | undefined;
|
|
6729
6820
|
declare function getIndexes(target: typeof Model): IndexType[];
|
|
6730
6821
|
declare function getUniques(target: typeof Model): UniqueType[];
|
|
6822
|
+
declare function getChecks(target: typeof Model): CheckType[];
|
|
6731
6823
|
|
|
6732
6824
|
type FactoryReturnType<T extends number, O extends Model> = T extends 1 ? O : O[];
|
|
6733
6825
|
|
|
@@ -7795,9 +7887,9 @@ declare class Schema {
|
|
|
7795
7887
|
}
|
|
7796
7888
|
|
|
7797
7889
|
declare abstract class Migration {
|
|
7798
|
-
dbType: SqlDataSourceType;
|
|
7799
|
-
migrationName: string;
|
|
7800
|
-
schema: Schema;
|
|
7890
|
+
readonly dbType: SqlDataSourceType;
|
|
7891
|
+
readonly migrationName: string;
|
|
7892
|
+
readonly schema: Schema;
|
|
7801
7893
|
constructor(dbType: SqlDataSourceType);
|
|
7802
7894
|
/**
|
|
7803
7895
|
* @description This method is called when the migration is to be run
|
|
@@ -7841,19 +7933,6 @@ declare class ClientMigrator {
|
|
|
7841
7933
|
*/
|
|
7842
7934
|
declare const defineMigrator: (migrationPath: string, sqlDataSourceInput?: SqlDataSource["inputDetails"] | SqlDataSource) => ClientMigrator;
|
|
7843
7935
|
|
|
7844
|
-
type CustomLogger = {
|
|
7845
|
-
info(message: string): void;
|
|
7846
|
-
error(message: string): void;
|
|
7847
|
-
warn(message: string): void;
|
|
7848
|
-
};
|
|
7849
|
-
declare class HysteriaLogger {
|
|
7850
|
-
static loggerInstance: CustomLogger;
|
|
7851
|
-
static setCustomLogger(customLogger: CustomLogger): void;
|
|
7852
|
-
static info(message: string): void;
|
|
7853
|
-
static error(message: string | Error): void;
|
|
7854
|
-
static warn(message: string): void;
|
|
7855
|
-
}
|
|
7856
|
-
|
|
7857
7936
|
/**
|
|
7858
7937
|
* @description Base class for all seeders
|
|
7859
7938
|
* @description Provides access to the SqlDataSource instance
|
|
@@ -7903,4 +7982,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
|
|
|
7903
7982
|
$id?: string;
|
|
7904
7983
|
}>;
|
|
7905
7984
|
|
|
7906
|
-
export { type AbstractConstructor, type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyConstructor, type AsymmetricEncryptionOptions, type BaseModelMethodOptions, type BaseModelRelationType, BaseSeeder, type BigIntFields, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type Constructor, type DataSourceInput, type DataSourceType, type DateColumnOptions, type DatetimeColumnOptions, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IncrementFields, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MixinColumns, MixinFactory, Model, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, Schema, SchemaBuilder, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, type TimestampFields, Transaction, type TransactionExecutionOptions, type TypedPropertyDecorator, type UlidFields, UlidMixin, type UniqueType, type UseCacheReturnType, type UseConnectionInput, type UuidFields, UuidMixin, WriteOperation, type WriteReturnType, belongsTo, bigIntMixin, column, createMixin, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, incrementMixin, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, timestampMixin, ulidMixin, unique, uuidMixin, view, withPerformance };
|
|
7985
|
+
export { type AbstractConstructor, type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyConstructor, type AsymmetricEncryptionOptions, type BaseModelMethodOptions, type BaseModelRelationType, BaseSeeder, type BigIntFields, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, type CheckType, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type Constructor, type CustomLogger, type DataSourceInput, type DataSourceType, type DateColumnOptions, type DatetimeColumnOptions, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IncrementFields, type IndexType, type LazyRelationType, type LoggerConfig, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MixinColumns, MixinFactory, Model, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, Schema, SchemaBuilder, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, type TimestampFields, Transaction, type TransactionExecutionOptions, type TypedPropertyDecorator, type UlidFields, UlidMixin, type UniqueType, type UseCacheReturnType, type UseConnectionInput, type UuidFields, UuidMixin, WriteOperation, type WriteReturnType, belongsTo, bigIntMixin, check, column, createMixin, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getChecks, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, incrementMixin, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, timestampMixin, ulidMixin, unique, uuidMixin, view, withPerformance };
|
package/lib/index.d.ts
CHANGED
|
@@ -34,6 +34,39 @@ declare abstract class Entity {
|
|
|
34
34
|
static databaseCaseConvention: CaseConvention;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
type CustomLogger = {
|
|
38
|
+
info(message: string): void;
|
|
39
|
+
error(message: string): void;
|
|
40
|
+
warn(message: string): void;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* @description Configuration for logging behavior
|
|
44
|
+
* @warning Logs are synchronous by default and add overhead — do not use in production unless you override with an async custom logger. Logs are mainly for debugging.
|
|
45
|
+
*/
|
|
46
|
+
type LoggerConfig = {
|
|
47
|
+
/**
|
|
48
|
+
* @description Minimum log level. Messages below this level are suppressed.
|
|
49
|
+
* @default "info"
|
|
50
|
+
*/
|
|
51
|
+
level?: "info" | "warn" | "error";
|
|
52
|
+
/**
|
|
53
|
+
* @description Whether to log SQL/Mongo queries.
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
logQueries?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* @description Custom logger instance. When provided, replaces the default console logger.
|
|
59
|
+
*/
|
|
60
|
+
customLogger?: CustomLogger;
|
|
61
|
+
};
|
|
62
|
+
declare class HysteriaLogger {
|
|
63
|
+
static loggerInstance: CustomLogger;
|
|
64
|
+
static setCustomLogger(customLogger: CustomLogger): void;
|
|
65
|
+
static info(message: string): void;
|
|
66
|
+
static error(message: string | Error): void;
|
|
67
|
+
static warn(message: string): void;
|
|
68
|
+
}
|
|
69
|
+
|
|
37
70
|
/**
|
|
38
71
|
* @description Creates a datasource for the selected database type with the provided credentials
|
|
39
72
|
*/
|
|
@@ -56,7 +89,7 @@ interface OracleDBDataSourceInput extends CommonDataSourceInput {
|
|
|
56
89
|
}
|
|
57
90
|
interface CommonDataSourceInput {
|
|
58
91
|
readonly type?: DataSourceType;
|
|
59
|
-
readonly logs?: boolean;
|
|
92
|
+
readonly logs?: boolean | LoggerConfig;
|
|
60
93
|
}
|
|
61
94
|
interface MongoDataSourceInput$1 extends CommonDataSourceInput {
|
|
62
95
|
readonly type: "mongo";
|
|
@@ -185,9 +218,9 @@ declare class MongoQueryBuilder<T extends Collection> {
|
|
|
185
218
|
protected mongoDataSource: MongoDataSource;
|
|
186
219
|
protected collection: Collection$1<T>;
|
|
187
220
|
protected model: typeof Collection;
|
|
188
|
-
protected logs: boolean;
|
|
221
|
+
protected logs: boolean | LoggerConfig;
|
|
189
222
|
protected session?: ReturnType<MongoDataSource["startSession"]>;
|
|
190
|
-
constructor(model: typeof Collection, mongoDataSource: MongoDataSource, _session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean);
|
|
223
|
+
constructor(model: typeof Collection, mongoDataSource: MongoDataSource, _session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean | LoggerConfig);
|
|
191
224
|
one(options?: OneOptions$1): Promise<T | null>;
|
|
192
225
|
oneOrFail(options?: OneOptions$1): Promise<T>;
|
|
193
226
|
many(options?: ManyOptions$1): Promise<T[]>;
|
|
@@ -475,7 +508,7 @@ declare abstract class DataSource {
|
|
|
475
508
|
password: string;
|
|
476
509
|
database: string;
|
|
477
510
|
url: string;
|
|
478
|
-
logs: boolean;
|
|
511
|
+
logs: boolean | LoggerConfig;
|
|
479
512
|
protected constructor(input?: DataSourceInput);
|
|
480
513
|
protected handleCockroachdbSource(input?: PostgresSqlDataSourceInput): void;
|
|
481
514
|
protected handlePostgresSource(input?: PostgresSqlDataSourceInput): void;
|
|
@@ -507,13 +540,13 @@ type MongoUnrestrictedFindManyOptions<T extends Collection> = UnrestrictedMongoF
|
|
|
507
540
|
offset?: number;
|
|
508
541
|
};
|
|
509
542
|
declare class CollectionManager<T extends Collection> {
|
|
510
|
-
protected logs: boolean;
|
|
543
|
+
protected logs: boolean | LoggerConfig;
|
|
511
544
|
protected collection: typeof Collection;
|
|
512
545
|
protected mongoClient: ReturnType<MongoDataSource["getCurrentConnection"]>;
|
|
513
546
|
protected mongoDataSource: MongoDataSource;
|
|
514
547
|
protected collectionInstance: MongoClientImport["Collection"]["prototype"];
|
|
515
548
|
protected session?: ReturnType<MongoDataSource["startSession"]>;
|
|
516
|
-
constructor(_collection: typeof Collection, mongoDataSource: MongoDataSource, session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean);
|
|
549
|
+
constructor(_collection: typeof Collection, mongoDataSource: MongoDataSource, session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean | LoggerConfig);
|
|
517
550
|
/**
|
|
518
551
|
* @description Finds all records that match the input
|
|
519
552
|
*/
|
|
@@ -555,10 +588,11 @@ declare class CollectionManager<T extends Collection> {
|
|
|
555
588
|
}
|
|
556
589
|
|
|
557
590
|
type MongoClientInstance = InstanceType<MongoClientImport["MongoClient"]>;
|
|
591
|
+
|
|
558
592
|
interface MongoDataSourceInput {
|
|
559
593
|
url?: string;
|
|
560
594
|
options?: MongoConnectionOptions;
|
|
561
|
-
logs?: boolean;
|
|
595
|
+
logs?: boolean | LoggerConfig;
|
|
562
596
|
}
|
|
563
597
|
declare class MongoDataSource extends DataSource {
|
|
564
598
|
url: string;
|
|
@@ -1389,9 +1423,11 @@ type SeederConfig = {
|
|
|
1389
1423
|
*/
|
|
1390
1424
|
type SqlDataSourceInputBase<T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}, D extends SqlDataSourceType = SqlDataSourceType> = {
|
|
1391
1425
|
/**
|
|
1392
|
-
* @description Whether to log the sql queries and other debug information
|
|
1426
|
+
* @description Whether to log the sql queries and other debug information. Can be a boolean or a LoggerConfig object for granular control.
|
|
1427
|
+
* @warning Logs are synchronous by default and add overhead — do not use in production unless you override with an async custom logger.
|
|
1428
|
+
* @default false
|
|
1393
1429
|
*/
|
|
1394
|
-
readonly logs?: boolean;
|
|
1430
|
+
readonly logs?: boolean | LoggerConfig;
|
|
1395
1431
|
/**
|
|
1396
1432
|
* @description The connection policies to use for the sql data source that are not configured in the driverOptions
|
|
1397
1433
|
*/
|
|
@@ -1481,7 +1517,7 @@ type UseConnectionInput<D extends SqlDataSourceType = SqlDataSourceType, T exten
|
|
|
1481
1517
|
* @description The type of the database to connect to
|
|
1482
1518
|
*/
|
|
1483
1519
|
readonly type: D;
|
|
1484
|
-
readonly logs?: boolean;
|
|
1520
|
+
readonly logs?: boolean | LoggerConfig;
|
|
1485
1521
|
readonly models?: T;
|
|
1486
1522
|
readonly driverOptions?: SqlDriverSpecificOptions<D>;
|
|
1487
1523
|
connectionPolicies?: ConnectionPolicies;
|
|
@@ -3301,6 +3337,10 @@ type UniqueType = {
|
|
|
3301
3337
|
columns: string[];
|
|
3302
3338
|
name: string;
|
|
3303
3339
|
};
|
|
3340
|
+
type CheckType = {
|
|
3341
|
+
expression: string;
|
|
3342
|
+
name: string;
|
|
3343
|
+
};
|
|
3304
3344
|
/**
|
|
3305
3345
|
* @description A property decorator that constrains the decorated property to type V.
|
|
3306
3346
|
* TypeScript infers K from the property name and T from the class, then checks
|
|
@@ -3317,7 +3357,7 @@ declare abstract class FooterQueryBuilder<T extends Model, S extends Record<stri
|
|
|
3317
3357
|
protected offsetNode: OffsetNode | null;
|
|
3318
3358
|
protected modelColumns: ColumnType[];
|
|
3319
3359
|
protected modelColumnsMap: Map<string, ColumnType>;
|
|
3320
|
-
protected logs: boolean;
|
|
3360
|
+
protected logs: boolean | LoggerConfig;
|
|
3321
3361
|
protected constructor(model: typeof Model, sqlDataSource: SqlDataSource);
|
|
3322
3362
|
/**
|
|
3323
3363
|
* @description Clears the group by query
|
|
@@ -3825,6 +3865,27 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
|
|
|
3825
3865
|
orWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
|
|
3826
3866
|
orWhere(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
|
|
3827
3867
|
orWhere(column: `${string}.${string}`, value: BaseValues): this;
|
|
3868
|
+
/**
|
|
3869
|
+
* @description Adds a WHERE condition comparing two columns.
|
|
3870
|
+
*/
|
|
3871
|
+
whereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
|
|
3872
|
+
whereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, referenceColumn: ModelKey<T>): this;
|
|
3873
|
+
whereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
|
|
3874
|
+
whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType, referenceColumn: `${string}.${string}`): this;
|
|
3875
|
+
/**
|
|
3876
|
+
* @description Adds an AND WHERE condition comparing two columns.
|
|
3877
|
+
*/
|
|
3878
|
+
andWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
|
|
3879
|
+
andWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, referenceColumn: ModelKey<T>): this;
|
|
3880
|
+
andWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
|
|
3881
|
+
andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType, referenceColumn: `${string}.${string}`): this;
|
|
3882
|
+
/**
|
|
3883
|
+
* @description Adds an OR WHERE condition comparing two columns.
|
|
3884
|
+
*/
|
|
3885
|
+
orWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
|
|
3886
|
+
orWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, referenceColumn: ModelKey<T>): this;
|
|
3887
|
+
orWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
|
|
3888
|
+
orWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType, referenceColumn: `${string}.${string}`): this;
|
|
3828
3889
|
/**
|
|
3829
3890
|
* @description Adds a negated WHERE condition to the query.
|
|
3830
3891
|
*/
|
|
@@ -4370,7 +4431,7 @@ type ComposeRawSelect<S extends Record<string, any>, Added extends Record<string
|
|
|
4370
4431
|
* @typeParam Columns - The columns being selected
|
|
4371
4432
|
*/
|
|
4372
4433
|
type ComposeBuildRawSelect<S extends Record<string, any>, Columns extends readonly Selectable[]> = (typeof RAW_SELECT_BRAND extends keyof S ? S : {}) & BuildRawSelectType<Columns>;
|
|
4373
|
-
type WhereOnlyQueryBuilder<T extends Model> = Pick<WhereQueryBuilder<T>, "where" | "andWhere" | "orWhere" | "whereNot" | "andWhereNot" | "orWhereNot" | "whereIn" | "andWhereIn" | "orWhereIn" | "whereNotIn" | "andWhereNotIn" | "orWhereNotIn" | "whereBetween" | "andWhereBetween" | "orWhereBetween" | "whereNotBetween" | "andWhereNotBetween" | "orWhereNotBetween" | "whereNull" | "andWhereNull" | "orWhereNull" | "whereNotNull" | "andWhereNotNull" | "orWhereNotNull" | "whereLike" | "andWhereLike" | "orWhereLike" | "whereILike" | "andWhereILike" | "orWhereILike" | "whereNotLike" | "andWhereNotLike" | "orWhereNotLike" | "whereNotILike" | "andWhereNotILike" | "orWhereNotILike" | "whereRegexp" | "andWhereRegexp" | "orWhereRegexp" | "whereNotRegexp" | "andWhereNotRegexp" | "orWhereNotRegexp" | "whereRaw" | "andWhereRaw" | "orWhereRaw" | "whereExists" | "orWhereExists" | "andWhereExists"> & Pick<JsonQueryBuilder<T>, "whereJson" | "andWhereJson" | "orWhereJson" | "whereJsonContains" | "andWhereJsonContains" | "orWhereJsonContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonRaw" | "andWhereJsonRaw" | "orWhereJsonRaw" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains">;
|
|
4434
|
+
type WhereOnlyQueryBuilder<T extends Model> = Pick<WhereQueryBuilder<T>, "where" | "andWhere" | "orWhere" | "whereNot" | "andWhereNot" | "orWhereNot" | "whereIn" | "andWhereIn" | "orWhereIn" | "whereNotIn" | "andWhereNotIn" | "orWhereNotIn" | "whereBetween" | "andWhereBetween" | "orWhereBetween" | "whereNotBetween" | "andWhereNotBetween" | "orWhereNotBetween" | "whereNull" | "andWhereNull" | "orWhereNull" | "whereNotNull" | "andWhereNotNull" | "orWhereNotNull" | "whereLike" | "andWhereLike" | "orWhereLike" | "whereILike" | "andWhereILike" | "orWhereILike" | "whereNotLike" | "andWhereNotLike" | "orWhereNotLike" | "whereNotILike" | "andWhereNotILike" | "orWhereNotILike" | "whereRegexp" | "andWhereRegexp" | "orWhereRegexp" | "whereNotRegexp" | "andWhereNotRegexp" | "orWhereNotRegexp" | "whereRaw" | "andWhereRaw" | "orWhereRaw" | "whereExists" | "orWhereExists" | "andWhereExists" | "whereNotExists" | "orWhereNotExists" | "andWhereNotExists" | "whereColumn" | "andWhereColumn" | "orWhereColumn"> & Pick<JsonQueryBuilder<T>, "whereJson" | "andWhereJson" | "orWhereJson" | "whereJsonContains" | "andWhereJsonContains" | "orWhereJsonContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonRaw" | "andWhereJsonRaw" | "orWhereJsonRaw" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains">;
|
|
4374
4435
|
type RelationRetrieveMethod<P extends any> = P extends any[] ? "many" : "one";
|
|
4375
4436
|
/**
|
|
4376
4437
|
* Validates a column string for raw query builder select().
|
|
@@ -4953,7 +5014,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
4953
5014
|
declare class ModelManager<T extends Model> {
|
|
4954
5015
|
protected sqlDataSource: SqlDataSource;
|
|
4955
5016
|
protected sqlType: SqlDataSourceType;
|
|
4956
|
-
protected logs: boolean;
|
|
5017
|
+
protected logs: boolean | LoggerConfig;
|
|
4957
5018
|
protected model: typeof Model;
|
|
4958
5019
|
protected modelInstance: T;
|
|
4959
5020
|
protected astParser: AstParser;
|
|
@@ -5050,11 +5111,16 @@ type TablePrimaryKeyInfo = {
|
|
|
5050
5111
|
name?: string;
|
|
5051
5112
|
columns: string[];
|
|
5052
5113
|
};
|
|
5114
|
+
type TableCheckConstraintInfo = {
|
|
5115
|
+
name: string;
|
|
5116
|
+
expression: string;
|
|
5117
|
+
};
|
|
5053
5118
|
type TableSchemaInfo = {
|
|
5054
5119
|
columns: TableColumnInfo[];
|
|
5055
5120
|
indexes: TableIndexInfo[];
|
|
5056
5121
|
foreignKeys: TableForeignKeyInfo[];
|
|
5057
5122
|
primaryKey?: TablePrimaryKeyInfo;
|
|
5123
|
+
checkConstraints: TableCheckConstraintInfo[];
|
|
5058
5124
|
};
|
|
5059
5125
|
type TableForeignKeyInfo = {
|
|
5060
5126
|
name?: string;
|
|
@@ -5554,6 +5620,10 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
5554
5620
|
* @description Introspects table primary key from the database
|
|
5555
5621
|
*/
|
|
5556
5622
|
getPrimaryKeyInfo(table: string): Promise<TablePrimaryKeyInfo | undefined>;
|
|
5623
|
+
/**
|
|
5624
|
+
* @description Introspects table CHECK constraints from the database
|
|
5625
|
+
*/
|
|
5626
|
+
getCheckConstraintInfo(table: string): Promise<TableCheckConstraintInfo[]>;
|
|
5557
5627
|
/**
|
|
5558
5628
|
* @description Acquires an advisory lock
|
|
5559
5629
|
* @description Useful for preventing concurrent operations from running simultaneously
|
|
@@ -6344,6 +6414,7 @@ declare abstract class Model<T extends Model<T> = any> extends Entity {
|
|
|
6344
6414
|
*/
|
|
6345
6415
|
static getIndexes(): IndexType[];
|
|
6346
6416
|
static getUniques(): UniqueType[];
|
|
6417
|
+
static getChecks(): CheckType[];
|
|
6347
6418
|
/**
|
|
6348
6419
|
* @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
|
|
6349
6420
|
* @javascript
|
|
@@ -6477,6 +6548,26 @@ type BaseModelRelationType = {
|
|
|
6477
6548
|
*/
|
|
6478
6549
|
declare function index(indexes: string | string[], indexName?: string): ClassDecorator;
|
|
6479
6550
|
declare function unique(columns: string | string[], constraintName?: string): ClassDecorator;
|
|
6551
|
+
/**
|
|
6552
|
+
* @description Decorator to define a CHECK constraint on the model's table
|
|
6553
|
+
* @param expression - The SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
|
|
6554
|
+
* @param constraintName - Optional custom name for the constraint
|
|
6555
|
+
* @example
|
|
6556
|
+
* ```ts
|
|
6557
|
+
* @check("age >= 0")
|
|
6558
|
+
* class User extends Model {
|
|
6559
|
+
* @column()
|
|
6560
|
+
* age!: number;
|
|
6561
|
+
* }
|
|
6562
|
+
*
|
|
6563
|
+
* @check("price > 0", "products_price_positive")
|
|
6564
|
+
* class Product extends Model {
|
|
6565
|
+
* @column()
|
|
6566
|
+
* price!: number;
|
|
6567
|
+
* }
|
|
6568
|
+
* ```
|
|
6569
|
+
*/
|
|
6570
|
+
declare function check(expression: string, constraintName?: string): ClassDecorator;
|
|
6480
6571
|
/**
|
|
6481
6572
|
* @description Decorator to define a view on the model
|
|
6482
6573
|
* @description This will automatically create a view on the database with the given statement
|
|
@@ -6728,6 +6819,7 @@ declare function getRelations(target: typeof Model): Relation[];
|
|
|
6728
6819
|
declare function getPrimaryKey(target: typeof Model): string | undefined;
|
|
6729
6820
|
declare function getIndexes(target: typeof Model): IndexType[];
|
|
6730
6821
|
declare function getUniques(target: typeof Model): UniqueType[];
|
|
6822
|
+
declare function getChecks(target: typeof Model): CheckType[];
|
|
6731
6823
|
|
|
6732
6824
|
type FactoryReturnType<T extends number, O extends Model> = T extends 1 ? O : O[];
|
|
6733
6825
|
|
|
@@ -7795,9 +7887,9 @@ declare class Schema {
|
|
|
7795
7887
|
}
|
|
7796
7888
|
|
|
7797
7889
|
declare abstract class Migration {
|
|
7798
|
-
dbType: SqlDataSourceType;
|
|
7799
|
-
migrationName: string;
|
|
7800
|
-
schema: Schema;
|
|
7890
|
+
readonly dbType: SqlDataSourceType;
|
|
7891
|
+
readonly migrationName: string;
|
|
7892
|
+
readonly schema: Schema;
|
|
7801
7893
|
constructor(dbType: SqlDataSourceType);
|
|
7802
7894
|
/**
|
|
7803
7895
|
* @description This method is called when the migration is to be run
|
|
@@ -7841,19 +7933,6 @@ declare class ClientMigrator {
|
|
|
7841
7933
|
*/
|
|
7842
7934
|
declare const defineMigrator: (migrationPath: string, sqlDataSourceInput?: SqlDataSource["inputDetails"] | SqlDataSource) => ClientMigrator;
|
|
7843
7935
|
|
|
7844
|
-
type CustomLogger = {
|
|
7845
|
-
info(message: string): void;
|
|
7846
|
-
error(message: string): void;
|
|
7847
|
-
warn(message: string): void;
|
|
7848
|
-
};
|
|
7849
|
-
declare class HysteriaLogger {
|
|
7850
|
-
static loggerInstance: CustomLogger;
|
|
7851
|
-
static setCustomLogger(customLogger: CustomLogger): void;
|
|
7852
|
-
static info(message: string): void;
|
|
7853
|
-
static error(message: string | Error): void;
|
|
7854
|
-
static warn(message: string): void;
|
|
7855
|
-
}
|
|
7856
|
-
|
|
7857
7936
|
/**
|
|
7858
7937
|
* @description Base class for all seeders
|
|
7859
7938
|
* @description Provides access to the SqlDataSource instance
|
|
@@ -7903,4 +7982,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
|
|
|
7903
7982
|
$id?: string;
|
|
7904
7983
|
}>;
|
|
7905
7984
|
|
|
7906
|
-
export { type AbstractConstructor, type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyConstructor, type AsymmetricEncryptionOptions, type BaseModelMethodOptions, type BaseModelRelationType, BaseSeeder, type BigIntFields, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type Constructor, type DataSourceInput, type DataSourceType, type DateColumnOptions, type DatetimeColumnOptions, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IncrementFields, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MixinColumns, MixinFactory, Model, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, Schema, SchemaBuilder, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, type TimestampFields, Transaction, type TransactionExecutionOptions, type TypedPropertyDecorator, type UlidFields, UlidMixin, type UniqueType, type UseCacheReturnType, type UseConnectionInput, type UuidFields, UuidMixin, WriteOperation, type WriteReturnType, belongsTo, bigIntMixin, column, createMixin, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, incrementMixin, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, timestampMixin, ulidMixin, unique, uuidMixin, view, withPerformance };
|
|
7985
|
+
export { type AbstractConstructor, type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyConstructor, type AsymmetricEncryptionOptions, type BaseModelMethodOptions, type BaseModelRelationType, BaseSeeder, type BigIntFields, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, type CheckType, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type Constructor, type CustomLogger, type DataSourceInput, type DataSourceType, type DateColumnOptions, type DatetimeColumnOptions, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IncrementFields, type IndexType, type LazyRelationType, type LoggerConfig, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MixinColumns, MixinFactory, Model, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, Schema, SchemaBuilder, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, type TimestampFields, Transaction, type TransactionExecutionOptions, type TypedPropertyDecorator, type UlidFields, UlidMixin, type UniqueType, type UseCacheReturnType, type UseConnectionInput, type UuidFields, UuidMixin, WriteOperation, type WriteReturnType, belongsTo, bigIntMixin, check, column, createMixin, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getChecks, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, incrementMixin, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, timestampMixin, ulidMixin, unique, uuidMixin, view, withPerformance };
|