hysteria-orm 11.0.0 → 11.0.2
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 +69 -40
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +58 -32
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +905 -1080
- package/lib/index.d.ts +905 -1080
- package/lib/index.js +58 -32
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PassThrough } from 'node:stream';
|
|
1
2
|
import * as mssql from 'mssql';
|
|
2
3
|
import { config, Transaction as Transaction$1, IResult } from 'mssql';
|
|
3
4
|
import * as mysql2_promise from 'mysql2/promise';
|
|
@@ -12,9 +13,8 @@ import { Collection as Collection$1 } from 'mongodb';
|
|
|
12
13
|
import * as sqlite3 from 'sqlite3';
|
|
13
14
|
import { RunResult } from 'sqlite3';
|
|
14
15
|
import { RedisOptions, Redis } from 'ioredis';
|
|
15
|
-
import { PassThrough } from 'node:stream';
|
|
16
16
|
|
|
17
|
-
type CaseConvention = "camel" | "snake" | "preserve" | RegExp | ((column: string) => string);
|
|
17
|
+
type CaseConvention = "camel" | "snake" | "pascal" | "preserve" | RegExp | ((column: string) => string);
|
|
18
18
|
|
|
19
19
|
type CommonConstraintOptions = {
|
|
20
20
|
constraintName?: string;
|
|
@@ -162,13 +162,6 @@ type DateTimeOptions = {
|
|
|
162
162
|
*/
|
|
163
163
|
type DatabaseTableOptions = MysqlTableOptions | PostgresTableOptions | SqliteTableOptions | MssqlTableOptions | OracledbTableOptions | MysqlAdvancedTableOptions;
|
|
164
164
|
|
|
165
|
-
/**
|
|
166
|
-
* Simplifies complex return types like SelectedModel to make it more readable and strips out whatever is passed as the second type parameter (e.g. SELECT_BRAND) to avoid showing it in the IDE autocomplete.
|
|
167
|
-
*/
|
|
168
|
-
type Simplify<T, Strip> = T extends infer U ? {
|
|
169
|
-
[K in keyof U as K extends Strip ? never : K]: U[K];
|
|
170
|
-
} : never;
|
|
171
|
-
|
|
172
165
|
declare abstract class QueryNode {
|
|
173
166
|
/**
|
|
174
167
|
* Sql keyword to use for the query e.g. "select"
|
|
@@ -213,7 +206,7 @@ declare class RawNode extends QueryNode {
|
|
|
213
206
|
}
|
|
214
207
|
|
|
215
208
|
type BaseValues$2 = string | number | boolean | undefined | null | RawNode;
|
|
216
|
-
type BinaryOperatorType$2 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "is" | "is not" | "like" | "not like" | "is null" | "is not null" | "ilike" | "in" | "not in" | "between" | "not between" | "regexp" | "not regexp" | "not ilike";
|
|
209
|
+
type BinaryOperatorType$2 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "is" | "is not" | "like" | "not like" | "is null" | "is not null" | "ilike" | "in" | "not in" | "between" | "not between" | "regexp" | "not regexp" | "not ilike" | (string & {});
|
|
217
210
|
declare class WhereNode extends QueryNode {
|
|
218
211
|
column: string;
|
|
219
212
|
isNegated: boolean;
|
|
@@ -840,6 +833,11 @@ type SqlDataSourceInputBase<T extends Record<string, SqlDataSourceModel> = {}, C
|
|
|
840
833
|
* @description To use AdminJS, install: `npm install adminjs`
|
|
841
834
|
*/
|
|
842
835
|
adminJs?: AdminJsOptions;
|
|
836
|
+
/**
|
|
837
|
+
* @description If true, the data source will not throw when unconnected — it will auto-connect on the first query execution.
|
|
838
|
+
* @default false
|
|
839
|
+
*/
|
|
840
|
+
lazyLoad?: boolean;
|
|
843
841
|
};
|
|
844
842
|
/**
|
|
845
843
|
* @description Maps a SqlDataSourceType to its corresponding input interface
|
|
@@ -934,6 +932,17 @@ type SlaveAlgorithm = "roundRobin" | "random";
|
|
|
934
932
|
type RawQueryOptions = {
|
|
935
933
|
replicationMode?: ReplicationType;
|
|
936
934
|
};
|
|
935
|
+
/**
|
|
936
|
+
* @description Result of a health check ping operation
|
|
937
|
+
*/
|
|
938
|
+
type PingResult = {
|
|
939
|
+
/** Whether the ping was successful */
|
|
940
|
+
ok: boolean;
|
|
941
|
+
/** Latency in milliseconds */
|
|
942
|
+
latencyMs: number;
|
|
943
|
+
/** Database dialect/type */
|
|
944
|
+
dialect: SqlDataSourceType;
|
|
945
|
+
};
|
|
937
946
|
|
|
938
947
|
type OpenApiModelType = {
|
|
939
948
|
type: "object";
|
|
@@ -1795,6 +1804,44 @@ declare class SchemaBuilder implements PromiseLike<void> {
|
|
|
1795
1804
|
hasFailed(): boolean;
|
|
1796
1805
|
}
|
|
1797
1806
|
|
|
1807
|
+
interface IntrospectedColumn {
|
|
1808
|
+
name: string;
|
|
1809
|
+
type: string;
|
|
1810
|
+
nullable: boolean;
|
|
1811
|
+
default?: string | null;
|
|
1812
|
+
length?: number;
|
|
1813
|
+
isPrimaryKey?: boolean;
|
|
1814
|
+
isForeignKey?: boolean;
|
|
1815
|
+
references?: {
|
|
1816
|
+
table: string;
|
|
1817
|
+
column: string;
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
interface IntrospectedForeignKey {
|
|
1821
|
+
column: string;
|
|
1822
|
+
references: {
|
|
1823
|
+
table: string;
|
|
1824
|
+
column: string;
|
|
1825
|
+
};
|
|
1826
|
+
onDelete?: string;
|
|
1827
|
+
onUpdate?: string;
|
|
1828
|
+
}
|
|
1829
|
+
interface IntrospectedTable {
|
|
1830
|
+
name: string;
|
|
1831
|
+
columns: IntrospectedColumn[];
|
|
1832
|
+
primaryKeys?: string[];
|
|
1833
|
+
foreignKeys?: IntrospectedForeignKey[];
|
|
1834
|
+
indices?: {
|
|
1835
|
+
name: string;
|
|
1836
|
+
columns: string[];
|
|
1837
|
+
unique?: boolean;
|
|
1838
|
+
}[];
|
|
1839
|
+
}
|
|
1840
|
+
interface IntrospectedSchema {
|
|
1841
|
+
dialect: string;
|
|
1842
|
+
tables: IntrospectedTable[];
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1798
1845
|
type AstParserType = {
|
|
1799
1846
|
sql: string;
|
|
1800
1847
|
bindings: any[];
|
|
@@ -1969,8 +2016,6 @@ declare class ModelManager<T extends Model> {
|
|
|
1969
2016
|
private applyFieldCondition;
|
|
1970
2017
|
}
|
|
1971
2018
|
|
|
1972
|
-
type JsonPathInput = string | (string | number)[];
|
|
1973
|
-
|
|
1974
2019
|
declare class DeleteNode extends QueryNode {
|
|
1975
2020
|
fromNode: FromNode;
|
|
1976
2021
|
returning?: string[];
|
|
@@ -2107,6 +2152,8 @@ declare class MongoQueryBuilder<T extends Collection> {
|
|
|
2107
2152
|
protected logs: boolean | LoggerConfig;
|
|
2108
2153
|
protected session?: ReturnType<MongoDataSource["startSession"]>;
|
|
2109
2154
|
constructor(model: typeof Collection, mongoDataSource: MongoDataSource, _session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean | LoggerConfig);
|
|
2155
|
+
private initCollection;
|
|
2156
|
+
protected ensureInitialized(): Promise<void>;
|
|
2110
2157
|
one(options?: OneOptions$1): Promise<T | null>;
|
|
2111
2158
|
oneOrFail(options?: OneOptions$1): Promise<T>;
|
|
2112
2159
|
many(options?: ManyOptions$1): Promise<T[]>;
|
|
@@ -2414,6 +2461,8 @@ declare class CollectionManager<T extends Collection> {
|
|
|
2414
2461
|
protected collectionInstance: MongoClientImport["Collection"]["prototype"];
|
|
2415
2462
|
protected session?: ReturnType<MongoDataSource["startSession"]>;
|
|
2416
2463
|
constructor(_collection: typeof Collection, mongoDataSource: MongoDataSource, session?: ReturnType<MongoDataSource["startSession"]>, logs?: boolean | LoggerConfig);
|
|
2464
|
+
private initConnection;
|
|
2465
|
+
protected ensureInitialized(): Promise<void>;
|
|
2417
2466
|
/**
|
|
2418
2467
|
* @description Finds all records that match the input
|
|
2419
2468
|
*/
|
|
@@ -2460,17 +2509,24 @@ interface MongoDataSourceInput {
|
|
|
2460
2509
|
url?: string;
|
|
2461
2510
|
options?: MongoConnectionOptions;
|
|
2462
2511
|
logs?: boolean | LoggerConfig;
|
|
2512
|
+
lazyLoad?: boolean;
|
|
2463
2513
|
}
|
|
2464
2514
|
declare class MongoDataSource extends DataSource {
|
|
2465
2515
|
url: string;
|
|
2466
2516
|
isConnected: boolean;
|
|
2467
2517
|
private mongoClient;
|
|
2468
2518
|
private mongoOptions?;
|
|
2519
|
+
private lazyLoad;
|
|
2520
|
+
private connecting;
|
|
2469
2521
|
constructor(input?: MongoDataSourceInput);
|
|
2470
2522
|
/**
|
|
2471
2523
|
* @description Establishes the connection to MongoDB
|
|
2472
2524
|
*/
|
|
2473
2525
|
connect(): Promise<void>;
|
|
2526
|
+
/**
|
|
2527
|
+
* @description Ensures the connection is established. If lazyLoad is true and not connected, connects automatically.
|
|
2528
|
+
*/
|
|
2529
|
+
ensureConnected(): Promise<void>;
|
|
2474
2530
|
/**
|
|
2475
2531
|
* @description Returns the current connection to the mongo client to execute direct statements using the mongo client from `mongodb` package
|
|
2476
2532
|
*/
|
|
@@ -2488,18 +2544,29 @@ declare class MongoDataSource extends DataSource {
|
|
|
2488
2544
|
* @alias disconnect
|
|
2489
2545
|
*/
|
|
2490
2546
|
closeConnection(): Promise<void>;
|
|
2491
|
-
/**
|
|
2492
|
-
* @description Returns a raw MongoQueryBuilder for a collection name string
|
|
2493
|
-
*/
|
|
2494
|
-
query(collectionName: string): MongoQueryBuilder<Collection>;
|
|
2495
2547
|
/**
|
|
2496
2548
|
* @description Returns a CollectionManager for the given collection class,
|
|
2497
2549
|
* providing query(), find(), findOne(), insert(), etc.
|
|
2550
|
+
* When a string is passed, returns a raw MongoQueryBuilder for the collection name.
|
|
2498
2551
|
*/
|
|
2499
2552
|
from<T extends Collection>(collection: (new (...args: any[]) => T) & Record<string, any>, options?: {
|
|
2500
2553
|
session?: InstanceType<MongoClientImport["ClientSession"]>;
|
|
2501
2554
|
}): CollectionManager<T>;
|
|
2555
|
+
from(collectionName: string): MongoQueryBuilder<Collection>;
|
|
2502
2556
|
getModelManager<T extends Collection>(model: typeof Collection, mongoDataSource: MongoDataSource, session?: InstanceType<MongoClientImport["ClientSession"]>): CollectionManager<T>;
|
|
2557
|
+
/**
|
|
2558
|
+
* @description Executes a lightweight health check ping
|
|
2559
|
+
* @returns Promise resolving to PingResult with ok status, latency in ms, and dialect 'mongo'
|
|
2560
|
+
*/
|
|
2561
|
+
ping(): Promise<{
|
|
2562
|
+
ok: boolean;
|
|
2563
|
+
latencyMs: number;
|
|
2564
|
+
dialect: "mongo";
|
|
2565
|
+
}>;
|
|
2566
|
+
/**
|
|
2567
|
+
* @description Returns true if the MongoDB connection is healthy, false on error (never throws)
|
|
2568
|
+
*/
|
|
2569
|
+
isHealthy(): Promise<boolean>;
|
|
2503
2570
|
}
|
|
2504
2571
|
|
|
2505
2572
|
type MongoCollectionKey<T> = T extends Collection ? T : never;
|
|
@@ -2543,7 +2610,7 @@ declare class HavingNode extends QueryNode {
|
|
|
2543
2610
|
constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType, value: BaseValues | BaseValues[], isRawValue?: boolean);
|
|
2544
2611
|
}
|
|
2545
2612
|
|
|
2546
|
-
type SubqueryOperatorType = "in" | "not in" | "exists" | "not exists" | "between" | "not between" | ">" | "<" | ">=" | "<=";
|
|
2613
|
+
type SubqueryOperatorType = "in" | "not in" | "exists" | "not exists" | "between" | "not between" | ">" | "<" | ">=" | "<=" | (string & {});
|
|
2547
2614
|
declare class WhereSubqueryNode extends QueryNode {
|
|
2548
2615
|
column: string;
|
|
2549
2616
|
operator: SubqueryOperatorType;
|
|
@@ -2564,199 +2631,439 @@ declare class WhereGroupNode extends QueryNode {
|
|
|
2564
2631
|
constructor(nodes: (WhereNode | WhereGroupNode | WhereSubqueryNode)[], chainsWith?: "and" | "or");
|
|
2565
2632
|
}
|
|
2566
2633
|
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
|
-
declare class DistinctOnNode extends QueryNode {
|
|
2576
|
-
columns: string[];
|
|
2577
|
-
chainsWith: string;
|
|
2578
|
-
canKeywordBeSeenMultipleTimes: boolean;
|
|
2579
|
-
folder: string;
|
|
2580
|
-
file: string;
|
|
2581
|
-
constructor(columns: string[]);
|
|
2582
|
-
}
|
|
2583
|
-
|
|
2584
|
-
declare class SelectNode extends QueryNode {
|
|
2585
|
-
column: string | QueryNode | QueryNode[];
|
|
2586
|
-
alias?: string;
|
|
2587
|
-
sqlFunction?: string;
|
|
2588
|
-
chainsWith: string;
|
|
2589
|
-
canKeywordBeSeenMultipleTimes: boolean;
|
|
2590
|
-
folder: string;
|
|
2591
|
-
file: string;
|
|
2592
|
-
constructor(column: string | QueryNode | QueryNode[], alias?: string, sqlFunction?: string, isRaw?: boolean);
|
|
2593
|
-
}
|
|
2594
|
-
|
|
2595
|
-
declare class JoinNode extends QueryNode {
|
|
2596
|
-
table: string;
|
|
2597
|
-
left: string;
|
|
2598
|
-
right: string;
|
|
2599
|
-
on?: {
|
|
2600
|
-
left?: string;
|
|
2601
|
-
right?: string;
|
|
2602
|
-
operator: string;
|
|
2603
|
-
};
|
|
2604
|
-
chainsWith: string;
|
|
2605
|
-
canKeywordBeSeenMultipleTimes: boolean;
|
|
2606
|
-
folder: string;
|
|
2607
|
-
file: string;
|
|
2608
|
-
type: "inner" | "left" | "right" | "full" | "cross" | "natural";
|
|
2609
|
-
additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[];
|
|
2610
|
-
constructor(table: string, left: string, right: string, type: "inner" | "left" | "right" | "full" | "cross" | "natural" | undefined, on: {
|
|
2611
|
-
left?: string;
|
|
2612
|
-
right?: string;
|
|
2613
|
-
operator: string;
|
|
2614
|
-
}, isRawValue?: boolean, additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[]);
|
|
2615
|
-
}
|
|
2616
|
-
|
|
2617
|
-
declare class GroupByNode extends QueryNode {
|
|
2618
|
-
column: string;
|
|
2619
|
-
chainsWith: string;
|
|
2620
|
-
canKeywordBeSeenMultipleTimes: boolean;
|
|
2621
|
-
folder: string;
|
|
2622
|
-
file: string;
|
|
2623
|
-
constructor(column: string, isRawValue?: boolean);
|
|
2624
|
-
}
|
|
2625
|
-
|
|
2626
|
-
declare class LimitNode extends QueryNode {
|
|
2627
|
-
limit: number;
|
|
2628
|
-
chainsWith: string;
|
|
2629
|
-
canKeywordBeSeenMultipleTimes: boolean;
|
|
2630
|
-
folder: string;
|
|
2631
|
-
file: string;
|
|
2632
|
-
constructor(limit: number);
|
|
2633
|
-
}
|
|
2634
|
-
|
|
2635
|
-
declare class OffsetNode extends QueryNode {
|
|
2636
|
-
offset: number;
|
|
2637
|
-
chainsWith: string;
|
|
2638
|
-
canKeywordBeSeenMultipleTimes: boolean;
|
|
2639
|
-
folder: string;
|
|
2640
|
-
file: string;
|
|
2641
|
-
constructor(offset: number);
|
|
2642
|
-
}
|
|
2643
|
-
|
|
2644
|
-
declare class OrderByNode extends QueryNode {
|
|
2645
|
-
column: string;
|
|
2646
|
-
direction: "asc" | "desc";
|
|
2647
|
-
chainsWith: string;
|
|
2648
|
-
canKeywordBeSeenMultipleTimes: boolean;
|
|
2649
|
-
folder: string;
|
|
2650
|
-
file: string;
|
|
2651
|
-
constructor(column: string, direction?: "asc" | "desc", isRawValue?: boolean);
|
|
2652
|
-
}
|
|
2653
|
-
|
|
2654
|
-
type DateFormat = "ISO" | "TIMESTAMP" | "DATE_ONLY" | "TIME_ONLY";
|
|
2655
|
-
type Timezone = "UTC" | "LOCAL";
|
|
2634
|
+
/**
|
|
2635
|
+
* Simplifies complex return types like SelectedModel to make it more readable and strips out whatever is passed as the second type parameter (e.g. SELECT_BRAND) to avoid showing it in the IDE autocomplete.
|
|
2636
|
+
*/
|
|
2637
|
+
type Simplify<T, Strip> = T extends infer U ? {
|
|
2638
|
+
[K in keyof U as K extends Strip ? never : K]: U[K];
|
|
2639
|
+
} : never;
|
|
2656
2640
|
|
|
2641
|
+
type PluckReturnType<T extends Model, K extends RawModelKey<T>> = T[StripTablePrefix<K & string> & keyof T] extends infer U ? U[] : never;
|
|
2657
2642
|
/**
|
|
2658
|
-
*
|
|
2659
|
-
*
|
|
2660
|
-
*
|
|
2643
|
+
* Common SQL functions with intellisense support.
|
|
2644
|
+
* Provides autocomplete for standard SQL aggregate and scalar functions,
|
|
2645
|
+
* while still allowing any custom function name via string fallback.
|
|
2646
|
+
*
|
|
2647
|
+
* @example
|
|
2648
|
+
* selectFunc("count", "*", "total") // Intellisense suggests "count"
|
|
2649
|
+
* selectFunc("custom_fn", "col", "res") // Custom functions still work
|
|
2661
2650
|
*/
|
|
2662
|
-
|
|
2663
|
-
hasOne = "hasOne",// One to One without foreign key
|
|
2664
|
-
belongsTo = "belongsTo",// One to One with foreign key
|
|
2665
|
-
hasMany = "hasMany",
|
|
2666
|
-
manyToMany = "manyToMany"
|
|
2667
|
-
}
|
|
2651
|
+
type SqlFunction = "count" | "sum" | "avg" | "min" | "max" | "upper" | "lower" | "length" | "trim" | "abs" | "round" | "coalesce" | "ceil" | "floor" | "sqrt" | (string & {});
|
|
2668
2652
|
/**
|
|
2669
|
-
*
|
|
2653
|
+
* Maps SQL function names to their return types.
|
|
2654
|
+
* Used by selectFunc to auto-infer the result type.
|
|
2655
|
+
*
|
|
2656
|
+
* - Numeric functions (count, sum, avg, etc.) → number
|
|
2657
|
+
* - String functions (upper, lower, trim) → string
|
|
2658
|
+
* - Unknown functions → any
|
|
2670
2659
|
*/
|
|
2671
|
-
|
|
2672
|
-
abstract type: RelationEnum;
|
|
2673
|
-
model: typeof Model;
|
|
2674
|
-
columnName: string;
|
|
2675
|
-
foreignKey?: string;
|
|
2676
|
-
relatedModel: string;
|
|
2677
|
-
protected constructor(model: typeof Model, columnName: string);
|
|
2678
|
-
}
|
|
2679
|
-
|
|
2680
|
-
type BaseColumnDataType = Exclude<keyof CreateTableBuilder, "enum" | "rawColumn" | "custom">;
|
|
2660
|
+
type SqlFunctionReturnType<F extends string> = F extends "count" | "sum" | "avg" | "min" | "max" | "length" | "abs" | "round" | "ceil" | "floor" | "sqrt" ? number : F extends "upper" | "lower" | "trim" ? string : any;
|
|
2681
2661
|
/**
|
|
2682
|
-
*
|
|
2683
|
-
*
|
|
2684
|
-
* @example
|
|
2685
|
-
* col<string>({ type: "varchar", length: 255 }) // built-in
|
|
2686
|
-
* col<string>({ type: "vector", length: 1536 }) // custom (pgvector)
|
|
2662
|
+
* A tuple type for selecting a column with an alias.
|
|
2663
|
+
* @example ["id", "userId"] selects "id" column as "userId"
|
|
2687
2664
|
*/
|
|
2688
|
-
type
|
|
2689
|
-
type ColumnDataTypeOptionWithLength = {
|
|
2690
|
-
type?: "char" | "varchar" | "string" | "uuid" | "ulid" | "varbinary" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "increment" | "bigIncrement";
|
|
2691
|
-
length?: number;
|
|
2692
|
-
};
|
|
2693
|
-
type ColumnDataTypeOptionWithEnum = {
|
|
2694
|
-
type?: readonly string[];
|
|
2695
|
-
};
|
|
2696
|
-
type ColumnDataTypeOptionWithPrecision = {
|
|
2697
|
-
type?: "float" | "double" | "real";
|
|
2698
|
-
precision?: number;
|
|
2699
|
-
};
|
|
2700
|
-
type ColumnDataTypeOptionWithScaleAndPrecision = {
|
|
2701
|
-
type?: "decimal" | "numeric";
|
|
2702
|
-
precision?: number;
|
|
2703
|
-
scale?: number;
|
|
2704
|
-
};
|
|
2705
|
-
type ColumnDataTypeOptionWithText = {
|
|
2706
|
-
type?: "text" | "longtext" | "mediumtext" | "tinytext";
|
|
2707
|
-
};
|
|
2708
|
-
type ColumnDataTypeOptionWithBinary = {
|
|
2709
|
-
type?: "binary" | "blob" | "tinyblob" | "mediumblob" | "longblob";
|
|
2710
|
-
};
|
|
2711
|
-
type ColumnDataTypeOptionWithDatePrecision = {
|
|
2712
|
-
type?: "date" | "time" | "datetime" | "timestamp";
|
|
2713
|
-
precision?: number;
|
|
2714
|
-
withTimezone?: boolean;
|
|
2715
|
-
};
|
|
2716
|
-
type ColumnDataTypeOptionSimple = {
|
|
2717
|
-
type?: "year" | "boolean" | "json" | "jsonb";
|
|
2718
|
-
};
|
|
2665
|
+
type SelectTuple<C extends string = string, A extends string = string> = readonly [column: C, alias: A];
|
|
2719
2666
|
/**
|
|
2720
|
-
*
|
|
2721
|
-
*
|
|
2667
|
+
* Input type for select() method in raw query builder.
|
|
2668
|
+
* Accepts either a column string or a [column, alias] tuple.
|
|
2669
|
+
*
|
|
2722
2670
|
* @example
|
|
2723
|
-
*
|
|
2724
|
-
*
|
|
2671
|
+
* .select("id", "name") // Simple columns
|
|
2672
|
+
* .select(["id", "userId"], ["name", "n"]) // Columns with aliases
|
|
2673
|
+
* .select("id", ["name", "userName"]) // Mixed
|
|
2725
2674
|
*/
|
|
2726
|
-
type
|
|
2727
|
-
/**
|
|
2728
|
-
* Custom database column type. Passes through as-is to SQL.
|
|
2729
|
-
* Supports extensions like pgvector, PostGIS, etc.
|
|
2730
|
-
*/
|
|
2731
|
-
type?: string & {};
|
|
2732
|
-
/**
|
|
2733
|
-
* Optional length for custom types (e.g., vector(1536)).
|
|
2734
|
-
*/
|
|
2735
|
-
length?: number;
|
|
2736
|
-
};
|
|
2737
|
-
type ColumnDataTypeOption = ColumnDataTypeOptionWithLength | ColumnDataTypeOptionWithPrecision | ColumnDataTypeOptionWithScaleAndPrecision | ColumnDataTypeOptionWithText | ColumnDataTypeOptionWithBinary | ColumnDataTypeOptionWithDatePrecision | ColumnDataTypeOptionWithEnum | ColumnDataTypeOptionSimple | ColumnDataTypeOptionCustom;
|
|
2738
|
-
type LazyRelationType = {
|
|
2739
|
-
type?: RelationEnum;
|
|
2740
|
-
columnName: string;
|
|
2741
|
-
model: () => AnyModelConstructor;
|
|
2742
|
-
foreignKey: string | (() => string);
|
|
2743
|
-
constraintName: string | (() => string);
|
|
2744
|
-
onDelete?: OnUpdateOrDelete;
|
|
2745
|
-
onUpdate?: OnUpdateOrDelete;
|
|
2746
|
-
/**
|
|
2747
|
-
* @description Only for many to many relations
|
|
2748
|
-
*/
|
|
2749
|
-
manyToManyOptions?: {
|
|
2750
|
-
primaryModel: string;
|
|
2751
|
-
throughModel: string | (() => string);
|
|
2752
|
-
leftForeignKey: string | (() => string);
|
|
2753
|
-
rightForeignKey: string | (() => string);
|
|
2754
|
-
wasModelProvided: boolean;
|
|
2755
|
-
};
|
|
2756
|
-
};
|
|
2675
|
+
type Selectable = string | SelectTuple;
|
|
2757
2676
|
/**
|
|
2758
|
-
*
|
|
2759
|
-
|
|
2677
|
+
* Unique symbol used internally to mark that a raw select() has been called.
|
|
2678
|
+
*/
|
|
2679
|
+
declare const RAW_SELECT_BRAND: unique symbol;
|
|
2680
|
+
/**
|
|
2681
|
+
* Marker type to indicate that a raw select() has been called.
|
|
2682
|
+
* @internal
|
|
2683
|
+
*/
|
|
2684
|
+
type RawSelectBrand = {
|
|
2685
|
+
[RAW_SELECT_BRAND]?: never;
|
|
2686
|
+
};
|
|
2687
|
+
/**
|
|
2688
|
+
* Utility type to convert a union to an intersection.
|
|
2689
|
+
* @internal
|
|
2690
|
+
*/
|
|
2691
|
+
type UnionToIntersection$1<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
2692
|
+
/**
|
|
2693
|
+
* Extracts the final property name from a column selection for raw queries.
|
|
2694
|
+
* Supports both string columns and [column, alias] tuples.
|
|
2695
|
+
*
|
|
2696
|
+
* | Input | Output |
|
|
2697
|
+
* |------------------------------|---------------|
|
|
2698
|
+
* | `"name"` | `"name"` |
|
|
2699
|
+
* | `"users.name"` | `"name"` |
|
|
2700
|
+
* | `["name", "userName"]` | `"userName"` |
|
|
2701
|
+
* | `["users.id", "id"]` | `"id"` |
|
|
2702
|
+
* | `"*"` | `never` |
|
|
2703
|
+
* | `"users.*"` | `never` |
|
|
2704
|
+
*/
|
|
2705
|
+
type ExtractRawColumnName<S> = S extends readonly [
|
|
2706
|
+
string,
|
|
2707
|
+
infer Alias extends string
|
|
2708
|
+
] ? Alias : S extends string ? S extends "*" ? never : S extends `${string}.*` ? never : S extends `${string}.${infer Column}` ? Column extends "*" ? never : Column : S : never;
|
|
2709
|
+
/**
|
|
2710
|
+
* Builds the type for a single selected column in a raw query.
|
|
2711
|
+
* All column types are `any` since we don't have model type information.
|
|
2712
|
+
* Supports both string columns and [column, alias] tuples.
|
|
2713
|
+
*
|
|
2714
|
+
* | Selection | Result Type |
|
|
2715
|
+
* |------------------------|---------------------------------------|
|
|
2716
|
+
* | `"*"` | `Record<string, any>` |
|
|
2717
|
+
* | `"table.*"` | `Record<string, any>` |
|
|
2718
|
+
* | `"column"` | `{ column: any }` |
|
|
2719
|
+
* | `["col", "alias"]` | `{ alias: any }` |
|
|
2720
|
+
*
|
|
2721
|
+
* @internal
|
|
2722
|
+
*/
|
|
2723
|
+
type BuildRawSingleSelectType<S> = S extends readonly [
|
|
2724
|
+
string,
|
|
2725
|
+
infer Alias extends string
|
|
2726
|
+
] ? {
|
|
2727
|
+
[K in Alias]: any;
|
|
2728
|
+
} : S extends string ? S extends "*" ? Record<string, any> : S extends `${string}.*` ? Record<string, any> : ExtractRawColumnName<S> extends never ? {} : {
|
|
2729
|
+
[K in ExtractRawColumnName<S> & string]: any;
|
|
2730
|
+
} : {};
|
|
2731
|
+
/**
|
|
2732
|
+
* Checks if a column selection includes wildcards or is empty.
|
|
2733
|
+
* @internal
|
|
2734
|
+
*/
|
|
2735
|
+
type HasRawStarOrEmpty<Columns extends readonly Selectable[]> = Columns["length"] extends 0 ? true : "*" extends Columns[number] ? true : false;
|
|
2736
|
+
/**
|
|
2737
|
+
* Builds the combined TypeScript type for multiple selected columns in a raw query.
|
|
2738
|
+
* Supports both string columns and [column, alias] tuples.
|
|
2739
|
+
*
|
|
2740
|
+
* ## Rules
|
|
2741
|
+
*
|
|
2742
|
+
* 1. **Empty selection or `*`**: Returns `Record<string, any>`
|
|
2743
|
+
* 2. **Specific columns**: Returns intersection of all selected column types (all `any`)
|
|
2744
|
+
* 3. **With `table.*`**: Adds `Record<string, any>` to allow unknown properties
|
|
2745
|
+
*
|
|
2746
|
+
* @example
|
|
2747
|
+
* // .select("name", ["age", "userAge"])
|
|
2748
|
+
* BuildRawSelectType<["name", ["age", "userAge"]]>
|
|
2749
|
+
* // Result: { name: any; userAge: any } & RawSelectBrand
|
|
2750
|
+
*
|
|
2751
|
+
* @example
|
|
2752
|
+
* // .select("*")
|
|
2753
|
+
* BuildRawSelectType<["*"]>
|
|
2754
|
+
* // Result: Record<string, any>
|
|
2755
|
+
*/
|
|
2756
|
+
type BuildRawSelectType<Columns extends readonly Selectable[]> = HasRawStarOrEmpty<Columns> extends true ? Record<string, any> : UnionToIntersection$1<{
|
|
2757
|
+
[K in keyof Columns]: BuildRawSingleSelectType<Columns[K]>;
|
|
2758
|
+
}[number]> extends infer Result ? Result extends Record<string, any> ? keyof Result extends never ? Record<string, any> : Result & RawSelectBrand : Record<string, any> : Record<string, any>;
|
|
2759
|
+
/**
|
|
2760
|
+
* Composes a new selection with the existing selection state for raw queries.
|
|
2761
|
+
*
|
|
2762
|
+
* - If S is the default Record<string, any> (no previous select), returns just the new selection
|
|
2763
|
+
* - If S is a typed selection from a prior select/selectRaw, composes with new selection
|
|
2764
|
+
*
|
|
2765
|
+
* Detection uses `string extends keyof S`: true for untyped `Record<string, any>`, false for any
|
|
2766
|
+
* specific typed record (e.g. `{ userName: any }`). This avoids relying on the RAW_SELECT_BRAND
|
|
2767
|
+
* symbol, which gets stripped by Simplify in intermediate types.
|
|
2768
|
+
*
|
|
2769
|
+
* @typeParam S - Current selection state
|
|
2770
|
+
* @typeParam Added - New fields being added by the select
|
|
2771
|
+
*
|
|
2772
|
+
* @example
|
|
2773
|
+
* // First selectRaw - creates new selection
|
|
2774
|
+
* ComposeRawSelect<Record<string, any>, { count: number }>
|
|
2775
|
+
* // Result: { count: number }
|
|
2776
|
+
*
|
|
2777
|
+
* @example
|
|
2778
|
+
* // Chained after select - composes with previous
|
|
2779
|
+
* ComposeRawSelect<{ userName: any }, { nameLength: number }>
|
|
2780
|
+
* // Result: { userName: any; nameLength: number }
|
|
2781
|
+
*/
|
|
2782
|
+
type ComposeRawSelect<S extends Record<string, any>, Added extends Record<string, any>> = Simplify<(string extends keyof S ? RawSelectBrand : S) & Added, typeof RAW_SELECT_BRAND>;
|
|
2783
|
+
/**
|
|
2784
|
+
* Composes a BuildRawSelectType result with the existing selection state.
|
|
2785
|
+
*
|
|
2786
|
+
* Similar to ComposeRawSelect but designed for use with BuildRawSelectType.
|
|
2787
|
+
*
|
|
2788
|
+
* @typeParam S - Current selection state
|
|
2789
|
+
* @typeParam Columns - The columns being selected
|
|
2790
|
+
*/
|
|
2791
|
+
type ComposeBuildRawSelect<S extends Record<string, any>, Columns extends readonly Selectable[]> = Simplify<(string extends keyof S ? {} : S) & BuildRawSelectType<Columns>, typeof RAW_SELECT_BRAND>;
|
|
2792
|
+
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">;
|
|
2793
|
+
type RelationRetrieveMethod<P> = NonNullable<P> extends any[] ? "many" : "one";
|
|
2794
|
+
/**
|
|
2795
|
+
* Validates a column string for raw query builder select().
|
|
2796
|
+
* Use [column, alias] tuple format for aliases instead of "column as alias".
|
|
2797
|
+
* Use selectFunction() for SQL functions instead of embedding them in select().
|
|
2798
|
+
*/
|
|
2799
|
+
type SelectableColumn$1<T extends string = string> = T extends `${string}.${string}.${string}` ? never : T extends `${string} ${string}` ? never : T extends `.${string}` | `${string}.` ? never : T extends `${string}-${string}` ? never : T extends `${string}.${string}` ? T : T;
|
|
2800
|
+
/**
|
|
2801
|
+
* @description A column that can be used in a join statement e.g. `users.id`
|
|
2802
|
+
*/
|
|
2803
|
+
type JoinableColumn = `${string}.${string}`;
|
|
2804
|
+
/**
|
|
2805
|
+
* @description Options for streaming queries
|
|
2806
|
+
* @sqlite Ignores the options below
|
|
2807
|
+
*/
|
|
2808
|
+
type StreamOptions = {
|
|
2809
|
+
highWaterMark?: number;
|
|
2810
|
+
/** Postgres only */
|
|
2811
|
+
rowMode?: "array";
|
|
2812
|
+
/** Postgres only */
|
|
2813
|
+
batchSize?: number;
|
|
2814
|
+
/** Postgres only */
|
|
2815
|
+
types?: any;
|
|
2816
|
+
/** Mysql only */
|
|
2817
|
+
objectMode?: boolean;
|
|
2818
|
+
};
|
|
2819
|
+
type Cursor<T extends Model, K extends ModelKey<T>> = {
|
|
2820
|
+
key: K;
|
|
2821
|
+
value: string | number;
|
|
2822
|
+
};
|
|
2823
|
+
type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
|
|
2824
|
+
discriminator: K;
|
|
2825
|
+
operator?: "<" | ">";
|
|
2826
|
+
orderBy?: "asc" | "desc";
|
|
2827
|
+
};
|
|
2828
|
+
type UpsertOptionsRawBuilder = {
|
|
2829
|
+
updateOnConflict?: boolean;
|
|
2830
|
+
returning?: readonly string[];
|
|
2831
|
+
};
|
|
2832
|
+
type WriteQueryParam = string | number | boolean | Date | RawNode | object | null | undefined;
|
|
2833
|
+
/**
|
|
2834
|
+
* Simple paginated data type for raw query builders (without Model constraint)
|
|
2835
|
+
*/
|
|
2836
|
+
type RawPaginatedData<S extends Record<string, any>> = {
|
|
2837
|
+
paginationMetadata: {
|
|
2838
|
+
perPage: number;
|
|
2839
|
+
currentPage: number;
|
|
2840
|
+
firstPage: number;
|
|
2841
|
+
isEmpty: boolean;
|
|
2842
|
+
total: number;
|
|
2843
|
+
lastPage: number;
|
|
2844
|
+
hasMorePages: boolean;
|
|
2845
|
+
hasPages: boolean;
|
|
2846
|
+
};
|
|
2847
|
+
data: S[];
|
|
2848
|
+
};
|
|
2849
|
+
/**
|
|
2850
|
+
* Simple cursor paginated data type for raw query builders (without Model constraint)
|
|
2851
|
+
*/
|
|
2852
|
+
type RawCursorPaginatedData<S extends Record<string, any>> = {
|
|
2853
|
+
paginationMetadata: {
|
|
2854
|
+
perPage: number;
|
|
2855
|
+
firstPage: number;
|
|
2856
|
+
isEmpty: boolean;
|
|
2857
|
+
total: number;
|
|
2858
|
+
};
|
|
2859
|
+
data: S[];
|
|
2860
|
+
};
|
|
2861
|
+
|
|
2862
|
+
declare class DistinctNode extends QueryNode {
|
|
2863
|
+
chainsWith: string;
|
|
2864
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
2865
|
+
folder: string;
|
|
2866
|
+
file: string;
|
|
2867
|
+
constructor();
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
declare class DistinctOnNode extends QueryNode {
|
|
2871
|
+
columns: string[];
|
|
2872
|
+
chainsWith: string;
|
|
2873
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
2874
|
+
folder: string;
|
|
2875
|
+
file: string;
|
|
2876
|
+
constructor(columns: string[]);
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
declare class SelectNode extends QueryNode {
|
|
2880
|
+
column: string | QueryNode | QueryNode[];
|
|
2881
|
+
alias?: string;
|
|
2882
|
+
sqlFunction?: string;
|
|
2883
|
+
chainsWith: string;
|
|
2884
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
2885
|
+
folder: string;
|
|
2886
|
+
file: string;
|
|
2887
|
+
constructor(column: string | QueryNode | QueryNode[], alias?: string, sqlFunction?: string, isRaw?: boolean);
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
declare class JoinNode extends QueryNode {
|
|
2891
|
+
table: string;
|
|
2892
|
+
left: string;
|
|
2893
|
+
right: string;
|
|
2894
|
+
on?: {
|
|
2895
|
+
left?: string;
|
|
2896
|
+
right?: string;
|
|
2897
|
+
operator: string;
|
|
2898
|
+
};
|
|
2899
|
+
chainsWith: string;
|
|
2900
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
2901
|
+
folder: string;
|
|
2902
|
+
file: string;
|
|
2903
|
+
type: "inner" | "left" | "right" | "full" | "cross" | "natural";
|
|
2904
|
+
additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[];
|
|
2905
|
+
constructor(table: string, left: string, right: string, type: "inner" | "left" | "right" | "full" | "cross" | "natural" | undefined, on: {
|
|
2906
|
+
left?: string;
|
|
2907
|
+
right?: string;
|
|
2908
|
+
operator: string;
|
|
2909
|
+
}, isRawValue?: boolean, additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[]);
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
declare class GroupByNode extends QueryNode {
|
|
2913
|
+
column: string;
|
|
2914
|
+
chainsWith: string;
|
|
2915
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
2916
|
+
folder: string;
|
|
2917
|
+
file: string;
|
|
2918
|
+
constructor(column: string, isRawValue?: boolean);
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
declare class LimitNode extends QueryNode {
|
|
2922
|
+
limit: number;
|
|
2923
|
+
chainsWith: string;
|
|
2924
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
2925
|
+
folder: string;
|
|
2926
|
+
file: string;
|
|
2927
|
+
constructor(limit: number);
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
declare class OffsetNode extends QueryNode {
|
|
2931
|
+
offset: number;
|
|
2932
|
+
chainsWith: string;
|
|
2933
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
2934
|
+
folder: string;
|
|
2935
|
+
file: string;
|
|
2936
|
+
constructor(offset: number);
|
|
2937
|
+
}
|
|
2938
|
+
|
|
2939
|
+
declare class OrderByNode extends QueryNode {
|
|
2940
|
+
column: string;
|
|
2941
|
+
direction: "asc" | "desc";
|
|
2942
|
+
chainsWith: string;
|
|
2943
|
+
canKeywordBeSeenMultipleTimes: boolean;
|
|
2944
|
+
folder: string;
|
|
2945
|
+
file: string;
|
|
2946
|
+
constructor(column: string, direction?: "asc" | "desc", isRawValue?: boolean);
|
|
2947
|
+
}
|
|
2948
|
+
|
|
2949
|
+
type DateFormat = "ISO" | "TIMESTAMP" | "DATE_ONLY" | "TIME_ONLY";
|
|
2950
|
+
type Timezone = "UTC" | "LOCAL";
|
|
2951
|
+
|
|
2952
|
+
/**
|
|
2953
|
+
* @description Options for the relation
|
|
2954
|
+
* @property {string} softDeleteColumn - The column name for the soft delete column, if set, the relation will only return rows that have not been soft deleted
|
|
2955
|
+
* @property {string} softDeleteType - The type of the soft delete column
|
|
2956
|
+
*/
|
|
2957
|
+
declare enum RelationEnum {
|
|
2958
|
+
hasOne = "hasOne",// One to One without foreign key
|
|
2959
|
+
belongsTo = "belongsTo",// One to One with foreign key
|
|
2960
|
+
hasMany = "hasMany",
|
|
2961
|
+
manyToMany = "manyToMany"
|
|
2962
|
+
}
|
|
2963
|
+
/**
|
|
2964
|
+
* Main Relation Class
|
|
2965
|
+
*/
|
|
2966
|
+
declare abstract class Relation {
|
|
2967
|
+
abstract type: RelationEnum;
|
|
2968
|
+
model: typeof Model;
|
|
2969
|
+
columnName: string;
|
|
2970
|
+
foreignKey?: string;
|
|
2971
|
+
relatedModel: string;
|
|
2972
|
+
protected constructor(model: typeof Model, columnName: string);
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
type ValidationResult = {
|
|
2976
|
+
valid: boolean;
|
|
2977
|
+
message?: string;
|
|
2978
|
+
};
|
|
2979
|
+
type ValidationContext = {
|
|
2980
|
+
model: any;
|
|
2981
|
+
column: string;
|
|
2982
|
+
operation: "insert" | "update";
|
|
2983
|
+
data: any;
|
|
2984
|
+
};
|
|
2985
|
+
type Validator = (value: any, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
|
|
2986
|
+
|
|
2987
|
+
type BaseColumnDataType = Exclude<keyof CreateTableBuilder, "enum" | "rawColumn" | "custom">;
|
|
2988
|
+
/**
|
|
2989
|
+
* Column data type - supports built-in types with intellisense and custom string types.
|
|
2990
|
+
* Built-in types get autocomplete, custom types pass through as-is for extensions like pgvector.
|
|
2991
|
+
* @example
|
|
2992
|
+
* col<string>({ type: "varchar", length: 255 }) // built-in
|
|
2993
|
+
* col<string>({ type: "vector", length: 1536 }) // custom (pgvector)
|
|
2994
|
+
*/
|
|
2995
|
+
type ColumnDataType = BaseColumnDataType | (string & {}) | readonly string[];
|
|
2996
|
+
type ColumnDataTypeOptionWithLength = {
|
|
2997
|
+
type?: "char" | "varchar" | "string" | "uuid" | "ulid" | "varbinary" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "increment" | "bigIncrement";
|
|
2998
|
+
length?: number;
|
|
2999
|
+
};
|
|
3000
|
+
type ColumnDataTypeOptionWithEnum = {
|
|
3001
|
+
type?: readonly string[];
|
|
3002
|
+
};
|
|
3003
|
+
type ColumnDataTypeOptionWithPrecision = {
|
|
3004
|
+
type?: "float" | "double" | "real";
|
|
3005
|
+
precision?: number;
|
|
3006
|
+
};
|
|
3007
|
+
type ColumnDataTypeOptionWithScaleAndPrecision = {
|
|
3008
|
+
type?: "decimal" | "numeric";
|
|
3009
|
+
precision?: number;
|
|
3010
|
+
scale?: number;
|
|
3011
|
+
};
|
|
3012
|
+
type ColumnDataTypeOptionWithText = {
|
|
3013
|
+
type?: "text" | "longtext" | "mediumtext" | "tinytext";
|
|
3014
|
+
};
|
|
3015
|
+
type ColumnDataTypeOptionWithBinary = {
|
|
3016
|
+
type?: "binary" | "blob" | "tinyblob" | "mediumblob" | "longblob";
|
|
3017
|
+
};
|
|
3018
|
+
type ColumnDataTypeOptionWithDatePrecision = {
|
|
3019
|
+
type?: "date" | "time" | "datetime" | "timestamp";
|
|
3020
|
+
precision?: number;
|
|
3021
|
+
withTimezone?: boolean;
|
|
3022
|
+
};
|
|
3023
|
+
type ColumnDataTypeOptionSimple = {
|
|
3024
|
+
type?: "year" | "boolean" | "json" | "jsonb";
|
|
3025
|
+
};
|
|
3026
|
+
/**
|
|
3027
|
+
* Custom column type for database extensions (e.g., pgvector).
|
|
3028
|
+
* The type string is passed through as-is to the SQL interpreter.
|
|
3029
|
+
* @example
|
|
3030
|
+
* col<string>({ type: "vector", length: 1536 }) // PostgreSQL pgvector
|
|
3031
|
+
* col<string>({ type: "geometry" }) // PostGIS
|
|
3032
|
+
*/
|
|
3033
|
+
type ColumnDataTypeOptionCustom = {
|
|
3034
|
+
/**
|
|
3035
|
+
* Custom database column type. Passes through as-is to SQL.
|
|
3036
|
+
* Supports extensions like pgvector, PostGIS, etc.
|
|
3037
|
+
*/
|
|
3038
|
+
type?: string & {};
|
|
3039
|
+
/**
|
|
3040
|
+
* Optional length for custom types (e.g., vector(1536)).
|
|
3041
|
+
*/
|
|
3042
|
+
length?: number;
|
|
3043
|
+
};
|
|
3044
|
+
type ColumnDataTypeOption = ColumnDataTypeOptionWithLength | ColumnDataTypeOptionWithPrecision | ColumnDataTypeOptionWithScaleAndPrecision | ColumnDataTypeOptionWithText | ColumnDataTypeOptionWithBinary | ColumnDataTypeOptionWithDatePrecision | ColumnDataTypeOptionWithEnum | ColumnDataTypeOptionSimple | ColumnDataTypeOptionCustom;
|
|
3045
|
+
type LazyRelationType = {
|
|
3046
|
+
type?: RelationEnum;
|
|
3047
|
+
columnName: string;
|
|
3048
|
+
model: () => AnyModelConstructor;
|
|
3049
|
+
foreignKey: string | (() => string);
|
|
3050
|
+
constraintName: string | (() => string);
|
|
3051
|
+
onDelete?: OnUpdateOrDelete;
|
|
3052
|
+
onUpdate?: OnUpdateOrDelete;
|
|
3053
|
+
/**
|
|
3054
|
+
* @description Only for many to many relations
|
|
3055
|
+
*/
|
|
3056
|
+
manyToManyOptions?: {
|
|
3057
|
+
primaryModel: string;
|
|
3058
|
+
throughModel: string | (() => string);
|
|
3059
|
+
leftForeignKey: string | (() => string);
|
|
3060
|
+
rightForeignKey: string | (() => string);
|
|
3061
|
+
wasModelProvided: boolean;
|
|
3062
|
+
};
|
|
3063
|
+
};
|
|
3064
|
+
/**
|
|
3065
|
+
* Callback type for autoCreate/autoUpdate hooks on date columns.
|
|
3066
|
+
* Returns `Date` when used with date-mode columns (e.g. `col.datetime()`),
|
|
2760
3067
|
* returns `string` when used with string-mode columns (e.g. `col.datetime.string()`).
|
|
2761
3068
|
*/
|
|
2762
3069
|
type DateAutoHook = (() => Date) | (() => string);
|
|
@@ -2860,6 +3167,10 @@ type ColumnOptions = {
|
|
|
2860
3167
|
* @migration Only affects auto-generated migrations (CREATE TABLE / ALTER TABLE). Does NOT set a default value during insert operations — use `prepare` for that.
|
|
2861
3168
|
*/
|
|
2862
3169
|
default?: string | number | null | boolean;
|
|
3170
|
+
/**
|
|
3171
|
+
* @description Per-column validators applied on insert/update
|
|
3172
|
+
*/
|
|
3173
|
+
validate?: Validator | Validator[];
|
|
2863
3174
|
} &
|
|
2864
3175
|
/**
|
|
2865
3176
|
* @description The data type of the column
|
|
@@ -2889,6 +3200,7 @@ type ColumnType = {
|
|
|
2889
3200
|
nullable?: boolean;
|
|
2890
3201
|
default?: string | number | null | boolean;
|
|
2891
3202
|
};
|
|
3203
|
+
validate?: Validator | Validator[];
|
|
2892
3204
|
};
|
|
2893
3205
|
type IndexType = {
|
|
2894
3206
|
columns: string[];
|
|
@@ -2935,7 +3247,7 @@ declare abstract class FooterQueryBuilder<T extends Model, S extends Record<stri
|
|
|
2935
3247
|
* @description Adds a group by query
|
|
2936
3248
|
*/
|
|
2937
3249
|
groupBy(...columns: ModelKey<T>[]): this;
|
|
2938
|
-
groupBy<S extends string>(...columns: SelectableColumn<S>[]): this;
|
|
3250
|
+
groupBy<S extends string>(...columns: SelectableColumn$1<S>[]): this;
|
|
2939
3251
|
/**
|
|
2940
3252
|
* @description Adds a raw group by query, GROUP BY clause is not necessary and will be added automatically
|
|
2941
3253
|
*/
|
|
@@ -2944,7 +3256,7 @@ declare abstract class FooterQueryBuilder<T extends Model, S extends Record<stri
|
|
|
2944
3256
|
* @description Adds an order by query
|
|
2945
3257
|
*/
|
|
2946
3258
|
orderBy(column: ModelKey<T>, order: OrderByChoices): this;
|
|
2947
|
-
orderBy<S extends string>(column: SelectableColumn<S>, order: OrderByChoices): this;
|
|
3259
|
+
orderBy<S extends string>(column: SelectableColumn$1<S>, order: OrderByChoices): this;
|
|
2948
3260
|
/**
|
|
2949
3261
|
* @description Adds a raw order by query, ORDER BY clause is not necessary and will be added automatically
|
|
2950
3262
|
*/
|
|
@@ -2971,180 +3283,180 @@ declare class JoinOnQueryBuilder {
|
|
|
2971
3283
|
/**
|
|
2972
3284
|
* @description Adds a WHERE condition to the query.
|
|
2973
3285
|
*/
|
|
2974
|
-
where(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
3286
|
+
where(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
2975
3287
|
where(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
|
|
2976
|
-
where(column: SelectableColumn<string>, value: BaseValues$2): this;
|
|
3288
|
+
where(column: SelectableColumn$1<string>, value: BaseValues$2): this;
|
|
2977
3289
|
/**
|
|
2978
3290
|
* @description Adds an AND WHERE condition to the query.
|
|
2979
3291
|
*/
|
|
2980
|
-
andWhere(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
2981
|
-
andWhere(column: SelectableColumn<string>, value: BaseValues$2): this;
|
|
3292
|
+
andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
3293
|
+
andWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
|
|
2982
3294
|
andWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
|
|
2983
3295
|
/**
|
|
2984
3296
|
* @description Adds an OR WHERE condition to the query.
|
|
2985
3297
|
*/
|
|
2986
|
-
orWhere(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
2987
|
-
orWhere(column: SelectableColumn<string>, value: BaseValues$2): this;
|
|
3298
|
+
orWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
3299
|
+
orWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
|
|
2988
3300
|
orWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
|
|
2989
3301
|
/**
|
|
2990
3302
|
* @description Adds a negated WHERE condition to the query.
|
|
2991
3303
|
*/
|
|
2992
|
-
whereNot(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
2993
|
-
whereNot(column: SelectableColumn<string>, value: BaseValues$2): this;
|
|
3304
|
+
whereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
3305
|
+
whereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
|
|
2994
3306
|
/**
|
|
2995
3307
|
* @description Adds a negated AND WHERE condition to the query.
|
|
2996
3308
|
*/
|
|
2997
|
-
andWhereNot(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
2998
|
-
andWhereNot(column: SelectableColumn<string>, value: BaseValues$2): this;
|
|
3309
|
+
andWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
3310
|
+
andWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
|
|
2999
3311
|
/**
|
|
3000
3312
|
* @description Adds a negated OR WHERE condition to the query.
|
|
3001
3313
|
*/
|
|
3002
|
-
orWhereNot(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
3003
|
-
orWhereNot(column: SelectableColumn<string>, value: BaseValues$2): this;
|
|
3314
|
+
orWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
|
|
3315
|
+
orWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
|
|
3004
3316
|
/**
|
|
3005
3317
|
* @description Adds a WHERE BETWEEN condition to the query.
|
|
3006
3318
|
*/
|
|
3007
|
-
whereBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3319
|
+
whereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3008
3320
|
/**
|
|
3009
3321
|
* @description Adds an AND WHERE BETWEEN condition to the query.
|
|
3010
3322
|
*/
|
|
3011
|
-
andWhereBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3323
|
+
andWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3012
3324
|
/**
|
|
3013
3325
|
* @description Adds an OR WHERE BETWEEN condition to the query.
|
|
3014
3326
|
*/
|
|
3015
|
-
orWhereBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3327
|
+
orWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3016
3328
|
/**
|
|
3017
3329
|
* @description Adds a WHERE NOT BETWEEN condition to the query.
|
|
3018
3330
|
*/
|
|
3019
|
-
whereNotBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3331
|
+
whereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3020
3332
|
/**
|
|
3021
3333
|
* @description Adds an AND WHERE NOT BETWEEN condition to the query.
|
|
3022
3334
|
*/
|
|
3023
|
-
andWhereNotBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3335
|
+
andWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3024
3336
|
/**
|
|
3025
3337
|
* @description Adds an OR WHERE NOT BETWEEN condition to the query.
|
|
3026
3338
|
*/
|
|
3027
|
-
orWhereNotBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3339
|
+
orWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
|
|
3028
3340
|
/**
|
|
3029
3341
|
* @description Adds a WHERE LIKE condition to the query.
|
|
3030
3342
|
*/
|
|
3031
|
-
whereLike(column: SelectableColumn<string>, value: string): this;
|
|
3343
|
+
whereLike(column: SelectableColumn$1<string>, value: string): this;
|
|
3032
3344
|
/**
|
|
3033
3345
|
* @description Adds an AND WHERE LIKE condition to the query.
|
|
3034
3346
|
*/
|
|
3035
|
-
andWhereLike(column: SelectableColumn<string>, value: string): this;
|
|
3347
|
+
andWhereLike(column: SelectableColumn$1<string>, value: string): this;
|
|
3036
3348
|
/**
|
|
3037
3349
|
* @description Adds an OR WHERE LIKE condition to the query.
|
|
3038
3350
|
*/
|
|
3039
|
-
orWhereLike(column: SelectableColumn<string>, value: string): this;
|
|
3351
|
+
orWhereLike(column: SelectableColumn$1<string>, value: string): this;
|
|
3040
3352
|
/**
|
|
3041
3353
|
* @description Adds a WHERE ILIKE condition to the query.
|
|
3042
3354
|
*/
|
|
3043
|
-
whereILike(column: SelectableColumn<string>, value: string): this;
|
|
3355
|
+
whereILike(column: SelectableColumn$1<string>, value: string): this;
|
|
3044
3356
|
/**
|
|
3045
3357
|
* @description Adds an AND WHERE ILIKE condition to the query.
|
|
3046
3358
|
*/
|
|
3047
|
-
andWhereILike(column: SelectableColumn<string>, value: string): this;
|
|
3359
|
+
andWhereILike(column: SelectableColumn$1<string>, value: string): this;
|
|
3048
3360
|
/**
|
|
3049
3361
|
* @description Adds an OR WHERE ILIKE condition to the query.
|
|
3050
3362
|
*/
|
|
3051
|
-
orWhereILike(column: SelectableColumn<string>, value: string): this;
|
|
3363
|
+
orWhereILike(column: SelectableColumn$1<string>, value: string): this;
|
|
3052
3364
|
/**
|
|
3053
3365
|
* @description Adds a WHERE NOT LIKE condition to the query.
|
|
3054
3366
|
*/
|
|
3055
|
-
whereNotLike(column: SelectableColumn<string>, value: string): this;
|
|
3367
|
+
whereNotLike(column: SelectableColumn$1<string>, value: string): this;
|
|
3056
3368
|
/**
|
|
3057
3369
|
* @description Adds an AND WHERE NOT LIKE condition to the query.
|
|
3058
3370
|
*/
|
|
3059
|
-
andWhereNotLike(column: SelectableColumn<string>, value: string): this;
|
|
3371
|
+
andWhereNotLike(column: SelectableColumn$1<string>, value: string): this;
|
|
3060
3372
|
/**
|
|
3061
3373
|
* @description Adds an OR WHERE NOT LIKE condition to the query.
|
|
3062
3374
|
*/
|
|
3063
|
-
orWhereNotLike(column: SelectableColumn<string>, value: string): this;
|
|
3375
|
+
orWhereNotLike(column: SelectableColumn$1<string>, value: string): this;
|
|
3064
3376
|
/**
|
|
3065
3377
|
* @description Adds a WHERE NOT ILIKE condition to the query.
|
|
3066
3378
|
*/
|
|
3067
|
-
whereNotILike(column: SelectableColumn<string>, value: string): this;
|
|
3379
|
+
whereNotILike(column: SelectableColumn$1<string>, value: string): this;
|
|
3068
3380
|
/**
|
|
3069
3381
|
* @description Adds an AND WHERE NOT ILIKE condition to the query.
|
|
3070
3382
|
*/
|
|
3071
|
-
andWhereNotILike(column: SelectableColumn<string>, value: string): this;
|
|
3383
|
+
andWhereNotILike(column: SelectableColumn$1<string>, value: string): this;
|
|
3072
3384
|
/**
|
|
3073
3385
|
* @description Adds an OR WHERE NOT ILIKE condition to the query.
|
|
3074
3386
|
*/
|
|
3075
|
-
orWhereNotILike(column: SelectableColumn<string>, value: string): this;
|
|
3387
|
+
orWhereNotILike(column: SelectableColumn$1<string>, value: string): this;
|
|
3076
3388
|
/**
|
|
3077
3389
|
* @description Adds a WHERE IN condition to the query.
|
|
3078
3390
|
*/
|
|
3079
|
-
whereIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
|
|
3391
|
+
whereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
|
|
3080
3392
|
/**
|
|
3081
3393
|
* @description Adds an AND WHERE IN condition to the query.
|
|
3082
3394
|
*/
|
|
3083
|
-
andWhereIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
|
|
3395
|
+
andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
|
|
3084
3396
|
/**
|
|
3085
3397
|
* @description Adds an OR WHERE IN condition to the query.
|
|
3086
3398
|
*/
|
|
3087
|
-
orWhereIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
|
|
3399
|
+
orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
|
|
3088
3400
|
/**
|
|
3089
3401
|
* @description Adds a WHERE NOT IN condition to the query.
|
|
3090
3402
|
*/
|
|
3091
|
-
whereNotIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
|
|
3403
|
+
whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
|
|
3092
3404
|
/**
|
|
3093
3405
|
* @description Adds an AND WHERE NOT IN condition to the query.
|
|
3094
3406
|
*/
|
|
3095
|
-
andWhereNotIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
|
|
3407
|
+
andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
|
|
3096
3408
|
/**
|
|
3097
3409
|
* @description Adds an OR WHERE NOT IN condition to the query.
|
|
3098
3410
|
*/
|
|
3099
|
-
orWhereNotIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
|
|
3411
|
+
orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
|
|
3100
3412
|
/**
|
|
3101
3413
|
* @description Adds a WHERE NULL condition to the query.
|
|
3102
3414
|
*/
|
|
3103
|
-
whereNull(column: SelectableColumn<string>): this;
|
|
3415
|
+
whereNull(column: SelectableColumn$1<string>): this;
|
|
3104
3416
|
/**
|
|
3105
3417
|
* @description Adds an AND WHERE NULL condition to the query.
|
|
3106
3418
|
*/
|
|
3107
|
-
andWhereNull(column: SelectableColumn<string>): this;
|
|
3419
|
+
andWhereNull(column: SelectableColumn$1<string>): this;
|
|
3108
3420
|
/**
|
|
3109
3421
|
* @description Adds an OR WHERE NULL condition to the query.
|
|
3110
3422
|
*/
|
|
3111
|
-
orWhereNull(column: SelectableColumn<string>): this;
|
|
3423
|
+
orWhereNull(column: SelectableColumn$1<string>): this;
|
|
3112
3424
|
/**
|
|
3113
3425
|
* @description Adds a WHERE NOT NULL condition to the query.
|
|
3114
3426
|
*/
|
|
3115
|
-
whereNotNull(column: SelectableColumn<string>): this;
|
|
3427
|
+
whereNotNull(column: SelectableColumn$1<string>): this;
|
|
3116
3428
|
/**
|
|
3117
3429
|
* @description Adds an AND WHERE NOT NULL condition to the query.
|
|
3118
3430
|
*/
|
|
3119
|
-
andWhereNotNull(column: SelectableColumn<string>): this;
|
|
3431
|
+
andWhereNotNull(column: SelectableColumn$1<string>): this;
|
|
3120
3432
|
/**
|
|
3121
3433
|
* @description Adds an OR WHERE NOT NULL condition to the query.
|
|
3122
3434
|
*/
|
|
3123
|
-
orWhereNotNull(column: SelectableColumn<string>): this;
|
|
3435
|
+
orWhereNotNull(column: SelectableColumn$1<string>): this;
|
|
3124
3436
|
/**
|
|
3125
3437
|
* @description Adds a WHERE REGEXP condition to the query.
|
|
3126
3438
|
*/
|
|
3127
|
-
whereRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
|
|
3439
|
+
whereRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
|
|
3128
3440
|
/**
|
|
3129
3441
|
* @description Adds an AND WHERE REGEXP condition to the query.
|
|
3130
3442
|
*/
|
|
3131
|
-
andWhereRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
|
|
3443
|
+
andWhereRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
|
|
3132
3444
|
/**
|
|
3133
3445
|
* @description Adds an OR WHERE REGEXP condition to the query.
|
|
3134
3446
|
*/
|
|
3135
|
-
orWhereRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
|
|
3447
|
+
orWhereRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
|
|
3136
3448
|
/**
|
|
3137
3449
|
* @description Adds a WHERE NOT REGEXP condition to the query.
|
|
3138
3450
|
*/
|
|
3139
|
-
whereNotRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
|
|
3451
|
+
whereNotRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
|
|
3140
3452
|
/**
|
|
3141
3453
|
* @description Adds an AND WHERE NOT REGEXP condition to the query.
|
|
3142
3454
|
*/
|
|
3143
|
-
andWhereNotRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
|
|
3455
|
+
andWhereNotRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
|
|
3144
3456
|
/**
|
|
3145
3457
|
* @description Adds an OR WHERE NOT REGEXP condition to the query.
|
|
3146
3458
|
*/
|
|
3147
|
-
orWhereNotRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
|
|
3459
|
+
orWhereNotRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
|
|
3148
3460
|
/**
|
|
3149
3461
|
* @description Adds a WHERE group condition with AND.
|
|
3150
3462
|
*/
|
|
@@ -3295,7 +3607,7 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
|
|
|
3295
3607
|
* .select(["id", "userId"], ["name", "userName"]) // Columns with aliases
|
|
3296
3608
|
* .select("id", ["name", "userName"]) // Mixed
|
|
3297
3609
|
*/
|
|
3298
|
-
select<C extends string>(...columns: (SelectableColumn<C> | Selectable)[]): this;
|
|
3610
|
+
select<C extends string>(...columns: (SelectableColumn$1<C> | Selectable)[]): this;
|
|
3299
3611
|
select(...columns: (ModelKey<T> | "*" | Selectable)[]): this;
|
|
3300
3612
|
/**
|
|
3301
3613
|
* @description Adds a raw SELECT statement to the query
|
|
@@ -3342,29 +3654,54 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
|
|
|
3342
3654
|
* @postgresql Only usable with PostgreSQL
|
|
3343
3655
|
*/
|
|
3344
3656
|
distinctOn(...columns: ModelKey<T>[]): this;
|
|
3345
|
-
distinctOn<C extends string>(...columns: SelectableColumn<C>[]): this;
|
|
3657
|
+
distinctOn<C extends string>(...columns: SelectableColumn$1<C>[]): this;
|
|
3346
3658
|
/**
|
|
3347
|
-
* @description Selects a JSON value at the specified path and returns it as JSON
|
|
3659
|
+
* @description Selects a JSON value at the specified path and returns it as JSON.
|
|
3660
|
+
* @description Path format is standardized across all databases — the ORM converts to DB-specific syntax.
|
|
3661
|
+
* @param column - The column containing JSON data (model column name or raw string).
|
|
3662
|
+
* @param path - The JSON path to extract. Accepts dot notation (`"user.name"`), `$`-prefixed
|
|
3663
|
+
* paths (`"$.user.name"`), or an array of segments (`["user", "name"]`).
|
|
3664
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
3665
|
+
* @param alias - The alias for the extracted value in the result set.
|
|
3348
3666
|
*/
|
|
3349
|
-
selectJson<A extends string>(column:
|
|
3667
|
+
selectJson<K extends ModelKey<T>, A extends string>(column: K, path: TypedJsonPathInput<ResolveColumnType<T, K & string>>, alias: A): this;
|
|
3350
3668
|
selectJson<A extends string>(column: string, path: JsonPathInput, alias: A): this;
|
|
3351
3669
|
/**
|
|
3352
|
-
* @description Selects a JSON value at the specified path and returns it as text
|
|
3670
|
+
* @description Selects a JSON value at the specified path and returns it as text.
|
|
3671
|
+
* @description Path format is standardized across all databases — the ORM converts to DB-specific syntax.
|
|
3672
|
+
* @param column - The column containing JSON data (model column name or raw string).
|
|
3673
|
+
* @param path - The JSON path to extract. Accepts dot notation (`"user.name"`), `$`-prefixed
|
|
3674
|
+
* paths (`"$.user.name"`), or an array of segments (`["user", "name"]`).
|
|
3675
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
3676
|
+
* @param alias - The alias for the extracted text value in the result set.
|
|
3353
3677
|
*/
|
|
3354
|
-
selectJsonText<A extends string>(column:
|
|
3678
|
+
selectJsonText<K extends ModelKey<T>, A extends string>(column: K, path: TypedJsonPathInput<ResolveColumnType<T, K & string>>, alias: A): this;
|
|
3355
3679
|
selectJsonText<A extends string>(column: string, path: JsonPathInput, alias: A): this;
|
|
3356
3680
|
/**
|
|
3357
|
-
* @description Selects the length of a JSON array
|
|
3681
|
+
* @description Selects the length of a JSON array at the specified path.
|
|
3682
|
+
* @description Path format is standardized across all databases — the ORM converts to DB-specific syntax.
|
|
3683
|
+
* @param column - The column containing JSON array data (model column name or raw string).
|
|
3684
|
+
* @param path - The JSON path to the array. Use `"$"` or `""` for the root array.
|
|
3685
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
3686
|
+
* @param alias - The alias for the array length value in the result set.
|
|
3358
3687
|
*/
|
|
3359
|
-
selectJsonArrayLength<A extends string>(column:
|
|
3688
|
+
selectJsonArrayLength<K extends ModelKey<T>, A extends string>(column: K, path: TypedJsonPathInput<ResolveColumnType<T, K & string>>, alias: A): this;
|
|
3360
3689
|
selectJsonArrayLength<A extends string>(column: string, path: JsonPathInput, alias: A): this;
|
|
3361
3690
|
/**
|
|
3362
|
-
* @description Selects the keys of a JSON object
|
|
3691
|
+
* @description Selects the keys of a JSON object at the specified path.
|
|
3692
|
+
* @description Path format is standardized across all databases — the ORM converts to DB-specific syntax.
|
|
3693
|
+
* @param column - The column containing JSON object data (model column name or raw string).
|
|
3694
|
+
* @param path - The JSON path to the object. Use `"$"` or `""` for the root object.
|
|
3695
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
3696
|
+
* @param alias - The alias for the keys array in the result set.
|
|
3363
3697
|
*/
|
|
3364
|
-
selectJsonKeys<A extends string>(column:
|
|
3698
|
+
selectJsonKeys<K extends ModelKey<T>, A extends string>(column: K, path: TypedJsonPathInput<ResolveColumnType<T, K & string>>, alias: A): this;
|
|
3365
3699
|
selectJsonKeys<A extends string>(column: string, path: JsonPathInput, alias: A): this;
|
|
3366
3700
|
/**
|
|
3367
|
-
* @description Adds a raw JSON select expression
|
|
3701
|
+
* @description Adds a raw JSON select expression using database-specific SQL syntax.
|
|
3702
|
+
* @description Bypasses path standardization — you must write DB-specific SQL.
|
|
3703
|
+
* @param raw - The raw SQL expression (e.g., `"data->>'email'"` for PostgreSQL).
|
|
3704
|
+
* @param alias - The alias for the result in the result set.
|
|
3368
3705
|
*/
|
|
3369
3706
|
selectJsonRaw<A extends string>(raw: string, alias: A): this;
|
|
3370
3707
|
}
|
|
@@ -3498,62 +3835,62 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
|
|
|
3498
3835
|
* @description Adds a WHERE LIKE condition to the query.
|
|
3499
3836
|
*/
|
|
3500
3837
|
whereLike(column: ModelKey<T>, value: string): this;
|
|
3501
|
-
whereLike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3838
|
+
whereLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3502
3839
|
/**
|
|
3503
3840
|
* @description Adds an AND WHERE LIKE condition to the query.
|
|
3504
3841
|
*/
|
|
3505
3842
|
andWhereLike(column: ModelKey<T>, value: string): this;
|
|
3506
|
-
andWhereLike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3843
|
+
andWhereLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3507
3844
|
/**
|
|
3508
3845
|
* @description Adds an OR WHERE LIKE condition to the query.
|
|
3509
3846
|
*/
|
|
3510
3847
|
orWhereLike(column: ModelKey<T>, value: string): this;
|
|
3511
|
-
orWhereLike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3848
|
+
orWhereLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3512
3849
|
/**
|
|
3513
3850
|
* @description Adds a WHERE ILIKE condition to the query.
|
|
3514
3851
|
*/
|
|
3515
3852
|
whereILike(column: ModelKey<T>, value: string): this;
|
|
3516
|
-
whereILike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3853
|
+
whereILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3517
3854
|
/**
|
|
3518
3855
|
* @description Adds an AND WHERE ILIKE condition to the query.
|
|
3519
3856
|
*/
|
|
3520
3857
|
andWhereILike(column: ModelKey<T>, value: string): this;
|
|
3521
|
-
andWhereILike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3858
|
+
andWhereILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3522
3859
|
/**
|
|
3523
3860
|
* @description Adds an OR WHERE ILIKE condition to the query.
|
|
3524
3861
|
*/
|
|
3525
3862
|
orWhereILike(column: ModelKey<T>, value: string): this;
|
|
3526
|
-
orWhereILike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3863
|
+
orWhereILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3527
3864
|
/**
|
|
3528
3865
|
* @description Adds a WHERE NOT LIKE condition to the query.
|
|
3529
3866
|
*/
|
|
3530
3867
|
whereNotLike(column: ModelKey<T>, value: string): this;
|
|
3531
|
-
whereNotLike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3868
|
+
whereNotLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3532
3869
|
/**
|
|
3533
3870
|
* @description Adds an AND WHERE NOT LIKE condition to the query.
|
|
3534
3871
|
*/
|
|
3535
3872
|
andWhereNotLike(column: ModelKey<T>, value: string): this;
|
|
3536
|
-
andWhereNotLike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3873
|
+
andWhereNotLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3537
3874
|
/**
|
|
3538
3875
|
* @description Adds an OR WHERE NOT LIKE condition to the query.
|
|
3539
3876
|
*/
|
|
3540
3877
|
orWhereNotLike(column: ModelKey<T>, value: string): this;
|
|
3541
|
-
orWhereNotLike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3878
|
+
orWhereNotLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3542
3879
|
/**
|
|
3543
3880
|
* @description Adds a WHERE NOT ILIKE condition to the query.
|
|
3544
3881
|
*/
|
|
3545
3882
|
whereNotILike(column: ModelKey<T>, value: string): this;
|
|
3546
|
-
whereNotILike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3883
|
+
whereNotILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3547
3884
|
/**
|
|
3548
3885
|
* @description Adds an AND WHERE NOT ILIKE condition to the query.
|
|
3549
3886
|
*/
|
|
3550
3887
|
andWhereNotILike(column: ModelKey<T>, value: string): this;
|
|
3551
|
-
andWhereNotILike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3888
|
+
andWhereNotILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3552
3889
|
/**
|
|
3553
3890
|
* @description Adds an OR WHERE NOT ILIKE condition to the query.
|
|
3554
3891
|
*/
|
|
3555
3892
|
orWhereNotILike(column: ModelKey<T>, value: string): this;
|
|
3556
|
-
orWhereNotILike<S extends string>(column: SelectableColumn<S>, value: string): this;
|
|
3893
|
+
orWhereNotILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
|
|
3557
3894
|
/**
|
|
3558
3895
|
* @description Adds a WHERE IN condition to the query.
|
|
3559
3896
|
* @warning If the array is empty, it will add an impossible condition.
|
|
@@ -3600,74 +3937,74 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
|
|
|
3600
3937
|
* @description Adds a WHERE NULL condition to the query.
|
|
3601
3938
|
*/
|
|
3602
3939
|
whereNull(column: ModelKey<T>): this;
|
|
3603
|
-
whereNull<S extends string>(column: SelectableColumn<S>): this;
|
|
3940
|
+
whereNull<S extends string>(column: SelectableColumn$1<S>): this;
|
|
3604
3941
|
/**
|
|
3605
3942
|
* @description Adds an AND WHERE NULL condition to the query.
|
|
3606
3943
|
*/
|
|
3607
3944
|
andWhereNull(column: ModelKey<T>): this;
|
|
3608
|
-
andWhereNull<S extends string>(column: SelectableColumn<S>): this;
|
|
3945
|
+
andWhereNull<S extends string>(column: SelectableColumn$1<S>): this;
|
|
3609
3946
|
/**
|
|
3610
3947
|
* @description Adds an OR WHERE NULL condition to the query.
|
|
3611
3948
|
*/
|
|
3612
3949
|
orWhereNull(column: ModelKey<T>): this;
|
|
3613
|
-
orWhereNull<S extends string>(column: SelectableColumn<S>): this;
|
|
3950
|
+
orWhereNull<S extends string>(column: SelectableColumn$1<S>): this;
|
|
3614
3951
|
/**
|
|
3615
3952
|
* @description Adds a WHERE NOT NULL condition to the query.
|
|
3616
3953
|
*/
|
|
3617
3954
|
whereNotNull(column: ModelKey<T>): this;
|
|
3618
|
-
whereNotNull<S extends string>(column: SelectableColumn<S>): this;
|
|
3955
|
+
whereNotNull<S extends string>(column: SelectableColumn$1<S>): this;
|
|
3619
3956
|
/**
|
|
3620
3957
|
* @description Adds an AND WHERE NOT NULL condition to the query.
|
|
3621
3958
|
*/
|
|
3622
3959
|
andWhereNotNull(column: ModelKey<T>): this;
|
|
3623
|
-
andWhereNotNull<S extends string>(column: SelectableColumn<S>): this;
|
|
3960
|
+
andWhereNotNull<S extends string>(column: SelectableColumn$1<S>): this;
|
|
3624
3961
|
/**
|
|
3625
3962
|
* @description Adds an OR WHERE NOT NULL condition to the query.
|
|
3626
3963
|
*/
|
|
3627
3964
|
orWhereNotNull(column: ModelKey<T>): this;
|
|
3628
|
-
orWhereNotNull<S extends string>(column: SelectableColumn<S>): this;
|
|
3965
|
+
orWhereNotNull<S extends string>(column: SelectableColumn$1<S>): this;
|
|
3629
3966
|
/**
|
|
3630
3967
|
* @description Adds a WHERE REGEXP condition to the query.
|
|
3631
3968
|
* @mssql doesn't support REGEXP syntax
|
|
3632
3969
|
* @sqlite doesn't support REGEXP syntax
|
|
3633
3970
|
*/
|
|
3634
3971
|
whereRegexp(column: ModelKey<T>, regexp: RegExp): this;
|
|
3635
|
-
whereRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
|
|
3972
|
+
whereRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
|
|
3636
3973
|
/**
|
|
3637
3974
|
* @description Adds an AND WHERE REGEXP condition to the query.
|
|
3638
3975
|
* @mssql doesn't support REGEXP syntax
|
|
3639
3976
|
* @sqlite doesn't support REGEXP syntax
|
|
3640
3977
|
*/
|
|
3641
3978
|
andWhereRegexp(column: ModelKey<T>, regexp: RegExp): this;
|
|
3642
|
-
andWhereRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
|
|
3979
|
+
andWhereRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
|
|
3643
3980
|
/**
|
|
3644
3981
|
* @description Adds an OR WHERE REGEXP condition to the query.
|
|
3645
3982
|
* @mssql doesn't support REGEXP syntax
|
|
3646
3983
|
* @sqlite doesn't support REGEXP syntax
|
|
3647
3984
|
*/
|
|
3648
3985
|
orWhereRegexp(column: ModelKey<T>, regexp: RegExp): this;
|
|
3649
|
-
orWhereRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
|
|
3986
|
+
orWhereRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
|
|
3650
3987
|
/**
|
|
3651
3988
|
* @description Adds a WHERE NOT REGEXP condition to the query.
|
|
3652
3989
|
* @mssql doesn't support REGEXP syntax
|
|
3653
3990
|
* @sqlite doesn't support REGEXP syntax
|
|
3654
3991
|
*/
|
|
3655
3992
|
whereNotRegexp(column: ModelKey<T>, regexp: RegExp): this;
|
|
3656
|
-
whereNotRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
|
|
3993
|
+
whereNotRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
|
|
3657
3994
|
/**
|
|
3658
3995
|
* @description Adds an AND WHERE NOT REGEXP condition to the query.
|
|
3659
3996
|
* @mssql doesn't support REGEXP syntax
|
|
3660
3997
|
* @sqlite doesn't support REGEXP syntax
|
|
3661
3998
|
*/
|
|
3662
3999
|
andWhereNotRegexp(column: ModelKey<T>, regexp: RegExp): this;
|
|
3663
|
-
andWhereNotRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
|
|
4000
|
+
andWhereNotRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
|
|
3664
4001
|
/**
|
|
3665
4002
|
* @description Adds an OR WHERE NOT REGEXP condition to the query.
|
|
3666
4003
|
* @mssql doesn't support REGEXP syntax
|
|
3667
4004
|
* @sqlite doesn't support REGEXP syntax
|
|
3668
4005
|
*/
|
|
3669
4006
|
orWhereNotRegexp(column: ModelKey<T>, regexp: RegExp): this;
|
|
3670
|
-
orWhereNotRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
|
|
4007
|
+
orWhereNotRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
|
|
3671
4008
|
/**
|
|
3672
4009
|
* @description Adds a AND WHERE EXISTS condition to the query. By default uses the same table, you can use the `from` method to change the table.
|
|
3673
4010
|
*/
|
|
@@ -3838,8 +4175,7 @@ declare class JsonQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
3838
4175
|
/**
|
|
3839
4176
|
* @description Minimal interface satisfied by both QueryBuilder and ModelQueryBuilder.
|
|
3840
4177
|
* Used as the return type for subquery callbacks so that both QB and MQB can be
|
|
3841
|
-
* returned without TypeScript complaining about structural incompatibilities
|
|
3842
|
-
* the `performance` property.
|
|
4178
|
+
* returned without TypeScript complaining about structural incompatibilities.
|
|
3843
4179
|
*/
|
|
3844
4180
|
interface SubQueryable {
|
|
3845
4181
|
extractQueryNodes(): QueryNode[];
|
|
@@ -3859,63 +4195,6 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
|
|
|
3859
4195
|
protected deleteNode: DeleteNode | null;
|
|
3860
4196
|
protected truncateNode: TruncateNode | null;
|
|
3861
4197
|
protected replicationMode: ReplicationType | null;
|
|
3862
|
-
/**
|
|
3863
|
-
* @description Performance methods that return the time that took to execute the query with the result
|
|
3864
|
-
*/
|
|
3865
|
-
performance: {
|
|
3866
|
-
many: (returnType?: "millis" | "seconds") => Promise<{
|
|
3867
|
-
data: S[];
|
|
3868
|
-
time: number;
|
|
3869
|
-
}>;
|
|
3870
|
-
one: (returnType?: "millis" | "seconds") => Promise<{
|
|
3871
|
-
data: S | null;
|
|
3872
|
-
time: number;
|
|
3873
|
-
}>;
|
|
3874
|
-
oneOrFail: (returnType?: "millis" | "seconds") => Promise<{
|
|
3875
|
-
data: S;
|
|
3876
|
-
time: number;
|
|
3877
|
-
}>;
|
|
3878
|
-
paginate: (page: number, perPage: number, returnType?: "millis" | "seconds") => Promise<{
|
|
3879
|
-
data: RawPaginatedData<S>;
|
|
3880
|
-
time: number;
|
|
3881
|
-
}>;
|
|
3882
|
-
paginateWithCursor: (page: number, options: PaginateWithCursorOptions<T, ModelKey<T>>, cursor?: Cursor<T, ModelKey<T>>, returnType?: "millis" | "seconds") => Promise<{
|
|
3883
|
-
data: [RawCursorPaginatedData<S>, Cursor<T, ModelKey<T>>];
|
|
3884
|
-
time: number;
|
|
3885
|
-
}>;
|
|
3886
|
-
exists: (returnType?: "millis" | "seconds") => Promise<{
|
|
3887
|
-
data: boolean;
|
|
3888
|
-
time: number;
|
|
3889
|
-
}>;
|
|
3890
|
-
truncate: (returnType?: "millis" | "seconds") => Promise<{
|
|
3891
|
-
data: void;
|
|
3892
|
-
time: number;
|
|
3893
|
-
}>;
|
|
3894
|
-
delete: (returnType?: "millis" | "seconds") => Promise<{
|
|
3895
|
-
data: any;
|
|
3896
|
-
time: number;
|
|
3897
|
-
}>;
|
|
3898
|
-
insert: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
|
|
3899
|
-
data: void;
|
|
3900
|
-
time: number;
|
|
3901
|
-
}>;
|
|
3902
|
-
insertMany: (data: Record<string, any>[], returnType?: "millis" | "seconds") => Promise<{
|
|
3903
|
-
data: void;
|
|
3904
|
-
time: number;
|
|
3905
|
-
}>;
|
|
3906
|
-
update: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
|
|
3907
|
-
data: any;
|
|
3908
|
-
time: number;
|
|
3909
|
-
}>;
|
|
3910
|
-
softDelete: (options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">, returnType?: "millis" | "seconds") => Promise<{
|
|
3911
|
-
data: number;
|
|
3912
|
-
time: number;
|
|
3913
|
-
}>;
|
|
3914
|
-
pluck: (key: RawModelKey<T>, returnType?: "millis" | "seconds") => Promise<{
|
|
3915
|
-
data: PluckReturnType<T, RawModelKey<T>>;
|
|
3916
|
-
time: number;
|
|
3917
|
-
}>;
|
|
3918
|
-
};
|
|
3919
4198
|
constructor(model: typeof Model, sqlDataSource: SqlDataSource);
|
|
3920
4199
|
/**
|
|
3921
4200
|
* @description Sets the replication mode for the query builder
|
|
@@ -4265,36 +4544,6 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
|
|
|
4265
4544
|
clearWithQuery(): this;
|
|
4266
4545
|
extractQueryNodes(): QueryNode[];
|
|
4267
4546
|
protected clearForFunctions(): this;
|
|
4268
|
-
/**
|
|
4269
|
-
* @description Makes a many query and returns the time that took to execute that query
|
|
4270
|
-
*/
|
|
4271
|
-
private manyWithPerformance;
|
|
4272
|
-
/**
|
|
4273
|
-
* @description Makes a one query and returns the time that took to execute that query
|
|
4274
|
-
*/
|
|
4275
|
-
private oneWithPerformance;
|
|
4276
|
-
/**
|
|
4277
|
-
* @alias oneOrFailWithPerformance
|
|
4278
|
-
*/
|
|
4279
|
-
private firstOrFailWithPerformance;
|
|
4280
|
-
private paginateWithPerformance;
|
|
4281
|
-
private paginateWithCursorWithPerformance;
|
|
4282
|
-
/**
|
|
4283
|
-
* @description Makes a one or fail query and returns the time that took to execute that query
|
|
4284
|
-
*/
|
|
4285
|
-
private oneOrFailWithPerformance;
|
|
4286
|
-
/**
|
|
4287
|
-
* @description Executes the query and returns true if the query returns at least one result, false otherwise.
|
|
4288
|
-
* @description Returns the time that took to execute the query
|
|
4289
|
-
*/
|
|
4290
|
-
private existsWithPerformance;
|
|
4291
|
-
private pluckWithPerformance;
|
|
4292
|
-
private updateWithPerformance;
|
|
4293
|
-
private insertWithPerformance;
|
|
4294
|
-
private insertManyWithPerformance;
|
|
4295
|
-
private softDeleteWithPerformance;
|
|
4296
|
-
private deleteWithPerformance;
|
|
4297
|
-
private truncateWithPerformance;
|
|
4298
4547
|
/**
|
|
4299
4548
|
* @description Checks if the current context is an MSSQL transaction
|
|
4300
4549
|
* @description MSSQL transactions can only handle one request at a time
|
|
@@ -4448,6 +4697,41 @@ declare class Transaction {
|
|
|
4448
4697
|
private getMssqlTransactionLevel;
|
|
4449
4698
|
}
|
|
4450
4699
|
|
|
4700
|
+
type Operation = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "OTHER";
|
|
4701
|
+
interface QueryContext {
|
|
4702
|
+
sql: string;
|
|
4703
|
+
params: any[];
|
|
4704
|
+
model?: any;
|
|
4705
|
+
operation?: string;
|
|
4706
|
+
timestamp: number;
|
|
4707
|
+
}
|
|
4708
|
+
/**
|
|
4709
|
+
* Query context extended with execution metadata.
|
|
4710
|
+
* @property duration - Query execution time in milliseconds (ms)
|
|
4711
|
+
*/
|
|
4712
|
+
type QueryContextWithDuration = QueryContext & {
|
|
4713
|
+
duration: number;
|
|
4714
|
+
result?: any;
|
|
4715
|
+
};
|
|
4716
|
+
interface QueryObserver {
|
|
4717
|
+
onBeforeQuery?(ctx: QueryContext): Promise<void> | void;
|
|
4718
|
+
onAfterQuery?(ctx: QueryContextWithDuration): Promise<void> | void;
|
|
4719
|
+
onQueryError?(ctx: QueryContext & {
|
|
4720
|
+
error: Error;
|
|
4721
|
+
}): Promise<void> | void;
|
|
4722
|
+
}
|
|
4723
|
+
declare class ObserverChain {
|
|
4724
|
+
private observers;
|
|
4725
|
+
constructor(observers?: QueryObserver[]);
|
|
4726
|
+
add(observer: QueryObserver): void;
|
|
4727
|
+
notifyBefore(ctx: QueryContext): Promise<void>;
|
|
4728
|
+
notifyAfter(ctx: QueryContextWithDuration, result?: any): Promise<void>;
|
|
4729
|
+
notifyError(ctx: QueryContext & {
|
|
4730
|
+
error: Error;
|
|
4731
|
+
}): Promise<void>;
|
|
4732
|
+
}
|
|
4733
|
+
declare const deriveOperationFromQuery: (sql: string) => string;
|
|
4734
|
+
|
|
4451
4735
|
declare const SQL_DATA_SOURCE_SYMBOL: unique symbol;
|
|
4452
4736
|
/**
|
|
4453
4737
|
* @description The SqlDataSource class is the main class for interacting with the database, it's used to create connections, execute queries, and manage transactions
|
|
@@ -4541,6 +4825,10 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
4541
4825
|
path: string;
|
|
4542
4826
|
tsconfig?: string;
|
|
4543
4827
|
};
|
|
4828
|
+
/**
|
|
4829
|
+
* Optional observer chain for query middleware. See src/sql/observers for details.
|
|
4830
|
+
*/
|
|
4831
|
+
observerChain?: ObserverChain;
|
|
4544
4832
|
/**
|
|
4545
4833
|
* @description AdminJS configuration options
|
|
4546
4834
|
*/
|
|
@@ -4553,10 +4841,26 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
4553
4841
|
* @description Callback to handle slave server failures
|
|
4554
4842
|
*/
|
|
4555
4843
|
private onSlaveServerFailure?;
|
|
4844
|
+
private lazyLoad;
|
|
4845
|
+
private connecting;
|
|
4556
4846
|
/**
|
|
4557
4847
|
* @description Returns the configured slave failure callback
|
|
4558
4848
|
*/
|
|
4559
4849
|
getOnSlaveServerFailure(): ((error: Error, context: SlaveContext) => void | Promise<void>) | undefined;
|
|
4850
|
+
/**
|
|
4851
|
+
* @description Add a single observer to the query middleware chain.
|
|
4852
|
+
* Can be called multiple times to add multiple observers.
|
|
4853
|
+
* @param observer A QueryObserver with onBeforeQuery, onAfterQuery, and/or onQueryError handlers
|
|
4854
|
+
* @example
|
|
4855
|
+
* ```ts
|
|
4856
|
+
* sql.addObserver({
|
|
4857
|
+
* onBeforeQuery: (ctx) => console.log("Before:", ctx.sql),
|
|
4858
|
+
* onAfterQuery: (ctx) => console.log("After:", ctx.sql),
|
|
4859
|
+
* onQueryError: (ctx) => console.log("Error:", ctx.sql)
|
|
4860
|
+
* });
|
|
4861
|
+
* ```
|
|
4862
|
+
*/
|
|
4863
|
+
addObserver(observer: QueryObserver): this;
|
|
4560
4864
|
/**
|
|
4561
4865
|
* @description Creates a new SqlDataSource instance. Call `.connect()` to establish the connection.
|
|
4562
4866
|
* @param input Configuration options for the database connection. If not provided, uses env variables.
|
|
@@ -4607,6 +4911,10 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
4607
4911
|
* @description Returns true if the connection is established
|
|
4608
4912
|
*/
|
|
4609
4913
|
get isConnected(): boolean;
|
|
4914
|
+
/**
|
|
4915
|
+
* @description Ensures the connection is established. If lazyLoad is true and not connected, connects automatically.
|
|
4916
|
+
*/
|
|
4917
|
+
ensureConnected(): Promise<void>;
|
|
4610
4918
|
/**
|
|
4611
4919
|
* @description Returns true if this instance is in a global transaction
|
|
4612
4920
|
*/
|
|
@@ -4753,6 +5061,11 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
4753
5061
|
* @description Returns the connection details
|
|
4754
5062
|
*/
|
|
4755
5063
|
getConnectionDetails(): SqlDataSourceInput<D, T, C>;
|
|
5064
|
+
/**
|
|
5065
|
+
* @description Introspects database schema and returns a basic introspection structure.
|
|
5066
|
+
* This is a scaffold for dialect-aware introspection to be expanded.
|
|
5067
|
+
*/
|
|
5068
|
+
introspectSchema(): Promise<IntrospectedSchema[]>;
|
|
4756
5069
|
/**
|
|
4757
5070
|
* @description Syncs the schema of the database with the models metadata
|
|
4758
5071
|
* @warning This will drop and recreate all the indexes and constraints, use with caution
|
|
@@ -4846,6 +5159,15 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
|
|
|
4846
5159
|
* @returns true if lock was acquired, false otherwise
|
|
4847
5160
|
*/
|
|
4848
5161
|
acquireLock(lockKey?: string, timeoutMs?: number): Promise<boolean>;
|
|
5162
|
+
/**
|
|
5163
|
+
* @description Executes a lightweight health check query
|
|
5164
|
+
* @returns Promise resolving to PingResult with ok status, latency in ms, and dialect
|
|
5165
|
+
*/
|
|
5166
|
+
ping(): Promise<PingResult>;
|
|
5167
|
+
/**
|
|
5168
|
+
* @description Returns true if the database connection is healthy, false on error (never throws)
|
|
5169
|
+
*/
|
|
5170
|
+
isHealthy(): Promise<boolean>;
|
|
4849
5171
|
/**
|
|
4850
5172
|
* @description Releases an advisory lock
|
|
4851
5173
|
* @param lockKey - The lock identifier (defaults to 'hysteria_lock')
|
|
@@ -5044,7 +5366,7 @@ type RelatedInstance<M extends Model, K extends ModelRelation<M>> = NonNullable<
|
|
|
5044
5366
|
*
|
|
5045
5367
|
* @internal
|
|
5046
5368
|
*/
|
|
5047
|
-
type UnionToIntersection
|
|
5369
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
5048
5370
|
/**
|
|
5049
5371
|
* Represents valid string column selection formats with intellisense support.
|
|
5050
5372
|
* Use [column, alias] tuple format for aliases instead of "column as alias".
|
|
@@ -5066,7 +5388,7 @@ type UnionToIntersection$1<U> = (U extends any ? (k: U) => void : never) extends
|
|
|
5066
5388
|
* "*" // All columns
|
|
5067
5389
|
* );
|
|
5068
5390
|
*/
|
|
5069
|
-
type SelectableColumn
|
|
5391
|
+
type SelectableColumn<T extends Model> = ModelKey<T> | `${string}.${string | "*"}` | "*";
|
|
5070
5392
|
/**
|
|
5071
5393
|
* A tuple type for selecting a column with an alias in ModelQueryBuilder.
|
|
5072
5394
|
* @example ["id", "userId"] selects "id" column as "userId"
|
|
@@ -5081,7 +5403,7 @@ type ModelSelectTuple<T extends Model, C extends ModelKey<T> | `${string}.${stri
|
|
|
5081
5403
|
* .select(["id", "userId"], ["name", "userName"]) // Columns with aliases
|
|
5082
5404
|
* .select("id", ["name", "userName"]) // Mixed
|
|
5083
5405
|
*/
|
|
5084
|
-
type ModelSelectableInput<T extends Model> = SelectableColumn
|
|
5406
|
+
type ModelSelectableInput<T extends Model> = SelectableColumn<T> | ModelSelectTuple<T>;
|
|
5085
5407
|
/**
|
|
5086
5408
|
* Extracts the final property name from a column selection.
|
|
5087
5409
|
* Supports both string columns and [column, alias] tuples.
|
|
@@ -5199,7 +5521,7 @@ type SelectBrand = {
|
|
|
5199
5521
|
* BuildSelectType<User, ["*"]>
|
|
5200
5522
|
* // Result: ModelWithoutRelations<User> (all columns)
|
|
5201
5523
|
*/
|
|
5202
|
-
type BuildSelectType<T extends Model, Columns extends readonly (string | readonly [string, string])[]> = HasStarOrEmpty<Columns> extends true ? ModelWithoutRelations<T> : UnionToIntersection
|
|
5524
|
+
type BuildSelectType<T extends Model, Columns extends readonly (string | readonly [string, string])[]> = HasStarOrEmpty<Columns> extends true ? ModelWithoutRelations<T> : UnionToIntersection<{
|
|
5203
5525
|
[K in keyof Columns]: BuildSingleSelectType<T, Columns[K]>;
|
|
5204
5526
|
}[number]> extends infer Result ? Result extends Record<string, any> ? keyof Result extends never ? ModelWithoutRelations<T> : Result & ModelDataProperties & SelectBrand : ModelWithoutRelations<T> : ModelWithoutRelations<T>;
|
|
5205
5527
|
/**
|
|
@@ -5436,244 +5758,98 @@ type FindReturnType<T extends Model, S extends ModelKey<T>[] = any[], R extends
|
|
|
5436
5758
|
[K in R[number] & keyof T]: T[K];
|
|
5437
5759
|
} : {
|
|
5438
5760
|
[K in StripTablePrefix<S[number] & string> & keyof T]: T[K];
|
|
5439
|
-
} & {
|
|
5440
|
-
[K in R[number] & keyof T]: T[K];
|
|
5441
|
-
} : ModelWithoutRelations<T> & {
|
|
5442
|
-
[K in R[number] & keyof T]: T[K];
|
|
5443
|
-
};
|
|
5444
|
-
/**
|
|
5445
|
-
* Return type for write operations (insert/upsert) based on the returning columns.
|
|
5446
|
-
* - `undefined` or `[]` -> `void` (no data fetched)
|
|
5447
|
-
* - `["*"]` -> `ModelQueryResult<T>` (full model)
|
|
5448
|
-
* - `["col1", "col2"]` -> `{ col1: ...; col2: ... } & ModelDataProperties`
|
|
5449
|
-
*
|
|
5450
|
-
* @typeParam T - The Model type
|
|
5451
|
-
* @typeParam R - The returning columns array (literal tuple for type inference)
|
|
5452
|
-
*/
|
|
5453
|
-
type WriteReturnType<T extends Model, R extends ReturningColumns<T>> = R extends undefined ? void : R extends readonly [] ? void : R extends readonly ReturningKey<T>[] ? "*" extends R[number] ? ModelQueryResult<T> : {
|
|
5454
|
-
[K in R[number] & string & keyof T]: T[K];
|
|
5455
|
-
} & ModelDataProperties : never;
|
|
5456
|
-
|
|
5457
|
-
type PluckReturnType<T extends Model, K extends RawModelKey<T>> = T[StripTablePrefix<K & string> & keyof T] extends infer U ? U[] : never;
|
|
5458
|
-
/**
|
|
5459
|
-
* Common SQL functions with intellisense support.
|
|
5460
|
-
* Provides autocomplete for standard SQL aggregate and scalar functions,
|
|
5461
|
-
* while still allowing any custom function name via string fallback.
|
|
5462
|
-
*
|
|
5463
|
-
* @example
|
|
5464
|
-
* selectFunc("count", "*", "total") // Intellisense suggests "count"
|
|
5465
|
-
* selectFunc("custom_fn", "col", "res") // Custom functions still work
|
|
5466
|
-
*/
|
|
5467
|
-
type SqlFunction = "count" | "sum" | "avg" | "min" | "max" | "upper" | "lower" | "length" | "trim" | "abs" | "round" | "coalesce" | "ceil" | "floor" | "sqrt" | (string & {});
|
|
5468
|
-
/**
|
|
5469
|
-
* Maps SQL function names to their return types.
|
|
5470
|
-
* Used by selectFunc to auto-infer the result type.
|
|
5471
|
-
*
|
|
5472
|
-
* - Numeric functions (count, sum, avg, etc.) → number
|
|
5473
|
-
* - String functions (upper, lower, trim) → string
|
|
5474
|
-
* - Unknown functions → any
|
|
5475
|
-
*/
|
|
5476
|
-
type SqlFunctionReturnType<F extends string> = F extends "count" | "sum" | "avg" | "min" | "max" | "length" | "abs" | "round" | "ceil" | "floor" | "sqrt" ? number : F extends "upper" | "lower" | "trim" ? string : any;
|
|
5477
|
-
/**
|
|
5478
|
-
* A tuple type for selecting a column with an alias.
|
|
5479
|
-
* @example ["id", "userId"] selects "id" column as "userId"
|
|
5480
|
-
*/
|
|
5481
|
-
type SelectTuple<C extends string = string, A extends string = string> = readonly [column: C, alias: A];
|
|
5482
|
-
/**
|
|
5483
|
-
* Input type for select() method in raw query builder.
|
|
5484
|
-
* Accepts either a column string or a [column, alias] tuple.
|
|
5485
|
-
*
|
|
5486
|
-
* @example
|
|
5487
|
-
* .select("id", "name") // Simple columns
|
|
5488
|
-
* .select(["id", "userId"], ["name", "n"]) // Columns with aliases
|
|
5489
|
-
* .select("id", ["name", "userName"]) // Mixed
|
|
5490
|
-
*/
|
|
5491
|
-
type Selectable = string | SelectTuple;
|
|
5492
|
-
/**
|
|
5493
|
-
* Unique symbol used internally to mark that a raw select() has been called.
|
|
5494
|
-
*/
|
|
5495
|
-
declare const RAW_SELECT_BRAND: unique symbol;
|
|
5496
|
-
/**
|
|
5497
|
-
* Marker type to indicate that a raw select() has been called.
|
|
5498
|
-
* @internal
|
|
5499
|
-
*/
|
|
5500
|
-
type RawSelectBrand = {
|
|
5501
|
-
[RAW_SELECT_BRAND]?: never;
|
|
5761
|
+
} & {
|
|
5762
|
+
[K in R[number] & keyof T]: T[K];
|
|
5763
|
+
} : ModelWithoutRelations<T> & {
|
|
5764
|
+
[K in R[number] & keyof T]: T[K];
|
|
5502
5765
|
};
|
|
5503
5766
|
/**
|
|
5504
|
-
*
|
|
5505
|
-
*
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
/**
|
|
5509
|
-
* Extracts the final property name from a column selection for raw queries.
|
|
5510
|
-
* Supports both string columns and [column, alias] tuples.
|
|
5767
|
+
* Return type for write operations (insert/upsert) based on the returning columns.
|
|
5768
|
+
* - `undefined` or `[]` -> `void` (no data fetched)
|
|
5769
|
+
* - `["*"]` -> `ModelQueryResult<T>` (full model)
|
|
5770
|
+
* - `["col1", "col2"]` -> `{ col1: ...; col2: ... } & ModelDataProperties`
|
|
5511
5771
|
*
|
|
5512
|
-
*
|
|
5513
|
-
*
|
|
5514
|
-
* | `"name"` | `"name"` |
|
|
5515
|
-
* | `"users.name"` | `"name"` |
|
|
5516
|
-
* | `["name", "userName"]` | `"userName"` |
|
|
5517
|
-
* | `["users.id", "id"]` | `"id"` |
|
|
5518
|
-
* | `"*"` | `never` |
|
|
5519
|
-
* | `"users.*"` | `never` |
|
|
5772
|
+
* @typeParam T - The Model type
|
|
5773
|
+
* @typeParam R - The returning columns array (literal tuple for type inference)
|
|
5520
5774
|
*/
|
|
5521
|
-
type
|
|
5522
|
-
string
|
|
5523
|
-
|
|
5524
|
-
|
|
5775
|
+
type WriteReturnType<T extends Model, R extends ReturningColumns<T>> = R extends undefined ? void : R extends readonly [] ? void : R extends readonly ReturningKey<T>[] ? "*" extends R[number] ? ModelQueryResult<T> : {
|
|
5776
|
+
[K in R[number] & string & keyof T]: T[K];
|
|
5777
|
+
} & ModelDataProperties : never;
|
|
5778
|
+
|
|
5779
|
+
type JsonPathInput = string | (string | number)[];
|
|
5525
5780
|
/**
|
|
5526
|
-
*
|
|
5527
|
-
*
|
|
5528
|
-
* Supports both string columns and [column, alias] tuples.
|
|
5781
|
+
* Recursively generates all valid dot-separated JSON path strings from an
|
|
5782
|
+
* object type `T`.
|
|
5529
5783
|
*
|
|
5530
|
-
*
|
|
5531
|
-
*
|
|
5532
|
-
*
|
|
5533
|
-
* | `"table.*"` | `Record<string, any>` |
|
|
5534
|
-
* | `"column"` | `{ column: any }` |
|
|
5535
|
-
* | `["col", "alias"]` | `{ alias: any }` |
|
|
5784
|
+
* Handles nested objects, arrays (via numeric indices), and stops recursion at
|
|
5785
|
+
* a configurable depth (default 5) to prevent infinite expansion with deeply
|
|
5786
|
+
* nested or self-referential types.
|
|
5536
5787
|
*
|
|
5537
|
-
* @
|
|
5788
|
+
* @typeParam T - The root object type to extract paths from.
|
|
5789
|
+
*
|
|
5790
|
+
* @example
|
|
5791
|
+
* ```ts
|
|
5792
|
+
* type Data = { user: { name: string; roles: string[] }; count: number };
|
|
5793
|
+
* type P = JsonPaths<Data>;
|
|
5794
|
+
* // "user" | "user.name" | "user.roles" | "user.roles.${number}" | "count"
|
|
5795
|
+
* ```
|
|
5538
5796
|
*/
|
|
5539
|
-
type
|
|
5540
|
-
string,
|
|
5541
|
-
|
|
5542
|
-
] ? {
|
|
5543
|
-
[K in Alias]: any;
|
|
5544
|
-
} : S extends string ? S extends "*" ? Record<string, any> : S extends `${string}.*` ? Record<string, any> : ExtractRawColumnName<S> extends never ? {} : {
|
|
5545
|
-
[K in ExtractRawColumnName<S> & string]: any;
|
|
5546
|
-
} : {};
|
|
5797
|
+
type JsonPaths<T, Depth extends number[] = []> = Depth["length"] extends 5 ? never : T extends readonly (infer E)[] ? `${number}` | (NonNullable<E> extends object ? `${number}.${JsonPaths<NonNullable<E>, [...Depth, 1]>}` : never) : T extends object ? {
|
|
5798
|
+
[K in keyof T & string]: K | (NonNullable<T[K]> extends object ? `${K}.${JsonPaths<NonNullable<T[K]>, [...Depth, 1]>}` : never);
|
|
5799
|
+
}[keyof T & string] : never;
|
|
5547
5800
|
/**
|
|
5548
|
-
*
|
|
5549
|
-
*
|
|
5801
|
+
* Resolves the TypeScript type of a model column given its `ModelKey` string.
|
|
5802
|
+
* Strips any table prefix (e.g. `"users.metadata"` → `"metadata"`) before
|
|
5803
|
+
* indexing into the model.
|
|
5804
|
+
*
|
|
5805
|
+
* @typeParam T - The Model instance type.
|
|
5806
|
+
* @typeParam K - The column key (plain or table-prefixed).
|
|
5550
5807
|
*/
|
|
5551
|
-
type
|
|
5808
|
+
type ResolveColumnType<T extends Model, K extends string> = T[StripTablePrefix<K> & keyof T];
|
|
5552
5809
|
/**
|
|
5553
|
-
*
|
|
5554
|
-
*
|
|
5810
|
+
* Type-safe JSON path input that provides IDE autocompletion for known JSON
|
|
5811
|
+
* column structures while still accepting arbitrary strings as a fallback.
|
|
5555
5812
|
*
|
|
5556
|
-
*
|
|
5813
|
+
* - When `ColumnType` is a known object/array type: suggests all valid
|
|
5814
|
+
* dot-separated paths via {@link JsonPaths}, plus `(string & {})` as a
|
|
5815
|
+
* catch-all and `(string | number)[]` for the array form.
|
|
5816
|
+
* - When `ColumnType` is `unknown`, a primitive, or `never`: falls back to the
|
|
5817
|
+
* original untyped {@link JsonPathInput}.
|
|
5557
5818
|
*
|
|
5558
|
-
*
|
|
5559
|
-
*
|
|
5560
|
-
* 3. **With `table.*`**: Adds `Record<string, any>` to allow unknown properties
|
|
5819
|
+
* Uses the `SpecificLiteral | (string & {})` pattern so TypeScript's
|
|
5820
|
+
* autocomplete shows the known paths first without blocking custom strings.
|
|
5561
5821
|
*
|
|
5562
|
-
* @
|
|
5563
|
-
* // .select("name", ["age", "userAge"])
|
|
5564
|
-
* BuildRawSelectType<["name", ["age", "userAge"]]>
|
|
5565
|
-
* // Result: { name: any; userAge: any } & RawSelectBrand
|
|
5822
|
+
* @typeParam ColumnType - The TypeScript type of the JSON column value.
|
|
5566
5823
|
*
|
|
5567
5824
|
* @example
|
|
5568
|
-
*
|
|
5569
|
-
*
|
|
5570
|
-
*
|
|
5825
|
+
* ```ts
|
|
5826
|
+
* type Settings = { theme: string; notifications: { email: boolean } };
|
|
5827
|
+
* type P = TypedJsonPathInput<Settings | null>;
|
|
5828
|
+
* // "theme" | "notifications" | "notifications.email" | (string & {}) | (string | number)[]
|
|
5829
|
+
* ```
|
|
5571
5830
|
*/
|
|
5572
|
-
type BuildRawSelectType<Columns extends readonly Selectable[]> = HasRawStarOrEmpty<Columns> extends true ? Record<string, any> : UnionToIntersection<{
|
|
5573
|
-
[K in keyof Columns]: BuildRawSingleSelectType<Columns[K]>;
|
|
5574
|
-
}[number]> extends infer Result ? Result extends Record<string, any> ? keyof Result extends never ? Record<string, any> : Result & RawSelectBrand : Record<string, any> : Record<string, any>;
|
|
5575
5831
|
/**
|
|
5576
|
-
*
|
|
5577
|
-
*
|
|
5578
|
-
* - If S is the default Record<string, any> (no previous select), returns just the new selection
|
|
5579
|
-
* - If S is a typed selection from a prior select/selectRaw, composes with new selection
|
|
5580
|
-
*
|
|
5581
|
-
* Detection uses `string extends keyof S`: true for untyped `Record<string, any>`, false for any
|
|
5582
|
-
* specific typed record (e.g. `{ userName: any }`). This avoids relying on the RAW_SELECT_BRAND
|
|
5583
|
-
* symbol, which gets stripped by Simplify in intermediate types.
|
|
5832
|
+
* Resolves the TypeScript type at a given dot-separated JSON path within a
|
|
5833
|
+
* root type. Handles `$` prefix, dot notation, and array numeric indices.
|
|
5584
5834
|
*
|
|
5585
|
-
*
|
|
5586
|
-
* @typeParam Added - New fields being added by the select
|
|
5835
|
+
* Falls back to `unknown` when the path does not match the type structure.
|
|
5587
5836
|
*
|
|
5588
|
-
* @
|
|
5589
|
-
*
|
|
5590
|
-
* ComposeRawSelect<Record<string, any>, { count: number }>
|
|
5591
|
-
* // Result: { count: number }
|
|
5837
|
+
* @typeParam T - The root JSON object type to traverse.
|
|
5838
|
+
* @typeParam Path - A dot-separated string path.
|
|
5592
5839
|
*
|
|
5593
5840
|
* @example
|
|
5594
|
-
*
|
|
5595
|
-
*
|
|
5596
|
-
*
|
|
5597
|
-
|
|
5598
|
-
type
|
|
5599
|
-
|
|
5600
|
-
*
|
|
5601
|
-
*
|
|
5602
|
-
* Similar to ComposeRawSelect but designed for use with BuildRawSelectType.
|
|
5603
|
-
*
|
|
5604
|
-
* @typeParam S - Current selection state
|
|
5605
|
-
* @typeParam Columns - The columns being selected
|
|
5606
|
-
*/
|
|
5607
|
-
type ComposeBuildRawSelect<S extends Record<string, any>, Columns extends readonly Selectable[]> = Simplify<(string extends keyof S ? {} : S) & BuildRawSelectType<Columns>, typeof RAW_SELECT_BRAND>;
|
|
5608
|
-
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">;
|
|
5609
|
-
type RelationRetrieveMethod<P> = NonNullable<P> extends any[] ? "many" : "one";
|
|
5610
|
-
/**
|
|
5611
|
-
* Validates a column string for raw query builder select().
|
|
5612
|
-
* Use [column, alias] tuple format for aliases instead of "column as alias".
|
|
5613
|
-
* Use selectFunction() for SQL functions instead of embedding them in select().
|
|
5614
|
-
*/
|
|
5615
|
-
type SelectableColumn<T extends string = string> = T extends `${string}.${string}.${string}` ? never : T extends `${string} ${string}` ? never : T extends `.${string}` | `${string}.` ? never : T extends `${string}-${string}` ? never : T extends `${string}.${string}` ? T : T;
|
|
5616
|
-
/**
|
|
5617
|
-
* @description A column that can be used in a join statement e.g. `users.id`
|
|
5618
|
-
*/
|
|
5619
|
-
type JoinableColumn = `${string}.${string}`;
|
|
5620
|
-
/**
|
|
5621
|
-
* @description Options for streaming queries
|
|
5622
|
-
* @sqlite Ignores the options below
|
|
5623
|
-
*/
|
|
5624
|
-
type StreamOptions = {
|
|
5625
|
-
highWaterMark?: number;
|
|
5626
|
-
/** Postgres only */
|
|
5627
|
-
rowMode?: "array";
|
|
5628
|
-
/** Postgres only */
|
|
5629
|
-
batchSize?: number;
|
|
5630
|
-
/** Postgres only */
|
|
5631
|
-
types?: any;
|
|
5632
|
-
/** Mysql only */
|
|
5633
|
-
objectMode?: boolean;
|
|
5634
|
-
};
|
|
5635
|
-
type Cursor<T extends Model, K extends ModelKey<T>> = {
|
|
5636
|
-
key: K;
|
|
5637
|
-
value: string | number;
|
|
5638
|
-
};
|
|
5639
|
-
type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
|
|
5640
|
-
discriminator: K;
|
|
5641
|
-
operator?: "<" | ">";
|
|
5642
|
-
orderBy?: "asc" | "desc";
|
|
5643
|
-
};
|
|
5644
|
-
type UpsertOptionsRawBuilder = {
|
|
5645
|
-
updateOnConflict?: boolean;
|
|
5646
|
-
returning?: readonly string[];
|
|
5647
|
-
};
|
|
5648
|
-
type WriteQueryParam = string | number | boolean | Date | RawNode | object | null | undefined;
|
|
5649
|
-
/**
|
|
5650
|
-
* Simple paginated data type for raw query builders (without Model constraint)
|
|
5651
|
-
*/
|
|
5652
|
-
type RawPaginatedData<S extends Record<string, any>> = {
|
|
5653
|
-
paginationMetadata: {
|
|
5654
|
-
perPage: number;
|
|
5655
|
-
currentPage: number;
|
|
5656
|
-
firstPage: number;
|
|
5657
|
-
isEmpty: boolean;
|
|
5658
|
-
total: number;
|
|
5659
|
-
lastPage: number;
|
|
5660
|
-
hasMorePages: boolean;
|
|
5661
|
-
hasPages: boolean;
|
|
5662
|
-
};
|
|
5663
|
-
data: S[];
|
|
5664
|
-
};
|
|
5665
|
-
/**
|
|
5666
|
-
* Simple cursor paginated data type for raw query builders (without Model constraint)
|
|
5841
|
+
* ```ts
|
|
5842
|
+
* type Data = { user: { name: string; roles: string[] } };
|
|
5843
|
+
* type A = ResolveJsonPathType<Data, "user.name">; // string
|
|
5844
|
+
* type B = ResolveJsonPathType<Data, "user.roles">; // string[]
|
|
5845
|
+
* type C = ResolveJsonPathType<Data, "user">; // { name: string; roles: string[] }
|
|
5846
|
+
* type D = ResolveJsonPathType<Data, "$">; // Data
|
|
5847
|
+
* ```
|
|
5667
5848
|
*/
|
|
5668
|
-
type
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
isEmpty: boolean;
|
|
5673
|
-
total: number;
|
|
5674
|
-
};
|
|
5675
|
-
data: S[];
|
|
5676
|
-
};
|
|
5849
|
+
type ResolveJsonPathType<T, Path extends string> = Path extends `$.${infer Rest}` ? ResolveJsonPathType<T, Rest> : Path extends "$" | "" ? T : Path extends `${infer Head}.${infer Rest}` ? Head extends keyof NonNullable<T> ? ResolveJsonPathType<NonNullable<T>[Head], Rest> : NonNullable<T> extends readonly (infer E)[] ? Head extends `${number}` ? ResolveJsonPathType<E, Rest> : unknown : unknown : Path extends keyof NonNullable<T> ? NonNullable<T>[Path] : NonNullable<T> extends readonly (infer E)[] ? Path extends `${number}` ? E : unknown : unknown;
|
|
5850
|
+
type TypedJsonPathInput<ColumnType> = [NonNullable<ColumnType>] extends [
|
|
5851
|
+
never
|
|
5852
|
+
] ? JsonPathInput : unknown extends NonNullable<ColumnType> ? JsonPathInput : NonNullable<ColumnType> extends object ? JsonPaths<NonNullable<ColumnType>> | (string & {}) | (string | number)[] : JsonPathInput;
|
|
5677
5853
|
|
|
5678
5854
|
declare class SqlModelManagerUtils<T extends Model> {
|
|
5679
5855
|
protected dbType: SqlDataSourceType;
|
|
@@ -5729,62 +5905,6 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
5729
5905
|
protected offsetValue?: number;
|
|
5730
5906
|
/** Options for relation loading strategy */
|
|
5731
5907
|
protected loadOptions: LoadOptions;
|
|
5732
|
-
performance: {
|
|
5733
|
-
many: (options?: ManyOptions, returnType?: "millis" | "seconds") => Promise<{
|
|
5734
|
-
data: SelectedModel<T, S, R>[];
|
|
5735
|
-
time: number;
|
|
5736
|
-
}>;
|
|
5737
|
-
one: (options?: OneOptions, returnType?: "millis" | "seconds") => Promise<{
|
|
5738
|
-
data: SelectedModel<T, S, R> | null;
|
|
5739
|
-
time: number;
|
|
5740
|
-
}>;
|
|
5741
|
-
oneOrFail: (options?: OneOptions, returnType?: "millis" | "seconds") => Promise<{
|
|
5742
|
-
data: SelectedModel<T, S, R>;
|
|
5743
|
-
time: number;
|
|
5744
|
-
}>;
|
|
5745
|
-
paginate: (page: number, perPage: number, options?: {
|
|
5746
|
-
ignoreHooks?: boolean;
|
|
5747
|
-
}, returnType?: "millis" | "seconds") => Promise<{
|
|
5748
|
-
data: PaginatedData<T, S, R>;
|
|
5749
|
-
time: number;
|
|
5750
|
-
}>;
|
|
5751
|
-
exists: (returnType?: "millis" | "seconds") => Promise<{
|
|
5752
|
-
data: boolean;
|
|
5753
|
-
time: number;
|
|
5754
|
-
}>;
|
|
5755
|
-
paginateWithCursor: (page: number, options: PaginateWithCursorOptions<T, ModelKey<T>>, cursor?: Cursor<T, ModelKey<T>>, returnType?: "millis" | "seconds") => Promise<{
|
|
5756
|
-
data: [CursorPaginatedData<T, S, R>, Cursor<T, ModelKey<T>>];
|
|
5757
|
-
time: number;
|
|
5758
|
-
}>;
|
|
5759
|
-
truncate: (returnType?: "millis" | "seconds") => Promise<{
|
|
5760
|
-
data: void;
|
|
5761
|
-
time: number;
|
|
5762
|
-
}>;
|
|
5763
|
-
delete: (returnType?: "millis" | "seconds") => Promise<{
|
|
5764
|
-
data: number;
|
|
5765
|
-
time: number;
|
|
5766
|
-
}>;
|
|
5767
|
-
update: (data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions, returnType?: "millis" | "seconds") => Promise<{
|
|
5768
|
-
data: MutationReturningResult<T, ReturningParam<T, D>>;
|
|
5769
|
-
time: number;
|
|
5770
|
-
}>;
|
|
5771
|
-
softDelete: (options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">, returnType?: "millis" | "seconds") => Promise<{
|
|
5772
|
-
data: number;
|
|
5773
|
-
time: number;
|
|
5774
|
-
}>;
|
|
5775
|
-
pluck: (key: RawModelKey<T>, returnType?: "millis" | "seconds") => Promise<{
|
|
5776
|
-
data: PluckReturnType<T, RawModelKey<T>>;
|
|
5777
|
-
time: number;
|
|
5778
|
-
}>;
|
|
5779
|
-
insert: (data: Partial<ModelWithoutRelations<T>>, returnType?: "millis" | "seconds") => Promise<{
|
|
5780
|
-
data: "*" extends "*" | RawModelKey<T> ? Simplify<ModelQueryResult<T>, never> : Simplify<{ [K in ("*" | RawModelKey<T>) & string & keyof T]: T[K]; }, never>;
|
|
5781
|
-
time: number;
|
|
5782
|
-
}>;
|
|
5783
|
-
insertMany: (data: Partial<ModelWithoutRelations<T>>[], returnType?: "millis" | "seconds") => Promise<{
|
|
5784
|
-
data: "*" extends "*" | RawModelKey<T> ? Simplify<ModelQueryResult<T>, never>[] : Simplify<{ [K in ("*" | RawModelKey<T>) & string & keyof T]: T[K]; }, never>[];
|
|
5785
|
-
time: number;
|
|
5786
|
-
}>;
|
|
5787
|
-
};
|
|
5788
5908
|
constructor(model: typeof Model, sqlDataSource: SqlDataSource);
|
|
5789
5909
|
/**
|
|
5790
5910
|
* @description Returns true if the query builder is a relation query builder, this changes the behavior of the query builder like limit, offset, etc.
|
|
@@ -6039,12 +6159,16 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6039
6159
|
*/
|
|
6040
6160
|
clearSelect(): ModelQueryBuilder<T, ModelWithoutRelations<T>, R>;
|
|
6041
6161
|
/**
|
|
6042
|
-
* @description Selects a JSON value at the specified path and returns it as JSON
|
|
6043
|
-
* @param column The column containing JSON data
|
|
6044
|
-
*
|
|
6045
|
-
* @param
|
|
6046
|
-
*
|
|
6047
|
-
*
|
|
6162
|
+
* @description Selects a JSON value at the specified path and returns it as JSON.
|
|
6163
|
+
* @param column - The column containing JSON data. Accepts model column names (with IDE autocompletion)
|
|
6164
|
+
* or raw column strings for joins/aliases.
|
|
6165
|
+
* @param path - The JSON path to extract. Accepts dot notation (`"user.name"`), `$`-prefixed paths
|
|
6166
|
+
* (`"$.user.name"`), or an array of segments (`["user", "name"]`).
|
|
6167
|
+
* When the column has a typed JSON schema (e.g. `col.jsonb<{ user: { name: string } }>()`),
|
|
6168
|
+
* IDE autocompletion suggests valid paths into the JSON structure.
|
|
6169
|
+
* @param alias - The alias for the extracted value. The result is available as a typed property
|
|
6170
|
+
* on the returned model with this alias name.
|
|
6171
|
+
* @description Path format is standardized across all databases - ORM converts to DB-specific syntax.
|
|
6048
6172
|
* @example
|
|
6049
6173
|
* ```ts
|
|
6050
6174
|
* // All these path formats are supported:
|
|
@@ -6072,16 +6196,19 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6072
6196
|
* console.log(user?.userName); // Typed as string
|
|
6073
6197
|
* ```
|
|
6074
6198
|
*/
|
|
6075
|
-
selectJson<
|
|
6076
|
-
[
|
|
6199
|
+
selectJson<K extends ModelKey<T> | (string & {}), P extends [K] extends [ModelKey<T>] ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, Alias extends string = string>(column: K, path: P, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
|
|
6200
|
+
[Q in Alias]: [K] extends [ModelKey<T>] ? P extends string ? ResolveJsonPathType<NonNullable<ResolveColumnType<T, K & string>>, P> extends infer R ? unknown extends R ? any : R : any : any : any;
|
|
6077
6201
|
}>, R>;
|
|
6078
6202
|
/**
|
|
6079
|
-
* @description Selects a JSON value at the specified path and returns it as text
|
|
6080
|
-
* @param column The column containing JSON data
|
|
6081
|
-
*
|
|
6082
|
-
* @param
|
|
6083
|
-
*
|
|
6084
|
-
*
|
|
6203
|
+
* @description Selects a JSON value at the specified path and returns it as text.
|
|
6204
|
+
* @param column - The column containing JSON data. Accepts model column names (with IDE autocompletion)
|
|
6205
|
+
* or raw column strings for joins/aliases.
|
|
6206
|
+
* @param path - The JSON path to extract. Accepts dot notation (`"user.email"`), `$`-prefixed paths
|
|
6207
|
+
* (`"$.user.email"`), or an array of segments (`["user", "email"]`).
|
|
6208
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
6209
|
+
* @param alias - The alias for the extracted text value. The result is available as a typed property
|
|
6210
|
+
* on the returned model with this alias name.
|
|
6211
|
+
* @description Path format is standardized across all databases - ORM converts to DB-specific syntax.
|
|
6085
6212
|
* @example
|
|
6086
6213
|
* ```ts
|
|
6087
6214
|
* // All these path formats are supported:
|
|
@@ -6107,17 +6234,19 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6107
6234
|
* console.log(user?.userEmail); // Typed as string
|
|
6108
6235
|
* ```
|
|
6109
6236
|
*/
|
|
6110
|
-
selectJsonText<ValueType = string, Alias extends string = string>(column: ModelKey<T>
|
|
6111
|
-
[
|
|
6237
|
+
selectJsonText<K extends ModelKey<T> | (string & {}), ValueType = string, Alias extends string = string>(column: K, path: K extends ModelKey<T> ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
|
|
6238
|
+
[P in Alias]: ValueType;
|
|
6112
6239
|
}>, R>;
|
|
6113
6240
|
/**
|
|
6114
|
-
* @description Selects the length of a JSON array
|
|
6115
|
-
* @param column The column containing JSON array data
|
|
6116
|
-
*
|
|
6117
|
-
* @param
|
|
6118
|
-
*
|
|
6119
|
-
* @
|
|
6120
|
-
*
|
|
6241
|
+
* @description Selects the length of a JSON array at the specified path.
|
|
6242
|
+
* @param column - The column containing JSON array data. Accepts model column names (with IDE autocompletion)
|
|
6243
|
+
* or raw column strings for joins/aliases.
|
|
6244
|
+
* @param path - The JSON path to the array. Use `"$"` or `""` for root.
|
|
6245
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
6246
|
+
* @param alias - The alias for the array length value. The result is available as a typed property
|
|
6247
|
+
* on the returned model with this alias name.
|
|
6248
|
+
* @description Path format is standardized across all databases - ORM converts to DB-specific syntax.
|
|
6249
|
+
* @warning Not supported in SQLite.
|
|
6121
6250
|
* @example
|
|
6122
6251
|
* ```ts
|
|
6123
6252
|
* // All these path formats are supported:
|
|
@@ -6147,19 +6276,21 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6147
6276
|
* console.log(user?.count); // Typed as number
|
|
6148
6277
|
* ```
|
|
6149
6278
|
*/
|
|
6150
|
-
selectJsonArrayLength<ValueType = number, Alias extends string = string>(column: ModelKey<T>
|
|
6151
|
-
[
|
|
6279
|
+
selectJsonArrayLength<K extends ModelKey<T> | (string & {}), ValueType = number, Alias extends string = string>(column: K, path: K extends ModelKey<T> ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
|
|
6280
|
+
[P in Alias]: ValueType;
|
|
6152
6281
|
}>, R>;
|
|
6153
6282
|
/**
|
|
6154
|
-
* @description Selects the keys of a JSON object
|
|
6155
|
-
* @param column The column containing JSON object data
|
|
6156
|
-
*
|
|
6157
|
-
* @param
|
|
6158
|
-
*
|
|
6159
|
-
* @
|
|
6160
|
-
*
|
|
6161
|
-
* @
|
|
6162
|
-
* @
|
|
6283
|
+
* @description Selects the keys of a JSON object at the specified path.
|
|
6284
|
+
* @param column - The column containing JSON object data. Accepts model column names (with IDE autocompletion)
|
|
6285
|
+
* or raw column strings for joins/aliases.
|
|
6286
|
+
* @param path - The JSON path to the object. Use `"$"` or `""` for root.
|
|
6287
|
+
* When the column has a typed JSON schema, IDE autocompletion suggests valid paths.
|
|
6288
|
+
* @param alias - The alias for the keys array. The result is available as a typed property
|
|
6289
|
+
* on the returned model with this alias name.
|
|
6290
|
+
* @description Path format is standardized across all databases - ORM converts to DB-specific syntax.
|
|
6291
|
+
* @warning Not supported in SQLite or MSSQL.
|
|
6292
|
+
* @postgresql Returns a native array of keys.
|
|
6293
|
+
* @mysql Returns a JSON array of keys.
|
|
6163
6294
|
* @example
|
|
6164
6295
|
* ```ts
|
|
6165
6296
|
* // All these path formats are supported:
|
|
@@ -6189,16 +6320,18 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6189
6320
|
* console.log(user?.keys); // Typed as string[] - ["theme", "fontSize", "autoSave"]
|
|
6190
6321
|
* ```
|
|
6191
6322
|
*/
|
|
6192
|
-
selectJsonKeys<ValueType = string[], Alias extends string = string>(column: ModelKey<T>
|
|
6193
|
-
[
|
|
6323
|
+
selectJsonKeys<K extends ModelKey<T> | (string & {}), ValueType = string[], Alias extends string = string>(column: K, path: K extends ModelKey<T> ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
|
|
6324
|
+
[P in Alias]: ValueType;
|
|
6194
6325
|
}>, R>;
|
|
6195
6326
|
/**
|
|
6196
|
-
* @description Adds a raw JSON select expression
|
|
6197
|
-
* @param raw The raw SQL expression (database-specific syntax)
|
|
6198
|
-
*
|
|
6199
|
-
*
|
|
6200
|
-
* @
|
|
6201
|
-
*
|
|
6327
|
+
* @description Adds a raw JSON select expression using database-specific SQL syntax.
|
|
6328
|
+
* @param raw - The raw SQL expression (database-specific syntax). Bypasses path standardization —
|
|
6329
|
+
* you must write DB-specific SQL (e.g., `"data->>'email'"` for PostgreSQL,
|
|
6330
|
+
* `"json_extract(data, '$.email')"` for SQLite).
|
|
6331
|
+
* @param alias - The alias for the extracted value. The result is available as a typed property
|
|
6332
|
+
* on the returned model with this alias name.
|
|
6333
|
+
* @description Use this for advanced JSON operations not covered by other selectJson* methods.
|
|
6334
|
+
* @warning This bypasses path standardization - you must write database-specific SQL.
|
|
6202
6335
|
* @example
|
|
6203
6336
|
* ```ts
|
|
6204
6337
|
* // PostgreSQL - Extract as text with ->> operator
|
|
@@ -6365,19 +6498,6 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
|
|
|
6365
6498
|
protected getFilterValuesFromModelsForRelation(relation: Relation, models: T[]): any[];
|
|
6366
6499
|
protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType$2, value?: BaseValues$2): void;
|
|
6367
6500
|
protected addAdditionalColumnsToModel(row: any): Record<string, any>;
|
|
6368
|
-
private manyWithPerformance;
|
|
6369
|
-
private oneWithPerformance;
|
|
6370
|
-
private oneOrFailWithPerformance;
|
|
6371
|
-
private paginateWithPerformance;
|
|
6372
|
-
private paginateWithCursorWithPerformance;
|
|
6373
|
-
private existsWithPerformance;
|
|
6374
|
-
private pluckWithPerformance;
|
|
6375
|
-
private softDeleteWithPerformance;
|
|
6376
|
-
private updateWithPerformance;
|
|
6377
|
-
private deleteWithPerformance;
|
|
6378
|
-
private truncateWithPerformance;
|
|
6379
|
-
private insertWithPerformance;
|
|
6380
|
-
private insertManyWithPerformance;
|
|
6381
6501
|
}
|
|
6382
6502
|
|
|
6383
6503
|
/**
|
|
@@ -6430,6 +6550,10 @@ declare abstract class Model<T extends Model<T> = any> extends Entity {
|
|
|
6430
6550
|
static getIndexes(): IndexType[];
|
|
6431
6551
|
static getUniques(): UniqueType[];
|
|
6432
6552
|
static getChecks(): CheckType[];
|
|
6553
|
+
static validate(data: any): Promise<{
|
|
6554
|
+
valid: boolean;
|
|
6555
|
+
errors?: Record<string, string[]>;
|
|
6556
|
+
}>;
|
|
6433
6557
|
}
|
|
6434
6558
|
|
|
6435
6559
|
/**
|
|
@@ -6459,6 +6583,8 @@ interface RelationDef<T = any> {
|
|
|
6459
6583
|
}
|
|
6460
6584
|
type ColOptions = Omit<ColumnOptions, "primaryKey" | "serialize" | "prepare" | "default"> & {
|
|
6461
6585
|
length?: number;
|
|
6586
|
+
/** Per-column validators (optional) */
|
|
6587
|
+
validate?: Validator | Validator[];
|
|
6462
6588
|
};
|
|
6463
6589
|
type ColPrimaryOptions = Omit<ColumnOptions, "primaryKey" | "serialize" | "prepare" | "default">;
|
|
6464
6590
|
type ColStringOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
|
|
@@ -6549,7 +6675,6 @@ type TypedPrepare<T> = {
|
|
|
6549
6675
|
};
|
|
6550
6676
|
type TypedDefault<T> = {
|
|
6551
6677
|
/**
|
|
6552
|
-
* Narrows the `default` property to the column's base type.
|
|
6553
6678
|
* @migration Migration-only metadata. Sets the DEFAULT clause in CREATE TABLE / ALTER TABLE.
|
|
6554
6679
|
* Does **not** enforce a value during `insert()` — pass the value explicitly or use `prepare`.
|
|
6555
6680
|
*/
|
|
@@ -7290,79 +7415,33 @@ type RedisFetchable = string | number | boolean | Record<string, any> | Array<an
|
|
|
7290
7415
|
* @description Type for Redis message handler callback
|
|
7291
7416
|
*/
|
|
7292
7417
|
type RedisMessageHandler = (channel: string, message: string) => void;
|
|
7418
|
+
interface RedisDataSourceInput extends RedisOptions {
|
|
7419
|
+
lazyLoad?: boolean;
|
|
7420
|
+
}
|
|
7293
7421
|
/**
|
|
7294
7422
|
* @description The RedisDataSource class is a wrapper around the ioredis library that provides a simple interface to interact with a redis database
|
|
7295
7423
|
*/
|
|
7296
7424
|
declare class RedisDataSource {
|
|
7297
|
-
static readonly OK = "OK";
|
|
7298
7425
|
readonly OK = "OK";
|
|
7299
|
-
static isConnected: boolean;
|
|
7300
|
-
protected static redisDataSourceInstance: RedisDataSource;
|
|
7301
7426
|
isConnected: boolean;
|
|
7302
|
-
protected ioRedisConnection: Redis;
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
*/
|
|
7308
|
-
static get ioredis(): Redis;
|
|
7427
|
+
protected ioRedisConnection: Redis | null;
|
|
7428
|
+
private inputOptions;
|
|
7429
|
+
private lazyLoad;
|
|
7430
|
+
private connecting;
|
|
7431
|
+
constructor(input?: RedisDataSourceInput);
|
|
7309
7432
|
/**
|
|
7310
7433
|
* @description Returns the raw ioredis connection
|
|
7311
7434
|
* @returns {Redis}
|
|
7312
7435
|
*/
|
|
7313
7436
|
get ioredis(): Redis;
|
|
7314
7437
|
/**
|
|
7315
|
-
* @description
|
|
7316
|
-
* @description The User input connection details will always come first
|
|
7317
|
-
* @description This is intended as a singleton connection to the redis database, if you need multiple connections, use the getConnection method
|
|
7318
|
-
*/
|
|
7319
|
-
static connect(input?: RedisOptions): Promise<void>;
|
|
7320
|
-
/**
|
|
7321
|
-
* @description Establishes a connection to the redis database and returns the connection
|
|
7322
|
-
* @param input
|
|
7323
|
-
* @returns
|
|
7324
|
-
*/
|
|
7325
|
-
static getConnection(input?: RedisOptions): Promise<RedisDataSource>;
|
|
7326
|
-
/**
|
|
7327
|
-
* @description Sets a key-value pair in the redis database
|
|
7328
|
-
* @param {string} key - The key
|
|
7329
|
-
* @param {string} value - The value
|
|
7330
|
-
* @param {number} expirationTime - The expiration time in milliseconds
|
|
7331
|
-
*/
|
|
7332
|
-
static set(key: string, value: RedisStorable, expirationTime?: number): Promise<void>;
|
|
7333
|
-
/**
|
|
7334
|
-
* @description Gets the value of a key in the redis database
|
|
7335
|
-
* @param {string} key - The key
|
|
7336
|
-
* @returns {Promise<string>}
|
|
7337
|
-
*/
|
|
7338
|
-
static get<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
7339
|
-
/**
|
|
7340
|
-
* @description Gets the value of a key in the redis database as a buffer
|
|
7341
|
-
*/
|
|
7342
|
-
static getBuffer(key: string): Promise<Buffer | null>;
|
|
7343
|
-
/**
|
|
7344
|
-
* @description Gets the value of a key in the redis database and deletes the key
|
|
7345
|
-
* @param {string} key - The key
|
|
7346
|
-
* @returns {Promise
|
|
7347
|
-
* <T | null>}
|
|
7348
|
-
*/
|
|
7349
|
-
static consume<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
7350
|
-
/**
|
|
7351
|
-
* @description Deletes a key from the redis database
|
|
7352
|
-
* @param {string} key - The key
|
|
7353
|
-
* @returns {Promise<void>}
|
|
7354
|
-
*/
|
|
7355
|
-
static delete(key: string): Promise<void>;
|
|
7356
|
-
/**
|
|
7357
|
-
* @description Flushes all the data in the redis database
|
|
7358
|
-
* @returns {Promise<void>}
|
|
7438
|
+
* @description Establishes a connection to the redis database. The ioredis driver is dynamically imported.
|
|
7359
7439
|
*/
|
|
7360
|
-
|
|
7440
|
+
connect(): Promise<void>;
|
|
7361
7441
|
/**
|
|
7362
|
-
* @description
|
|
7363
|
-
* @returns {Promise<void>}
|
|
7442
|
+
* @description Ensures the connection is established. If lazyLoad is true and not connected, connects automatically.
|
|
7364
7443
|
*/
|
|
7365
|
-
|
|
7444
|
+
private ensureConnected;
|
|
7366
7445
|
/**
|
|
7367
7446
|
* @description Sets a key-value pair in the redis database
|
|
7368
7447
|
* @param {string} key - The key
|
|
@@ -7396,54 +7475,14 @@ declare class RedisDataSource {
|
|
|
7396
7475
|
delete(key: string): Promise<void>;
|
|
7397
7476
|
/**
|
|
7398
7477
|
* @description Flushes all the data in the redis database
|
|
7399
|
-
* @returns {Promise<void>}
|
|
7400
|
-
*/
|
|
7401
|
-
flushAll(): Promise<void>;
|
|
7402
|
-
/**
|
|
7403
|
-
* @description Disconnects from the redis database
|
|
7404
|
-
* @returns {Promise<void>}
|
|
7405
|
-
*/
|
|
7406
|
-
disconnect(forceError?: boolean): Promise<void>;
|
|
7407
|
-
/**
|
|
7408
|
-
* @description Adds one or more values to the beginning of a list
|
|
7409
|
-
* @param {string} key - The key of the list
|
|
7410
|
-
* @param {RedisStorable[]} values - The values to add
|
|
7411
|
-
* @returns {Promise<number>} - The length of the list after the push operation
|
|
7412
|
-
*/
|
|
7413
|
-
static lpush(key: string, ...values: RedisStorable[]): Promise<number>;
|
|
7414
|
-
/**
|
|
7415
|
-
* @description Adds one or more values to the end of a list
|
|
7416
|
-
* @param {string} key - The key of the list
|
|
7417
|
-
* @param {RedisStorable[]} values - The values to add
|
|
7418
|
-
* @returns {Promise<number>} - The length of the list after the push operation
|
|
7419
|
-
*/
|
|
7420
|
-
static rpush(key: string, ...values: RedisStorable[]): Promise<number>;
|
|
7421
|
-
/**
|
|
7422
|
-
* @description Removes and returns the first element of a list
|
|
7423
|
-
* @param {string} key - The key of the list
|
|
7424
|
-
* @returns {Promise<T | null>} - The popped value
|
|
7425
|
-
*/
|
|
7426
|
-
static lpop<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
7427
|
-
/**
|
|
7428
|
-
* @description Removes and returns the last element of a list
|
|
7429
|
-
* @param {string} key - The key of the list
|
|
7430
|
-
* @returns {Promise<T | null>} - The popped value
|
|
7431
|
-
*/
|
|
7432
|
-
static rpop<T = RedisFetchable>(key: string): Promise<T | null>;
|
|
7433
|
-
/**
|
|
7434
|
-
* @description Gets a range of elements from a list
|
|
7435
|
-
* @param {string} key - The key of the list
|
|
7436
|
-
* @param {number} start - The starting index
|
|
7437
|
-
* @param {number} stop - The stopping index
|
|
7438
|
-
* @returns {Promise<T[]>} - Array of elements in the specified range
|
|
7478
|
+
* @returns {Promise<void>}
|
|
7439
7479
|
*/
|
|
7440
|
-
|
|
7480
|
+
flushAll(): Promise<void>;
|
|
7441
7481
|
/**
|
|
7442
|
-
* @description
|
|
7443
|
-
* @
|
|
7444
|
-
* @returns {Promise<number>} - The length of the list
|
|
7482
|
+
* @description Disconnects from the redis database
|
|
7483
|
+
* @returns {Promise<void>}
|
|
7445
7484
|
*/
|
|
7446
|
-
|
|
7485
|
+
disconnect(forceError?: boolean): Promise<void>;
|
|
7447
7486
|
/**
|
|
7448
7487
|
* @description Adds one or more values to the beginning of a list
|
|
7449
7488
|
* @param {string} key - The key of the list
|
|
@@ -7484,67 +7523,6 @@ declare class RedisDataSource {
|
|
|
7484
7523
|
* @returns {Promise<number>} - The length of the list
|
|
7485
7524
|
*/
|
|
7486
7525
|
llen(key: string): Promise<number>;
|
|
7487
|
-
/**
|
|
7488
|
-
* @description Sets field in the hash stored at key to value
|
|
7489
|
-
* @param {string} key - The key of the hash
|
|
7490
|
-
* @param {string} field - The field to set
|
|
7491
|
-
* @param {RedisStorable} value - The value to set
|
|
7492
|
-
* @returns {Promise<number>} - 1 if field is a new field and value was set, 0 if field already exists and the value was updated
|
|
7493
|
-
*/
|
|
7494
|
-
static hset(key: string, field: string, value: RedisStorable): Promise<number>;
|
|
7495
|
-
/**
|
|
7496
|
-
* @description Sets multiple fields in the hash stored at key to their respective values
|
|
7497
|
-
* @param {string} key - The key of the hash
|
|
7498
|
-
* @param {Record<string, RedisStorable>} hash - Object containing field-value pairs
|
|
7499
|
-
* @returns {Promise<string>} - "OK" if successful
|
|
7500
|
-
*/
|
|
7501
|
-
static hmset(key: string, hash: Record<string, RedisStorable>): Promise<string>;
|
|
7502
|
-
/**
|
|
7503
|
-
* @description Gets the value of a field in a hash
|
|
7504
|
-
* @param {string} key - The key of the hash
|
|
7505
|
-
* @param {string} field - The field to get
|
|
7506
|
-
* @returns {Promise<T | null>} - The value of the field
|
|
7507
|
-
*/
|
|
7508
|
-
static hget<T = RedisFetchable>(key: string, field: string): Promise<T | null>;
|
|
7509
|
-
/**
|
|
7510
|
-
* @description Gets all the fields and values in a hash
|
|
7511
|
-
* @param {string} key - The key of the hash
|
|
7512
|
-
* @returns {Promise<Record<string, T>>} - Object containing field-value pairs
|
|
7513
|
-
*/
|
|
7514
|
-
static hgetall<T = RedisFetchable>(key: string): Promise<Record<string, T>>;
|
|
7515
|
-
/**
|
|
7516
|
-
* @description Gets values for multiple fields in a hash
|
|
7517
|
-
* @param {string} key - The key of the hash
|
|
7518
|
-
* @param {string[]} fields - The fields to get
|
|
7519
|
-
* @returns {Promise<Array<T | null>>} - Array of values
|
|
7520
|
-
*/
|
|
7521
|
-
static hmget<T = RedisFetchable>(key: string, ...fields: string[]): Promise<Array<T | null>>;
|
|
7522
|
-
/**
|
|
7523
|
-
* @description Deletes one or more fields from a hash
|
|
7524
|
-
* @param {string} key - The key of the hash
|
|
7525
|
-
* @param {string[]} fields - The fields to delete
|
|
7526
|
-
* @returns {Promise<number>} - The number of fields that were removed
|
|
7527
|
-
*/
|
|
7528
|
-
static hdel(key: string, ...fields: string[]): Promise<number>;
|
|
7529
|
-
/**
|
|
7530
|
-
* @description Checks if a field exists in a hash
|
|
7531
|
-
* @param {string} key - The key of the hash
|
|
7532
|
-
* @param {string} field - The field to check
|
|
7533
|
-
* @returns {Promise<number>} - 1 if the field exists, 0 if not
|
|
7534
|
-
*/
|
|
7535
|
-
static hexists(key: string, field: string): Promise<number>;
|
|
7536
|
-
/**
|
|
7537
|
-
* @description Gets all the fields in a hash
|
|
7538
|
-
* @param {string} key - The key of the hash
|
|
7539
|
-
* @returns {Promise<string[]>} - Array of field names
|
|
7540
|
-
*/
|
|
7541
|
-
static hkeys(key: string): Promise<string[]>;
|
|
7542
|
-
/**
|
|
7543
|
-
* @description Gets the number of fields in a hash
|
|
7544
|
-
* @param {string} key - The key of the hash
|
|
7545
|
-
* @returns {Promise<number>} - The number of fields
|
|
7546
|
-
*/
|
|
7547
|
-
static hlen(key: string): Promise<number>;
|
|
7548
7526
|
/**
|
|
7549
7527
|
* @description Sets field in the hash stored at key to value
|
|
7550
7528
|
* @param {string} key - The key of the hash
|
|
@@ -7606,57 +7584,6 @@ declare class RedisDataSource {
|
|
|
7606
7584
|
* @returns {Promise<number>} - The number of fields
|
|
7607
7585
|
*/
|
|
7608
7586
|
hlen(key: string): Promise<number>;
|
|
7609
|
-
/**
|
|
7610
|
-
* @description Adds one or more members to a set
|
|
7611
|
-
* @param {string} key - The key of the set
|
|
7612
|
-
* @param {RedisStorable[]} members - The members to add
|
|
7613
|
-
* @returns {Promise<number>} - The number of elements added to the set
|
|
7614
|
-
*/
|
|
7615
|
-
static sadd(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
7616
|
-
/**
|
|
7617
|
-
* @description Gets all members of a set
|
|
7618
|
-
* @param {string} key - The key of the set
|
|
7619
|
-
* @returns {Promise<T[]>} - Array of set members
|
|
7620
|
-
*/
|
|
7621
|
-
static smembers<T = RedisFetchable>(key: string): Promise<T[]>;
|
|
7622
|
-
/**
|
|
7623
|
-
* @description Removes one or more members from a set
|
|
7624
|
-
* @param {string} key - The key of the set
|
|
7625
|
-
* @param {RedisStorable[]} members - The members to remove
|
|
7626
|
-
* @returns {Promise<number>} - The number of members that were removed
|
|
7627
|
-
*/
|
|
7628
|
-
static srem(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
7629
|
-
/**
|
|
7630
|
-
* @description Determines whether a member belongs to a set
|
|
7631
|
-
* @param {string} key - The key of the set
|
|
7632
|
-
* @param {RedisStorable} member - The member to check
|
|
7633
|
-
* @returns {Promise<number>} - 1 if the member exists in the set, 0 if not
|
|
7634
|
-
*/
|
|
7635
|
-
static sismember(key: string, member: RedisStorable): Promise<number>;
|
|
7636
|
-
/**
|
|
7637
|
-
* @description Gets the number of members in a set
|
|
7638
|
-
* @param {string} key - The key of the set
|
|
7639
|
-
* @returns {Promise<number>} - The number of members in the set
|
|
7640
|
-
*/
|
|
7641
|
-
static scard(key: string): Promise<number>;
|
|
7642
|
-
/**
|
|
7643
|
-
* @description Returns the intersection of multiple sets
|
|
7644
|
-
* @param {string[]} keys - The keys of the sets to intersect
|
|
7645
|
-
* @returns {Promise<T[]>} - Array of members in the intersection
|
|
7646
|
-
*/
|
|
7647
|
-
static sinter<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
7648
|
-
/**
|
|
7649
|
-
* @description Returns the union of multiple sets
|
|
7650
|
-
* @param {string[]} keys - The keys of the sets to union
|
|
7651
|
-
* @returns {Promise<T[]>} - Array of members in the union
|
|
7652
|
-
*/
|
|
7653
|
-
static sunion<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
7654
|
-
/**
|
|
7655
|
-
* @description Returns the difference between the first set and all successive sets
|
|
7656
|
-
* @param {string[]} keys - The keys of the sets to diff
|
|
7657
|
-
* @returns {Promise<T[]>} - Array of members in the difference
|
|
7658
|
-
*/
|
|
7659
|
-
static sdiff<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
7660
7587
|
/**
|
|
7661
7588
|
* @description Adds one or more members to a set
|
|
7662
7589
|
* @param {string} key - The key of the set
|
|
@@ -7708,59 +7635,6 @@ declare class RedisDataSource {
|
|
|
7708
7635
|
* @returns {Promise<T[]>} - Array of members in the difference
|
|
7709
7636
|
*/
|
|
7710
7637
|
sdiff<T = RedisFetchable>(...keys: string[]): Promise<T[]>;
|
|
7711
|
-
/**
|
|
7712
|
-
* @description Adds a member to a sorted set, or updates the score of an existing member
|
|
7713
|
-
* @param {string} key - The key of the sorted set
|
|
7714
|
-
* @param {number} score - The score associated with the member
|
|
7715
|
-
* @param {RedisStorable} member - The member to add or update
|
|
7716
|
-
* @returns {Promise<number>} - The number of new members added to the sorted set
|
|
7717
|
-
*/
|
|
7718
|
-
static zadd(key: string, score: number, member: RedisStorable): Promise<number>;
|
|
7719
|
-
static zadd(key: string, scoreMembers: Array<[number, RedisStorable]>): Promise<number>;
|
|
7720
|
-
/**
|
|
7721
|
-
* @description Gets a range of members from a sorted set, ordered by score
|
|
7722
|
-
* @param {string} key - The key of the sorted set
|
|
7723
|
-
* @param {number} start - The starting index
|
|
7724
|
-
* @param {number} stop - The stopping index
|
|
7725
|
-
* @param {boolean} withScores - Whether to return the scores along with the members
|
|
7726
|
-
* @returns {Promise<T[] | Array<{value: T, score: number}>>} - Array of members or [member, score] pairs
|
|
7727
|
-
*/
|
|
7728
|
-
static zrange<T = RedisFetchable>(key: string, start: number, stop: number, withScores?: boolean): Promise<T[] | Array<{
|
|
7729
|
-
value: T;
|
|
7730
|
-
score: number;
|
|
7731
|
-
}>>;
|
|
7732
|
-
/**
|
|
7733
|
-
* @description Gets a range of members from a sorted set, ordered by score in descending order
|
|
7734
|
-
* @param {string} key - The key of the sorted set
|
|
7735
|
-
* @param {number} start - The starting index
|
|
7736
|
-
* @param {number} stop - The stopping index
|
|
7737
|
-
* @param {boolean} withScores - Whether to return the scores along with the members
|
|
7738
|
-
* @returns {Promise<T[] | Array<{value: T, score: number}>>} - Array of members or [member, score] pairs
|
|
7739
|
-
*/
|
|
7740
|
-
static zrevrange<T = RedisFetchable>(key: string, start: number, stop: number, withScores?: boolean): Promise<T[] | Array<{
|
|
7741
|
-
value: T;
|
|
7742
|
-
score: number;
|
|
7743
|
-
}>>;
|
|
7744
|
-
/**
|
|
7745
|
-
* @description Removes one or more members from a sorted set
|
|
7746
|
-
* @param {string} key - The key of the sorted set
|
|
7747
|
-
* @param {RedisStorable[]} members - The members to remove
|
|
7748
|
-
* @returns {Promise<number>} - The number of members removed
|
|
7749
|
-
*/
|
|
7750
|
-
static zrem(key: string, ...members: RedisStorable[]): Promise<number>;
|
|
7751
|
-
/**
|
|
7752
|
-
* @description Gets the score of a member in a sorted set
|
|
7753
|
-
* @param {string} key - The key of the sorted set
|
|
7754
|
-
* @param {RedisStorable} member - The member to get the score of
|
|
7755
|
-
* @returns {Promise<number | null>} - The score of the member, or null if the member does not exist
|
|
7756
|
-
*/
|
|
7757
|
-
static zscore(key: string, member: RedisStorable): Promise<number | null>;
|
|
7758
|
-
/**
|
|
7759
|
-
* @description Gets the number of members in a sorted set
|
|
7760
|
-
* @param {string} key - The key of the sorted set
|
|
7761
|
-
* @returns {Promise<number>} - The number of members in the sorted set
|
|
7762
|
-
*/
|
|
7763
|
-
static zcard(key: string): Promise<number>;
|
|
7764
7638
|
/**
|
|
7765
7639
|
* @description Adds a member to a sorted set, or updates the score of an existing member
|
|
7766
7640
|
* @param {string} key - The key of the sorted set
|
|
@@ -7814,39 +7688,6 @@ declare class RedisDataSource {
|
|
|
7814
7688
|
* @returns {Promise<number>} - The number of members in the sorted set
|
|
7815
7689
|
*/
|
|
7816
7690
|
zcard(key: string): Promise<number>;
|
|
7817
|
-
/**
|
|
7818
|
-
* @description Subscribes to one or more channels
|
|
7819
|
-
* @param {string[]} channels - The channels to subscribe to
|
|
7820
|
-
* @param {RedisMessageHandler} handler - The function to call when a message is received
|
|
7821
|
-
* @returns {Promise<void>}
|
|
7822
|
-
*/
|
|
7823
|
-
static subscribe(channels: string[], handler: RedisMessageHandler): Promise<void>;
|
|
7824
|
-
/**
|
|
7825
|
-
* @description Unsubscribes from one or more channels
|
|
7826
|
-
* @param {string[]} channels - The channels to unsubscribe from
|
|
7827
|
-
* @returns {Promise<void>}
|
|
7828
|
-
*/
|
|
7829
|
-
static unsubscribe(...channels: string[]): Promise<void>;
|
|
7830
|
-
/**
|
|
7831
|
-
* @description Publishes a message to a channel
|
|
7832
|
-
* @param {string} channel - The channel to publish to
|
|
7833
|
-
* @param {RedisStorable} message - The message to publish
|
|
7834
|
-
* @returns {Promise<number>} - The number of clients that received the message
|
|
7835
|
-
*/
|
|
7836
|
-
static publish(channel: string, message: RedisStorable): Promise<number>;
|
|
7837
|
-
/**
|
|
7838
|
-
* @description Pattern subscribe to channels
|
|
7839
|
-
* @param {string[]} patterns - The patterns to subscribe to
|
|
7840
|
-
* @param {RedisMessageHandler} handler - The function to call when a message is received
|
|
7841
|
-
* @returns {Promise<void>}
|
|
7842
|
-
*/
|
|
7843
|
-
static psubscribe(patterns: string[], handler: RedisMessageHandler): Promise<void>;
|
|
7844
|
-
/**
|
|
7845
|
-
* @description Pattern unsubscribe from channels
|
|
7846
|
-
* @param {string[]} patterns - The patterns to unsubscribe from
|
|
7847
|
-
* @returns {Promise<void>}
|
|
7848
|
-
*/
|
|
7849
|
-
static punsubscribe(...patterns: string[]): Promise<void>;
|
|
7850
7691
|
/**
|
|
7851
7692
|
* @description Subscribes to one or more channels
|
|
7852
7693
|
* @param {string[]} channels - The channels to subscribe to
|
|
@@ -7880,70 +7721,6 @@ declare class RedisDataSource {
|
|
|
7880
7721
|
* @returns {Promise<void>}
|
|
7881
7722
|
*/
|
|
7882
7723
|
punsubscribe(...patterns: string[]): Promise<void>;
|
|
7883
|
-
/**
|
|
7884
|
-
* @description Checks if a key exists
|
|
7885
|
-
* @param {string} key - The key to check
|
|
7886
|
-
* @returns {Promise<number>} - 1 if the key exists, 0 if not
|
|
7887
|
-
*/
|
|
7888
|
-
static exists(key: string): Promise<number>;
|
|
7889
|
-
/**
|
|
7890
|
-
* @description Sets the expiration time of a key
|
|
7891
|
-
* @param {string} key - The key to set the expiration for
|
|
7892
|
-
* @param {number} seconds - The expiration time in seconds
|
|
7893
|
-
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
7894
|
-
*/
|
|
7895
|
-
static expire(key: string, seconds: number): Promise<number>;
|
|
7896
|
-
/**
|
|
7897
|
-
* @description Sets the expiration time of a key using a UNIX timestamp
|
|
7898
|
-
* @param {string} key - The key to set the expiration for
|
|
7899
|
-
* @param {number} timestamp - UNIX timestamp in seconds
|
|
7900
|
-
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
7901
|
-
*/
|
|
7902
|
-
static expireat(key: string, timestamp: number): Promise<number>;
|
|
7903
|
-
/**
|
|
7904
|
-
* @description Sets the expiration time of a key in milliseconds
|
|
7905
|
-
* @param {string} key - The key to set the expiration for
|
|
7906
|
-
* @param {number} milliseconds - The expiration time in milliseconds
|
|
7907
|
-
* @returns {Promise<number>} - 1 if the timeout was set, 0 if not
|
|
7908
|
-
*/
|
|
7909
|
-
static pexpire(key: string, milliseconds: number): Promise<number>;
|
|
7910
|
-
/**
|
|
7911
|
-
* @description Gets the remaining time to live of a key in seconds
|
|
7912
|
-
* @param {string} key - The key to get the TTL for
|
|
7913
|
-
* @returns {Promise<number>} - TTL in seconds, -1 if no expiry, -2 if key doesn't exist
|
|
7914
|
-
*/
|
|
7915
|
-
static ttl(key: string): Promise<number>;
|
|
7916
|
-
/**
|
|
7917
|
-
* @description Gets the remaining time to live of a key in milliseconds
|
|
7918
|
-
* @param {string} key - The key to get the TTL for
|
|
7919
|
-
* @returns {Promise<number>} - TTL in milliseconds, -1 if no expiry, -2 if key doesn't exist
|
|
7920
|
-
*/
|
|
7921
|
-
static pttl(key: string): Promise<number>;
|
|
7922
|
-
/**
|
|
7923
|
-
* @description Removes the expiration time from a key
|
|
7924
|
-
* @param {string} key - The key to persist
|
|
7925
|
-
* @returns {Promise<number>} - 1 if the timeout was removed, 0 if not
|
|
7926
|
-
*/
|
|
7927
|
-
static persist(key: string): Promise<number>;
|
|
7928
|
-
/**
|
|
7929
|
-
* @description Gets all keys matching a pattern
|
|
7930
|
-
* @param {string} pattern - The pattern to match
|
|
7931
|
-
* @returns {Promise<string[]>} - Array of matching keys
|
|
7932
|
-
*/
|
|
7933
|
-
static keys(pattern: string): Promise<string[]>;
|
|
7934
|
-
/**
|
|
7935
|
-
* @description Renames a key
|
|
7936
|
-
* @param {string} key - The key to rename
|
|
7937
|
-
* @param {string} newKey - The new name for the key
|
|
7938
|
-
* @returns {Promise<string>} - "OK" if successful
|
|
7939
|
-
*/
|
|
7940
|
-
static rename(key: string, newKey: string): Promise<string>;
|
|
7941
|
-
/**
|
|
7942
|
-
* @description Returns the type of value stored at a key
|
|
7943
|
-
* @param {string} key - The key to check
|
|
7944
|
-
* @returns {Promise<string>} - Type of key (string, list, set, zset, hash, or none if key doesn't exist)
|
|
7945
|
-
*/
|
|
7946
|
-
static type(key: string): Promise<string>;
|
|
7947
7724
|
/**
|
|
7948
7725
|
* @description Checks if a key exists
|
|
7949
7726
|
* @param {string} key - The key to check
|
|
@@ -8011,6 +7788,13 @@ declare class RedisDataSource {
|
|
|
8011
7788
|
protected static getValue<T = RedisFetchable>(value: string | null): T | null;
|
|
8012
7789
|
}
|
|
8013
7790
|
|
|
7791
|
+
declare class ObserverChainWrapper {
|
|
7792
|
+
private chain;
|
|
7793
|
+
constructor(observers?: QueryObserver[]);
|
|
7794
|
+
get chainInstance(): ObserverChain;
|
|
7795
|
+
add(observer: QueryObserver): void;
|
|
7796
|
+
}
|
|
7797
|
+
|
|
8014
7798
|
declare class Schema {
|
|
8015
7799
|
queryStatements: string[];
|
|
8016
7800
|
sqlType: SqlDataSourceType;
|
|
@@ -8202,16 +7986,7 @@ declare abstract class BaseSeeder {
|
|
|
8202
7986
|
abstract run(): Promise<void>;
|
|
8203
7987
|
}
|
|
8204
7988
|
|
|
8205
|
-
type
|
|
8206
|
-
/**
|
|
8207
|
-
* @description executes the async function with a timer to check how long it took
|
|
8208
|
-
* @param `returnType` of the performance in milliseconds or seconds
|
|
8209
|
-
* @param `fix` Number of digits in the decimal part of the performance result
|
|
8210
|
-
* @returns An array with the millis or seconds that the function took as first element, and the result of the async function as second element
|
|
8211
|
-
*/
|
|
8212
|
-
declare const withPerformance: <A extends any[], R>(fn: (...args: A) => Promise<R>, returnType?: "millis" | "seconds", fix?: number) => (...args: A) => Promise<WithPerformanceResult<R>>;
|
|
8213
|
-
|
|
8214
|
-
type HysteriaErrorCode = "CONNECTION_ALREADY_ESTABLISHED" | `UNSUPPORTED_ISOLATION_LEVEL_${string}` | "ROW_NOT_FOUND" | `UNSUPPORTED_DATABASE_TYPE_${string}` | `RELATION_TYPE_NOT_SUPPORTED_${string}` | `NOT_SUPPORTED_IN_${string}` | `RELATION_NOT_FOUND_IN_MODEL_${string}` | `UNKNOWN_RELATION_TYPE_${string}` | `DISTINCT_ON_NOT_SUPPORTED_IN_${string}` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_HAS_ONE_RELATION_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_BELONGS_TO_RELATION_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_HAS_MANY_RELATION_${string}` | `MANY_TO_MANY_RELATION_NOT_FOUND_FOR_RELATED_MODEL_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_MANY_TO_MANY_RELATION_${string}` | `RELATED_MODEL_DOES_NOT_HAVE_A_PRIMARY_KEY_${string}` | `FOR_SHARE_NOT_SUPPORTED_IN_${string}` | `SKIP_LOCKED_NOT_SUPPORTED_IN_${string}` | `LOCK_FOR_UPDATE_NOT_SUPPORTED_${string}` | `KEY_${string}_HAS_NO_HANDLER_IN_CACHE_KEYS_CONFIG` | `CACHE_ADAPTER_NOT_CONFIGURED` | `SQLITE_NOT_SUPPORTED` | `COCKROACHDB_NOT_SUPPORTED` | `RELATION_NOT_FOUND` | `POSTGRES_TABLE_REQUIRED` | `MODEL_HAS_NO_PRIMARY_KEY_VALUE` | `RELATION_NOT_MANY_TO_MANY` | "MATERIALIZED_CTE_NOT_SUPPORTED" | "DUPLICATE_MODEL_KEYS_WHILE_INSTANTIATING_MODELS" | "INVALID_ONE_PARAMETER_WHERE_CONDITION" | "INVALID_PAGINATION_PARAMETERS" | "MISSING_ALIAS_FOR_SUBQUERY" | "MODEL_HAS_NO_PRIMARY_KEY" | "PRIMARY_KEY_NOT_FOUND" | "SQLITE_ONLY_SUPPORTS_SERIALIZABLE_ISOLATION_LEVEL" | "MUST_CALL_BUILD_CTE_AT_LEAST_ONCE" | "REGEXP_NOT_SUPPORTED_IN_SQLITE" | "MANY_TO_MANY_RELATION_MUST_HAVE_A_THROUGH_MODEL" | "INSERT_FAILED" | "MULTIPLE_PRIMARY_KEYS_NOT_ALLOWED" | "FILE_NOT_A_SQL_OR_TXT_FILE" | "CONNECTION_NOT_ESTABLISHED" | "TRANSACTION_NOT_ACTIVE" | "DEVELOPMENT_ERROR" | "MIGRATION_MODULE_NOT_FOUND" | "DRIVER_NOT_FOUND" | "FILE_NOT_FOUND_OR_NOT_ACCESSIBLE" | "ENV_NOT_SET" | "REQUIRED_VALUE_NOT_SET" | "SET_FAILED" | "GET_FAILED" | "REFERENCES_OPTION_REQUIRED" | "DELETE_FAILED" | "INVALID_DEFAULT_VALUE" | "DISCONNECT_FAILED" | "FLUSH_FAILED" | "LEFT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "RIGHT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "MODEL_HAS_NO_PRIMARY_KEY" | "GLOBAL_TRANSACTION_ALREADY_STARTED" | "GLOBAL_TRANSACTION_NOT_STARTED" | "MYSQL_REQUIRES_TABLE_NAME_FOR_INDEX_DROP" | "INVALID_DATE_OBJECT" | "INVALID_DATE_STRING" | "FAILED_TO_PARSE_DATE" | "MIGRATION_MODULE_REQUIRES_TS_NODE" | "FAILED_TO_ENCRYPT_SYMMETRICALLY" | "FAILED_TO_DECRYPT_SYMMETRICALLY" | "FAILED_TO_ENCRYPT_ASYMMETRICALLY" | "FAILED_TO_DECRYPT_ASYMMETRICALLY" | "UNSUPPORTED_RELATION_TYPE" | "LPUSH_FAILED" | "RPUSH_FAILED" | "LPOP_FAILED" | "RPOP_FAILED" | "LRANGE_FAILED" | "LLEN_FAILED" | "HSET_FAILED" | "HMSET_FAILED" | "HGET_FAILED" | "HGETALL_FAILED" | "HMGET_FAILED" | "HDEL_FAILED" | "HEXISTS_FAILED" | "HKEYS_FAILED" | "HLEN_FAILED" | "SADD_FAILED" | "SMEMBERS_FAILED" | "SREM_FAILED" | "SISMEMBER_FAILED" | "SCARD_FAILED" | "SINTER_FAILED" | "SUNION_FAILED" | "SDIFF_FAILED" | "ZADD_FAILED" | "ZRANGE_FAILED" | "ZREVRANGE_FAILED" | "ZREM_FAILED" | "ZSCORE_FAILED" | "ZCARD_FAILED" | "SUBSCRIBE_FAILED" | "UNSUBSCRIBE_FAILED" | "PUBLISH_FAILED" | "PSUBSCRIBE_FAILED" | "PUNSUBSCRIBE_FAILED" | "EXISTS_FAILED" | "EXPIRE_FAILED" | "EXPIREAT_FAILED" | "PEXPIRE_FAILED" | "TTL_FAILED" | "PTTL_FAILED" | "PERSIST_FAILED" | "KEYS_FAILED" | "RENAME_FAILED" | "TYPE_FAILED" | "SCAN_FAILED" | "ADMINJS_NOT_ENABLED" | "ADMINJS_INITIALIZATION_FAILED" | "ADMINJS_NO_MODELS_PROVIDED";
|
|
7989
|
+
type HysteriaErrorCode = "VALIDATION_ERROR" | "CONNECTION_ALREADY_ESTABLISHED" | `UNSUPPORTED_ISOLATION_LEVEL_${string}` | "ROW_NOT_FOUND" | `UNSUPPORTED_DATABASE_TYPE_${string}` | `RELATION_TYPE_NOT_SUPPORTED_${string}` | `NOT_SUPPORTED_IN_${string}` | `RELATION_NOT_FOUND_IN_MODEL_${string}` | `UNKNOWN_RELATION_TYPE_${string}` | `DISTINCT_ON_NOT_SUPPORTED_IN_${string}` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_HAS_ONE_RELATION_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_BELONGS_TO_RELATION_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_HAS_MANY_RELATION_${string}` | `MANY_TO_MANY_RELATION_NOT_FOUND_FOR_RELATED_MODEL_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_MANY_TO_MANY_RELATION_${string}` | `RELATED_MODEL_DOES_NOT_HAVE_A_PRIMARY_KEY_${string}` | `FOR_SHARE_NOT_SUPPORTED_IN_${string}` | `SKIP_LOCKED_NOT_SUPPORTED_IN_${string}` | `LOCK_FOR_UPDATE_NOT_SUPPORTED_${string}` | `KEY_${string}_HAS_NO_HANDLER_IN_CACHE_KEYS_CONFIG` | `CACHE_ADAPTER_NOT_CONFIGURED` | `SQLITE_NOT_SUPPORTED` | `COCKROACHDB_NOT_SUPPORTED` | `RELATION_NOT_FOUND` | `POSTGRES_TABLE_REQUIRED` | `MODEL_HAS_NO_PRIMARY_KEY_VALUE` | `RELATION_NOT_MANY_TO_MANY` | "MATERIALIZED_CTE_NOT_SUPPORTED" | "DUPLICATE_MODEL_KEYS_WHILE_INSTANTIATING_MODELS" | "INVALID_ONE_PARAMETER_WHERE_CONDITION" | "INVALID_PAGINATION_PARAMETERS" | "MISSING_ALIAS_FOR_SUBQUERY" | "MODEL_HAS_NO_PRIMARY_KEY" | "PRIMARY_KEY_NOT_FOUND" | "SQLITE_ONLY_SUPPORTS_SERIALIZABLE_ISOLATION_LEVEL" | "MUST_CALL_BUILD_CTE_AT_LEAST_ONCE" | "REGEXP_NOT_SUPPORTED_IN_SQLITE" | "MANY_TO_MANY_RELATION_MUST_HAVE_A_THROUGH_MODEL" | "INSERT_FAILED" | "MULTIPLE_PRIMARY_KEYS_NOT_ALLOWED" | "FILE_NOT_A_SQL_OR_TXT_FILE" | "CONNECTION_NOT_ESTABLISHED" | "TRANSACTION_NOT_ACTIVE" | "DEVELOPMENT_ERROR" | "MIGRATION_MODULE_NOT_FOUND" | "DRIVER_NOT_FOUND" | "FILE_NOT_FOUND_OR_NOT_ACCESSIBLE" | "ENV_NOT_SET" | "REQUIRED_VALUE_NOT_SET" | "SET_FAILED" | "GET_FAILED" | "REFERENCES_OPTION_REQUIRED" | "DELETE_FAILED" | "INVALID_DEFAULT_VALUE" | "DISCONNECT_FAILED" | "FLUSH_FAILED" | "LEFT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "RIGHT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "MODEL_HAS_NO_PRIMARY_KEY" | "GLOBAL_TRANSACTION_ALREADY_STARTED" | "GLOBAL_TRANSACTION_NOT_STARTED" | "MYSQL_REQUIRES_TABLE_NAME_FOR_INDEX_DROP" | "INVALID_DATE_OBJECT" | "INVALID_DATE_STRING" | "FAILED_TO_PARSE_DATE" | "MIGRATION_MODULE_REQUIRES_TS_NODE" | "FAILED_TO_ENCRYPT_SYMMETRICALLY" | "FAILED_TO_DECRYPT_SYMMETRICALLY" | "FAILED_TO_ENCRYPT_ASYMMETRICALLY" | "FAILED_TO_DECRYPT_ASYMMETRICALLY" | "UNSUPPORTED_RELATION_TYPE" | "LPUSH_FAILED" | "RPUSH_FAILED" | "LPOP_FAILED" | "RPOP_FAILED" | "LRANGE_FAILED" | "LLEN_FAILED" | "HSET_FAILED" | "HMSET_FAILED" | "HGET_FAILED" | "HGETALL_FAILED" | "HMGET_FAILED" | "HDEL_FAILED" | "HEXISTS_FAILED" | "HKEYS_FAILED" | "HLEN_FAILED" | "SADD_FAILED" | "SMEMBERS_FAILED" | "SREM_FAILED" | "SISMEMBER_FAILED" | "SCARD_FAILED" | "SINTER_FAILED" | "SUNION_FAILED" | "SDIFF_FAILED" | "ZADD_FAILED" | "ZRANGE_FAILED" | "ZREVRANGE_FAILED" | "ZREM_FAILED" | "ZSCORE_FAILED" | "ZCARD_FAILED" | "SUBSCRIBE_FAILED" | "UNSUBSCRIBE_FAILED" | "PUBLISH_FAILED" | "PSUBSCRIBE_FAILED" | "PUNSUBSCRIBE_FAILED" | "EXISTS_FAILED" | "EXPIRE_FAILED" | "EXPIREAT_FAILED" | "PEXPIRE_FAILED" | "TTL_FAILED" | "PTTL_FAILED" | "PERSIST_FAILED" | "KEYS_FAILED" | "RENAME_FAILED" | "TYPE_FAILED" | "SCAN_FAILED" | "ADMINJS_NOT_ENABLED" | "ADMINJS_INITIALIZATION_FAILED" | "ADMINJS_NO_MODELS_PROVIDED" | `SCOPE_NOT_FOUND_${string}`;
|
|
8215
7990
|
|
|
8216
7991
|
declare class HysteriaError extends Error {
|
|
8217
7992
|
code: HysteriaErrorCode;
|
|
@@ -8219,6 +7994,56 @@ declare class HysteriaError extends Error {
|
|
|
8219
7994
|
error?: Error;
|
|
8220
7995
|
constructor(caller: string, code: HysteriaErrorCode, error?: Error);
|
|
8221
7996
|
}
|
|
7997
|
+
declare class ValidationError extends HysteriaError {
|
|
7998
|
+
errors: Record<string, string[]>;
|
|
7999
|
+
constructor(errors: Record<string, string[]>);
|
|
8000
|
+
}
|
|
8001
|
+
|
|
8002
|
+
/**
|
|
8003
|
+
* @description Field is required and will throw if not provided
|
|
8004
|
+
* @throws HysteriaError with code VALIDATION_ERROR
|
|
8005
|
+
*/
|
|
8006
|
+
declare const required: Validator;
|
|
8007
|
+
/**
|
|
8008
|
+
* @description Field must have a minimum length, null is allowed
|
|
8009
|
+
* @throws HysteriaError with code VALIDATION_ERROR
|
|
8010
|
+
*/
|
|
8011
|
+
declare const minLength: (min: number) => Validator;
|
|
8012
|
+
/**
|
|
8013
|
+
* @description Field must have a maximum length, null is allowed
|
|
8014
|
+
* @throws HysteriaError with code VALIDATION_ERROR
|
|
8015
|
+
*/
|
|
8016
|
+
declare const maxLength: (max: number) => Validator;
|
|
8017
|
+
/**
|
|
8018
|
+
* @description Field must have a minimum value, null is allowed
|
|
8019
|
+
* @throws HysteriaError with code VALIDATION_ERROR
|
|
8020
|
+
*/
|
|
8021
|
+
declare const min: (minValue: number) => Validator;
|
|
8022
|
+
/**
|
|
8023
|
+
* @description Field must have a maximum value, null is allowed
|
|
8024
|
+
* @throws HysteriaError with code VALIDATION_ERROR
|
|
8025
|
+
*/
|
|
8026
|
+
declare const max: (maxValue: number) => Validator;
|
|
8027
|
+
/**
|
|
8028
|
+
* @description Field must match a regex, null is allowed
|
|
8029
|
+
* @throws HysteriaError with code VALIDATION_ERROR
|
|
8030
|
+
*/
|
|
8031
|
+
declare const pattern: (regex: RegExp) => Validator;
|
|
8032
|
+
/**
|
|
8033
|
+
* @description Field must be a valid email, null is allowed
|
|
8034
|
+
* @throws HysteriaError with code VALIDATION_ERROR
|
|
8035
|
+
*/
|
|
8036
|
+
declare const email: Validator;
|
|
8037
|
+
/**
|
|
8038
|
+
* @description Field must be a valid url, null is allowed
|
|
8039
|
+
* @throws HysteriaError with code VALIDATION_ERROR
|
|
8040
|
+
*/
|
|
8041
|
+
declare const url: Validator;
|
|
8042
|
+
/**
|
|
8043
|
+
* @description Field must be a valid enum value, null is allowed
|
|
8044
|
+
* @throws HysteriaError with code VALIDATION_ERROR
|
|
8045
|
+
*/
|
|
8046
|
+
declare const enumValidator: (allowed: readonly string[]) => Validator;
|
|
8222
8047
|
|
|
8223
8048
|
interface PropertyDef<T = unknown> {
|
|
8224
8049
|
_phantom: T;
|
|
@@ -8299,4 +8124,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
|
|
|
8299
8124
|
$id?: string;
|
|
8300
8125
|
}>;
|
|
8301
8126
|
|
|
8302
|
-
export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn
|
|
8127
|
+
export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type OneOptions, type Operation, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PingResult, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, 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 StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, required, url };
|