prisma-sql 1.64.0 → 1.66.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 +5701 -1445
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +5691 -1444
- package/dist/generator.js.map +1 -1
- package/dist/index.cjs +3545 -1219
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +143 -49
- package/dist/index.d.ts +143 -49
- package/dist/index.js +3530 -1220
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,66 +1,34 @@
|
|
|
1
|
-
import { ParamMap, DirectiveProps } from '@dee-wan/schema-parser';
|
|
1
|
+
import { Model as Model$1, ParamMap, DirectiveProps } from '@dee-wan/schema-parser';
|
|
2
2
|
import { DMMF } from '@prisma/generator-helper';
|
|
3
3
|
|
|
4
4
|
type SqlDialect = 'postgres' | 'sqlite';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
type Model = Model$1;
|
|
7
|
+
interface ParamMapping {
|
|
8
|
+
index: number;
|
|
9
|
+
dynamicName?: string;
|
|
10
|
+
value?: unknown;
|
|
10
11
|
}
|
|
11
|
-
interface
|
|
12
|
-
model: string;
|
|
13
|
-
method: 'count';
|
|
14
|
-
args?: {
|
|
15
|
-
where?: Record<string, unknown>;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
interface BatchResult {
|
|
12
|
+
interface SqlResult {
|
|
19
13
|
sql: string;
|
|
20
14
|
params: unknown[];
|
|
15
|
+
paramMappings?: ParamMapping[];
|
|
16
|
+
requiresReduction?: boolean;
|
|
17
|
+
includeSpec?: Record<string, any>;
|
|
18
|
+
supportsStreaming?: boolean;
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
keys: string[];
|
|
24
|
-
aliases: string[];
|
|
25
|
-
};
|
|
26
|
-
declare function buildBatchCountSql(queries: BatchCountQuery[], modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult;
|
|
27
|
-
declare function parseBatchCountResults(row: Record<string, unknown>, count: number): number[];
|
|
28
|
-
declare function parseBatchResults(row: Record<string, unknown>, keys: string[], queries: Record<string, BatchQuery>, aliases?: string[], modelMap?: Map<string, Model>): Record<string, unknown>;
|
|
29
|
-
|
|
30
|
-
interface Field {
|
|
31
|
-
name: string;
|
|
32
|
-
dbName: string;
|
|
33
|
-
type: string;
|
|
34
|
-
isRequired: boolean;
|
|
35
|
-
isRelation: boolean;
|
|
36
|
-
isId?: boolean;
|
|
37
|
-
relatedModel?: string;
|
|
38
|
-
relationName?: string;
|
|
39
|
-
foreignKey?: string | string[];
|
|
40
|
-
references?: string | string[];
|
|
41
|
-
isForeignKeyLocal?: boolean;
|
|
42
|
-
}
|
|
43
|
-
interface Model {
|
|
44
|
-
name: string;
|
|
45
|
-
tableName: string;
|
|
46
|
-
fields: Field[];
|
|
47
|
-
}
|
|
48
|
-
type PrismaMethod = 'findMany' | 'findFirst' | 'findUnique' | 'count' | 'aggregate' | 'groupBy';
|
|
20
|
+
type PrismaMethod = 'findUnique' | 'findFirst' | 'findMany' | 'create' | 'createMany' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
49
21
|
interface PrismaSQLConfig<TClient> {
|
|
50
22
|
client: TClient;
|
|
51
23
|
models?: Model[];
|
|
52
|
-
dmmf?:
|
|
53
|
-
dialect:
|
|
24
|
+
dmmf?: any;
|
|
25
|
+
dialect: 'postgres' | 'sqlite';
|
|
54
26
|
execute: (client: TClient, sql: string, params: unknown[]) => Promise<unknown[]>;
|
|
55
27
|
}
|
|
56
|
-
interface SqlResult {
|
|
57
|
-
sql: string;
|
|
58
|
-
params: unknown[];
|
|
59
|
-
}
|
|
60
28
|
interface PrismaSQLResult<TClient> {
|
|
61
29
|
toSQL: (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
|
|
62
30
|
query: <T = unknown[]>(model: string, method: PrismaMethod, args?: Record<string, unknown>) => Promise<T>;
|
|
63
|
-
batchSql: (queries: Record<string,
|
|
31
|
+
batchSql: (queries: Record<string, any>) => SqlResult;
|
|
64
32
|
client: TClient;
|
|
65
33
|
}
|
|
66
34
|
|
|
@@ -71,9 +39,35 @@ interface SQLDirective {
|
|
|
71
39
|
dynamicKeys: string[];
|
|
72
40
|
paramOrder: string;
|
|
73
41
|
paramMappings: readonly ParamMap[];
|
|
42
|
+
requiresReduction: boolean;
|
|
43
|
+
includeSpec: Record<string, any>;
|
|
74
44
|
originalDirective: DirectiveProps;
|
|
75
45
|
}
|
|
76
46
|
|
|
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>, count: 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
|
+
|
|
77
71
|
interface TransactionQuery {
|
|
78
72
|
model: string;
|
|
79
73
|
method: PrismaMethod;
|
|
@@ -94,10 +88,110 @@ declare function createTransactionExecutor(deps: {
|
|
|
94
88
|
postgresClient?: any;
|
|
95
89
|
}): TransactionExecutor;
|
|
96
90
|
|
|
97
|
-
declare function transformQueryResults(method:
|
|
91
|
+
declare function transformQueryResults(method: string, results: unknown): unknown;
|
|
92
|
+
|
|
93
|
+
type RelStats = {
|
|
94
|
+
avg: number;
|
|
95
|
+
p95: number;
|
|
96
|
+
p99: number;
|
|
97
|
+
max: number;
|
|
98
|
+
coverage: number;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
interface WhereInSegment {
|
|
102
|
+
relationName: string;
|
|
103
|
+
relArgs: unknown;
|
|
104
|
+
childModelName: string;
|
|
105
|
+
fkFieldName: string;
|
|
106
|
+
parentKeyFieldName: string;
|
|
107
|
+
isList: boolean;
|
|
108
|
+
}
|
|
109
|
+
interface QueryPlan {
|
|
110
|
+
filteredArgs: any;
|
|
111
|
+
whereInSegments: WhereInSegment[];
|
|
112
|
+
}
|
|
113
|
+
type RelationStatsLike = Record<string, Record<string, RelStats>>;
|
|
114
|
+
declare function planQueryStrategy(params: {
|
|
115
|
+
model: Model;
|
|
116
|
+
method: string;
|
|
117
|
+
args: any;
|
|
118
|
+
allModels: readonly Model[];
|
|
119
|
+
relationStats?: RelationStatsLike;
|
|
120
|
+
dialect: 'postgres' | 'sqlite';
|
|
121
|
+
}): QueryPlan;
|
|
122
|
+
|
|
123
|
+
interface ExecuteWhereInParams {
|
|
124
|
+
segments: WhereInSegment[];
|
|
125
|
+
parentRows: any[];
|
|
126
|
+
parentModel: Model;
|
|
127
|
+
allModels: readonly Model[];
|
|
128
|
+
modelMap: Map<string, Model>;
|
|
129
|
+
dialect: 'postgres' | 'sqlite';
|
|
130
|
+
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare function executeWhereInSegments(params: ExecuteWhereInParams): Promise<void>;
|
|
134
|
+
|
|
135
|
+
interface ReducerConfig {
|
|
136
|
+
parentModel: Model;
|
|
137
|
+
includedRelations: RelationMetadata[];
|
|
138
|
+
allModels: readonly Model[];
|
|
139
|
+
}
|
|
140
|
+
interface ScalarColSpec {
|
|
141
|
+
fieldName: string;
|
|
142
|
+
colName: string;
|
|
143
|
+
isJson: boolean;
|
|
144
|
+
}
|
|
145
|
+
interface RelationMetadata {
|
|
146
|
+
name: string;
|
|
147
|
+
cardinality: 'one' | 'many';
|
|
148
|
+
relatedModel: Model;
|
|
149
|
+
primaryKeyFields: string[];
|
|
150
|
+
includeAllScalars: boolean;
|
|
151
|
+
selectedScalarFields: string[];
|
|
152
|
+
nestedIncludes?: ReducerConfig | null;
|
|
153
|
+
path: string;
|
|
154
|
+
keyCols: string[];
|
|
155
|
+
scalarCols: ScalarColSpec[];
|
|
156
|
+
}
|
|
157
|
+
declare function buildReducerConfig(parentModel: Model, includeSpec: Record<string, any>, allModels: readonly Model[], prefix?: string, depth?: number): ReducerConfig;
|
|
158
|
+
declare function reduceFlatRows(rows: any[], config: ReducerConfig): any[];
|
|
98
159
|
|
|
99
160
|
declare function normalizeValue(value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
|
|
100
161
|
|
|
162
|
+
declare function createStreamingReducer(config: ReducerConfig): {
|
|
163
|
+
processRow(row: any): void;
|
|
164
|
+
getResults(): any[];
|
|
165
|
+
getParentMap(): Map<string, any>;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
interface ProgressiveReducer {
|
|
169
|
+
processRow(row: any): void;
|
|
170
|
+
getCurrentParentKey(row: any): string | null;
|
|
171
|
+
getCompletedParent(parentKey: string): any | null;
|
|
172
|
+
getRemainingParents(): any[];
|
|
173
|
+
}
|
|
174
|
+
declare function createProgressiveReducer(config: ReducerConfig): ProgressiveReducer;
|
|
175
|
+
|
|
176
|
+
interface StreamingWhereInParams extends ExecuteWhereInParams {
|
|
177
|
+
parentSql: string;
|
|
178
|
+
parentParams: unknown[];
|
|
179
|
+
batchSize?: number;
|
|
180
|
+
maxConcurrency?: number;
|
|
181
|
+
}
|
|
182
|
+
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
183
|
+
|
|
184
|
+
declare function transformAggregateRow(row: any): any;
|
|
185
|
+
declare function extractCountValue(row: any): number | bigint;
|
|
186
|
+
declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
187
|
+
|
|
188
|
+
declare function getOrPrepareStatement(client: any, sql: string): any;
|
|
189
|
+
declare function shouldSqliteUseGet(method: string): boolean;
|
|
190
|
+
declare function normalizeParams(params: unknown[]): unknown[];
|
|
191
|
+
declare function executePostgresQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any | undefined, allModels: readonly any[]): Promise<unknown[]>;
|
|
192
|
+
declare function executeSqliteQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any | undefined, allModels: readonly any[]): unknown[];
|
|
193
|
+
declare function executeRaw(client: any, sql: string, params: unknown[] | undefined, dialect: string): Promise<unknown[]>;
|
|
194
|
+
|
|
101
195
|
declare function buildSQL(model: Model, models: Model[], method: PrismaMethod, args: Record<string, unknown>, dialect: SqlDialect): SqlResult;
|
|
102
196
|
declare function createToSQL(modelsOrDmmf: Model[] | DMMF.Document, dialect: SqlDialect): (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
|
|
103
197
|
declare function createPrismaSQL<TClient>(config: PrismaSQLConfig<TClient>): PrismaSQLResult<TClient>;
|
|
@@ -105,4 +199,4 @@ declare function generateSQL(directive: DirectiveProps): SQLDirective;
|
|
|
105
199
|
declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
|
|
106
200
|
declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
|
|
107
201
|
|
|
108
|
-
export { type BatchCountQuery, type BatchQuery, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type SqlResult, type TransactionOptions, type TransactionQuery, buildBatchCountSql, buildBatchSql, buildSQL, createPrismaSQL, createToSQL, createTransactionExecutor, generateAllSQL, generateSQL, generateSQLByModel, normalizeValue, parseBatchCountResults, parseBatchResults, transformQueryResults };
|
|
202
|
+
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, createPrismaSQL, createProgressiveReducer, createStreamingReducer, createToSQL, createTransactionExecutor, executePostgresQuery, executeRaw, executeSqliteQuery, executeWhereInSegments, executeWhereInSegmentsStreaming, extractCountValue, generateAllSQL, generateSQL, generateSQLByModel, getOrPrepareStatement, getRowTransformer, normalizeParams, normalizeValue, parseBatchCountResults, parseBatchResults, planQueryStrategy, reduceFlatRows, shouldSqliteUseGet, transformAggregateRow, transformQueryResults };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,66 +1,34 @@
|
|
|
1
|
-
import { ParamMap, DirectiveProps } from '@dee-wan/schema-parser';
|
|
1
|
+
import { Model as Model$1, ParamMap, DirectiveProps } from '@dee-wan/schema-parser';
|
|
2
2
|
import { DMMF } from '@prisma/generator-helper';
|
|
3
3
|
|
|
4
4
|
type SqlDialect = 'postgres' | 'sqlite';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
type Model = Model$1;
|
|
7
|
+
interface ParamMapping {
|
|
8
|
+
index: number;
|
|
9
|
+
dynamicName?: string;
|
|
10
|
+
value?: unknown;
|
|
10
11
|
}
|
|
11
|
-
interface
|
|
12
|
-
model: string;
|
|
13
|
-
method: 'count';
|
|
14
|
-
args?: {
|
|
15
|
-
where?: Record<string, unknown>;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
interface BatchResult {
|
|
12
|
+
interface SqlResult {
|
|
19
13
|
sql: string;
|
|
20
14
|
params: unknown[];
|
|
15
|
+
paramMappings?: ParamMapping[];
|
|
16
|
+
requiresReduction?: boolean;
|
|
17
|
+
includeSpec?: Record<string, any>;
|
|
18
|
+
supportsStreaming?: boolean;
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
keys: string[];
|
|
24
|
-
aliases: string[];
|
|
25
|
-
};
|
|
26
|
-
declare function buildBatchCountSql(queries: BatchCountQuery[], modelMap: Map<string, Model>, models: Model[], dialect: SqlDialect): BatchResult;
|
|
27
|
-
declare function parseBatchCountResults(row: Record<string, unknown>, count: number): number[];
|
|
28
|
-
declare function parseBatchResults(row: Record<string, unknown>, keys: string[], queries: Record<string, BatchQuery>, aliases?: string[], modelMap?: Map<string, Model>): Record<string, unknown>;
|
|
29
|
-
|
|
30
|
-
interface Field {
|
|
31
|
-
name: string;
|
|
32
|
-
dbName: string;
|
|
33
|
-
type: string;
|
|
34
|
-
isRequired: boolean;
|
|
35
|
-
isRelation: boolean;
|
|
36
|
-
isId?: boolean;
|
|
37
|
-
relatedModel?: string;
|
|
38
|
-
relationName?: string;
|
|
39
|
-
foreignKey?: string | string[];
|
|
40
|
-
references?: string | string[];
|
|
41
|
-
isForeignKeyLocal?: boolean;
|
|
42
|
-
}
|
|
43
|
-
interface Model {
|
|
44
|
-
name: string;
|
|
45
|
-
tableName: string;
|
|
46
|
-
fields: Field[];
|
|
47
|
-
}
|
|
48
|
-
type PrismaMethod = 'findMany' | 'findFirst' | 'findUnique' | 'count' | 'aggregate' | 'groupBy';
|
|
20
|
+
type PrismaMethod = 'findUnique' | 'findFirst' | 'findMany' | 'create' | 'createMany' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
49
21
|
interface PrismaSQLConfig<TClient> {
|
|
50
22
|
client: TClient;
|
|
51
23
|
models?: Model[];
|
|
52
|
-
dmmf?:
|
|
53
|
-
dialect:
|
|
24
|
+
dmmf?: any;
|
|
25
|
+
dialect: 'postgres' | 'sqlite';
|
|
54
26
|
execute: (client: TClient, sql: string, params: unknown[]) => Promise<unknown[]>;
|
|
55
27
|
}
|
|
56
|
-
interface SqlResult {
|
|
57
|
-
sql: string;
|
|
58
|
-
params: unknown[];
|
|
59
|
-
}
|
|
60
28
|
interface PrismaSQLResult<TClient> {
|
|
61
29
|
toSQL: (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
|
|
62
30
|
query: <T = unknown[]>(model: string, method: PrismaMethod, args?: Record<string, unknown>) => Promise<T>;
|
|
63
|
-
batchSql: (queries: Record<string,
|
|
31
|
+
batchSql: (queries: Record<string, any>) => SqlResult;
|
|
64
32
|
client: TClient;
|
|
65
33
|
}
|
|
66
34
|
|
|
@@ -71,9 +39,35 @@ interface SQLDirective {
|
|
|
71
39
|
dynamicKeys: string[];
|
|
72
40
|
paramOrder: string;
|
|
73
41
|
paramMappings: readonly ParamMap[];
|
|
42
|
+
requiresReduction: boolean;
|
|
43
|
+
includeSpec: Record<string, any>;
|
|
74
44
|
originalDirective: DirectiveProps;
|
|
75
45
|
}
|
|
76
46
|
|
|
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>, count: 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
|
+
|
|
77
71
|
interface TransactionQuery {
|
|
78
72
|
model: string;
|
|
79
73
|
method: PrismaMethod;
|
|
@@ -94,10 +88,110 @@ declare function createTransactionExecutor(deps: {
|
|
|
94
88
|
postgresClient?: any;
|
|
95
89
|
}): TransactionExecutor;
|
|
96
90
|
|
|
97
|
-
declare function transformQueryResults(method:
|
|
91
|
+
declare function transformQueryResults(method: string, results: unknown): unknown;
|
|
92
|
+
|
|
93
|
+
type RelStats = {
|
|
94
|
+
avg: number;
|
|
95
|
+
p95: number;
|
|
96
|
+
p99: number;
|
|
97
|
+
max: number;
|
|
98
|
+
coverage: number;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
interface WhereInSegment {
|
|
102
|
+
relationName: string;
|
|
103
|
+
relArgs: unknown;
|
|
104
|
+
childModelName: string;
|
|
105
|
+
fkFieldName: string;
|
|
106
|
+
parentKeyFieldName: string;
|
|
107
|
+
isList: boolean;
|
|
108
|
+
}
|
|
109
|
+
interface QueryPlan {
|
|
110
|
+
filteredArgs: any;
|
|
111
|
+
whereInSegments: WhereInSegment[];
|
|
112
|
+
}
|
|
113
|
+
type RelationStatsLike = Record<string, Record<string, RelStats>>;
|
|
114
|
+
declare function planQueryStrategy(params: {
|
|
115
|
+
model: Model;
|
|
116
|
+
method: string;
|
|
117
|
+
args: any;
|
|
118
|
+
allModels: readonly Model[];
|
|
119
|
+
relationStats?: RelationStatsLike;
|
|
120
|
+
dialect: 'postgres' | 'sqlite';
|
|
121
|
+
}): QueryPlan;
|
|
122
|
+
|
|
123
|
+
interface ExecuteWhereInParams {
|
|
124
|
+
segments: WhereInSegment[];
|
|
125
|
+
parentRows: any[];
|
|
126
|
+
parentModel: Model;
|
|
127
|
+
allModels: readonly Model[];
|
|
128
|
+
modelMap: Map<string, Model>;
|
|
129
|
+
dialect: 'postgres' | 'sqlite';
|
|
130
|
+
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare function executeWhereInSegments(params: ExecuteWhereInParams): Promise<void>;
|
|
134
|
+
|
|
135
|
+
interface ReducerConfig {
|
|
136
|
+
parentModel: Model;
|
|
137
|
+
includedRelations: RelationMetadata[];
|
|
138
|
+
allModels: readonly Model[];
|
|
139
|
+
}
|
|
140
|
+
interface ScalarColSpec {
|
|
141
|
+
fieldName: string;
|
|
142
|
+
colName: string;
|
|
143
|
+
isJson: boolean;
|
|
144
|
+
}
|
|
145
|
+
interface RelationMetadata {
|
|
146
|
+
name: string;
|
|
147
|
+
cardinality: 'one' | 'many';
|
|
148
|
+
relatedModel: Model;
|
|
149
|
+
primaryKeyFields: string[];
|
|
150
|
+
includeAllScalars: boolean;
|
|
151
|
+
selectedScalarFields: string[];
|
|
152
|
+
nestedIncludes?: ReducerConfig | null;
|
|
153
|
+
path: string;
|
|
154
|
+
keyCols: string[];
|
|
155
|
+
scalarCols: ScalarColSpec[];
|
|
156
|
+
}
|
|
157
|
+
declare function buildReducerConfig(parentModel: Model, includeSpec: Record<string, any>, allModels: readonly Model[], prefix?: string, depth?: number): ReducerConfig;
|
|
158
|
+
declare function reduceFlatRows(rows: any[], config: ReducerConfig): any[];
|
|
98
159
|
|
|
99
160
|
declare function normalizeValue(value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
|
|
100
161
|
|
|
162
|
+
declare function createStreamingReducer(config: ReducerConfig): {
|
|
163
|
+
processRow(row: any): void;
|
|
164
|
+
getResults(): any[];
|
|
165
|
+
getParentMap(): Map<string, any>;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
interface ProgressiveReducer {
|
|
169
|
+
processRow(row: any): void;
|
|
170
|
+
getCurrentParentKey(row: any): string | null;
|
|
171
|
+
getCompletedParent(parentKey: string): any | null;
|
|
172
|
+
getRemainingParents(): any[];
|
|
173
|
+
}
|
|
174
|
+
declare function createProgressiveReducer(config: ReducerConfig): ProgressiveReducer;
|
|
175
|
+
|
|
176
|
+
interface StreamingWhereInParams extends ExecuteWhereInParams {
|
|
177
|
+
parentSql: string;
|
|
178
|
+
parentParams: unknown[];
|
|
179
|
+
batchSize?: number;
|
|
180
|
+
maxConcurrency?: number;
|
|
181
|
+
}
|
|
182
|
+
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
183
|
+
|
|
184
|
+
declare function transformAggregateRow(row: any): any;
|
|
185
|
+
declare function extractCountValue(row: any): number | bigint;
|
|
186
|
+
declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
187
|
+
|
|
188
|
+
declare function getOrPrepareStatement(client: any, sql: string): any;
|
|
189
|
+
declare function shouldSqliteUseGet(method: string): boolean;
|
|
190
|
+
declare function normalizeParams(params: unknown[]): unknown[];
|
|
191
|
+
declare function executePostgresQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any | undefined, allModels: readonly any[]): Promise<unknown[]>;
|
|
192
|
+
declare function executeSqliteQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any | undefined, allModels: readonly any[]): unknown[];
|
|
193
|
+
declare function executeRaw(client: any, sql: string, params: unknown[] | undefined, dialect: string): Promise<unknown[]>;
|
|
194
|
+
|
|
101
195
|
declare function buildSQL(model: Model, models: Model[], method: PrismaMethod, args: Record<string, unknown>, dialect: SqlDialect): SqlResult;
|
|
102
196
|
declare function createToSQL(modelsOrDmmf: Model[] | DMMF.Document, dialect: SqlDialect): (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
|
|
103
197
|
declare function createPrismaSQL<TClient>(config: PrismaSQLConfig<TClient>): PrismaSQLResult<TClient>;
|
|
@@ -105,4 +199,4 @@ declare function generateSQL(directive: DirectiveProps): SQLDirective;
|
|
|
105
199
|
declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
|
|
106
200
|
declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
|
|
107
201
|
|
|
108
|
-
export { type BatchCountQuery, type BatchQuery, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type SqlResult, type TransactionOptions, type TransactionQuery, buildBatchCountSql, buildBatchSql, buildSQL, createPrismaSQL, createToSQL, createTransactionExecutor, generateAllSQL, generateSQL, generateSQLByModel, normalizeValue, parseBatchCountResults, parseBatchResults, transformQueryResults };
|
|
202
|
+
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, createPrismaSQL, createProgressiveReducer, createStreamingReducer, createToSQL, createTransactionExecutor, executePostgresQuery, executeRaw, executeSqliteQuery, executeWhereInSegments, executeWhereInSegmentsStreaming, extractCountValue, generateAllSQL, generateSQL, generateSQLByModel, getOrPrepareStatement, getRowTransformer, normalizeParams, normalizeValue, parseBatchCountResults, parseBatchResults, planQueryStrategy, reduceFlatRows, shouldSqliteUseGet, transformAggregateRow, transformQueryResults };
|