hysteria-orm 10.2.0 → 10.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.cts CHANGED
@@ -2,9 +2,9 @@ import * as mongodb from 'mongodb';
2
2
  import { Collection as Collection$1 } from 'mongodb';
3
3
  import * as sqlite3 from 'sqlite3';
4
4
  import * as pg from 'pg';
5
- import { PoolClient } from 'pg';
5
+ import { ClientConfig, PoolClient } from 'pg';
6
6
  import * as mysql2_promise from 'mysql2/promise';
7
- import { PoolConnection } from 'mysql2/promise';
7
+ import { PoolOptions, PoolConnection } from 'mysql2/promise';
8
8
  import { RedisOptions, Redis } from 'ioredis';
9
9
  import { PassThrough } from 'node:stream';
10
10
  import { FormatOptionsWithLanguage } from 'sql-formatter';
@@ -49,7 +49,6 @@ interface PostgresSqlDataSourceInput extends CommonDataSourceInput {
49
49
  readonly username?: string;
50
50
  readonly password?: string;
51
51
  readonly database?: string;
52
- readonly driverOptions?: PgClientOptions;
53
52
  }
54
53
  interface NotNullablePostgresSqlDataSourceInput extends PostgresSqlDataSourceInput {
55
54
  readonly type?: "postgres" | "cockroachdb";
@@ -58,7 +57,6 @@ interface NotNullablePostgresSqlDataSourceInput extends PostgresSqlDataSourceInp
58
57
  readonly password: string;
59
58
  readonly database: string;
60
59
  readonly port?: number;
61
- readonly driverOptions?: PgClientOptions;
62
60
  }
63
61
  interface MysqlSqlDataSourceInput extends CommonDataSourceInput {
64
62
  readonly type?: "mysql" | "mariadb";
@@ -67,7 +65,6 @@ interface MysqlSqlDataSourceInput extends CommonDataSourceInput {
67
65
  readonly username?: string;
68
66
  readonly password?: string;
69
67
  readonly database?: string;
70
- readonly driverOptions?: MysqlCreateConnectionOptions;
71
68
  }
72
69
  interface NotNullableMysqlSqlDataSourceInput extends MysqlSqlDataSourceInput {
73
70
  readonly type?: "mysql" | "mariadb";
@@ -76,7 +73,6 @@ interface NotNullableMysqlSqlDataSourceInput extends MysqlSqlDataSourceInput {
76
73
  readonly password: string;
77
74
  readonly database: string;
78
75
  readonly port?: number;
79
- readonly driverOptions?: MysqlCreateConnectionOptions;
80
76
  }
81
77
  interface SqliteDataSourceInput extends CommonDataSourceInput {
82
78
  readonly type?: "sqlite";
@@ -95,11 +91,10 @@ type Mysql2Import = typeof mysql2_promise;
95
91
  type PgImport = typeof pg;
96
92
  type Sqlite3Import = typeof sqlite3;
97
93
  type MongoClientImport = typeof mongodb;
98
- type ExcludeStringFromOptions<T> = T extends string ? never : T;
99
- type MysqlCreateConnectionOptions = Parameters<Mysql2Import["createPool"]>[0];
100
- type PgClientOptions = ExcludeStringFromOptions<ConstructorParameters<PgImport["Pool"]>[0]>;
94
+ type MysqlCreateConnectionOptions = PoolOptions;
95
+ type PgClientOptions = ClientConfig;
101
96
  type MongoConnectionOptions = NonNullable<ConstructorParameters<MongoClientImport["MongoClient"]>[1]>;
102
- type DriverSpecificOptions<T extends DataSourceType> = T extends "mongo" ? MongoConnectionOptions : T extends "cockroachdb" ? PgClientOptions : T extends "redis" ? RedisOptions : T extends "postgres" ? PgClientOptions : T extends "mongo" ? MongoConnectionOptions : T extends "mariadb" ? MysqlCreateConnectionOptions : T extends "mysql" ? MysqlCreateConnectionOptions : never;
97
+ type DriverSpecificOptions<T extends DataSourceType> = T extends "mongo" ? MongoConnectionOptions : T extends "cockroachdb" | "postgres" ? PgClientOptions : T extends "redis" ? RedisOptions : T extends "mysql" | "mariadb" ? MysqlCreateConnectionOptions : never;
103
98
 
104
99
  type MongoCollectionKey<T> = T extends Collection ? T : never;
105
100
  type BaseModelMethodOptions$1 = {
@@ -3399,6 +3394,9 @@ declare class SqlDataSource extends DataSource {
3399
3394
  get registeredModels(): Record<string, typeof Model>;
3400
3395
  }
3401
3396
 
3397
+ type Sqlite3ConnectionOptions = {
3398
+ mode: number;
3399
+ };
3402
3400
  type SqlDriverSpecificOptions<T extends DataSourceType> = Omit<DriverSpecificOptions<T>, "mongoOptions" | "redisOptions">;
3403
3401
  type MysqlConnectionInstance = Awaited<ReturnType<Mysql2Import["createPool"]>>;
3404
3402
  type PgPoolClientInstance = InstanceType<PgImport["Pool"]>;
@@ -3423,7 +3421,7 @@ type SqlDataSourceModel = typeof Model;
3423
3421
  * @description The connectionPolicies object is used to configure the connection policies for the sql data source
3424
3422
  */
3425
3423
  type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}> = {
3426
- readonly type?: Exclude<DataSourceType, "mongo">;
3424
+ readonly type?: D;
3427
3425
  /**
3428
3426
  * @description Whether to log the sql queries and other debug information
3429
3427
  */
@@ -3445,6 +3443,9 @@ type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, Sq
3445
3443
  * @description The driver specific options to use for the sql data source, it's used to configure the driver specific options for the sql data source
3446
3444
  */
3447
3445
  driverOptions?: SqlDriverSpecificOptions<D>;
3446
+ /**
3447
+ * @description The cache strategy to use for the sql data source, it's used to configure the cache strategy for the sql data source
3448
+ */
3448
3449
  cacheStrategy?: {
3449
3450
  cacheAdapter?: CacheAdapter;
3450
3451
  keys: C;
@@ -5388,4 +5389,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
5388
5389
  $id?: string;
5389
5390
  }>;
5390
5391
 
5391
- export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, 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 CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseCacheReturnType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
5392
+ export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, 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 CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseCacheReturnType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
package/lib/index.d.ts CHANGED
@@ -2,9 +2,9 @@ import * as mongodb from 'mongodb';
2
2
  import { Collection as Collection$1 } from 'mongodb';
3
3
  import * as sqlite3 from 'sqlite3';
4
4
  import * as pg from 'pg';
5
- import { PoolClient } from 'pg';
5
+ import { ClientConfig, PoolClient } from 'pg';
6
6
  import * as mysql2_promise from 'mysql2/promise';
7
- import { PoolConnection } from 'mysql2/promise';
7
+ import { PoolOptions, PoolConnection } from 'mysql2/promise';
8
8
  import { RedisOptions, Redis } from 'ioredis';
9
9
  import { PassThrough } from 'node:stream';
10
10
  import { FormatOptionsWithLanguage } from 'sql-formatter';
@@ -49,7 +49,6 @@ interface PostgresSqlDataSourceInput extends CommonDataSourceInput {
49
49
  readonly username?: string;
50
50
  readonly password?: string;
51
51
  readonly database?: string;
52
- readonly driverOptions?: PgClientOptions;
53
52
  }
54
53
  interface NotNullablePostgresSqlDataSourceInput extends PostgresSqlDataSourceInput {
55
54
  readonly type?: "postgres" | "cockroachdb";
@@ -58,7 +57,6 @@ interface NotNullablePostgresSqlDataSourceInput extends PostgresSqlDataSourceInp
58
57
  readonly password: string;
59
58
  readonly database: string;
60
59
  readonly port?: number;
61
- readonly driverOptions?: PgClientOptions;
62
60
  }
63
61
  interface MysqlSqlDataSourceInput extends CommonDataSourceInput {
64
62
  readonly type?: "mysql" | "mariadb";
@@ -67,7 +65,6 @@ interface MysqlSqlDataSourceInput extends CommonDataSourceInput {
67
65
  readonly username?: string;
68
66
  readonly password?: string;
69
67
  readonly database?: string;
70
- readonly driverOptions?: MysqlCreateConnectionOptions;
71
68
  }
72
69
  interface NotNullableMysqlSqlDataSourceInput extends MysqlSqlDataSourceInput {
73
70
  readonly type?: "mysql" | "mariadb";
@@ -76,7 +73,6 @@ interface NotNullableMysqlSqlDataSourceInput extends MysqlSqlDataSourceInput {
76
73
  readonly password: string;
77
74
  readonly database: string;
78
75
  readonly port?: number;
79
- readonly driverOptions?: MysqlCreateConnectionOptions;
80
76
  }
81
77
  interface SqliteDataSourceInput extends CommonDataSourceInput {
82
78
  readonly type?: "sqlite";
@@ -95,11 +91,10 @@ type Mysql2Import = typeof mysql2_promise;
95
91
  type PgImport = typeof pg;
96
92
  type Sqlite3Import = typeof sqlite3;
97
93
  type MongoClientImport = typeof mongodb;
98
- type ExcludeStringFromOptions<T> = T extends string ? never : T;
99
- type MysqlCreateConnectionOptions = Parameters<Mysql2Import["createPool"]>[0];
100
- type PgClientOptions = ExcludeStringFromOptions<ConstructorParameters<PgImport["Pool"]>[0]>;
94
+ type MysqlCreateConnectionOptions = PoolOptions;
95
+ type PgClientOptions = ClientConfig;
101
96
  type MongoConnectionOptions = NonNullable<ConstructorParameters<MongoClientImport["MongoClient"]>[1]>;
102
- type DriverSpecificOptions<T extends DataSourceType> = T extends "mongo" ? MongoConnectionOptions : T extends "cockroachdb" ? PgClientOptions : T extends "redis" ? RedisOptions : T extends "postgres" ? PgClientOptions : T extends "mongo" ? MongoConnectionOptions : T extends "mariadb" ? MysqlCreateConnectionOptions : T extends "mysql" ? MysqlCreateConnectionOptions : never;
97
+ type DriverSpecificOptions<T extends DataSourceType> = T extends "mongo" ? MongoConnectionOptions : T extends "cockroachdb" | "postgres" ? PgClientOptions : T extends "redis" ? RedisOptions : T extends "mysql" | "mariadb" ? MysqlCreateConnectionOptions : never;
103
98
 
104
99
  type MongoCollectionKey<T> = T extends Collection ? T : never;
105
100
  type BaseModelMethodOptions$1 = {
@@ -3399,6 +3394,9 @@ declare class SqlDataSource extends DataSource {
3399
3394
  get registeredModels(): Record<string, typeof Model>;
3400
3395
  }
3401
3396
 
3397
+ type Sqlite3ConnectionOptions = {
3398
+ mode: number;
3399
+ };
3402
3400
  type SqlDriverSpecificOptions<T extends DataSourceType> = Omit<DriverSpecificOptions<T>, "mongoOptions" | "redisOptions">;
3403
3401
  type MysqlConnectionInstance = Awaited<ReturnType<Mysql2Import["createPool"]>>;
3404
3402
  type PgPoolClientInstance = InstanceType<PgImport["Pool"]>;
@@ -3423,7 +3421,7 @@ type SqlDataSourceModel = typeof Model;
3423
3421
  * @description The connectionPolicies object is used to configure the connection policies for the sql data source
3424
3422
  */
3425
3423
  type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}> = {
3426
- readonly type?: Exclude<DataSourceType, "mongo">;
3424
+ readonly type?: D;
3427
3425
  /**
3428
3426
  * @description Whether to log the sql queries and other debug information
3429
3427
  */
@@ -3445,6 +3443,9 @@ type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, Sq
3445
3443
  * @description The driver specific options to use for the sql data source, it's used to configure the driver specific options for the sql data source
3446
3444
  */
3447
3445
  driverOptions?: SqlDriverSpecificOptions<D>;
3446
+ /**
3447
+ * @description The cache strategy to use for the sql data source, it's used to configure the cache strategy for the sql data source
3448
+ */
3448
3449
  cacheStrategy?: {
3449
3450
  cacheAdapter?: CacheAdapter;
3450
3451
  keys: C;
@@ -5388,4 +5389,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
5388
5389
  $id?: string;
5389
5390
  }>;
5390
5391
 
5391
- export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, 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 CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseCacheReturnType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
5392
+ export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, 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 CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseCacheReturnType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };