prisma-sql 1.63.0 → 1.65.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/index.d.mts CHANGED
@@ -55,7 +55,10 @@ interface PrismaSQLConfig<TClient> {
55
55
  }
56
56
  interface SqlResult {
57
57
  sql: string;
58
- params: unknown[];
58
+ params: readonly unknown[];
59
+ paramMappings?: readonly ParamMap[];
60
+ requiresReduction?: boolean;
61
+ includeSpec?: Record<string, any>;
59
62
  }
60
63
  interface PrismaSQLResult<TClient> {
61
64
  toSQL: (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
@@ -71,6 +74,8 @@ interface SQLDirective {
71
74
  dynamicKeys: string[];
72
75
  paramOrder: string;
73
76
  paramMappings: readonly ParamMap[];
77
+ requiresReduction: boolean;
78
+ includeSpec: Record<string, any>;
74
79
  originalDirective: DirectiveProps;
75
80
  }
76
81
 
@@ -96,6 +101,31 @@ declare function createTransactionExecutor(deps: {
96
101
 
97
102
  declare function transformQueryResults(method: PrismaMethod, results: unknown[]): unknown;
98
103
 
104
+ interface ReducerConfig {
105
+ parentModel: Model;
106
+ includedRelations: RelationMetadata[];
107
+ allModels: readonly Model[];
108
+ }
109
+ interface ScalarColSpec {
110
+ fieldName: string;
111
+ colName: string;
112
+ isJson: boolean;
113
+ }
114
+ interface RelationMetadata {
115
+ name: string;
116
+ cardinality: 'one' | 'many';
117
+ relatedModel: Model;
118
+ primaryKeyFields: string[];
119
+ includeAllScalars: boolean;
120
+ selectedScalarFields: string[];
121
+ nestedIncludes?: ReducerConfig | null;
122
+ path: string;
123
+ keyCols: string[];
124
+ scalarCols: ScalarColSpec[];
125
+ }
126
+ declare function buildReducerConfig(parentModel: Model, includeSpec: Record<string, any>, allModels: readonly Model[], prefix?: string, depth?: number): ReducerConfig;
127
+ declare function reduceFlatRows(rows: any[], config: ReducerConfig): any[];
128
+
99
129
  declare function normalizeValue(value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
100
130
 
101
131
  declare function buildSQL(model: Model, models: Model[], method: PrismaMethod, args: Record<string, unknown>, dialect: SqlDialect): SqlResult;
@@ -105,4 +135,4 @@ declare function generateSQL(directive: DirectiveProps): SQLDirective;
105
135
  declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
106
136
  declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
107
137
 
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 };
138
+ 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, createToSQL, createTransactionExecutor, generateAllSQL, generateSQL, generateSQLByModel, normalizeValue, parseBatchCountResults, parseBatchResults, reduceFlatRows, transformQueryResults };
package/dist/index.d.ts CHANGED
@@ -55,7 +55,10 @@ interface PrismaSQLConfig<TClient> {
55
55
  }
56
56
  interface SqlResult {
57
57
  sql: string;
58
- params: unknown[];
58
+ params: readonly unknown[];
59
+ paramMappings?: readonly ParamMap[];
60
+ requiresReduction?: boolean;
61
+ includeSpec?: Record<string, any>;
59
62
  }
60
63
  interface PrismaSQLResult<TClient> {
61
64
  toSQL: (model: string, method: PrismaMethod, args?: Record<string, unknown>) => SqlResult;
@@ -71,6 +74,8 @@ interface SQLDirective {
71
74
  dynamicKeys: string[];
72
75
  paramOrder: string;
73
76
  paramMappings: readonly ParamMap[];
77
+ requiresReduction: boolean;
78
+ includeSpec: Record<string, any>;
74
79
  originalDirective: DirectiveProps;
75
80
  }
76
81
 
@@ -96,6 +101,31 @@ declare function createTransactionExecutor(deps: {
96
101
 
97
102
  declare function transformQueryResults(method: PrismaMethod, results: unknown[]): unknown;
98
103
 
104
+ interface ReducerConfig {
105
+ parentModel: Model;
106
+ includedRelations: RelationMetadata[];
107
+ allModels: readonly Model[];
108
+ }
109
+ interface ScalarColSpec {
110
+ fieldName: string;
111
+ colName: string;
112
+ isJson: boolean;
113
+ }
114
+ interface RelationMetadata {
115
+ name: string;
116
+ cardinality: 'one' | 'many';
117
+ relatedModel: Model;
118
+ primaryKeyFields: string[];
119
+ includeAllScalars: boolean;
120
+ selectedScalarFields: string[];
121
+ nestedIncludes?: ReducerConfig | null;
122
+ path: string;
123
+ keyCols: string[];
124
+ scalarCols: ScalarColSpec[];
125
+ }
126
+ declare function buildReducerConfig(parentModel: Model, includeSpec: Record<string, any>, allModels: readonly Model[], prefix?: string, depth?: number): ReducerConfig;
127
+ declare function reduceFlatRows(rows: any[], config: ReducerConfig): any[];
128
+
99
129
  declare function normalizeValue(value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
100
130
 
101
131
  declare function buildSQL(model: Model, models: Model[], method: PrismaMethod, args: Record<string, unknown>, dialect: SqlDialect): SqlResult;
@@ -105,4 +135,4 @@ declare function generateSQL(directive: DirectiveProps): SQLDirective;
105
135
  declare function generateAllSQL(directives: DirectiveProps[]): SQLDirective[];
106
136
  declare function generateSQLByModel(directives: DirectiveProps[]): Map<string, SQLDirective[]>;
107
137
 
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 };
138
+ 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, createToSQL, createTransactionExecutor, generateAllSQL, generateSQL, generateSQLByModel, normalizeValue, parseBatchCountResults, parseBatchResults, reduceFlatRows, transformQueryResults };