@plyaz/types 1.24.0 → 1.25.0
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/dist/db/query.types.d.ts +81 -1
- package/package.json +1 -1
package/dist/db/query.types.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Query Builder Types
|
|
3
3
|
*
|
|
4
|
-
* Types for SQL query building utilities used by database adapters
|
|
4
|
+
* Types for SQL query building utilities used by database adapters
|
|
5
|
+
* and the fluent QueryBuilder API.
|
|
5
6
|
*/
|
|
7
|
+
import type { Filter, QueryOptions, DatabaseResult } from './database.types';
|
|
8
|
+
import type { PaginatedResult } from './databsePagination';
|
|
9
|
+
import type { OperationConfig } from './features-config.types';
|
|
6
10
|
/**
|
|
7
11
|
* Options for building SQL WHERE clause conditions
|
|
8
12
|
*/
|
|
@@ -18,3 +22,79 @@ export interface BuildWhereClauseOptions {
|
|
|
18
22
|
/** Starting index for parameter placeholders ($1, $2, etc.) */
|
|
19
23
|
startIndex: number;
|
|
20
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Filter operator types supported by the query builder
|
|
27
|
+
*/
|
|
28
|
+
export type FilterOperator = Filter['operator'];
|
|
29
|
+
/**
|
|
30
|
+
* Raw SQL condition for complex queries
|
|
31
|
+
*/
|
|
32
|
+
export interface RawCondition {
|
|
33
|
+
/** Raw SQL clause (use $1, $2, etc. for parameters) */
|
|
34
|
+
clause: string;
|
|
35
|
+
/** Parameter values for the clause */
|
|
36
|
+
params: unknown[];
|
|
37
|
+
/** Logical operator to combine with other conditions */
|
|
38
|
+
logical?: 'and' | 'or';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* JOIN clause definition
|
|
42
|
+
*/
|
|
43
|
+
export interface JoinClause {
|
|
44
|
+
/** Type of join */
|
|
45
|
+
type: 'inner' | 'left' | 'right' | 'full';
|
|
46
|
+
/** Table to join */
|
|
47
|
+
table: string;
|
|
48
|
+
/** Join condition (e.g., 'users.id = orders.user_id') */
|
|
49
|
+
condition: string;
|
|
50
|
+
/** Optional alias for the joined table */
|
|
51
|
+
alias?: string;
|
|
52
|
+
/** Schema for the joined table */
|
|
53
|
+
schema?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* GROUP BY with optional HAVING clause
|
|
57
|
+
*/
|
|
58
|
+
export interface GroupByClause {
|
|
59
|
+
/** Fields to group by */
|
|
60
|
+
fields: string[];
|
|
61
|
+
/** HAVING conditions (raw SQL) */
|
|
62
|
+
having?: RawCondition[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* SELECT clause options
|
|
66
|
+
*/
|
|
67
|
+
export interface SelectClause {
|
|
68
|
+
/** Specific fields to select (empty = all) */
|
|
69
|
+
fields: string[];
|
|
70
|
+
/** Raw select expressions */
|
|
71
|
+
rawExpressions: string[];
|
|
72
|
+
/** Whether to use DISTINCT */
|
|
73
|
+
distinct: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Result from QueryBuilder.build() containing all query components
|
|
77
|
+
*/
|
|
78
|
+
export interface QueryBuilderResult<TRecord extends object = object> {
|
|
79
|
+
/** Standard QueryOptions for BaseRepository.findMany() */
|
|
80
|
+
options: QueryOptions<TRecord>;
|
|
81
|
+
/** Array of filters for direct SQL building */
|
|
82
|
+
filters: Filter<TRecord>[];
|
|
83
|
+
/** Raw SQL conditions */
|
|
84
|
+
rawConditions: RawCondition[];
|
|
85
|
+
/** JOIN clauses */
|
|
86
|
+
joins: JoinClause[];
|
|
87
|
+
/** GROUP BY clause */
|
|
88
|
+
groupBy?: GroupByClause;
|
|
89
|
+
/** SELECT clause */
|
|
90
|
+
select?: SelectClause;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Repository interface for QueryBuilder execution
|
|
94
|
+
* Matches BaseRepository's method signatures
|
|
95
|
+
*/
|
|
96
|
+
export interface QueryExecutor<TRecord extends object = object> {
|
|
97
|
+
findMany(options?: QueryOptions<TRecord>, config?: OperationConfig): Promise<DatabaseResult<PaginatedResult<TRecord>>>;
|
|
98
|
+
findOne?(filter: Filter<TRecord>, config?: OperationConfig): Promise<DatabaseResult<TRecord | null>>;
|
|
99
|
+
count?(filter?: Filter<TRecord>, config?: OperationConfig): Promise<DatabaseResult<number>>;
|
|
100
|
+
}
|
package/package.json
CHANGED