prisma-sql 1.67.0 → 1.69.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/generator.cjs +3971 -2708
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +3974 -2711
- package/dist/generator.js.map +1 -1
- package/dist/index.cjs +5306 -4366
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +113 -59
- package/dist/index.d.ts +113 -59
- package/dist/index.js +5298 -4363
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { Model as Model$1, ParamMap, DirectiveProps } from '@dee-wan/schema-parser';
|
|
2
|
-
import { DMMF } from '@prisma/generator-helper';
|
|
3
2
|
|
|
4
3
|
type SqlDialect = 'postgres' | 'sqlite';
|
|
5
4
|
|
|
5
|
+
interface LateralRelationMeta {
|
|
6
|
+
name: string;
|
|
7
|
+
isList: boolean;
|
|
8
|
+
fieldTypes: Array<{
|
|
9
|
+
fieldName: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}>;
|
|
12
|
+
nestedRelations: LateralRelationMeta[];
|
|
13
|
+
}
|
|
14
|
+
|
|
6
15
|
type Model = Model$1;
|
|
7
16
|
interface ParamMapping {
|
|
8
17
|
index: number;
|
|
@@ -15,7 +24,9 @@ interface SqlResult {
|
|
|
15
24
|
paramMappings?: ParamMapping[];
|
|
16
25
|
requiresReduction?: boolean;
|
|
17
26
|
includeSpec?: Record<string, any>;
|
|
18
|
-
|
|
27
|
+
isLateral?: boolean;
|
|
28
|
+
lateralMeta?: LateralRelationMeta[];
|
|
29
|
+
skipWhereIn?: boolean;
|
|
19
30
|
}
|
|
20
31
|
type PrismaMethod = 'findUnique' | 'findFirst' | 'findMany' | 'create' | 'createMany' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
21
32
|
interface PrismaSQLConfig<TClient> {
|
|
@@ -41,33 +52,12 @@ interface SQLDirective {
|
|
|
41
52
|
paramMappings: readonly ParamMap[];
|
|
42
53
|
requiresReduction: boolean;
|
|
43
54
|
includeSpec: Record<string, any>;
|
|
55
|
+
isLateral: boolean;
|
|
56
|
+
lateralMeta?: LateralRelationMeta[];
|
|
57
|
+
skipWhereIn?: boolean;
|
|
44
58
|
originalDirective: DirectiveProps;
|
|
45
59
|
}
|
|
46
60
|
|
|
47
|
-
interface BatchQuery {
|
|
48
|
-
model: string;
|
|
49
|
-
method: PrismaMethod;
|
|
50
|
-
args?: Record<string, unknown>;
|
|
51
|
-
}
|
|
52
|
-
interface BatchCountQuery {
|
|
53
|
-
model: string;
|
|
54
|
-
method: 'count';
|
|
55
|
-
args?: {
|
|
56
|
-
where?: Record<string, unknown>;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
interface BatchResult {
|
|
60
|
-
sql: string;
|
|
61
|
-
params: unknown[];
|
|
62
|
-
}
|
|
63
|
-
declare function buildBatchSql(queries: Record<string, BatchQuery>, modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult & {
|
|
64
|
-
keys: string[];
|
|
65
|
-
aliases: string[];
|
|
66
|
-
};
|
|
67
|
-
declare function buildBatchCountSql(queries: BatchCountQuery[], modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult;
|
|
68
|
-
declare function parseBatchCountResults(row: Record<string, unknown>, queryCount: number): number[];
|
|
69
|
-
declare function parseBatchResults(row: Record<string, unknown>, keys: string[], queries: Record<string, BatchQuery>, aliases?: string[], modelMap?: Map<string, Model>): Record<string, unknown>;
|
|
70
|
-
|
|
71
61
|
interface TransactionQuery {
|
|
72
62
|
model: string;
|
|
73
63
|
method: PrismaMethod;
|
|
@@ -90,14 +80,6 @@ declare function createTransactionExecutor(deps: {
|
|
|
90
80
|
|
|
91
81
|
declare function transformQueryResults(method: string, results: unknown): unknown;
|
|
92
82
|
|
|
93
|
-
type RelStats = {
|
|
94
|
-
avg: number;
|
|
95
|
-
p95: number;
|
|
96
|
-
p99: number;
|
|
97
|
-
max: number;
|
|
98
|
-
coverage: number;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
83
|
interface WhereInSegment {
|
|
102
84
|
relationName: string;
|
|
103
85
|
relArgs: unknown;
|
|
@@ -105,21 +87,26 @@ interface WhereInSegment {
|
|
|
105
87
|
fkFieldName: string;
|
|
106
88
|
parentKeyFieldName: string;
|
|
107
89
|
isList: boolean;
|
|
90
|
+
perParentTake?: number;
|
|
91
|
+
perParentSkip?: number;
|
|
108
92
|
}
|
|
109
93
|
interface QueryPlan {
|
|
110
94
|
filteredArgs: any;
|
|
95
|
+
originalArgs: any;
|
|
111
96
|
whereInSegments: WhereInSegment[];
|
|
97
|
+
injectedParentKeys: string[];
|
|
112
98
|
}
|
|
113
|
-
type RelationStatsLike = Record<string, Record<string, RelStats>>;
|
|
114
99
|
declare function planQueryStrategy(params: {
|
|
115
100
|
model: Model;
|
|
116
101
|
method: string;
|
|
117
102
|
args: any;
|
|
118
103
|
allModels: readonly Model[];
|
|
119
|
-
relationStats?: RelationStatsLike;
|
|
120
104
|
dialect: 'postgres' | 'sqlite';
|
|
105
|
+
debug?: boolean;
|
|
121
106
|
}): QueryPlan;
|
|
122
107
|
|
|
108
|
+
type ExecuteFn = (sql: string, params: unknown[]) => Promise<any[]>;
|
|
109
|
+
|
|
123
110
|
interface ExecuteWhereInParams {
|
|
124
111
|
segments: WhereInSegment[];
|
|
125
112
|
parentRows: any[];
|
|
@@ -127,11 +114,69 @@ interface ExecuteWhereInParams {
|
|
|
127
114
|
allModels: readonly Model[];
|
|
128
115
|
modelMap: Map<string, Model>;
|
|
129
116
|
dialect: 'postgres' | 'sqlite';
|
|
130
|
-
execute:
|
|
117
|
+
execute: ExecuteFn;
|
|
131
118
|
}
|
|
132
|
-
|
|
133
119
|
declare function executeWhereInSegments(params: ExecuteWhereInParams): Promise<void>;
|
|
134
120
|
|
|
121
|
+
interface StreamingWhereInParams {
|
|
122
|
+
segments: WhereInSegment[];
|
|
123
|
+
parentSql: string;
|
|
124
|
+
parentParams: unknown[];
|
|
125
|
+
parentModel: Model;
|
|
126
|
+
allModels: readonly Model[];
|
|
127
|
+
modelMap: Map<string, Model>;
|
|
128
|
+
dialect: 'postgres' | 'sqlite';
|
|
129
|
+
execute: ExecuteFn;
|
|
130
|
+
stream?: (sql: string, params: unknown[], onRow: (row: any) => void) => Promise<void>;
|
|
131
|
+
parentTake?: number;
|
|
132
|
+
}
|
|
133
|
+
interface PreFetchedWhereInParams {
|
|
134
|
+
segments: WhereInSegment[];
|
|
135
|
+
parentRows: any[];
|
|
136
|
+
parentModel: Model;
|
|
137
|
+
allModels: readonly Model[];
|
|
138
|
+
modelMap: Map<string, Model>;
|
|
139
|
+
dialect: 'postgres' | 'sqlite';
|
|
140
|
+
execute: ExecuteFn;
|
|
141
|
+
}
|
|
142
|
+
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
143
|
+
declare function executeWithPreFetchedParents(params: PreFetchedWhereInParams): Promise<any[]>;
|
|
144
|
+
|
|
145
|
+
declare function getPrimaryKeyField(model: Model): string;
|
|
146
|
+
|
|
147
|
+
interface LateralReducerConfig {
|
|
148
|
+
parentScalarFields: string[];
|
|
149
|
+
parentJsonSet: ReadonlySet<string>;
|
|
150
|
+
relations: LateralRelationMeta[];
|
|
151
|
+
}
|
|
152
|
+
declare function buildLateralReducerConfig(parentModel: Model, lateralMeta: LateralRelationMeta[]): LateralReducerConfig;
|
|
153
|
+
declare function reduceLateralRows(rows: any[], config: LateralReducerConfig): any[];
|
|
154
|
+
|
|
155
|
+
interface BatchQuery {
|
|
156
|
+
model: string;
|
|
157
|
+
method: PrismaMethod;
|
|
158
|
+
args?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
interface BatchCountQuery {
|
|
161
|
+
model: string;
|
|
162
|
+
method: 'count';
|
|
163
|
+
args?: {
|
|
164
|
+
where?: Record<string, unknown>;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
interface BatchResult {
|
|
168
|
+
sql: string;
|
|
169
|
+
params: unknown[];
|
|
170
|
+
}
|
|
171
|
+
declare function buildBatchSql(queries: Record<string, BatchQuery>, modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult & {
|
|
172
|
+
keys: string[];
|
|
173
|
+
aliases: string[];
|
|
174
|
+
};
|
|
175
|
+
declare function buildBatchCountSql(queries: BatchCountQuery[], modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult;
|
|
176
|
+
|
|
177
|
+
declare function parseBatchCountResults(row: Record<string, unknown>, queryCount: number): number[];
|
|
178
|
+
declare function parseBatchResults(row: Record<string, unknown>, keys: string[], queries: Record<string, BatchQuery>, aliases?: string[], modelMap?: Map<string, Model>): Record<string, unknown>;
|
|
179
|
+
|
|
135
180
|
interface ReducerConfig {
|
|
136
181
|
parentModel: Model;
|
|
137
182
|
includedRelations: RelationMetadata[];
|
|
@@ -150,6 +195,7 @@ interface RelationMetadata {
|
|
|
150
195
|
includeAllScalars: boolean;
|
|
151
196
|
selectedScalarFields: string[];
|
|
152
197
|
nestedIncludes?: ReducerConfig | null;
|
|
198
|
+
childLimit?: number;
|
|
153
199
|
path: string;
|
|
154
200
|
keyCols: string[];
|
|
155
201
|
scalarCols: ScalarColSpec[];
|
|
@@ -162,7 +208,7 @@ declare function normalizeValue(value: unknown, seen?: WeakSet<object>, depth?:
|
|
|
162
208
|
declare function createStreamingReducer(config: ReducerConfig): {
|
|
163
209
|
processRow(row: any): void;
|
|
164
210
|
getResults(): any[];
|
|
165
|
-
getParentMap(): Map<
|
|
211
|
+
getParentMap(): Map<unknown, any>;
|
|
166
212
|
};
|
|
167
213
|
|
|
168
214
|
interface ProgressiveReducer {
|
|
@@ -173,20 +219,6 @@ interface ProgressiveReducer {
|
|
|
173
219
|
}
|
|
174
220
|
declare function createProgressiveReducer(config: ReducerConfig): ProgressiveReducer;
|
|
175
221
|
|
|
176
|
-
interface StreamingWhereInParams {
|
|
177
|
-
segments: WhereInSegment[];
|
|
178
|
-
parentSql: string;
|
|
179
|
-
parentParams: unknown[];
|
|
180
|
-
parentModel: Model;
|
|
181
|
-
allModels: readonly Model[];
|
|
182
|
-
modelMap: Map<string, Model>;
|
|
183
|
-
dialect: 'postgres' | 'sqlite';
|
|
184
|
-
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
185
|
-
batchSize?: number;
|
|
186
|
-
maxConcurrency?: number;
|
|
187
|
-
}
|
|
188
|
-
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
189
|
-
|
|
190
222
|
declare function transformAggregateRow(row: any): any;
|
|
191
223
|
declare function extractCountValue(row: any): number | bigint;
|
|
192
224
|
declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
@@ -194,15 +226,37 @@ declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
|
194
226
|
declare function getOrPrepareStatement(client: any, sql: string): any;
|
|
195
227
|
declare function shouldSqliteUseGet(method: string): boolean;
|
|
196
228
|
declare function normalizeParams(params: unknown[]): unknown[];
|
|
197
|
-
|
|
229
|
+
interface PostgresQueryOptions {
|
|
230
|
+
client: any;
|
|
231
|
+
sql: string;
|
|
232
|
+
params: unknown[];
|
|
233
|
+
method: string;
|
|
234
|
+
requiresReduction: boolean;
|
|
235
|
+
includeSpec?: Record<string, any>;
|
|
236
|
+
model: any;
|
|
237
|
+
allModels: readonly any[];
|
|
238
|
+
isLateral?: boolean;
|
|
239
|
+
lateralMeta?: LateralRelationMeta[];
|
|
240
|
+
}
|
|
241
|
+
declare function executePostgresQuery(opts: PostgresQueryOptions): Promise<unknown[]>;
|
|
198
242
|
declare function executeSqliteQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any, allModels: readonly any[]): unknown[];
|
|
199
243
|
declare function executeRaw(client: any, sql: string, params: unknown[] | undefined, dialect: string): Promise<unknown[]>;
|
|
200
244
|
|
|
245
|
+
type RelStats = {
|
|
246
|
+
avg: number;
|
|
247
|
+
p95: number;
|
|
248
|
+
p99: number;
|
|
249
|
+
max: number;
|
|
250
|
+
coverage: number;
|
|
251
|
+
};
|
|
252
|
+
type RelationStatsMap = Record<string, Record<string, RelStats>>;
|
|
253
|
+
declare function setRoundtripRowEquivalent(value: number): void;
|
|
254
|
+
declare function setJsonRowFactor(value: number): void;
|
|
255
|
+
declare function setRelationStats(stats: RelationStatsMap): void;
|
|
256
|
+
declare function getRelationStats(): RelationStatsMap | undefined;
|
|
257
|
+
declare function countIncludeDepth(includeSpec: Record<string, any>, model: Model, schemas: readonly Model[]): number;
|
|
258
|
+
|
|
201
259
|
declare function buildSQL(model: Model, models: Model[], method: PrismaMethod, args: Record<string, unknown>, dialect: SqlDialect): SqlResult;
|
|
202
|
-
declare function createToSQL(modelsOrDmmf: Model[] | DMMF.Document, dialect: SqlDialect): (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
|
|
203
|
-
declare function createPrismaSQL<TClient>(config: PrismaSQLConfig<TClient>): PrismaSQLResult<TClient>;
|
|
204
260
|
declare function generateSQL(directive: DirectiveProps): SQLDirective;
|
|
205
|
-
declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
|
|
206
|
-
declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
|
|
207
261
|
|
|
208
|
-
export { type BatchCountQuery, type BatchQuery, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type ReducerConfig, type SqlResult, type TransactionOptions, type TransactionQuery, buildBatchCountSql, buildBatchSql, buildReducerConfig, buildSQL,
|
|
262
|
+
export { type BatchCountQuery, type BatchQuery, type LateralRelationMeta, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type ReducerConfig, type SqlResult, type TransactionOptions, type TransactionQuery, buildBatchCountSql, buildBatchSql, buildLateralReducerConfig, buildReducerConfig, buildSQL, countIncludeDepth, createProgressiveReducer, createStreamingReducer, createTransactionExecutor, executePostgresQuery, executeRaw, executeSqliteQuery, executeWhereInSegments, executeWhereInSegmentsStreaming, executeWithPreFetchedParents, extractCountValue, generateSQL, getOrPrepareStatement, getPrimaryKeyField, getRelationStats, getRowTransformer, normalizeParams, normalizeValue, parseBatchCountResults, parseBatchResults, planQueryStrategy, reduceFlatRows, reduceLateralRows, setJsonRowFactor, setRelationStats, setRoundtripRowEquivalent, shouldSqliteUseGet, transformAggregateRow, transformQueryResults };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { Model as Model$1, ParamMap, DirectiveProps } from '@dee-wan/schema-parser';
|
|
2
|
-
import { DMMF } from '@prisma/generator-helper';
|
|
3
2
|
|
|
4
3
|
type SqlDialect = 'postgres' | 'sqlite';
|
|
5
4
|
|
|
5
|
+
interface LateralRelationMeta {
|
|
6
|
+
name: string;
|
|
7
|
+
isList: boolean;
|
|
8
|
+
fieldTypes: Array<{
|
|
9
|
+
fieldName: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}>;
|
|
12
|
+
nestedRelations: LateralRelationMeta[];
|
|
13
|
+
}
|
|
14
|
+
|
|
6
15
|
type Model = Model$1;
|
|
7
16
|
interface ParamMapping {
|
|
8
17
|
index: number;
|
|
@@ -15,7 +24,9 @@ interface SqlResult {
|
|
|
15
24
|
paramMappings?: ParamMapping[];
|
|
16
25
|
requiresReduction?: boolean;
|
|
17
26
|
includeSpec?: Record<string, any>;
|
|
18
|
-
|
|
27
|
+
isLateral?: boolean;
|
|
28
|
+
lateralMeta?: LateralRelationMeta[];
|
|
29
|
+
skipWhereIn?: boolean;
|
|
19
30
|
}
|
|
20
31
|
type PrismaMethod = 'findUnique' | 'findFirst' | 'findMany' | 'create' | 'createMany' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
21
32
|
interface PrismaSQLConfig<TClient> {
|
|
@@ -41,33 +52,12 @@ interface SQLDirective {
|
|
|
41
52
|
paramMappings: readonly ParamMap[];
|
|
42
53
|
requiresReduction: boolean;
|
|
43
54
|
includeSpec: Record<string, any>;
|
|
55
|
+
isLateral: boolean;
|
|
56
|
+
lateralMeta?: LateralRelationMeta[];
|
|
57
|
+
skipWhereIn?: boolean;
|
|
44
58
|
originalDirective: DirectiveProps;
|
|
45
59
|
}
|
|
46
60
|
|
|
47
|
-
interface BatchQuery {
|
|
48
|
-
model: string;
|
|
49
|
-
method: PrismaMethod;
|
|
50
|
-
args?: Record<string, unknown>;
|
|
51
|
-
}
|
|
52
|
-
interface BatchCountQuery {
|
|
53
|
-
model: string;
|
|
54
|
-
method: 'count';
|
|
55
|
-
args?: {
|
|
56
|
-
where?: Record<string, unknown>;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
interface BatchResult {
|
|
60
|
-
sql: string;
|
|
61
|
-
params: unknown[];
|
|
62
|
-
}
|
|
63
|
-
declare function buildBatchSql(queries: Record<string, BatchQuery>, modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult & {
|
|
64
|
-
keys: string[];
|
|
65
|
-
aliases: string[];
|
|
66
|
-
};
|
|
67
|
-
declare function buildBatchCountSql(queries: BatchCountQuery[], modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult;
|
|
68
|
-
declare function parseBatchCountResults(row: Record<string, unknown>, queryCount: number): number[];
|
|
69
|
-
declare function parseBatchResults(row: Record<string, unknown>, keys: string[], queries: Record<string, BatchQuery>, aliases?: string[], modelMap?: Map<string, Model>): Record<string, unknown>;
|
|
70
|
-
|
|
71
61
|
interface TransactionQuery {
|
|
72
62
|
model: string;
|
|
73
63
|
method: PrismaMethod;
|
|
@@ -90,14 +80,6 @@ declare function createTransactionExecutor(deps: {
|
|
|
90
80
|
|
|
91
81
|
declare function transformQueryResults(method: string, results: unknown): unknown;
|
|
92
82
|
|
|
93
|
-
type RelStats = {
|
|
94
|
-
avg: number;
|
|
95
|
-
p95: number;
|
|
96
|
-
p99: number;
|
|
97
|
-
max: number;
|
|
98
|
-
coverage: number;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
83
|
interface WhereInSegment {
|
|
102
84
|
relationName: string;
|
|
103
85
|
relArgs: unknown;
|
|
@@ -105,21 +87,26 @@ interface WhereInSegment {
|
|
|
105
87
|
fkFieldName: string;
|
|
106
88
|
parentKeyFieldName: string;
|
|
107
89
|
isList: boolean;
|
|
90
|
+
perParentTake?: number;
|
|
91
|
+
perParentSkip?: number;
|
|
108
92
|
}
|
|
109
93
|
interface QueryPlan {
|
|
110
94
|
filteredArgs: any;
|
|
95
|
+
originalArgs: any;
|
|
111
96
|
whereInSegments: WhereInSegment[];
|
|
97
|
+
injectedParentKeys: string[];
|
|
112
98
|
}
|
|
113
|
-
type RelationStatsLike = Record<string, Record<string, RelStats>>;
|
|
114
99
|
declare function planQueryStrategy(params: {
|
|
115
100
|
model: Model;
|
|
116
101
|
method: string;
|
|
117
102
|
args: any;
|
|
118
103
|
allModels: readonly Model[];
|
|
119
|
-
relationStats?: RelationStatsLike;
|
|
120
104
|
dialect: 'postgres' | 'sqlite';
|
|
105
|
+
debug?: boolean;
|
|
121
106
|
}): QueryPlan;
|
|
122
107
|
|
|
108
|
+
type ExecuteFn = (sql: string, params: unknown[]) => Promise<any[]>;
|
|
109
|
+
|
|
123
110
|
interface ExecuteWhereInParams {
|
|
124
111
|
segments: WhereInSegment[];
|
|
125
112
|
parentRows: any[];
|
|
@@ -127,11 +114,69 @@ interface ExecuteWhereInParams {
|
|
|
127
114
|
allModels: readonly Model[];
|
|
128
115
|
modelMap: Map<string, Model>;
|
|
129
116
|
dialect: 'postgres' | 'sqlite';
|
|
130
|
-
execute:
|
|
117
|
+
execute: ExecuteFn;
|
|
131
118
|
}
|
|
132
|
-
|
|
133
119
|
declare function executeWhereInSegments(params: ExecuteWhereInParams): Promise<void>;
|
|
134
120
|
|
|
121
|
+
interface StreamingWhereInParams {
|
|
122
|
+
segments: WhereInSegment[];
|
|
123
|
+
parentSql: string;
|
|
124
|
+
parentParams: unknown[];
|
|
125
|
+
parentModel: Model;
|
|
126
|
+
allModels: readonly Model[];
|
|
127
|
+
modelMap: Map<string, Model>;
|
|
128
|
+
dialect: 'postgres' | 'sqlite';
|
|
129
|
+
execute: ExecuteFn;
|
|
130
|
+
stream?: (sql: string, params: unknown[], onRow: (row: any) => void) => Promise<void>;
|
|
131
|
+
parentTake?: number;
|
|
132
|
+
}
|
|
133
|
+
interface PreFetchedWhereInParams {
|
|
134
|
+
segments: WhereInSegment[];
|
|
135
|
+
parentRows: any[];
|
|
136
|
+
parentModel: Model;
|
|
137
|
+
allModels: readonly Model[];
|
|
138
|
+
modelMap: Map<string, Model>;
|
|
139
|
+
dialect: 'postgres' | 'sqlite';
|
|
140
|
+
execute: ExecuteFn;
|
|
141
|
+
}
|
|
142
|
+
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
143
|
+
declare function executeWithPreFetchedParents(params: PreFetchedWhereInParams): Promise<any[]>;
|
|
144
|
+
|
|
145
|
+
declare function getPrimaryKeyField(model: Model): string;
|
|
146
|
+
|
|
147
|
+
interface LateralReducerConfig {
|
|
148
|
+
parentScalarFields: string[];
|
|
149
|
+
parentJsonSet: ReadonlySet<string>;
|
|
150
|
+
relations: LateralRelationMeta[];
|
|
151
|
+
}
|
|
152
|
+
declare function buildLateralReducerConfig(parentModel: Model, lateralMeta: LateralRelationMeta[]): LateralReducerConfig;
|
|
153
|
+
declare function reduceLateralRows(rows: any[], config: LateralReducerConfig): any[];
|
|
154
|
+
|
|
155
|
+
interface BatchQuery {
|
|
156
|
+
model: string;
|
|
157
|
+
method: PrismaMethod;
|
|
158
|
+
args?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
interface BatchCountQuery {
|
|
161
|
+
model: string;
|
|
162
|
+
method: 'count';
|
|
163
|
+
args?: {
|
|
164
|
+
where?: Record<string, unknown>;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
interface BatchResult {
|
|
168
|
+
sql: string;
|
|
169
|
+
params: unknown[];
|
|
170
|
+
}
|
|
171
|
+
declare function buildBatchSql(queries: Record<string, BatchQuery>, modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult & {
|
|
172
|
+
keys: string[];
|
|
173
|
+
aliases: string[];
|
|
174
|
+
};
|
|
175
|
+
declare function buildBatchCountSql(queries: BatchCountQuery[], modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult;
|
|
176
|
+
|
|
177
|
+
declare function parseBatchCountResults(row: Record<string, unknown>, queryCount: number): number[];
|
|
178
|
+
declare function parseBatchResults(row: Record<string, unknown>, keys: string[], queries: Record<string, BatchQuery>, aliases?: string[], modelMap?: Map<string, Model>): Record<string, unknown>;
|
|
179
|
+
|
|
135
180
|
interface ReducerConfig {
|
|
136
181
|
parentModel: Model;
|
|
137
182
|
includedRelations: RelationMetadata[];
|
|
@@ -150,6 +195,7 @@ interface RelationMetadata {
|
|
|
150
195
|
includeAllScalars: boolean;
|
|
151
196
|
selectedScalarFields: string[];
|
|
152
197
|
nestedIncludes?: ReducerConfig | null;
|
|
198
|
+
childLimit?: number;
|
|
153
199
|
path: string;
|
|
154
200
|
keyCols: string[];
|
|
155
201
|
scalarCols: ScalarColSpec[];
|
|
@@ -162,7 +208,7 @@ declare function normalizeValue(value: unknown, seen?: WeakSet<object>, depth?:
|
|
|
162
208
|
declare function createStreamingReducer(config: ReducerConfig): {
|
|
163
209
|
processRow(row: any): void;
|
|
164
210
|
getResults(): any[];
|
|
165
|
-
getParentMap(): Map<
|
|
211
|
+
getParentMap(): Map<unknown, any>;
|
|
166
212
|
};
|
|
167
213
|
|
|
168
214
|
interface ProgressiveReducer {
|
|
@@ -173,20 +219,6 @@ interface ProgressiveReducer {
|
|
|
173
219
|
}
|
|
174
220
|
declare function createProgressiveReducer(config: ReducerConfig): ProgressiveReducer;
|
|
175
221
|
|
|
176
|
-
interface StreamingWhereInParams {
|
|
177
|
-
segments: WhereInSegment[];
|
|
178
|
-
parentSql: string;
|
|
179
|
-
parentParams: unknown[];
|
|
180
|
-
parentModel: Model;
|
|
181
|
-
allModels: readonly Model[];
|
|
182
|
-
modelMap: Map<string, Model>;
|
|
183
|
-
dialect: 'postgres' | 'sqlite';
|
|
184
|
-
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
185
|
-
batchSize?: number;
|
|
186
|
-
maxConcurrency?: number;
|
|
187
|
-
}
|
|
188
|
-
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
189
|
-
|
|
190
222
|
declare function transformAggregateRow(row: any): any;
|
|
191
223
|
declare function extractCountValue(row: any): number | bigint;
|
|
192
224
|
declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
@@ -194,15 +226,37 @@ declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
|
194
226
|
declare function getOrPrepareStatement(client: any, sql: string): any;
|
|
195
227
|
declare function shouldSqliteUseGet(method: string): boolean;
|
|
196
228
|
declare function normalizeParams(params: unknown[]): unknown[];
|
|
197
|
-
|
|
229
|
+
interface PostgresQueryOptions {
|
|
230
|
+
client: any;
|
|
231
|
+
sql: string;
|
|
232
|
+
params: unknown[];
|
|
233
|
+
method: string;
|
|
234
|
+
requiresReduction: boolean;
|
|
235
|
+
includeSpec?: Record<string, any>;
|
|
236
|
+
model: any;
|
|
237
|
+
allModels: readonly any[];
|
|
238
|
+
isLateral?: boolean;
|
|
239
|
+
lateralMeta?: LateralRelationMeta[];
|
|
240
|
+
}
|
|
241
|
+
declare function executePostgresQuery(opts: PostgresQueryOptions): Promise<unknown[]>;
|
|
198
242
|
declare function executeSqliteQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any, allModels: readonly any[]): unknown[];
|
|
199
243
|
declare function executeRaw(client: any, sql: string, params: unknown[] | undefined, dialect: string): Promise<unknown[]>;
|
|
200
244
|
|
|
245
|
+
type RelStats = {
|
|
246
|
+
avg: number;
|
|
247
|
+
p95: number;
|
|
248
|
+
p99: number;
|
|
249
|
+
max: number;
|
|
250
|
+
coverage: number;
|
|
251
|
+
};
|
|
252
|
+
type RelationStatsMap = Record<string, Record<string, RelStats>>;
|
|
253
|
+
declare function setRoundtripRowEquivalent(value: number): void;
|
|
254
|
+
declare function setJsonRowFactor(value: number): void;
|
|
255
|
+
declare function setRelationStats(stats: RelationStatsMap): void;
|
|
256
|
+
declare function getRelationStats(): RelationStatsMap | undefined;
|
|
257
|
+
declare function countIncludeDepth(includeSpec: Record<string, any>, model: Model, schemas: readonly Model[]): number;
|
|
258
|
+
|
|
201
259
|
declare function buildSQL(model: Model, models: Model[], method: PrismaMethod, args: Record<string, unknown>, dialect: SqlDialect): SqlResult;
|
|
202
|
-
declare function createToSQL(modelsOrDmmf: Model[] | DMMF.Document, dialect: SqlDialect): (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
|
|
203
|
-
declare function createPrismaSQL<TClient>(config: PrismaSQLConfig<TClient>): PrismaSQLResult<TClient>;
|
|
204
260
|
declare function generateSQL(directive: DirectiveProps): SQLDirective;
|
|
205
|
-
declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
|
|
206
|
-
declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
|
|
207
261
|
|
|
208
|
-
export { type BatchCountQuery, type BatchQuery, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type ReducerConfig, type SqlResult, type TransactionOptions, type TransactionQuery, buildBatchCountSql, buildBatchSql, buildReducerConfig, buildSQL,
|
|
262
|
+
export { type BatchCountQuery, type BatchQuery, type LateralRelationMeta, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type ReducerConfig, type SqlResult, type TransactionOptions, type TransactionQuery, buildBatchCountSql, buildBatchSql, buildLateralReducerConfig, buildReducerConfig, buildSQL, countIncludeDepth, createProgressiveReducer, createStreamingReducer, createTransactionExecutor, executePostgresQuery, executeRaw, executeSqliteQuery, executeWhereInSegments, executeWhereInSegmentsStreaming, executeWithPreFetchedParents, extractCountValue, generateSQL, getOrPrepareStatement, getPrimaryKeyField, getRelationStats, getRowTransformer, normalizeParams, normalizeValue, parseBatchCountResults, parseBatchResults, planQueryStrategy, reduceFlatRows, reduceLateralRows, setJsonRowFactor, setRelationStats, setRoundtripRowEquivalent, shouldSqliteUseGet, transformAggregateRow, transformQueryResults };
|