hysteria-orm 10.5.2 → 10.5.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 +15 -15
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +11 -11
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +85 -18
- package/lib/index.d.ts +85 -18
- package/lib/index.js +11 -11
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -5491,7 +5491,7 @@ type ModelInstanceMethods<T extends Model> = {
|
|
|
5491
5491
|
* Refreshes the model from the database, updating all properties with current values.
|
|
5492
5492
|
* @throws {HysteriaError} If the model has no primary key or primary key value
|
|
5493
5493
|
*/
|
|
5494
|
-
refresh: (options?: Omit<BaseModelMethodOptions, "ignoreHooks">) => Promise<
|
|
5494
|
+
refresh: (options?: Omit<BaseModelMethodOptions, "ignoreHooks">) => Promise<void>;
|
|
5495
5495
|
};
|
|
5496
5496
|
/**
|
|
5497
5497
|
* Model data without relation properties.
|
|
@@ -5946,7 +5946,7 @@ type FindReturnType<T extends Model, S extends ModelKey<T>[] = any[], R extends
|
|
|
5946
5946
|
/**
|
|
5947
5947
|
* @description Represents a Table in the Database
|
|
5948
5948
|
*/
|
|
5949
|
-
declare abstract class Model extends Entity {
|
|
5949
|
+
declare abstract class Model<T extends Model<T> = any> extends Entity {
|
|
5950
5950
|
private "*";
|
|
5951
5951
|
/**
|
|
5952
5952
|
* @description The column used to soft delete a record, default is deletedAt
|
|
@@ -5973,7 +5973,26 @@ declare abstract class Model extends Entity {
|
|
|
5973
5973
|
* @description Getter for the primary key of the model
|
|
5974
5974
|
*/
|
|
5975
5975
|
static get primaryKey(): string | undefined;
|
|
5976
|
-
|
|
5976
|
+
/**
|
|
5977
|
+
* @description Creates a new instance of the model
|
|
5978
|
+
* @description Use `${Model.from(...)}` to pass initial data to the model or pass initial data to the constructor
|
|
5979
|
+
* @warning For typescript limitations, in order to pass initial data to the constructor directly, you must use generic type inference to pass the model type
|
|
5980
|
+
* @example
|
|
5981
|
+
* ```typescript
|
|
5982
|
+
* class User extends Model<User> {
|
|
5983
|
+
* @column.string()
|
|
5984
|
+
* declare name: string;
|
|
5985
|
+
* }
|
|
5986
|
+
*
|
|
5987
|
+
* const user = new User({ name: "John Doe" }); // now the constructor is typed as User
|
|
5988
|
+
* ```
|
|
5989
|
+
*/
|
|
5990
|
+
constructor(initialData?: Partial<ModelWithoutRelations<T>>);
|
|
5991
|
+
/**
|
|
5992
|
+
* @description Returns a model query result from the given initial data
|
|
5993
|
+
* @warning This method does not persist the data to the database, it only creates a new instance of the model with the given data
|
|
5994
|
+
*/
|
|
5995
|
+
static from<T extends Model>(this: new () => T | typeof Model, data: Partial<ModelWithoutRelations<T>>): ModelQueryResult<T>;
|
|
5977
5996
|
/**
|
|
5978
5997
|
* @description Returns all the records for the given model
|
|
5979
5998
|
*/
|
|
@@ -6021,7 +6040,7 @@ declare abstract class Model extends Entity {
|
|
|
6021
6040
|
/**
|
|
6022
6041
|
* @description Refreshes a model from the database, the model must have a primary key defined
|
|
6023
6042
|
*/
|
|
6024
|
-
static refresh<T extends Model>(this: new () => T | typeof Model, model: T, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<
|
|
6043
|
+
static refresh<T extends Model>(this: new () => T | typeof Model, model: T, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<void>;
|
|
6025
6044
|
/**
|
|
6026
6045
|
* @description Saves a new record to the database
|
|
6027
6046
|
* @warning If not using postgres and the model has no primary key, the model will be saved, but it won't be possible to retrieve it so at that point it will be returned as null, this is not typed as Model | null for type safety reasons
|
|
@@ -6361,23 +6380,30 @@ declare function view(statement: (query: ModelQueryBuilder<any>) => void): Class
|
|
|
6361
6380
|
*/
|
|
6362
6381
|
declare function column(options?: ColumnOptions): PropertyDecorator;
|
|
6363
6382
|
declare namespace column {
|
|
6364
|
-
var primary: typeof primaryKeyColumn;
|
|
6365
|
-
var date: typeof dateOnlyColumn;
|
|
6366
|
-
var datetime: typeof datetimeColumn;
|
|
6367
|
-
var timestamp: typeof timestampColumn;
|
|
6368
|
-
var time: typeof timeOnlyColumn;
|
|
6369
|
-
var boolean: typeof booleanColumn;
|
|
6370
|
-
var json: typeof jsonColumn;
|
|
6371
|
-
var uuid: typeof uuidColumn;
|
|
6372
|
-
var ulid: typeof ulidColumn;
|
|
6373
|
-
var integer: typeof integerColumn;
|
|
6374
|
-
var
|
|
6375
|
-
var
|
|
6376
|
-
var
|
|
6377
|
-
var
|
|
6383
|
+
export var primary: typeof primaryKeyColumn;
|
|
6384
|
+
export var date: typeof dateOnlyColumn;
|
|
6385
|
+
export var datetime: typeof datetimeColumn;
|
|
6386
|
+
export var timestamp: typeof timestampColumn;
|
|
6387
|
+
export var time: typeof timeOnlyColumn;
|
|
6388
|
+
export var boolean: typeof booleanColumn;
|
|
6389
|
+
export var json: typeof jsonColumn;
|
|
6390
|
+
export var uuid: typeof uuidColumn;
|
|
6391
|
+
export var ulid: typeof ulidColumn;
|
|
6392
|
+
export var integer: typeof integerColumn;
|
|
6393
|
+
export var bigint: typeof bigintColumn;
|
|
6394
|
+
export var float: typeof floatColumn;
|
|
6395
|
+
export var decimal: typeof decimalColumn;
|
|
6396
|
+
export var increment: typeof incrementColumn;
|
|
6397
|
+
export var bigIncrement: typeof bigIncrementColumn;
|
|
6398
|
+
export var string: typeof stringColumn;
|
|
6399
|
+
export var text: typeof textColumn;
|
|
6400
|
+
export var binary: typeof binaryColumn;
|
|
6401
|
+
var _a: typeof enumColumn;
|
|
6402
|
+
export var encryption: {
|
|
6378
6403
|
symmetric: typeof symmetric;
|
|
6379
6404
|
asymmetric: typeof asymmetric;
|
|
6380
6405
|
};
|
|
6406
|
+
export { _a as enum };
|
|
6381
6407
|
}
|
|
6382
6408
|
declare function primaryKeyColumn(options?: Omit<ColumnOptions, "primaryKey">): PropertyDecorator;
|
|
6383
6409
|
declare function floatColumn(options?: Omit<ColumnOptions, "serialize">): PropertyDecorator;
|
|
@@ -6415,6 +6441,47 @@ declare function uuidColumn(options?: Omit<ColumnOptions, "prepare">): PropertyD
|
|
|
6415
6441
|
* @description Defaults type to ulid for migration generation
|
|
6416
6442
|
*/
|
|
6417
6443
|
declare function ulidColumn(options?: Omit<ColumnOptions, "prepare">): PropertyDecorator;
|
|
6444
|
+
/**
|
|
6445
|
+
* @description Decorator to define a string (varchar) column in the model
|
|
6446
|
+
* @description Defaults type to string for migration generation
|
|
6447
|
+
*/
|
|
6448
|
+
declare function stringColumn(options?: Omit<ColumnOptions, "type"> & {
|
|
6449
|
+
length?: number;
|
|
6450
|
+
}): PropertyDecorator;
|
|
6451
|
+
/**
|
|
6452
|
+
* @description Decorator to define a text column in the model for longer text content
|
|
6453
|
+
* @description Defaults type to longtext for migration generation
|
|
6454
|
+
*/
|
|
6455
|
+
declare function textColumn(options?: Omit<ColumnOptions, "type">): PropertyDecorator;
|
|
6456
|
+
/**
|
|
6457
|
+
* @description Decorator to define a bigint column in the model
|
|
6458
|
+
* @description Useful in databases like postgres where the bigint is returned as a string by the driver
|
|
6459
|
+
* @description Defaults type to bigint for migration generation
|
|
6460
|
+
*/
|
|
6461
|
+
declare function bigintColumn(options?: Omit<ColumnOptions, "serialize">): PropertyDecorator;
|
|
6462
|
+
/**
|
|
6463
|
+
* @description Decorator to define a decimal column in the model for precise numeric values
|
|
6464
|
+
* @description Useful for financial data and other precise calculations
|
|
6465
|
+
* @description Defaults type to decimal for migration generation
|
|
6466
|
+
* @param options.precision The total number of digits (default: 10)
|
|
6467
|
+
* @param options.scale The number of digits after the decimal point (default: 2)
|
|
6468
|
+
*/
|
|
6469
|
+
declare function decimalColumn(options?: Omit<ColumnOptions, "serialize"> & {
|
|
6470
|
+
precision?: number;
|
|
6471
|
+
scale?: number;
|
|
6472
|
+
}): PropertyDecorator;
|
|
6473
|
+
/**
|
|
6474
|
+
* @description Decorator to define a binary/blob column in the model
|
|
6475
|
+
* @description Defaults type to binary for migration generation
|
|
6476
|
+
*/
|
|
6477
|
+
declare function binaryColumn(options?: Omit<ColumnOptions, "type">): PropertyDecorator;
|
|
6478
|
+
/**
|
|
6479
|
+
* @description Decorator to define an enum column in the model
|
|
6480
|
+
* @description Defaults type to enum for migration generation
|
|
6481
|
+
* @param values The allowed enum values
|
|
6482
|
+
* @param options Additional column options
|
|
6483
|
+
*/
|
|
6484
|
+
declare function enumColumn(values: readonly string[], options?: Omit<ColumnOptions, "type">): PropertyDecorator;
|
|
6418
6485
|
/**
|
|
6419
6486
|
* @description Decorator to define a symmetric encrypted column in the model with a key
|
|
6420
6487
|
* @description This will automatically encrypt the value before it is inserted or updated in the database and decrypt it when it is retrieved from the database
|
package/lib/index.d.ts
CHANGED
|
@@ -5491,7 +5491,7 @@ type ModelInstanceMethods<T extends Model> = {
|
|
|
5491
5491
|
* Refreshes the model from the database, updating all properties with current values.
|
|
5492
5492
|
* @throws {HysteriaError} If the model has no primary key or primary key value
|
|
5493
5493
|
*/
|
|
5494
|
-
refresh: (options?: Omit<BaseModelMethodOptions, "ignoreHooks">) => Promise<
|
|
5494
|
+
refresh: (options?: Omit<BaseModelMethodOptions, "ignoreHooks">) => Promise<void>;
|
|
5495
5495
|
};
|
|
5496
5496
|
/**
|
|
5497
5497
|
* Model data without relation properties.
|
|
@@ -5946,7 +5946,7 @@ type FindReturnType<T extends Model, S extends ModelKey<T>[] = any[], R extends
|
|
|
5946
5946
|
/**
|
|
5947
5947
|
* @description Represents a Table in the Database
|
|
5948
5948
|
*/
|
|
5949
|
-
declare abstract class Model extends Entity {
|
|
5949
|
+
declare abstract class Model<T extends Model<T> = any> extends Entity {
|
|
5950
5950
|
private "*";
|
|
5951
5951
|
/**
|
|
5952
5952
|
* @description The column used to soft delete a record, default is deletedAt
|
|
@@ -5973,7 +5973,26 @@ declare abstract class Model extends Entity {
|
|
|
5973
5973
|
* @description Getter for the primary key of the model
|
|
5974
5974
|
*/
|
|
5975
5975
|
static get primaryKey(): string | undefined;
|
|
5976
|
-
|
|
5976
|
+
/**
|
|
5977
|
+
* @description Creates a new instance of the model
|
|
5978
|
+
* @description Use `${Model.from(...)}` to pass initial data to the model or pass initial data to the constructor
|
|
5979
|
+
* @warning For typescript limitations, in order to pass initial data to the constructor directly, you must use generic type inference to pass the model type
|
|
5980
|
+
* @example
|
|
5981
|
+
* ```typescript
|
|
5982
|
+
* class User extends Model<User> {
|
|
5983
|
+
* @column.string()
|
|
5984
|
+
* declare name: string;
|
|
5985
|
+
* }
|
|
5986
|
+
*
|
|
5987
|
+
* const user = new User({ name: "John Doe" }); // now the constructor is typed as User
|
|
5988
|
+
* ```
|
|
5989
|
+
*/
|
|
5990
|
+
constructor(initialData?: Partial<ModelWithoutRelations<T>>);
|
|
5991
|
+
/**
|
|
5992
|
+
* @description Returns a model query result from the given initial data
|
|
5993
|
+
* @warning This method does not persist the data to the database, it only creates a new instance of the model with the given data
|
|
5994
|
+
*/
|
|
5995
|
+
static from<T extends Model>(this: new () => T | typeof Model, data: Partial<ModelWithoutRelations<T>>): ModelQueryResult<T>;
|
|
5977
5996
|
/**
|
|
5978
5997
|
* @description Returns all the records for the given model
|
|
5979
5998
|
*/
|
|
@@ -6021,7 +6040,7 @@ declare abstract class Model extends Entity {
|
|
|
6021
6040
|
/**
|
|
6022
6041
|
* @description Refreshes a model from the database, the model must have a primary key defined
|
|
6023
6042
|
*/
|
|
6024
|
-
static refresh<T extends Model>(this: new () => T | typeof Model, model: T, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<
|
|
6043
|
+
static refresh<T extends Model>(this: new () => T | typeof Model, model: T, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): Promise<void>;
|
|
6025
6044
|
/**
|
|
6026
6045
|
* @description Saves a new record to the database
|
|
6027
6046
|
* @warning If not using postgres and the model has no primary key, the model will be saved, but it won't be possible to retrieve it so at that point it will be returned as null, this is not typed as Model | null for type safety reasons
|
|
@@ -6361,23 +6380,30 @@ declare function view(statement: (query: ModelQueryBuilder<any>) => void): Class
|
|
|
6361
6380
|
*/
|
|
6362
6381
|
declare function column(options?: ColumnOptions): PropertyDecorator;
|
|
6363
6382
|
declare namespace column {
|
|
6364
|
-
var primary: typeof primaryKeyColumn;
|
|
6365
|
-
var date: typeof dateOnlyColumn;
|
|
6366
|
-
var datetime: typeof datetimeColumn;
|
|
6367
|
-
var timestamp: typeof timestampColumn;
|
|
6368
|
-
var time: typeof timeOnlyColumn;
|
|
6369
|
-
var boolean: typeof booleanColumn;
|
|
6370
|
-
var json: typeof jsonColumn;
|
|
6371
|
-
var uuid: typeof uuidColumn;
|
|
6372
|
-
var ulid: typeof ulidColumn;
|
|
6373
|
-
var integer: typeof integerColumn;
|
|
6374
|
-
var
|
|
6375
|
-
var
|
|
6376
|
-
var
|
|
6377
|
-
var
|
|
6383
|
+
export var primary: typeof primaryKeyColumn;
|
|
6384
|
+
export var date: typeof dateOnlyColumn;
|
|
6385
|
+
export var datetime: typeof datetimeColumn;
|
|
6386
|
+
export var timestamp: typeof timestampColumn;
|
|
6387
|
+
export var time: typeof timeOnlyColumn;
|
|
6388
|
+
export var boolean: typeof booleanColumn;
|
|
6389
|
+
export var json: typeof jsonColumn;
|
|
6390
|
+
export var uuid: typeof uuidColumn;
|
|
6391
|
+
export var ulid: typeof ulidColumn;
|
|
6392
|
+
export var integer: typeof integerColumn;
|
|
6393
|
+
export var bigint: typeof bigintColumn;
|
|
6394
|
+
export var float: typeof floatColumn;
|
|
6395
|
+
export var decimal: typeof decimalColumn;
|
|
6396
|
+
export var increment: typeof incrementColumn;
|
|
6397
|
+
export var bigIncrement: typeof bigIncrementColumn;
|
|
6398
|
+
export var string: typeof stringColumn;
|
|
6399
|
+
export var text: typeof textColumn;
|
|
6400
|
+
export var binary: typeof binaryColumn;
|
|
6401
|
+
var _a: typeof enumColumn;
|
|
6402
|
+
export var encryption: {
|
|
6378
6403
|
symmetric: typeof symmetric;
|
|
6379
6404
|
asymmetric: typeof asymmetric;
|
|
6380
6405
|
};
|
|
6406
|
+
export { _a as enum };
|
|
6381
6407
|
}
|
|
6382
6408
|
declare function primaryKeyColumn(options?: Omit<ColumnOptions, "primaryKey">): PropertyDecorator;
|
|
6383
6409
|
declare function floatColumn(options?: Omit<ColumnOptions, "serialize">): PropertyDecorator;
|
|
@@ -6415,6 +6441,47 @@ declare function uuidColumn(options?: Omit<ColumnOptions, "prepare">): PropertyD
|
|
|
6415
6441
|
* @description Defaults type to ulid for migration generation
|
|
6416
6442
|
*/
|
|
6417
6443
|
declare function ulidColumn(options?: Omit<ColumnOptions, "prepare">): PropertyDecorator;
|
|
6444
|
+
/**
|
|
6445
|
+
* @description Decorator to define a string (varchar) column in the model
|
|
6446
|
+
* @description Defaults type to string for migration generation
|
|
6447
|
+
*/
|
|
6448
|
+
declare function stringColumn(options?: Omit<ColumnOptions, "type"> & {
|
|
6449
|
+
length?: number;
|
|
6450
|
+
}): PropertyDecorator;
|
|
6451
|
+
/**
|
|
6452
|
+
* @description Decorator to define a text column in the model for longer text content
|
|
6453
|
+
* @description Defaults type to longtext for migration generation
|
|
6454
|
+
*/
|
|
6455
|
+
declare function textColumn(options?: Omit<ColumnOptions, "type">): PropertyDecorator;
|
|
6456
|
+
/**
|
|
6457
|
+
* @description Decorator to define a bigint column in the model
|
|
6458
|
+
* @description Useful in databases like postgres where the bigint is returned as a string by the driver
|
|
6459
|
+
* @description Defaults type to bigint for migration generation
|
|
6460
|
+
*/
|
|
6461
|
+
declare function bigintColumn(options?: Omit<ColumnOptions, "serialize">): PropertyDecorator;
|
|
6462
|
+
/**
|
|
6463
|
+
* @description Decorator to define a decimal column in the model for precise numeric values
|
|
6464
|
+
* @description Useful for financial data and other precise calculations
|
|
6465
|
+
* @description Defaults type to decimal for migration generation
|
|
6466
|
+
* @param options.precision The total number of digits (default: 10)
|
|
6467
|
+
* @param options.scale The number of digits after the decimal point (default: 2)
|
|
6468
|
+
*/
|
|
6469
|
+
declare function decimalColumn(options?: Omit<ColumnOptions, "serialize"> & {
|
|
6470
|
+
precision?: number;
|
|
6471
|
+
scale?: number;
|
|
6472
|
+
}): PropertyDecorator;
|
|
6473
|
+
/**
|
|
6474
|
+
* @description Decorator to define a binary/blob column in the model
|
|
6475
|
+
* @description Defaults type to binary for migration generation
|
|
6476
|
+
*/
|
|
6477
|
+
declare function binaryColumn(options?: Omit<ColumnOptions, "type">): PropertyDecorator;
|
|
6478
|
+
/**
|
|
6479
|
+
* @description Decorator to define an enum column in the model
|
|
6480
|
+
* @description Defaults type to enum for migration generation
|
|
6481
|
+
* @param values The allowed enum values
|
|
6482
|
+
* @param options Additional column options
|
|
6483
|
+
*/
|
|
6484
|
+
declare function enumColumn(values: readonly string[], options?: Omit<ColumnOptions, "type">): PropertyDecorator;
|
|
6418
6485
|
/**
|
|
6419
6486
|
* @description Decorator to define a symmetric encrypted column in the model with a key
|
|
6420
6487
|
* @description This will automatically encrypt the value before it is inserted or updated in the database and decrypt it when it is retrieved from the database
|