prisma-sql 1.68.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 +3819 -2915
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +3822 -2918
- package/dist/generator.js.map +1 -1
- package/dist/index.cjs +6113 -5881
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +88 -59
- package/dist/index.d.ts +88 -59
- package/dist/index.js +6107 -5876
- 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,8 +24,9 @@ interface SqlResult {
|
|
|
15
24
|
paramMappings?: ParamMapping[];
|
|
16
25
|
requiresReduction?: boolean;
|
|
17
26
|
includeSpec?: Record<string, any>;
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
isLateral?: boolean;
|
|
28
|
+
lateralMeta?: LateralRelationMeta[];
|
|
29
|
+
skipWhereIn?: boolean;
|
|
20
30
|
}
|
|
21
31
|
type PrismaMethod = 'findUnique' | 'findFirst' | 'findMany' | 'create' | 'createMany' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
22
32
|
interface PrismaSQLConfig<TClient> {
|
|
@@ -42,34 +52,12 @@ interface SQLDirective {
|
|
|
42
52
|
paramMappings: readonly ParamMap[];
|
|
43
53
|
requiresReduction: boolean;
|
|
44
54
|
includeSpec: Record<string, any>;
|
|
45
|
-
|
|
55
|
+
isLateral: boolean;
|
|
56
|
+
lateralMeta?: LateralRelationMeta[];
|
|
57
|
+
skipWhereIn?: boolean;
|
|
46
58
|
originalDirective: DirectiveProps;
|
|
47
59
|
}
|
|
48
60
|
|
|
49
|
-
interface BatchQuery {
|
|
50
|
-
model: string;
|
|
51
|
-
method: PrismaMethod;
|
|
52
|
-
args?: Record<string, unknown>;
|
|
53
|
-
}
|
|
54
|
-
interface BatchCountQuery {
|
|
55
|
-
model: string;
|
|
56
|
-
method: 'count';
|
|
57
|
-
args?: {
|
|
58
|
-
where?: Record<string, unknown>;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
interface BatchResult {
|
|
62
|
-
sql: string;
|
|
63
|
-
params: unknown[];
|
|
64
|
-
}
|
|
65
|
-
declare function buildBatchSql(queries: Record<string, BatchQuery>, modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult & {
|
|
66
|
-
keys: string[];
|
|
67
|
-
aliases: string[];
|
|
68
|
-
};
|
|
69
|
-
declare function buildBatchCountSql(queries: BatchCountQuery[], modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult;
|
|
70
|
-
declare function parseBatchCountResults(row: Record<string, unknown>, queryCount: number): number[];
|
|
71
|
-
declare function parseBatchResults(row: Record<string, unknown>, keys: string[], queries: Record<string, BatchQuery>, aliases?: string[], modelMap?: Map<string, Model>): Record<string, unknown>;
|
|
72
|
-
|
|
73
61
|
interface TransactionQuery {
|
|
74
62
|
model: string;
|
|
75
63
|
method: PrismaMethod;
|
|
@@ -99,9 +87,12 @@ interface WhereInSegment {
|
|
|
99
87
|
fkFieldName: string;
|
|
100
88
|
parentKeyFieldName: string;
|
|
101
89
|
isList: boolean;
|
|
90
|
+
perParentTake?: number;
|
|
91
|
+
perParentSkip?: number;
|
|
102
92
|
}
|
|
103
93
|
interface QueryPlan {
|
|
104
94
|
filteredArgs: any;
|
|
95
|
+
originalArgs: any;
|
|
105
96
|
whereInSegments: WhereInSegment[];
|
|
106
97
|
injectedParentKeys: string[];
|
|
107
98
|
}
|
|
@@ -111,8 +102,11 @@ declare function planQueryStrategy(params: {
|
|
|
111
102
|
args: any;
|
|
112
103
|
allModels: readonly Model[];
|
|
113
104
|
dialect: 'postgres' | 'sqlite';
|
|
105
|
+
debug?: boolean;
|
|
114
106
|
}): QueryPlan;
|
|
115
107
|
|
|
108
|
+
type ExecuteFn = (sql: string, params: unknown[]) => Promise<any[]>;
|
|
109
|
+
|
|
116
110
|
interface ExecuteWhereInParams {
|
|
117
111
|
segments: WhereInSegment[];
|
|
118
112
|
parentRows: any[];
|
|
@@ -120,32 +114,10 @@ interface ExecuteWhereInParams {
|
|
|
120
114
|
allModels: readonly Model[];
|
|
121
115
|
modelMap: Map<string, Model>;
|
|
122
116
|
dialect: 'postgres' | 'sqlite';
|
|
123
|
-
execute:
|
|
124
|
-
originalArgs?: any;
|
|
125
|
-
method?: string;
|
|
117
|
+
execute: ExecuteFn;
|
|
126
118
|
}
|
|
127
|
-
|
|
128
119
|
declare function executeWhereInSegments(params: ExecuteWhereInParams): Promise<void>;
|
|
129
120
|
|
|
130
|
-
interface ArrayAggRelationMeta {
|
|
131
|
-
name: string;
|
|
132
|
-
isList: boolean;
|
|
133
|
-
scalarFields: Array<{
|
|
134
|
-
fieldName: string;
|
|
135
|
-
colName: string;
|
|
136
|
-
isJson: boolean;
|
|
137
|
-
}>;
|
|
138
|
-
pkFieldName: string;
|
|
139
|
-
}
|
|
140
|
-
interface ArrayAggReducerConfig {
|
|
141
|
-
parentModel: Model;
|
|
142
|
-
parentScalarFields: string[];
|
|
143
|
-
parentJsonSet: ReadonlySet<string>;
|
|
144
|
-
relations: ArrayAggRelationMeta[];
|
|
145
|
-
}
|
|
146
|
-
declare function buildArrayAggReducerConfig(parentModel: Model, includeSpec: Record<string, any>, allModels: readonly Model[]): ArrayAggReducerConfig;
|
|
147
|
-
declare function reduceArrayAggRows(rows: any[], config: ArrayAggReducerConfig): any[];
|
|
148
|
-
|
|
149
121
|
interface StreamingWhereInParams {
|
|
150
122
|
segments: WhereInSegment[];
|
|
151
123
|
parentSql: string;
|
|
@@ -154,7 +126,9 @@ interface StreamingWhereInParams {
|
|
|
154
126
|
allModels: readonly Model[];
|
|
155
127
|
modelMap: Map<string, Model>;
|
|
156
128
|
dialect: 'postgres' | 'sqlite';
|
|
157
|
-
execute:
|
|
129
|
+
execute: ExecuteFn;
|
|
130
|
+
stream?: (sql: string, params: unknown[], onRow: (row: any) => void) => Promise<void>;
|
|
131
|
+
parentTake?: number;
|
|
158
132
|
}
|
|
159
133
|
interface PreFetchedWhereInParams {
|
|
160
134
|
segments: WhereInSegment[];
|
|
@@ -163,13 +137,46 @@ interface PreFetchedWhereInParams {
|
|
|
163
137
|
allModels: readonly Model[];
|
|
164
138
|
modelMap: Map<string, Model>;
|
|
165
139
|
dialect: 'postgres' | 'sqlite';
|
|
166
|
-
execute:
|
|
140
|
+
execute: ExecuteFn;
|
|
167
141
|
}
|
|
168
142
|
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
169
143
|
declare function executeWithPreFetchedParents(params: PreFetchedWhereInParams): Promise<any[]>;
|
|
170
144
|
|
|
171
145
|
declare function getPrimaryKeyField(model: Model): string;
|
|
172
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
|
+
|
|
173
180
|
interface ReducerConfig {
|
|
174
181
|
parentModel: Model;
|
|
175
182
|
includedRelations: RelationMetadata[];
|
|
@@ -219,15 +226,37 @@ declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
|
219
226
|
declare function getOrPrepareStatement(client: any, sql: string): any;
|
|
220
227
|
declare function shouldSqliteUseGet(method: string): boolean;
|
|
221
228
|
declare function normalizeParams(params: unknown[]): unknown[];
|
|
222
|
-
|
|
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[]>;
|
|
223
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[];
|
|
224
243
|
declare function executeRaw(client: any, sql: string, params: unknown[] | undefined, dialect: string): Promise<unknown[]>;
|
|
225
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
|
+
|
|
226
259
|
declare function buildSQL(model: Model, models: Model[], method: PrismaMethod, args: Record<string, unknown>, dialect: SqlDialect): SqlResult;
|
|
227
|
-
declare function createToSQL(modelsOrDmmf: Model[] | DMMF.Document, dialect: SqlDialect): (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
|
|
228
|
-
declare function createPrismaSQL<TClient>(config: PrismaSQLConfig<TClient>): PrismaSQLResult<TClient>;
|
|
229
260
|
declare function generateSQL(directive: DirectiveProps): SQLDirective;
|
|
230
|
-
declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
|
|
231
|
-
declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
|
|
232
261
|
|
|
233
|
-
export { type BatchCountQuery, type BatchQuery, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type ReducerConfig, type SqlResult, type TransactionOptions, type TransactionQuery,
|
|
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,8 +24,9 @@ interface SqlResult {
|
|
|
15
24
|
paramMappings?: ParamMapping[];
|
|
16
25
|
requiresReduction?: boolean;
|
|
17
26
|
includeSpec?: Record<string, any>;
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
isLateral?: boolean;
|
|
28
|
+
lateralMeta?: LateralRelationMeta[];
|
|
29
|
+
skipWhereIn?: boolean;
|
|
20
30
|
}
|
|
21
31
|
type PrismaMethod = 'findUnique' | 'findFirst' | 'findMany' | 'create' | 'createMany' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
22
32
|
interface PrismaSQLConfig<TClient> {
|
|
@@ -42,34 +52,12 @@ interface SQLDirective {
|
|
|
42
52
|
paramMappings: readonly ParamMap[];
|
|
43
53
|
requiresReduction: boolean;
|
|
44
54
|
includeSpec: Record<string, any>;
|
|
45
|
-
|
|
55
|
+
isLateral: boolean;
|
|
56
|
+
lateralMeta?: LateralRelationMeta[];
|
|
57
|
+
skipWhereIn?: boolean;
|
|
46
58
|
originalDirective: DirectiveProps;
|
|
47
59
|
}
|
|
48
60
|
|
|
49
|
-
interface BatchQuery {
|
|
50
|
-
model: string;
|
|
51
|
-
method: PrismaMethod;
|
|
52
|
-
args?: Record<string, unknown>;
|
|
53
|
-
}
|
|
54
|
-
interface BatchCountQuery {
|
|
55
|
-
model: string;
|
|
56
|
-
method: 'count';
|
|
57
|
-
args?: {
|
|
58
|
-
where?: Record<string, unknown>;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
interface BatchResult {
|
|
62
|
-
sql: string;
|
|
63
|
-
params: unknown[];
|
|
64
|
-
}
|
|
65
|
-
declare function buildBatchSql(queries: Record<string, BatchQuery>, modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult & {
|
|
66
|
-
keys: string[];
|
|
67
|
-
aliases: string[];
|
|
68
|
-
};
|
|
69
|
-
declare function buildBatchCountSql(queries: BatchCountQuery[], modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult;
|
|
70
|
-
declare function parseBatchCountResults(row: Record<string, unknown>, queryCount: number): number[];
|
|
71
|
-
declare function parseBatchResults(row: Record<string, unknown>, keys: string[], queries: Record<string, BatchQuery>, aliases?: string[], modelMap?: Map<string, Model>): Record<string, unknown>;
|
|
72
|
-
|
|
73
61
|
interface TransactionQuery {
|
|
74
62
|
model: string;
|
|
75
63
|
method: PrismaMethod;
|
|
@@ -99,9 +87,12 @@ interface WhereInSegment {
|
|
|
99
87
|
fkFieldName: string;
|
|
100
88
|
parentKeyFieldName: string;
|
|
101
89
|
isList: boolean;
|
|
90
|
+
perParentTake?: number;
|
|
91
|
+
perParentSkip?: number;
|
|
102
92
|
}
|
|
103
93
|
interface QueryPlan {
|
|
104
94
|
filteredArgs: any;
|
|
95
|
+
originalArgs: any;
|
|
105
96
|
whereInSegments: WhereInSegment[];
|
|
106
97
|
injectedParentKeys: string[];
|
|
107
98
|
}
|
|
@@ -111,8 +102,11 @@ declare function planQueryStrategy(params: {
|
|
|
111
102
|
args: any;
|
|
112
103
|
allModels: readonly Model[];
|
|
113
104
|
dialect: 'postgres' | 'sqlite';
|
|
105
|
+
debug?: boolean;
|
|
114
106
|
}): QueryPlan;
|
|
115
107
|
|
|
108
|
+
type ExecuteFn = (sql: string, params: unknown[]) => Promise<any[]>;
|
|
109
|
+
|
|
116
110
|
interface ExecuteWhereInParams {
|
|
117
111
|
segments: WhereInSegment[];
|
|
118
112
|
parentRows: any[];
|
|
@@ -120,32 +114,10 @@ interface ExecuteWhereInParams {
|
|
|
120
114
|
allModels: readonly Model[];
|
|
121
115
|
modelMap: Map<string, Model>;
|
|
122
116
|
dialect: 'postgres' | 'sqlite';
|
|
123
|
-
execute:
|
|
124
|
-
originalArgs?: any;
|
|
125
|
-
method?: string;
|
|
117
|
+
execute: ExecuteFn;
|
|
126
118
|
}
|
|
127
|
-
|
|
128
119
|
declare function executeWhereInSegments(params: ExecuteWhereInParams): Promise<void>;
|
|
129
120
|
|
|
130
|
-
interface ArrayAggRelationMeta {
|
|
131
|
-
name: string;
|
|
132
|
-
isList: boolean;
|
|
133
|
-
scalarFields: Array<{
|
|
134
|
-
fieldName: string;
|
|
135
|
-
colName: string;
|
|
136
|
-
isJson: boolean;
|
|
137
|
-
}>;
|
|
138
|
-
pkFieldName: string;
|
|
139
|
-
}
|
|
140
|
-
interface ArrayAggReducerConfig {
|
|
141
|
-
parentModel: Model;
|
|
142
|
-
parentScalarFields: string[];
|
|
143
|
-
parentJsonSet: ReadonlySet<string>;
|
|
144
|
-
relations: ArrayAggRelationMeta[];
|
|
145
|
-
}
|
|
146
|
-
declare function buildArrayAggReducerConfig(parentModel: Model, includeSpec: Record<string, any>, allModels: readonly Model[]): ArrayAggReducerConfig;
|
|
147
|
-
declare function reduceArrayAggRows(rows: any[], config: ArrayAggReducerConfig): any[];
|
|
148
|
-
|
|
149
121
|
interface StreamingWhereInParams {
|
|
150
122
|
segments: WhereInSegment[];
|
|
151
123
|
parentSql: string;
|
|
@@ -154,7 +126,9 @@ interface StreamingWhereInParams {
|
|
|
154
126
|
allModels: readonly Model[];
|
|
155
127
|
modelMap: Map<string, Model>;
|
|
156
128
|
dialect: 'postgres' | 'sqlite';
|
|
157
|
-
execute:
|
|
129
|
+
execute: ExecuteFn;
|
|
130
|
+
stream?: (sql: string, params: unknown[], onRow: (row: any) => void) => Promise<void>;
|
|
131
|
+
parentTake?: number;
|
|
158
132
|
}
|
|
159
133
|
interface PreFetchedWhereInParams {
|
|
160
134
|
segments: WhereInSegment[];
|
|
@@ -163,13 +137,46 @@ interface PreFetchedWhereInParams {
|
|
|
163
137
|
allModels: readonly Model[];
|
|
164
138
|
modelMap: Map<string, Model>;
|
|
165
139
|
dialect: 'postgres' | 'sqlite';
|
|
166
|
-
execute:
|
|
140
|
+
execute: ExecuteFn;
|
|
167
141
|
}
|
|
168
142
|
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
169
143
|
declare function executeWithPreFetchedParents(params: PreFetchedWhereInParams): Promise<any[]>;
|
|
170
144
|
|
|
171
145
|
declare function getPrimaryKeyField(model: Model): string;
|
|
172
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
|
+
|
|
173
180
|
interface ReducerConfig {
|
|
174
181
|
parentModel: Model;
|
|
175
182
|
includedRelations: RelationMetadata[];
|
|
@@ -219,15 +226,37 @@ declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
|
219
226
|
declare function getOrPrepareStatement(client: any, sql: string): any;
|
|
220
227
|
declare function shouldSqliteUseGet(method: string): boolean;
|
|
221
228
|
declare function normalizeParams(params: unknown[]): unknown[];
|
|
222
|
-
|
|
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[]>;
|
|
223
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[];
|
|
224
243
|
declare function executeRaw(client: any, sql: string, params: unknown[] | undefined, dialect: string): Promise<unknown[]>;
|
|
225
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
|
+
|
|
226
259
|
declare function buildSQL(model: Model, models: Model[], method: PrismaMethod, args: Record<string, unknown>, dialect: SqlDialect): SqlResult;
|
|
227
|
-
declare function createToSQL(modelsOrDmmf: Model[] | DMMF.Document, dialect: SqlDialect): (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
|
|
228
|
-
declare function createPrismaSQL<TClient>(config: PrismaSQLConfig<TClient>): PrismaSQLResult<TClient>;
|
|
229
260
|
declare function generateSQL(directive: DirectiveProps): SQLDirective;
|
|
230
|
-
declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
|
|
231
|
-
declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
|
|
232
261
|
|
|
233
|
-
export { type BatchCountQuery, type BatchQuery, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type ReducerConfig, type SqlResult, type TransactionOptions, type TransactionQuery,
|
|
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 };
|