prisma-sql 1.67.0 → 1.68.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 +562 -203
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +562 -203
- package/dist/generator.js.map +1 -1
- package/dist/index.cjs +1174 -466
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +52 -27
- package/dist/index.d.ts +52 -27
- package/dist/index.js +1171 -467
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -16,6 +16,7 @@ interface SqlResult {
|
|
|
16
16
|
requiresReduction?: boolean;
|
|
17
17
|
includeSpec?: Record<string, any>;
|
|
18
18
|
supportsStreaming?: boolean;
|
|
19
|
+
isArrayAgg?: boolean;
|
|
19
20
|
}
|
|
20
21
|
type PrismaMethod = 'findUnique' | 'findFirst' | 'findMany' | 'create' | 'createMany' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
21
22
|
interface PrismaSQLConfig<TClient> {
|
|
@@ -41,6 +42,7 @@ interface SQLDirective {
|
|
|
41
42
|
paramMappings: readonly ParamMap[];
|
|
42
43
|
requiresReduction: boolean;
|
|
43
44
|
includeSpec: Record<string, any>;
|
|
45
|
+
isArrayAgg: boolean;
|
|
44
46
|
originalDirective: DirectiveProps;
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -90,14 +92,6 @@ declare function createTransactionExecutor(deps: {
|
|
|
90
92
|
|
|
91
93
|
declare function transformQueryResults(method: string, results: unknown): unknown;
|
|
92
94
|
|
|
93
|
-
type RelStats = {
|
|
94
|
-
avg: number;
|
|
95
|
-
p95: number;
|
|
96
|
-
p99: number;
|
|
97
|
-
max: number;
|
|
98
|
-
coverage: number;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
95
|
interface WhereInSegment {
|
|
102
96
|
relationName: string;
|
|
103
97
|
relArgs: unknown;
|
|
@@ -109,14 +103,13 @@ interface WhereInSegment {
|
|
|
109
103
|
interface QueryPlan {
|
|
110
104
|
filteredArgs: any;
|
|
111
105
|
whereInSegments: WhereInSegment[];
|
|
106
|
+
injectedParentKeys: string[];
|
|
112
107
|
}
|
|
113
|
-
type RelationStatsLike = Record<string, Record<string, RelStats>>;
|
|
114
108
|
declare function planQueryStrategy(params: {
|
|
115
109
|
model: Model;
|
|
116
110
|
method: string;
|
|
117
111
|
args: any;
|
|
118
112
|
allModels: readonly Model[];
|
|
119
|
-
relationStats?: RelationStatsLike;
|
|
120
113
|
dialect: 'postgres' | 'sqlite';
|
|
121
114
|
}): QueryPlan;
|
|
122
115
|
|
|
@@ -128,10 +121,55 @@ interface ExecuteWhereInParams {
|
|
|
128
121
|
modelMap: Map<string, Model>;
|
|
129
122
|
dialect: 'postgres' | 'sqlite';
|
|
130
123
|
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
124
|
+
originalArgs?: any;
|
|
125
|
+
method?: string;
|
|
131
126
|
}
|
|
132
127
|
|
|
133
128
|
declare function executeWhereInSegments(params: ExecuteWhereInParams): Promise<void>;
|
|
134
129
|
|
|
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
|
+
interface StreamingWhereInParams {
|
|
150
|
+
segments: WhereInSegment[];
|
|
151
|
+
parentSql: string;
|
|
152
|
+
parentParams: unknown[];
|
|
153
|
+
parentModel: Model;
|
|
154
|
+
allModels: readonly Model[];
|
|
155
|
+
modelMap: Map<string, Model>;
|
|
156
|
+
dialect: 'postgres' | 'sqlite';
|
|
157
|
+
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
158
|
+
}
|
|
159
|
+
interface PreFetchedWhereInParams {
|
|
160
|
+
segments: WhereInSegment[];
|
|
161
|
+
parentRows: any[];
|
|
162
|
+
parentModel: Model;
|
|
163
|
+
allModels: readonly Model[];
|
|
164
|
+
modelMap: Map<string, Model>;
|
|
165
|
+
dialect: 'postgres' | 'sqlite';
|
|
166
|
+
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
167
|
+
}
|
|
168
|
+
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
169
|
+
declare function executeWithPreFetchedParents(params: PreFetchedWhereInParams): Promise<any[]>;
|
|
170
|
+
|
|
171
|
+
declare function getPrimaryKeyField(model: Model): string;
|
|
172
|
+
|
|
135
173
|
interface ReducerConfig {
|
|
136
174
|
parentModel: Model;
|
|
137
175
|
includedRelations: RelationMetadata[];
|
|
@@ -150,6 +188,7 @@ interface RelationMetadata {
|
|
|
150
188
|
includeAllScalars: boolean;
|
|
151
189
|
selectedScalarFields: string[];
|
|
152
190
|
nestedIncludes?: ReducerConfig | null;
|
|
191
|
+
childLimit?: number;
|
|
153
192
|
path: string;
|
|
154
193
|
keyCols: string[];
|
|
155
194
|
scalarCols: ScalarColSpec[];
|
|
@@ -162,7 +201,7 @@ declare function normalizeValue(value: unknown, seen?: WeakSet<object>, depth?:
|
|
|
162
201
|
declare function createStreamingReducer(config: ReducerConfig): {
|
|
163
202
|
processRow(row: any): void;
|
|
164
203
|
getResults(): any[];
|
|
165
|
-
getParentMap(): Map<
|
|
204
|
+
getParentMap(): Map<unknown, any>;
|
|
166
205
|
};
|
|
167
206
|
|
|
168
207
|
interface ProgressiveReducer {
|
|
@@ -173,20 +212,6 @@ interface ProgressiveReducer {
|
|
|
173
212
|
}
|
|
174
213
|
declare function createProgressiveReducer(config: ReducerConfig): ProgressiveReducer;
|
|
175
214
|
|
|
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
215
|
declare function transformAggregateRow(row: any): any;
|
|
191
216
|
declare function extractCountValue(row: any): number | bigint;
|
|
192
217
|
declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
@@ -194,7 +219,7 @@ declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
|
194
219
|
declare function getOrPrepareStatement(client: any, sql: string): any;
|
|
195
220
|
declare function shouldSqliteUseGet(method: string): boolean;
|
|
196
221
|
declare function normalizeParams(params: unknown[]): unknown[];
|
|
197
|
-
declare function executePostgresQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any, allModels: readonly any[]): Promise<unknown[]>;
|
|
222
|
+
declare function executePostgresQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any, allModels: readonly any[], isArrayAgg?: boolean): Promise<unknown[]>;
|
|
198
223
|
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
224
|
declare function executeRaw(client: any, sql: string, params: unknown[] | undefined, dialect: string): Promise<unknown[]>;
|
|
200
225
|
|
|
@@ -205,4 +230,4 @@ declare function generateSQL(directive: DirectiveProps): SQLDirective;
|
|
|
205
230
|
declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
|
|
206
231
|
declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
|
|
207
232
|
|
|
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, 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 };
|
|
233
|
+
export { type BatchCountQuery, type BatchQuery, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type ReducerConfig, type SqlResult, type TransactionOptions, type TransactionQuery, buildArrayAggReducerConfig, buildBatchCountSql, buildBatchSql, buildReducerConfig, buildSQL, createPrismaSQL, createProgressiveReducer, createStreamingReducer, createToSQL, createTransactionExecutor, executePostgresQuery, executeRaw, executeSqliteQuery, executeWhereInSegments, executeWhereInSegmentsStreaming, executeWithPreFetchedParents, extractCountValue, generateAllSQL, generateSQL, generateSQLByModel, getOrPrepareStatement, getPrimaryKeyField, getRowTransformer, normalizeParams, normalizeValue, parseBatchCountResults, parseBatchResults, planQueryStrategy, reduceArrayAggRows, reduceFlatRows, shouldSqliteUseGet, transformAggregateRow, transformQueryResults };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ interface SqlResult {
|
|
|
16
16
|
requiresReduction?: boolean;
|
|
17
17
|
includeSpec?: Record<string, any>;
|
|
18
18
|
supportsStreaming?: boolean;
|
|
19
|
+
isArrayAgg?: boolean;
|
|
19
20
|
}
|
|
20
21
|
type PrismaMethod = 'findUnique' | 'findFirst' | 'findMany' | 'create' | 'createMany' | 'update' | 'updateMany' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
21
22
|
interface PrismaSQLConfig<TClient> {
|
|
@@ -41,6 +42,7 @@ interface SQLDirective {
|
|
|
41
42
|
paramMappings: readonly ParamMap[];
|
|
42
43
|
requiresReduction: boolean;
|
|
43
44
|
includeSpec: Record<string, any>;
|
|
45
|
+
isArrayAgg: boolean;
|
|
44
46
|
originalDirective: DirectiveProps;
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -90,14 +92,6 @@ declare function createTransactionExecutor(deps: {
|
|
|
90
92
|
|
|
91
93
|
declare function transformQueryResults(method: string, results: unknown): unknown;
|
|
92
94
|
|
|
93
|
-
type RelStats = {
|
|
94
|
-
avg: number;
|
|
95
|
-
p95: number;
|
|
96
|
-
p99: number;
|
|
97
|
-
max: number;
|
|
98
|
-
coverage: number;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
95
|
interface WhereInSegment {
|
|
102
96
|
relationName: string;
|
|
103
97
|
relArgs: unknown;
|
|
@@ -109,14 +103,13 @@ interface WhereInSegment {
|
|
|
109
103
|
interface QueryPlan {
|
|
110
104
|
filteredArgs: any;
|
|
111
105
|
whereInSegments: WhereInSegment[];
|
|
106
|
+
injectedParentKeys: string[];
|
|
112
107
|
}
|
|
113
|
-
type RelationStatsLike = Record<string, Record<string, RelStats>>;
|
|
114
108
|
declare function planQueryStrategy(params: {
|
|
115
109
|
model: Model;
|
|
116
110
|
method: string;
|
|
117
111
|
args: any;
|
|
118
112
|
allModels: readonly Model[];
|
|
119
|
-
relationStats?: RelationStatsLike;
|
|
120
113
|
dialect: 'postgres' | 'sqlite';
|
|
121
114
|
}): QueryPlan;
|
|
122
115
|
|
|
@@ -128,10 +121,55 @@ interface ExecuteWhereInParams {
|
|
|
128
121
|
modelMap: Map<string, Model>;
|
|
129
122
|
dialect: 'postgres' | 'sqlite';
|
|
130
123
|
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
124
|
+
originalArgs?: any;
|
|
125
|
+
method?: string;
|
|
131
126
|
}
|
|
132
127
|
|
|
133
128
|
declare function executeWhereInSegments(params: ExecuteWhereInParams): Promise<void>;
|
|
134
129
|
|
|
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
|
+
interface StreamingWhereInParams {
|
|
150
|
+
segments: WhereInSegment[];
|
|
151
|
+
parentSql: string;
|
|
152
|
+
parentParams: unknown[];
|
|
153
|
+
parentModel: Model;
|
|
154
|
+
allModels: readonly Model[];
|
|
155
|
+
modelMap: Map<string, Model>;
|
|
156
|
+
dialect: 'postgres' | 'sqlite';
|
|
157
|
+
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
158
|
+
}
|
|
159
|
+
interface PreFetchedWhereInParams {
|
|
160
|
+
segments: WhereInSegment[];
|
|
161
|
+
parentRows: any[];
|
|
162
|
+
parentModel: Model;
|
|
163
|
+
allModels: readonly Model[];
|
|
164
|
+
modelMap: Map<string, Model>;
|
|
165
|
+
dialect: 'postgres' | 'sqlite';
|
|
166
|
+
execute: (sql: string, params: unknown[]) => Promise<any[]>;
|
|
167
|
+
}
|
|
168
|
+
declare function executeWhereInSegmentsStreaming(params: StreamingWhereInParams): Promise<any[]>;
|
|
169
|
+
declare function executeWithPreFetchedParents(params: PreFetchedWhereInParams): Promise<any[]>;
|
|
170
|
+
|
|
171
|
+
declare function getPrimaryKeyField(model: Model): string;
|
|
172
|
+
|
|
135
173
|
interface ReducerConfig {
|
|
136
174
|
parentModel: Model;
|
|
137
175
|
includedRelations: RelationMetadata[];
|
|
@@ -150,6 +188,7 @@ interface RelationMetadata {
|
|
|
150
188
|
includeAllScalars: boolean;
|
|
151
189
|
selectedScalarFields: string[];
|
|
152
190
|
nestedIncludes?: ReducerConfig | null;
|
|
191
|
+
childLimit?: number;
|
|
153
192
|
path: string;
|
|
154
193
|
keyCols: string[];
|
|
155
194
|
scalarCols: ScalarColSpec[];
|
|
@@ -162,7 +201,7 @@ declare function normalizeValue(value: unknown, seen?: WeakSet<object>, depth?:
|
|
|
162
201
|
declare function createStreamingReducer(config: ReducerConfig): {
|
|
163
202
|
processRow(row: any): void;
|
|
164
203
|
getResults(): any[];
|
|
165
|
-
getParentMap(): Map<
|
|
204
|
+
getParentMap(): Map<unknown, any>;
|
|
166
205
|
};
|
|
167
206
|
|
|
168
207
|
interface ProgressiveReducer {
|
|
@@ -173,20 +212,6 @@ interface ProgressiveReducer {
|
|
|
173
212
|
}
|
|
174
213
|
declare function createProgressiveReducer(config: ReducerConfig): ProgressiveReducer;
|
|
175
214
|
|
|
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
215
|
declare function transformAggregateRow(row: any): any;
|
|
191
216
|
declare function extractCountValue(row: any): number | bigint;
|
|
192
217
|
declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
@@ -194,7 +219,7 @@ declare function getRowTransformer(method: string): ((row: any) => any) | null;
|
|
|
194
219
|
declare function getOrPrepareStatement(client: any, sql: string): any;
|
|
195
220
|
declare function shouldSqliteUseGet(method: string): boolean;
|
|
196
221
|
declare function normalizeParams(params: unknown[]): unknown[];
|
|
197
|
-
declare function executePostgresQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any, allModels: readonly any[]): Promise<unknown[]>;
|
|
222
|
+
declare function executePostgresQuery(client: any, sql: string, params: unknown[], method: string, requiresReduction: boolean, includeSpec: Record<string, any> | undefined, model: any, allModels: readonly any[], isArrayAgg?: boolean): Promise<unknown[]>;
|
|
198
223
|
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
224
|
declare function executeRaw(client: any, sql: string, params: unknown[] | undefined, dialect: string): Promise<unknown[]>;
|
|
200
225
|
|
|
@@ -205,4 +230,4 @@ declare function generateSQL(directive: DirectiveProps): SQLDirective;
|
|
|
205
230
|
declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
|
|
206
231
|
declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
|
|
207
232
|
|
|
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, 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 };
|
|
233
|
+
export { type BatchCountQuery, type BatchQuery, type Model, type PrismaMethod, type PrismaSQLConfig, type PrismaSQLResult, type ReducerConfig, type SqlResult, type TransactionOptions, type TransactionQuery, buildArrayAggReducerConfig, buildBatchCountSql, buildBatchSql, buildReducerConfig, buildSQL, createPrismaSQL, createProgressiveReducer, createStreamingReducer, createToSQL, createTransactionExecutor, executePostgresQuery, executeRaw, executeSqliteQuery, executeWhereInSegments, executeWhereInSegmentsStreaming, executeWithPreFetchedParents, extractCountValue, generateAllSQL, generateSQL, generateSQLByModel, getOrPrepareStatement, getPrimaryKeyField, getRowTransformer, normalizeParams, normalizeValue, parseBatchCountResults, parseBatchResults, planQueryStrategy, reduceArrayAggRows, reduceFlatRows, shouldSqliteUseGet, transformAggregateRow, transformQueryResults };
|