@prisma/client-engine-runtime 7.10.0-dev.4 → 7.10.0-dev.41

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.
@@ -1,7 +1,7 @@
1
1
  import { ConnectionInfo, SqlQueryable, SqlResultSet } from '@prisma/driver-adapter-utils';
2
2
  import type { SqlCommenterPlugin, SqlCommenterQueryInfo } from '@prisma/sqlcommenter';
3
3
  import { QueryEvent } from '../events';
4
- import { QueryPlanNode } from '../query-plan';
4
+ import { ImpureQueryPlanNode, PureQueryPlanNode, QueryPlanNode } from '../query-plan';
5
5
  import { type SchemaProvider } from '../schema';
6
6
  import { type TracingHelper } from '../tracing';
7
7
  import { type TransactionManager } from '../transaction-manager/transaction-manager';
@@ -43,3 +43,22 @@ export declare class QueryInterpreter {
43
43
  run(queryPlan: DeepReadonly<QueryPlanNode>, options: QueryRuntimeOptions): Promise<unknown>;
44
44
  private interpretNode;
45
45
  }
46
+ type IntermediateValue = {
47
+ value: Value;
48
+ lastInsertId?: string;
49
+ };
50
+ /**
51
+ * Attempts to convert a query plan into a pure one by finding the single impure node
52
+ * that is unconditionally evaluated exactly once, evaluating it eagerly via `evalNode`,
53
+ * and substituting its result into the plan as a constant. The remaining plan can then
54
+ * be interpreted synchronously.
55
+ *
56
+ * Returns `undefined` if the plan cannot be purified this way (it contains no impure
57
+ * nodes, more than one of them, or unsupported constructs).
58
+ *
59
+ * Query plans are cached and shared between requests, so the input plan is never
60
+ * modified; the returned plan shares all unaffected subtrees with the input and only
61
+ * copies the nodes on the path to the substituted one.
62
+ */
63
+ export declare function purifyQueryPlan(node: DeepReadonly<QueryPlanNode>, evalNode: (node: DeepReadonly<ImpureQueryPlanNode>) => Promise<IntermediateValue>): Promise<DeepReadonly<PureQueryPlanNode>> | undefined;
64
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -76,12 +76,24 @@ export type JoinExpression = {
76
76
  parentField: string;
77
77
  isRelationUnique: boolean;
78
78
  };
79
- export type QueryPlanNode = {
79
+ /**
80
+ * Query plan nodes that are free of side effects and can be interpreted synchronously
81
+ * without touching the database. The `Rest` parameter controls what other nodes may
82
+ * appear in child positions: with the default `never` the tree is fully pure, while
83
+ * `PureQueryPlanNode<ImpureQueryPlanNode>` describes a tree of pure nodes that may
84
+ * contain impure nodes anywhere inside.
85
+ */
86
+ export type PureQueryPlanNode<Rest = never> = {
80
87
  type: 'value';
81
88
  args: PrismaValue;
89
+ /**
90
+ * Present when this node is the result of evaluating an impure node during
91
+ * query plan purification. Never produced by the query compiler.
92
+ */
93
+ lastInsertId?: string;
82
94
  } | {
83
95
  type: 'seq';
84
- args: QueryPlanNode[];
96
+ args: (PureQueryPlanNode<Rest> | Rest)[];
85
97
  } | {
86
98
  type: 'get';
87
99
  args: {
@@ -90,100 +102,118 @@ export type QueryPlanNode = {
90
102
  } | {
91
103
  type: 'let';
92
104
  args: {
93
- bindings: QueryPlanBinding[];
94
- expr: QueryPlanNode;
105
+ bindings: {
106
+ name: string;
107
+ expr: PureQueryPlanNode<Rest> | Rest;
108
+ }[];
109
+ expr: PureQueryPlanNode<Rest> | Rest;
95
110
  };
96
111
  } | {
97
112
  type: 'getFirstNonEmpty';
98
113
  args: {
99
114
  names: string[];
100
115
  };
101
- } | {
102
- type: 'query';
103
- args: QueryPlanDbQuery;
104
- } | {
105
- type: 'execute';
106
- args: QueryPlanDbQuery;
107
116
  } | {
108
117
  type: 'reverse';
109
- args: QueryPlanNode;
118
+ args: PureQueryPlanNode<Rest> | Rest;
110
119
  } | {
111
120
  type: 'sum';
112
- args: QueryPlanNode[];
121
+ args: (PureQueryPlanNode<Rest> | Rest)[];
113
122
  } | {
114
123
  type: 'concat';
115
- args: QueryPlanNode[];
124
+ args: (PureQueryPlanNode<Rest> | Rest)[];
116
125
  } | {
117
126
  type: 'unique';
118
- args: QueryPlanNode;
127
+ args: PureQueryPlanNode<Rest> | Rest;
119
128
  } | {
120
129
  type: 'required';
121
- args: QueryPlanNode;
130
+ args: PureQueryPlanNode<Rest> | Rest;
122
131
  } | {
123
132
  type: 'join';
124
133
  args: {
125
- parent: QueryPlanNode;
126
- children: JoinExpression[];
134
+ parent: PureQueryPlanNode<Rest> | Rest;
135
+ children: {
136
+ child: PureQueryPlanNode<Rest> | Rest;
137
+ on: [left: string, right: string][];
138
+ parentField: string;
139
+ isRelationUnique: boolean;
140
+ }[];
127
141
  canAssumeStrictEquality: boolean;
128
142
  };
129
143
  } | {
130
144
  type: 'mapField';
131
145
  args: {
132
146
  field: string;
133
- records: QueryPlanNode;
147
+ records: PureQueryPlanNode<Rest> | Rest;
134
148
  };
135
- } | {
136
- type: 'transaction';
137
- args: QueryPlanNode;
138
149
  } | {
139
150
  type: 'dataMap';
140
151
  args: {
141
- expr: QueryPlanNode;
152
+ expr: PureQueryPlanNode<Rest> | Rest;
142
153
  structure: ResultNode;
143
154
  enums: Record<string, Record<string, string>>;
144
155
  };
145
156
  } | {
146
157
  type: 'validate';
147
158
  args: {
148
- expr: QueryPlanNode;
159
+ expr: PureQueryPlanNode<Rest> | Rest;
149
160
  rules: DataRule[];
150
161
  } & ValidationError;
151
162
  } | {
152
163
  type: 'if';
153
164
  args: {
154
- value: QueryPlanNode;
165
+ value: PureQueryPlanNode<Rest> | Rest;
155
166
  rule: DataRule;
156
- then: QueryPlanNode;
157
- else: QueryPlanNode;
167
+ then: PureQueryPlanNode<Rest> | Rest;
168
+ else: PureQueryPlanNode<Rest> | Rest;
158
169
  };
159
170
  } | {
160
171
  type: 'unit';
161
172
  } | {
162
173
  type: 'diff';
163
174
  args: {
164
- from: QueryPlanNode;
165
- to: QueryPlanNode;
175
+ from: PureQueryPlanNode<Rest> | Rest;
176
+ to: PureQueryPlanNode<Rest> | Rest;
166
177
  fields: string[];
167
178
  };
168
179
  } | {
169
180
  type: 'initializeRecord';
170
181
  args: {
171
- expr: QueryPlanNode;
182
+ expr: PureQueryPlanNode<Rest> | Rest;
172
183
  fields: Record<string, FieldInitializer>;
173
184
  };
174
185
  } | {
175
186
  type: 'mapRecord';
176
187
  args: {
177
- expr: QueryPlanNode;
188
+ expr: PureQueryPlanNode<Rest> | Rest;
178
189
  fields: Record<string, FieldOperation>;
179
190
  };
180
191
  } | {
181
192
  type: 'process';
182
193
  args: {
183
- expr: QueryPlanNode;
194
+ expr: PureQueryPlanNode<Rest> | Rest;
184
195
  operations: InMemoryOps;
185
196
  };
186
197
  };
198
+ /**
199
+ * Query plan nodes that perform database I/O: individual queries and statements,
200
+ * and subtrees executed within a transaction.
201
+ */
202
+ export type ImpureQueryPlanNode = {
203
+ type: 'query';
204
+ args: QueryPlanDbQuery;
205
+ } | {
206
+ type: 'execute';
207
+ args: QueryPlanDbQuery;
208
+ } | {
209
+ type: 'transaction';
210
+ args: QueryPlanNode;
211
+ };
212
+ /**
213
+ * A query plan as emitted by the query compiler: a tree of pure nodes that may
214
+ * contain impure nodes anywhere inside.
215
+ */
216
+ export type QueryPlanNode = ImpureQueryPlanNode | PureQueryPlanNode<ImpureQueryPlanNode>;
187
217
  export type FieldInitializer = {
188
218
  type: 'value';
189
219
  value: PrismaValue;
package/dist/utils.d.ts CHANGED
@@ -4,6 +4,16 @@ export type DeepReadonly<T> = T extends undefined | null | boolean | string | nu
4
4
  export type DeepUnreadonly<T> = T extends undefined | null | boolean | string | number | symbol | Function | Date ? T : T extends ReadonlyArray<infer U> ? Array<DeepUnreadonly<U>> : unknown extends T ? unknown : {
5
5
  -readonly [K in keyof T]: DeepUnreadonly<T[K]>;
6
6
  };
7
+ /**
8
+ * Cross-realm safe check for Uint8Array. `instanceof Uint8Array` fails when the value
9
+ * was created in a different realm (e.g. jsdom, iframes, vm contexts).
10
+ */
11
+ export declare function isUint8Array(value: unknown): value is Uint8Array;
12
+ /**
13
+ * Cross-realm safe check for Date. `instanceof Date` fails when the value
14
+ * was created in a different realm (e.g. jsdom, iframes, vm contexts).
15
+ */
16
+ export declare function isDate(value: unknown): value is Date;
7
17
  export declare function assertNever(_: never, message: string): never;
8
18
  /**
9
19
  * Checks if two objects are deeply equal, recursively checking all properties for strict equality.
@@ -20,3 +30,8 @@ export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
20
30
  * BigInt and Uint8Array values.
21
31
  */
22
32
  export declare function safeJsonStringify(obj: unknown): string;
33
+ /**
34
+ * Appends all elements of `source` to `target` without spreading the whole
35
+ * array as call arguments, which overflows the stack for large arrays.
36
+ */
37
+ export declare function appendToArray<T>(target: T[], source: readonly T[]): void;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "7.10.0-dev.4",
3
+ "version": "7.10.0-dev.41",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -26,25 +26,25 @@
26
26
  "dependencies": {
27
27
  "@bugsnag/cuid": "3.2.1",
28
28
  "@opentelemetry/api": "1.9.0",
29
- "@paralleldrive/cuid2": "2.2.2",
29
+ "@paralleldrive/cuid2": "3.3.0",
30
30
  "klona": "2.0.6",
31
31
  "nanoid": "5.1.5",
32
32
  "ulid": "3.0.0",
33
33
  "uuid": "14.0.0",
34
- "@prisma/client-runtime-utils": "7.10.0-dev.4",
35
- "@prisma/debug": "7.10.0-dev.4",
36
- "@prisma/driver-adapter-utils": "7.10.0-dev.4",
37
- "@prisma/sqlcommenter": "7.10.0-dev.4",
38
- "@prisma/param-graph": "7.10.0-dev.4",
39
- "@prisma/json-protocol": "7.10.0-dev.4"
34
+ "@prisma/client-runtime-utils": "7.10.0-dev.41",
35
+ "@prisma/debug": "7.10.0-dev.41",
36
+ "@prisma/driver-adapter-utils": "7.10.0-dev.41",
37
+ "@prisma/sqlcommenter": "7.10.0-dev.41",
38
+ "@prisma/param-graph": "7.10.0-dev.41",
39
+ "@prisma/json-protocol": "7.10.0-dev.41"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@codspeed/benchmark.js-plugin": "4.0.0",
43
43
  "@types/benchmark": "2.1.5",
44
44
  "@types/node": "~20.19.24",
45
45
  "benchmark": "2.1.4",
46
- "@prisma/get-dmmf": "7.10.0-dev.4",
47
- "@prisma/param-graph-builder": "7.10.0-dev.4"
46
+ "@prisma/param-graph-builder": "7.10.0-dev.41",
47
+ "@prisma/get-dmmf": "7.10.0-dev.41"
48
48
  },
49
49
  "files": [
50
50
  "dist"